Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringNotationToMapNotationIntention - NullPointerException #76

Closed
Vity01 opened this issue Feb 18, 2021 · 9 comments
Closed

StringNotationToMapNotationIntention - NullPointerException #76

Vity01 opened this issue Feb 18, 2021 · 9 comments

Comments

@Vity01
Copy link

Vity01 commented Feb 18, 2021

I don't have some piece of code to reproduce the problem, but I hope it helps.
Plugin version 0.6
Intellij Idea Ultimate 2020.3.2

EDIT1. I think it's somehow related with a editing Groovy code in the README.MD when you mark code section as groovy, eg. :

README.MD

|```groovy
|  some piece of Groovy code   
|```

Stacktrace

java.lang.NullPointerException
	at com.github.platan.idea.dependencies.intentions.StringNotationToMapNotationIntention.findElement(StringNotationToMapNotationIntention.java:107)
	at com.github.platan.idea.dependencies.intentions.StringNotationToMapNotationIntention.lambda$getElementPredicate$0(StringNotationToMapNotationIntention.java:89)
	at org.jetbrains.plugins.groovy.intentions.base.Intention.findMatchingElement(Intention.java:92)
	at org.jetbrains.plugins.groovy.intentions.base.Intention.isAvailable(Intention.java:113)
	at com.github.platan.idea.dependencies.intentions.SelectionIntention.isAvailable(SelectionIntention.java:71)
	at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.availableFor(ShowIntentionActionsHandler.java:155)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.lambda$getActionsToShow$1(ShowIntentionsPass.java:322)
	at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseBetweenHostAndInjected(ShowIntentionActionsHandler.java:182)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:321)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:226)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:56)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:400)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1137)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:393)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:392)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:368)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:172)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:183)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:366)
	at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:188)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
@platan
Copy link
Owner

platan commented Feb 19, 2021

@Vity01 thank you for reporting this 👍 . I can reproduce it and I will fix it.

@0xfaulty
Copy link

@platan how it's going? There doesn't seem to be much activity in the repository 😔

@Janmm14
Copy link

Janmm14 commented Sep 3, 2021

Same exception here:

java.lang.NullPointerException: Cannot invoke "com.intellij.psi.PsiElement.getParent()" because the return value of "com.intellij.psi.PsiElement.getParent()" is null
	at com.github.platan.idea.dependencies.intentions.StringNotationToMapNotationIntention.findElement(StringNotationToMapNotationIntention.java:107)
	at com.github.platan.idea.dependencies.intentions.StringNotationToMapNotationIntention.lambda$getElementPredicate$0(StringNotationToMapNotationIntention.java:89)
	at org.jetbrains.plugins.groovy.intentions.base.Intention.findMatchingElement(Intention.java:92)
	at org.jetbrains.plugins.groovy.intentions.base.Intention.isAvailable(Intention.java:113)
	at com.github.platan.idea.dependencies.intentions.SelectionIntention.isAvailable(SelectionIntention.java:71)
	at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.availableFor(ShowIntentionActionsHandler.java:169)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.lambda$getActionsToShow$1(ShowIntentionsPass.java:336)
	at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseBetweenHostAndInjected(ShowIntentionActionsHandler.java:202)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:335)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:240)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:56)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:414)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1078)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:407)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:406)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:382)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:174)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:183)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:380)
	at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:188)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

@platan
Copy link
Owner

platan commented Sep 3, 2021

@0xfaulty @Janmm14 Thank you for reporting this. Did you get the exception while editing a *.gradle file or a *.md file?

@0xfaulty
Copy link

0xfaulty commented Sep 7, 2021

@platan Exception does not occur so often, and I was unable to reproduce it on purpose, when it appears next time I will try to describe how got to it.
But as far as I remember, it wasn't necessary to edit the *.gradle file, it was enough for it to be displayed, for example, by the search window (Find in Files) for the project.

@0xfaulty
Copy link

0xfaulty commented Sep 8, 2021

@platan got stable way how I face with this exception
Tested on latest (at this time) Idea version 2021.2.1
I use multimodule project if that matter (not tested in single module gradle projects)

  1. need to add several lines in different place of *.gradle file (idk maybe just one enough)
In my case these lines:
    compile "io.springfox:springfox-swagger2:${project.swaggerVersion}"
    compile "io.springfox:springfox-swagger-ui:${project.swaggerVersion}"
    ....
    compile project(":common")
  1. Git>Uncommited Changes>Stash Changes for stash these changes
  2. Restart idea and wait for indexing complete
  3. Git>Uncommited Changes>Unstash Changes then press View button and open changed file
  4. Then press << arrows to appy changes one by one
  5. Close that unstash windows
  6. (!) icon should appear with exception

@platan
Copy link
Owner

platan commented Sep 8, 2021

@0xfaulty Thank you for detailed description. I was able to reproduce it easily.

@platan
Copy link
Owner

platan commented Sep 12, 2021

I've just released a new version 0.6.1 which fixes this bug. The new version should be available in JetBrains marketplace within few days.

@platan
Copy link
Owner

platan commented Sep 14, 2021

Version 0.6.1 is available in JetBrains marketplace.

@platan platan closed this as completed Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants