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,200
google/closure-compiler
src/com/google/javascript/jscomp/ComposeWarningsGuard.java
ComposeWarningsGuard.makeEmergencyFailSafeGuard
ComposeWarningsGuard makeEmergencyFailSafeGuard() { ComposeWarningsGuard safeGuard = new ComposeWarningsGuard(); safeGuard.demoteErrors = true; for (WarningsGuard guard : guards.descendingSet()) { safeGuard.addGuard(guard); } return safeGuard; }
java
ComposeWarningsGuard makeEmergencyFailSafeGuard() { ComposeWarningsGuard safeGuard = new ComposeWarningsGuard(); safeGuard.demoteErrors = true; for (WarningsGuard guard : guards.descendingSet()) { safeGuard.addGuard(guard); } return safeGuard; }
[ "ComposeWarningsGuard", "makeEmergencyFailSafeGuard", "(", ")", "{", "ComposeWarningsGuard", "safeGuard", "=", "new", "ComposeWarningsGuard", "(", ")", ";", "safeGuard", ".", "demoteErrors", "=", "true", ";", "for", "(", "WarningsGuard", "guard", ":", "guards", ".",...
Make a warnings guard that's the same as this one but demotes all errors to warnings.
[ "Make", "a", "warnings", "guard", "that", "s", "the", "same", "as", "this", "one", "but", "demotes", "all", "errors", "to", "warnings", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ComposeWarningsGuard.java#L167-L174
24,201
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.isSupportedCallType
private boolean isSupportedCallType(Node callNode) { if (!callNode.getFirstChild().isName()) { if (NodeUtil.isFunctionObjectCall(callNode)) { if (!assumeStrictThis) { Node thisValue = callNode.getSecondChild(); if (thisValue == null || !thisValue.isThis()) { return fals...
java
private boolean isSupportedCallType(Node callNode) { if (!callNode.getFirstChild().isName()) { if (NodeUtil.isFunctionObjectCall(callNode)) { if (!assumeStrictThis) { Node thisValue = callNode.getSecondChild(); if (thisValue == null || !thisValue.isThis()) { return fals...
[ "private", "boolean", "isSupportedCallType", "(", "Node", "callNode", ")", "{", "if", "(", "!", "callNode", ".", "getFirstChild", "(", ")", ".", "isName", "(", ")", ")", "{", "if", "(", "NodeUtil", ".", "isFunctionObjectCall", "(", "callNode", ")", ")", ...
Only ".call" calls and direct calls to functions are supported. @param callNode The call evaluate. @return Whether the call is of a type that is supported.
[ "Only", ".", "call", "calls", "and", "direct", "calls", "to", "functions", "are", "supported", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L268-L283
24,202
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.inline
Node inline(Reference ref, String fnName, Node fnNode) { checkState(compiler.getLifeCycleStage().isNormalized()); return internalInline(ref, fnName, fnNode); }
java
Node inline(Reference ref, String fnName, Node fnNode) { checkState(compiler.getLifeCycleStage().isNormalized()); return internalInline(ref, fnName, fnNode); }
[ "Node", "inline", "(", "Reference", "ref", ",", "String", "fnName", ",", "Node", "fnNode", ")", "{", "checkState", "(", "compiler", ".", "getLifeCycleStage", "(", ")", ".", "isNormalized", "(", ")", ")", ";", "return", "internalInline", "(", "ref", ",", ...
Inline a function into the call site.
[ "Inline", "a", "function", "into", "the", "call", "site", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L298-L301
24,203
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.inlineReturnValue
private Node inlineReturnValue(Reference ref, Node fnNode) { Node callNode = ref.callNode; Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new names, there is...
java
private Node inlineReturnValue(Reference ref, Node fnNode) { Node callNode = ref.callNode; Node block = fnNode.getLastChild(); Node callParentNode = callNode.getParent(); // NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new names, there is...
[ "private", "Node", "inlineReturnValue", "(", "Reference", "ref", ",", "Node", "fnNode", ")", "{", "Node", "callNode", "=", "ref", ".", "callNode", ";", "Node", "block", "=", "fnNode", ".", "getLastChild", "(", ")", ";", "Node", "callParentNode", "=", "call...
Inline a function that fulfills the requirements of canInlineReferenceDirectly into the call site, replacing only the CALL node.
[ "Inline", "a", "function", "that", "fulfills", "the", "requirements", "of", "canInlineReferenceDirectly", "into", "the", "call", "site", "replacing", "only", "the", "CALL", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L328-L368
24,204
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.classifyCallSite
private CallSiteType classifyCallSite(Reference ref) { Node callNode = ref.callNode; Node parent = callNode.getParent(); Node grandParent = parent.getParent(); // Verify the call site: if (NodeUtil.isExprCall(parent)) { // This is a simple call. Example: "foo();". return CallSiteType.SI...
java
private CallSiteType classifyCallSite(Reference ref) { Node callNode = ref.callNode; Node parent = callNode.getParent(); Node grandParent = parent.getParent(); // Verify the call site: if (NodeUtil.isExprCall(parent)) { // This is a simple call. Example: "foo();". return CallSiteType.SI...
[ "private", "CallSiteType", "classifyCallSite", "(", "Reference", "ref", ")", "{", "Node", "callNode", "=", "ref", ".", "callNode", ";", "Node", "parent", "=", "callNode", ".", "getParent", "(", ")", ";", "Node", "grandParent", "=", "parent", ".", "getParent"...
Determine which, if any, of the supported types the call site is. Constant vars are treated differently so that we don't break their const-ness when we decompose the expression. Once the CONSTANT_VAR annotation is used everywhere instead of coding conventions, we should just teach this pass how to remove the annotatio...
[ "Determine", "which", "if", "any", "of", "the", "supported", "types", "the", "call", "site", "is", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L484-L524
24,205
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.maybePrepareCall
void maybePrepareCall(Reference ref) { CallSiteType callSiteType = classifyCallSite(ref); callSiteType.prepare(this, ref); }
java
void maybePrepareCall(Reference ref) { CallSiteType callSiteType = classifyCallSite(ref); callSiteType.prepare(this, ref); }
[ "void", "maybePrepareCall", "(", "Reference", "ref", ")", "{", "CallSiteType", "callSiteType", "=", "classifyCallSite", "(", "ref", ")", ";", "callSiteType", ".", "prepare", "(", "this", ",", "ref", ")", ";", "}" ]
If required, rewrite the statement containing the call expression. @see ExpressionDecomposer#canExposeExpression
[ "If", "required", "rewrite", "the", "statement", "containing", "the", "call", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L535-L538
24,206
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.inlineFunction
private Node inlineFunction(Reference ref, Node fnNode, String fnName) { Node callNode = ref.callNode; Node parent = callNode.getParent(); Node grandParent = parent.getParent(); // TODO(johnlenz): Consider storing the callSite classification in the // reference object and passing it in here. Ca...
java
private Node inlineFunction(Reference ref, Node fnNode, String fnName) { Node callNode = ref.callNode; Node parent = callNode.getParent(); Node grandParent = parent.getParent(); // TODO(johnlenz): Consider storing the callSite classification in the // reference object and passing it in here. Ca...
[ "private", "Node", "inlineFunction", "(", "Reference", "ref", ",", "Node", "fnNode", ",", "String", "fnName", ")", "{", "Node", "callNode", "=", "ref", ".", "callNode", ";", "Node", "parent", "=", "callNode", ".", "getParent", "(", ")", ";", "Node", "gra...
Inline a function which fulfills the requirements of canInlineReferenceAsStatementBlock into the call site, replacing the parent expression.
[ "Inline", "a", "function", "which", "fulfills", "the", "requirements", "of", "canInlineReferenceAsStatementBlock", "into", "the", "call", "site", "replacing", "the", "parent", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L545-L630
24,207
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.isDirectCallNodeReplacementPossible
static boolean isDirectCallNodeReplacementPossible(Node fnNode) { // Only inline single-statement functions Node block = NodeUtil.getFunctionBody(fnNode); // Check if this function is suitable for direct replacement of a CALL node: // a function that consists of single return that returns an expression...
java
static boolean isDirectCallNodeReplacementPossible(Node fnNode) { // Only inline single-statement functions Node block = NodeUtil.getFunctionBody(fnNode); // Check if this function is suitable for direct replacement of a CALL node: // a function that consists of single return that returns an expression...
[ "static", "boolean", "isDirectCallNodeReplacementPossible", "(", "Node", "fnNode", ")", "{", "// Only inline single-statement functions", "Node", "block", "=", "NodeUtil", ".", "getFunctionBody", "(", "fnNode", ")", ";", "// Check if this function is suitable for direct replace...
Checks if the given function matches the criteria for an inlinable function, and if so, adds it to our set of inlinable functions.
[ "Checks", "if", "the", "given", "function", "matches", "the", "criteria", "for", "an", "inlinable", "function", "and", "if", "so", "adds", "it", "to", "our", "set", "of", "inlinable", "functions", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L648-L666
24,208
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.callMeetsBlockInliningRequirements
private boolean callMeetsBlockInliningRequirements( Reference ref, final Node fnNode, ImmutableSet<String> namesToAlias) { // Note: functions that contain function definitions are filtered out // in isCandidateFunction. // TODO(johnlenz): Determining if the called function contains VARs // or if ...
java
private boolean callMeetsBlockInliningRequirements( Reference ref, final Node fnNode, ImmutableSet<String> namesToAlias) { // Note: functions that contain function definitions are filtered out // in isCandidateFunction. // TODO(johnlenz): Determining if the called function contains VARs // or if ...
[ "private", "boolean", "callMeetsBlockInliningRequirements", "(", "Reference", "ref", ",", "final", "Node", "fnNode", ",", "ImmutableSet", "<", "String", ">", "namesToAlias", ")", "{", "// Note: functions that contain function definitions are filtered out", "// in isCandidateFun...
Determines whether a function can be inlined at a particular call site. - Don't inline if the calling function contains an inner function and inlining would introduce new globals.
[ "Determines", "whether", "a", "function", "can", "be", "inlined", "at", "a", "particular", "call", "site", ".", "-", "Don", "t", "inline", "if", "the", "calling", "function", "contains", "an", "inner", "function", "and", "inlining", "would", "introduce", "ne...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L715-L775
24,209
google/closure-compiler
src/com/google/javascript/jscomp/FunctionInjector.java
FunctionInjector.inliningLowersCost
boolean inliningLowersCost( JSModule fnModule, Node fnNode, Collection<? extends Reference> refs, Set<String> namesToAlias, boolean isRemovable, boolean referencesThis) { int referenceCount = refs.size(); if (referenceCount == 0) { return true; } int referencesUsingBlockInlining = 0; ...
java
boolean inliningLowersCost( JSModule fnModule, Node fnNode, Collection<? extends Reference> refs, Set<String> namesToAlias, boolean isRemovable, boolean referencesThis) { int referenceCount = refs.size(); if (referenceCount == 0) { return true; } int referencesUsingBlockInlining = 0; ...
[ "boolean", "inliningLowersCost", "(", "JSModule", "fnModule", ",", "Node", "fnNode", ",", "Collection", "<", "?", "extends", "Reference", ">", "refs", ",", "Set", "<", "String", ">", "namesToAlias", ",", "boolean", "isRemovable", ",", "boolean", "referencesThis"...
Determine if inlining the function is likely to reduce the code size. @param namesToAlias
[ "Determine", "if", "inlining", "the", "function", "is", "likely", "to", "reduce", "the", "code", "size", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionInjector.java#L836-L887
24,210
google/closure-compiler
src/com/google/debugging/sourcemap/SourceMapConsumerV3.java
SourceMapConsumerV3.search
private static int search(ArrayList<Entry> entries, int target, int start, int end) { while (true) { int mid = ((end - start) / 2) + start; int compare = compareEntry(entries, mid, target); if (compare == 0) { return mid; } else if (compare < 0) { // it is in the upper half ...
java
private static int search(ArrayList<Entry> entries, int target, int start, int end) { while (true) { int mid = ((end - start) / 2) + start; int compare = compareEntry(entries, mid, target); if (compare == 0) { return mid; } else if (compare < 0) { // it is in the upper half ...
[ "private", "static", "int", "search", "(", "ArrayList", "<", "Entry", ">", "entries", ",", "int", "target", ",", "int", "start", ",", "int", "end", ")", "{", "while", "(", "true", ")", "{", "int", "mid", "=", "(", "(", "end", "-", "start", ")", "...
Perform a binary search on the array to find a section that covers the target column.
[ "Perform", "a", "binary", "search", "on", "the", "array", "to", "find", "a", "section", "that", "covers", "the", "target", "column", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapConsumerV3.java#L396-L416
24,211
google/closure-compiler
src/com/google/debugging/sourcemap/SourceMapConsumerV3.java
SourceMapConsumerV3.compareEntry
private static int compareEntry(ArrayList<Entry> entries, int entry, int target) { return entries.get(entry).getGeneratedColumn() - target; }
java
private static int compareEntry(ArrayList<Entry> entries, int entry, int target) { return entries.get(entry).getGeneratedColumn() - target; }
[ "private", "static", "int", "compareEntry", "(", "ArrayList", "<", "Entry", ">", "entries", ",", "int", "entry", ",", "int", "target", ")", "{", "return", "entries", ".", "get", "(", "entry", ")", ".", "getGeneratedColumn", "(", ")", "-", "target", ";", ...
Compare an array entry's column value to the target column value.
[ "Compare", "an", "array", "entry", "s", "column", "value", "to", "the", "target", "column", "value", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapConsumerV3.java#L421-L423
24,212
google/closure-compiler
src/com/google/debugging/sourcemap/SourceMapConsumerV3.java
SourceMapConsumerV3.getPreviousMapping
private OriginalMapping getPreviousMapping(int lineNumber) { do { if (lineNumber == 0) { return null; } lineNumber--; } while (lines.get(lineNumber) == null); ArrayList<Entry> entries = lines.get(lineNumber); return getOriginalMappingForEntry(Iterables.getLast(entries)); }
java
private OriginalMapping getPreviousMapping(int lineNumber) { do { if (lineNumber == 0) { return null; } lineNumber--; } while (lines.get(lineNumber) == null); ArrayList<Entry> entries = lines.get(lineNumber); return getOriginalMappingForEntry(Iterables.getLast(entries)); }
[ "private", "OriginalMapping", "getPreviousMapping", "(", "int", "lineNumber", ")", "{", "do", "{", "if", "(", "lineNumber", "==", "0", ")", "{", "return", "null", ";", "}", "lineNumber", "--", ";", "}", "while", "(", "lines", ".", "get", "(", "lineNumber...
Returns the mapping entry that proceeds the supplied line or null if no such entry exists.
[ "Returns", "the", "mapping", "entry", "that", "proceeds", "the", "supplied", "line", "or", "null", "if", "no", "such", "entry", "exists", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapConsumerV3.java#L429-L438
24,213
google/closure-compiler
src/com/google/debugging/sourcemap/SourceMapConsumerV3.java
SourceMapConsumerV3.getOriginalMappingForEntry
private OriginalMapping getOriginalMappingForEntry(Entry entry) { if (entry.getSourceFileId() == UNMAPPED) { return null; } else { // Adjust the line/column here to be start at 1. Builder x = OriginalMapping.newBuilder() .setOriginalFile(sources[entry.getSourceFileId()]) .setLi...
java
private OriginalMapping getOriginalMappingForEntry(Entry entry) { if (entry.getSourceFileId() == UNMAPPED) { return null; } else { // Adjust the line/column here to be start at 1. Builder x = OriginalMapping.newBuilder() .setOriginalFile(sources[entry.getSourceFileId()]) .setLi...
[ "private", "OriginalMapping", "getOriginalMappingForEntry", "(", "Entry", "entry", ")", "{", "if", "(", "entry", ".", "getSourceFileId", "(", ")", "==", "UNMAPPED", ")", "{", "return", "null", ";", "}", "else", "{", "// Adjust the line/column here to be start at 1."...
Creates an "OriginalMapping" object for the given entry object.
[ "Creates", "an", "OriginalMapping", "object", "for", "the", "given", "entry", "object", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapConsumerV3.java#L443-L457
24,214
google/closure-compiler
src/com/google/debugging/sourcemap/SourceMapConsumerV3.java
SourceMapConsumerV3.createReverseMapping
private void createReverseMapping() { reverseSourceMapping = new HashMap<>(); for (int targetLine = 0; targetLine < lines.size(); targetLine++) { ArrayList<Entry> entries = lines.get(targetLine); if (entries != null) { for (Entry entry : entries) { if (entry.getSourceFileId() != ...
java
private void createReverseMapping() { reverseSourceMapping = new HashMap<>(); for (int targetLine = 0; targetLine < lines.size(); targetLine++) { ArrayList<Entry> entries = lines.get(targetLine); if (entries != null) { for (Entry entry : entries) { if (entry.getSourceFileId() != ...
[ "private", "void", "createReverseMapping", "(", ")", "{", "reverseSourceMapping", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "int", "targetLine", "=", "0", ";", "targetLine", "<", "lines", ".", "size", "(", ")", ";", "targetLine", "++", ")",...
Reverse the source map; the created mapping will allow us to quickly go from a source file and line number to a collection of target OriginalMappings.
[ "Reverse", "the", "source", "map", ";", "the", "created", "mapping", "will", "allow", "us", "to", "quickly", "go", "from", "a", "source", "file", "and", "line", "number", "to", "a", "collection", "of", "target", "OriginalMappings", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapConsumerV3.java#L464-L502
24,215
google/closure-compiler
src/com/google/javascript/jscomp/RewriteJsonToModule.java
RewriteJsonToModule.visitScript
private void visitScript(NodeTraversal t, Node n) { if (!n.hasOneChild() || !n.getFirstChild().isExprResult()) { compiler.report(JSError.make(n, JSON_UNEXPECTED_TOKEN)); return; } Node jsonObject = n.getFirstFirstChild().detach(); n.removeFirstChild(); String moduleName = t.getInput()....
java
private void visitScript(NodeTraversal t, Node n) { if (!n.hasOneChild() || !n.getFirstChild().isExprResult()) { compiler.report(JSError.make(n, JSON_UNEXPECTED_TOKEN)); return; } Node jsonObject = n.getFirstFirstChild().detach(); n.removeFirstChild(); String moduleName = t.getInput()....
[ "private", "void", "visitScript", "(", "NodeTraversal", "t", ",", "Node", "n", ")", "{", "if", "(", "!", "n", ".", "hasOneChild", "(", ")", "||", "!", "n", ".", "getFirstChild", "(", ")", ".", "isExprResult", "(", ")", ")", "{", "compiler", ".", "r...
For script nodes of JSON objects, add a module variable assignment so the result is exported. <p>If the file path ends with "/package.json", look for main entries in their specified order in the object literal and track them as module aliases. Main entries default to "main" and can be overridden with the `--package_js...
[ "For", "script", "nodes", "of", "JSON", "objects", "add", "a", "module", "variable", "assignment", "so", "the", "result", "is", "exported", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RewriteJsonToModule.java#L120-L166
24,216
google/closure-compiler
src/com/google/javascript/jscomp/Es6RewriteScriptsToModules.java
Es6RewriteScriptsToModules.forceToEs6Module
void forceToEs6Module(Node root) { if (Es6RewriteModules.isEs6ModuleRoot(root)) { return; } Node moduleNode = new Node(Token.MODULE_BODY).srcref(root); moduleNode.addChildrenToBack(root.removeChildren()); root.addChildToBack(moduleNode); compiler.reportChangeToChangeScope(root); }
java
void forceToEs6Module(Node root) { if (Es6RewriteModules.isEs6ModuleRoot(root)) { return; } Node moduleNode = new Node(Token.MODULE_BODY).srcref(root); moduleNode.addChildrenToBack(root.removeChildren()); root.addChildToBack(moduleNode); compiler.reportChangeToChangeScope(root); }
[ "void", "forceToEs6Module", "(", "Node", "root", ")", "{", "if", "(", "Es6RewriteModules", ".", "isEs6ModuleRoot", "(", "root", ")", ")", "{", "return", ";", "}", "Node", "moduleNode", "=", "new", "Node", "(", "Token", ".", "MODULE_BODY", ")", ".", "srcr...
Force rewriting of a script into an ES6 module, such as for imported files that contain no "import" or "export" statements.
[ "Force", "rewriting", "of", "a", "script", "into", "an", "ES6", "module", "such", "as", "for", "imported", "files", "that", "contain", "no", "import", "or", "export", "statements", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteScriptsToModules.java#L41-L49
24,217
google/closure-compiler
src/com/google/javascript/jscomp/ReplacedStringsDecoder.java
ReplacedStringsDecoder.decode
public String decode(String encodedStr) { String[] suppliedBits = encodedStr.split(ARGUMENT_PLACE_HOLDER, -1); String originalStr = originalToNewNameMap.get(suppliedBits[0]); if (originalStr == null) { return encodedStr; // Failed to decode. } String[] originalBits = originalStr.split(ARGUMENT...
java
public String decode(String encodedStr) { String[] suppliedBits = encodedStr.split(ARGUMENT_PLACE_HOLDER, -1); String originalStr = originalToNewNameMap.get(suppliedBits[0]); if (originalStr == null) { return encodedStr; // Failed to decode. } String[] originalBits = originalStr.split(ARGUMENT...
[ "public", "String", "decode", "(", "String", "encodedStr", ")", "{", "String", "[", "]", "suppliedBits", "=", "encodedStr", ".", "split", "(", "ARGUMENT_PLACE_HOLDER", ",", "-", "1", ")", ";", "String", "originalStr", "=", "originalToNewNameMap", ".", "get", ...
Decodes an encoded string from the JS Compiler ReplaceStrings pass. <p>An original string with args might look like this: <pre> Error('Some ' + arg1 + ' error ' + arg2 + ' message.');</pre> Which gets replaced with: <pre> Error('key' + '`' + arg1 + '`' + arg2);</pre> Where ` is the argument place holder. The replace...
[ "Decodes", "an", "encoded", "string", "from", "the", "JS", "Compiler", "ReplaceStrings", "pass", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ReplacedStringsDecoder.java#L63-L78
24,218
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
PeepholeSubstituteAlternateSyntax.optimizeSubtree
@Override @SuppressWarnings("fallthrough") public Node optimizeSubtree(Node node) { switch (node.getToken()) { case ASSIGN_SUB: return reduceSubstractionAssignment(node); case TRUE: case FALSE: return reduceTrueFalse(node); case NEW: node = tryFoldStandardConstr...
java
@Override @SuppressWarnings("fallthrough") public Node optimizeSubtree(Node node) { switch (node.getToken()) { case ASSIGN_SUB: return reduceSubstractionAssignment(node); case TRUE: case FALSE: return reduceTrueFalse(node); case NEW: node = tryFoldStandardConstr...
[ "@", "Override", "@", "SuppressWarnings", "(", "\"fallthrough\"", ")", "public", "Node", "optimizeSubtree", "(", "Node", "node", ")", "{", "switch", "(", "node", ".", "getToken", "(", ")", ")", "{", "case", "ASSIGN_SUB", ":", "return", "reduceSubstractionAssig...
Tries apply our various peephole minimizations on the passed in node.
[ "Tries", "apply", "our", "various", "peephole", "minimizations", "on", "the", "passed", "in", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java#L66-L124
24,219
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
PeepholeSubstituteAlternateSyntax.tryReplaceUndefined
private Node tryReplaceUndefined(Node n) { // TODO(johnlenz): consider doing this as a normalization. if (isASTNormalized() && NodeUtil.isUndefined(n) && !NodeUtil.isLValue(n)) { Node replacement = NodeUtil.newUndefinedNode(n); n.replaceWith(replacement); reportChangeToEnclosin...
java
private Node tryReplaceUndefined(Node n) { // TODO(johnlenz): consider doing this as a normalization. if (isASTNormalized() && NodeUtil.isUndefined(n) && !NodeUtil.isLValue(n)) { Node replacement = NodeUtil.newUndefinedNode(n); n.replaceWith(replacement); reportChangeToEnclosin...
[ "private", "Node", "tryReplaceUndefined", "(", "Node", "n", ")", "{", "// TODO(johnlenz): consider doing this as a normalization.", "if", "(", "isASTNormalized", "(", ")", "&&", "NodeUtil", ".", "isUndefined", "(", "n", ")", "&&", "!", "NodeUtil", ".", "isLValue", ...
Use "void 0" in place of "undefined"
[ "Use", "void", "0", "in", "place", "of", "undefined" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java#L333-L344
24,220
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
PeepholeSubstituteAlternateSyntax.tryReduceReturn
private Node tryReduceReturn(Node n) { Node result = n.getFirstChild(); if (result != null) { switch (result.getToken()) { case VOID: Node operand = result.getFirstChild(); if (!mayHaveSideEffects(operand)) { n.removeFirstChild(); reportChangeToEnclosin...
java
private Node tryReduceReturn(Node n) { Node result = n.getFirstChild(); if (result != null) { switch (result.getToken()) { case VOID: Node operand = result.getFirstChild(); if (!mayHaveSideEffects(operand)) { n.removeFirstChild(); reportChangeToEnclosin...
[ "private", "Node", "tryReduceReturn", "(", "Node", "n", ")", "{", "Node", "result", "=", "n", ".", "getFirstChild", "(", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "switch", "(", "result", ".", "getToken", "(", ")", ")", "{", "case", "V...
Reduce "return undefined" or "return void 0" to simply "return". @return The original node, maybe simplified.
[ "Reduce", "return", "undefined", "or", "return", "void", "0", "to", "simply", "return", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java#L351-L376
24,221
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
PeepholeSubstituteAlternateSyntax.tryFoldLiteralConstructor
private Node tryFoldLiteralConstructor(Node n) { checkArgument(n.isCall() || n.isNew()); Node constructorNameNode = n.getFirstChild(); Node newLiteralNode = null; // We require the AST to be normalized to ensure that, say, // Object() really refers to the built-in Object constructor // and no...
java
private Node tryFoldLiteralConstructor(Node n) { checkArgument(n.isCall() || n.isNew()); Node constructorNameNode = n.getFirstChild(); Node newLiteralNode = null; // We require the AST to be normalized to ensure that, say, // Object() really refers to the built-in Object constructor // and no...
[ "private", "Node", "tryFoldLiteralConstructor", "(", "Node", "n", ")", "{", "checkArgument", "(", "n", ".", "isCall", "(", ")", "||", "n", ".", "isNew", "(", ")", ")", ";", "Node", "constructorNameNode", "=", "n", ".", "getFirstChild", "(", ")", ";", "...
Replaces a new Array, Object, or RegExp node with a literal, unless the call is to a local constructor function with the same name.
[ "Replaces", "a", "new", "Array", "Object", "or", "RegExp", "node", "with", "a", "literal", "unless", "the", "call", "is", "to", "a", "local", "constructor", "function", "with", "the", "same", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java#L431-L479
24,222
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
PeepholeSubstituteAlternateSyntax.pickDelimiter
private static String pickDelimiter(String[] strings) { boolean allLength1 = true; for (String s : strings) { if (s.length() != 1) { allLength1 = false; break; } } if (allLength1) { return ""; } String[] delimiters = new String[]{" ", ";", ",", "{", "}", null}...
java
private static String pickDelimiter(String[] strings) { boolean allLength1 = true; for (String s : strings) { if (s.length() != 1) { allLength1 = false; break; } } if (allLength1) { return ""; } String[] delimiters = new String[]{" ", ";", ",", "{", "}", null}...
[ "private", "static", "String", "pickDelimiter", "(", "String", "[", "]", "strings", ")", "{", "boolean", "allLength1", "=", "true", ";", "for", "(", "String", "s", ":", "strings", ")", "{", "if", "(", "s", ".", "length", "(", ")", "!=", "1", ")", "...
Find a delimiter that does not occur in the given strings @param strings The strings that must be separated. @return a delimiter string or null
[ "Find", "a", "delimiter", "that", "does", "not", "occur", "in", "the", "given", "strings" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java#L687-L711
24,223
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
PeepholeSubstituteAlternateSyntax.containsUnicodeEscape
static boolean containsUnicodeEscape(String s) { String esc = REGEXP_ESCAPER.regexpEscape(s); for (int i = -1; (i = esc.indexOf("\\u", i + 1)) >= 0;) { int nSlashes = 0; while (i - nSlashes > 0 && '\\' == esc.charAt(i - nSlashes - 1)) { ++nSlashes; } // if there are an even numbe...
java
static boolean containsUnicodeEscape(String s) { String esc = REGEXP_ESCAPER.regexpEscape(s); for (int i = -1; (i = esc.indexOf("\\u", i + 1)) >= 0;) { int nSlashes = 0; while (i - nSlashes > 0 && '\\' == esc.charAt(i - nSlashes - 1)) { ++nSlashes; } // if there are an even numbe...
[ "static", "boolean", "containsUnicodeEscape", "(", "String", "s", ")", "{", "String", "esc", "=", "REGEXP_ESCAPER", ".", "regexpEscape", "(", "s", ")", ";", "for", "(", "int", "i", "=", "-", "1", ";", "(", "i", "=", "esc", ".", "indexOf", "(", "\"\\\...
true if the JavaScript string would contain a Unicode escape when written out as the body of a regular expression literal.
[ "true", "if", "the", "JavaScript", "string", "would", "contain", "a", "Unicode", "escape", "when", "written", "out", "as", "the", "body", "of", "a", "regular", "expression", "literal", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java#L821-L833
24,224
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getArrayElementStringValue
static String getArrayElementStringValue(Node n) { return (NodeUtil.isNullOrUndefined(n) || n.isEmpty()) ? "" : getStringValue(n); }
java
static String getArrayElementStringValue(Node n) { return (NodeUtil.isNullOrUndefined(n) || n.isEmpty()) ? "" : getStringValue(n); }
[ "static", "String", "getArrayElementStringValue", "(", "Node", "n", ")", "{", "return", "(", "NodeUtil", ".", "isNullOrUndefined", "(", "n", ")", "||", "n", ".", "isEmpty", "(", ")", ")", "?", "\"\"", ":", "getStringValue", "(", "n", ")", ";", "}" ]
When converting arrays to string using Array.prototype.toString or Array.prototype.join, the rules for conversion to String are different than converting each element individually. Specifically, "null" and "undefined" are converted to an empty string. @param n A node that is a member of an Array. @return The string re...
[ "When", "converting", "arrays", "to", "string", "using", "Array", ".", "prototype", ".", "toString", "or", "Array", ".", "prototype", ".", "join", "the", "rules", "for", "conversion", "to", "String", "are", "different", "than", "converting", "each", "element",...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L283-L286
24,225
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isImmutableValue
static boolean isImmutableValue(Node n) { // TODO(johnlenz): rename this function. It is currently being used // in two disjoint cases: // 1) We only care about the result of the expression // (in which case NOT here should return true) // 2) We care that expression is a side-effect free and can...
java
static boolean isImmutableValue(Node n) { // TODO(johnlenz): rename this function. It is currently being used // in two disjoint cases: // 1) We only care about the result of the expression // (in which case NOT here should return true) // 2) We care that expression is a side-effect free and can...
[ "static", "boolean", "isImmutableValue", "(", "Node", "n", ")", "{", "// TODO(johnlenz): rename this function. It is currently being used", "// in two disjoint cases:", "// 1) We only care about the result of the expression", "// (in which case NOT here should return true)", "// 2) We ca...
Returns true if this is an immutable value.
[ "Returns", "true", "if", "this", "is", "an", "immutable", "value", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L568-L611
24,226
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isSymmetricOperation
static boolean isSymmetricOperation(Node n) { switch (n.getToken()) { case EQ: // equal case NE: // not equal case SHEQ: // exactly equal case SHNE: // exactly not equal case MUL: // multiply, unlike add it only works on numbers // or results NaN if any of the operators is not ...
java
static boolean isSymmetricOperation(Node n) { switch (n.getToken()) { case EQ: // equal case NE: // not equal case SHEQ: // exactly equal case SHNE: // exactly not equal case MUL: // multiply, unlike add it only works on numbers // or results NaN if any of the operators is not ...
[ "static", "boolean", "isSymmetricOperation", "(", "Node", "n", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "EQ", ":", "// equal", "case", "NE", ":", "// not equal", "case", "SHEQ", ":", "// exactly equal", "case", "SHNE", "...
Returns true if the operator on this node is symmetric
[ "Returns", "true", "if", "the", "operator", "on", "this", "node", "is", "symmetric" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L616-L629
24,227
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isRelationalOperation
static boolean isRelationalOperation(Node n) { switch (n.getToken()) { case GT: // equal case GE: // not equal case LT: // exactly equal case LE: // exactly not equal return true; default: break; } return false; }
java
static boolean isRelationalOperation(Node n) { switch (n.getToken()) { case GT: // equal case GE: // not equal case LT: // exactly equal case LE: // exactly not equal return true; default: break; } return false; }
[ "static", "boolean", "isRelationalOperation", "(", "Node", "n", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "GT", ":", "// equal", "case", "GE", ":", "// not equal", "case", "LT", ":", "// exactly equal", "case", "LE", ":",...
Returns true if the operator on this node is relational. the returned set does not include the equalities.
[ "Returns", "true", "if", "the", "operator", "on", "this", "node", "is", "relational", ".", "the", "returned", "set", "does", "not", "include", "the", "equalities", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L635-L646
24,228
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isSomeCompileTimeConstStringValue
static boolean isSomeCompileTimeConstStringValue(Node node) { // TODO(bangert): Support constants, using a Scope argument. See ConstParamCheck if (node.isString() || (node.isTemplateLit() && node.hasOneChild())) { return true; } else if (node.isAdd()) { checkState(node.hasTwoChildren(), node); ...
java
static boolean isSomeCompileTimeConstStringValue(Node node) { // TODO(bangert): Support constants, using a Scope argument. See ConstParamCheck if (node.isString() || (node.isTemplateLit() && node.hasOneChild())) { return true; } else if (node.isAdd()) { checkState(node.hasTwoChildren(), node); ...
[ "static", "boolean", "isSomeCompileTimeConstStringValue", "(", "Node", "node", ")", "{", "// TODO(bangert): Support constants, using a Scope argument. See ConstParamCheck", "if", "(", "node", ".", "isString", "(", ")", "||", "(", "node", ".", "isTemplateLit", "(", ")", ...
Returns true iff the value associated with the node is a JS string literal, a concatenation thereof or a ternary operator choosing between string literals.
[ "Returns", "true", "iff", "the", "value", "associated", "with", "the", "node", "is", "a", "JS", "string", "literal", "a", "concatenation", "thereof", "or", "a", "ternary", "operator", "choosing", "between", "string", "literals", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L779-L795
24,229
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isEmptyBlock
static boolean isEmptyBlock(Node block) { if (!block.isBlock()) { return false; } for (Node n = block.getFirstChild(); n != null; n = n.getNext()) { if (!n.isEmpty()) { return false; } } return true; }
java
static boolean isEmptyBlock(Node block) { if (!block.isBlock()) { return false; } for (Node n = block.getFirstChild(); n != null; n = n.getNext()) { if (!n.isEmpty()) { return false; } } return true; }
[ "static", "boolean", "isEmptyBlock", "(", "Node", "block", ")", "{", "if", "(", "!", "block", ".", "isBlock", "(", ")", ")", "{", "return", "false", ";", "}", "for", "(", "Node", "n", "=", "block", ".", "getFirstChild", "(", ")", ";", "n", "!=", ...
Returns whether this a BLOCK node with no children. @param block The node.
[ "Returns", "whether", "this", "a", "BLOCK", "node", "with", "no", "children", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L802-L813
24,230
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isBinaryOperatorType
static boolean isBinaryOperatorType(Token type) { switch (type) { case OR: case AND: case BITOR: case BITXOR: case BITAND: case EQ: case NE: case SHEQ: case SHNE: case LT: case GT: case LE: case GE: case INSTANCEOF: case IN: ...
java
static boolean isBinaryOperatorType(Token type) { switch (type) { case OR: case AND: case BITOR: case BITXOR: case BITAND: case EQ: case NE: case SHEQ: case SHNE: case LT: case GT: case LE: case GE: case INSTANCEOF: case IN: ...
[ "static", "boolean", "isBinaryOperatorType", "(", "Token", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "OR", ":", "case", "AND", ":", "case", "BITOR", ":", "case", "BITXOR", ":", "case", "BITAND", ":", "case", "EQ", ":", "case", "NE", ...
An operator with two operands that does not assign a value to either. Once you cut through the layers of rules, these all parse similarly, taking LeftHandSideExpression operands on either side. Comma is not included, because it takes AssignmentExpression operands, making its syntax different.
[ "An", "operator", "with", "two", "operands", "that", "does", "not", "assign", "a", "value", "to", "either", ".", "Once", "you", "cut", "through", "the", "layers", "of", "rules", "these", "all", "parse", "similarly", "taking", "LeftHandSideExpression", "operand...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L826-L857
24,231
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isUnaryOperatorType
static boolean isUnaryOperatorType(Token type) { switch (type) { case DELPROP: case VOID: case TYPEOF: case POS: case NEG: case BITNOT: case NOT: return true; default: return false; } }
java
static boolean isUnaryOperatorType(Token type) { switch (type) { case DELPROP: case VOID: case TYPEOF: case POS: case NEG: case BITNOT: case NOT: return true; default: return false; } }
[ "static", "boolean", "isUnaryOperatorType", "(", "Token", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "DELPROP", ":", "case", "VOID", ":", "case", "TYPEOF", ":", "case", "POS", ":", "case", "NEG", ":", "case", "BITNOT", ":", "case", "NOT...
An operator taking only one operand. These all parse very similarly, taking LeftHandSideExpression operands.
[ "An", "operator", "taking", "only", "one", "operand", ".", "These", "all", "parse", "very", "similarly", "taking", "LeftHandSideExpression", "operands", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L867-L881
24,232
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isAliasedConstDefinition
static boolean isAliasedConstDefinition(Node lhs) { JSDocInfo jsdoc = getBestJSDocInfo(lhs); if (jsdoc == null && !lhs.isFromExterns()) { return false; } if (jsdoc != null && !jsdoc.hasConstAnnotation()) { return false; } Node rhs = getRValueOfLValue(lhs); if (rhs == null || !rhs...
java
static boolean isAliasedConstDefinition(Node lhs) { JSDocInfo jsdoc = getBestJSDocInfo(lhs); if (jsdoc == null && !lhs.isFromExterns()) { return false; } if (jsdoc != null && !jsdoc.hasConstAnnotation()) { return false; } Node rhs = getRValueOfLValue(lhs); if (rhs == null || !rhs...
[ "static", "boolean", "isAliasedConstDefinition", "(", "Node", "lhs", ")", "{", "JSDocInfo", "jsdoc", "=", "getBestJSDocInfo", "(", "lhs", ")", ";", "if", "(", "jsdoc", "==", "null", "&&", "!", "lhs", ".", "isFromExterns", "(", ")", ")", "{", "return", "f...
True for aliases defined with @const, not for aliases defined with @constructor/@interface.
[ "True", "for", "aliases", "defined", "with" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L950-L966
24,233
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isFromTypeSummary
public static boolean isFromTypeSummary(Node n) { checkArgument(n.isScript(), n); JSDocInfo info = n.getJSDocInfo(); return info != null && info.isTypeSummary(); }
java
public static boolean isFromTypeSummary(Node n) { checkArgument(n.isScript(), n); JSDocInfo info = n.getJSDocInfo(); return info != null && info.isTypeSummary(); }
[ "public", "static", "boolean", "isFromTypeSummary", "(", "Node", "n", ")", "{", "checkArgument", "(", "n", ".", "isScript", "(", ")", ",", "n", ")", ";", "JSDocInfo", "info", "=", "n", ".", "getJSDocInfo", "(", ")", ";", "return", "info", "!=", "null",...
Determine if the given SCRIPT is a @typeSummary file, like an i.js file
[ "Determine", "if", "the", "given", "SCRIPT", "is", "a" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L1045-L1049
24,234
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.mayEffectMutableState
static boolean mayEffectMutableState(Node n, AbstractCompiler compiler) { checkNotNull(compiler); return checkForStateChangeHelper(n, true, compiler); }
java
static boolean mayEffectMutableState(Node n, AbstractCompiler compiler) { checkNotNull(compiler); return checkForStateChangeHelper(n, true, compiler); }
[ "static", "boolean", "mayEffectMutableState", "(", "Node", "n", ",", "AbstractCompiler", "compiler", ")", "{", "checkNotNull", "(", "compiler", ")", ";", "return", "checkForStateChangeHelper", "(", "n", ",", "true", ",", "compiler", ")", ";", "}" ]
Returns true if the node may create new mutable state, or change existing state. @see <a href="http://www.xkcd.org/326/">XKCD Cartoon</a>
[ "Returns", "true", "if", "the", "node", "may", "create", "new", "mutable", "state", "or", "change", "existing", "state", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L1066-L1069
24,235
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.constructorCallHasSideEffects
static boolean constructorCallHasSideEffects(Node callNode) { checkArgument(callNode.isNew(), "Expected NEW node, got %s", callNode.getToken()); if (callNode.isNoSideEffectsCall()) { return false; } if (callNode.isOnlyModifiesArgumentsCall() && allArgsUnescapedLocal(callNode)) { return fal...
java
static boolean constructorCallHasSideEffects(Node callNode) { checkArgument(callNode.isNew(), "Expected NEW node, got %s", callNode.getToken()); if (callNode.isNoSideEffectsCall()) { return false; } if (callNode.isOnlyModifiesArgumentsCall() && allArgsUnescapedLocal(callNode)) { return fal...
[ "static", "boolean", "constructorCallHasSideEffects", "(", "Node", "callNode", ")", "{", "checkArgument", "(", "callNode", ".", "isNew", "(", ")", ",", "\"Expected NEW node, got %s\"", ",", "callNode", ".", "getToken", "(", ")", ")", ";", "if", "(", "callNode", ...
Do calls to this constructor have side effects? @param callNode - constructor call node
[ "Do", "calls", "to", "this", "constructor", "have", "side", "effects?" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L1357-L1370
24,236
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.nodeTypeMayHaveSideEffects
static boolean nodeTypeMayHaveSideEffects(Node n, AbstractCompiler compiler) { if (isAssignmentOp(n)) { return true; } switch (n.getToken()) { case DELPROP: case DEC: case INC: case YIELD: case THROW: case AWAIT: case FOR_IN: // assigns to a loop LHS ca...
java
static boolean nodeTypeMayHaveSideEffects(Node n, AbstractCompiler compiler) { if (isAssignmentOp(n)) { return true; } switch (n.getToken()) { case DELPROP: case DEC: case INC: case YIELD: case THROW: case AWAIT: case FOR_IN: // assigns to a loop LHS ca...
[ "static", "boolean", "nodeTypeMayHaveSideEffects", "(", "Node", "n", ",", "AbstractCompiler", "compiler", ")", "{", "if", "(", "isAssignmentOp", "(", "n", ")", ")", "{", "return", "true", ";", "}", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{",...
Returns true if the current node's type implies side effects. <p>This is a non-recursive version of the may have side effects check; used to check wherever the current node's type is one of the reasons why a subtree has side effects.
[ "Returns", "true", "if", "the", "current", "node", "s", "type", "implies", "side", "effects", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L1549-L1582
24,237
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.mayBeString
static boolean mayBeString(Node n, boolean useType) { if (useType) { JSType type = n.getJSType(); if (type != null) { if (type.isStringValueType()) { return true; } else if (type.isNumberValueType() || type.isBooleanValueType() || type.isNullType() || type.isVoidTyp...
java
static boolean mayBeString(Node n, boolean useType) { if (useType) { JSType type = n.getJSType(); if (type != null) { if (type.isStringValueType()) { return true; } else if (type.isNumberValueType() || type.isBooleanValueType() || type.isNullType() || type.isVoidTyp...
[ "static", "boolean", "mayBeString", "(", "Node", "n", ",", "boolean", "useType", ")", "{", "if", "(", "useType", ")", "{", "JSType", "type", "=", "n", ".", "getJSType", "(", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "if", "(", "type", ...
Return if the node is possibly a string. @param n The node. @param useType If true and the node has a primitive type, return true if that type is string and false otherwise. @return Whether the results is possibly a string.
[ "Return", "if", "the", "node", "is", "possibly", "a", "string", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2019-L2032
24,238
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getEnclosingType
public static Node getEnclosingType(Node n, final Token type) { return getEnclosingNode( n, new Predicate<Node>() { @Override public boolean apply(Node n) { return n.getToken() == type; } }); }
java
public static Node getEnclosingType(Node n, final Token type) { return getEnclosingNode( n, new Predicate<Node>() { @Override public boolean apply(Node n) { return n.getToken() == type; } }); }
[ "public", "static", "Node", "getEnclosingType", "(", "Node", "n", ",", "final", "Token", "type", ")", "{", "return", "getEnclosingNode", "(", "n", ",", "new", "Predicate", "<", "Node", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(...
Gets the closest ancestor to the given node of the provided type.
[ "Gets", "the", "closest", "ancestor", "to", "the", "given", "node", "of", "the", "provided", "type", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2230-L2239
24,239
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.referencesThis
static boolean referencesThis(Node n) { if (n.isFunction()) { return referencesThis(NodeUtil.getFunctionParameters(n)) || referencesThis(NodeUtil.getFunctionBody(n)); } else { return has(n, Node::isThis, MATCH_ANYTHING_BUT_NON_ARROW_FUNCTION); } }
java
static boolean referencesThis(Node n) { if (n.isFunction()) { return referencesThis(NodeUtil.getFunctionParameters(n)) || referencesThis(NodeUtil.getFunctionBody(n)); } else { return has(n, Node::isThis, MATCH_ANYTHING_BUT_NON_ARROW_FUNCTION); } }
[ "static", "boolean", "referencesThis", "(", "Node", "n", ")", "{", "if", "(", "n", ".", "isFunction", "(", ")", ")", "{", "return", "referencesThis", "(", "NodeUtil", ".", "getFunctionParameters", "(", "n", ")", ")", "||", "referencesThis", "(", "NodeUtil"...
Returns true if the shallow scope contains references to 'this' keyword
[ "Returns", "true", "if", "the", "shallow", "scope", "contains", "references", "to", "this", "keyword" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2344-L2351
24,240
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.referencesSuper
static boolean referencesSuper(Node n) { Node curr = n.getFirstChild(); while (curr != null) { if (containsType(curr, Token.SUPER, node -> !node.isClass())) { return true; } curr = curr.getNext(); } return false; }
java
static boolean referencesSuper(Node n) { Node curr = n.getFirstChild(); while (curr != null) { if (containsType(curr, Token.SUPER, node -> !node.isClass())) { return true; } curr = curr.getNext(); } return false; }
[ "static", "boolean", "referencesSuper", "(", "Node", "n", ")", "{", "Node", "curr", "=", "n", ".", "getFirstChild", "(", ")", ";", "while", "(", "curr", "!=", "null", ")", "{", "if", "(", "containsType", "(", "curr", ",", "Token", ".", "SUPER", ",", ...
Returns true if the current scope contains references to the 'super' keyword. Note that if there are classes declared inside the current class, super calls which reference those classes are not reported.
[ "Returns", "true", "if", "the", "current", "scope", "contains", "references", "to", "the", "super", "keyword", ".", "Note", "that", "if", "there", "are", "classes", "declared", "inside", "the", "current", "class", "super", "calls", "which", "reference", "those...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2358-L2367
24,241
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isBlockScopedDeclaration
static boolean isBlockScopedDeclaration(Node n) { if (n.isName()) { switch (n.getParent().getToken()) { case LET: case CONST: case CATCH: return true; case CLASS: return n.getParent().getFirstChild() == n; case FUNCTION: return isBlockScope...
java
static boolean isBlockScopedDeclaration(Node n) { if (n.isName()) { switch (n.getParent().getToken()) { case LET: case CONST: case CATCH: return true; case CLASS: return n.getParent().getFirstChild() == n; case FUNCTION: return isBlockScope...
[ "static", "boolean", "isBlockScopedDeclaration", "(", "Node", "n", ")", "{", "if", "(", "n", ".", "isName", "(", ")", ")", "{", "switch", "(", "n", ".", "getParent", "(", ")", ".", "getToken", "(", ")", ")", "{", "case", "LET", ":", "case", "CONST"...
Is this node the name of a block-scoped declaration? Checks for let, const, class, or block-scoped function declarations. @param n The node @return True if {@code n} is the NAME of a block-scoped declaration.
[ "Is", "this", "node", "the", "name", "of", "a", "block", "-", "scoped", "declaration?", "Checks", "for", "let", "const", "class", "or", "block", "-", "scoped", "function", "declarations", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2384-L2400
24,242
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isNameDeclaration
public static boolean isNameDeclaration(Node n) { return n != null && (n.isVar() || n.isLet() || n.isConst()); }
java
public static boolean isNameDeclaration(Node n) { return n != null && (n.isVar() || n.isLet() || n.isConst()); }
[ "public", "static", "boolean", "isNameDeclaration", "(", "Node", "n", ")", "{", "return", "n", "!=", "null", "&&", "(", "n", ".", "isVar", "(", ")", "||", "n", ".", "isLet", "(", ")", "||", "n", ".", "isConst", "(", ")", ")", ";", "}" ]
Is this node a name declaration? @param n The node @return True if {@code n} is VAR, LET or CONST
[ "Is", "this", "node", "a", "name", "declaration?" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2408-L2410
24,243
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getAssignedValue
public static Node getAssignedValue(Node n) { checkState(n.isName() || n.isGetProp(), n); Node parent = n.getParent(); if (NodeUtil.isNameDeclaration(parent)) { return n.getFirstChild(); } else if (parent.isAssign() && parent.getFirstChild() == n) { return n.getNext(); } else { ret...
java
public static Node getAssignedValue(Node n) { checkState(n.isName() || n.isGetProp(), n); Node parent = n.getParent(); if (NodeUtil.isNameDeclaration(parent)) { return n.getFirstChild(); } else if (parent.isAssign() && parent.getFirstChild() == n) { return n.getNext(); } else { ret...
[ "public", "static", "Node", "getAssignedValue", "(", "Node", "n", ")", "{", "checkState", "(", "n", ".", "isName", "(", ")", "||", "n", ".", "isGetProp", "(", ")", ",", "n", ")", ";", "Node", "parent", "=", "n", ".", "getParent", "(", ")", ";", "...
For an assignment or variable declaration get the assigned value. @return The value node representing the new value.
[ "For", "an", "assignment", "or", "variable", "declaration", "get", "the", "assigned", "value", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2432-L2442
24,244
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isLoopStructure
static boolean isLoopStructure(Node n) { switch (n.getToken()) { case FOR: case FOR_IN: case FOR_OF: case FOR_AWAIT_OF: case DO: case WHILE: return true; default: return false; } }
java
static boolean isLoopStructure(Node n) { switch (n.getToken()) { case FOR: case FOR_IN: case FOR_OF: case FOR_AWAIT_OF: case DO: case WHILE: return true; default: return false; } }
[ "static", "boolean", "isLoopStructure", "(", "Node", "n", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "FOR", ":", "case", "FOR_IN", ":", "case", "FOR_OF", ":", "case", "FOR_AWAIT_OF", ":", "case", "DO", ":", "case", "WH...
Determines whether the given node is a FOR, DO, or WHILE node.
[ "Determines", "whether", "the", "given", "node", "is", "a", "FOR", "DO", "or", "WHILE", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2483-L2495
24,245
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isControlStructure
public static boolean isControlStructure(Node n) { switch (n.getToken()) { case FOR: case FOR_IN: case FOR_OF: case FOR_AWAIT_OF: case DO: case WHILE: case WITH: case IF: case LABEL: case TRY: case CATCH: case SWITCH: case CASE: cas...
java
public static boolean isControlStructure(Node n) { switch (n.getToken()) { case FOR: case FOR_IN: case FOR_OF: case FOR_AWAIT_OF: case DO: case WHILE: case WITH: case IF: case LABEL: case TRY: case CATCH: case SWITCH: case CASE: cas...
[ "public", "static", "boolean", "isControlStructure", "(", "Node", "n", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "FOR", ":", "case", "FOR_IN", ":", "case", "FOR_OF", ":", "case", "FOR_AWAIT_OF", ":", "case", "DO", ":", ...
Determines whether the given node is a FOR, DO, WHILE, WITH, or IF node.
[ "Determines", "whether", "the", "given", "node", "is", "a", "FOR", "DO", "WHILE", "WITH", "or", "IF", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2537-L2557
24,246
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isControlStructureCodeBlock
static boolean isControlStructureCodeBlock(Node parent, Node n) { switch (parent.getToken()) { case DO: return parent.getFirstChild() == n; case TRY: return parent.getFirstChild() == n || parent.getLastChild() == n; case FOR: case FOR_IN: case FOR_OF: case FOR_AWA...
java
static boolean isControlStructureCodeBlock(Node parent, Node n) { switch (parent.getToken()) { case DO: return parent.getFirstChild() == n; case TRY: return parent.getFirstChild() == n || parent.getLastChild() == n; case FOR: case FOR_IN: case FOR_OF: case FOR_AWA...
[ "static", "boolean", "isControlStructureCodeBlock", "(", "Node", "parent", ",", "Node", "n", ")", "{", "switch", "(", "parent", ".", "getToken", "(", ")", ")", "{", "case", "DO", ":", "return", "parent", ".", "getFirstChild", "(", ")", "==", "n", ";", ...
Determines whether the given node is code node for FOR, DO, WHILE, WITH, or IF node.
[ "Determines", "whether", "the", "given", "node", "is", "code", "node", "for", "FOR", "DO", "WHILE", "WITH", "or", "IF", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2563-L2588
24,247
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.createsBlockScope
static boolean createsBlockScope(Node n) { switch (n.getToken()) { case BLOCK: Node parent = n.getParent(); // Don't create block scope for switch cases or catch blocks. return parent != null && !isSwitchCase(parent) && !parent.isCatch(); case FOR: case FOR_IN: case F...
java
static boolean createsBlockScope(Node n) { switch (n.getToken()) { case BLOCK: Node parent = n.getParent(); // Don't create block scope for switch cases or catch blocks. return parent != null && !isSwitchCase(parent) && !parent.isCatch(); case FOR: case FOR_IN: case F...
[ "static", "boolean", "createsBlockScope", "(", "Node", "n", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "BLOCK", ":", "Node", "parent", "=", "n", ".", "getParent", "(", ")", ";", "// Don't create block scope for switch cases or...
A block scope is created by a non-synthetic block node, a for loop node, or a for-of loop node. <p>Note: for functions, we use two separate scopes for parameters and declarations in the body. We need to make sure default parameters cannot reference var / function declarations in the body. @return Whether the node cre...
[ "A", "block", "scope", "is", "created", "by", "a", "non", "-", "synthetic", "block", "node", "a", "for", "loop", "node", "or", "a", "for", "-", "of", "loop", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2632-L2648
24,248
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isTryFinallyNode
static boolean isTryFinallyNode(Node parent, Node child) { return parent.isTry() && parent.hasXChildren(3) && child == parent.getLastChild(); }
java
static boolean isTryFinallyNode(Node parent, Node child) { return parent.isTry() && parent.hasXChildren(3) && child == parent.getLastChild(); }
[ "static", "boolean", "isTryFinallyNode", "(", "Node", "parent", ",", "Node", "child", ")", "{", "return", "parent", ".", "isTry", "(", ")", "&&", "parent", ".", "hasXChildren", "(", "3", ")", "&&", "child", "==", "parent", ".", "getLastChild", "(", ")", ...
Whether the child node is the FINALLY block of a try.
[ "Whether", "the", "child", "node", "is", "the", "FINALLY", "block", "of", "a", "try", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2725-L2728
24,249
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isTryCatchNodeContainer
static boolean isTryCatchNodeContainer(Node n) { Node parent = n.getParent(); return parent.isTry() && parent.getSecondChild() == n; }
java
static boolean isTryCatchNodeContainer(Node n) { Node parent = n.getParent(); return parent.isTry() && parent.getSecondChild() == n; }
[ "static", "boolean", "isTryCatchNodeContainer", "(", "Node", "n", ")", "{", "Node", "parent", "=", "n", ".", "getParent", "(", ")", ";", "return", "parent", ".", "isTry", "(", ")", "&&", "parent", ".", "getSecondChild", "(", ")", "==", "n", ";", "}" ]
Whether the node is a CATCH container BLOCK.
[ "Whether", "the", "node", "is", "a", "CATCH", "container", "BLOCK", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2731-L2735
24,250
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.deleteChildren
public static void deleteChildren(Node n, AbstractCompiler compiler) { while (n.hasChildren()) { deleteNode(n.getFirstChild(), compiler); } }
java
public static void deleteChildren(Node n, AbstractCompiler compiler) { while (n.hasChildren()) { deleteNode(n.getFirstChild(), compiler); } }
[ "public", "static", "void", "deleteChildren", "(", "Node", "n", ",", "AbstractCompiler", "compiler", ")", "{", "while", "(", "n", ".", "hasChildren", "(", ")", ")", "{", "deleteNode", "(", "n", ".", "getFirstChild", "(", ")", ",", "compiler", ")", ";", ...
Permanently delete all the children of the given node, including reporting changes.
[ "Permanently", "delete", "all", "the", "children", "of", "the", "given", "node", "including", "reporting", "changes", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2779-L2783
24,251
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.removeChild
public static void removeChild(Node parent, Node node) { if (isTryFinallyNode(parent, node)) { if (NodeUtil.hasCatchHandler(getCatchBlock(parent))) { // A finally can only be removed if there is a catch. parent.removeChild(node); } else { // Otherwise, only its children can be re...
java
public static void removeChild(Node parent, Node node) { if (isTryFinallyNode(parent, node)) { if (NodeUtil.hasCatchHandler(getCatchBlock(parent))) { // A finally can only be removed if there is a catch. parent.removeChild(node); } else { // Otherwise, only its children can be re...
[ "public", "static", "void", "removeChild", "(", "Node", "parent", ",", "Node", "node", ")", "{", "if", "(", "isTryFinallyNode", "(", "parent", ",", "node", ")", ")", "{", "if", "(", "NodeUtil", ".", "hasCatchHandler", "(", "getCatchBlock", "(", "parent", ...
Safely remove children while maintaining a valid node structure. In some cases, this is done by removing the parent from the AST as well.
[ "Safely", "remove", "children", "while", "maintaining", "a", "valid", "node", "structure", ".", "In", "some", "cases", "this", "is", "done", "by", "removing", "the", "parent", "from", "the", "AST", "as", "well", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2789-L2870
24,252
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.maybeAddFinally
static void maybeAddFinally(Node tryNode) { checkState(tryNode.isTry()); if (!NodeUtil.hasFinally(tryNode)) { tryNode.addChildToBack(IR.block().srcref(tryNode)); } }
java
static void maybeAddFinally(Node tryNode) { checkState(tryNode.isTry()); if (!NodeUtil.hasFinally(tryNode)) { tryNode.addChildToBack(IR.block().srcref(tryNode)); } }
[ "static", "void", "maybeAddFinally", "(", "Node", "tryNode", ")", "{", "checkState", "(", "tryNode", ".", "isTry", "(", ")", ")", ";", "if", "(", "!", "NodeUtil", ".", "hasFinally", "(", "tryNode", ")", ")", "{", "tryNode", ".", "addChildToBack", "(", ...
Add a finally block if one does not exist.
[ "Add", "a", "finally", "block", "if", "one", "does", "not", "exist", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2909-L2914
24,253
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.tryMergeBlock
public static boolean tryMergeBlock(Node block, boolean alwaysMerge) { checkState(block.isBlock()); Node parent = block.getParent(); boolean canMerge = alwaysMerge || canMergeBlock(block); // Try to remove the block if its parent is a block/script or if its // parent is label and it has exactly one ...
java
public static boolean tryMergeBlock(Node block, boolean alwaysMerge) { checkState(block.isBlock()); Node parent = block.getParent(); boolean canMerge = alwaysMerge || canMergeBlock(block); // Try to remove the block if its parent is a block/script or if its // parent is label and it has exactly one ...
[ "public", "static", "boolean", "tryMergeBlock", "(", "Node", "block", ",", "boolean", "alwaysMerge", ")", "{", "checkState", "(", "block", ".", "isBlock", "(", ")", ")", ";", "Node", "parent", "=", "block", ".", "getParent", "(", ")", ";", "boolean", "ca...
Merge a block with its parent block. @return Whether the block was removed.
[ "Merge", "a", "block", "with", "its", "parent", "block", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2920-L2938
24,254
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.canMergeBlock
public static boolean canMergeBlock(Node block) { for (Node c = block.getFirstChild(); c != null; c = c.getNext()) { switch (c.getToken()) { case LABEL: if (canMergeBlock(c)){ continue; } else { return false; } case CONST: case LET...
java
public static boolean canMergeBlock(Node block) { for (Node c = block.getFirstChild(); c != null; c = c.getNext()) { switch (c.getToken()) { case LABEL: if (canMergeBlock(c)){ continue; } else { return false; } case CONST: case LET...
[ "public", "static", "boolean", "canMergeBlock", "(", "Node", "block", ")", "{", "for", "(", "Node", "c", "=", "block", ".", "getFirstChild", "(", ")", ";", "c", "!=", "null", ";", "c", "=", "c", ".", "getNext", "(", ")", ")", "{", "switch", "(", ...
A check inside a block to see if there are const, let, class, or function declarations to be safe and not hoist them into the upper block. @return Whether the block can be removed
[ "A", "check", "inside", "a", "block", "to", "see", "if", "there", "are", "const", "let", "class", "or", "function", "declarations", "to", "be", "safe", "and", "not", "hoist", "them", "into", "the", "upper", "block", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2945-L2966
24,255
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getFunctionBody
public static Node getFunctionBody(Node fn) { checkArgument(fn.isFunction(), fn); return fn.getLastChild(); }
java
public static Node getFunctionBody(Node fn) { checkArgument(fn.isFunction(), fn); return fn.getLastChild(); }
[ "public", "static", "Node", "getFunctionBody", "(", "Node", "fn", ")", "{", "checkArgument", "(", "fn", ".", "isFunction", "(", ")", ",", "fn", ")", ";", "return", "fn", ".", "getLastChild", "(", ")", ";", "}" ]
Return a BLOCK node for the given FUNCTION node.
[ "Return", "a", "BLOCK", "node", "for", "the", "given", "FUNCTION", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2979-L2982
24,256
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isMethodDeclaration
public static boolean isMethodDeclaration(Node n) { if (n.isFunction()) { Node parent = n.getParent(); switch (parent.getToken()) { case GETTER_DEF: case SETTER_DEF: case MEMBER_FUNCTION_DEF: // `({ get x() {} })` // `({ set x(v) {} })` // `({ f() {}...
java
public static boolean isMethodDeclaration(Node n) { if (n.isFunction()) { Node parent = n.getParent(); switch (parent.getToken()) { case GETTER_DEF: case SETTER_DEF: case MEMBER_FUNCTION_DEF: // `({ get x() {} })` // `({ set x(v) {} })` // `({ f() {}...
[ "public", "static", "boolean", "isMethodDeclaration", "(", "Node", "n", ")", "{", "if", "(", "n", ".", "isFunction", "(", ")", ")", "{", "Node", "parent", "=", "n", ".", "getParent", "(", ")", ";", "switch", "(", "parent", ".", "getToken", "(", ")", ...
Is this node a class or object literal member function? <p>examples: <pre><code> class C { f() {} get x() { return this.x_; } set x(v) { this.x_ = v; } [someExpr]() {} } obj = { f() {} get x() { return this.x_; } set x(v) { this.x_ = v; } [someExpr]() {} } </code></pre>
[ "Is", "this", "node", "a", "class", "or", "object", "literal", "member", "function?" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3025-L3052
24,257
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isFunctionExpression
static boolean isFunctionExpression(Node n) { return n.isFunction() && !NodeUtil.isFunctionDeclaration(n) && !NodeUtil.isMethodDeclaration(n); }
java
static boolean isFunctionExpression(Node n) { return n.isFunction() && !NodeUtil.isFunctionDeclaration(n) && !NodeUtil.isMethodDeclaration(n); }
[ "static", "boolean", "isFunctionExpression", "(", "Node", "n", ")", "{", "return", "n", ".", "isFunction", "(", ")", "&&", "!", "NodeUtil", ".", "isFunctionDeclaration", "(", "n", ")", "&&", "!", "NodeUtil", ".", "isMethodDeclaration", "(", "n", ")", ";", ...
Is a FUNCTION node a function expression? <p>A function expression is a function that: <ul> <li>has either no name or a name that is not added to the current scope <li>AND can be manipulated as an expression (assigned to variables, passed to functions, etc.) i.e. It is not a method declaration on a class or object lit...
[ "Is", "a", "FUNCTION", "node", "a", "function", "expression?" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3151-L3155
24,258
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isNameDeclOrSimpleAssignLhs
public static boolean isNameDeclOrSimpleAssignLhs(Node n, Node parent) { return (parent.isAssign() && parent.getFirstChild() == n) || NodeUtil.isNameDeclaration(parent); }
java
public static boolean isNameDeclOrSimpleAssignLhs(Node n, Node parent) { return (parent.isAssign() && parent.getFirstChild() == n) || NodeUtil.isNameDeclaration(parent); }
[ "public", "static", "boolean", "isNameDeclOrSimpleAssignLhs", "(", "Node", "n", ",", "Node", "parent", ")", "{", "return", "(", "parent", ".", "isAssign", "(", ")", "&&", "parent", ".", "getFirstChild", "(", ")", "==", "n", ")", "||", "NodeUtil", ".", "i...
Determines whether this node is strictly on the left hand side of an assign or var initialization. Notably, this does not include all L-values, only statements where the node is used only as an L-value. @param n The node @param parent Parent of the node @return True if n is the left hand of an assign
[ "Determines", "whether", "this", "node", "is", "strictly", "on", "the", "left", "hand", "side", "of", "an", "assign", "or", "var", "initialization", ".", "Notably", "this", "does", "not", "include", "all", "L", "-", "values", "only", "statements", "where", ...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3309-L3312
24,259
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isLValue
public static boolean isLValue(Node n) { switch (n.getToken()) { case NAME: case GETPROP: case GETELEM: break; default: return false; } Node parent = n.getParent(); if (parent == null) { return false; } switch (parent.getToken()) { case IMPOR...
java
public static boolean isLValue(Node n) { switch (n.getToken()) { case NAME: case GETPROP: case GETELEM: break; default: return false; } Node parent = n.getParent(); if (parent == null) { return false; } switch (parent.getToken()) { case IMPOR...
[ "public", "static", "boolean", "isLValue", "(", "Node", "n", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "NAME", ":", "case", "GETPROP", ":", "case", "GETELEM", ":", "break", ";", "default", ":", "return", "false", ";",...
Determines whether this node is used as an L-value. Notice that sometimes names are used as both L-values and R-values. <p>We treat "var x;" and "let x;" as an L-value because it's syntactically similar to "var x = undefined", even though it's technically not an L-value. But it kind of makes sense if you treat it as "...
[ "Determines", "whether", "this", "node", "is", "used", "as", "an", "L", "-", "value", ".", "Notice", "that", "sometimes", "names", "are", "used", "as", "both", "L", "-", "values", "and", "R", "-", "values", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3325-L3368
24,260
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isDeclarationLValue
public static boolean isDeclarationLValue(Node n) { boolean isLValue = isLValue(n); if (!isLValue) { return false; } Node parent = n.getParent(); switch (parent.getToken()) { case IMPORT_SPEC: case VAR: case LET: case CONST: case PARAM_LIST: case IMPORT: ...
java
public static boolean isDeclarationLValue(Node n) { boolean isLValue = isLValue(n); if (!isLValue) { return false; } Node parent = n.getParent(); switch (parent.getToken()) { case IMPORT_SPEC: case VAR: case LET: case CONST: case PARAM_LIST: case IMPORT: ...
[ "public", "static", "boolean", "isDeclarationLValue", "(", "Node", "n", ")", "{", "boolean", "isLValue", "=", "isLValue", "(", "n", ")", ";", "if", "(", "!", "isLValue", ")", "{", "return", "false", ";", "}", "Node", "parent", "=", "n", ".", "getParent...
Determines whether this node is used as an L-value that is a declaration. <p><code>x = 5;</code> is an L-value but does not declare a variable.
[ "Determines", "whether", "this", "node", "is", "used", "as", "an", "L", "-", "value", "that", "is", "a", "declaration", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3375-L3403
24,261
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getDeclaringParent
public static Node getDeclaringParent(Node targetNode) { Node rootTarget = getRootTarget(targetNode); Node parent = rootTarget.getParent(); if (parent.isRest() || parent.isDefaultValue()) { // e.g. `function foo(targetNode1 = default, ...targetNode2) {}` parent = parent.getParent(); checkS...
java
public static Node getDeclaringParent(Node targetNode) { Node rootTarget = getRootTarget(targetNode); Node parent = rootTarget.getParent(); if (parent.isRest() || parent.isDefaultValue()) { // e.g. `function foo(targetNode1 = default, ...targetNode2) {}` parent = parent.getParent(); checkS...
[ "public", "static", "Node", "getDeclaringParent", "(", "Node", "targetNode", ")", "{", "Node", "rootTarget", "=", "getRootTarget", "(", "targetNode", ")", ";", "Node", "parent", "=", "rootTarget", ".", "getParent", "(", ")", ";", "if", "(", "parent", ".", ...
Returns the node that is effectively declaring the given target. <p>Examples: <pre><code> const a = 1; // getDeclaringParent(a) returns CONST let {[expression]: [x = 3]} = obj; // getDeclaringParent(x) returns LET function foo({a, b}) {}; // getDeclaringParent(a) returns PARAM_LIST function foo(a = 1) {}; // getDecla...
[ "Returns", "the", "node", "that", "is", "effectively", "declaring", "the", "given", "target", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3439-L3474
24,262
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getRootTarget
public static Node getRootTarget(Node targetNode) { Node enclosingTarget = targetNode; for (Node nextTarget = getEnclosingTarget(enclosingTarget); nextTarget != null; nextTarget = getEnclosingTarget(enclosingTarget)) { enclosingTarget = nextTarget; } return enclosingTarget; }
java
public static Node getRootTarget(Node targetNode) { Node enclosingTarget = targetNode; for (Node nextTarget = getEnclosingTarget(enclosingTarget); nextTarget != null; nextTarget = getEnclosingTarget(enclosingTarget)) { enclosingTarget = nextTarget; } return enclosingTarget; }
[ "public", "static", "Node", "getRootTarget", "(", "Node", "targetNode", ")", "{", "Node", "enclosingTarget", "=", "targetNode", ";", "for", "(", "Node", "nextTarget", "=", "getEnclosingTarget", "(", "enclosingTarget", ")", ";", "nextTarget", "!=", "null", ";", ...
Returns the outermost target enclosing the given assignment target. <p>Returns targetNode itself if there is no enclosing target. <p>Examples: <pre><code> const a = 1; // getRootTarget(a) returns a let {[expression]: [x = 3]} = obj; // getRootTarget(x) returns {[expression]: [x = 3]} {a = 1} = obj; // getRootTarget(a...
[ "Returns", "the", "outermost", "target", "enclosing", "the", "given", "assignment", "target", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3501-L3509
24,263
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getEnclosingTarget
@Nullable private static Node getEnclosingTarget(Node targetNode) { checkState(checkNotNull(targetNode).isValidAssignmentTarget(), targetNode); Node parent = checkNotNull(targetNode.getParent(), targetNode); boolean targetIsFirstChild = parent.getFirstChild() == targetNode; if (parent.isDefaultValue()...
java
@Nullable private static Node getEnclosingTarget(Node targetNode) { checkState(checkNotNull(targetNode).isValidAssignmentTarget(), targetNode); Node parent = checkNotNull(targetNode.getParent(), targetNode); boolean targetIsFirstChild = parent.getFirstChild() == targetNode; if (parent.isDefaultValue()...
[ "@", "Nullable", "private", "static", "Node", "getEnclosingTarget", "(", "Node", "targetNode", ")", "{", "checkState", "(", "checkNotNull", "(", "targetNode", ")", ".", "isValidAssignmentTarget", "(", ")", ",", "targetNode", ")", ";", "Node", "parent", "=", "c...
Returns the immediately enclosing target node for a given target node, or null if none found. @see #getRootTarget(Node) for examples @param targetNode
[ "Returns", "the", "immediately", "enclosing", "target", "node", "for", "a", "given", "target", "node", "or", "null", "if", "none", "found", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3517-L3603
24,264
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isLhsByDestructuring
public static boolean isLhsByDestructuring(Node n) { switch (n.getToken()) { case NAME: case GETPROP: case GETELEM: return isLhsByDestructuringHelper(n); default: return false; } }
java
public static boolean isLhsByDestructuring(Node n) { switch (n.getToken()) { case NAME: case GETPROP: case GETELEM: return isLhsByDestructuringHelper(n); default: return false; } }
[ "public", "static", "boolean", "isLhsByDestructuring", "(", "Node", "n", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "NAME", ":", "case", "GETPROP", ":", "case", "GETELEM", ":", "return", "isLhsByDestructuringHelper", "(", "n...
Returns true if the node is a lhs value of a destructuring assignment. <p>For example, x in {@code var [x] = [1];}, {@code var [...x] = [1];}, and {@code var {a: x} = {a: 1}} or a.b in {@code ([a.b] = [1]);} or {@code ({key: a.b} = {key: 1});}
[ "Returns", "true", "if", "the", "node", "is", "a", "lhs", "value", "of", "a", "destructuring", "assignment", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3611-L3620
24,265
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getObjectLitKeyName
static String getObjectLitKeyName(Node key) { Node keyNode = getObjectLitKeyNode(key); if (keyNode != null) { return keyNode.getString(); } throw new IllegalStateException("Unexpected node type: " + key); }
java
static String getObjectLitKeyName(Node key) { Node keyNode = getObjectLitKeyNode(key); if (keyNode != null) { return keyNode.getString(); } throw new IllegalStateException("Unexpected node type: " + key); }
[ "static", "String", "getObjectLitKeyName", "(", "Node", "key", ")", "{", "Node", "keyNode", "=", "getObjectLitKeyNode", "(", "key", ")", ";", "if", "(", "keyNode", "!=", "null", ")", "{", "return", "keyNode", ".", "getString", "(", ")", ";", "}", "throw"...
Get the name of an object literal key. @param key A node
[ "Get", "the", "name", "of", "an", "object", "literal", "key", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3692-L3698
24,266
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getObjectLitKeyNode
static Node getObjectLitKeyNode(Node key) { switch (key.getToken()) { case STRING_KEY: case GETTER_DEF: case SETTER_DEF: case MEMBER_FUNCTION_DEF: return key; case COMPUTED_PROP: return key.getFirstChild().isString() ? key.getFirstChild() : null; default: ...
java
static Node getObjectLitKeyNode(Node key) { switch (key.getToken()) { case STRING_KEY: case GETTER_DEF: case SETTER_DEF: case MEMBER_FUNCTION_DEF: return key; case COMPUTED_PROP: return key.getFirstChild().isString() ? key.getFirstChild() : null; default: ...
[ "static", "Node", "getObjectLitKeyNode", "(", "Node", "key", ")", "{", "switch", "(", "key", ".", "getToken", "(", ")", ")", "{", "case", "STRING_KEY", ":", "case", "GETTER_DEF", ":", "case", "SETTER_DEF", ":", "case", "MEMBER_FUNCTION_DEF", ":", "return", ...
Get the Node that defines the name of an object literal key. @param key A node
[ "Get", "the", "Node", "that", "defines", "the", "name", "of", "an", "object", "literal", "key", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3705-L3718
24,267
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isNestedObjectPattern
static boolean isNestedObjectPattern(Node n) { checkState(n.isObjectPattern()); for (Node key = n.getFirstChild(); key != null; key = key.getNext()) { Node value = key.getFirstChild(); if (value != null && (value.isObjectLit() || value.isArrayLit() || value.isDestructuringPattern())) { ...
java
static boolean isNestedObjectPattern(Node n) { checkState(n.isObjectPattern()); for (Node key = n.getFirstChild(); key != null; key = key.getNext()) { Node value = key.getFirstChild(); if (value != null && (value.isObjectLit() || value.isArrayLit() || value.isDestructuringPattern())) { ...
[ "static", "boolean", "isNestedObjectPattern", "(", "Node", "n", ")", "{", "checkState", "(", "n", ".", "isObjectPattern", "(", ")", ")", ";", "for", "(", "Node", "key", "=", "n", ".", "getFirstChild", "(", ")", ";", "key", "!=", "null", ";", "key", "...
Determine whether the destructuring object pattern is nested @param n object pattern node
[ "Determine", "whether", "the", "destructuring", "object", "pattern", "is", "nested" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3725-L3735
24,268
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isNestedArrayPattern
static boolean isNestedArrayPattern(Node n) { checkState(n.isArrayPattern()); for (Node key = n.getFirstChild(); key != null; key = key.getNext()) { if (key.hasChildren()) { return true; } } return false; }
java
static boolean isNestedArrayPattern(Node n) { checkState(n.isArrayPattern()); for (Node key = n.getFirstChild(); key != null; key = key.getNext()) { if (key.hasChildren()) { return true; } } return false; }
[ "static", "boolean", "isNestedArrayPattern", "(", "Node", "n", ")", "{", "checkState", "(", "n", ".", "isArrayPattern", "(", ")", ")", ";", "for", "(", "Node", "key", "=", "n", ".", "getFirstChild", "(", ")", ";", "key", "!=", "null", ";", "key", "="...
Determine whether the destructuring array pattern is nested @param n array pattern node
[ "Determine", "whether", "the", "destructuring", "array", "pattern", "is", "nested" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3742-L3750
24,269
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.redeclareVarsInsideBranch
static void redeclareVarsInsideBranch(Node branch) { Collection<Node> vars = getVarsDeclaredInBranch(branch); if (vars.isEmpty()) { return; } Node parent = getAddingRoot(branch); for (Node nameNode : vars) { Node var = IR.var( IR.name(nameNode.getString()) .srcre...
java
static void redeclareVarsInsideBranch(Node branch) { Collection<Node> vars = getVarsDeclaredInBranch(branch); if (vars.isEmpty()) { return; } Node parent = getAddingRoot(branch); for (Node nameNode : vars) { Node var = IR.var( IR.name(nameNode.getString()) .srcre...
[ "static", "void", "redeclareVarsInsideBranch", "(", "Node", "branch", ")", "{", "Collection", "<", "Node", ">", "vars", "=", "getVarsDeclaredInBranch", "(", "branch", ")", ";", "if", "(", "vars", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "N...
Given a node tree, finds all the VAR declarations in that tree that are not in an inner scope. Then adds a new VAR node at the top of the current scope that redeclares them, if necessary.
[ "Given", "a", "node", "tree", "finds", "all", "the", "VAR", "declarations", "in", "that", "tree", "that", "are", "not", "in", "an", "inner", "scope", ".", "Then", "adds", "a", "new", "VAR", "node", "at", "the", "top", "of", "the", "current", "scope", ...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3905-L3920
24,270
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.copyNameAnnotations
static void copyNameAnnotations(Node source, Node destination) { if (source.getBooleanProp(Node.IS_CONSTANT_NAME)) { destination.putBooleanProp(Node.IS_CONSTANT_NAME, true); } }
java
static void copyNameAnnotations(Node source, Node destination) { if (source.getBooleanProp(Node.IS_CONSTANT_NAME)) { destination.putBooleanProp(Node.IS_CONSTANT_NAME, true); } }
[ "static", "void", "copyNameAnnotations", "(", "Node", "source", ",", "Node", "destination", ")", "{", "if", "(", "source", ".", "getBooleanProp", "(", "Node", ".", "IS_CONSTANT_NAME", ")", ")", "{", "destination", ".", "putBooleanProp", "(", "Node", ".", "IS...
Copy any annotations that follow a named value. @param source @param destination
[ "Copy", "any", "annotations", "that", "follow", "a", "named", "value", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3927-L3931
24,271
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getAddingRoot
private static Node getAddingRoot(Node n) { Node addingRoot = null; Node ancestor = n; crawl_ancestors: while (null != (ancestor = ancestor.getParent())) { switch (ancestor.getToken()) { case SCRIPT: case MODULE_BODY: addingRoot = ancestor; break crawl_ancestors; ...
java
private static Node getAddingRoot(Node n) { Node addingRoot = null; Node ancestor = n; crawl_ancestors: while (null != (ancestor = ancestor.getParent())) { switch (ancestor.getToken()) { case SCRIPT: case MODULE_BODY: addingRoot = ancestor; break crawl_ancestors; ...
[ "private", "static", "Node", "getAddingRoot", "(", "Node", "n", ")", "{", "Node", "addingRoot", "=", "null", ";", "Node", "ancestor", "=", "n", ";", "crawl_ancestors", ":", "while", "(", "null", "!=", "(", "ancestor", "=", "ancestor", ".", "getParent", "...
Gets a Node at the top of the current scope where we can add new var declarations as children.
[ "Gets", "a", "Node", "at", "the", "top", "of", "the", "current", "scope", "where", "we", "can", "add", "new", "var", "declarations", "as", "children", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L3937-L3958
24,272
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.newQName
static Node newQName( AbstractCompiler compiler, String name, Node basisNode, String originalName) { Node node = newQName(compiler, name); useSourceInfoForNewQName(node, basisNode); if (!originalName.equals(node.getOriginalName())) { // If basisNode already had the correct original name, t...
java
static Node newQName( AbstractCompiler compiler, String name, Node basisNode, String originalName) { Node node = newQName(compiler, name); useSourceInfoForNewQName(node, basisNode); if (!originalName.equals(node.getOriginalName())) { // If basisNode already had the correct original name, t...
[ "static", "Node", "newQName", "(", "AbstractCompiler", "compiler", ",", "String", "name", ",", "Node", "basisNode", ",", "String", "originalName", ")", "{", "Node", "node", "=", "newQName", "(", "compiler", ",", "name", ")", ";", "useSourceInfoForNewQName", "(...
Creates a node representing a qualified name, copying over the source location information from the basis node and assigning the given original name to the node. @param name A qualified name (e.g. "foo" or "foo.bar.baz") @param basisNode The node that represents the name as currently found in the AST. @param originalN...
[ "Creates", "a", "node", "representing", "a", "qualified", "name", "copying", "over", "the", "source", "location", "information", "from", "the", "basis", "node", "and", "assigning", "the", "given", "original", "name", "to", "the", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4019-L4031
24,273
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.useSourceInfoForNewQName
private static void useSourceInfoForNewQName(Node newQName, Node basisNode) { if (newQName.getStaticSourceFile() == null) { newQName.setStaticSourceFileFrom(basisNode); newQName.setSourceEncodedPosition(basisNode.getSourcePosition()); } if (newQName.getOriginalName() == null) { newQName.p...
java
private static void useSourceInfoForNewQName(Node newQName, Node basisNode) { if (newQName.getStaticSourceFile() == null) { newQName.setStaticSourceFileFrom(basisNode); newQName.setSourceEncodedPosition(basisNode.getSourcePosition()); } if (newQName.getOriginalName() == null) { newQName.p...
[ "private", "static", "void", "useSourceInfoForNewQName", "(", "Node", "newQName", ",", "Node", "basisNode", ")", "{", "if", "(", "newQName", ".", "getStaticSourceFile", "(", ")", "==", "null", ")", "{", "newQName", ".", "setStaticSourceFileFrom", "(", "basisNode...
Custom update new QName node with source info from another node. <p>This is very similar to {@link Node#useSourceInfoIfMissingFromForTree(Node)}, but it avoids overwriting the length field of the nodes. TODO(bradfordcsmith): Eliminate the need for this custom method.
[ "Custom", "update", "new", "QName", "node", "with", "source", "info", "from", "another", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4088-L4101
24,274
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getRootOfQualifiedName
static Node getRootOfQualifiedName(Node qName) { for (Node current = qName; true; current = current.getFirstChild()) { if (current.isName() || current.isThis() || current.isSuper()) { return current; } checkState(current.isGetProp(), "Not a getprop node: ", current); } }
java
static Node getRootOfQualifiedName(Node qName) { for (Node current = qName; true; current = current.getFirstChild()) { if (current.isName() || current.isThis() || current.isSuper()) { return current; } checkState(current.isGetProp(), "Not a getprop node: ", current); } }
[ "static", "Node", "getRootOfQualifiedName", "(", "Node", "qName", ")", "{", "for", "(", "Node", "current", "=", "qName", ";", "true", ";", "current", "=", "current", ".", "getFirstChild", "(", ")", ")", "{", "if", "(", "current", ".", "isName", "(", ")...
Gets the root node of a qualified name. Must be either NAME, THIS or SUPER.
[ "Gets", "the", "root", "node", "of", "a", "qualified", "name", ".", "Must", "be", "either", "NAME", "THIS", "or", "SUPER", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4106-L4113
24,275
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isValidSimpleName
static boolean isValidSimpleName(String name) { return TokenStream.isJSIdentifier(name) && !TokenStream.isKeyword(name) // no Unicode escaped characters - some browsers are less tolerant // of Unicode characters that might be valid according to the // language spec. // Note t...
java
static boolean isValidSimpleName(String name) { return TokenStream.isJSIdentifier(name) && !TokenStream.isKeyword(name) // no Unicode escaped characters - some browsers are less tolerant // of Unicode characters that might be valid according to the // language spec. // Note t...
[ "static", "boolean", "isValidSimpleName", "(", "String", "name", ")", "{", "return", "TokenStream", ".", "isJSIdentifier", "(", "name", ")", "&&", "!", "TokenStream", ".", "isKeyword", "(", "name", ")", "// no Unicode escaped characters - some browsers are less tolerant...
Determines whether the given name is a valid variable name.
[ "Determines", "whether", "the", "given", "name", "is", "a", "valid", "variable", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4193-L4203
24,276
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isValidQualifiedName
public static boolean isValidQualifiedName(FeatureSet mode, String name) { if (name.endsWith(".") || name.startsWith(".")) { return false; } List<String> parts = Splitter.on('.').splitToList(name); for (String part : parts) { if (!isValidPropertyName(mode, part)) { return false; ...
java
public static boolean isValidQualifiedName(FeatureSet mode, String name) { if (name.endsWith(".") || name.startsWith(".")) { return false; } List<String> parts = Splitter.on('.').splitToList(name); for (String part : parts) { if (!isValidPropertyName(mode, part)) { return false; ...
[ "public", "static", "boolean", "isValidQualifiedName", "(", "FeatureSet", "mode", ",", "String", "name", ")", "{", "if", "(", "name", ".", "endsWith", "(", "\".\"", ")", "||", "name", ".", "startsWith", "(", "\".\"", ")", ")", "{", "return", "false", ";"...
Determines whether the given name is a valid qualified name.
[ "Determines", "whether", "the", "given", "name", "is", "a", "valid", "qualified", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4211-L4223
24,277
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getVarsDeclaredInBranch
static Collection<Node> getVarsDeclaredInBranch(Node root) { VarCollector collector = new VarCollector(); visitPreOrder( root, collector, MATCH_NOT_FUNCTION); return collector.vars.values(); }
java
static Collection<Node> getVarsDeclaredInBranch(Node root) { VarCollector collector = new VarCollector(); visitPreOrder( root, collector, MATCH_NOT_FUNCTION); return collector.vars.values(); }
[ "static", "Collection", "<", "Node", ">", "getVarsDeclaredInBranch", "(", "Node", "root", ")", "{", "VarCollector", "collector", "=", "new", "VarCollector", "(", ")", ";", "visitPreOrder", "(", "root", ",", "collector", ",", "MATCH_NOT_FUNCTION", ")", ";", "re...
Retrieves vars declared in the current node tree, excluding descent scopes.
[ "Retrieves", "vars", "declared", "in", "the", "current", "node", "tree", "excluding", "descent", "scopes", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4255-L4262
24,278
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.findLhsNodesInNode
public static List<Node> findLhsNodesInNode(Node assigningParent) { checkArgument( isNameDeclaration(assigningParent) || assigningParent.isParamList() || isAssignmentOp(assigningParent) || assigningParent.isCatch() || assigningParent.isDestructuringLhs() ...
java
public static List<Node> findLhsNodesInNode(Node assigningParent) { checkArgument( isNameDeclaration(assigningParent) || assigningParent.isParamList() || isAssignmentOp(assigningParent) || assigningParent.isCatch() || assigningParent.isDestructuringLhs() ...
[ "public", "static", "List", "<", "Node", ">", "findLhsNodesInNode", "(", "Node", "assigningParent", ")", "{", "checkArgument", "(", "isNameDeclaration", "(", "assigningParent", ")", "||", "assigningParent", ".", "isParamList", "(", ")", "||", "isAssignmentOp", "("...
Retrieves lhs nodes declared or assigned in a given assigning parent node. <p>An assigning parent node is one that assigns a value to one or more LHS nodes.
[ "Retrieves", "lhs", "nodes", "declared", "or", "assigned", "in", "a", "given", "assigning", "parent", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4327-L4342
24,279
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.newVarNode
static Node newVarNode(String name, Node value) { Node lhs = IR.name(name); if (value != null) { lhs.srcref(value); } return newVarNode(lhs, value); }
java
static Node newVarNode(String name, Node value) { Node lhs = IR.name(name); if (value != null) { lhs.srcref(value); } return newVarNode(lhs, value); }
[ "static", "Node", "newVarNode", "(", "String", "name", ",", "Node", "value", ")", "{", "Node", "lhs", "=", "IR", ".", "name", "(", "name", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "lhs", ".", "srcref", "(", "value", ")", ";", "}", ...
Create a VAR node containing the given name and initial value expression.
[ "Create", "a", "VAR", "node", "containing", "the", "given", "name", "and", "initial", "value", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4547-L4553
24,280
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getNodeTypeReferenceCount
static int getNodeTypeReferenceCount( Node node, Token type, Predicate<Node> traverseChildrenPred) { return getCount(node, new MatchNodeType(type), traverseChildrenPred); }
java
static int getNodeTypeReferenceCount( Node node, Token type, Predicate<Node> traverseChildrenPred) { return getCount(node, new MatchNodeType(type), traverseChildrenPred); }
[ "static", "int", "getNodeTypeReferenceCount", "(", "Node", "node", ",", "Token", "type", ",", "Predicate", "<", "Node", ">", "traverseChildrenPred", ")", "{", "return", "getCount", "(", "node", ",", "new", "MatchNodeType", "(", "type", ")", ",", "traverseChild...
Finds the number of times a type is referenced within the node tree.
[ "Finds", "the", "number", "of", "times", "a", "type", "is", "referenced", "within", "the", "node", "tree", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4647-L4650
24,281
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getNameReferenceCount
static int getNameReferenceCount(Node node, String name) { return getCount(node, new MatchNameNode(name), Predicates.alwaysTrue()); }
java
static int getNameReferenceCount(Node node, String name) { return getCount(node, new MatchNameNode(name), Predicates.alwaysTrue()); }
[ "static", "int", "getNameReferenceCount", "(", "Node", "node", ",", "String", "name", ")", "{", "return", "getCount", "(", "node", ",", "new", "MatchNameNode", "(", "name", ")", ",", "Predicates", ".", "alwaysTrue", "(", ")", ")", ";", "}" ]
Finds the number of times a simple name is referenced within the node tree.
[ "Finds", "the", "number", "of", "times", "a", "simple", "name", "is", "referenced", "within", "the", "node", "tree", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4667-L4669
24,282
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.visitPreOrder
public static void visitPreOrder(Node node, Visitor visitor) { visitPreOrder(node, visitor, Predicates.alwaysTrue()); }
java
public static void visitPreOrder(Node node, Visitor visitor) { visitPreOrder(node, visitor, Predicates.alwaysTrue()); }
[ "public", "static", "void", "visitPreOrder", "(", "Node", "node", ",", "Visitor", "visitor", ")", "{", "visitPreOrder", "(", "node", ",", "visitor", ",", "Predicates", ".", "alwaysTrue", "(", ")", ")", ";", "}" ]
A pre-order traversal, calling Visitor.visit for each decendent.
[ "A", "pre", "-", "order", "traversal", "calling", "Visitor", ".", "visit", "for", "each", "decendent", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4720-L4722
24,283
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.visitPreOrder
public static void visitPreOrder( Node node, Visitor visitor, Predicate<Node> traverseChildrenPred) { visitor.visit(node); if (traverseChildrenPred.apply(node)) { for (Node c = node.getFirstChild(); c != null; c = c.getNext()) { visitPreOrder(c, visitor, traverseChildrenPred); } }...
java
public static void visitPreOrder( Node node, Visitor visitor, Predicate<Node> traverseChildrenPred) { visitor.visit(node); if (traverseChildrenPred.apply(node)) { for (Node c = node.getFirstChild(); c != null; c = c.getNext()) { visitPreOrder(c, visitor, traverseChildrenPred); } }...
[ "public", "static", "void", "visitPreOrder", "(", "Node", "node", ",", "Visitor", "visitor", ",", "Predicate", "<", "Node", ">", "traverseChildrenPred", ")", "{", "visitor", ".", "visit", "(", "node", ")", ";", "if", "(", "traverseChildrenPred", ".", "apply"...
A pre-order traversal, calling Visitor.visit for each child matching the predicate.
[ "A", "pre", "-", "order", "traversal", "calling", "Visitor", ".", "visit", "for", "each", "child", "matching", "the", "predicate", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4725-L4734
24,284
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.visitPostOrder
public static void visitPostOrder(Node node, Visitor visitor) { visitPostOrder(node, visitor, Predicates.alwaysTrue()); }
java
public static void visitPostOrder(Node node, Visitor visitor) { visitPostOrder(node, visitor, Predicates.alwaysTrue()); }
[ "public", "static", "void", "visitPostOrder", "(", "Node", "node", ",", "Visitor", "visitor", ")", "{", "visitPostOrder", "(", "node", ",", "visitor", ",", "Predicates", ".", "alwaysTrue", "(", ")", ")", ";", "}" ]
A post-order traversal, calling Visitor.visit for each decendent.
[ "A", "post", "-", "order", "traversal", "calling", "Visitor", ".", "visit", "for", "each", "decendent", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4737-L4739
24,285
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isConstantByConvention
static boolean isConstantByConvention( CodingConvention convention, Node node) { Node parent = node.getParent(); if (parent.isGetProp() && node == parent.getLastChild()) { return convention.isConstantKey(node.getString()); } else if (mayBeObjectLitKey(node)) { return convention.isConstantK...
java
static boolean isConstantByConvention( CodingConvention convention, Node node) { Node parent = node.getParent(); if (parent.isGetProp() && node == parent.getLastChild()) { return convention.isConstantKey(node.getString()); } else if (mayBeObjectLitKey(node)) { return convention.isConstantK...
[ "static", "boolean", "isConstantByConvention", "(", "CodingConvention", "convention", ",", "Node", "node", ")", "{", "Node", "parent", "=", "node", ".", "getParent", "(", ")", ";", "if", "(", "parent", ".", "isGetProp", "(", ")", "&&", "node", "==", "paren...
Whether the given name is constant by coding convention.
[ "Whether", "the", "given", "name", "is", "constant", "by", "coding", "convention", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4847-L4858
24,286
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isConstantDeclaration
static boolean isConstantDeclaration( CodingConvention convention, JSDocInfo info, Node node) { // TODO(b/77597706): Update this method to handle destructured declarations. if (node.isName() && node.getParent().isConst()) { return true; } else if (node.isName() && isLhsByDestructuring(no...
java
static boolean isConstantDeclaration( CodingConvention convention, JSDocInfo info, Node node) { // TODO(b/77597706): Update this method to handle destructured declarations. if (node.isName() && node.getParent().isConst()) { return true; } else if (node.isName() && isLhsByDestructuring(no...
[ "static", "boolean", "isConstantDeclaration", "(", "CodingConvention", "convention", ",", "JSDocInfo", "info", ",", "Node", "node", ")", "{", "// TODO(b/77597706): Update this method to handle destructured declarations.", "if", "(", "node", ".", "isName", "(", ")", "&&", ...
Temporary function to determine if a node is constant in the old or new world. This does not check its inputs carefully because it will go away once we switch to the new world.
[ "Temporary", "function", "to", "determine", "if", "a", "node", "is", "constant", "in", "the", "old", "or", "new", "world", ".", "This", "does", "not", "check", "its", "inputs", "carefully", "because", "it", "will", "go", "away", "once", "we", "switch", "...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4866-L4895
24,287
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getNodeByLineCol
public static Node getNodeByLineCol(Node ancestor, int lineNo, int columNo) { checkArgument(ancestor.isScript()); Node current = ancestor; Node result = null; while (current != null) { int currLineNo = current.getLineno(); checkState(current.getLineno() <= lineNo); Node nextSibling = c...
java
public static Node getNodeByLineCol(Node ancestor, int lineNo, int columNo) { checkArgument(ancestor.isScript()); Node current = ancestor; Node result = null; while (current != null) { int currLineNo = current.getLineno(); checkState(current.getLineno() <= lineNo); Node nextSibling = c...
[ "public", "static", "Node", "getNodeByLineCol", "(", "Node", "ancestor", ",", "int", "lineNo", ",", "int", "columNo", ")", "{", "checkArgument", "(", "ancestor", ".", "isScript", "(", ")", ")", ";", "Node", "current", "=", "ancestor", ";", "Node", "result"...
Column number 1 represents a cursor at the start of the line.
[ "Column", "number", "1", "represents", "a", "cursor", "at", "the", "start", "of", "the", "line", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4958-L5002
24,288
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.newCallNode
static Node newCallNode(Node callTarget, Node... parameters) { boolean isFreeCall = !isGet(callTarget); Node call = IR.call(callTarget); call.putBooleanProp(Node.FREE_CALL, isFreeCall); for (Node parameter : parameters) { call.addChildToBack(parameter); } return call; }
java
static Node newCallNode(Node callTarget, Node... parameters) { boolean isFreeCall = !isGet(callTarget); Node call = IR.call(callTarget); call.putBooleanProp(Node.FREE_CALL, isFreeCall); for (Node parameter : parameters) { call.addChildToBack(parameter); } return call; }
[ "static", "Node", "newCallNode", "(", "Node", "callTarget", ",", "Node", "...", "parameters", ")", "{", "boolean", "isFreeCall", "=", "!", "isGet", "(", "callTarget", ")", ";", "Node", "call", "=", "IR", ".", "call", "(", "callTarget", ")", ";", "call", ...
A new CALL node with the "FREE_CALL" set based on call target.
[ "A", "new", "CALL", "node", "with", "the", "FREE_CALL", "set", "based", "on", "call", "target", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5014-L5022
24,289
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getNthSibling
private static Node getNthSibling(Node first, int index) { Node sibling = first; while (index != 0 && sibling != null) { sibling = sibling.getNext(); index--; } return sibling; }
java
private static Node getNthSibling(Node first, int index) { Node sibling = first; while (index != 0 && sibling != null) { sibling = sibling.getNext(); index--; } return sibling; }
[ "private", "static", "Node", "getNthSibling", "(", "Node", "first", ",", "int", "index", ")", "{", "Node", "sibling", "=", "first", ";", "while", "(", "index", "!=", "0", "&&", "sibling", "!=", "null", ")", "{", "sibling", "=", "sibling", ".", "getNext...
Given the first sibling, this returns the nth sibling or null if no such sibling exists. This is like "getChildAtIndex" but returns null for non-existent indexes.
[ "Given", "the", "first", "sibling", "this", "returns", "the", "nth", "sibling", "or", "null", "if", "no", "such", "sibling", "exists", ".", "This", "is", "like", "getChildAtIndex", "but", "returns", "null", "for", "non", "-", "existent", "indexes", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5197-L5204
24,290
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getArgumentForFunction
static Node getArgumentForFunction(Node function, int index) { checkState(function.isFunction()); return getNthSibling( function.getSecondChild().getFirstChild(), index); }
java
static Node getArgumentForFunction(Node function, int index) { checkState(function.isFunction()); return getNthSibling( function.getSecondChild().getFirstChild(), index); }
[ "static", "Node", "getArgumentForFunction", "(", "Node", "function", ",", "int", "index", ")", "{", "checkState", "(", "function", ".", "isFunction", "(", ")", ")", ";", "return", "getNthSibling", "(", "function", ".", "getSecondChild", "(", ")", ".", "getFi...
Given the function, this returns the nth argument or null if no such parameter exists.
[ "Given", "the", "function", "this", "returns", "the", "nth", "argument", "or", "null", "if", "no", "such", "parameter", "exists", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5210-L5214
24,291
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getArgumentForCallOrNew
static Node getArgumentForCallOrNew(Node call, int index) { checkState(isCallOrNew(call)); return getNthSibling(call.getSecondChild(), index); }
java
static Node getArgumentForCallOrNew(Node call, int index) { checkState(isCallOrNew(call)); return getNthSibling(call.getSecondChild(), index); }
[ "static", "Node", "getArgumentForCallOrNew", "(", "Node", "call", ",", "int", "index", ")", "{", "checkState", "(", "isCallOrNew", "(", "call", ")", ")", ";", "return", "getNthSibling", "(", "call", ".", "getSecondChild", "(", ")", ",", "index", ")", ";", ...
Given the new or call, this returns the nth argument of the call or null if no such argument exists.
[ "Given", "the", "new", "or", "call", "this", "returns", "the", "nth", "argument", "of", "the", "call", "or", "null", "if", "no", "such", "argument", "exists", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5220-L5223
24,292
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.isInvocationTarget
static boolean isInvocationTarget(Node n) { Node parent = n.getParent(); return parent != null && (isCallOrNew(parent) || parent.isTaggedTemplateLit()) && parent.getFirstChild() == n; }
java
static boolean isInvocationTarget(Node n) { Node parent = n.getParent(); return parent != null && (isCallOrNew(parent) || parent.isTaggedTemplateLit()) && parent.getFirstChild() == n; }
[ "static", "boolean", "isInvocationTarget", "(", "Node", "n", ")", "{", "Node", "parent", "=", "n", ".", "getParent", "(", ")", ";", "return", "parent", "!=", "null", "&&", "(", "isCallOrNew", "(", "parent", ")", "||", "parent", ".", "isTaggedTemplateLit", ...
Returns whether this is a target of a call or new.
[ "Returns", "whether", "this", "is", "a", "target", "of", "a", "call", "or", "new", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5228-L5232
24,293
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getDeclaredTypeExpression
@Nullable public static JSTypeExpression getDeclaredTypeExpression(Node declaration) { checkArgument(declaration.isName() || declaration.isStringKey()); JSDocInfo nameJsdoc = getBestJSDocInfo(declaration); if (nameJsdoc != null) { return nameJsdoc.getType(); } Node parent = declaration.getPa...
java
@Nullable public static JSTypeExpression getDeclaredTypeExpression(Node declaration) { checkArgument(declaration.isName() || declaration.isStringKey()); JSDocInfo nameJsdoc = getBestJSDocInfo(declaration); if (nameJsdoc != null) { return nameJsdoc.getType(); } Node parent = declaration.getPa...
[ "@", "Nullable", "public", "static", "JSTypeExpression", "getDeclaredTypeExpression", "(", "Node", "declaration", ")", "{", "checkArgument", "(", "declaration", ".", "isName", "(", ")", "||", "declaration", ".", "isStringKey", "(", ")", ")", ";", "JSDocInfo", "n...
Return declared JSDoc type for the given name declaration, or null if none present.
[ "Return", "declared", "JSDoc", "type", "for", "the", "given", "name", "declaration", "or", "null", "if", "none", "present", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5256-L5274
24,294
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getBestJSDocInfo
@Nullable public static JSDocInfo getBestJSDocInfo(Node n) { Node jsdocNode = getBestJSDocInfoNode(n); return jsdocNode == null ? null : jsdocNode.getJSDocInfo(); }
java
@Nullable public static JSDocInfo getBestJSDocInfo(Node n) { Node jsdocNode = getBestJSDocInfoNode(n); return jsdocNode == null ? null : jsdocNode.getJSDocInfo(); }
[ "@", "Nullable", "public", "static", "JSDocInfo", "getBestJSDocInfo", "(", "Node", "n", ")", "{", "Node", "jsdocNode", "=", "getBestJSDocInfoNode", "(", "n", ")", ";", "return", "jsdocNode", "==", "null", "?", "null", ":", "jsdocNode", ".", "getJSDocInfo", "...
Find the best JSDoc for the given node.
[ "Find", "the", "best", "JSDoc", "for", "the", "given", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5277-L5281
24,295
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getBestLValue
public static Node getBestLValue(Node n) { Node parent = n.getParent(); if (isFunctionDeclaration(n) || isClassDeclaration(n)) { return n.getFirstChild(); } else if (n.isClassMembers()) { return getBestLValue(parent); } else if (parent.isName()) { return parent; } else if (parent.i...
java
public static Node getBestLValue(Node n) { Node parent = n.getParent(); if (isFunctionDeclaration(n) || isClassDeclaration(n)) { return n.getFirstChild(); } else if (n.isClassMembers()) { return getBestLValue(parent); } else if (parent.isName()) { return parent; } else if (parent.i...
[ "public", "static", "Node", "getBestLValue", "(", "Node", "n", ")", "{", "Node", "parent", "=", "n", ".", "getParent", "(", ")", ";", "if", "(", "isFunctionDeclaration", "(", "n", ")", "||", "isClassDeclaration", "(", "n", ")", ")", "{", "return", "n",...
Find the l-value that the given r-value is being assigned to.
[ "Find", "the", "l", "-", "value", "that", "the", "given", "r", "-", "value", "is", "being", "assigned", "to", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5317-L5338
24,296
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.markNewScopesChanged
static void markNewScopesChanged(Node node, AbstractCompiler compiler) { if (node.isFunction()) { compiler.reportChangeToChangeScope(node); } for (Node child = node.getFirstChild(); child != null; child = child.getNext()) { markNewScopesChanged(child, compiler); } }
java
static void markNewScopesChanged(Node node, AbstractCompiler compiler) { if (node.isFunction()) { compiler.reportChangeToChangeScope(node); } for (Node child = node.getFirstChild(); child != null; child = child.getNext()) { markNewScopesChanged(child, compiler); } }
[ "static", "void", "markNewScopesChanged", "(", "Node", "node", ",", "AbstractCompiler", "compiler", ")", "{", "if", "(", "node", ".", "isFunction", "(", ")", ")", "{", "compiler", ".", "reportChangeToChangeScope", "(", "node", ")", ";", "}", "for", "(", "N...
Recurses through a tree, marking all function nodes as changed.
[ "Recurses", "through", "a", "tree", "marking", "all", "function", "nodes", "as", "changed", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5822-L5829
24,297
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.markFunctionsDeleted
public static void markFunctionsDeleted(Node node, AbstractCompiler compiler) { if (node.isFunction()) { compiler.reportFunctionDeleted(node); } for (Node child = node.getFirstChild(); child != null; child = child.getNext()) { markFunctionsDeleted(child, compiler); } }
java
public static void markFunctionsDeleted(Node node, AbstractCompiler compiler) { if (node.isFunction()) { compiler.reportFunctionDeleted(node); } for (Node child = node.getFirstChild(); child != null; child = child.getNext()) { markFunctionsDeleted(child, compiler); } }
[ "public", "static", "void", "markFunctionsDeleted", "(", "Node", "node", ",", "AbstractCompiler", "compiler", ")", "{", "if", "(", "node", ".", "isFunction", "(", ")", ")", "{", "compiler", ".", "reportFunctionDeleted", "(", "node", ")", ";", "}", "for", "...
Recurses through a tree, marking all function nodes deleted.
[ "Recurses", "through", "a", "tree", "marking", "all", "function", "nodes", "deleted", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5832-L5840
24,298
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.getParentChangeScopeNodes
public static List<Node> getParentChangeScopeNodes(List<Node> scopeNodes) { Set<Node> parentScopeNodes = new LinkedHashSet<>(scopeNodes); for (Node scopeNode : scopeNodes) { parentScopeNodes.add(getEnclosingChangeScopeRoot(scopeNode)); } return new ArrayList<>(parentScopeNodes); }
java
public static List<Node> getParentChangeScopeNodes(List<Node> scopeNodes) { Set<Node> parentScopeNodes = new LinkedHashSet<>(scopeNodes); for (Node scopeNode : scopeNodes) { parentScopeNodes.add(getEnclosingChangeScopeRoot(scopeNode)); } return new ArrayList<>(parentScopeNodes); }
[ "public", "static", "List", "<", "Node", ">", "getParentChangeScopeNodes", "(", "List", "<", "Node", ">", "scopeNodes", ")", "{", "Set", "<", "Node", ">", "parentScopeNodes", "=", "new", "LinkedHashSet", "<>", "(", "scopeNodes", ")", ";", "for", "(", "Node...
Returns the list of scope nodes which are parents of the provided list of scope nodes.
[ "Returns", "the", "list", "of", "scope", "nodes", "which", "are", "parents", "of", "the", "provided", "list", "of", "scope", "nodes", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5843-L5849
24,299
google/closure-compiler
src/com/google/javascript/jscomp/NodeUtil.java
NodeUtil.removeNestedChangeScopeNodes
public static List<Node> removeNestedChangeScopeNodes(List<Node> scopeNodes) { Set<Node> uniqueScopeNodes = new LinkedHashSet<>(scopeNodes); for (Node scopeNode : scopeNodes) { for (Node ancestor = scopeNode.getParent(); ancestor != null; ancestor = ancestor.getParent()) { if (...
java
public static List<Node> removeNestedChangeScopeNodes(List<Node> scopeNodes) { Set<Node> uniqueScopeNodes = new LinkedHashSet<>(scopeNodes); for (Node scopeNode : scopeNodes) { for (Node ancestor = scopeNode.getParent(); ancestor != null; ancestor = ancestor.getParent()) { if (...
[ "public", "static", "List", "<", "Node", ">", "removeNestedChangeScopeNodes", "(", "List", "<", "Node", ">", "scopeNodes", ")", "{", "Set", "<", "Node", ">", "uniqueScopeNodes", "=", "new", "LinkedHashSet", "<>", "(", "scopeNodes", ")", ";", "for", "(", "N...
Removes any scope nodes from the provided list that are nested within some other scope node also in the list. Returns the modified list.
[ "Removes", "any", "scope", "nodes", "from", "the", "provided", "list", "that", "are", "nested", "within", "some", "other", "scope", "node", "also", "in", "the", "list", ".", "Returns", "the", "modified", "list", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5855-L5868