Files
codeql/javascript/extractor/src/com/semmle/js/ast/VariableDeclaration.java
Max Schaefer c4fa29dd0f JavaScript: Autoformat extractor sources using google-java-format.
No special settings; command:

  find javascript/extractor/src -name "*.java" | xargs java -jar /path/to/google-java-format-1.7-all-deps.jar --replace
2019-02-28 14:30:06 +00:00

57 lines
1.5 KiB
Java

package com.semmle.js.ast;
import com.semmle.js.extractor.ExtractorConfig.ECMAVersion;
import java.util.List;
/**
* A variable declaration statement containing one or more {@link VariableDeclarator} expressions.
*/
public class VariableDeclaration extends Statement {
private final String kind;
private final List<VariableDeclarator> declarations;
private final boolean hasDeclareKeyword;
public VariableDeclaration(
SourceLocation loc,
String kind,
List<VariableDeclarator> declarations,
boolean hasDeclareKeyword) {
super("VariableDeclaration", loc);
this.kind = kind;
this.declarations = declarations;
this.hasDeclareKeyword = hasDeclareKeyword;
}
@Override
public <Q, A> A accept(Visitor<Q, A> v, Q q) {
return v.visit(this, q);
}
/**
* The kind of this variable declaration statement; one of <code>"var"</code>, <code>"let"</code>
* or <code>"const"</code>.
*/
public String getKind() {
return kind;
}
/**
* Is this a block-scoped declaration?
*
* <p>Note that <code>const</code> declarations are function-scoped pre-ECMAScript 2015.
*/
public boolean isBlockScoped(ECMAVersion ecmaVersion) {
return "let".equals(kind)
|| ecmaVersion.compareTo(ECMAVersion.ECMA2015) >= 0 && "const".equals(kind);
}
/** The declarations in this declaration statement. */
public List<VariableDeclarator> getDeclarations() {
return declarations;
}
public boolean hasDeclareKeyword() {
return hasDeclareKeyword;
}
}