What does this NPE in PsiWhitespaceImpl mean?

I am very frustrated with IDEA plugin development. I'm not stupid and I get mystery exceptions all the time, and it ends up I passed a null somewhere or returned something bad that could have easily been checked by an assertion in IDEA code (I run IDEA under -ea in development). Recently Eugene Vigordchik stated he would not add assertions that generated items in SourceGeneratingCompiler to make sure the API was used correctly. I think this sucks.

What does this exception mean?

java.lang.NullPointerException
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiWhiteSpaceImpl.java:0)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitElement(HighlightVisitorImpl.java:325)
at com.intellij.psi.JavaElementVisitor.visitWhiteSpace(JavaElementVisitor.java:344)
at com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.accept(PsiWhiteSpaceImpl.java:3)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visit(HighlightVisitorImpl.java:327)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$1.run(GeneralHighlightingPass.java:2)
at com.intellij.psi.impl.PsiManagerImpl.performActionWithFormatterDisabled(PsiManagerImpl.java:228)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:121)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.doCollectInformation(GeneralHighlightingPass.java:28)
at com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:8)
at com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.java:7)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:39)
at com.intellij.codeInsight.daemon.impl.UpdateThread.a(UpdateThread.java:30)
at com.intellij.codeInsight.daemon.impl.UpdateThread.access$100(UpdateThread.java:27)
at com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.java:2)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:25)
at com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.java:23)

6 comments


"Keith Lea" <keith@cs.oswego.edu> wrote in message
news:15870856.1129148993595.JavaMail.itn@is.intellij.net...

I am very frustrated with IDEA plugin development. I'm not stupid and I

get mystery exceptions all the time, and it ends up I passed a null
somewhere or returned something bad that could have easily been checked by
an assertion in IDEA code (I run IDEA under -ea in development). Recently
Eugene Vigordchik stated he would not add assertions that generated items in
SourceGeneratingCompiler to make sure the API was used correctly. I think
this sucks.

Keith, I fail to recall when I stated this.


0

No names please it sounds not good!

0

Hello Keith,

KL> I am very frustrated with IDEA plugin development. I'm not stupid
KL> and I get mystery exceptions all the time, and it ends up I passed a
KL> null somewhere or returned something bad that could have easily been
KL> checked by an assertion in IDEA code (I run IDEA under -ea in
KL> development).

One topic very frequently discussed here is run-time verification of @NotNull
annotations, by compile-time or run-time code instrumentation. Because it's
likely that the annotations will be verified automatically quite soon, we're
very reluctant to hand-code assertions verifying that every @NotNull parameter
or return value is in fact not null. (On the other hand, we do continue the
work on annotating the OpenAPI.)

I understand that this sucks for you in the short term, but please understand
that our team has limited resources, and we prefer to spend them on work
that has the biggest long-term effect.

KL> Recently Eugene Vigordchik stated he would not add
KL> assertions that generated items in SourceGeneratingCompiler to make
KL> sure the API was used correctly. I think this sucks.

This was Eugene Zhuravlev, not Eugene Vigdorchik. If you're calling names,
please get them right. :)

Eugene was worried about the performance effect of adding the extra checks
to the compile process.

KL>
KL> What does this exception mean?
KL>
KL> java.lang.NullPointerException
KL> at
KL> com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiW
KL> hiteSpaceImpl.java:0)

It means that a whitespace element has no parent. It's hard to diagnose why
exactly this happens by looking at the stacktrace alone.

-
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Eugene Vigdorchik (JetBrains) wrote:

"Keith Lea" <keith@cs.oswego.edu> wrote in message
news:15870856.1129148993595.JavaMail.itn@is.intellij.net...

>> I am very frustrated with IDEA plugin development. I'm not stupid and I

get mystery exceptions all the time, and it ends up I passed a null
somewhere or returned something bad that could have easily been checked by
an assertion in IDEA code (I run IDEA under -ea in development). Recently
Eugene Vigordchik stated he would not add assertions that generated items in
SourceGeneratingCompiler to make sure the API was used correctly. I think
this sucks.

Keith, I fail to recall when I stated this.


I'm very sorry Eugene, I see so many posts from you I think I started
reading your name by its shape and not by the letters. It was not you,
it was Eugene Zhuravlev.

0

Dmitry Jemerov (JetBrains) wrote:

Hello Keith,

I understand that this sucks for you in the short term, but please
understand that our team has limited resources, and we prefer to spend
them on work that has the biggest long-term effect.


I feel that I do understand and I can relate to not having enough time.
However I feel that the language API has invited and will invite many
developers to try to write some very cool plugins for IDEA, only to find
that the API is difficult to use (from a usability standpoint, not about
programming skill). The OpenAPI has always been elegant, but elegance
means little when accompanied by frustrating error messages.

I know you guys are working hard and trying to make the best thing you
can, and I think you should keep doing that, but I don't plan to stop
asking for plugin API improvements :)

KL> Recently Eugene Vigordchik stated he would not add
KL> assertions that generated items in SourceGeneratingCompiler to make
KL> sure the API was used correctly. I think this sucks.

This was Eugene Zhuravlev, not Eugene Vigdorchik. If you're calling
names, please get them right. :)

Eugene was worried about the performance effect of adding the extra
checks to the compile process.


I understand, and at the time I felt that it was fine, but then I
realized it could be a single string comparison for each GeneratedItem,
and IDEA could print a warning if the path didn't match. It seems like a
silly reason to remove the checks, considering how common it probably is
for external compiler tools to generate output in an undesired path.

KL> KL> What does this exception mean?
KL> KL> java.lang.NullPointerException
KL> at
KL> com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl.getLanguage(PsiW
KL> hiteSpaceImpl.java:0)

It means that a whitespace element has no parent. It's hard to diagnose
why exactly this happens by looking at the stacktrace alone.


It's probably related to the parser null problem that I reported last
night. I'll look into it, thanks.

0

Please sign in to leave a comment.