-
Notifications
You must be signed in to change notification settings - Fork 184
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
JS-158 Geneate Java API for ESTree #4725
Conversation
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
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.
One minor remark regarding naming conventions (type
-> tpe
?), and one question regarding Node
- Expression
relationship.
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Show resolved
Hide resolved
sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/ESTreeFactory.java
Outdated
Show resolved
Hide resolved
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.
Except for a small manual modification in the generated file, it LGTM.
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Show resolved
Hide resolved
public record Location(Position start, Position end) {} | ||
|
||
public sealed interface CallExpression extends Node { | ||
Node callee(); |
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 understand why it's a Node
. The spec says that callee and arguments are all Expression
s.
This would result in a million unnecessary type casts.
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.
no problem to change, for some reason .d.ts
says that it can be also Super
https:/DefinitelyTyped/DefinitelyTyped/blob/master/types/estree/index.d.ts#L389
I am not sure which one is wrong, spec or dts
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.
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.
Ah, sorry, yeah, estree/index.d.ts
is the ultimate source of truth here.
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.
Scrolled through it, added a few comments here and there.
Some types of some child nodes seem unnecessarily lax, lots of child nodes are declared just as Node
, even though they have a much more specific type in the .d.ts
.
Note that Java allows to implement multiple sealed interfaces:
public class Multisealed {
sealed interface A {}
sealed interface B {}
public record Foo() implements A, B {}
}
Could we maybe collect all |
type unions, and convert them into sealed interfaces like ExpressionOrPropertyDefinition
, and then let both Expression
and PropertyDefinition
implement the ExpressionOrPropertyDefinition
? This should preserve the tight bounds on all types.
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
sonar-plugin/api/src/main/java/org/sonar/plugins/javascript/api/estree/ESTree.java
Outdated
Show resolved
Hide resolved
@@ -591,4 +591,4 @@ message SourceLocation { | |||
message Position { |
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.
Having a comment somewhere whether it's all 0
-based or 1
-based certainly wouldn't hurt.
Quality Gate failedFailed conditions See analysis details on SonarQube Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Missing coverage is expected, it will be addressed after JS-159 and JS-160