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

Handle case when VirtualFile is null #7156

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

tomaszgolebiowski
Copy link
Collaborator

Closes sourcegraph/jetbrains#3087

During creation of TextEditorHighlightingPass VirtualFile can return null. This PR handles this situation.

Test plan

N/A

@@ -45,6 +45,8 @@ jobs:
pushd jetbrains
scip-java index --build-tool=gradle
popd > /dev/null
env:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixing SCIP failing on search build.
That said, it is failing later anyway on:

e: There are some plugins incompatible with language version 2.0:

> Task :compileKotlin FAILED
  com.sourcegraph.semanticdb_kotlinc.AnalyzerRegistrar
Please use language version 1.9 or below

@dominiccooney should we somehow push to fix it?
If not or it won't be easy, should we just disable it for jetbrains to not waste time on failing compilation?
TBH. I'm not sure what is policy on the SCIP and what it exectly gives us (considering it is failing for a long time already and no one complains...)

}
if (file.virtualFile == null) null
else
when (file.virtualFile.fileSystem.protocol) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://sourcegraph.sourcegraph.com/github.com/JetBrains/intellij-community/-/blob/platform/core-api/src/com/intellij/psi/PsiFile.java?L32-42

If you want to get a non-null virtual file consider using FileViewProvider#getVirtualFile()

Interesting... 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://plugins.jetbrains.com/docs/intellij/psi-files.html

btw, here are some docs on PSI Files if you are interested

Copy link
Collaborator Author

@tomaszgolebiowski tomaszgolebiowski Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://plugins.jetbrains.com/docs/intellij/virtual-file.html#how-do-i-get-a-virtual-file

may return null if the PSI file exists only in memory

The exceptions we get show that we must assume that sometimes there will be a null returned.

Copy link
Contributor

@pkukielka pkukielka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tomaszgolebiowski tomaszgolebiowski merged commit 250db73 into main Feb 21, 2025
19 of 20 checks passed
@tomaszgolebiowski tomaszgolebiowski deleted the tg/3087-bug-javalangnullpointerexception branch February 21, 2025 10:27
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

Successfully merging this pull request may close these issues.

bug: java.lang.NullPointerException
3 participants