Content Assist Problem in the second Grammar [message #1800972] |
Thu, 10 January 2019 08:46  |
Eclipse User |
|
|
|
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?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05654 seconds