mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Auto-format
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
package com.semmle.ts.extractor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
@@ -145,17 +139,22 @@ import com.semmle.ts.ast.OptionalTypeExpr;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.RestTypeExpr;
|
||||
import com.semmle.ts.ast.SatisfiesExpr;
|
||||
import com.semmle.ts.ast.TemplateLiteralTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeAliasDeclaration;
|
||||
import com.semmle.ts.ast.TypeAssertion;
|
||||
import com.semmle.ts.ast.SatisfiesExpr;
|
||||
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.collections.CollectionUtil;
|
||||
import com.semmle.util.data.IntList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Utility class for converting a <a
|
||||
@@ -877,8 +876,10 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
}
|
||||
|
||||
private Node convertStaticInitializerBlock(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
BlockStatement body = new BlockStatement(loc, convertChildren(node.get("body").getAsJsonObject(), "statements"));
|
||||
private Node convertStaticInitializerBlock(JsonObject node, SourceLocation loc)
|
||||
throws ParseError {
|
||||
BlockStatement body =
|
||||
new BlockStatement(loc, convertChildren(node.get("body").getAsJsonObject(), "statements"));
|
||||
return new StaticInitializer(loc, body);
|
||||
}
|
||||
|
||||
@@ -893,7 +894,8 @@ public class TypeScriptASTConverter {
|
||||
private Node convertCallExpression(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
List<Expression> arguments = convertChildren(node, "arguments");
|
||||
if (arguments.size() >= 1 && hasKind(node.get("expression"), "ImportKeyword")) {
|
||||
return new DynamicImport(loc, arguments.get(0), arguments.size() > 1 ? arguments.get(1) : null);
|
||||
return new DynamicImport(
|
||||
loc, arguments.get(0), arguments.size() > 1 ? arguments.get(1) : null);
|
||||
}
|
||||
Expression callee = convertChild(node, "expression");
|
||||
List<ITypeExpression> typeArguments = convertChildrenAsTypes(node, "typeArguments");
|
||||
@@ -1238,7 +1240,8 @@ public class TypeScriptASTConverter {
|
||||
|
||||
private Node convertExternalModuleReference(JsonObject node, SourceLocation loc)
|
||||
throws ParseError {
|
||||
ExternalModuleReference moduleRef = new ExternalModuleReference(loc, convertChild(node, "expression"));
|
||||
ExternalModuleReference moduleRef =
|
||||
new ExternalModuleReference(loc, convertChild(node, "expression"));
|
||||
attachSymbolInformation(moduleRef, node);
|
||||
return moduleRef;
|
||||
}
|
||||
@@ -1407,7 +1410,8 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
hasTypeKeyword = importClause.get("isTypeOnly").getAsBoolean();
|
||||
}
|
||||
ImportDeclaration importDecl = new ImportDeclaration(loc, specifiers, src, assertion, hasTypeKeyword);
|
||||
ImportDeclaration importDecl =
|
||||
new ImportDeclaration(loc, specifiers, src, assertion, hasTypeKeyword);
|
||||
attachSymbolInformation(importDecl, node);
|
||||
return importDecl;
|
||||
}
|
||||
@@ -1558,7 +1562,9 @@ public class TypeScriptASTConverter {
|
||||
nameNode = nameNode.get("name").getAsJsonObject();
|
||||
}
|
||||
return new JSXAttribute(
|
||||
loc, convertJSXName(((Expression)convertNode(nameNode, null))), convertChild(node, "initializer")); // 2
|
||||
loc,
|
||||
convertJSXName(((Expression) convertNode(nameNode, null))),
|
||||
convertChild(node, "initializer")); // 2
|
||||
}
|
||||
|
||||
private Node convertJsxClosingElement(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
@@ -1649,8 +1655,10 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
}
|
||||
if (literal instanceof TemplateLiteral) {
|
||||
// A LiteralType containing a NoSubstitutionTemplateLiteral must produce a TemplateLiteralTypeExpr
|
||||
return new TemplateLiteralTypeExpr(literal.getLoc(), new ArrayList<>(), ((TemplateLiteral)literal).getQuasis());
|
||||
// A LiteralType containing a NoSubstitutionTemplateLiteral must produce a
|
||||
// TemplateLiteralTypeExpr
|
||||
return new TemplateLiteralTypeExpr(
|
||||
literal.getLoc(), new ArrayList<>(), ((TemplateLiteral) literal).getQuasis());
|
||||
}
|
||||
return literal;
|
||||
}
|
||||
@@ -2254,7 +2262,7 @@ public class TypeScriptASTConverter {
|
||||
for (JsonElement element : node.get("elements").getAsJsonArray()) {
|
||||
Identifier id = null;
|
||||
if (getKind(element).equals("NamedTupleMember")) {
|
||||
id = (Identifier)convertNode(element.getAsJsonObject().get("name").getAsJsonObject());
|
||||
id = (Identifier) convertNode(element.getAsJsonObject().get("name").getAsJsonObject());
|
||||
}
|
||||
names.add(id);
|
||||
}
|
||||
@@ -2262,7 +2270,8 @@ public class TypeScriptASTConverter {
|
||||
return new TupleTypeExpr(loc, convertChildrenAsTypes(node, "elements"), names);
|
||||
}
|
||||
|
||||
// This method just does a trivial forward to the type. The names have already been extracted in `convertTupleType`.
|
||||
// This method just does a trivial forward to the type. The names have already been extracted in
|
||||
// `convertTupleType`.
|
||||
private Node convertNamedTupleMember(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
return convertChild(node, "type");
|
||||
}
|
||||
@@ -2291,7 +2300,7 @@ public class TypeScriptASTConverter {
|
||||
private Node convertAssertClause(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
List<Property> properties = new ArrayList<>();
|
||||
for (INode child : convertChildren(node, "elements")) {
|
||||
properties.add((Property)child);
|
||||
properties.add((Property) child);
|
||||
}
|
||||
// Adjust location to skip over the `assert` keyword.
|
||||
Matcher m = ASSERT_START.matcher(loc.getSource());
|
||||
@@ -2303,12 +2312,7 @@ public class TypeScriptASTConverter {
|
||||
|
||||
private Node convertAssertEntry(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
return new Property(
|
||||
loc,
|
||||
convertChild(node, "key"),
|
||||
convertChild(node, "value"),
|
||||
"init",
|
||||
false,
|
||||
false);
|
||||
loc, convertChild(node, "key"), convertChild(node, "value"), "init", false, false);
|
||||
}
|
||||
|
||||
private Node convertSatisfiesExpression(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
@@ -2490,7 +2494,8 @@ public class TypeScriptASTConverter {
|
||||
advance(loc, skipped);
|
||||
// capture group 1 is `default`, if present
|
||||
if (m.group(1) == null)
|
||||
return new ExportNamedDeclaration(outerLoc, (Statement) decl, new ArrayList<>(), null, null);
|
||||
return new ExportNamedDeclaration(
|
||||
outerLoc, (Statement) decl, new ArrayList<>(), null, null);
|
||||
return new ExportDefaultDeclaration(outerLoc, decl);
|
||||
}
|
||||
return decl;
|
||||
@@ -2586,8 +2591,9 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific modifier from the given node (or <code>null</code> if absent), as defined by its
|
||||
* <code>modifiers</code> property and the <code>kind</code> property of the modifier AST node.
|
||||
* Returns a specific modifier from the given node (or <code>null</code> if absent), as defined by
|
||||
* its <code>modifiers</code> property and the <code>kind</code> property of the modifier AST
|
||||
* node.
|
||||
*/
|
||||
private JsonObject getModifier(JsonObject node, String modKind) {
|
||||
for (JsonElement mod : getModifiers(node))
|
||||
@@ -2597,8 +2603,8 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a node has a particular modifier, as defined by its <code>modifiers</code> property
|
||||
* and the <code>kind</code> property of the modifier AST node.
|
||||
* Check whether a node has a particular modifier, as defined by its <code>modifiers</code>
|
||||
* property and the <code>kind</code> property of the modifier AST node.
|
||||
*/
|
||||
private boolean hasModifier(JsonObject node, String modKind) {
|
||||
return getModifier(node, modKind) != null;
|
||||
@@ -2639,8 +2645,8 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a node has a particular flag, as defined by its <code>flags</code> property and the
|
||||
* <code>ts.NodeFlags</code> in enum.
|
||||
* Check whether a node has a particular flag, as defined by its <code>flags</code> property and
|
||||
* the <code>ts.NodeFlags</code> in enum.
|
||||
*/
|
||||
private boolean hasFlag(JsonObject node, String flagName) {
|
||||
int flagId = metadata.getNodeFlagId(flagName);
|
||||
@@ -2683,7 +2689,7 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the declaration kind of the given node, which is one of {@code "var"}, {@code "let"},
|
||||
* Gets the declaration kind of the given node, which is one of {@code "var"}, {@code "let"},
|
||||
* {@code "const"}, or {@code "using"}.
|
||||
*/
|
||||
private String getDeclarationKind(JsonObject declarationList) {
|
||||
|
||||
Reference in New Issue
Block a user