github / github/codeql

Java: Clarify that Expr.getLocation does not include parentheses

未关闭
#3,908 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Java question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

**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.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。