github / github/codeql

Java: Clarify that Expr.getLocation does not include parentheses

Offen
#3,908 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Java question
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

**Description of the issue**
The name of the predicate `Expr.isParenthesized()` suggests that parentheses are considered part of the expression (a name like `isEnclosedInParentheses` or similar would suggest the opposite).
However, it appears `Expr.getLocation` does not consider parentheses to be part of the expression.
Example query:
```ql
import java

string locationToString(Location l) {
result = l.getStartLine() + "[" + l.getStartColumn() + "]-"
+ l.getEndLine() + "[" + l.getEndColumn() + "]"
}

from Expr e
where
e.isParenthesized()
select e, locationToString(e.getLocation())
```
[Query console](https://lgtm.com/query/4021771571886901977/)

It would therefore be good to clarify this in the `Expr.getLocation` documentation.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.