Community
Participate
Working Groups
org.eclipse.emf.common.util.WrappedException: org.eclipse.emf.common.util.WrappedException: java.lang.ClassCastException: org.eclipse.xtext.xbase.impl.XAssignmentImplCustom cannot be cast to org.eclipse.xtext.xbase.XFeatureCall at org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:123) at org.eclipse.xtext.xbase.resource.XbaseResource.getEObject(XbaseResource.java:226) at org.eclipse.xtext.xtend2.resource.Xtend2Resource.getEObject(Xtend2Resource.java:88) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:141) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:102) at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:485) at org.eclipse.xtext.validation.ResourceValidatorImpl.resolveProxies(ResourceValidatorImpl.java:127) at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:62) at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:79) at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1) at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32) at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:78) at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:75) at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:64) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.ClassCastException: org.eclipse.xtext.xbase.impl.XAssignmentImplCustom cannot be cast to org.eclipse.xtext.xbase.XFeatureCall at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:205) at org.eclipse.xtext.xbase.resource.XbaseResource.access$0(XbaseResource.java:1) at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:228) at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:1) at org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:121) ... 14 more Caused by: java.lang.ClassCastException: org.eclipse.xtext.xbase.impl.XAssignmentImplCustom cannot be cast to org.eclipse.xtext.xbase.XFeatureCall at org.eclipse.xtext.xbase.linking.BestMatchingJvmFeatureScope.setImplicitReceiverAndIsValid(BestMatchingJvmFeatureScope.java:97) at org.eclipse.xtext.xbase.linking.BestMatchingJvmFeatureScope.getSingleElement(BestMatchingJvmFeatureScope.java:79) at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:121) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:173) ... 18 more
With this source file: package org.xtext.example.mydsl.jvmmodel import com.google.inject.Inject import org.eclipse.emf.ecore.EObject import org.eclipse.xtext.common.types.JvmDeclaredType import org.eclipse.xtext.common.types.JvmExecutable import org.eclipse.xtext.util.IAcceptor import org.eclipse.xtext.xbase.XExpression import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder import org.xtext.example.mydsl.myDsl.Entity import org.xtext.example.mydsl.myDsl.Operation import org.xtext.example.mydsl.myDsl.PackageDeclaration import org.xtext.example.mydsl.myDsl.Property /** * <p>Infers a JVM model from the source model.</p> * * <p>The JVM model should contain all elements that would appear in the Java code * which is generated from the source model. Other models link against the JVM model rather than the source model.</p> */ class MyDslJvmModelInferrer extends AbstractModelInferrer { /** * conveninence API to build and initialize JvmTypes and their members. */ @Inject extension JvmTypesBuilder def void setBody(JvmExecutable it, XExpression expression) { expression.isLogicallyContainedIn(it) } /** * Is called for each instance of the first argument's type contained in a resource. * * @param element - the model to create one or more JvmDeclaredTypes from. * @param acceptor - each created JvmDeclaredType without a container should be passed to the acceptor in order get attached to the * current resource. * @param isPreLinkingPhase - whether the method is called in a pre linking üphase, i.e. when the global index isn't fully updated. You * must not rely on linking using the index if iPrelinkingPhase is <code>true</code> */ def dispatch void infer(Entity element, IAcceptor<JvmDeclaredType> acceptor, boolean isPrelinkingPhase) { acceptor.accept(element.toClass(element.qualifiedName) [ for (feature : element.features) { switch feature { Property : { } Operation : { it.members += feature.toMethod(feature.name, feature.newTypeRef(typeof(String))) [ body = feature.body ] } } } ]) } def String qualifiedName(EObject element) { switch element { Entity case element.eContainer != null : qualifiedName(element.eContainer)+"."+element.name Entity : element.name PackageDeclaration case element.eContainer != null : qualifiedName(element.eContainer)+"."+element.name PackageDeclaration : element.name } } }
I have a Nullpointer for this file during scoping. 239171 [Worker-7] ERROR org.eclipse.xtext.xbase.scoping.XbaseScopeProvider - error during scoping java.lang.NullPointerException at org.eclipse.xtext.common.types.util.TypesSwitch.doSwitch(TypesSwitch.java:61) at org.eclipse.xtext.common.types.util.SuperTypeCollector$Implementation.caseJvmDelegateTypeReference(SuperTypeCollector.java:222) at org.eclipse.xtext.common.types.util.SuperTypeCollector$Implementation.caseJvmDelegateTypeReference(SuperTypeCollector.java:1) at org.eclipse.xtext.common.types.util.TypesSwitch.doSwitch(TypesSwitch.java:510) at org.eclipse.xtext.common.types.util.TypesSwitch.doSwitch(TypesSwitch.java:75) at org.eclipse.xtext.common.types.util.TypesSwitch.doSwitch(TypesSwitch.java:61) at org.eclipse.xtext.common.types.util.SuperTypeCollector$Implementation.caseJvmMultiTypeReference(SuperTypeCollector.java:211) at org.eclipse.xtext.common.types.util.SuperTypeCollector$Implementation.caseJvmMultiTypeReference(SuperTypeCollector.java:1) at org.eclipse.xtext.common.types.util.TypesSwitch.doSwitch(TypesSwitch.java:306) at org.eclipse.xtext.common.types.util.TypesSwitch.doSwitch(TypesSwitch.java:75) at org.eclipse.xtext.common.types.util.TypesSwitch.doSwitch(TypesSwitch.java:61) at org.eclipse.xtext.common.types.util.SuperTypeCollector.doCollectSupertypeData(SuperTypeCollector.java:137) at org.eclipse.xtext.common.types.util.SuperTypeCollector.collectSuperTypes(SuperTypeCollector.java:87) at org.eclipse.xtext.xbase.scoping.featurecalls.JvmFeatureScopeProvider.linearizeTypeHierarchy(JvmFeatureScopeProvider.java:159) at org.eclipse.xtext.xbase.scoping.featurecalls.JvmFeatureScopeProvider.createFeatureScopeForTypeRef(JvmFeatureScopeProvider.java:109) at org.eclipse.xtext.xbase.scoping.featurecalls.JvmFeatureScopeProvider.createFeatureScope(JvmFeatureScopeProvider.java:73) at org.eclipse.xtext.xbase.scoping.XbaseScopeProvider$JvmFeatureScopeAcceptor.createScope(XbaseScopeProvider.java:739) at org.eclipse.xtext.xbase.scoping.XbaseScopeProvider.createFeatureScopeForTypeRef(XbaseScopeProvider.java:372) at org.eclipse.xtext.xbase.scoping.XbaseScopeProvider.createFeatureCallScopeForReceiver(XbaseScopeProvider.java:394) at org.eclipse.xtext.xbase.scoping.XbaseScopeProvider.createFeatureCallScope(XbaseScopeProvider.java:327) at org.eclipse.xtext.xbase.scoping.XbaseScopeProvider.getScope(XbaseScopeProvider.java:181) at org.eclipse.xtext.xbase.annotations.scoping.XbaseWithAnnotationsScopeProvider.getScope(XbaseWithAnnotationsScopeProvider.java:50) at org.eclipse.xtext.xbase.linking.XbaseLinkingScopeProvider.getScope(XbaseLinkingScopeProvider.java:42) at org.eclipse.xtext.linking.impl.DefaultLinkingService.getScope(DefaultLinkingService.java:59) at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:119) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:175) at org.eclipse.xtext.xbase.resource.XbaseResource.access$0(XbaseResource.java:1) at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:227) at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:1) at org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:121) at org.eclipse.xtext.xbase.resource.XbaseResource.getEObject(XbaseResource.java:225) at org.eclipse.xtext.xtend2.resource.Xtend2Resource.getEObject(Xtend2Resource.java:88) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:219) at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:202) at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:262) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1475) at org.eclipse.xtext.xbase.impl.XAbstractFeatureCallImpl.getFeature(XAbstractFeatureCallImpl.java:161) at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.computeFeatureCallHighlighting(XbaseHighlightingCalculator.java:149) at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.searchAndHighlightElements(XbaseHighlightingCalculator.java:115) at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.doProvideHighlightingFor(XbaseHighlightingCalculator.java:107) at org.eclipse.xtext.xtend2.ui.highlighting.XtendHighlightingCalculator.doProvideHighlightingFor(XtendHighlightingCalculator.java:93) at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.provideHighlightingFor(XbaseHighlightingCalculator.java:87) at org.eclipse.xtext.ui.editor.syntaxcoloring.MergingHighlightedPositionAcceptor.provideHighlightingFor(MergingHighlightedPositionAcceptor.java:51) at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.reconcilePositions(HighlightingReconciler.java:87) at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.modelChanged(HighlightingReconciler.java:277) at org.eclipse.xtext.ui.editor.model.XtextDocument.notifyModelListeners(XtextDocument.java:118) at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.afterModify(XtextDocument.java:172) at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.afterModify(XtextDocument.java:1) at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.modify(AbstractReadWriteAcces.java:50) at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.modify(XtextDocument.java:181) at org.eclipse.xtext.ui.editor.model.XtextDocument.internalModify(XtextDocument.java:90) at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.reconcile(XtextDocumentReconcileStrategy.java:33) at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.run(XtextReconciler.java:239) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Added NPE guard for comment #3. stack trace from comment #1 is outdated and can't happen anymore. pushed to master.
Requested via bug 522520. -M.