mirror of
https://github.com/github/codeql.git
synced 2026-02-19 16:33:40 +01:00
Remove VariableScope
This commit is contained in:
@@ -12,4 +12,13 @@ class Scope extends AstNode, Scope::ScopeType {
|
||||
|
||||
/** Gets the scope in which this scope is nested, if any. */
|
||||
Scope getOuterScope() { result = range.getOuterScope() }
|
||||
|
||||
/** Gets a variable that is declared in this scope. */
|
||||
final Variable getAVariable() { result.getDeclaringScope() = this }
|
||||
|
||||
/** Gets the variable with the given name that is declared in this scope. */
|
||||
final Variable getVariable(string name) {
|
||||
result = this.getAVariable() and
|
||||
result.getName() = name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,6 @@ private import codeql_ruby.AST
|
||||
private import codeql.Locations
|
||||
private import internal.Variable
|
||||
|
||||
/** A scope in which variables can be declared. */
|
||||
class VariableScope extends Scope {
|
||||
/** Gets a variable that is declared in this scope. */
|
||||
final Variable getAVariable() { result.getDeclaringScope() = this }
|
||||
|
||||
/** Gets the variable with the given name that is declared in this scope. */
|
||||
final Variable getVariable(string name) {
|
||||
result = this.getAVariable() and
|
||||
result.getName() = name
|
||||
}
|
||||
}
|
||||
|
||||
/** A variable declared in a scope. */
|
||||
class Variable extends TVariable {
|
||||
Variable::Range range;
|
||||
@@ -32,7 +20,7 @@ class Variable extends TVariable {
|
||||
final Location getLocation() { result = range.getLocation() }
|
||||
|
||||
/** Gets the scope this variable is declared in. */
|
||||
final VariableScope getDeclaringScope() { result = range.getDeclaringScope() }
|
||||
final Scope getDeclaringScope() { result = range.getDeclaringScope() }
|
||||
|
||||
/** Gets an access to this variable. */
|
||||
VariableAccess getAnAccess() { result.getVariable() = this }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import codeql_ruby.AST
|
||||
import codeql_ruby.ast.Variable
|
||||
|
||||
query predicate variableAccess(VariableAccess access, Variable variable, VariableScope scope) {
|
||||
query predicate variableAccess(VariableAccess access, Variable variable, Scope scope) {
|
||||
variable = access.getVariable() and
|
||||
scope = variable.getDeclaringScope()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import codeql_ruby.ast.Variable
|
||||
import codeql_ruby.ast.Scope
|
||||
|
||||
select any(VariableScope x)
|
||||
select any(Scope x)
|
||||
|
||||
Reference in New Issue
Block a user