mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
JavaScript: Open-source extractor.
This commit is contained in:
45
javascript/extractor/src/com/semmle/js/ast/Identifier.java
Normal file
45
javascript/extractor/src/com/semmle/js/ast/Identifier.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.semmle.js.ast;
|
||||
|
||||
import com.semmle.ts.ast.INodeWithSymbol;
|
||||
import com.semmle.ts.ast.ITypeExpression;
|
||||
|
||||
/**
|
||||
* An identifier.
|
||||
*
|
||||
* Identifiers can either be variable declarations (like <code>x</code> in <code>var x;</code>),
|
||||
* variable references (like <code>x</code> in <code>x = 42</code>), property names
|
||||
* (like <code>f</code> in <code>e.f</code>), statement labels (like <code>l</code> in
|
||||
* <code>l: while(true);</code>), or statement label references (like <code>l</code> in
|
||||
* <code>break l;</code>).
|
||||
*/
|
||||
public class Identifier extends Expression implements IPattern, ITypeExpression, INodeWithSymbol {
|
||||
private final String name;
|
||||
private int symbol = -1;
|
||||
|
||||
public Identifier(SourceLocation loc, String name) {
|
||||
super("Identifier", loc);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Q, A> A accept(Visitor<Q, A> v, Q q) {
|
||||
return v.visit(this, q);
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this identifier.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSymbol(int symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user