Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Why add a pair of brackets will lead to Cannot invoke...EClassifierInfo.getEClassifier()?(xtext syntax)
Why add a pair of brackets will lead to Cannot invoke...EClassifierInfo.getEClassifier()? [message #1836680] Tue, 12 January 2021 05:34 Go to next message
wings cu is currently offline wings cuFriend
Messages: 14
Registered: January 2021
Junior Member
My xtext file is as following
 
Domainmodel:
    (elements+=AbstractElement)*;
 
PackageDeclaration:
    'package' name=QualifiedName '{'
        (elements+=AbstractElement)*
    '}';
 
AbstractElement:
    PackageDeclaration | Type | Import | {AbstractElement} ML_COMMENT;
 
QualifiedName:
    ID ('.' ID)*;
 
Import:
    'import' importedNamespace=QualifiedNameWithWildcard;
 
QualifiedNameWithWildcard:
    QualifiedName '.*'?;
 
Type:
    DataType | Entity;
 
DataType:
    'datatype' name=ID;
 
Entity:
    'entity' name=ID ('extends' superType=[Entity|QualifiedName])? '{'
        (features+=Feature)*
        (methods+=Method)*
    '}';
 
Feature:
    (many?='many')? name=ID ':' type=[Type|QualifiedName];

Var:
	name=ID ':' type=[Type|QualifiedName]
;

VarList:
	(vars+=(Feature|','))*;
    
Method:
	'method:'ret=[Type] name=ID'('varList=VarList')' '{'
		
	'}';

and here is the error message:
[main] ERROR org.eclipse.xtext.xtext.XtextLinker  - Cannot invoke "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.getEClassifier()" because the return value of "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfoAccess.getCurrentCompatibleType()" is null
java.lang.NullPointerException: Cannot invoke "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.getEClassifier()" because the return value of "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfoAccess.getCurrentCompatibleType()" is null
	at org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo$EClassInfo.addFeature(EClassifierInfo.java:168)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreInterpretationContext.addFeature(Xtext2EcoreInterpretationContext.java:161)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreInterpretationContext.addFeature(Xtext2EcoreInterpretationContext.java:119)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer$1.caseAssignment(Xtext2EcoreTransformer.java:412)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer$1.caseAssignment(Xtext2EcoreTransformer.java:386)
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:144)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer.deriveFeatures(Xtext2EcoreTransformer.java:504)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer.deriveFeatures(Xtext2EcoreTransformer.java:523)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer.deriveFeatures(Xtext2EcoreTransformer.java:322)
	at org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer.transform(Xtext2EcoreTransformer.java:151)
	at org.eclipse.xtext.xtext.XtextLinker.linkModel(XtextLinker.java:263)
	at org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:341)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:122)
	at org.eclipse.xtext.xtext.GrammarResource.superDoLinking(GrammarResource.java:49)
	at org.eclipse.xtext.xtext.GrammarResource$LinkingTrigger.installDerivedState(GrammarResource.java:96)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:244)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.getContents(DerivedStateAwareResource.java:98)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage.initialize(XtextGeneratorLanguage.java:217)
	at org.eclipse.xtext.xtext.generator.StandardLanguage.initialize(StandardLanguage.java:167)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:186)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:140)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2.checkConfiguration(AbstractWorkflowComponent2.java:23)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.preInvoke(Mwe2Bridge.java:69)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.preInvoke(AbstractWorkflowComponent.java:208)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.preInvoke(AbstractCompositeWorkflowComponent.java:31)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:20)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:103)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:63)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:53)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:79)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:37)
503  [main] ERROR xt.generator.XtextGeneratorLanguage  - [NullPointerException: Cannot invoke "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.getEClassifier()" because the return value of "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfoAccess.getCurrentCompatibleType()" is null (see logs for details)]
507  [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow org.xtext.example.domainmodel.GenerateDomainmodel: Problem parsing 'file:/D:/repository/org.xtext.example.domainmodel/../org.xtext.example.domainmodel/src/org/xtext/example/domainmodel/Domainmodel.xtext':
NullPointerException: Cannot invoke "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.getEClassifier()" because the return value of "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfoAccess.getCurrentCompatibleType()" is null (see logs for details)
java.lang.RuntimeException: Problems running workflow org.xtext.example.domainmodel.GenerateDomainmodel: Problem parsing 'file:/D:/repository/org.xtext.example.domainmodel/../org.xtext.example.domainmodel/src/org/xtext/example/domainmodel/Domainmodel.xtext':
NullPointerException: Cannot invoke "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.getEClassifier()" because the return value of "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfoAccess.getCurrentCompatibleType()" is null (see logs for details)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:105)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:63)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:53)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:79)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:37)
Caused by: java.lang.IllegalStateException: Problem parsing 'file:/D:/repository/org.xtext.example.domainmodel/../org.xtext.example.domainmodel/src/org/xtext/example/domainmodel/Domainmodel.xtext':
NullPointerException: Cannot invoke "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.getEClassifier()" because the return value of "org.eclipse.xtext.xtext.ecoreInference.EClassifierInfoAccess.getCurrentCompatibleType()" is null (see logs for details)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage.initialize(XtextGeneratorLanguage.java:223)
	at org.eclipse.xtext.xtext.generator.StandardLanguage.initialize(StandardLanguage.java:167)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:186)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:140)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2.checkConfiguration(AbstractWorkflowComponent2.java:23)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.preInvoke(Mwe2Bridge.java:69)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.preInvoke(AbstractWorkflowComponent.java:208)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.preInvoke(AbstractCompositeWorkflowComponent.java:31)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:20)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:103)
	... 4 more 

I'm a beginner to xtext´╝îand I want to know why this code cannot work, and when I change
 VarList:
	(vars+=(Feature|','))*;
to
 VarList:
	(vars+=Feature|',')*;
, it can be compiled correctly.
Besides, how can I find some information about how to write DSL syntax?Is there any tutorials? (I have read the xtext 15 minutes tutorial.)
Re: Why add a pair of brackets will lead to Cannot invoke...EClassifierInfo.getEClassifier()? [message #1836705 is a reply to message #1836680] Tue, 12 January 2021 15:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14026
Registered: July 2009
Senior Member
i assume this is a missing grammar validation. can you please create an issue at

https://github.com/eclipse/xtext-core/


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Why add a pair of brackets will lead to Cannot invoke...EClassifierInfo.getEClassifier()? [message #1836713 is a reply to message #1836705] Tue, 12 January 2021 17:58 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7220
Registered: July 2009
Senior Member
Hi

No. It's just an inelegant diagnostic for a crazy grammar.

vars+=(Feature|',')

requires both Feature and ',' to be type compatible with vars, which they are not, and so far not as to provoke the NPE.

vars+=Feature|',' is two independent alternatives, but probably not what was intended.

Regards

Ed Willink
Previous Topic:XTend code generation and comments
Next Topic:Beginner Grammar Question
Goto Forum:
  


Current Time: Thu Jul 29 17:23:52 GMT 2021

Powered by FUDForum. Page generated in 0.02322 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top