viatra / EMF-IncQuery

This repository is only kept for historic reasons. All development happens on eclipse.org
http://eclipse.org/viatra
13 stars 4 forks source link

CorePatternLanguageHelper NPE #314

Closed istvanrath closed 11 years ago

istvanrath commented 11 years ago

Unfortunately I don't have a deterministic way to reproduce this yet.

!ENTRY org.eclipse.viatra2.patternlanguage.emf.ui 4 0 2012-09-29 20:13:32.032
!MESSAGE Error initializing JvmElement

!STACK 0
java.lang.NullPointerException
    at org.eclipse.viatra2.patternlanguage.core.helper.CorePatternLanguageHelper.getReferencedPatternVariablesOfXExpression(CorePatternLanguageHelper.java:86)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.PatternMatchEvaluatorClassInferrer$2.apply(PatternMatchEvaluatorClassInferrer.java:124)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.PatternMatchEvaluatorClassInferrer$2.apply(PatternMatchEvaluatorClassInferrer.java:1)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.util.EMFJvmTypesBuilder.initializeSafely(EMFJvmTypesBuilder.java:104)
    at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toMethod(JvmTypesBuilder.java:511)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.PatternMatchEvaluatorClassInferrer.inferEvaluatorClassMethods(PatternMatchEvaluatorClassInferrer.java:138)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.PatternMatchEvaluatorClassInferrer.inferEvaluatorClass(PatternMatchEvaluatorClassInferrer.java:91)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.EMFPatternLanguageJvmModelInferrer._infer(EMFPatternLanguageJvmModelInferrer.java:126)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.EMFPatternLanguageJvmModelInferrer.infer(EMFPatternLanguageJvmModelInferrer.java:216)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.EMFPatternLanguageJvmModelInferrer._infer(EMFPatternLanguageJvmModelInferrer.java:188)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.EMFPatternLanguageJvmModelInferrer.infer(EMFPatternLanguageJvmModelInferrer.java:213)
    at org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator.installDerivedState(JvmModelAssociator.java:231)
    at org.eclipse.viatra2.emf.incquery.tooling.generator.jvmmodel.EMFPatternJvmModelAssociator.installDerivedState(EMFPatternJvmModelAssociator.java:58)
    at org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:125)
    at org.eclipse.xtext.resource.DerivedStateAwareResource.getContents(DerivedStateAwareResource.java:48)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl$4.getChildren(ResourceImpl.java:519)
    at org.eclipse.emf.common.util.AbstractTreeIterator.hasAnyChildren(AbstractTreeIterator.java:97)
    at org.eclipse.emf.common.util.AbstractTreeIterator.hasNext(AbstractTreeIterator.java:85)
    at org.eclipse.viatra2.patternlanguage.ui.highlight.EMFPatternLanguageHighlightingCalculator.searchAndHighlightElements(EMFPatternLanguageHighlightingCalculator.java:45)
    at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.doProvideHighlightingFor(XbaseHighlightingCalculator.java:115)
    at org.eclipse.xtext.xbase.ui.highlighting.XbaseHighlightingCalculator.provideHighlightingFor(XbaseHighlightingCalculator.java:92)
    at org.eclipse.xtext.ui.editor.syntaxcoloring.MergingHighlightedPositionAcceptor.provideHighlightingFor(MergingHighlightedPositionAcceptor.java:51)
    at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.reconcilePositions(HighlightingReconciler.java:88)
    at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.modelChanged(HighlightingReconciler.java:281)
    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:44)
    at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.run(XtextReconciler.java:254)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
ujhelyiz commented 11 years ago

I have never seen this issue yet, but from a manual code inspection I have found that the only way this issue could come forth if for some reason Xtext tries to infer a JvmModel from a 'null' expression.

As that 'null' expression also is an error in the source model, I simply turned off the model inference from null expression globally. In this case, the generated code may be erroneous (or non-existent), but as the source code is as well (and is reported in the editor as well), I don't think that is a serious side effect.

Could you test it whether it holds? Try editing your check expressions, that may help to bring forth the issue.