diff --git a/javascript/extractor/src/com/semmle/js/ast/DefaultVisitor.java b/javascript/extractor/src/com/semmle/js/ast/DefaultVisitor.java index e6c6110fd36..d6779fdaa3b 100644 --- a/javascript/extractor/src/com/semmle/js/ast/DefaultVisitor.java +++ b/javascript/extractor/src/com/semmle/js/ast/DefaultVisitor.java @@ -35,7 +35,6 @@ import com.semmle.ts.ast.InterfaceDeclaration; import com.semmle.ts.ast.InterfaceTypeExpr; import com.semmle.ts.ast.IntersectionTypeExpr; import com.semmle.ts.ast.IsTypeExpr; -import com.semmle.ts.ast.UnaryTypeExpr; import com.semmle.ts.ast.KeywordTypeExpr; import com.semmle.ts.ast.MappedTypeExpr; import com.semmle.ts.ast.NamespaceDeclaration; @@ -49,6 +48,7 @@ import com.semmle.ts.ast.TypeAssertion; import com.semmle.ts.ast.TypeExpression; import com.semmle.ts.ast.TypeParameter; import com.semmle.ts.ast.TypeofTypeExpr; +import com.semmle.ts.ast.UnaryTypeExpr; import com.semmle.ts.ast.UnionTypeExpr; import com.semmle.util.exception.CatastrophicError; diff --git a/javascript/extractor/src/com/semmle/js/ast/Visitor.java b/javascript/extractor/src/com/semmle/js/ast/Visitor.java index a1ab0101208..f825d448719 100644 --- a/javascript/extractor/src/com/semmle/js/ast/Visitor.java +++ b/javascript/extractor/src/com/semmle/js/ast/Visitor.java @@ -31,7 +31,6 @@ import com.semmle.ts.ast.InterfaceDeclaration; import com.semmle.ts.ast.InterfaceTypeExpr; import com.semmle.ts.ast.IntersectionTypeExpr; import com.semmle.ts.ast.IsTypeExpr; -import com.semmle.ts.ast.UnaryTypeExpr; import com.semmle.ts.ast.KeywordTypeExpr; import com.semmle.ts.ast.MappedTypeExpr; import com.semmle.ts.ast.NamespaceDeclaration; @@ -44,6 +43,7 @@ import com.semmle.ts.ast.TypeAliasDeclaration; import com.semmle.ts.ast.TypeAssertion; import com.semmle.ts.ast.TypeParameter; import com.semmle.ts.ast.TypeofTypeExpr; +import com.semmle.ts.ast.UnaryTypeExpr; import com.semmle.ts.ast.UnionTypeExpr; /** diff --git a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java index 64bad10273d..cc867bc9d68 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java @@ -1,11 +1,5 @@ package com.semmle.js.extractor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.Stack; - import com.semmle.js.ast.AClass; import com.semmle.js.ast.AFunction; import com.semmle.js.ast.AFunctionExpression; @@ -149,6 +143,11 @@ import com.semmle.ts.ast.UnionTypeExpr; import com.semmle.util.collections.CollectionUtil; import com.semmle.util.trap.TrapWriter; import com.semmle.util.trap.TrapWriter.Label; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.Stack; /** Extractor for AST-based information; invoked by the {@link JSExtractor}. */ public class ASTExtractor { diff --git a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java index 0544290ebd6..5ffa5680cd9 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java +++ b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java @@ -1,5 +1,26 @@ package com.semmle.js.extractor; +import com.semmle.js.extractor.ExtractorConfig.SourceType; +import com.semmle.js.extractor.FileExtractor.FileType; +import com.semmle.js.extractor.trapcache.DefaultTrapCache; +import com.semmle.js.extractor.trapcache.DummyTrapCache; +import com.semmle.js.extractor.trapcache.ITrapCache; +import com.semmle.js.parser.ParsedProject; +import com.semmle.js.parser.TypeScriptParser; +import com.semmle.ts.extractor.TypeExtractor; +import com.semmle.ts.extractor.TypeTable; +import com.semmle.util.data.StringUtil; +import com.semmle.util.exception.CatastrophicError; +import com.semmle.util.exception.Exceptions; +import com.semmle.util.exception.ResourceError; +import com.semmle.util.exception.UserError; +import com.semmle.util.extraction.ExtractorOutputConfig; +import com.semmle.util.files.FileUtil; +import com.semmle.util.io.csv.CSVReader; +import com.semmle.util.language.LegacyLanguage; +import com.semmle.util.process.Env; +import com.semmle.util.projectstructure.ProjectLayout; +import com.semmle.util.trap.TrapWriter; import java.io.File; import java.io.IOException; import java.io.Reader; @@ -27,28 +48,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import com.semmle.js.extractor.ExtractorConfig.SourceType; -import com.semmle.js.extractor.FileExtractor.FileType; -import com.semmle.js.extractor.trapcache.DefaultTrapCache; -import com.semmle.js.extractor.trapcache.DummyTrapCache; -import com.semmle.js.extractor.trapcache.ITrapCache; -import com.semmle.js.parser.ParsedProject; -import com.semmle.js.parser.TypeScriptParser; -import com.semmle.ts.extractor.TypeExtractor; -import com.semmle.ts.extractor.TypeTable; -import com.semmle.util.data.StringUtil; -import com.semmle.util.exception.CatastrophicError; -import com.semmle.util.exception.Exceptions; -import com.semmle.util.exception.ResourceError; -import com.semmle.util.exception.UserError; -import com.semmle.util.extraction.ExtractorOutputConfig; -import com.semmle.util.files.FileUtil; -import com.semmle.util.io.csv.CSVReader; -import com.semmle.util.language.LegacyLanguage; -import com.semmle.util.process.Env; -import com.semmle.util.projectstructure.ProjectLayout; -import com.semmle.util.trap.TrapWriter; - /** * An alternative entry point to the JavaScript extractor. * @@ -71,8 +70,8 @@ import com.semmle.util.trap.TrapWriter; * patterns that can be used to refine the list of files to include and exclude *
LGTM_INDEX_TYPESCRIPT: whether to extract TypeScript
* LGTM_INDEX_FILETYPES: a newline-separated list of ".extension:filetype" pairs
- * specifying which {@link FileType} to use for the given extension; the additional file
- * type XML is also supported
+ * specifying which {@link FileType} to use for the given extension; the additional file type
+ * XML is also supported
* LGTM_INDEX_XML_MODE: whether to extract XML files
* LGTM_THREADS: the maximum number of files to extract in parallel
* LGTM_TRAP_CACHE: the path of a directory to use for trap caching
@@ -166,8 +165,8 @@ import com.semmle.util.trap.TrapWriter;
* If LGTM_INDEX_XML_MODE is set to ALL, then all files with extension
* .xml under LGTM_SRC are extracted as XML (in addition to any files
* whose file type is specified to be XML via LGTM_INDEX_SOURCE_TYPE).
- * Currently XML extraction does not respect inclusion and exclusion filters, but this is a bug,
- * not a feature, and hence will change eventually.
+ * Currently XML extraction does not respect inclusion and exclusion filters, but this is a bug, not
+ * a feature, and hence will change eventually.
*
*
Note that all these customisations only apply to This can differ from the start of the current token in case the two tokens are separated
+ * by whitespace.
*/
private Position endPos() {
- return new Position(this.lineNumber + 1, endOfPrevToken - lineStart, endOfPrevToken + absoluteOffset);
+ return new Position(
+ this.lineNumber + 1, endOfPrevToken - lineStart, endOfPrevToken + absoluteOffset);
}
private The script launches the Node.js wrapper in the Node.js runtime, looking for {@code node}
- * on the {@code PATH} by default. Non-standard locations can be configured using the property
- * {@value #TYPESCRIPT_NODE_RUNTIME_VAR}, and additional arguments can be configured using the
- * property {@value #TYPESCRIPT_NODE_RUNTIME_EXTRA_ARGS_VAR}.
+ *
+ * The script launches the Node.js wrapper in the Node.js runtime, looking for {@code node} on
+ * the {@code PATH} by default. Non-standard locations can be configured using the property {@value
+ * #TYPESCRIPT_NODE_RUNTIME_VAR}, and additional arguments can be configured using the property
+ * {@value #TYPESCRIPT_NODE_RUNTIME_EXTRA_ARGS_VAR}.
*
* The script is started upon parsing the first TypeScript file and then is kept running in the
* background, passing it requests for parsing files and getting JSON-encoded ASTs as responses.
@@ -62,8 +60,8 @@ public class TypeScriptParser {
public static final String PARSER_WRAPPER_PATH_ENV_VAR = "SEMMLE_TYPESCRIPT_PARSER_WRAPPER";
/**
- * An environment variable that can be set to indicate the location of the Node.js runtime,
- * as an alternative to adding Node to the PATH.
+ * An environment variable that can be set to indicate the location of the Node.js runtime, as an
+ * alternative to adding Node to the PATH.
*/
public static final String TYPESCRIPT_NODE_RUNTIME_VAR = "SEMMLE_TYPESCRIPT_NODE_RUNTIME";
@@ -71,7 +69,8 @@ public class TypeScriptParser {
* An environment variable that can be set to provide additional arguments to the Node.js runtime
* each time it is invoked. Arguments should be separated by spaces.
*/
- public static final String TYPESCRIPT_NODE_RUNTIME_EXTRA_ARGS_VAR = "SEMMLE_TYPESCRIPT_NODE_RUNTIME_EXTRA_ARGS";
+ public static final String TYPESCRIPT_NODE_RUNTIME_EXTRA_ARGS_VAR =
+ "SEMMLE_TYPESCRIPT_NODE_RUNTIME_EXTRA_ARGS";
/**
* An environment variable that can be set to specify a timeout to use when verifying the
@@ -102,8 +101,8 @@ public class TypeScriptParser {
/**
* An environment variable with additional VM arguments to pass to the Node process.
- *
- * Only Only This can be keyof T or readonly T.
*/
public class UnaryTypeExpr extends TypeExpression {
private final ITypeExpression elementType;
diff --git a/javascript/extractor/src/com/semmle/ts/extractor/TypeExtractor.java b/javascript/extractor/src/com/semmle/ts/extractor/TypeExtractor.java
index 8d1aae35681..ed9242490e9 100644
--- a/javascript/extractor/src/com/semmle/ts/extractor/TypeExtractor.java
+++ b/javascript/extractor/src/com/semmle/ts/extractor/TypeExtractor.java
@@ -4,7 +4,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.semmle.util.trap.TrapWriter;
import com.semmle.util.trap.TrapWriter.Label;
-
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
LGTM_SRC. Extraction of externs
* is not customisable.
@@ -288,8 +287,7 @@ public class AutoBuild {
try {
fileType = StringUtil.uc(fileType);
if ("XML".equals(fileType)) {
- if (extension.length() < 2)
- throw new UserError("Invalid extension '" + extension + "'.");
+ if (extension.length() < 2) throw new UserError("Invalid extension '" + extension + "'.");
xmlExtensions.add(extension.substring(1));
} else {
fileTypes.put(extension, FileType.valueOf(fileType));
@@ -304,8 +302,7 @@ public class AutoBuild {
private void setupXmlMode() {
String xmlMode = getEnvVar("LGTM_INDEX_XML_MODE", "DISABLED");
xmlMode = StringUtil.uc(xmlMode.trim());
- if ("ALL".equals(xmlMode))
- xmlExtensions.add("xml");
+ if ("ALL".equals(xmlMode)) xmlExtensions.add("xml");
else if (!"DISABLED".equals(xmlMode))
throw new UserError("Invalid XML mode '" + xmlMode + "' (should be either ALL or DISABLED).");
}
@@ -744,8 +741,7 @@ public class AutoBuild {
try {
long start = logBeginProcess("Extracting " + file);
Integer loc = extractor.extract(f, state);
- if (!extractor.getConfig().isExterns() && (loc == null || loc != 0))
- seenCode = true;
+ if (!extractor.getConfig().isExterns() && (loc == null || loc != 0)) seenCode = true;
logEndProcess(start, "Done extracting " + file);
} catch (Throwable t) {
System.err.println("Exception while extracting " + file + ".");
@@ -776,8 +772,7 @@ public class AutoBuild {
}
protected void extractXml() throws IOException {
- if (xmlExtensions.isEmpty())
- return;
+ if (xmlExtensions.isEmpty()) return;
List--inspect or --inspect-brk may be used at the moment.
+ *
+ * --inspect or --inspect-brk may be used at the moment.
*/
public static final String TYPESCRIPT_NODE_FLAGS = "SEMMLE_TYPESCRIPT_NODE_FLAGS";
@@ -123,8 +122,8 @@ public class TypeScriptParser {
private String nodeJsRuntime;
/**
- * Arguments to pass to the Node.js runtime each time it is invoked.
- * Initialised by {@link #verifyNodeInstallation}.
+ * Arguments to pass to the Node.js runtime each time it is invoked. Initialised by {@link
+ * #verifyNodeInstallation}.
*/
private List