id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
24,700
google/closure-compiler
src/com/google/javascript/jscomp/AstFactory.java
AstFactory.createThisAliasDeclarationForFunction
Node createThisAliasDeclarationForFunction(String aliasName, Node functionNode) { return createSingleConstNameDeclaration( aliasName, createThis(getTypeOfThisForFunctionNode(functionNode))); }
java
Node createThisAliasDeclarationForFunction(String aliasName, Node functionNode) { return createSingleConstNameDeclaration( aliasName, createThis(getTypeOfThisForFunctionNode(functionNode))); }
[ "Node", "createThisAliasDeclarationForFunction", "(", "String", "aliasName", ",", "Node", "functionNode", ")", "{", "return", "createSingleConstNameDeclaration", "(", "aliasName", ",", "createThis", "(", "getTypeOfThisForFunctionNode", "(", "functionNode", ")", ")", ")", ...
Creates a statement declaring a const alias for "this" to be used in the given function node. <p>e.g. `const aliasName = this;`
[ "Creates", "a", "statement", "declaring", "a", "const", "alias", "for", "this", "to", "be", "used", "in", "the", "given", "function", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L322-L325
24,701
google/closure-compiler
src/com/google/javascript/jscomp/AstFactory.java
AstFactory.createSingleConstNameDeclaration
Node createSingleConstNameDeclaration(String variableName, Node value) { return IR.constNode(createName(variableName, value.getJSType()), value); }
java
Node createSingleConstNameDeclaration(String variableName, Node value) { return IR.constNode(createName(variableName, value.getJSType()), value); }
[ "Node", "createSingleConstNameDeclaration", "(", "String", "variableName", ",", "Node", "value", ")", "{", "return", "IR", ".", "constNode", "(", "createName", "(", "variableName", ",", "value", ".", "getJSType", "(", ")", ")", ",", "value", ")", ";", "}" ]
Creates a new `const` declaration statement for a single variable name. <p>Takes the type for the variable name from the value node. <p>e.g. `const variableName = value;`
[ "Creates", "a", "new", "const", "declaration", "statement", "for", "a", "single", "variable", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L334-L336
24,702
google/closure-compiler
src/com/google/javascript/jscomp/AstFactory.java
AstFactory.createArgumentsReference
Node createArgumentsReference() { Node result = IR.name("arguments"); if (isAddingTypes()) { result.setJSType(argumentsTypeSupplier.get()); } return result; }
java
Node createArgumentsReference() { Node result = IR.name("arguments"); if (isAddingTypes()) { result.setJSType(argumentsTypeSupplier.get()); } return result; }
[ "Node", "createArgumentsReference", "(", ")", "{", "Node", "result", "=", "IR", ".", "name", "(", "\"arguments\"", ")", ";", "if", "(", "isAddingTypes", "(", ")", ")", "{", "result", ".", "setJSType", "(", "argumentsTypeSupplier", ".", "get", "(", ")", "...
Creates a reference to "arguments" with the type specified in externs, or unknown if the externs for it weren't included.
[ "Creates", "a", "reference", "to", "arguments", "with", "the", "type", "specified", "in", "externs", "or", "unknown", "if", "the", "externs", "for", "it", "weren", "t", "included", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L342-L348
24,703
google/closure-compiler
src/com/google/javascript/jscomp/AstFactory.java
AstFactory.createObjectDotAssignCall
Node createObjectDotAssignCall(Scope scope, JSType returnType, Node... args) { Node objAssign = createQName(scope, "Object.assign"); Node result = createCall(objAssign, args); if (isAddingTypes()) { // Make a unique function type that returns the exact type we've inferred it to be. // Object.as...
java
Node createObjectDotAssignCall(Scope scope, JSType returnType, Node... args) { Node objAssign = createQName(scope, "Object.assign"); Node result = createCall(objAssign, args); if (isAddingTypes()) { // Make a unique function type that returns the exact type we've inferred it to be. // Object.as...
[ "Node", "createObjectDotAssignCall", "(", "Scope", "scope", ",", "JSType", "returnType", ",", "Node", "...", "args", ")", "{", "Node", "objAssign", "=", "createQName", "(", "scope", ",", "\"Object.assign\"", ")", ";", "Node", "result", "=", "createCall", "(", ...
Creates a call to Object.assign that returns the specified type. <p>Object.assign returns !Object in the externs, which can lose type information if the actual type is known.
[ "Creates", "a", "call", "to", "Object", ".", "assign", "that", "returns", "the", "specified", "type", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L572-L589
24,704
google/closure-compiler
src/com/google/javascript/jscomp/AstFactory.java
AstFactory.createAssignStatement
Node createAssignStatement(Node lhs, Node rhs) { return exprResult(createAssign(lhs, rhs)); }
java
Node createAssignStatement(Node lhs, Node rhs) { return exprResult(createAssign(lhs, rhs)); }
[ "Node", "createAssignStatement", "(", "Node", "lhs", ",", "Node", "rhs", ")", "{", "return", "exprResult", "(", "createAssign", "(", "lhs", ",", "rhs", ")", ")", ";", "}" ]
Creates a statement `lhs = rhs;`.
[ "Creates", "a", "statement", "lhs", "=", "rhs", ";", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L652-L654
24,705
google/closure-compiler
src/com/google/javascript/jscomp/AstFactory.java
AstFactory.createAssign
Node createAssign(Node lhs, Node rhs) { Node result = IR.assign(lhs, rhs); if (isAddingTypes()) { result.setJSType(rhs.getJSType()); } return result; }
java
Node createAssign(Node lhs, Node rhs) { Node result = IR.assign(lhs, rhs); if (isAddingTypes()) { result.setJSType(rhs.getJSType()); } return result; }
[ "Node", "createAssign", "(", "Node", "lhs", ",", "Node", "rhs", ")", "{", "Node", "result", "=", "IR", ".", "assign", "(", "lhs", ",", "rhs", ")", ";", "if", "(", "isAddingTypes", "(", ")", ")", "{", "result", ".", "setJSType", "(", "rhs", ".", "...
Creates an assignment expression `lhs = rhs`
[ "Creates", "an", "assignment", "expression", "lhs", "=", "rhs" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L657-L663
24,706
google/closure-compiler
src/com/google/javascript/jscomp/AstFactory.java
AstFactory.getVarNameType
private JSType getVarNameType(Scope scope, String name) { Var var = scope.getVar(name); JSType type = null; if (var != null) { Node nameDefinitionNode = var.getNode(); if (nameDefinitionNode != null) { type = nameDefinitionNode.getJSType(); } } if (type == null) { // ...
java
private JSType getVarNameType(Scope scope, String name) { Var var = scope.getVar(name); JSType type = null; if (var != null) { Node nameDefinitionNode = var.getNode(); if (nameDefinitionNode != null) { type = nameDefinitionNode.getJSType(); } } if (type == null) { // ...
[ "private", "JSType", "getVarNameType", "(", "Scope", "scope", ",", "String", "name", ")", "{", "Var", "var", "=", "scope", ".", "getVar", "(", "name", ")", ";", "JSType", "type", "=", "null", ";", "if", "(", "var", "!=", "null", ")", "{", "Node", "...
Look up the correct type for the given name in the given scope. <p>Returns the unknown type if no type can be found
[ "Look", "up", "the", "correct", "type", "for", "the", "given", "name", "in", "the", "given", "scope", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L978-L992
24,707
google/closure-compiler
src/com/google/javascript/jscomp/SideEffectsAnalysis.java
SideEffectsAnalysis.nodesHaveSameControlFlow
private static boolean nodesHaveSameControlFlow(Node node1, Node node2) { /* * We conservatively approximate this with the following criteria: * * Define the "deepest control dependent block" for a node to be the * closest ancestor whose *parent* is a control structure and where that * ance...
java
private static boolean nodesHaveSameControlFlow(Node node1, Node node2) { /* * We conservatively approximate this with the following criteria: * * Define the "deepest control dependent block" for a node to be the * closest ancestor whose *parent* is a control structure and where that * ance...
[ "private", "static", "boolean", "nodesHaveSameControlFlow", "(", "Node", "node1", ",", "Node", "node2", ")", "{", "/*\n * We conservatively approximate this with the following criteria:\n *\n * Define the \"deepest control dependent block\" for a node to be the\n * closest an...
Returns true if the two nodes have the same control flow properties, that is, is node1 be executed every time node2 is executed and vice versa?
[ "Returns", "true", "if", "the", "two", "nodes", "have", "the", "same", "control", "flow", "properties", "that", "is", "is", "node1", "be", "executed", "every", "time", "node2", "is", "executed", "and", "vice", "versa?" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/SideEffectsAnalysis.java#L227-L314
24,708
google/closure-compiler
src/com/google/javascript/jscomp/SideEffectsAnalysis.java
SideEffectsAnalysis.isControlDependentChild
private static boolean isControlDependentChild(Node child) { Node parent = child.getParent(); if (parent == null) { return false; } ArrayList<Node> siblings = new ArrayList<>(); Iterables.addAll(siblings, parent.children()); int indexOfChildInParent = siblings.indexOf(child); switc...
java
private static boolean isControlDependentChild(Node child) { Node parent = child.getParent(); if (parent == null) { return false; } ArrayList<Node> siblings = new ArrayList<>(); Iterables.addAll(siblings, parent.children()); int indexOfChildInParent = siblings.indexOf(child); switc...
[ "private", "static", "boolean", "isControlDependentChild", "(", "Node", "child", ")", "{", "Node", "parent", "=", "child", ".", "getParent", "(", ")", ";", "if", "(", "parent", "==", "null", ")", "{", "return", "false", ";", "}", "ArrayList", "<", "Node"...
Returns true if the number of times the child executes depends on the parent. For example, the guard of an IF is not control dependent on the IF, but its two THEN/ELSE blocks are. Also, the guard of WHILE and DO are control dependent on the parent since the number of times it executes depends on the parent.
[ "Returns", "true", "if", "the", "number", "of", "times", "the", "child", "executes", "depends", "on", "the", "parent", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/SideEffectsAnalysis.java#L326-L358
24,709
google/closure-compiler
src/com/google/javascript/jscomp/SideEffectsAnalysis.java
SideEffectsAnalysis.nodeHasCall
private static boolean nodeHasCall(Node node) { return NodeUtil.has(node, new Predicate<Node>() { @Override public boolean apply(Node input) { return input.isCall() || input.isNew() || input.isTaggedTemplateLit(); }}, NOT_FUNCTION_PREDICATE); }
java
private static boolean nodeHasCall(Node node) { return NodeUtil.has(node, new Predicate<Node>() { @Override public boolean apply(Node input) { return input.isCall() || input.isNew() || input.isTaggedTemplateLit(); }}, NOT_FUNCTION_PREDICATE); }
[ "private", "static", "boolean", "nodeHasCall", "(", "Node", "node", ")", "{", "return", "NodeUtil", ".", "has", "(", "node", ",", "new", "Predicate", "<", "Node", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "Node", "input", ...
Returns true if a node has a CALL or a NEW descendant.
[ "Returns", "true", "if", "a", "node", "has", "a", "CALL", "or", "a", "NEW", "descendant", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/SideEffectsAnalysis.java#L394-L401
24,710
google/closure-compiler
src/com/google/javascript/jscomp/DefaultExterns.java
DefaultExterns.prepareExterns
public static List<SourceFile> prepareExterns(CompilerOptions.Environment env, Map<String, SourceFile> externs) { List<SourceFile> out = new ArrayList<>(); for (String key : BUILTIN_LANG_EXTERNS) { Preconditions.checkState(externs.containsKey(key), "Externs must contain builtin: %s", key); ...
java
public static List<SourceFile> prepareExterns(CompilerOptions.Environment env, Map<String, SourceFile> externs) { List<SourceFile> out = new ArrayList<>(); for (String key : BUILTIN_LANG_EXTERNS) { Preconditions.checkState(externs.containsKey(key), "Externs must contain builtin: %s", key); ...
[ "public", "static", "List", "<", "SourceFile", ">", "prepareExterns", "(", "CompilerOptions", ".", "Environment", "env", ",", "Map", "<", "String", ",", "SourceFile", ">", "externs", ")", "{", "List", "<", "SourceFile", ">", "out", "=", "new", "ArrayList", ...
Filters and orders the passed externs for the specified environment. @param env The environment being used. @param externs Flat tilename to source externs map. Must be mutable and will be modified. @return Ordered list of externs.
[ "Filters", "and", "orders", "the", "passed", "externs", "for", "the", "specified", "environment", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DefaultExterns.java#L68-L88
24,711
google/closure-compiler
src/com/google/javascript/jscomp/PhaseOptimizer.java
PhaseOptimizer.setValidityCheck
void setValidityCheck(PassFactory validityCheck) { this.validityCheck = validityCheck; this.changeVerifier = new ChangeVerifier(compiler).snapshot(jsRoot); }
java
void setValidityCheck(PassFactory validityCheck) { this.validityCheck = validityCheck; this.changeVerifier = new ChangeVerifier(compiler).snapshot(jsRoot); }
[ "void", "setValidityCheck", "(", "PassFactory", "validityCheck", ")", "{", "this", ".", "validityCheck", "=", "validityCheck", ";", "this", ".", "changeVerifier", "=", "new", "ChangeVerifier", "(", "compiler", ")", ".", "snapshot", "(", "jsRoot", ")", ";", "}"...
Adds a checker to be run after every pass. Intended for development.
[ "Adds", "a", "checker", "to", "be", "run", "after", "every", "pass", ".", "Intended", "for", "development", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PhaseOptimizer.java#L200-L203
24,712
google/closure-compiler
src/com/google/javascript/jscomp/PhaseOptimizer.java
PhaseOptimizer.process
@Override public void process(Node externs, Node root) { progress = 0.0; progressStep = 0.0; if (progressRange != null) { progressStep = (progressRange.maxValue - progressRange.initialValue) / passes.size(); progress = progressRange.initialValue; } // When looking at this co...
java
@Override public void process(Node externs, Node root) { progress = 0.0; progressStep = 0.0; if (progressRange != null) { progressStep = (progressRange.maxValue - progressRange.initialValue) / passes.size(); progress = progressRange.initialValue; } // When looking at this co...
[ "@", "Override", "public", "void", "process", "(", "Node", "externs", ",", "Node", "root", ")", "{", "progress", "=", "0.0", ";", "progressStep", "=", "0.0", ";", "if", "(", "progressRange", "!=", "null", ")", "{", "progressStep", "=", "(", "progressRang...
Run all the passes in the optimizer.
[ "Run", "all", "the", "passes", "in", "the", "optimizer", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PhaseOptimizer.java#L216-L242
24,713
google/closure-compiler
src/com/google/javascript/jscomp/PhaseOptimizer.java
PhaseOptimizer.maybeRunValidityCheck
private void maybeRunValidityCheck(String passName, Node externs, Node root) { if (validityCheck == null) { return; } try { validityCheck.create(compiler).process(externs, root); changeVerifier.checkRecordedChanges(passName, jsRoot); } catch (Exception e) { throw new IllegalState...
java
private void maybeRunValidityCheck(String passName, Node externs, Node root) { if (validityCheck == null) { return; } try { validityCheck.create(compiler).process(externs, root); changeVerifier.checkRecordedChanges(passName, jsRoot); } catch (Exception e) { throw new IllegalState...
[ "private", "void", "maybeRunValidityCheck", "(", "String", "passName", ",", "Node", "externs", ",", "Node", "root", ")", "{", "if", "(", "validityCheck", "==", "null", ")", "{", "return", ";", "}", "try", "{", "validityCheck", ".", "create", "(", "compiler...
Runs the validity check if it is available.
[ "Runs", "the", "validity", "check", "if", "it", "is", "available", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PhaseOptimizer.java#L255-L265
24,714
google/closure-compiler
src/com/google/javascript/jscomp/Es6RewriteClassExtendsExpressions.java
Es6RewriteClassExtendsExpressions.canDecomposeSimply
private boolean canDecomposeSimply(Node classNode) { Node enclosingStatement = checkNotNull(NodeUtil.getEnclosingStatement(classNode), classNode); if (enclosingStatement == classNode) { // `class Foo extends some_expression {}` // can always be converted to // ``` // const tmpvar = some_...
java
private boolean canDecomposeSimply(Node classNode) { Node enclosingStatement = checkNotNull(NodeUtil.getEnclosingStatement(classNode), classNode); if (enclosingStatement == classNode) { // `class Foo extends some_expression {}` // can always be converted to // ``` // const tmpvar = some_...
[ "private", "boolean", "canDecomposeSimply", "(", "Node", "classNode", ")", "{", "Node", "enclosingStatement", "=", "checkNotNull", "(", "NodeUtil", ".", "getEnclosingStatement", "(", "classNode", ")", ",", "classNode", ")", ";", "if", "(", "enclosingStatement", "=...
Find common cases where we can safely decompose class extends expressions which are not qualified names. Enables transpilation of complex extends expressions. <p>We can only decompose the expression in a limited set of cases to avoid changing evaluation order of side-effect causing statements.
[ "Find", "common", "cases", "where", "we", "can", "safely", "decompose", "class", "extends", "expressions", "which", "are", "not", "qualified", "names", ".", "Enables", "transpilation", "of", "complex", "extends", "expressions", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteClassExtendsExpressions.java#L97-L132
24,715
google/closure-compiler
src/com/google/javascript/jscomp/Es6RewriteClassExtendsExpressions.java
Es6RewriteClassExtendsExpressions.decomposeInIIFE
private void decomposeInIIFE(NodeTraversal t, Node classNode) { // converts // `class X extends something {}` // to // `(function() { return class X extends something {}; })()` Node functionBody = IR.block(); Node function = IR.function(IR.name(""), IR.paramList(), functionBody); Node call =...
java
private void decomposeInIIFE(NodeTraversal t, Node classNode) { // converts // `class X extends something {}` // to // `(function() { return class X extends something {}; })()` Node functionBody = IR.block(); Node function = IR.function(IR.name(""), IR.paramList(), functionBody); Node call =...
[ "private", "void", "decomposeInIIFE", "(", "NodeTraversal", "t", ",", "Node", "classNode", ")", "{", "// converts", "// `class X extends something {}`", "// to", "// `(function() { return class X extends something {}; })()`", "Node", "functionBody", "=", "IR", ".", "block", ...
When a class is used in an expressions where adding an alias as the previous statement might change execution order of a side-effect causing statement, wrap the class in an IIFE so that decomposition can happen safely.
[ "When", "a", "class", "is", "used", "in", "an", "expressions", "where", "adding", "an", "alias", "as", "the", "previous", "statement", "might", "change", "execution", "order", "of", "a", "side", "-", "effect", "causing", "statement", "wrap", "the", "class", ...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteClassExtendsExpressions.java#L156-L172
24,716
google/closure-compiler
src/com/google/javascript/jscomp/BasicBlock.java
BasicBlock.provablyExecutesBefore
boolean provablyExecutesBefore(BasicBlock thatBlock) { // If thatBlock is a descendant of this block, and there are no hoisted // blocks between them, then this block must start before thatBlock. BasicBlock currentBlock; for (currentBlock = thatBlock; currentBlock != null && currentBlock != this...
java
boolean provablyExecutesBefore(BasicBlock thatBlock) { // If thatBlock is a descendant of this block, and there are no hoisted // blocks between them, then this block must start before thatBlock. BasicBlock currentBlock; for (currentBlock = thatBlock; currentBlock != null && currentBlock != this...
[ "boolean", "provablyExecutesBefore", "(", "BasicBlock", "thatBlock", ")", "{", "// If thatBlock is a descendant of this block, and there are no hoisted", "// blocks between them, then this block must start before thatBlock.", "BasicBlock", "currentBlock", ";", "for", "(", "currentBlock",...
Determines whether this block is guaranteed to begin executing before the given block does.
[ "Determines", "whether", "this", "block", "is", "guaranteed", "to", "begin", "executing", "before", "the", "given", "block", "does", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/BasicBlock.java#L81-L93
24,717
google/closure-compiler
src/com/google/javascript/jscomp/Denormalize.java
Denormalize.maybeCollapseIntoForStatements
private void maybeCollapseIntoForStatements(Node n, Node parent) { // Only SCRIPT, BLOCK, and LABELs can have FORs that can be collapsed into. // LABELs are not supported here. if (parent == null || !NodeUtil.isStatementBlock(parent)) { return; } // Is the current node something that can be i...
java
private void maybeCollapseIntoForStatements(Node n, Node parent) { // Only SCRIPT, BLOCK, and LABELs can have FORs that can be collapsed into. // LABELs are not supported here. if (parent == null || !NodeUtil.isStatementBlock(parent)) { return; } // Is the current node something that can be i...
[ "private", "void", "maybeCollapseIntoForStatements", "(", "Node", "n", ",", "Node", "parent", ")", "{", "// Only SCRIPT, BLOCK, and LABELs can have FORs that can be collapsed into.", "// LABELs are not supported here.", "if", "(", "parent", "==", "null", "||", "!", "NodeUtil"...
Collapse VARs and EXPR_RESULT node into FOR loop initializers where possible.
[ "Collapse", "VARs", "and", "EXPR_RESULT", "node", "into", "FOR", "loop", "initializers", "where", "possible", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Denormalize.java#L127-L188
24,718
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.longToPaddedString
private static String longToPaddedString(long v, int digitsColumnWidth) { int digitWidth = numDigits(v); StringBuilder sb = new StringBuilder(); appendSpaces(sb, digitsColumnWidth - digitWidth); sb.append(v); return sb.toString(); }
java
private static String longToPaddedString(long v, int digitsColumnWidth) { int digitWidth = numDigits(v); StringBuilder sb = new StringBuilder(); appendSpaces(sb, digitsColumnWidth - digitWidth); sb.append(v); return sb.toString(); }
[ "private", "static", "String", "longToPaddedString", "(", "long", "v", ",", "int", "digitsColumnWidth", ")", "{", "int", "digitWidth", "=", "numDigits", "(", "v", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "appendSpaces", "(...
Converts 'v' to a string and pads it with up to 16 spaces for improved alignment. @param v The value to convert. @param digitsColumnWidth The desired with of the string.
[ "Converts", "v", "to", "a", "string", "and", "pads", "it", "with", "up", "to", "16", "spaces", "for", "improved", "alignment", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L295-L301
24,719
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.appendSpaces
@VisibleForTesting static void appendSpaces(StringBuilder sb, int numSpaces) { if (numSpaces > 16) { logger.warning("Tracer.appendSpaces called with large numSpaces"); // Avoid long loop in case some bug in the caller numSpaces = 16; } while (numSpaces >= 5) { sb.append(" "); ...
java
@VisibleForTesting static void appendSpaces(StringBuilder sb, int numSpaces) { if (numSpaces > 16) { logger.warning("Tracer.appendSpaces called with large numSpaces"); // Avoid long loop in case some bug in the caller numSpaces = 16; } while (numSpaces >= 5) { sb.append(" "); ...
[ "@", "VisibleForTesting", "static", "void", "appendSpaces", "(", "StringBuilder", "sb", ",", "int", "numSpaces", ")", "{", "if", "(", "numSpaces", ">", "16", ")", "{", "logger", ".", "warning", "(", "\"Tracer.appendSpaces called with large numSpaces\"", ")", ";", ...
Gets a string of spaces of the length specified. @param sb The string builder to append to. @param numSpaces The number of spaces in the string.
[ "Gets", "a", "string", "of", "spaces", "of", "the", "length", "specified", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L323-L350
24,720
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.addTracingStatistic
static int addTracingStatistic(TracingStatistic tracingStatistic) { // Check to see if we can enable the tracing statistic before actually // adding it. if (tracingStatistic.enable()) { // No synchronization needed, since this is a copy-on-write array. extraTracingStatistics.add(tracingStatistic...
java
static int addTracingStatistic(TracingStatistic tracingStatistic) { // Check to see if we can enable the tracing statistic before actually // adding it. if (tracingStatistic.enable()) { // No synchronization needed, since this is a copy-on-write array. extraTracingStatistics.add(tracingStatistic...
[ "static", "int", "addTracingStatistic", "(", "TracingStatistic", "tracingStatistic", ")", "{", "// Check to see if we can enable the tracing statistic before actually", "// adding it.", "if", "(", "tracingStatistic", ".", "enable", "(", ")", ")", "{", "// No synchronization nee...
Adds a new tracing statistic to a trace @param tracingStatistic to enable a run @return The index of this statistic (for use with stat.extraInfo()), or -1 if the statistic is not enabled.
[ "Adds", "a", "new", "tracing", "statistic", "to", "a", "trace" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L359-L371
24,721
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.stop
long stop(int silenceThreshold) { checkState(Thread.currentThread() == startThread); ThreadTrace trace = getThreadTrace(); // Do nothing if the thread trace was not initialized. if (!trace.isInitialized()) { return 0; } stopTimeMs = clock.currentTimeMillis(); if (extraTracingValues !...
java
long stop(int silenceThreshold) { checkState(Thread.currentThread() == startThread); ThreadTrace trace = getThreadTrace(); // Do nothing if the thread trace was not initialized. if (!trace.isInitialized()) { return 0; } stopTimeMs = clock.currentTimeMillis(); if (extraTracingValues !...
[ "long", "stop", "(", "int", "silenceThreshold", ")", "{", "checkState", "(", "Thread", ".", "currentThread", "(", ")", "==", "startThread", ")", ";", "ThreadTrace", "trace", "=", "getThreadTrace", "(", ")", ";", "// Do nothing if the thread trace was not initialized...
Stop the trace. This may only be done once and must be done from the same thread that started it. @param silenceThreshold Traces for time less than silence_threshold ms will be left out of the trace report. A value of -1 indicates that the current ThreadTrace silence_threshold should be used. @return The time that this...
[ "Stop", "the", "trace", ".", "This", "may", "only", "be", "done", "once", "and", "must", "be", "done", "from", "the", "same", "thread", "that", "started", "it", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L394-L421
24,722
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.initCurrentThreadTrace
static void initCurrentThreadTrace() { ThreadTrace events = getThreadTrace(); if (!events.isEmpty()) { logger.log(Level.WARNING, "Non-empty timer log:\n" + events, new Throwable()); clearThreadTrace(); // Grab a new thread trace if we find a previous non-empt...
java
static void initCurrentThreadTrace() { ThreadTrace events = getThreadTrace(); if (!events.isEmpty()) { logger.log(Level.WARNING, "Non-empty timer log:\n" + events, new Throwable()); clearThreadTrace(); // Grab a new thread trace if we find a previous non-empt...
[ "static", "void", "initCurrentThreadTrace", "(", ")", "{", "ThreadTrace", "events", "=", "getThreadTrace", "(", ")", ";", "if", "(", "!", "events", ".", "isEmpty", "(", ")", ")", "{", "logger", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Non-empty ...
Initialize the trace associated with the current thread by clearing out any existing trace. There shouldn't be a trace so if one is found we log it as an error.
[ "Initialize", "the", "trace", "associated", "with", "the", "current", "thread", "by", "clearing", "out", "any", "existing", "trace", ".", "There", "shouldn", "t", "be", "a", "trace", "so", "if", "one", "is", "found", "we", "log", "it", "as", "an", "error...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L448-L462
24,723
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.logCurrentThreadTrace
static void logCurrentThreadTrace() { ThreadTrace trace = getThreadTrace(); // New threads must call Tracer.initCurrentThreadTrace() before Tracer // statistics are gathered. This is a recent change (Jun 2007) that // prevents spurious Third Eye messages when an application uses a class in // a dif...
java
static void logCurrentThreadTrace() { ThreadTrace trace = getThreadTrace(); // New threads must call Tracer.initCurrentThreadTrace() before Tracer // statistics are gathered. This is a recent change (Jun 2007) that // prevents spurious Third Eye messages when an application uses a class in // a dif...
[ "static", "void", "logCurrentThreadTrace", "(", ")", "{", "ThreadTrace", "trace", "=", "getThreadTrace", "(", ")", ";", "// New threads must call Tracer.initCurrentThreadTrace() before Tracer", "// statistics are gathered. This is a recent change (Jun 2007) that", "// prevents spurious...
Logs a timer report similar to the one described in the class comment.
[ "Logs", "a", "timer", "report", "similar", "to", "the", "one", "described", "in", "the", "class", "comment", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L481-L501
24,724
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.getStatsForType
static Stat getStatsForType(String type) { Stat stat = getThreadTrace().stats.get(type); return stat != null ? stat : ZERO_STAT; }
java
static Stat getStatsForType(String type) { Stat stat = getThreadTrace().stats.get(type); return stat != null ? stat : ZERO_STAT; }
[ "static", "Stat", "getStatsForType", "(", "String", "type", ")", "{", "Stat", "stat", "=", "getThreadTrace", "(", ")", ".", "stats", ".", "get", "(", "type", ")", ";", "return", "stat", "!=", "null", "?", "stat", ":", "ZERO_STAT", ";", "}" ]
Gets the Stat for a tracer type; never returns null
[ "Gets", "the", "Stat", "for", "a", "tracer", "type", ";", "never", "returns", "null" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L616-L619
24,725
google/closure-compiler
src/com/google/javascript/jscomp/Tracer.java
Tracer.getThreadTrace
static ThreadTrace getThreadTrace() { ThreadTrace t = traces.get(); if (t == null) { t = new ThreadTrace(); t.prettyPrint = defaultPrettyPrint; traces.set(t); } return t; }
java
static ThreadTrace getThreadTrace() { ThreadTrace t = traces.get(); if (t == null) { t = new ThreadTrace(); t.prettyPrint = defaultPrettyPrint; traces.set(t); } return t; }
[ "static", "ThreadTrace", "getThreadTrace", "(", ")", "{", "ThreadTrace", "t", "=", "traces", ".", "get", "(", ")", ";", "if", "(", "t", "==", "null", ")", "{", "t", "=", "new", "ThreadTrace", "(", ")", ";", "t", ".", "prettyPrint", "=", "defaultPrett...
Get the ThreadTrace for the current thread, creating one if necessary.
[ "Get", "the", "ThreadTrace", "for", "the", "current", "thread", "creating", "one", "if", "necessary", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Tracer.java#L945-L953
24,726
google/closure-compiler
src/com/google/javascript/jscomp/LiveVariablesAnalysis.java
LiveVariablesAnalysis.addScopeVariables
private void addScopeVariables() { int num = 0; for (Var v : orderedVars) { scopeVariables.put(v.getName(), num); num++; } }
java
private void addScopeVariables() { int num = 0; for (Var v : orderedVars) { scopeVariables.put(v.getName(), num); num++; } }
[ "private", "void", "addScopeVariables", "(", ")", "{", "int", "num", "=", "0", ";", "for", "(", "Var", "v", ":", "orderedVars", ")", "{", "scopeVariables", ".", "put", "(", "v", ".", "getName", "(", ")", ",", "num", ")", ";", "num", "++", ";", "}...
Parameters belong to the function scope, but variables defined in the function body belong to the function body scope. Assign a unique index to each variable, regardless of which scope it's in.
[ "Parameters", "belong", "to", "the", "function", "scope", "but", "variables", "defined", "in", "the", "function", "body", "belong", "to", "the", "function", "body", "scope", ".", "Assign", "a", "unique", "index", "to", "each", "variable", "regardless", "of", ...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/LiveVariablesAnalysis.java#L170-L176
24,727
google/closure-compiler
src/com/google/javascript/jscomp/LiveVariablesAnalysis.java
LiveVariablesAnalysis.markAllParametersEscaped
void markAllParametersEscaped() { Node paramList = NodeUtil.getFunctionParameters(jsScope.getRootNode()); for (Node arg = paramList.getFirstChild(); arg != null; arg = arg.getNext()) { if (arg.isRest() || arg.isDefaultValue()) { escaped.add(jsScope.getVar(arg.getFirstChild().getString())); }...
java
void markAllParametersEscaped() { Node paramList = NodeUtil.getFunctionParameters(jsScope.getRootNode()); for (Node arg = paramList.getFirstChild(); arg != null; arg = arg.getNext()) { if (arg.isRest() || arg.isDefaultValue()) { escaped.add(jsScope.getVar(arg.getFirstChild().getString())); }...
[ "void", "markAllParametersEscaped", "(", ")", "{", "Node", "paramList", "=", "NodeUtil", ".", "getFunctionParameters", "(", "jsScope", ".", "getRootNode", "(", ")", ")", ";", "for", "(", "Node", "arg", "=", "paramList", ".", "getFirstChild", "(", ")", ";", ...
Give up computing liveness of formal parameter by putting all the parameter names in the escaped set.
[ "Give", "up", "computing", "liveness", "of", "formal", "parameter", "by", "putting", "all", "the", "parameter", "names", "in", "the", "escaped", "set", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/LiveVariablesAnalysis.java#L400-L409
24,728
google/closure-compiler
src/com/google/javascript/jscomp/DiagnosticGroupPathSuppressingWarningsGuard.java
DiagnosticGroupPathSuppressingWarningsGuard.level
@Override public CheckLevel level(JSError error) { return error.sourceName != null && error.sourceName.contains(part) ? super.level(error) /** suppress */ : null /** proceed */; }
java
@Override public CheckLevel level(JSError error) { return error.sourceName != null && error.sourceName.contains(part) ? super.level(error) /** suppress */ : null /** proceed */; }
[ "@", "Override", "public", "CheckLevel", "level", "(", "JSError", "error", ")", "{", "return", "error", ".", "sourceName", "!=", "null", "&&", "error", ".", "sourceName", ".", "contains", "(", "part", ")", "?", "super", ".", "level", "(", "error", ")", ...
Does not touch warnings in other paths.
[ "Does", "not", "touch", "warnings", "in", "other", "paths", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DiagnosticGroupPathSuppressingWarningsGuard.java#L38-L42
24,729
google/closure-compiler
src/com/google/javascript/rhino/jstype/TemplatizedType.java
TemplatizedType.getCtorImplementedInterfaces
@Override public Iterable<ObjectType> getCtorImplementedInterfaces() { LinkedHashSet<ObjectType> resolvedImplementedInterfaces = new LinkedHashSet<>(); for (ObjectType obj : getReferencedObjTypeInternal().getCtorImplementedInterfaces()) { resolvedImplementedInterfaces.add(obj.visit(replacer).toObjectTyp...
java
@Override public Iterable<ObjectType> getCtorImplementedInterfaces() { LinkedHashSet<ObjectType> resolvedImplementedInterfaces = new LinkedHashSet<>(); for (ObjectType obj : getReferencedObjTypeInternal().getCtorImplementedInterfaces()) { resolvedImplementedInterfaces.add(obj.visit(replacer).toObjectTyp...
[ "@", "Override", "public", "Iterable", "<", "ObjectType", ">", "getCtorImplementedInterfaces", "(", ")", "{", "LinkedHashSet", "<", "ObjectType", ">", "resolvedImplementedInterfaces", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "for", "(", "ObjectType", "obj...
an UnsupportedOperationException.
[ "an", "UnsupportedOperationException", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/TemplatizedType.java#L91-L98
24,730
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.checkTypeDeprecation
private void checkTypeDeprecation(NodeTraversal t, Node n) { if (!shouldEmitDeprecationWarning(t, n)) { return; } ObjectType instanceType = n.getJSType().toMaybeFunctionType().getInstanceType(); String deprecationInfo = getTypeDeprecationInfo(instanceType); if (deprecationInfo == null) { ...
java
private void checkTypeDeprecation(NodeTraversal t, Node n) { if (!shouldEmitDeprecationWarning(t, n)) { return; } ObjectType instanceType = n.getJSType().toMaybeFunctionType().getInstanceType(); String deprecationInfo = getTypeDeprecationInfo(instanceType); if (deprecationInfo == null) { ...
[ "private", "void", "checkTypeDeprecation", "(", "NodeTraversal", "t", ",", "Node", "n", ")", "{", "if", "(", "!", "shouldEmitDeprecationWarning", "(", "t", ",", "n", ")", ")", "{", "return", ";", "}", "ObjectType", "instanceType", "=", "n", ".", "getJSType...
Reports deprecation issue with regard to a type usage. <p>Precondition: {@code n} has a constructor {@link JSType}.
[ "Reports", "deprecation", "issue", "with", "regard", "to", "a", "type", "usage", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L431-L445
24,731
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.checkNameDeprecation
private void checkNameDeprecation(NodeTraversal t, Node n) { if (!n.isName()) { return; } if (!shouldEmitDeprecationWarning(t, n)) { return; } Var var = t.getScope().getVar(n.getString()); JSDocInfo docInfo = var == null ? null : var.getJSDocInfo(); if (docInfo != null && docI...
java
private void checkNameDeprecation(NodeTraversal t, Node n) { if (!n.isName()) { return; } if (!shouldEmitDeprecationWarning(t, n)) { return; } Var var = t.getScope().getVar(n.getString()); JSDocInfo docInfo = var == null ? null : var.getJSDocInfo(); if (docInfo != null && docI...
[ "private", "void", "checkNameDeprecation", "(", "NodeTraversal", "t", ",", "Node", "n", ")", "{", "if", "(", "!", "n", ".", "isName", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "shouldEmitDeprecationWarning", "(", "t", ",", "n", ")", ")"...
Checks the given NAME node to ensure that access restrictions are obeyed.
[ "Checks", "the", "given", "NAME", "node", "to", "ensure", "that", "access", "restrictions", "are", "obeyed", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L448-L468
24,732
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.checkPropertyDeprecation
private void checkPropertyDeprecation(NodeTraversal t, PropertyReference propRef) { if (!shouldEmitDeprecationWarning(t, propRef)) { return; } // Don't bother checking constructors. if (propRef.getSourceNode().getParent().isNew()) { return; } ObjectType objectType = castToObject(de...
java
private void checkPropertyDeprecation(NodeTraversal t, PropertyReference propRef) { if (!shouldEmitDeprecationWarning(t, propRef)) { return; } // Don't bother checking constructors. if (propRef.getSourceNode().getParent().isNew()) { return; } ObjectType objectType = castToObject(de...
[ "private", "void", "checkPropertyDeprecation", "(", "NodeTraversal", "t", ",", "PropertyReference", "propRef", ")", "{", "if", "(", "!", "shouldEmitDeprecationWarning", "(", "t", ",", "propRef", ")", ")", "{", "return", ";", "}", "// Don't bother checking constructo...
Checks the given GETPROP node to ensure that access restrictions are obeyed.
[ "Checks", "the", "given", "GETPROP", "node", "to", "ensure", "that", "access", "restrictions", "are", "obeyed", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L471-L508
24,733
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.checkKeyVisibilityConvention
private void checkKeyVisibilityConvention(Node key, Node parent) { JSDocInfo info = key.getJSDocInfo(); if (info == null) { return; } if (!isPrivateByConvention(key.getString())) { return; } Node assign = parent.getParent(); if (assign == null || !assign.isAssign()) { retur...
java
private void checkKeyVisibilityConvention(Node key, Node parent) { JSDocInfo info = key.getJSDocInfo(); if (info == null) { return; } if (!isPrivateByConvention(key.getString())) { return; } Node assign = parent.getParent(); if (assign == null || !assign.isAssign()) { retur...
[ "private", "void", "checkKeyVisibilityConvention", "(", "Node", "key", ",", "Node", "parent", ")", "{", "JSDocInfo", "info", "=", "key", ".", "getJSDocInfo", "(", ")", ";", "if", "(", "info", "==", "null", ")", "{", "return", ";", "}", "if", "(", "!", ...
Determines whether the given OBJECTLIT property visibility violates the coding convention. @param key The objectlit key node (STRING_KEY, GETTER_DEF, SETTER_DEF, MEMBER_FUNCTION_DEF).
[ "Determines", "whether", "the", "given", "OBJECTLIT", "property", "visibility", "violates", "the", "coding", "convention", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L520-L543
24,734
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.checkNameVisibility
private void checkNameVisibility(Scope scope, Node name) { if (!name.isName()) { return; } Var var = scope.getVar(name.getString()); if (var == null) { return; } Visibility v = checkPrivateNameConvention( AccessControlUtils.getEffectiveNameVisibility( name, var,...
java
private void checkNameVisibility(Scope scope, Node name) { if (!name.isName()) { return; } Var var = scope.getVar(name.getString()); if (var == null) { return; } Visibility v = checkPrivateNameConvention( AccessControlUtils.getEffectiveNameVisibility( name, var,...
[ "private", "void", "checkNameVisibility", "(", "Scope", "scope", ",", "Node", "name", ")", "{", "if", "(", "!", "name", ".", "isName", "(", ")", ")", "{", "return", ";", "}", "Var", "var", "=", "scope", ".", "getVar", "(", "name", ".", "getString", ...
Reports an error if the given name is not visible in the current context. @param scope The current scope. @param name The name node.
[ "Reports", "an", "error", "if", "the", "given", "name", "is", "not", "visible", "in", "the", "current", "context", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L551-L591
24,735
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.checkFinalClassOverrides
private void checkFinalClassOverrides(Node ctor) { if (!isFunctionOrClass(ctor)) { return; } JSType type = ctor.getJSType().toMaybeFunctionType(); if (type != null && type.isConstructor()) { JSType finalParentClass = getSuperClassInstanceIfFinal(bestInstanceTypeForMethodOrCtor(ctor)); ...
java
private void checkFinalClassOverrides(Node ctor) { if (!isFunctionOrClass(ctor)) { return; } JSType type = ctor.getJSType().toMaybeFunctionType(); if (type != null && type.isConstructor()) { JSType finalParentClass = getSuperClassInstanceIfFinal(bestInstanceTypeForMethodOrCtor(ctor)); ...
[ "private", "void", "checkFinalClassOverrides", "(", "Node", "ctor", ")", "{", "if", "(", "!", "isFunctionOrClass", "(", "ctor", ")", ")", "{", "return", ";", "}", "JSType", "type", "=", "ctor", ".", "getJSType", "(", ")", ".", "toMaybeFunctionType", "(", ...
Checks if a constructor is trying to override a final class.
[ "Checks", "if", "a", "constructor", "is", "trying", "to", "override", "a", "final", "class", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L661-L678
24,736
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.getCanonicalInstance
static ObjectType getCanonicalInstance(ObjectType obj) { FunctionType ctor = obj.getConstructor(); return ctor == null ? obj : ctor.getInstanceType(); }
java
static ObjectType getCanonicalInstance(ObjectType obj) { FunctionType ctor = obj.getConstructor(); return ctor == null ? obj : ctor.getInstanceType(); }
[ "static", "ObjectType", "getCanonicalInstance", "(", "ObjectType", "obj", ")", "{", "FunctionType", "ctor", "=", "obj", ".", "getConstructor", "(", ")", ";", "return", "ctor", "==", "null", "?", "obj", ":", "ctor", ".", "getInstanceType", "(", ")", ";", "}...
Return an object with the same nominal type as obj, but without any possible extra properties that exist on obj.
[ "Return", "an", "object", "with", "the", "same", "nominal", "type", "as", "obj", "but", "without", "any", "possible", "extra", "properties", "that", "exist", "on", "obj", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L742-L745
24,737
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.checkPropertyVisibility
private void checkPropertyVisibility(PropertyReference propRef) { if (NodeUtil.isEs6ConstructorMemberFunctionDef(propRef.getSourceNode())) { // Class ctor *declarations* can never violate visibility restrictions. They are not // accesses and we don't consider them overrides. // // TODO(nickr...
java
private void checkPropertyVisibility(PropertyReference propRef) { if (NodeUtil.isEs6ConstructorMemberFunctionDef(propRef.getSourceNode())) { // Class ctor *declarations* can never violate visibility restrictions. They are not // accesses and we don't consider them overrides. // // TODO(nickr...
[ "private", "void", "checkPropertyVisibility", "(", "PropertyReference", "propRef", ")", "{", "if", "(", "NodeUtil", ".", "isEs6ConstructorMemberFunctionDef", "(", "propRef", ".", "getSourceNode", "(", ")", ")", ")", "{", "// Class ctor *declarations* can never violate vis...
Reports an error if the given property is not visible in the current context. <p>This method covers both: <ul> <li>accesses to properties during execution <li>overrides of properties during declaration </ul> TODO(nickreid): Things would probably be a lot simpler, though a bit duplicated, if these two concepts were s...
[ "Reports", "an", "error", "if", "the", "given", "property", "is", "not", "visible", "in", "the", "current", "context", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L779-L857
24,738
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.canAccessDeprecatedTypes
private boolean canAccessDeprecatedTypes(NodeTraversal t) { Node scopeRoot = t.getClosestHoistScopeRoot(); if (NodeUtil.isFunctionBlock(scopeRoot)) { scopeRoot = scopeRoot.getParent(); } Node scopeRootParent = scopeRoot.getParent(); return // Case #1 (deprecationDepth > 0) // ...
java
private boolean canAccessDeprecatedTypes(NodeTraversal t) { Node scopeRoot = t.getClosestHoistScopeRoot(); if (NodeUtil.isFunctionBlock(scopeRoot)) { scopeRoot = scopeRoot.getParent(); } Node scopeRootParent = scopeRoot.getParent(); return // Case #1 (deprecationDepth > 0) // ...
[ "private", "boolean", "canAccessDeprecatedTypes", "(", "NodeTraversal", "t", ")", "{", "Node", "scopeRoot", "=", "t", ".", "getClosestHoistScopeRoot", "(", ")", ";", "if", "(", "NodeUtil", ".", "isFunctionBlock", "(", "scopeRoot", ")", ")", "{", "scopeRoot", "...
Returns whether it's currently OK to access deprecated names and properties. There are 3 exceptions when we're allowed to use a deprecated type or property: 1) When we're in a deprecated function. 2) When we're in a deprecated class. 3) When we're in a static method of a deprecated class.
[ "Returns", "whether", "it", "s", "currently", "OK", "to", "access", "deprecated", "names", "and", "properties", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L1109-L1125
24,739
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.getTypeDeprecationInfo
private static String getTypeDeprecationInfo(JSType type) { if (type == null) { return null; } String depReason = getDeprecationReason(type.getJSDocInfo()); if (depReason != null) { return depReason; } ObjectType objType = castToObject(type); if (objType != null) { Object...
java
private static String getTypeDeprecationInfo(JSType type) { if (type == null) { return null; } String depReason = getDeprecationReason(type.getJSDocInfo()); if (depReason != null) { return depReason; } ObjectType objType = castToObject(type); if (objType != null) { Object...
[ "private", "static", "String", "getTypeDeprecationInfo", "(", "JSType", "type", ")", "{", "if", "(", "type", "==", "null", ")", "{", "return", "null", ";", "}", "String", "depReason", "=", "getDeprecationReason", "(", "type", ".", "getJSDocInfo", "(", ")", ...
Returns the deprecation reason for the type if it is marked as being deprecated. Returns empty string if the type is deprecated but no reason was given. Returns null if the type is not deprecated.
[ "Returns", "the", "deprecation", "reason", "for", "the", "type", "if", "it", "is", "marked", "as", "being", "deprecated", ".", "Returns", "empty", "string", "if", "the", "type", "is", "deprecated", "but", "no", "reason", "was", "given", ".", "Returns", "nu...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L1140-L1158
24,740
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.isPropertyDeclaredConstant
private boolean isPropertyDeclaredConstant( ObjectType objectType, String prop) { if (enforceCodingConventions && compiler.getCodingConvention().isConstant(prop)) { return true; } for (; objectType != null; objectType = objectType.getImplicitPrototype()) { JSDocInfo docInfo = objec...
java
private boolean isPropertyDeclaredConstant( ObjectType objectType, String prop) { if (enforceCodingConventions && compiler.getCodingConvention().isConstant(prop)) { return true; } for (; objectType != null; objectType = objectType.getImplicitPrototype()) { JSDocInfo docInfo = objec...
[ "private", "boolean", "isPropertyDeclaredConstant", "(", "ObjectType", "objectType", ",", "String", "prop", ")", "{", "if", "(", "enforceCodingConventions", "&&", "compiler", ".", "getCodingConvention", "(", ")", ".", "isConstant", "(", "prop", ")", ")", "{", "r...
Returns if a property is declared constant.
[ "Returns", "if", "a", "property", "is", "declared", "constant", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L1173-L1186
24,741
google/closure-compiler
src/com/google/javascript/jscomp/CheckAccessControls.java
CheckAccessControls.getPropertyDeprecationInfo
@Nullable private static String getPropertyDeprecationInfo(ObjectType type, String prop) { String depReason = getDeprecationReason(type.getOwnPropertyJSDocInfo(prop)); if (depReason != null) { return depReason; } ObjectType implicitProto = type.getImplicitPrototype(); if (implicitProto != n...
java
@Nullable private static String getPropertyDeprecationInfo(ObjectType type, String prop) { String depReason = getDeprecationReason(type.getOwnPropertyJSDocInfo(prop)); if (depReason != null) { return depReason; } ObjectType implicitProto = type.getImplicitPrototype(); if (implicitProto != n...
[ "@", "Nullable", "private", "static", "String", "getPropertyDeprecationInfo", "(", "ObjectType", "type", ",", "String", "prop", ")", "{", "String", "depReason", "=", "getDeprecationReason", "(", "type", ".", "getOwnPropertyJSDocInfo", "(", "prop", ")", ")", ";", ...
Returns the deprecation reason for the property if it is marked as being deprecated. Returns empty string if the property is deprecated but no reason was given. Returns null if the property is not deprecated.
[ "Returns", "the", "deprecation", "reason", "for", "the", "property", "if", "it", "is", "marked", "as", "being", "deprecated", ".", "Returns", "empty", "string", "if", "the", "property", "is", "deprecated", "but", "no", "reason", "was", "given", ".", "Returns...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L1193-L1205
24,742
google/closure-compiler
src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java
Es6RewriteRestAndSpread.visitArrayLitOrCallWithSpread
private void visitArrayLitOrCallWithSpread(Node spreadParent) { if (spreadParent.isArrayLit()) { visitArrayLitContainingSpread(spreadParent); } else if (spreadParent.isCall()) { visitCallContainingSpread(spreadParent); } else { checkArgument(spreadParent.isNew(), spreadParent); visit...
java
private void visitArrayLitOrCallWithSpread(Node spreadParent) { if (spreadParent.isArrayLit()) { visitArrayLitContainingSpread(spreadParent); } else if (spreadParent.isCall()) { visitCallContainingSpread(spreadParent); } else { checkArgument(spreadParent.isNew(), spreadParent); visit...
[ "private", "void", "visitArrayLitOrCallWithSpread", "(", "Node", "spreadParent", ")", "{", "if", "(", "spreadParent", ".", "isArrayLit", "(", ")", ")", "{", "visitArrayLitContainingSpread", "(", "spreadParent", ")", ";", "}", "else", "if", "(", "spreadParent", "...
Processes array literals or calls to eliminate spreads. <p>Examples: <ul> <li>[1, 2, ...x, 4, 5] => [].concat([1, 2], $jscomp.arrayFromIterable(x), [4, 5]) <li>f(1, ...arr) => f.apply(null, [1].concat($jscomp.arrayFromIterable(arr))) <li>new F(...args) => new Function.prototype.bind.apply(F, [null].concat($jscomp.arr...
[ "Processes", "array", "literals", "or", "calls", "to", "eliminate", "spreads", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java#L222-L231
24,743
google/closure-compiler
src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java
Es6RewriteRestAndSpread.visitArrayLitContainingSpread
private void visitArrayLitContainingSpread(Node spreadParent) { checkArgument(spreadParent.isArrayLit()); List<Node> groups = extractSpreadGroups(spreadParent); final Node baseArrayLit; if (groups.get(0).isArrayLit()) { // g0.concat(g1, g2, ..., gn) baseArrayLit = groups.remove(0); } e...
java
private void visitArrayLitContainingSpread(Node spreadParent) { checkArgument(spreadParent.isArrayLit()); List<Node> groups = extractSpreadGroups(spreadParent); final Node baseArrayLit; if (groups.get(0).isArrayLit()) { // g0.concat(g1, g2, ..., gn) baseArrayLit = groups.remove(0); } e...
[ "private", "void", "visitArrayLitContainingSpread", "(", "Node", "spreadParent", ")", "{", "checkArgument", "(", "spreadParent", ".", "isArrayLit", "(", ")", ")", ";", "List", "<", "Node", ">", "groups", "=", "extractSpreadGroups", "(", "spreadParent", ")", ";",...
Processes array literals containing spreads. <p>Example: <pre><code> [1, 2, ...x, 4, 5] => [1, 2].concat($jscomp.arrayFromIterable(x), [4, 5]) </code></pre>
[ "Processes", "array", "literals", "containing", "spreads", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java#L309-L336
24,744
google/closure-compiler
src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java
Es6RewriteRestAndSpread.visitCallContainingSpread
private void visitCallContainingSpread(Node spreadParent) { checkArgument(spreadParent.isCall()); Node callee = spreadParent.getFirstChild(); // Check if the callee has side effects before removing it from the AST (since some NodeUtil // methods assume the node they are passed has a non-null parent). ...
java
private void visitCallContainingSpread(Node spreadParent) { checkArgument(spreadParent.isCall()); Node callee = spreadParent.getFirstChild(); // Check if the callee has side effects before removing it from the AST (since some NodeUtil // methods assume the node they are passed has a non-null parent). ...
[ "private", "void", "visitCallContainingSpread", "(", "Node", "spreadParent", ")", "{", "checkArgument", "(", "spreadParent", ".", "isCall", "(", ")", ")", ";", "Node", "callee", "=", "spreadParent", ".", "getFirstChild", "(", ")", ";", "// Check if the callee has ...
Processes calls containing spreads. <p>Examples: <pre><code> f(...arr) => f.apply(null, $jscomp.arrayFromIterable(arr)) f(a, ...arr) => f.apply(null, [a].concat($jscomp.arrayFromIterable(arr))) f(...arr, b) => f.apply(null, [].concat($jscomp.arrayFromIterable(arr), [b])) </code></pre>
[ "Processes", "calls", "containing", "spreads", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java#L349-L429
24,745
google/closure-compiler
src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java
Es6RewriteRestAndSpread.visitNewWithSpread
private void visitNewWithSpread(Node spreadParent) { checkArgument(spreadParent.isNew()); // Must remove callee before extracting argument groups. Node callee = spreadParent.removeFirstChild(); List<Node> groups = extractSpreadGroups(spreadParent); // We need to generate // `new (Function.prot...
java
private void visitNewWithSpread(Node spreadParent) { checkArgument(spreadParent.isNew()); // Must remove callee before extracting argument groups. Node callee = spreadParent.removeFirstChild(); List<Node> groups = extractSpreadGroups(spreadParent); // We need to generate // `new (Function.prot...
[ "private", "void", "visitNewWithSpread", "(", "Node", "spreadParent", ")", "{", "checkArgument", "(", "spreadParent", ".", "isNew", "(", ")", ")", ";", "// Must remove callee before extracting argument groups.", "Node", "callee", "=", "spreadParent", ".", "removeFirstCh...
Processes new calls containing spreads. <p>Example: <pre><code> new F(...args) => new Function.prototype.bind.apply(F, [].concat($jscomp.arrayFromIterable(args))) </code></pre>
[ "Processes", "new", "calls", "containing", "spreads", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteRestAndSpread.java#L445-L499
24,746
google/closure-compiler
src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java
FlowSensitiveInlineVariables.checkPostExpressions
private static boolean checkPostExpressions( Node n, Node expressionRoot, Predicate<Node> predicate) { for (Node p = n; p != expressionRoot; p = p.getParent()) { for (Node cur = p.getNext(); cur != null; cur = cur.getNext()) { if (predicate.apply(cur)) { return true; } } ...
java
private static boolean checkPostExpressions( Node n, Node expressionRoot, Predicate<Node> predicate) { for (Node p = n; p != expressionRoot; p = p.getParent()) { for (Node cur = p.getNext(); cur != null; cur = cur.getNext()) { if (predicate.apply(cur)) { return true; } } ...
[ "private", "static", "boolean", "checkPostExpressions", "(", "Node", "n", ",", "Node", "expressionRoot", ",", "Predicate", "<", "Node", ">", "predicate", ")", "{", "for", "(", "Node", "p", "=", "n", ";", "p", "!=", "expressionRoot", ";", "p", "=", "p", ...
Given an expression by its root and sub-expression n, return true if the predicate is true for some expression evaluated after n. <p>NOTE: this doesn't correctly check destructuring patterns, because their order of evaluation is different from AST traversal order, but currently this is ok because FlowSensitiveInlineV...
[ "Given", "an", "expression", "by", "its", "root", "and", "sub", "-", "expression", "n", "return", "true", "if", "the", "predicate", "is", "true", "for", "some", "expression", "evaluated", "after", "n", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java#L662-L672
24,747
google/closure-compiler
src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java
FlowSensitiveInlineVariables.checkPreExpressions
private static boolean checkPreExpressions( Node n, Node expressionRoot, Predicate<Node> predicate) { for (Node p = n; p != expressionRoot; p = p.getParent()) { Node oldestSibling = p.getParent().getFirstChild(); // Evaluate a destructuring assignment right-to-left. if (oldestSibling.isDestr...
java
private static boolean checkPreExpressions( Node n, Node expressionRoot, Predicate<Node> predicate) { for (Node p = n; p != expressionRoot; p = p.getParent()) { Node oldestSibling = p.getParent().getFirstChild(); // Evaluate a destructuring assignment right-to-left. if (oldestSibling.isDestr...
[ "private", "static", "boolean", "checkPreExpressions", "(", "Node", "n", ",", "Node", "expressionRoot", ",", "Predicate", "<", "Node", ">", "predicate", ")", "{", "for", "(", "Node", "p", "=", "n", ";", "p", "!=", "expressionRoot", ";", "p", "=", "p", ...
Given an expression by its root and sub-expression n, return true if the predicate is true for some expression evaluated before n. <p>In most cases evaluation order follows left-to-right AST order. Destructuring pattern evaluation is an exception. <p>Example: <p>Checked(), Checked(), n, NotChecked(), NotChecked();
[ "Given", "an", "expression", "by", "its", "root", "and", "sub", "-", "expression", "n", "return", "true", "if", "the", "predicate", "is", "true", "for", "some", "expression", "evaluated", "before", "n", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java#L685-L705
24,748
google/closure-compiler
src/com/google/javascript/jscomp/PolymerClassDefinition.java
PolymerClassDefinition.extractFromClassNode
@Nullable static PolymerClassDefinition extractFromClassNode( Node classNode, AbstractCompiler compiler, GlobalNamespace globalNames) { checkState(classNode != null && classNode.isClass()); // The supported case is for the config getter to return an object literal descriptor. Node propertiesDescrip...
java
@Nullable static PolymerClassDefinition extractFromClassNode( Node classNode, AbstractCompiler compiler, GlobalNamespace globalNames) { checkState(classNode != null && classNode.isClass()); // The supported case is for the config getter to return an object literal descriptor. Node propertiesDescrip...
[ "@", "Nullable", "static", "PolymerClassDefinition", "extractFromClassNode", "(", "Node", "classNode", ",", "AbstractCompiler", "compiler", ",", "GlobalNamespace", "globalNames", ")", "{", "checkState", "(", "classNode", "!=", "null", "&&", "classNode", ".", "isClass"...
Validates the class definition and if valid, extracts the class definition from the AST. As opposed to the Polymer 1 extraction, this operation is non-destructive.
[ "Validates", "the", "class", "definition", "and", "if", "valid", "extracts", "the", "class", "definition", "from", "the", "AST", ".", "As", "opposed", "to", "the", "Polymer", "1", "extraction", "this", "operation", "is", "non", "-", "destructive", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PolymerClassDefinition.java#L208-L285
24,749
google/closure-compiler
src/com/google/javascript/jscomp/PolymerClassDefinition.java
PolymerClassDefinition.overwriteMembersIfPresent
private static void overwriteMembersIfPresent( List<MemberDefinition> list, List<MemberDefinition> newMembers) { for (MemberDefinition newMember : newMembers) { for (MemberDefinition member : list) { if (member.name.getString().equals(newMember.name.getString())) { list.remove(member);...
java
private static void overwriteMembersIfPresent( List<MemberDefinition> list, List<MemberDefinition> newMembers) { for (MemberDefinition newMember : newMembers) { for (MemberDefinition member : list) { if (member.name.getString().equals(newMember.name.getString())) { list.remove(member);...
[ "private", "static", "void", "overwriteMembersIfPresent", "(", "List", "<", "MemberDefinition", ">", "list", ",", "List", "<", "MemberDefinition", ">", "newMembers", ")", "{", "for", "(", "MemberDefinition", "newMember", ":", "newMembers", ")", "{", "for", "(", ...
Appends a list of new MemberDefinitions to the end of a list and removes any previous MemberDefinition in the list which has the same name as the new member.
[ "Appends", "a", "list", "of", "new", "MemberDefinitions", "to", "the", "end", "of", "a", "list", "and", "removes", "any", "previous", "MemberDefinition", "in", "the", "list", "which", "has", "the", "same", "name", "as", "the", "new", "member", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PolymerClassDefinition.java#L291-L302
24,750
google/closure-compiler
src/com/google/javascript/jscomp/StaticSuperPropReplacer.java
StaticSuperPropReplacer.tryReplaceSuper
private void tryReplaceSuper(Node superNode) { checkState(!superclasses.isEmpty(), "`super` cannot appear outside a function"); Optional<Node> currentSuperclass = superclasses.peek(); if (!currentSuperclass.isPresent() || !currentSuperclass.get().isQualifiedName()) { // either if a) we're in a static ...
java
private void tryReplaceSuper(Node superNode) { checkState(!superclasses.isEmpty(), "`super` cannot appear outside a function"); Optional<Node> currentSuperclass = superclasses.peek(); if (!currentSuperclass.isPresent() || !currentSuperclass.get().isQualifiedName()) { // either if a) we're in a static ...
[ "private", "void", "tryReplaceSuper", "(", "Node", "superNode", ")", "{", "checkState", "(", "!", "superclasses", ".", "isEmpty", "(", ")", ",", "\"`super` cannot appear outside a function\"", ")", ";", "Optional", "<", "Node", ">", "currentSuperclass", "=", "supe...
Replaces `super` with `Super.Class` if in a static class method with a qname superclass
[ "Replaces", "super", "with", "Super", ".", "Class", "if", "in", "a", "static", "class", "method", "with", "a", "qname", "superclass" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/StaticSuperPropReplacer.java#L98-L110
24,751
google/closure-compiler
src/com/google/javascript/jscomp/ConstParamCheck.java
ConstParamCheck.isSafeValue
private boolean isSafeValue(Scope scope, Node argument) { if (NodeUtil.isSomeCompileTimeConstStringValue(argument)) { return true; } else if (argument.isAdd()) { Node left = argument.getFirstChild(); Node right = argument.getLastChild(); return isSafeValue(scope, left) && isSafeValue(sco...
java
private boolean isSafeValue(Scope scope, Node argument) { if (NodeUtil.isSomeCompileTimeConstStringValue(argument)) { return true; } else if (argument.isAdd()) { Node left = argument.getFirstChild(); Node right = argument.getLastChild(); return isSafeValue(scope, left) && isSafeValue(sco...
[ "private", "boolean", "isSafeValue", "(", "Scope", "scope", ",", "Node", "argument", ")", "{", "if", "(", "NodeUtil", ".", "isSomeCompileTimeConstStringValue", "(", "argument", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "argument", ".", ...
Checks if the method call argument is made of constant string literals. <p>This function argument checker will return true if: <ol> <li>The argument is a constant variable assigned from a string literal, or <li>The argument is an expression that is a string literal, or <li>The argument is a ternary expression choosin...
[ "Checks", "if", "the", "method", "call", "argument", "is", "made", "of", "constant", "string", "literals", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ConstParamCheck.java#L118-L138
24,752
google/closure-compiler
src/com/google/javascript/jscomp/ijs/PotentialDeclaration.java
PotentialDeclaration.remove
final void remove(AbstractCompiler compiler) { if (isDetached()) { return; } Node statement = getRemovableNode(); NodeUtil.deleteNode(statement, compiler); statement.removeChildren(); }
java
final void remove(AbstractCompiler compiler) { if (isDetached()) { return; } Node statement = getRemovableNode(); NodeUtil.deleteNode(statement, compiler); statement.removeChildren(); }
[ "final", "void", "remove", "(", "AbstractCompiler", "compiler", ")", "{", "if", "(", "isDetached", "(", ")", ")", "{", "return", ";", "}", "Node", "statement", "=", "getRemovableNode", "(", ")", ";", "NodeUtil", ".", "deleteNode", "(", "statement", ",", ...
Remove this "potential declaration" completely. Usually, this is because the same symbol has already been declared in this file.
[ "Remove", "this", "potential", "declaration", "completely", ".", "Usually", "this", "is", "because", "the", "same", "symbol", "has", "already", "been", "declared", "in", "this", "file", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ijs/PotentialDeclaration.java#L123-L130
24,753
google/closure-compiler
src/com/google/javascript/jscomp/ijs/PotentialDeclaration.java
PotentialDeclaration.simplifyEnumValues
private void simplifyEnumValues(AbstractCompiler compiler) { if (getRhs().isObjectLit() && getRhs().hasChildren()) { for (Node key : getRhs().children()) { removeStringKeyValue(key); } compiler.reportChangeToEnclosingScope(getRhs()); } }
java
private void simplifyEnumValues(AbstractCompiler compiler) { if (getRhs().isObjectLit() && getRhs().hasChildren()) { for (Node key : getRhs().children()) { removeStringKeyValue(key); } compiler.reportChangeToEnclosingScope(getRhs()); } }
[ "private", "void", "simplifyEnumValues", "(", "AbstractCompiler", "compiler", ")", "{", "if", "(", "getRhs", "(", ")", ".", "isObjectLit", "(", ")", "&&", "getRhs", "(", ")", ".", "hasChildren", "(", ")", ")", "{", "for", "(", "Node", "key", ":", "getR...
Remove values from enums
[ "Remove", "values", "from", "enums" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ijs/PotentialDeclaration.java#L437-L444
24,754
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.collectProvidedNames
Map<String, ProvidedName> collectProvidedNames(Node externs, Node root) { if (this.providedNames.isEmpty()) { // goog is special-cased because it is provided in Closure's base library. providedNames.put(GOOG, new ProvidedName(GOOG, null, null, false /* implicit */, false)); NodeTraversal.traverseR...
java
Map<String, ProvidedName> collectProvidedNames(Node externs, Node root) { if (this.providedNames.isEmpty()) { // goog is special-cased because it is provided in Closure's base library. providedNames.put(GOOG, new ProvidedName(GOOG, null, null, false /* implicit */, false)); NodeTraversal.traverseR...
[ "Map", "<", "String", ",", "ProvidedName", ">", "collectProvidedNames", "(", "Node", "externs", ",", "Node", "root", ")", "{", "if", "(", "this", ".", "providedNames", ".", "isEmpty", "(", ")", ")", "{", "// goog is special-cased because it is provided in Closure'...
Collects all goog.provides in the given namespace and warns on invalid code
[ "Collects", "all", "goog", ".", "provides", "in", "the", "given", "namespace", "and", "warns", "on", "invalid", "code" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L97-L104
24,755
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.rewriteProvidesAndRequires
void rewriteProvidesAndRequires(Node externs, Node root) { checkState(!hasRewritingOccurred, "Cannot call rewriteProvidesAndRequires twice per instance"); hasRewritingOccurred = true; collectProvidedNames(externs, root); for (ProvidedName pn : providedNames.values()) { pn.replace(); } de...
java
void rewriteProvidesAndRequires(Node externs, Node root) { checkState(!hasRewritingOccurred, "Cannot call rewriteProvidesAndRequires twice per instance"); hasRewritingOccurred = true; collectProvidedNames(externs, root); for (ProvidedName pn : providedNames.values()) { pn.replace(); } de...
[ "void", "rewriteProvidesAndRequires", "(", "Node", "externs", ",", "Node", "root", ")", "{", "checkState", "(", "!", "hasRewritingOccurred", ",", "\"Cannot call rewriteProvidesAndRequires twice per instance\"", ")", ";", "hasRewritingOccurred", "=", "true", ";", "collectP...
Rewrites all provides and requires in the given namespace. <p>Call this instead of {@link #collectProvidedNames(Node, Node)} if you want rewriting.
[ "Rewrites", "all", "provides", "and", "requires", "in", "the", "given", "namespace", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L111-L135
24,756
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.processRequireCall
private void processRequireCall(NodeTraversal t, Node n, Node parent) { Node left = n.getFirstChild(); Node arg = left.getNext(); String method = left.getFirstChild().getNext().getString(); if (verifyLastArgumentIsString(left, arg)) { String ns = arg.getString(); ProvidedName provided = prov...
java
private void processRequireCall(NodeTraversal t, Node n, Node parent) { Node left = n.getFirstChild(); Node arg = left.getNext(); String method = left.getFirstChild().getNext().getString(); if (verifyLastArgumentIsString(left, arg)) { String ns = arg.getString(); ProvidedName provided = prov...
[ "private", "void", "processRequireCall", "(", "NodeTraversal", "t", ",", "Node", "n", ",", "Node", "parent", ")", "{", "Node", "left", "=", "n", ".", "getFirstChild", "(", ")", ";", "Node", "arg", "=", "left", ".", "getNext", "(", ")", ";", "String", ...
Handles a goog.require or goog.requireType call.
[ "Handles", "a", "goog", ".", "require", "or", "goog", ".", "requireType", "call", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L296-L340
24,757
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.processLegacyModuleCall
private void processLegacyModuleCall(String namespace, Node googModuleCall, JSModule module) { registerAnyProvidedPrefixes(namespace, googModuleCall, module); providedNames.put( namespace, new ProvidedName( namespace, googModuleCall, module, /* exp...
java
private void processLegacyModuleCall(String namespace, Node googModuleCall, JSModule module) { registerAnyProvidedPrefixes(namespace, googModuleCall, module); providedNames.put( namespace, new ProvidedName( namespace, googModuleCall, module, /* exp...
[ "private", "void", "processLegacyModuleCall", "(", "String", "namespace", ",", "Node", "googModuleCall", ",", "JSModule", "module", ")", "{", "registerAnyProvidedPrefixes", "(", "namespace", ",", "googModuleCall", ",", "module", ")", ";", "providedNames", ".", "put"...
Handles a goog.module that is a legacy namespace.
[ "Handles", "a", "goog", ".", "module", "that", "is", "a", "legacy", "namespace", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L343-L353
24,758
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.processProvideCall
private void processProvideCall(NodeTraversal t, Node n, Node parent) { checkState(n.isCall()); Node left = n.getFirstChild(); Node arg = left.getNext(); if (verifyProvide(left, arg)) { String ns = arg.getString(); maybeAddNameToSymbolTable(left); maybeAddStringToSymbolTable(arg); ...
java
private void processProvideCall(NodeTraversal t, Node n, Node parent) { checkState(n.isCall()); Node left = n.getFirstChild(); Node arg = left.getNext(); if (verifyProvide(left, arg)) { String ns = arg.getString(); maybeAddNameToSymbolTable(left); maybeAddStringToSymbolTable(arg); ...
[ "private", "void", "processProvideCall", "(", "NodeTraversal", "t", ",", "Node", "n", ",", "Node", "parent", ")", "{", "checkState", "(", "n", ".", "isCall", "(", ")", ")", ";", "Node", "left", "=", "n", ".", "getFirstChild", "(", ")", ";", "Node", "...
Handles a goog.provide call.
[ "Handles", "a", "goog", ".", "provide", "call", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L356-L384
24,759
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.handleCandidateProvideDefinition
private void handleCandidateProvideDefinition(NodeTraversal t, Node n, Node parent) { if (t.inGlobalHoistScope()) { String name = null; if (n.isName() && NodeUtil.isNameDeclaration(parent)) { name = n.getString(); } else if (n.isAssign() && parent.isExprResult()) { name = n.getFirs...
java
private void handleCandidateProvideDefinition(NodeTraversal t, Node n, Node parent) { if (t.inGlobalHoistScope()) { String name = null; if (n.isName() && NodeUtil.isNameDeclaration(parent)) { name = n.getString(); } else if (n.isAssign() && parent.isExprResult()) { name = n.getFirs...
[ "private", "void", "handleCandidateProvideDefinition", "(", "NodeTraversal", "t", ",", "Node", "n", ",", "Node", "parent", ")", "{", "if", "(", "t", ".", "inGlobalHoistScope", "(", ")", ")", "{", "String", "name", "=", "null", ";", "if", "(", "n", ".", ...
Handles a candidate definition for a goog.provided name.
[ "Handles", "a", "candidate", "definition", "for", "a", "goog", ".", "provided", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L417-L438
24,760
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.processProvideFromPreviousPass
private void processProvideFromPreviousPass(NodeTraversal t, String name, Node parent) { JSModule module = t.getModule(); if (providedNames.containsKey(name)) { ProvidedName provided = providedNames.get(name); provided.addDefinition(parent, module); if (isNamespacePlaceholder(parent)) { ...
java
private void processProvideFromPreviousPass(NodeTraversal t, String name, Node parent) { JSModule module = t.getModule(); if (providedNames.containsKey(name)) { ProvidedName provided = providedNames.get(name); provided.addDefinition(parent, module); if (isNamespacePlaceholder(parent)) { ...
[ "private", "void", "processProvideFromPreviousPass", "(", "NodeTraversal", "t", ",", "String", "name", ",", "Node", "parent", ")", "{", "JSModule", "module", "=", "t", ".", "getModule", "(", ")", ";", "if", "(", "providedNames", ".", "containsKey", "(", "nam...
Processes the output of processed-provide from a previous pass. This will update our data structures in the same manner as if the provide had been processed in this pass. <p>TODO(b/128120127): delete this method
[ "Processes", "the", "output", "of", "processed", "-", "provide", "from", "a", "previous", "pass", ".", "This", "will", "update", "our", "data", "structures", "in", "the", "same", "manner", "as", "if", "the", "provide", "had", "been", "processed", "in", "th...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L457-L478
24,761
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
ProcessClosureProvidesAndRequires.registerAnyProvidedPrefixes
private void registerAnyProvidedPrefixes(String ns, Node node, JSModule module) { int pos = ns.indexOf('.'); while (pos != -1) { String prefixNs = ns.substring(0, pos); pos = ns.indexOf('.', pos + 1); if (providedNames.containsKey(prefixNs)) { providedNames.get(prefixNs).addProvide(nod...
java
private void registerAnyProvidedPrefixes(String ns, Node node, JSModule module) { int pos = ns.indexOf('.'); while (pos != -1) { String prefixNs = ns.substring(0, pos); pos = ns.indexOf('.', pos + 1); if (providedNames.containsKey(prefixNs)) { providedNames.get(prefixNs).addProvide(nod...
[ "private", "void", "registerAnyProvidedPrefixes", "(", "String", "ns", ",", "Node", "node", ",", "JSModule", "module", ")", "{", "int", "pos", "=", "ns", ".", "indexOf", "(", "'", "'", ")", ";", "while", "(", "pos", "!=", "-", "1", ")", "{", "String"...
Registers ProvidedNames for prefix namespaces if they haven't already been defined. The prefix namespaces must be registered in order from shortest to longest. @param ns The namespace whose prefixes may need to be provided. @param node The EXPR of the provide call. @param module The current module.
[ "Registers", "ProvidedNames", "for", "prefix", "namespaces", "if", "they", "haven", "t", "already", "been", "defined", ".", "The", "prefix", "namespaces", "must", "be", "registered", "in", "order", "from", "shortest", "to", "longest", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L587-L601
24,762
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.mayBeGlobalAlias
private boolean mayBeGlobalAlias(Ref alias) { // Note: alias.scope is the closest scope in which the aliasing assignment occurred. // So for "if (true) { var alias = aliasedVar; }", the alias.scope would be the IF block scope. if (alias.scope.isGlobal()) { return true; } // If the scope in whi...
java
private boolean mayBeGlobalAlias(Ref alias) { // Note: alias.scope is the closest scope in which the aliasing assignment occurred. // So for "if (true) { var alias = aliasedVar; }", the alias.scope would be the IF block scope. if (alias.scope.isGlobal()) { return true; } // If the scope in whi...
[ "private", "boolean", "mayBeGlobalAlias", "(", "Ref", "alias", ")", "{", "// Note: alias.scope is the closest scope in which the aliasing assignment occurred.", "// So for \"if (true) { var alias = aliasedVar; }\", the alias.scope would be the IF block scope.", "if", "(", "alias", ".", "...
Returns true if the alias is possibly defined in the global scope, which we handle with more caution than with locally scoped variables. May return false positives. @param alias An aliasing get. @return If the alias is possibly defined in the global scope.
[ "Returns", "true", "if", "the", "alias", "is", "possibly", "defined", "in", "the", "global", "scope", "which", "we", "handle", "with", "more", "caution", "than", "with", "locally", "scoped", "variables", ".", "May", "return", "false", "positives", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L273-L296
24,763
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.inlineAliasIfPossible
private void inlineAliasIfPossible(Name name, Ref alias, GlobalNamespace namespace) { // Ensure that the alias is assigned to a local variable at that // variable's declaration. If the alias's parent is a NAME, // then the NAME must be the child of a VAR, LET, or CONST node, and we must // be in a VAR, ...
java
private void inlineAliasIfPossible(Name name, Ref alias, GlobalNamespace namespace) { // Ensure that the alias is assigned to a local variable at that // variable's declaration. If the alias's parent is a NAME, // then the NAME must be the child of a VAR, LET, or CONST node, and we must // be in a VAR, ...
[ "private", "void", "inlineAliasIfPossible", "(", "Name", "name", ",", "Ref", "alias", ",", "GlobalNamespace", "namespace", ")", "{", "// Ensure that the alias is assigned to a local variable at that", "// variable's declaration. If the alias's parent is a NAME,", "// then the NAME mu...
Attempts to inline a non-global alias of a global name. <p>It is assumed that the name for which it is an alias meets conditions (a) and (b). <p>The non-global alias is only inlinable if it is well-defined and assigned once, according to the definitions in {@link ReferenceCollection} <p>If the aliasing name is compl...
[ "Attempts", "to", "inline", "a", "non", "-", "global", "alias", "of", "a", "global", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L311-L369
24,764
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.partiallyInlineAlias
private boolean partiallyInlineAlias( Ref alias, GlobalNamespace namespace, ReferenceCollection aliasRefs, Node aliasLhsNode) { BasicBlock aliasBlock = null; // This initial iteration through all the alias references does two things: // a) Find the control flow block in which the alias is assigned. ...
java
private boolean partiallyInlineAlias( Ref alias, GlobalNamespace namespace, ReferenceCollection aliasRefs, Node aliasLhsNode) { BasicBlock aliasBlock = null; // This initial iteration through all the alias references does two things: // a) Find the control flow block in which the alias is assigned. ...
[ "private", "boolean", "partiallyInlineAlias", "(", "Ref", "alias", ",", "GlobalNamespace", "namespace", ",", "ReferenceCollection", "aliasRefs", ",", "Node", "aliasLhsNode", ")", "{", "BasicBlock", "aliasBlock", "=", "null", ";", "// This initial iteration through all the...
Inlines some references to an alias with its value. This handles cases where the alias is not declared at initialization. It does nothing if the alias is reassigned after being initialized, unless the reassignment occurs because of an enclosing function or a loop. @param alias An alias of some variable, which may not ...
[ "Inlines", "some", "references", "to", "an", "alias", "with", "its", "value", ".", "This", "handles", "cases", "where", "the", "alias", "is", "not", "declared", "at", "initialization", ".", "It", "does", "nothing", "if", "the", "alias", "is", "reassigned", ...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L382-L440
24,765
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.tryReplacingAliasingAssignment
private boolean tryReplacingAliasingAssignment(Ref alias, Node aliasLhsNode) { // either VAR/CONST/LET or ASSIGN. Node assignment = aliasLhsNode.getParent(); if (!NodeUtil.isNameDeclaration(assignment) && NodeUtil.isExpressionResultUsed(assignment)) { // e.g. don't change "if (alias = someVariable)" t...
java
private boolean tryReplacingAliasingAssignment(Ref alias, Node aliasLhsNode) { // either VAR/CONST/LET or ASSIGN. Node assignment = aliasLhsNode.getParent(); if (!NodeUtil.isNameDeclaration(assignment) && NodeUtil.isExpressionResultUsed(assignment)) { // e.g. don't change "if (alias = someVariable)" t...
[ "private", "boolean", "tryReplacingAliasingAssignment", "(", "Ref", "alias", ",", "Node", "aliasLhsNode", ")", "{", "// either VAR/CONST/LET or ASSIGN.", "Node", "assignment", "=", "aliasLhsNode", ".", "getParent", "(", ")", ";", "if", "(", "!", "NodeUtil", ".", "...
Replaces the rhs of an aliasing assignment with null, unless the assignment result is used in a complex expression.
[ "Replaces", "the", "rhs", "of", "an", "aliasing", "assignment", "with", "null", "unless", "the", "assignment", "result", "is", "used", "in", "a", "complex", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L446-L460
24,766
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.referencesCollapsibleProperty
private boolean referencesCollapsibleProperty( ReferenceCollection aliasRefs, Name aliasedName, GlobalNamespace namespace) { for (Reference ref : aliasRefs.references) { if (ref.getParent() == null) { continue; } if (ref.getParent().isGetProp()) { Node propertyNode = ref.getN...
java
private boolean referencesCollapsibleProperty( ReferenceCollection aliasRefs, Name aliasedName, GlobalNamespace namespace) { for (Reference ref : aliasRefs.references) { if (ref.getParent() == null) { continue; } if (ref.getParent().isGetProp()) { Node propertyNode = ref.getN...
[ "private", "boolean", "referencesCollapsibleProperty", "(", "ReferenceCollection", "aliasRefs", ",", "Name", "aliasedName", ",", "GlobalNamespace", "namespace", ")", "{", "for", "(", "Reference", "ref", ":", "aliasRefs", ".", "references", ")", "{", "if", "(", "re...
Returns whether a ReferenceCollection for some aliasing variable references a property on the original aliased variable that may be collapsed in CollapseProperties. <p>See {@link GlobalNamespace.Name#canCollapse} for what can/cannot be collapsed.
[ "Returns", "whether", "a", "ReferenceCollection", "for", "some", "aliasing", "variable", "references", "a", "property", "on", "the", "original", "aliased", "variable", "that", "may", "be", "collapsed", "in", "CollapseProperties", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L468-L489
24,767
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.rewriteAliasReferences
private void rewriteAliasReferences(Name aliasingName, Ref aliasingRef, Set<AstChange> newNodes) { List<Ref> refs = new ArrayList<>(aliasingName.getRefs()); for (Ref ref : refs) { switch (ref.type) { case SET_FROM_GLOBAL: continue; case DIRECT_GET: case ALIASING_GET: ...
java
private void rewriteAliasReferences(Name aliasingName, Ref aliasingRef, Set<AstChange> newNodes) { List<Ref> refs = new ArrayList<>(aliasingName.getRefs()); for (Ref ref : refs) { switch (ref.type) { case SET_FROM_GLOBAL: continue; case DIRECT_GET: case ALIASING_GET: ...
[ "private", "void", "rewriteAliasReferences", "(", "Name", "aliasingName", ",", "Ref", "aliasingRef", ",", "Set", "<", "AstChange", ">", "newNodes", ")", "{", "List", "<", "Ref", ">", "refs", "=", "new", "ArrayList", "<>", "(", "aliasingName", ".", "getRefs",...
Replaces all reads of a name with the name it aliases
[ "Replaces", "all", "reads", "of", "a", "name", "with", "the", "name", "it", "aliases" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L589-L628
24,768
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.rewriteNestedAliasReference
private void rewriteNestedAliasReference( Node value, int depth, Set<AstChange> newNodes, Name prop) { rewriteAliasProps(prop, value, depth + 1, newNodes); List<Ref> refs = new ArrayList<>(prop.getRefs()); for (Ref ref : refs) { Node target = ref.getNode(); if (target.isStringKey() && targ...
java
private void rewriteNestedAliasReference( Node value, int depth, Set<AstChange> newNodes, Name prop) { rewriteAliasProps(prop, value, depth + 1, newNodes); List<Ref> refs = new ArrayList<>(prop.getRefs()); for (Ref ref : refs) { Node target = ref.getNode(); if (target.isStringKey() && targ...
[ "private", "void", "rewriteNestedAliasReference", "(", "Node", "value", ",", "int", "depth", ",", "Set", "<", "AstChange", ">", "newNodes", ",", "Name", "prop", ")", "{", "rewriteAliasProps", "(", "prop", ",", "value", ",", "depth", "+", "1", ",", "newNode...
Replaces references to an alias that are nested inside a longer getprop chain or an object literal <p>For example: if we have an inlined alias 'const A = B;', and reference a property 'A.x', then this method is responsible for replacing 'A.x' with 'B.x'. <p>This is necessary because in the above example, given 'A.x',...
[ "Replaces", "references", "to", "an", "alias", "that", "are", "nested", "inside", "a", "longer", "getprop", "chain", "or", "an", "object", "literal" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L685-L748
24,769
google/closure-compiler
src/com/google/javascript/jscomp/AggressiveInlineAliases.java
AggressiveInlineAliases.getSubclassForEs6Superclass
@Nullable private static Node getSubclassForEs6Superclass(Node superclass) { Node classNode = superclass.getParent(); checkArgument(classNode.isClass(), classNode); if (NodeUtil.isNameDeclaration(classNode.getGrandparent())) { // const Clazz = class extends Super { return classNode.getParent()...
java
@Nullable private static Node getSubclassForEs6Superclass(Node superclass) { Node classNode = superclass.getParent(); checkArgument(classNode.isClass(), classNode); if (NodeUtil.isNameDeclaration(classNode.getGrandparent())) { // const Clazz = class extends Super { return classNode.getParent()...
[ "@", "Nullable", "private", "static", "Node", "getSubclassForEs6Superclass", "(", "Node", "superclass", ")", "{", "Node", "classNode", "=", "superclass", ".", "getParent", "(", ")", ";", "checkArgument", "(", "classNode", ".", "isClass", "(", ")", ",", "classN...
Tries to find an lvalue for the subclass given the superclass node in an `class ... extends ` clause <p>Only handles cases where we have either a class declaration or a class expression in an assignment or name declaration. Otherwise returns null.
[ "Tries", "to", "find", "an", "lvalue", "for", "the", "subclass", "given", "the", "superclass", "node", "in", "an", "class", "...", "extends", "clause" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AggressiveInlineAliases.java#L757-L772
24,770
google/closure-compiler
src/com/google/javascript/jscomp/ImplicitNullabilityCheck.java
ImplicitNullabilityCheck.visit
@Override public void visit(final NodeTraversal t, final Node n, final Node p) { final JSDocInfo info = n.getJSDocInfo(); if (info == null) { return; } final JSTypeRegistry registry = compiler.getTypeRegistry(); final List<Node> thrownTypes = transform( info.getThrownTyp...
java
@Override public void visit(final NodeTraversal t, final Node n, final Node p) { final JSDocInfo info = n.getJSDocInfo(); if (info == null) { return; } final JSTypeRegistry registry = compiler.getTypeRegistry(); final List<Node> thrownTypes = transform( info.getThrownTyp...
[ "@", "Override", "public", "void", "visit", "(", "final", "NodeTraversal", "t", ",", "final", "Node", "n", ",", "final", "Node", "p", ")", "{", "final", "JSDocInfo", "info", "=", "n", ".", "getJSDocInfo", "(", ")", ";", "if", "(", "info", "==", "null...
Crawls the JSDoc of the given node to find any names in JSDoc that are implicitly null.
[ "Crawls", "the", "JSDoc", "of", "the", "given", "node", "to", "find", "any", "names", "in", "JSDoc", "that", "are", "implicitly", "null", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ImplicitNullabilityCheck.java#L60-L130
24,771
google/closure-compiler
src/com/google/javascript/jscomp/lint/CheckRequiresSorted.java
CheckRequiresSorted.canonicalizeImports
private static List<ImportStatement> canonicalizeImports( Multimap<String, ImportStatement> importsByNamespace) { List<ImportStatement> canonicalImports = new ArrayList<>(); for (String namespace : importsByNamespace.keySet()) { Collection<ImportStatement> allImports = importsByNamespace.get(namesp...
java
private static List<ImportStatement> canonicalizeImports( Multimap<String, ImportStatement> importsByNamespace) { List<ImportStatement> canonicalImports = new ArrayList<>(); for (String namespace : importsByNamespace.keySet()) { Collection<ImportStatement> allImports = importsByNamespace.get(namesp...
[ "private", "static", "List", "<", "ImportStatement", ">", "canonicalizeImports", "(", "Multimap", "<", "String", ",", "ImportStatement", ">", "importsByNamespace", ")", "{", "List", "<", "ImportStatement", ">", "canonicalImports", "=", "new", "ArrayList", "<>", "(...
Canonicalizes a list of import statements by deduplicating and merging imports for the same namespace, and sorting the result.
[ "Canonicalizes", "a", "list", "of", "import", "statements", "by", "deduplicating", "and", "merging", "imports", "for", "the", "same", "namespace", "and", "sorting", "the", "result", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/lint/CheckRequiresSorted.java#L407-L479
24,772
google/closure-compiler
src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java
MakeDeclaredNamesUnique.getReplacementName
private String getReplacementName(String oldName) { for (Renamer renamer : renamerStack) { String newName = renamer.getReplacementName(oldName); if (newName != null) { return newName; } } return null; }
java
private String getReplacementName(String oldName) { for (Renamer renamer : renamerStack) { String newName = renamer.getReplacementName(oldName); if (newName != null) { return newName; } } return null; }
[ "private", "String", "getReplacementName", "(", "String", "oldName", ")", "{", "for", "(", "Renamer", "renamer", ":", "renamerStack", ")", "{", "String", "newName", "=", "renamer", ".", "getReplacementName", "(", "oldName", ")", ";", "if", "(", "newName", "!...
Walks the stack of name maps and finds the replacement name for the current scope.
[ "Walks", "the", "stack", "of", "name", "maps", "and", "finds", "the", "replacement", "name", "for", "the", "current", "scope", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java#L147-L155
24,773
google/closure-compiler
src/com/google/javascript/jscomp/StatementFusion.java
StatementFusion.fuseIntoOneStatement
private static Node fuseIntoOneStatement(Node parent, Node first, Node last) { // Nothing to fuse if there is only one statement. if (first.getNext() == last) { return first; } // Step one: Create a comma tree that contains all the statements. Node commaTree = first.removeFirstChild(); N...
java
private static Node fuseIntoOneStatement(Node parent, Node first, Node last) { // Nothing to fuse if there is only one statement. if (first.getNext() == last) { return first; } // Step one: Create a comma tree that contains all the statements. Node commaTree = first.removeFirstChild(); N...
[ "private", "static", "Node", "fuseIntoOneStatement", "(", "Node", "parent", ",", "Node", "first", ",", "Node", "last", ")", "{", "// Nothing to fuse if there is only one statement.", "if", "(", "first", ".", "getNext", "(", ")", "==", "last", ")", "{", "return",...
Given a block, fuse a list of statements with comma's. @param parent The parent that contains the statements. @param first The first statement to fuse (inclusive) @param last The last statement to fuse (exclusive) @return A single statement that contains all the fused statement as one.
[ "Given", "a", "block", "fuse", "a", "list", "of", "statements", "with", "comma", "s", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/StatementFusion.java#L164-L185
24,774
google/closure-compiler
src/com/google/javascript/jscomp/graph/GraphColoring.java
GraphColoring.getPartitionSuperNode
public N getPartitionSuperNode(N node) { checkNotNull(colorToNodeMap, "No coloring founded. color() should be called first."); Color color = graph.getNode(node).getAnnotation(); N headNode = colorToNodeMap[color.value]; if (headNode == null) { colorToNodeMap[color.value] = node; return node;...
java
public N getPartitionSuperNode(N node) { checkNotNull(colorToNodeMap, "No coloring founded. color() should be called first."); Color color = graph.getNode(node).getAnnotation(); N headNode = colorToNodeMap[color.value]; if (headNode == null) { colorToNodeMap[color.value] = node; return node;...
[ "public", "N", "getPartitionSuperNode", "(", "N", "node", ")", "{", "checkNotNull", "(", "colorToNodeMap", ",", "\"No coloring founded. color() should be called first.\"", ")", ";", "Color", "color", "=", "graph", ".", "getNode", "(", "node", ")", ".", "getAnnotatio...
Using the coloring as partitions, finds the node that represents that partition as the super node. The first to retrieve its partition will become the super node.
[ "Using", "the", "coloring", "as", "partitions", "finds", "the", "node", "that", "represents", "that", "partition", "as", "the", "super", "node", ".", "The", "first", "to", "retrieve", "its", "partition", "will", "become", "the", "super", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/graph/GraphColoring.java#L69-L79
24,775
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.inject
static Node inject( AbstractCompiler compiler, Node node, Node parent, Map<String, Node> replacements) { return inject(compiler, node, parent, replacements, /* replaceThis */ true); }
java
static Node inject( AbstractCompiler compiler, Node node, Node parent, Map<String, Node> replacements) { return inject(compiler, node, parent, replacements, /* replaceThis */ true); }
[ "static", "Node", "inject", "(", "AbstractCompiler", "compiler", ",", "Node", "node", ",", "Node", "parent", ",", "Map", "<", "String", ",", "Node", ">", "replacements", ")", "{", "return", "inject", "(", "compiler", ",", "node", ",", "parent", ",", "rep...
With the map provided, replace the names with expression trees. @param node The root node of the tree within which to perform the substitutions. @param parent The parent root node. @param replacements The map of names to template node trees with which to replace the name Nodes. @return The root node or its replacement...
[ "With", "the", "map", "provided", "replace", "the", "names", "with", "expression", "trees", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L65-L68
24,776
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.getFunctionCallParameterMap
static ImmutableMap<String, Node> getFunctionCallParameterMap( final Node fnNode, Node callNode, Supplier<String> safeNameIdSupplier) { checkNotNull(fnNode); // Create an argName -> expression map ImmutableMap.Builder<String, Node> argMap = ImmutableMap.builder(); // CALL NODE: [ NAME, ARG1, ARG2...
java
static ImmutableMap<String, Node> getFunctionCallParameterMap( final Node fnNode, Node callNode, Supplier<String> safeNameIdSupplier) { checkNotNull(fnNode); // Create an argName -> expression map ImmutableMap.Builder<String, Node> argMap = ImmutableMap.builder(); // CALL NODE: [ NAME, ARG1, ARG2...
[ "static", "ImmutableMap", "<", "String", ",", "Node", ">", "getFunctionCallParameterMap", "(", "final", "Node", "fnNode", ",", "Node", "callNode", ",", "Supplier", "<", "String", ">", "safeNameIdSupplier", ")", "{", "checkNotNull", "(", "fnNode", ")", ";", "//...
Get a mapping for function parameter names to call arguments.
[ "Get", "a", "mapping", "for", "function", "parameter", "names", "to", "call", "arguments", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L123-L180
24,777
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.maybeAddTempsForCallArguments
static void maybeAddTempsForCallArguments( AbstractCompiler compiler, Node fnNode, ImmutableMap<String, Node> argMap, Set<String> namesNeedingTemps, CodingConvention convention) { if (argMap.isEmpty()) { // No arguments to check, we are done. return; } checkArgumen...
java
static void maybeAddTempsForCallArguments( AbstractCompiler compiler, Node fnNode, ImmutableMap<String, Node> argMap, Set<String> namesNeedingTemps, CodingConvention convention) { if (argMap.isEmpty()) { // No arguments to check, we are done. return; } checkArgumen...
[ "static", "void", "maybeAddTempsForCallArguments", "(", "AbstractCompiler", "compiler", ",", "Node", "fnNode", ",", "ImmutableMap", "<", "String", ",", "Node", ">", "argMap", ",", "Set", "<", "String", ">", "namesNeedingTemps", ",", "CodingConvention", "convention",...
Updates the set of parameter names in set unsafe to include any arguments from the call site that require aliases. @param fnNode The FUNCTION node to be inlined. @param argMap The argument list for the call to fnNode. @param namesNeedingTemps The set of names to update.
[ "Updates", "the", "set", "of", "parameter", "names", "in", "set", "unsafe", "to", "include", "any", "arguments", "from", "the", "call", "site", "that", "require", "aliases", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L271-L359
24,778
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.bodyMayHaveConditionalCode
static boolean bodyMayHaveConditionalCode(Node n) { if (!n.isReturn() && !n.isExprResult()) { return true; } return mayHaveConditionalCode(n); }
java
static boolean bodyMayHaveConditionalCode(Node n) { if (!n.isReturn() && !n.isExprResult()) { return true; } return mayHaveConditionalCode(n); }
[ "static", "boolean", "bodyMayHaveConditionalCode", "(", "Node", "n", ")", "{", "if", "(", "!", "n", ".", "isReturn", "(", ")", "&&", "!", "n", ".", "isExprResult", "(", ")", ")", "{", "return", "true", ";", "}", "return", "mayHaveConditionalCode", "(", ...
We consider a return or expression trivial if it doesn't contain a conditional expression or a function.
[ "We", "consider", "a", "return", "or", "expression", "trivial", "if", "it", "doesn", "t", "contain", "a", "conditional", "expression", "or", "a", "function", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L365-L370
24,779
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.mayHaveConditionalCode
static boolean mayHaveConditionalCode(Node n) { for (Node c = n.getFirstChild(); c != null; c = c.getNext()) { switch (c.getToken()) { case FUNCTION: case AND: case OR: case HOOK: return true; default: break; } if (mayHaveConditionalCode(...
java
static boolean mayHaveConditionalCode(Node n) { for (Node c = n.getFirstChild(); c != null; c = c.getNext()) { switch (c.getToken()) { case FUNCTION: case AND: case OR: case HOOK: return true; default: break; } if (mayHaveConditionalCode(...
[ "static", "boolean", "mayHaveConditionalCode", "(", "Node", "n", ")", "{", "for", "(", "Node", "c", "=", "n", ".", "getFirstChild", "(", ")", ";", "c", "!=", "null", ";", "c", "=", "c", ".", "getNext", "(", ")", ")", "{", "switch", "(", "c", ".",...
We consider an expression trivial if it doesn't contain a conditional expression or a function.
[ "We", "consider", "an", "expression", "trivial", "if", "it", "doesn", "t", "contain", "a", "conditional", "expression", "or", "a", "function", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L376-L392
24,780
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.findParametersReferencedAfterSideEffect
private static ImmutableSet<String> findParametersReferencedAfterSideEffect( ImmutableSet<String> parameters, Node root) { // TODO(johnlenz): Consider using scope for this. Set<String> locals = new HashSet<>(parameters); gatherLocalNames(root, locals); ReferencedAfterSideEffect collector = new R...
java
private static ImmutableSet<String> findParametersReferencedAfterSideEffect( ImmutableSet<String> parameters, Node root) { // TODO(johnlenz): Consider using scope for this. Set<String> locals = new HashSet<>(parameters); gatherLocalNames(root, locals); ReferencedAfterSideEffect collector = new R...
[ "private", "static", "ImmutableSet", "<", "String", ">", "findParametersReferencedAfterSideEffect", "(", "ImmutableSet", "<", "String", ">", "parameters", ",", "Node", "root", ")", "{", "// TODO(johnlenz): Consider using scope for this.", "Set", "<", "String", ">", "loc...
Bootstrap a traversal to look for parameters referenced after a non-local side-effect. NOTE: This assumes no-inner functions. @param parameters The set of parameter names. @param root The function code block. @return The subset of parameters referenced after the first seen non-local side-effect.
[ "Bootstrap", "a", "traversal", "to", "look", "for", "parameters", "referenced", "after", "a", "non", "-", "local", "side", "-", "effect", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L403-L417
24,781
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.gatherLocalNames
private static void gatherLocalNames(Node n, Set<String> names) { if (n.isFunction()) { if (NodeUtil.isFunctionDeclaration(n)) { names.add(n.getFirstChild().getString()); } // Don't traverse into inner function scopes; return; } else if (n.isName()) { switch (n.getParent()....
java
private static void gatherLocalNames(Node n, Set<String> names) { if (n.isFunction()) { if (NodeUtil.isFunctionDeclaration(n)) { names.add(n.getFirstChild().getString()); } // Don't traverse into inner function scopes; return; } else if (n.isName()) { switch (n.getParent()....
[ "private", "static", "void", "gatherLocalNames", "(", "Node", "n", ",", "Set", "<", "String", ">", "names", ")", "{", "if", "(", "n", ".", "isFunction", "(", ")", ")", "{", "if", "(", "NodeUtil", ".", "isFunctionDeclaration", "(", "n", ")", ")", "{",...
Gather any names declared in the local scope.
[ "Gather", "any", "names", "declared", "in", "the", "local", "scope", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L548-L571
24,782
google/closure-compiler
src/com/google/javascript/jscomp/FunctionArgumentInjector.java
FunctionArgumentInjector.getFunctionParameterSet
private static ImmutableSet<String> getFunctionParameterSet(Node fnNode) { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (Node n : NodeUtil.getFunctionParameters(fnNode).children()) { if (n.isRest()){ builder.add(REST_MARKER); } else if (n.isDefaultValue() || n.isObjectP...
java
private static ImmutableSet<String> getFunctionParameterSet(Node fnNode) { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (Node n : NodeUtil.getFunctionParameters(fnNode).children()) { if (n.isRest()){ builder.add(REST_MARKER); } else if (n.isDefaultValue() || n.isObjectP...
[ "private", "static", "ImmutableSet", "<", "String", ">", "getFunctionParameterSet", "(", "Node", "fnNode", ")", "{", "ImmutableSet", ".", "Builder", "<", "String", ">", "builder", "=", "ImmutableSet", ".", "builder", "(", ")", ";", "for", "(", "Node", "n", ...
Get a set of function parameter names.
[ "Get", "a", "set", "of", "function", "parameter", "names", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionArgumentInjector.java#L576-L588
24,783
google/closure-compiler
src/com/google/javascript/jscomp/resources/ResourceLoader.java
ResourceLoader.loadGlobalConformance
public static ConformanceConfig loadGlobalConformance(Class<?> clazz) { ConformanceConfig.Builder builder = ConformanceConfig.newBuilder(); if (resourceExists(clazz, "global_conformance.binarypb")) { try { builder.mergeFrom(clazz.getResourceAsStream("global_conformance.binarypb")); } catch (...
java
public static ConformanceConfig loadGlobalConformance(Class<?> clazz) { ConformanceConfig.Builder builder = ConformanceConfig.newBuilder(); if (resourceExists(clazz, "global_conformance.binarypb")) { try { builder.mergeFrom(clazz.getResourceAsStream("global_conformance.binarypb")); } catch (...
[ "public", "static", "ConformanceConfig", "loadGlobalConformance", "(", "Class", "<", "?", ">", "clazz", ")", "{", "ConformanceConfig", ".", "Builder", "builder", "=", "ConformanceConfig", ".", "newBuilder", "(", ")", ";", "if", "(", "resourceExists", "(", "clazz...
Load the global ConformanceConfig
[ "Load", "the", "global", "ConformanceConfig" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/resources/ResourceLoader.java#L47-L57
24,784
google/closure-compiler
src/com/google/javascript/jscomp/lint/CheckUselessBlocks.java
CheckUselessBlocks.isLoneBlock
private boolean isLoneBlock(Node n) { Node parent = n.getParent(); if (parent != null && (parent.isScript() || (parent.isBlock() && !parent.isSyntheticBlock() && !parent.isAddedBlock()))) { return !n.isSyntheticBlock() && !n.isAddedBlock(); } return false; }
java
private boolean isLoneBlock(Node n) { Node parent = n.getParent(); if (parent != null && (parent.isScript() || (parent.isBlock() && !parent.isSyntheticBlock() && !parent.isAddedBlock()))) { return !n.isSyntheticBlock() && !n.isAddedBlock(); } return false; }
[ "private", "boolean", "isLoneBlock", "(", "Node", "n", ")", "{", "Node", "parent", "=", "n", ".", "getParent", "(", ")", ";", "if", "(", "parent", "!=", "null", "&&", "(", "parent", ".", "isScript", "(", ")", "||", "(", "parent", ".", "isBlock", "(...
A lone block is a non-synthetic, not-added BLOCK that is a direct child of another non-synthetic, not-added BLOCK or a SCRIPT node.
[ "A", "lone", "block", "is", "a", "non", "-", "synthetic", "not", "-", "added", "BLOCK", "that", "is", "a", "direct", "child", "of", "another", "non", "-", "synthetic", "not", "-", "added", "BLOCK", "or", "a", "SCRIPT", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/lint/CheckUselessBlocks.java#L74-L81
24,785
google/closure-compiler
src/com/google/javascript/jscomp/lint/CheckUselessBlocks.java
CheckUselessBlocks.allowLoneBlock
private void allowLoneBlock(Node parent) { if (loneBlocks.isEmpty()) { return; } if (loneBlocks.peek() == parent) { loneBlocks.pop(); } }
java
private void allowLoneBlock(Node parent) { if (loneBlocks.isEmpty()) { return; } if (loneBlocks.peek() == parent) { loneBlocks.pop(); } }
[ "private", "void", "allowLoneBlock", "(", "Node", "parent", ")", "{", "if", "(", "loneBlocks", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "if", "(", "loneBlocks", ".", "peek", "(", ")", "==", "parent", ")", "{", "loneBlocks", ".", "pop",...
Remove the enclosing block of a block-scoped declaration from the loneBlocks stack.
[ "Remove", "the", "enclosing", "block", "of", "a", "block", "-", "scoped", "declaration", "from", "the", "loneBlocks", "stack", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/lint/CheckUselessBlocks.java#L86-L94
24,786
google/closure-compiler
src/com/google/javascript/jscomp/ExpressionDecomposer.java
ExpressionDecomposer.maybeExposeExpression
void maybeExposeExpression(Node expression) { // If the expression needs to exposed. int i = 0; while (DecompositionType.DECOMPOSABLE == canExposeExpression(expression)) { exposeExpression(expression); i++; if (i > MAX_ITERATIONS) { throw new IllegalStateException( "Dec...
java
void maybeExposeExpression(Node expression) { // If the expression needs to exposed. int i = 0; while (DecompositionType.DECOMPOSABLE == canExposeExpression(expression)) { exposeExpression(expression); i++; if (i > MAX_ITERATIONS) { throw new IllegalStateException( "Dec...
[ "void", "maybeExposeExpression", "(", "Node", "expression", ")", "{", "// If the expression needs to exposed.", "int", "i", "=", "0", ";", "while", "(", "DecompositionType", ".", "DECOMPOSABLE", "==", "canExposeExpression", "(", "expression", ")", ")", "{", "exposeE...
If required, rewrite the statement containing the expression. @param expression The expression to be exposed. @see #canExposeExpression
[ "If", "required", "rewrite", "the", "statement", "containing", "the", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExpressionDecomposer.java#L108-L119
24,787
google/closure-compiler
src/com/google/javascript/jscomp/ExpressionDecomposer.java
ExpressionDecomposer.moveExpression
void moveExpression(Node expression) { // TODO(johnlenz): This is not currently used by the function inliner, // as moving the call out of the expression before the actual function call // causes additional variables to be introduced. As the variable // inliner is improved, this might be a viable optio...
java
void moveExpression(Node expression) { // TODO(johnlenz): This is not currently used by the function inliner, // as moving the call out of the expression before the actual function call // causes additional variables to be introduced. As the variable // inliner is improved, this might be a viable optio...
[ "void", "moveExpression", "(", "Node", "expression", ")", "{", "// TODO(johnlenz): This is not currently used by the function inliner,", "// as moving the call out of the expression before the actual function call", "// causes additional variables to be introduced. As the variable", "// inliner...
Extract the specified expression from its parent expression. @see #canExposeExpression
[ "Extract", "the", "specified", "expression", "from", "its", "parent", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExpressionDecomposer.java#L257-L281
24,788
google/closure-compiler
src/com/google/javascript/jscomp/ExpressionDecomposer.java
ExpressionDecomposer.buildResultExpression
private static Node buildResultExpression(Node expr, boolean needResult, String tempName) { if (needResult) { JSType type = expr.getJSType(); return withType(IR.assign(withType(IR.name(tempName), type), expr), type).srcrefTree(expr); } else { return expr; } }
java
private static Node buildResultExpression(Node expr, boolean needResult, String tempName) { if (needResult) { JSType type = expr.getJSType(); return withType(IR.assign(withType(IR.name(tempName), type), expr), type).srcrefTree(expr); } else { return expr; } }
[ "private", "static", "Node", "buildResultExpression", "(", "Node", "expr", ",", "boolean", "needResult", ",", "String", "tempName", ")", "{", "if", "(", "needResult", ")", "{", "JSType", "type", "=", "expr", ".", "getJSType", "(", ")", ";", "return", "with...
Create an expression tree for an expression. <p>If the result of the expression is needed, then: <pre> ASSIGN tempName expr </pre> otherwise, simply: `expr`
[ "Create", "an", "expression", "tree", "for", "an", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExpressionDecomposer.java#L474-L481
24,789
google/closure-compiler
src/com/google/javascript/jscomp/ExpressionDecomposer.java
ExpressionDecomposer.rewriteCallExpression
private Node rewriteCallExpression(Node call, DecompositionState state) { checkArgument(call.isCall(), call); Node first = call.getFirstChild(); checkArgument(NodeUtil.isGet(first), first); // Find the type of (fn expression).call JSType fnType = first.getJSType(); JSType fnCallType = null; ...
java
private Node rewriteCallExpression(Node call, DecompositionState state) { checkArgument(call.isCall(), call); Node first = call.getFirstChild(); checkArgument(NodeUtil.isGet(first), first); // Find the type of (fn expression).call JSType fnType = first.getJSType(); JSType fnCallType = null; ...
[ "private", "Node", "rewriteCallExpression", "(", "Node", "call", ",", "DecompositionState", "state", ")", "{", "checkArgument", "(", "call", ".", "isCall", "(", ")", ",", "call", ")", ";", "Node", "first", "=", "call", ".", "getFirstChild", "(", ")", ";", ...
Rewrite the call so "this" is preserved. <pre>a.b(c);</pre> becomes: <pre> var temp1 = a; var temp0 = temp1.b; temp0.call(temp1,c); </pre> @return The replacement node.
[ "Rewrite", "the", "call", "so", "this", "is", "preserved", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExpressionDecomposer.java#L606-L666
24,790
google/closure-compiler
src/com/google/javascript/jscomp/ExpressionDecomposer.java
ExpressionDecomposer.getTempConstantValueName
private String getTempConstantValueName() { String name = tempNamePrefix + "_const" + ContextualRenamer.UNIQUE_ID_SEPARATOR + safeNameIdSupplier.get(); this.knownConstants.add(name); return name; }
java
private String getTempConstantValueName() { String name = tempNamePrefix + "_const" + ContextualRenamer.UNIQUE_ID_SEPARATOR + safeNameIdSupplier.get(); this.knownConstants.add(name); return name; }
[ "private", "String", "getTempConstantValueName", "(", ")", "{", "String", "name", "=", "tempNamePrefix", "+", "\"_const\"", "+", "ContextualRenamer", ".", "UNIQUE_ID_SEPARATOR", "+", "safeNameIdSupplier", ".", "get", "(", ")", ";", "this", ".", "knownConstants", "...
Create a constant unique temp name.
[ "Create", "a", "constant", "unique", "temp", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExpressionDecomposer.java#L694-L702
24,791
google/closure-compiler
src/com/google/javascript/jscomp/ExpressionDecomposer.java
ExpressionDecomposer.getEvaluationDirection
private static EvaluationDirection getEvaluationDirection(Node node) { switch (node.getToken()) { case DESTRUCTURING_LHS: case ASSIGN: case DEFAULT_VALUE: if (node.getFirstChild().isDestructuringPattern()) { // The lhs of a destructuring assignment is evaluated AFTER the rhs. Thi...
java
private static EvaluationDirection getEvaluationDirection(Node node) { switch (node.getToken()) { case DESTRUCTURING_LHS: case ASSIGN: case DEFAULT_VALUE: if (node.getFirstChild().isDestructuringPattern()) { // The lhs of a destructuring assignment is evaluated AFTER the rhs. Thi...
[ "private", "static", "EvaluationDirection", "getEvaluationDirection", "(", "Node", "node", ")", "{", "switch", "(", "node", ".", "getToken", "(", ")", ")", "{", "case", "DESTRUCTURING_LHS", ":", "case", "ASSIGN", ":", "case", "DEFAULT_VALUE", ":", "if", "(", ...
Returns the order in which the given node's children should be evaluated. <p>In most cases, this is EvaluationDirection.FORWARD because the AST order matches the actual evaluation order. A few nodes require reversed evaluation instead.
[ "Returns", "the", "order", "in", "which", "the", "given", "node", "s", "children", "should", "be", "evaluated", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExpressionDecomposer.java#L969-L984
24,792
google/closure-compiler
src/com/google/javascript/jscomp/FunctionToBlockMutator.java
FunctionToBlockMutator.mutateWithoutRenaming
Node mutateWithoutRenaming( String fnName, Node fnNode, Node callNode, String resultName, boolean needsDefaultResult, boolean isCallInLoop) { return mutateInternal( fnName, fnNode, callNode, resultName, needsDefaultResult, isCallInL...
java
Node mutateWithoutRenaming( String fnName, Node fnNode, Node callNode, String resultName, boolean needsDefaultResult, boolean isCallInLoop) { return mutateInternal( fnName, fnNode, callNode, resultName, needsDefaultResult, isCallInL...
[ "Node", "mutateWithoutRenaming", "(", "String", "fnName", ",", "Node", "fnNode", ",", "Node", "callNode", ",", "String", "resultName", ",", "boolean", "needsDefaultResult", ",", "boolean", "isCallInLoop", ")", "{", "return", "mutateInternal", "(", "fnName", ",", ...
Used where the inlining occurs into an isolated scope such as a module. Renaming is avoided since the associated JSDoc annotations are not updated. @param fnName The name to use when preparing human readable names. @param fnNode The function to prepare. @param callNode The call node that will be replaced. @param resul...
[ "Used", "where", "the", "inlining", "occurs", "into", "an", "isolated", "scope", "such", "as", "a", "module", ".", "Renaming", "is", "avoided", "since", "the", "associated", "JSDoc", "annotations", "are", "not", "updated", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L87-L102
24,793
google/closure-compiler
src/com/google/javascript/jscomp/FunctionToBlockMutator.java
FunctionToBlockMutator.fixUninitializedVarDeclarations
private static void fixUninitializedVarDeclarations(Node n, Node containingBlock) { // Inner loop structure must already have logic to initialize its // variables. In particular FOR-IN structures must not be modified. if (NodeUtil.isLoopStructure(n)) { return; } if ((n.isVar() || n.isLet()) ...
java
private static void fixUninitializedVarDeclarations(Node n, Node containingBlock) { // Inner loop structure must already have logic to initialize its // variables. In particular FOR-IN structures must not be modified. if (NodeUtil.isLoopStructure(n)) { return; } if ((n.isVar() || n.isLet()) ...
[ "private", "static", "void", "fixUninitializedVarDeclarations", "(", "Node", "n", ",", "Node", "containingBlock", ")", "{", "// Inner loop structure must already have logic to initialize its", "// variables. In particular FOR-IN structures must not be modified.", "if", "(", "NodeUti...
For all VAR node with uninitialized declarations, set the values to be "undefined".
[ "For", "all", "VAR", "node", "with", "uninitialized", "declarations", "set", "the", "values", "to", "be", "undefined", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L228-L249
24,794
google/closure-compiler
src/com/google/javascript/jscomp/FunctionToBlockMutator.java
FunctionToBlockMutator.makeLocalNamesUnique
private void makeLocalNamesUnique(Node fnNode, boolean isCallInLoop) { Supplier<String> idSupplier = compiler.getUniqueNameIdSupplier(); // Make variable names unique to this instance. NodeTraversal.traverseScopeRoots( compiler, null, ImmutableList.of(fnNode), new MakeDeclare...
java
private void makeLocalNamesUnique(Node fnNode, boolean isCallInLoop) { Supplier<String> idSupplier = compiler.getUniqueNameIdSupplier(); // Make variable names unique to this instance. NodeTraversal.traverseScopeRoots( compiler, null, ImmutableList.of(fnNode), new MakeDeclare...
[ "private", "void", "makeLocalNamesUnique", "(", "Node", "fnNode", ",", "boolean", "isCallInLoop", ")", "{", "Supplier", "<", "String", ">", "idSupplier", "=", "compiler", ".", "getUniqueNameIdSupplier", "(", ")", ";", "// Make variable names unique to this instance.", ...
Fix-up all local names to be unique for this subtree. @param fnNode A mutable instance of the function to be inlined.
[ "Fix", "-", "up", "all", "local", "names", "to", "be", "unique", "for", "this", "subtree", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L255-L270
24,795
google/closure-compiler
src/com/google/javascript/jscomp/FunctionToBlockMutator.java
FunctionToBlockMutator.getLabelNameForFunction
private String getLabelNameForFunction(String fnName) { String name = (isNullOrEmpty(fnName)) ? "anon" : fnName; return "JSCompiler_inline_label_" + name + "_" + safeNameIdSupplier.get(); }
java
private String getLabelNameForFunction(String fnName) { String name = (isNullOrEmpty(fnName)) ? "anon" : fnName; return "JSCompiler_inline_label_" + name + "_" + safeNameIdSupplier.get(); }
[ "private", "String", "getLabelNameForFunction", "(", "String", "fnName", ")", "{", "String", "name", "=", "(", "isNullOrEmpty", "(", "fnName", ")", ")", "?", "\"anon\"", ":", "fnName", ";", "return", "\"JSCompiler_inline_label_\"", "+", "name", "+", "\"_\"", "...
Create a unique label name.
[ "Create", "a", "unique", "label", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L288-L291
24,796
google/closure-compiler
src/com/google/javascript/jscomp/FunctionToBlockMutator.java
FunctionToBlockMutator.aliasAndInlineArguments
private Node aliasAndInlineArguments( Node fnTemplateRoot, ImmutableMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. Node result = FunctionArgumentInjector.inject( ...
java
private Node aliasAndInlineArguments( Node fnTemplateRoot, ImmutableMap<String, Node> argMap, Set<String> namesToAlias) { if (namesToAlias == null || namesToAlias.isEmpty()) { // There are no names to alias, just inline the arguments directly. Node result = FunctionArgumentInjector.inject( ...
[ "private", "Node", "aliasAndInlineArguments", "(", "Node", "fnTemplateRoot", ",", "ImmutableMap", "<", "String", ",", "Node", ">", "argMap", ",", "Set", "<", "String", ">", "namesToAlias", ")", "{", "if", "(", "namesToAlias", "==", "null", "||", "namesToAlias"...
Inlines the arguments within the node tree using the given argument map, replaces "unsafe" names with local aliases. The aliases for unsafe require new VAR declarations, so this function can not be used in for direct CALL node replacement as VAR nodes can not be created there. @return The node or its replacement.
[ "Inlines", "the", "arguments", "within", "the", "node", "tree", "using", "the", "given", "argument", "map", "replaces", "unsafe", "names", "with", "local", "aliases", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L310-L379
24,797
google/closure-compiler
src/com/google/javascript/jscomp/FunctionToBlockMutator.java
FunctionToBlockMutator.createAssignStatementNode
private static Node createAssignStatementNode(String name, Node expression) { // Create 'name = result-expression;' statement. // EXPR (ASSIGN (NAME, EXPRESSION)) Node nameNode = IR.name(name); Node assign = IR.assign(nameNode, expression); return NodeUtil.newExpr(assign); }
java
private static Node createAssignStatementNode(String name, Node expression) { // Create 'name = result-expression;' statement. // EXPR (ASSIGN (NAME, EXPRESSION)) Node nameNode = IR.name(name); Node assign = IR.assign(nameNode, expression); return NodeUtil.newExpr(assign); }
[ "private", "static", "Node", "createAssignStatementNode", "(", "String", "name", ",", "Node", "expression", ")", "{", "// Create 'name = result-expression;' statement.", "// EXPR (ASSIGN (NAME, EXPRESSION))", "Node", "nameNode", "=", "IR", ".", "name", "(", "name", ")", ...
Create a valid statement Node containing an assignment to name of the given expression.
[ "Create", "a", "valid", "statement", "Node", "containing", "an", "assignment", "to", "name", "of", "the", "given", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L496-L502
24,798
google/closure-compiler
src/com/google/javascript/jscomp/JSModuleGraph.java
JSModuleGraph.makeWeakModule
private List<JSModule> makeWeakModule(List<JSModule> modulesInDepOrder) { boolean hasWeakModule = false; for (JSModule module : modulesInDepOrder) { if (module.getName().equals(JSModule.WEAK_MODULE_NAME)) { hasWeakModule = true; Set<JSModule> allOtherModules = new HashSet<>(modulesInDepOrd...
java
private List<JSModule> makeWeakModule(List<JSModule> modulesInDepOrder) { boolean hasWeakModule = false; for (JSModule module : modulesInDepOrder) { if (module.getName().equals(JSModule.WEAK_MODULE_NAME)) { hasWeakModule = true; Set<JSModule> allOtherModules = new HashSet<>(modulesInDepOrd...
[ "private", "List", "<", "JSModule", ">", "makeWeakModule", "(", "List", "<", "JSModule", ">", "modulesInDepOrder", ")", "{", "boolean", "hasWeakModule", "=", "false", ";", "for", "(", "JSModule", "module", ":", "modulesInDepOrder", ")", "{", "if", "(", "modu...
If a weak module doesn't already exist, creates a weak module depending on every other module. <p>Does not move any sources into the weak module. @return a new list of modules that includes the weak module, if it was newly created, or the same list if the weak module already existed @throws IllegalStateException if a...
[ "If", "a", "weak", "module", "doesn", "t", "already", "exist", "creates", "a", "weak", "module", "depending", "on", "every", "other", "module", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JSModuleGraph.java#L164-L204
24,799
google/closure-compiler
src/com/google/javascript/jscomp/JSModuleGraph.java
JSModuleGraph.getAllInputs
Iterable<CompilerInput> getAllInputs() { return Iterables.concat(Iterables.transform(Arrays.asList(modules), JSModule::getInputs)); }
java
Iterable<CompilerInput> getAllInputs() { return Iterables.concat(Iterables.transform(Arrays.asList(modules), JSModule::getInputs)); }
[ "Iterable", "<", "CompilerInput", ">", "getAllInputs", "(", ")", "{", "return", "Iterables", ".", "concat", "(", "Iterables", ".", "transform", "(", "Arrays", ".", "asList", "(", "modules", ")", ",", "JSModule", "::", "getInputs", ")", ")", ";", "}" ]
Gets an iterable over all input source files in dependency order.
[ "Gets", "an", "iterable", "over", "all", "input", "source", "files", "in", "dependency", "order", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JSModuleGraph.java#L239-L241