Content Assist Problem in the second Grammar [message #1800972] |
Thu, 10 January 2019 13:46 |
Mehmetcan Sinir Messages: 55 Registered: September 2018 |
Member |
|
|
I have two XText Grammars (Grammar1 and Grammar2) and the following mwe2 workflow
Workflow {
component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "base"
rootPath = rootPath
runtimeTest = {
enabled = true
}
genericIde = {
enabled = true
}
mavenLayout = true
}
code = {
encoding = "UTF-8"
lineDelimiter = "\n"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
/* Custom `XtextGeneratorLanguage` instead of StandardLanguage:
* - omit `GeneratorFragment2` because custom generators are used
* - omit unnecessary IDE fragments
*/
language = XtextGeneratorLanguage {
grammarUri = grammar1.xtext
name = "org.xtext.grammar1"
fileExtensions = "grammar1"
referencedResource = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
fragment = grammarAccess.GrammarAccessFragment2 {}
fragment = ecore.EMFGeneratorFragment2 {}
fragment = serializer.SerializerFragment2 {}
fragment = resourceFactory.ResourceFactoryFragment2 {}
fragment = parser.antlr.XtextAntlrGeneratorFragment2 {}
fragment = validation.ValidatorFragment2 {}
fragment = scoping.ImportNamespacesScopingFragment2 {}
fragment = index.ResourceDescriptionStrategyFragment {}
fragment = exporting.QualifiedNamesFragment2 {}
fragment = builder.BuilderIntegrationFragment2 {}
fragment = formatting.Formatter2Fragment2 {}
fragment = ui.labeling.LabelProviderFragment2 {}
fragment = ui.outline.QuickOutlineFragment2 {}
fragment = ui.outline.OutlineTreeProviderFragment2 {}
fragment = ui.quickfix.QuickfixProviderFragment2 {}
fragment = ui.contentAssist.ContentAssistFragment2 {}
fragment = junit.JUnitFragment {}
fragment = ui.refactoring.RefactorElementNameFragment2 {}
fragment = ui.templates.CodetemplatesGeneratorFragment2 {}
fragment = types.TypesGeneratorFragment2 {}
fragment = xbase.XtypeGeneratorFragment2 {}
fragment = xbase.XbaseGeneratorFragment2 {}
fragment = ui.compare.CompareFragment2 {}
}
language = XtextGeneratorLanguage {
grammarUri = grammarURI
referencedResource = "platform:/resource/org/xtext/grammar1.xtext"
name = "org.xtext.grammar2"
fileExtensions = "grammar2"
referencedResource = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
fragment = grammarAccess.GrammarAccessFragment2 {}
fragment = ecore.EMFGeneratorFragment2 {}
fragment = serializer.SerializerFragment2 {}
fragment = resourceFactory.ResourceFactoryFragment2 {}
fragment = parser.antlr.XtextAntlrGeneratorFragment2 {}
fragment = validation.ValidatorFragment2 {
inheritImplementation = false
}
fragment = scoping.ImportNamespacesScopingFragment2 {
generateXtendStub = false
}
fragment = index.ResourceDescriptionStrategyFragment {}
fragment = exporting.QualifiedNamesFragment2 {}
fragment = builder.BuilderIntegrationFragment2 {}
fragment = formatting.Formatter2Fragment2 {}
fragment = ui.labeling.LabelProviderFragment2 {}
fragment = ui.outline.QuickOutlineFragment2 {}
fragment = ui.outline.OutlineTreeProviderFragment2 {}
fragment = ui.quickfix.QuickfixProviderFragment2 {}
fragment = xbase.XtypeGeneratorFragment2 {}
fragment = xbase.XbaseGeneratorFragment2 {}
fragment = ui.contentAssist.ContentAssistFragment2 {}
fragment = junit.JUnitFragment {}
fragment = ui.refactoring.RefactorElementNameFragment2 {}
fragment = ui.templates.CodetemplatesGeneratorFragment2 {}
fragment = ui.compare.CompareFragment2 {}
fragment = types.TypesGeneratorFragment2 {}
}
}
}
The Content Assist for Grammar2 is working, but Content Assist for Grammar1 is not working.
After debugging, I realized that the entryPoint in the XTextResource Representing the first grammar is null. That is why content assist fails.
More specifically, this is where the two grammars differ in term of content assist:
This code is from org.eclipse.xtext.resource.XTextResource
public ParserRule getEntryPoint() {
if (entryPoint == null && parseResult != null) {
entryPoint = NodeModelUtils.getEntryParserRule(parseResult.getRootNode());
}
return entryPoint;
}
for the grammar1, the entryPoint is null and so XText resource creates a new one, however, it doesn't match the first rule in the ruleSet, so contentAssist fails
for grammar2, the entryPoint is never null, so content assist always works
I realize that this has been a rather too technical question, but perhaps I am missing something obvious here, why is the entryPoint of the XTextResource representing Grammar1 null?
|
|
|
|
|
|
|
|
|
|
|
|
Re: Content Assist Problem in the second Grammar [message #1801067 is a reply to message #1801066] |
Fri, 11 January 2019 20:12 |
Mehmetcan Sinir Messages: 55 Registered: September 2018 |
Member |
|
|
IT works! Thanks alot!!!! That has been very helpful.
There doesn't seem to be any side effects. Validation is still working. Everything seems to work. Debug doesn't show anything.
The XTextServiceLoader already calls createInjectorAndDoEmfReg for all ISetup Classes in the ISetup File. So the required doSetups are already called for every grammar.
So a second call inside the HouseStandAloneSetup loads the person grammar a second time by calling doSetup.
This is an XText bug and probably needs to be fixed with version 2.17=)
Thanks again
[Updated on: Fri, 11 January 2019 20:15] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06742 seconds