Hello, I have a bunch of problems with linking of entities.
My language files have two endings:
.ttp and .tts
Every file is in the same directory:
_global.tt
file1.ttp
file2.tts
file3.tts
Now I am trying to inherit file2 and from file1, file3 is "standalone":
file2:
INHERIT file1; //note that I don't want to write "file1.ttp", this should be found automatically
Grammar:
InheritPart: "INHERIT" importURI=ID ";";
The filename is the classname, but it's not explicitly written in the code. Is there a way to reference to a file?
I also have global and local variables. A global variable should be accessible in all files, whereas local variables should only be accessible in its file and all inherited files.
Full example:
file1:
VAR
localVar : INT;
END_VAR
VAR GLOBAL
globalVar : INT;
END_VAR
local := 42;
globalVar := 42;
//standaloneVar := 42; //should not work
file2:
INHERIT file1;
local := 42;
globalVar := 42;
//standaloneVar := 42; //should not work
file3:
VAR
standaloneVar : INT;
END_VAR
//local := 42; //should not work
globalVar := 42;
standaloneVar := 42;
Now I don't understand which scoping / name Fragments I should use. I also don't want to loose the AbstractDeclarativeScopeProvider, because I have implemented stuff with it.
At the moment I am using this:
// Xtend-based API for validation
fragment = validation.ValidatorFragment auto-inject {
// composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" //when I'm activating this, every ID in my testfile "Imported resource could not be found."
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
// old scoping and exporting API
fragment = scoping.ImportURIScopingFragment auto-inject {}
// fragment = exporting.SimpleNamesFragment auto-inject {}
// scoping and exporting API
fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
fragment = exporting.QualifiedNamesFragment auto-inject {}
// fragment = types.TypesGeneratorFragment auto-inject {}
I also tried to implement my own URI resolver, but that also has no impact:
public class TeachTalkImportUriResolver extends ImportUriResolver {
@Override
public String resolve(EObject object) {
return "platform:/resource/projectname/_global.tt/"+super.resolve(object)+".ttp"; // or .tts ???
}
}
public class TeachTalkRuntimeModule extends com.engel.teachtalk.teachtalk.AbstractTeachTalkRuntimeModule {
@Override
public Class<? extends IValueConverterService> bindIValueConverterService() {
return MyValueConverter.class;
}
@Override
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return TeachTalkSimpleNameProvider.class;
}
public Class<? extends ImportUriResolver> bindImportUriResolver() {
return TeachTalkImportUriResolver.class;
}
}
Do you have some tips for me how to combine these requirements?
PS: When I have a big project (600 files) the reference checking is very slow (10min+). I am guessing that scoping reduces this problem?
Thanks in advance,
Martin
[Updated on: Wed, 14 August 2013 05:13]
Report message to a moderator