Community
Participate
Working Groups
Build Identifier: 20110615-0604 The class Internal<DSL>Parser, which gets generated in the UI-Plug-In of Xtext projects contains some strange imports, like org.eclipse.xtext.parsetree.*; When building this Plug-In via Command Line (javac –classpath…), the import of the empty package cannot be resolved: src-gen\org\example\mydsl\ui\contentassist\antlr\internal\InternalMyDSLParser.java:7: package org.eclipse.xtext.parsetree does not exist import org.eclipse.xtext.parsetree.*; ^ 1 error After manually optimizing Imports in InternalMyDSLParser.java, building works fine. Therefore I would consider it a good idea to automatically optimize Imports of the generated Code. As far as I know, EMF and GMF do so by default. Reproducible: Always
Hi Ralph, I'm pretty sure your installation in inconsistent. The generator does not match the other Xtext plugins. The code generated by Xtext is compile clean. Please double check the versions of the installed plugins and make sure that you only have one version of Xtext installed. Feel free to reopen the bug if I missed your point. The import section of a correctly generated parser looks like this: import org.eclipse.xtext.*; import org.eclipse.xtext.parser.*; import org.eclipse.xtext.parser.impl.*; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; import org.eclipse.xtext.parser.antlr.XtextTokenStream; import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; import <YourPackage>.<YourLang>GrammarAccess; import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList;
Hi, thanks for the quick response! The difference in the imports seems to be caused by the generator fragment: Using parser.antlr.XtextAntlrUiGeneratorFragment, i get the following imports in the Internal<DSL>Parser, which leads to the problem described: import java.io.InputStream; import org.eclipse.xtext.*; import org.eclipse.xtext.parser.*; import org.eclipse.xtext.parser.impl.*; import org.eclipse.xtext.parsetree.*; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.parser.antlr.XtextTokenStream; import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; import org.eclipse.xtext.ui.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser; import org.eclipse.xtext.ui.editor.contentassist.antlr.internal.DFA; import <...>.<DSL>GrammarAccess; import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; Using the org.eclipse.xtext.generator.parser.antlr.ex.rt.AntlrGeneratorFragment on the other hand, i get the imports you described: import org.eclipse.xtext.*; import org.eclipse.xtext.parser.*; import org.eclipse.xtext.parser.impl.*; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; import org.eclipse.xtext.parser.antlr.XtextTokenStream; import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; import <...>.<DSL>GrammarAccess; import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; Unfortunately, when using the org.eclipse.xtext.generator.parser.antlr.ex.rt.AntlrGeneratorFragment, content assist does generally not seem to work for my languge...
Thanks for the clarification.
Created attachment 200050 [details] proposed fix removing the unused import The attached fix removes the unnecessary import from the generator template.
Thanks for the report. Pushed fix to master for SR1.
Closing all bugs that were set to RESOLVED before Neon.0