parsing - Xtext Grammar mixins result in Guice injection error -
I am writing an extact grammar which can access documents declared before a function.
Our current grammar defines with I have now created a second Xtext project with the following grammar: I have created dependency in the plugin and added this to now my thirty Ministers plugin project, I standalone fashion want to use the parser in a So I created the following Parsr file (based on the example :): However, when I try to run it, I get the guise injection errors, such as I know that the parser should be "correct", since I use OriginalGrammarStandaloneSetup, it works perfectly well. You must ensure that your sub-section also invites the standalone setup of your super language Usually this is generated in the The hidden (ML_COMMENT, SL_COMMENT, ...) :
ML_COMMENT: '/ *' - & Gt; '* /' SL_COMMENT: '//' - & gt; EOL
my.OriginalGrammar HID (WS, FUNCTION_BODY with grammar my.DocumentationGrammar , EOL, SL_COMMENT) "http://www.originalGrammar.my" documentation to import Grammar "http://www.documentationGrammar.my" / * Parser Rule * / translate: eds + = DoxExternalDefinition *; DoxExternalDefinition: def = Definition | Lib = CtrlLibUsage | Comment = ML_COMMENT; FunctionDefinition: aml = AccessModifiersList ts = TypeSpecifier? F = function '(' pl = parameter type list? ')' / * Cs = compound statement / / // compound statement is ignored; // Terminal DOXYGEN_COMMENT: ML_COMMENT; Terminal FUNCTION_BODY: '{' - & gt; '}';
beam = standaloneSetup {scanClassPath = true platformUri = "$ {runtimeProject} / The following two lines can be removed if the Xbase has not been used registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage" registerGenModelFile = "forum: /resource/org.eclipse.xtext.xbase //model/Xbase.genmodel/ "// We need to register super.generatedEPackage to super genmodel =" my.OriginalGrammar. OriginalGrammarPackage "registerGenModelFile =" forum: /resource/my.OriginalGrammar/model/generated/OriginalGrammar.genmodel "}
import java.io.IOException; Import java.io.Reader; Import java.nio.file.Path; Import org.eclipse.emf.common.util.URI; Import org.eclipse.emf.ecore.EObject; Import org.eclipse.emf.ecore.resource.Resource; Import org.eclipse.xtext.parser.IParseResult; Import org.eclipse.xtext.parser.IParser; Import org.eclipse.xtext.parser.ParseException; Import org.eclipse.xtext.resource.XtextResource; Import org.eclipse.xtext.resource.XtextResourceSet; Import my.DocumentationGrammar.DocumentationGrammarStandaloneSetup; Import com.google.inject.Inject; Import com.google.inject.Injector; People class DoxygenParser {@Inject Private IParser parser; Private Injector Injector; Public DoxygenParser () {setupParser (); } Private Zero Setup Parser () {Injector = New Document Grammar StdLon Setup () CreateInjectorAndDoEMFRegistration (); Injector.injectMembers (this); } / ** * Using an extext parses the data provided by an input reader and returns the root tree of the object tree as a result. * @The Ultimate Reader Input Reader * Returns Root Object Node * @ Throw IOE Exceptions When the error occurs during the parsing process * / Public eObaked Pars (Reader Reader) throws IOException {IParseResult result = parser.parse (reader); If (result.hasSyntaxErrors ()) {new parseException ("there are syntax errors in the provided input."); } Return result. GetRootASTElement (); }}
com.google.inject. ProvisionException: Guice provision errors: 1) Error in constructing the constructor, org.eclipse.emf.common.util.WrappedException: java.lang.RuntimeException: 'can not create a resource for the path: / my / documentationGrammar / DocumentationGrammar.xtextbin '; A registered resource factory is important
DocumentationGrammarStandaloneSetupGenerated class, but please make sure it was properly setup by Xtext. Finally, something like this should be
if (! Resource.factor.registry.INSTANCE.getExtensionToFactoryMap () .user ("xtextbin") resource. Factor Registry INSTANCE.getExtensionToFactoryMap () .put ("extextin", new binarygrammer rsssourcefile IMPL ());
createInjectorAndDoEMFRegistration method in your setup's call center.
Really nice blog post.provided a helpful information.I hope that you will post more updates like this Ruby on Rails Online Training
ReplyDelete