Rust: Move the restriction to variableDecl.

This commit is contained in:
Geoffrey White
2024-10-09 16:21:12 +01:00
parent a66f31d844
commit dfeb35fe1a

View File

@@ -77,7 +77,12 @@ module Impl {
not exists(getOutermostEnclosingOrPat(p)) and
definingNode = p.getName()
) and
name = p.getName().getText()
name = p.getName().getText() and
// exclude for now anything starting with an uppercase character, which may be a reference to
// an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
// which we don't appear to recognize yet anyway. This also assumes programmers follow the
// naming guidelines, which they generally do, but they're not enforced.
not name.charAt(0).isUppercase()
}
/** A variable. */
@@ -85,13 +90,7 @@ module Impl {
private AstNode definingNode;
private string name;
Variable() {
this = MkVariable(definingNode, name) and
// exclude for now anything starting with an uppercase character, which may be an enum constant (e.g. `None`). This excludes
// static and constant variables (UPPERCASE), which we don't appear to recognize yet anyway. This also assumes programmers
// follow the naming guidelines, which they generally do, but they're not enforced.
not name.charAt(0).isUppercase()
}
Variable() { this = MkVariable(definingNode, name) }
/** Gets the name of this variable. */
string getName() { result = name }