Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » NPE in IntelliJ plugin tryting to convert PSIElement to EObject
NPE in IntelliJ plugin tryting to convert PSIElement to EObject [message #1764871] Fri, 02 June 2017 17:52 Go to next message
Pratik Dixit is currently offline Pratik DixitFriend
Messages: 2
Registered: June 2017
Junior Member
Hi,
I am trying to add folding support for certain elements in my dsl in Intellij.
I am implementing buildFoldRegions method. I try to convert from PSIElement to eObject as follows.
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
    if (root instanceof MyDSLBasicFileImpl) {
      EObject eObject = ((MyDSLBasicFileImpl) root).getRoot().getEObject();
     ...
    }
}


In many instances this leads to the following NullPointerException :
resolution of uriFragment '|0' failed.
java.lang.NullPointerException
        at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
        at org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions.getContainer(ChunkedResourceDescriptions.java:182)
        at org.eclipse.xtext.resource.containers.ProjectDescriptionBasedContainerManager.getVisibleContainers(ProjectDescriptionBasedContainerManager.java:82)
        at org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.getVisibleContainers(DefaultGlobalScopeProvider.java:72)
        at org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.getScope(DefaultGlobalScopeProvider.java:49)
        at org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.getScope(DefaultGlobalScopeProvider.java:61)
        at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeProvider.getScope(AbstractGlobalScopeProvider.java:50)
        at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider.getGlobalScope(AbstractGlobalScopeDelegatingScopeProvider.java:46)
        at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider.getGlobalScope(AbstractGlobalScopeDelegatingScopeProvider.java:42)
        at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getResourceScope(ImportedNamespaceAwareLocalScopeProvider.java:104)
        at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:97)
        at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:95)
        at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:95)
        at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:95)
        at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.delegateGetScope(DelegatingScopeProvider.java:42)
        at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.getScope(DelegatingScopeProvider.java:38)
        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:247)
        at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:222)
        at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doResolveLazyCrossReference(LazyLinkingResource.java:169)
        at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:148)
        at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:134)
        at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:498)
        at org.eclipse.xtext.psi.impl.BaseXtextFile.createResource(BaseXtextFile.java:149)
        at org.eclipse.xtext.psi.impl.BaseXtextFile$1.compute(BaseXtextFile.java:89)
        at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
        at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
        at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:60)
        at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
        at org.eclipse.xtext.psi.impl.BaseXtextFile.getResource(BaseXtextFile.java:108)
        at org.eclipse.xtext.psi.impl.BaseXtextFile.getINode(BaseXtextFile.java:112)
        at org.eclipse.xtext.psi.impl.PsiEObjectImpl.getINode(PsiEObjectImpl.java:109)
        at org.eclipse.xtext.psi.impl.PsiEObjectImpl.getEObject(PsiEObjectImpl.java:120)
        at com.example.mydsl.idea.folding.MyDSLBasicFoldingBuilder.buildFoldRegions(MyDSLBasicFoldingBuilder.java:45)
        at com.intellij.lang.folding.LanguageFolding.buildFoldingDescriptors(LanguageFolding.java:83) 
        at com.intellij.codeInsight.folding.impl.FoldingUpdate.a(FoldingUpdate.java:236)
        at com.intellij.codeInsight.folding.impl.FoldingUpdate.getFoldingsFor(FoldingUpdate.java:222)
        at com.intellij.codeInsight.folding.impl.CodeFoldingManagerImpl.buildInitialFoldings(CodeFoldingManagerImpl.java:225)
        at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl.loadEditorInBackground(PsiAwareTextEditorImpl.java:54)
        at com.intellij.openapi.fileEditor.impl.text.AsyncEditorLoader.b(AsyncEditorLoader.java:98)
        at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$commitAndRunReadAction$1(PsiDocumentManagerBase.java:478)
        at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$commitAndRunReadAction$2(PsiDocumentManagerBase.java:503)
        at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:946)
        at com.intellij.psi.impl.PsiDocumentManagerBase.commitAndRunReadAction(PsiDocumentManagerBase.java:501)
        at com.intellij.psi.impl.PsiDocumentManagerBase.commitAndRunReadAction(PsiDocumentManagerBase.java:478)
        at com.intellij.openapi.fileEditor.impl.text.AsyncEditorLoader.a(AsyncEditorLoader.java:97)
        at com.intellij.openapi.progress.util.ProgressIndicatorUtils.a(ProgressIndicatorUtils.java:146)
        at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:176)
        at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:556)
        at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
        at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163)
        at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:144)
        at com.intellij.openapi.fileEditor.impl.text.AsyncEditorLoader.a(AsyncEditorLoader.java:96)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)


Any pointers of what might be going wrong and how I should debug this problem?



Re: NPE in IntelliJ plugin tryting to convert PSIElement to EObject [message #1765120 is a reply to message #1764871] Tue, 06 June 2017 20:29 Go to previous message
Pratik Dixit is currently offline Pratik DixitFriend
Messages: 2
Registered: June 2017
Junior Member
I think the problem was with my multi-file references. After I enabled ImportUriGlobalScopeProvider and SimpleNameProvider, the NullPointerException went away.
Previous Topic:Cross references to non-EMF objects
Next Topic:import and scope provider
Goto Forum:
  


Current Time: Fri Sep 17 11:20:40 GMT 2021

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

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

Back to the top