-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
fix: fixed identifier correctness check when simplenamePart == "" #3550
Conversation
Good catch, haven't thought about this case while writing the code. Would you mind adding a new testcase in |
Annoyingly, the issue doesnt seem to occur when gson is not a module, with |
Heres the scenario matrix. Patched = with #3549 applied, zero check = with this PR applied, module = if gson has
|
Have discovered why I got |
Thanks a lot for the analysis, this is something we've seen in the past. OK, let's merge the other ones and come back to this one later. |
Thanks @Strum355. Could you add the corresponding test case? |
5d39292
to
85411b0
Compare
bc483e2
to
80d2ad6
Compare
80d2ad6
to
fd3313d
Compare
@monperrus test case added 👍 |
@Test | ||
public void correctSquareBrackets() { | ||
CtLocalVariableReference<Object> localVariableRef = new Launcher().getFactory().createLocalVariableReference(); | ||
assertDoesNotThrow(() -> localVariableRef.setSimpleName("List<String>[]")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that a valid name for a local variable reference? Maybe you mean a type reference instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't a allowed identifier for a local variable, must be more or less alphanumeric with some exceptions.
We have 1 check for all setSimpleName
methods. Looking at the decision today i would prefer something like a visitor. Allowing different handling for the cases., like type or local variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, @Strum355 could you create a type reference instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My attempts have been unsuccessful unfortunately, I consistently get NPE as getPackage always returns null and Ive been unable to run the Launcher in classpath mode. Im afraid my knowledge of Spoon only goes sofar 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by CtTypeReference localVariableRef = new Launcher().getFactory().createTypeReference();
LGTM, OK to merge
Thanks @Strum355 |
Exception when indexing https://github.com/google/gson library in module mode (with
module-info.java
andpackage-info.java
s) with https://github.com/sourcegraph/lsif-java with #3549 applied.Exception does not occur when the library is not a module (with
module-info.java
andpackage-info.java
s removed) (Note, need to double check the behaviour in each scenario: gson-module+3549, gson-not-module+3549, gson-module, gson-not-module)Occurs with
TypeToken<List<String>[]>
@ https://github.com/google/gson/blob/master/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java#L45Debug state screenshots for context:
Stacktrace
Screenshots