Status Update
Comments
za...@google.com <za...@google.com>
em...@google.com <em...@google.com> #2
Copying over the comment from the duplicate bug: the gradlew file is treated by the IDE as a C++ header file (see the h icon), which is probably why it causes clangd to be used for analyzing this file. We should investigate why gradlew file is treated as a C++ header.
em...@google.com <em...@google.com> #4
It is related, but removing that line that associates the "" extension with C++ header files is not sufficient.
When I remove that line, this time we get gradlew
recognized as a C++ source file, i.e., VirtualFile(".../gradlew")
has the type OCFile
. Debugging the internals of how file type is computed, I see:
- We first try to find the file type using the file extension, which returns
null
file type because the empty file extension is no longer associated with anything. - Then we try to deduce from contents of the file: In
, we iterate over a set of detectors. One of those detectors isFileTypeDetectionService . It has a parser that somehow accepts thisOCHeaderFileTypeDetector gradlew
file contents and returnsOCFileType
.
I think all the #
comments inside the gradlew
file make the detector think that this is a header file.
There is a denylist inside the OCHeaderFileTypeDetector, and when I add the empty/null extension (or "gradlew") there, I get gradlew
file registered as a Shell file (which fixes (1) the icon, (2) the "Inspect Code", and (3) syntax higlighting in the editor for the gradlew
file).
tn...@google.com <tn...@google.com> #6
I can't access the bug, so maybe add something along the following lines unless you already did: I can see why looking at the file contents for a file full of shell comments (#) might lead it to think it's a header file since # is often a preprocessor directive, but it would be great for it to explicitly check for shebangs (
em...@google.com <em...@google.com> #7
I can't access the bug
That's odd. Are you logged into YouTrack? (I always mark visibility as Jetbrains Team + Registered Users).
to explicitly check for shebangs (
https://en.wikipedia.org/wiki/Shebang_(Unix) )
Makes sense. I'll make sure I mention this in the YouTrack bug.
em...@google.com <em...@google.com>
em...@google.com <em...@google.com> #8
Jetbrains says this has already been implemented in the following issue:
I searched the latest tags in our cidr/ fork, but I couldn't find the fix. I asked them for the commit hash. Maybe it's not tagged yet.
em...@google.com <em...@google.com> #9
Raluca found the change I was looking for:
We will cherry-pick that one (instead of my fix(es)) next week. We should also cherry-pick it into studio-hedgehog-dev when the branch is ready.
Description
Create a new project.
Invoke Code > Inspect Code.... and run it on the whole project.
You now get 19 errors from Clangd reporting problems in the gradlew script (which is not a C++ file). It's flagging on every line that starts with "#" (e.g. comments and the shebang line. See screenshot.
We should make sure it doesn't treat this file as native code.