-
Notifications
You must be signed in to change notification settings - Fork 97
SONARPY-432 Support symbol highlighting #393
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
Conversation
47dd708
to
e914fe8
Compare
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.
Quite some things in there : most interestingly, simpler code and stronger testing would have prevented to have a bug ;)
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.
Name is dodgy : Those are global variables, neither module variables or global fields. I think we should name this globalVariables.
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.
assertThat(moduleSymbols).extracting(name).containsExactly("global_x", "global_var");
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.
Doesn't this assert on the order as well? which can't be guaranteed for a Set?
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.
not related to your PR : I am just wondering if we could just avoid 3 iterations over values and have only one with a plain old for loop. If you're up to it, I think it is worth a commit of refactoring at the end of your PR.
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.
I don't think you need to collect to assert on a stream. And moreover, the containsOnly assertion will check it is not Empty, so no need for the isNotEmpty call.
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.
Please note that you only tested START of references and you most probably have a bug of end of references.
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.
Why the dir variable ? I think you can inline it and concatenate it to the file name.
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.
I think you could remove componentKey as parameter of this method and use the field directly.
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.
Maybe we can store firstUsage.tree() in a dedicated var instead of calling it 4 times ?
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.
Maybe we can store usage.tree() in a dedicated var instead of calling it 4 times ? which makes me realize that we might have a copy/paste bug here : there is a firstUsage.tree() call !!! Why is this not caught by unit test ? (seems that ending of reference is not tested)
623eaa7
to
8fc6a37
Compare
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.
This ought to be rename to addGlobalVariable
(and the param name as well)
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.
we probably don't need the condition.
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.
we probably don't need the condition
8fc6a37
to
53a4425
Compare
53a4425
to
89f2c1a
Compare
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.
see last minor details. Otherwise LGTM
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.
indentation.
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.
tiny detail but I personally think it would be more readable with :
new SymbolVisitor(context.newSymbolTable().onFile(inputFile)).visitFileInput(visitorContext.rootTree());
feel free to discard the suggestion.
89f2c1a
to
6e1d2c1
Compare
…gument (#393) GitOrigin-RevId: 329a636f233c46a099cfa1b70c5c24c08ac2a37e
No description provided.