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,100
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.makesDicts
public final boolean makesDicts() { if (!isConstructor()) { return false; } if (propAccess == PropAccess.DICT) { return true; } FunctionType superc = getSuperClassConstructor(); if (superc != null && superc.makesDicts()) { setDict(); return true; } return false; ...
java
public final boolean makesDicts() { if (!isConstructor()) { return false; } if (propAccess == PropAccess.DICT) { return true; } FunctionType superc = getSuperClassConstructor(); if (superc != null && superc.makesDicts()) { setDict(); return true; } return false; ...
[ "public", "final", "boolean", "makesDicts", "(", ")", "{", "if", "(", "!", "isConstructor", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "propAccess", "==", "PropAccess", ".", "DICT", ")", "{", "return", "true", ";", "}", "FunctionType",...
When a class B inherits from A and A is annotated as a dict, then B automatically gets the annotation, even if B's constructor is not explicitly annotated.
[ "When", "a", "class", "B", "inherits", "from", "A", "and", "A", "is", "annotated", "as", "a", "dict", "then", "B", "automatically", "gets", "the", "annotation", "even", "if", "B", "s", "constructor", "is", "not", "explicitly", "annotated", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L258-L271
24,101
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getMinArity
public final int getMinArity() { // NOTE(nicksantos): There are some native functions that have optional // parameters before required parameters. This algorithm finds the position // of the last required parameter. int i = 0; int min = 0; for (Node n : getParameters()) { i++; if (!n...
java
public final int getMinArity() { // NOTE(nicksantos): There are some native functions that have optional // parameters before required parameters. This algorithm finds the position // of the last required parameter. int i = 0; int min = 0; for (Node n : getParameters()) { i++; if (!n...
[ "public", "final", "int", "getMinArity", "(", ")", "{", "// NOTE(nicksantos): There are some native functions that have optional", "// parameters before required parameters. This algorithm finds the position", "// of the last required parameter.", "int", "i", "=", "0", ";", "int", "m...
Gets the minimum number of arguments that this function requires.
[ "Gets", "the", "minimum", "number", "of", "arguments", "that", "this", "function", "requires", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L325-L338
24,102
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getMaxArity
public final int getMaxArity() { Node params = getParametersNode(); if (params != null) { Node lastParam = params.getLastChild(); if (lastParam == null || !lastParam.isVarArgs()) { return params.getChildCount(); } } return Integer.MAX_VALUE; }
java
public final int getMaxArity() { Node params = getParametersNode(); if (params != null) { Node lastParam = params.getLastChild(); if (lastParam == null || !lastParam.isVarArgs()) { return params.getChildCount(); } } return Integer.MAX_VALUE; }
[ "public", "final", "int", "getMaxArity", "(", ")", "{", "Node", "params", "=", "getParametersNode", "(", ")", ";", "if", "(", "params", "!=", "null", ")", "{", "Node", "lastParam", "=", "params", ".", "getLastChild", "(", ")", ";", "if", "(", "lastPara...
Gets the maximum number of arguments that this function requires, or Integer.MAX_VALUE if this is a variable argument function.
[ "Gets", "the", "maximum", "number", "of", "arguments", "that", "this", "function", "requires", "or", "Integer", ".", "MAX_VALUE", "if", "this", "is", "a", "variable", "argument", "function", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L344-L354
24,103
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getOwnPropertyNames
@Override public final Set<String> getOwnPropertyNames() { if (prototypeSlot == null) { return super.getOwnPropertyNames(); } else { ImmutableSet.Builder<String> names = ImmutableSet.builder(); names.add("prototype"); names.addAll(super.getOwnPropertyNames()); return names.build(...
java
@Override public final Set<String> getOwnPropertyNames() { if (prototypeSlot == null) { return super.getOwnPropertyNames(); } else { ImmutableSet.Builder<String> names = ImmutableSet.builder(); names.add("prototype"); names.addAll(super.getOwnPropertyNames()); return names.build(...
[ "@", "Override", "public", "final", "Set", "<", "String", ">", "getOwnPropertyNames", "(", ")", "{", "if", "(", "prototypeSlot", "==", "null", ")", "{", "return", "super", ".", "getOwnPropertyNames", "(", ")", ";", "}", "else", "{", "ImmutableSet", ".", ...
Includes the prototype iff someone has created it. We do not want to expose the prototype for ordinary functions.
[ "Includes", "the", "prototype", "iff", "someone", "has", "created", "it", ".", "We", "do", "not", "want", "to", "expose", "the", "prototype", "for", "ordinary", "functions", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L384-L394
24,104
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.setPrototype
final boolean setPrototype(ObjectType prototype, Node propertyNode) { if (prototype == null) { return false; } // getInstanceType fails if the function is not a constructor if (isConstructor() && prototype == getInstanceType()) { return false; } return setPrototypeNoCheck(prototype, ...
java
final boolean setPrototype(ObjectType prototype, Node propertyNode) { if (prototype == null) { return false; } // getInstanceType fails if the function is not a constructor if (isConstructor() && prototype == getInstanceType()) { return false; } return setPrototypeNoCheck(prototype, ...
[ "final", "boolean", "setPrototype", "(", "ObjectType", "prototype", ",", "Node", "propertyNode", ")", "{", "if", "(", "prototype", "==", "null", ")", "{", "return", "false", ";", "}", "// getInstanceType fails if the function is not a constructor", "if", "(", "isCon...
Sets the prototype. @param prototype the prototype. If this value is {@code null} it will silently be discarded.
[ "Sets", "the", "prototype", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L485-L494
24,105
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.setPrototypeNoCheck
private boolean setPrototypeNoCheck(ObjectType prototype, Node propertyNode) { ObjectType oldPrototype = prototypeSlot == null ? null : (ObjectType) prototypeSlot.getType(); boolean replacedPrototype = oldPrototype != null; this.prototypeSlot = new Property("prototype", prototype, true, propertyNod...
java
private boolean setPrototypeNoCheck(ObjectType prototype, Node propertyNode) { ObjectType oldPrototype = prototypeSlot == null ? null : (ObjectType) prototypeSlot.getType(); boolean replacedPrototype = oldPrototype != null; this.prototypeSlot = new Property("prototype", prototype, true, propertyNod...
[ "private", "boolean", "setPrototypeNoCheck", "(", "ObjectType", "prototype", ",", "Node", "propertyNode", ")", "{", "ObjectType", "oldPrototype", "=", "prototypeSlot", "==", "null", "?", "null", ":", "(", "ObjectType", ")", "prototypeSlot", ".", "getType", "(", ...
Set the prototype without doing any sanity checks.
[ "Set", "the", "prototype", "without", "doing", "any", "sanity", "checks", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L497-L532
24,106
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getAllImplementedInterfaces
public final Iterable<ObjectType> getAllImplementedInterfaces() { // Store them in a linked hash set, so that the compile job is // deterministic. Set<ObjectType> interfaces = new LinkedHashSet<>(); for (ObjectType type : getImplementedInterfaces()) { addRelatedInterfaces(type, interfaces); }...
java
public final Iterable<ObjectType> getAllImplementedInterfaces() { // Store them in a linked hash set, so that the compile job is // deterministic. Set<ObjectType> interfaces = new LinkedHashSet<>(); for (ObjectType type : getImplementedInterfaces()) { addRelatedInterfaces(type, interfaces); }...
[ "public", "final", "Iterable", "<", "ObjectType", ">", "getAllImplementedInterfaces", "(", ")", "{", "// Store them in a linked hash set, so that the compile job is", "// deterministic.", "Set", "<", "ObjectType", ">", "interfaces", "=", "new", "LinkedHashSet", "<>", "(", ...
Returns all interfaces implemented by a class or its superclass and any superclasses for any of those interfaces. If this is called before all types are resolved, it may return an incomplete set.
[ "Returns", "all", "interfaces", "implemented", "by", "a", "class", "or", "its", "superclass", "and", "any", "superclasses", "for", "any", "of", "those", "interfaces", ".", "If", "this", "is", "called", "before", "all", "types", "are", "resolved", "it", "may"...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L539-L548
24,107
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getImplementedInterfaces
public final ImmutableList<ObjectType> getImplementedInterfaces() { FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor == null) { return implementedInterfaces; } ImmutableList.Builder<ObjectType> builder = ImmutableList.builder(); builder.addAll(impleme...
java
public final ImmutableList<ObjectType> getImplementedInterfaces() { FunctionType superCtor = isConstructor() ? getSuperClassConstructor() : null; if (superCtor == null) { return implementedInterfaces; } ImmutableList.Builder<ObjectType> builder = ImmutableList.builder(); builder.addAll(impleme...
[ "public", "final", "ImmutableList", "<", "ObjectType", ">", "getImplementedInterfaces", "(", ")", "{", "FunctionType", "superCtor", "=", "isConstructor", "(", ")", "?", "getSuperClassConstructor", "(", ")", ":", "null", ";", "if", "(", "superCtor", "==", "null",...
Returns interfaces implemented directly by a class or its superclass.
[ "Returns", "interfaces", "implemented", "directly", "by", "a", "class", "or", "its", "superclass", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L578-L590
24,108
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getBindReturnType
public final FunctionType getBindReturnType(int argsToBind) { Builder builder = builder(registry) .withReturnType(getReturnType()) .withTemplateKeys(getTemplateTypeMap().getTemplateKeys()); if (argsToBind >= 0) { Node origParams = getParametersNode(); if (origParams !...
java
public final FunctionType getBindReturnType(int argsToBind) { Builder builder = builder(registry) .withReturnType(getReturnType()) .withTemplateKeys(getTemplateTypeMap().getTemplateKeys()); if (argsToBind >= 0) { Node origParams = getParametersNode(); if (origParams !...
[ "public", "final", "FunctionType", "getBindReturnType", "(", "int", "argsToBind", ")", "{", "Builder", "builder", "=", "builder", "(", "registry", ")", ".", "withReturnType", "(", "getReturnType", "(", ")", ")", ".", "withTemplateKeys", "(", "getTemplateTypeMap", ...
Get the return value of calling "bind" on this function with the specified number of arguments. <p>If -1 is passed, then we will return a result that accepts any parameters.
[ "Get", "the", "return", "value", "of", "calling", "bind", "on", "this", "function", "with", "the", "specified", "number", "of", "arguments", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L670-L689
24,109
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.checkFunctionEquivalenceHelper
final boolean checkFunctionEquivalenceHelper( FunctionType that, EquivalenceMethod eqMethod, EqCache eqCache) { if (this == that) { return true; } if (kind != that.kind) { return false; } switch (kind) { case CONSTRUCTOR: return false; // constructors use identity sem...
java
final boolean checkFunctionEquivalenceHelper( FunctionType that, EquivalenceMethod eqMethod, EqCache eqCache) { if (this == that) { return true; } if (kind != that.kind) { return false; } switch (kind) { case CONSTRUCTOR: return false; // constructors use identity sem...
[ "final", "boolean", "checkFunctionEquivalenceHelper", "(", "FunctionType", "that", ",", "EquivalenceMethod", "eqMethod", ",", "EqCache", "eqCache", ")", "{", "if", "(", "this", "==", "that", ")", "{", "return", "true", ";", "}", "if", "(", "kind", "!=", "tha...
Two function types are equal if their signatures match. Since they don't have signatures, two interfaces are equal if their names match.
[ "Two", "function", "types", "are", "equal", "if", "their", "signatures", "match", ".", "Since", "they", "don", "t", "have", "signatures", "two", "interfaces", "are", "equal", "if", "their", "names", "match", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L902-L921
24,110
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.appendVarArgsString
private void appendVarArgsString(StringBuilder sb, JSType paramType, boolean forAnnotations) { sb.append("..."); paramType.appendAsNonNull(sb, forAnnotations); }
java
private void appendVarArgsString(StringBuilder sb, JSType paramType, boolean forAnnotations) { sb.append("..."); paramType.appendAsNonNull(sb, forAnnotations); }
[ "private", "void", "appendVarArgsString", "(", "StringBuilder", "sb", ",", "JSType", "paramType", ",", "boolean", "forAnnotations", ")", "{", "sb", ".", "append", "(", "\"...\"", ")", ";", "paramType", ".", "appendAsNonNull", "(", "sb", ",", "forAnnotations", ...
Gets the string representation of a var args param.
[ "Gets", "the", "string", "representation", "of", "a", "var", "args", "param", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1011-L1014
24,111
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.appendOptionalArgString
private void appendOptionalArgString(StringBuilder sb, JSType paramType, boolean forAnnotations) { if (paramType.isUnionType()) { // Remove the optionality from the var arg. paramType = paramType .toMaybeUnionType() .getRestrictedUnion(registry.getNativeType(JSTypeN...
java
private void appendOptionalArgString(StringBuilder sb, JSType paramType, boolean forAnnotations) { if (paramType.isUnionType()) { // Remove the optionality from the var arg. paramType = paramType .toMaybeUnionType() .getRestrictedUnion(registry.getNativeType(JSTypeN...
[ "private", "void", "appendOptionalArgString", "(", "StringBuilder", "sb", ",", "JSType", "paramType", ",", "boolean", "forAnnotations", ")", "{", "if", "(", "paramType", ".", "isUnionType", "(", ")", ")", "{", "// Remove the optionality from the var arg.", "paramType"...
Gets the string representation of an optional param.
[ "Gets", "the", "string", "representation", "of", "an", "optional", "param", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1017-L1026
24,112
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.setSource
public final void setSource(Node source) { if (prototypeSlot != null) { // NOTE(bashir): On one hand when source is null we want to drop any // references to old nodes retained in prototypeSlot. On the other hand // we cannot simply drop prototypeSlot, so we retain all information // except ...
java
public final void setSource(Node source) { if (prototypeSlot != null) { // NOTE(bashir): On one hand when source is null we want to drop any // references to old nodes retained in prototypeSlot. On the other hand // we cannot simply drop prototypeSlot, so we retain all information // except ...
[ "public", "final", "void", "setSource", "(", "Node", "source", ")", "{", "if", "(", "prototypeSlot", "!=", "null", ")", "{", "// NOTE(bashir): On one hand when source is null we want to drop any", "// references to old nodes retained in prototypeSlot. On the other hand", "// we c...
Sets the source node.
[ "Sets", "the", "source", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1131-L1148
24,113
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.addSubType
private void addSubType(FunctionType subType) { if (subTypes == null) { subTypes = new ArrayList<>(); } subTypes.add(subType); }
java
private void addSubType(FunctionType subType) { if (subTypes == null) { subTypes = new ArrayList<>(); } subTypes.add(subType); }
[ "private", "void", "addSubType", "(", "FunctionType", "subType", ")", "{", "if", "(", "subTypes", "==", "null", ")", "{", "subTypes", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "subTypes", ".", "add", "(", "subType", ")", ";", "}" ]
Adds a type to the list of subtypes for this type.
[ "Adds", "a", "type", "to", "the", "list", "of", "subtypes", "for", "this", "type", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1151-L1156
24,114
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.clearCachedValues
@Override public final void clearCachedValues() { super.clearCachedValues(); if (subTypes != null) { for (FunctionType subType : subTypes) { subType.clearCachedValues(); } } if (!isNativeObjectType()) { if (hasInstanceType()) { getInstanceType().clearCachedValues();...
java
@Override public final void clearCachedValues() { super.clearCachedValues(); if (subTypes != null) { for (FunctionType subType : subTypes) { subType.clearCachedValues(); } } if (!isNativeObjectType()) { if (hasInstanceType()) { getInstanceType().clearCachedValues();...
[ "@", "Override", "public", "final", "void", "clearCachedValues", "(", ")", "{", "super", ".", "clearCachedValues", "(", ")", ";", "if", "(", "subTypes", "!=", "null", ")", "{", "for", "(", "FunctionType", "subType", ":", "subTypes", ")", "{", "subType", ...
prototypeSlot is non-null, and this override does nothing to change that state.
[ "prototypeSlot", "is", "non", "-", "null", "and", "this", "override", "does", "nothing", "to", "change", "that", "state", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1177-L1196
24,115
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.resolveTypeListHelper
private ImmutableList<ObjectType> resolveTypeListHelper( ImmutableList<ObjectType> list, ErrorReporter reporter) { boolean changed = false; ImmutableList.Builder<ObjectType> resolvedList = ImmutableList.builder(); for (ObjectType type : list) { JSType rt = type.resolve(reporter); if (!rt.i...
java
private ImmutableList<ObjectType> resolveTypeListHelper( ImmutableList<ObjectType> list, ErrorReporter reporter) { boolean changed = false; ImmutableList.Builder<ObjectType> resolvedList = ImmutableList.builder(); for (ObjectType type : list) { JSType rt = type.resolve(reporter); if (!rt.i...
[ "private", "ImmutableList", "<", "ObjectType", ">", "resolveTypeListHelper", "(", "ImmutableList", "<", "ObjectType", ">", "list", ",", "ErrorReporter", "reporter", ")", "{", "boolean", "changed", "=", "false", ";", "ImmutableList", ".", "Builder", "<", "ObjectTyp...
Resolve each item in the list, and return a new list if any references changed. Otherwise, return null.
[ "Resolve", "each", "item", "in", "the", "list", "and", "return", "a", "new", "list", "if", "any", "references", "changed", ".", "Otherwise", "return", "null", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1260-L1279
24,116
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getPropertyTypeMap
@Override public final Map<String, JSType> getPropertyTypeMap() { Map<String, JSType> propTypeMap = new LinkedHashMap<>(); updatePropertyTypeMap(this, propTypeMap, new HashSet<FunctionType>()); return propTypeMap; }
java
@Override public final Map<String, JSType> getPropertyTypeMap() { Map<String, JSType> propTypeMap = new LinkedHashMap<>(); updatePropertyTypeMap(this, propTypeMap, new HashSet<FunctionType>()); return propTypeMap; }
[ "@", "Override", "public", "final", "Map", "<", "String", ",", "JSType", ">", "getPropertyTypeMap", "(", ")", "{", "Map", "<", "String", ",", "JSType", ">", "propTypeMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "updatePropertyTypeMap", "(", "thi...
get the map of properties to types covered in a function type @return a Map that maps the property's name to the property's type
[ "get", "the", "map", "of", "properties", "to", "types", "covered", "in", "a", "function", "type" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1357-L1362
24,117
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.forgetParameterAndReturnTypes
public final FunctionType forgetParameterAndReturnTypes() { FunctionType result = builder(registry) .withName(getReferenceName()) .withSourceNode(source) .withTypeOfThis(getInstanceType()) .withKind(kind) .build(); result.setPrototypeBasedOn(ge...
java
public final FunctionType forgetParameterAndReturnTypes() { FunctionType result = builder(registry) .withName(getReferenceName()) .withSourceNode(source) .withTypeOfThis(getInstanceType()) .withKind(kind) .build(); result.setPrototypeBasedOn(ge...
[ "public", "final", "FunctionType", "forgetParameterAndReturnTypes", "(", ")", "{", "FunctionType", "result", "=", "builder", "(", "registry", ")", ".", "withName", "(", "getReferenceName", "(", ")", ")", ".", "withSourceNode", "(", "source", ")", ".", "withTypeO...
Create a new constructor with the parameters and return type stripped.
[ "Create", "a", "new", "constructor", "with", "the", "parameters", "and", "return", "type", "stripped", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1463-L1473
24,118
google/closure-compiler
src/com/google/javascript/rhino/jstype/FunctionType.java
FunctionType.getConstructorOnlyTemplateParameters
public final ImmutableList<TemplateType> getConstructorOnlyTemplateParameters() { TemplateTypeMap ctorMap = getTemplateTypeMap(); TemplateTypeMap instanceMap = getInstanceType().getTemplateTypeMap(); if (ctorMap == instanceMap) { return ImmutableList.of(); } ImmutableList.Builder<TemplateType>...
java
public final ImmutableList<TemplateType> getConstructorOnlyTemplateParameters() { TemplateTypeMap ctorMap = getTemplateTypeMap(); TemplateTypeMap instanceMap = getInstanceType().getTemplateTypeMap(); if (ctorMap == instanceMap) { return ImmutableList.of(); } ImmutableList.Builder<TemplateType>...
[ "public", "final", "ImmutableList", "<", "TemplateType", ">", "getConstructorOnlyTemplateParameters", "(", ")", "{", "TemplateTypeMap", "ctorMap", "=", "getTemplateTypeMap", "(", ")", ";", "TemplateTypeMap", "instanceMap", "=", "getInstanceType", "(", ")", ".", "getTe...
Returns a list of template types present on the constructor but not on the instance.
[ "Returns", "a", "list", "of", "template", "types", "present", "on", "the", "constructor", "but", "not", "on", "the", "instance", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/FunctionType.java#L1476-L1490
24,119
google/closure-compiler
src/com/google/javascript/jscomp/PreprocessorSymbolTable.java
PreprocessorSymbolTable.addStringNode
void addStringNode(Node n, AbstractCompiler compiler) { String name = n.getString(); Node syntheticRef = NodeUtil.newQName( compiler, name, n /* real source offsets will be filled in below */, name); // Offsets to add to source. Named for documentation purposes. final int forQuote =...
java
void addStringNode(Node n, AbstractCompiler compiler) { String name = n.getString(); Node syntheticRef = NodeUtil.newQName( compiler, name, n /* real source offsets will be filled in below */, name); // Offsets to add to source. Named for documentation purposes. final int forQuote =...
[ "void", "addStringNode", "(", "Node", "n", ",", "AbstractCompiler", "compiler", ")", "{", "String", "name", "=", "n", ".", "getString", "(", ")", ";", "Node", "syntheticRef", "=", "NodeUtil", ".", "newQName", "(", "compiler", ",", "name", ",", "n", "/* r...
Adds a synthetic reference for a 'string' node representing a reference name. <p>This does some work to set the source info for the reference as well.
[ "Adds", "a", "synthetic", "reference", "for", "a", "string", "node", "representing", "a", "reference", "name", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PreprocessorSymbolTable.java#L165-L193
24,120
google/closure-compiler
src/com/google/javascript/jscomp/GlobalVarReferenceMap.java
GlobalVarReferenceMap.resetGlobalVarReferences
private void resetGlobalVarReferences( Map<Var, ReferenceCollection> globalRefMap) { refMap = new LinkedHashMap<>(); for (Entry<Var, ReferenceCollection> entry : globalRefMap.entrySet()) { Var var = entry.getKey(); if (var.isGlobal()) { refMap.put(var.getName(), entry.getValue()); ...
java
private void resetGlobalVarReferences( Map<Var, ReferenceCollection> globalRefMap) { refMap = new LinkedHashMap<>(); for (Entry<Var, ReferenceCollection> entry : globalRefMap.entrySet()) { Var var = entry.getKey(); if (var.isGlobal()) { refMap.put(var.getName(), entry.getValue()); ...
[ "private", "void", "resetGlobalVarReferences", "(", "Map", "<", "Var", ",", "ReferenceCollection", ">", "globalRefMap", ")", "{", "refMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "for", "(", "Entry", "<", "Var", ",", "ReferenceCollection", ">", "e...
Resets global var reference map with the new provide map. @param globalRefMap The reference map result of a {@link ReferenceCollectingCallback} pass collected from the whole AST.
[ "Resets", "global", "var", "reference", "map", "with", "the", "new", "provide", "map", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GlobalVarReferenceMap.java#L75-L84
24,121
google/closure-compiler
src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java
DevirtualizePrototypeMethods.isPrototypeMethodDefinition
private static boolean isPrototypeMethodDefinition(Node node) { Node parent = node.getParent(); Node grandparent = node.getGrandparent(); if (parent == null || grandparent == null) { return false; } switch (node.getToken()) { case MEMBER_FUNCTION_DEF: if (NodeUtil.isEs6Construct...
java
private static boolean isPrototypeMethodDefinition(Node node) { Node parent = node.getParent(); Node grandparent = node.getGrandparent(); if (parent == null || grandparent == null) { return false; } switch (node.getToken()) { case MEMBER_FUNCTION_DEF: if (NodeUtil.isEs6Construct...
[ "private", "static", "boolean", "isPrototypeMethodDefinition", "(", "Node", "node", ")", "{", "Node", "parent", "=", "node", ".", "getParent", "(", ")", ";", "Node", "grandparent", "=", "node", ".", "getGrandparent", "(", ")", ";", "if", "(", "parent", "==...
Determines if the current node is a function prototype definition.
[ "Determines", "if", "the", "current", "node", "is", "a", "function", "prototype", "definition", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L136-L203
24,122
google/closure-compiler
src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java
DevirtualizePrototypeMethods.isEligibleDefinitionSite
private boolean isEligibleDefinitionSite(String name, Node definitionSite) { switch (definitionSite.getToken()) { case GETPROP: case MEMBER_FUNCTION_DEF: case STRING_KEY: break; default: // No other node types are supported. throw new IllegalArgumentException(definit...
java
private boolean isEligibleDefinitionSite(String name, Node definitionSite) { switch (definitionSite.getToken()) { case GETPROP: case MEMBER_FUNCTION_DEF: case STRING_KEY: break; default: // No other node types are supported. throw new IllegalArgumentException(definit...
[ "private", "boolean", "isEligibleDefinitionSite", "(", "String", "name", ",", "Node", "definitionSite", ")", "{", "switch", "(", "definitionSite", ".", "getToken", "(", ")", ")", "{", "case", "GETPROP", ":", "case", "MEMBER_FUNCTION_DEF", ":", "case", "STRING_KE...
Determines if a method definition site is eligible for rewrite as a global. <p>In order to be eligible for rewrite, the definition site must: <ul> <li>Not be exported <li>Be for a prototype method </ul>
[ "Determines", "if", "a", "method", "definition", "site", "is", "eligible", "for", "rewrite", "as", "a", "global", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L215-L238
24,123
google/closure-compiler
src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java
DevirtualizePrototypeMethods.isEligibleDefinitionFunction
private boolean isEligibleDefinitionFunction(Node definitionFunction) { checkArgument(definitionFunction.isFunction(), definitionFunction); if (definitionFunction.isArrowFunction()) { return false; } for (Node ancestor = definitionFunction.getParent(); ancestor != null; ancestor ...
java
private boolean isEligibleDefinitionFunction(Node definitionFunction) { checkArgument(definitionFunction.isFunction(), definitionFunction); if (definitionFunction.isArrowFunction()) { return false; } for (Node ancestor = definitionFunction.getParent(); ancestor != null; ancestor ...
[ "private", "boolean", "isEligibleDefinitionFunction", "(", "Node", "definitionFunction", ")", "{", "checkArgument", "(", "definitionFunction", ".", "isFunction", "(", ")", ",", "definitionFunction", ")", ";", "if", "(", "definitionFunction", ".", "isArrowFunction", "(...
Determines if a method definition function is eligible for rewrite as a global function. <p>In order to be eligible for rewrite, the definition function must: <ul> <li>Be instantiated exactly once <li>Be the only possible implementation at a given site <li>Not refer to its `arguments`; no implicit varags <li>Not be a...
[ "Determines", "if", "a", "method", "definition", "function", "is", "eligible", "for", "rewrite", "as", "a", "global", "function", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L252-L289
24,124
google/closure-compiler
src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java
DevirtualizePrototypeMethods.rewriteCall
private void rewriteCall(Node getprop, String newMethodName) { checkArgument(getprop.isGetProp(), getprop); Node call = getprop.getParent(); checkArgument(call.isCall(), call); Node receiver = getprop.getFirstChild(); // This rewriting does not exactly preserve order of operations; the newly insert...
java
private void rewriteCall(Node getprop, String newMethodName) { checkArgument(getprop.isGetProp(), getprop); Node call = getprop.getParent(); checkArgument(call.isCall(), call); Node receiver = getprop.getFirstChild(); // This rewriting does not exactly preserve order of operations; the newly insert...
[ "private", "void", "rewriteCall", "(", "Node", "getprop", ",", "String", "newMethodName", ")", "{", "checkArgument", "(", "getprop", ".", "isGetProp", "(", ")", ",", "getprop", ")", ";", "Node", "call", "=", "getprop", ".", "getParent", "(", ")", ";", "c...
Rewrites object method call sites as calls to global functions that take "this" as their first argument. <p>Before: o.foo(a, b, c) <p>After: foo(o, a, b, c)
[ "Rewrites", "object", "method", "call", "sites", "as", "calls", "to", "global", "functions", "that", "take", "this", "as", "their", "first", "argument", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L363-L388
24,125
google/closure-compiler
src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java
DevirtualizePrototypeMethods.rewriteDefinition
private void rewriteDefinition(Node definitionSite, String newMethodName) { final Node function; final Node subtreeToRemove; final Node nameSource; switch (definitionSite.getToken()) { case GETPROP: function = definitionSite.getParent().getLastChild(); nameSource = definitionSite....
java
private void rewriteDefinition(Node definitionSite, String newMethodName) { final Node function; final Node subtreeToRemove; final Node nameSource; switch (definitionSite.getToken()) { case GETPROP: function = definitionSite.getParent().getLastChild(); nameSource = definitionSite....
[ "private", "void", "rewriteDefinition", "(", "Node", "definitionSite", ",", "String", "newMethodName", ")", "{", "final", "Node", "function", ";", "final", "Node", "subtreeToRemove", ";", "final", "Node", "nameSource", ";", "switch", "(", "definitionSite", ".", ...
Rewrites method definitions as global functions that take "this" as their first argument. <p>Before: a.prototype.b = function(a, b, c) {...} <p>After: var b = function(self, a, b, c) {...}
[ "Rewrites", "method", "definitions", "as", "global", "functions", "that", "take", "this", "as", "their", "first", "argument", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L397-L445
24,126
google/closure-compiler
src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java
DevirtualizePrototypeMethods.fixFunctionType
private void fixFunctionType(Node functionNode) { JSType t = functionNode.getJSType(); if (t == null) { return; } FunctionType ft = t.toMaybeFunctionType(); if (ft != null) { functionNode.setJSType(convertMethodToFunction(ft)); } }
java
private void fixFunctionType(Node functionNode) { JSType t = functionNode.getJSType(); if (t == null) { return; } FunctionType ft = t.toMaybeFunctionType(); if (ft != null) { functionNode.setJSType(convertMethodToFunction(ft)); } }
[ "private", "void", "fixFunctionType", "(", "Node", "functionNode", ")", "{", "JSType", "t", "=", "functionNode", ".", "getJSType", "(", ")", ";", "if", "(", "t", "==", "null", ")", "{", "return", ";", "}", "FunctionType", "ft", "=", "t", ".", "toMaybeF...
Creates a new type based on the original function type by adding the original this pointer type to the beginning of the argument type list and replacing the this pointer type with bottom.
[ "Creates", "a", "new", "type", "based", "on", "the", "original", "function", "type", "by", "adding", "the", "original", "this", "pointer", "type", "to", "the", "beginning", "of", "the", "argument", "type", "list", "and", "replacing", "the", "this", "pointer"...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L452-L461
24,127
google/closure-compiler
src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java
DevirtualizePrototypeMethods.replaceReferencesToThis
private void replaceReferencesToThis(Node node, String name) { if (node.isFunction() && !node.isArrowFunction()) { // Functions (besides arrows) create a new binding for `this`. return; } for (Node child : node.children()) { if (child.isThis()) { Node newName = IR.name(name).useSo...
java
private void replaceReferencesToThis(Node node, String name) { if (node.isFunction() && !node.isArrowFunction()) { // Functions (besides arrows) create a new binding for `this`. return; } for (Node child : node.children()) { if (child.isThis()) { Node newName = IR.name(name).useSo...
[ "private", "void", "replaceReferencesToThis", "(", "Node", "node", ",", "String", "name", ")", "{", "if", "(", "node", ".", "isFunction", "(", ")", "&&", "!", "node", ".", "isArrowFunction", "(", ")", ")", "{", "// Functions (besides arrows) create a new binding...
Replaces references to "this" with references to name. Do not traverse function boundaries.
[ "Replaces", "references", "to", "this", "with", "references", "to", "name", ".", "Do", "not", "traverse", "function", "boundaries", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DevirtualizePrototypeMethods.java#L475-L490
24,128
google/closure-compiler
src/com/google/javascript/jscomp/TypedCodeGenerator.java
TypedCodeGenerator.getParameterJSDocName
private String getParameterJSDocName(Node paramNode, int paramIndex) { Node nameNode = null; if (paramNode != null) { checkArgument(paramNode.getParent().isParamList(), paramNode); if (paramNode.isRest()) { // use `restParam` of `...restParam` // restParam might still be a destructur...
java
private String getParameterJSDocName(Node paramNode, int paramIndex) { Node nameNode = null; if (paramNode != null) { checkArgument(paramNode.getParent().isParamList(), paramNode); if (paramNode.isRest()) { // use `restParam` of `...restParam` // restParam might still be a destructur...
[ "private", "String", "getParameterJSDocName", "(", "Node", "paramNode", ",", "int", "paramIndex", ")", "{", "Node", "nameNode", "=", "null", ";", "if", "(", "paramNode", "!=", "null", ")", "{", "checkArgument", "(", "paramNode", ".", "getParent", "(", ")", ...
Return the name of the parameter to be used in JSDoc, generating one for destructuring parameters. @param paramNode child node of a parameter list @param paramIndex position of child in the list @return name to use in JSDoc
[ "Return", "the", "name", "of", "the", "parameter", "to", "be", "used", "in", "JSDoc", "generating", "one", "for", "destructuring", "parameters", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypedCodeGenerator.java#L308-L334
24,129
google/closure-compiler
src/com/google/javascript/jscomp/TypedCodeGenerator.java
TypedCodeGenerator.appendClassAnnotations
private void appendClassAnnotations(StringBuilder sb, FunctionType funType) { FunctionType superConstructor = funType.getInstanceType().getSuperClassConstructor(); if (superConstructor != null) { ObjectType superInstance = superConstructor.getInstanceType(); if (!superInstance.toString().equals("Obj...
java
private void appendClassAnnotations(StringBuilder sb, FunctionType funType) { FunctionType superConstructor = funType.getInstanceType().getSuperClassConstructor(); if (superConstructor != null) { ObjectType superInstance = superConstructor.getInstanceType(); if (!superInstance.toString().equals("Obj...
[ "private", "void", "appendClassAnnotations", "(", "StringBuilder", "sb", ",", "FunctionType", "funType", ")", "{", "FunctionType", "superConstructor", "=", "funType", ".", "getInstanceType", "(", ")", ".", "getSuperClassConstructor", "(", ")", ";", "if", "(", "sup...
we should print it first, like users write it. Same for @interface and @record.
[ "we", "should", "print", "it", "first", "like", "users", "write", "it", ".", "Same", "for" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypedCodeGenerator.java#L342-L362
24,130
google/closure-compiler
src/com/google/javascript/jscomp/TypedCodeGenerator.java
TypedCodeGenerator.getParameterJSDocType
private String getParameterJSDocType(List<JSType> types, int index, int minArgs, int maxArgs) { JSType type = types.get(index); if (index < minArgs) { return type.toAnnotationString(Nullability.EXPLICIT); } boolean isRestArgument = maxArgs == Integer.MAX_VALUE && index == types.size() - 1; if ...
java
private String getParameterJSDocType(List<JSType> types, int index, int minArgs, int maxArgs) { JSType type = types.get(index); if (index < minArgs) { return type.toAnnotationString(Nullability.EXPLICIT); } boolean isRestArgument = maxArgs == Integer.MAX_VALUE && index == types.size() - 1; if ...
[ "private", "String", "getParameterJSDocType", "(", "List", "<", "JSType", ">", "types", ",", "int", "index", ",", "int", "minArgs", ",", "int", "maxArgs", ")", "{", "JSType", "type", "=", "types", ".", "get", "(", "index", ")", ";", "if", "(", "index",...
Creates a JSDoc-suitable String representation of the type of a parameter.
[ "Creates", "a", "JSDoc", "-", "suitable", "String", "representation", "of", "the", "type", "of", "a", "parameter", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypedCodeGenerator.java#L412-L422
24,131
google/closure-compiler
src/com/google/javascript/jscomp/TypedCodeGenerator.java
TypedCodeGenerator.restrictByUndefined
private JSType restrictByUndefined(JSType type) { // If not voidable, there's nothing to do. If not nullable then the easiest // thing is to simply remove both null and undefined. If nullable, then add // null back into the union after removing null and undefined. if (!type.isVoidable()) { return ...
java
private JSType restrictByUndefined(JSType type) { // If not voidable, there's nothing to do. If not nullable then the easiest // thing is to simply remove both null and undefined. If nullable, then add // null back into the union after removing null and undefined. if (!type.isVoidable()) { return ...
[ "private", "JSType", "restrictByUndefined", "(", "JSType", "type", ")", "{", "// If not voidable, there's nothing to do. If not nullable then the easiest", "// thing is to simply remove both null and undefined. If nullable, then add", "// null back into the union after removing null and undefine...
Removes undefined from a union type.
[ "Removes", "undefined", "from", "a", "union", "type", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypedCodeGenerator.java#L425-L439
24,132
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.validateClassLevelJsDoc
private void validateClassLevelJsDoc(Node n, JSDocInfo info) { if (info != null && n.isMemberFunctionDef() && hasClassLevelJsDoc(info)) { report(n, DISALLOWED_MEMBER_JSDOC); } }
java
private void validateClassLevelJsDoc(Node n, JSDocInfo info) { if (info != null && n.isMemberFunctionDef() && hasClassLevelJsDoc(info)) { report(n, DISALLOWED_MEMBER_JSDOC); } }
[ "private", "void", "validateClassLevelJsDoc", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "if", "(", "info", "!=", "null", "&&", "n", ".", "isMemberFunctionDef", "(", ")", "&&", "hasClassLevelJsDoc", "(", "info", ")", ")", "{", "report", "(", "...
Checks that class-level annotations like @interface/@extends are not used on member functions.
[ "Checks", "that", "class", "-", "level", "annotations", "like" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L310-L315
24,133
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.validateDeprecatedJsDoc
private void validateDeprecatedJsDoc(Node n, JSDocInfo info) { if (info != null && info.isExpose()) { report(n, ANNOTATION_DEPRECATED, "@expose", "Use @nocollapse or @export instead."); } }
java
private void validateDeprecatedJsDoc(Node n, JSDocInfo info) { if (info != null && info.isExpose()) { report(n, ANNOTATION_DEPRECATED, "@expose", "Use @nocollapse or @export instead."); } }
[ "private", "void", "validateDeprecatedJsDoc", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "if", "(", "info", "!=", "null", "&&", "info", ".", "isExpose", "(", ")", ")", "{", "report", "(", "n", ",", "ANNOTATION_DEPRECATED", ",", "\"@expose\"", ...
Checks that deprecated annotations such as @expose are not present
[ "Checks", "that", "deprecated", "annotations", "such", "as" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L387-L392
24,134
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.validateNoCollapse
private void validateNoCollapse(Node n, JSDocInfo info) { if (n.isFromExterns()) { if (info != null && info.isNoCollapse()) { // @nocollapse has no effect in externs reportMisplaced(n, "nocollapse", "This JSDoc has no effect in externs."); } return; } if (!NodeUtil.isProtot...
java
private void validateNoCollapse(Node n, JSDocInfo info) { if (n.isFromExterns()) { if (info != null && info.isNoCollapse()) { // @nocollapse has no effect in externs reportMisplaced(n, "nocollapse", "This JSDoc has no effect in externs."); } return; } if (!NodeUtil.isProtot...
[ "private", "void", "validateNoCollapse", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "if", "(", "n", ".", "isFromExterns", "(", ")", ")", "{", "if", "(", "info", "!=", "null", "&&", "info", ".", "isNoCollapse", "(", ")", ")", "{", "// @noco...
Warns when nocollapse annotations are present on nodes which are not eligible for property collapsing.
[ "Warns", "when", "nocollapse", "annotations", "are", "present", "on", "nodes", "which", "are", "not", "eligible", "for", "property", "collapsing", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L398-L413
24,135
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.validateFunctionJsDoc
private void validateFunctionJsDoc(Node n, JSDocInfo info) { if (info == null) { return; } if (info.containsFunctionDeclaration() && !info.hasType() && !isJSDocOnFunctionNode(n, info)) { // This JSDoc should be attached to a FUNCTION node, or an assignment // with a function as the RHS, e...
java
private void validateFunctionJsDoc(Node n, JSDocInfo info) { if (info == null) { return; } if (info.containsFunctionDeclaration() && !info.hasType() && !isJSDocOnFunctionNode(n, info)) { // This JSDoc should be attached to a FUNCTION node, or an assignment // with a function as the RHS, e...
[ "private", "void", "validateFunctionJsDoc", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "if", "(", "info", "==", "null", ")", "{", "return", ";", "}", "if", "(", "info", ".", "containsFunctionDeclaration", "(", ")", "&&", "!", "info", ".", "h...
Checks that JSDoc intended for a function is actually attached to a function.
[ "Checks", "that", "JSDoc", "intended", "for", "a", "function", "is", "actually", "attached", "to", "a", "function", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L419-L433
24,136
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.isJSDocOnFunctionNode
private boolean isJSDocOnFunctionNode(Node n, JSDocInfo info) { switch (n.getToken()) { case FUNCTION: case GETTER_DEF: case SETTER_DEF: case MEMBER_FUNCTION_DEF: case STRING_KEY: case COMPUTED_PROP: case EXPORT: return true; case GETELEM: case GETPROP: ...
java
private boolean isJSDocOnFunctionNode(Node n, JSDocInfo info) { switch (n.getToken()) { case FUNCTION: case GETTER_DEF: case SETTER_DEF: case MEMBER_FUNCTION_DEF: case STRING_KEY: case COMPUTED_PROP: case EXPORT: return true; case GETELEM: case GETPROP: ...
[ "private", "boolean", "isJSDocOnFunctionNode", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "FUNCTION", ":", "case", "GETTER_DEF", ":", "case", "SETTER_DEF", ":", "case", "MEMBER_FUN...
Whether this node's JSDoc may apply to a function <p>This has some false positive cases, to allow for patterns like goog.abstractMethod.
[ "Whether", "this", "node", "s", "JSDoc", "may", "apply", "to", "a", "function" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L440-L476
24,137
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.isValidMsgName
private boolean isValidMsgName(Node nameNode) { if (nameNode.isName() || nameNode.isStringKey()) { return nameNode.getString().startsWith("MSG_"); } else if (nameNode.isQualifiedName()) { return nameNode.getLastChild().getString().startsWith("MSG_"); } else { return false; } }
java
private boolean isValidMsgName(Node nameNode) { if (nameNode.isName() || nameNode.isStringKey()) { return nameNode.getString().startsWith("MSG_"); } else if (nameNode.isQualifiedName()) { return nameNode.getLastChild().getString().startsWith("MSG_"); } else { return false; } }
[ "private", "boolean", "isValidMsgName", "(", "Node", "nameNode", ")", "{", "if", "(", "nameNode", ".", "isName", "(", ")", "||", "nameNode", ".", "isStringKey", "(", ")", ")", "{", "return", "nameNode", ".", "getString", "(", ")", ".", "startsWith", "(",...
Returns whether of not the given name is valid target for the result of goog.getMsg
[ "Returns", "whether", "of", "not", "the", "given", "name", "is", "valid", "target", "for", "the", "result", "of", "goog", ".", "getMsg" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L519-L527
24,138
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.isTypeAnnotationAllowedForName
private boolean isTypeAnnotationAllowedForName(Node n) { checkState(n.isName(), n); // Only allow type annotations on nodes used as an lvalue. if (!NodeUtil.isLValue(n)) { return false; } // Don't allow JSDoc on a name in an assignment. Simple names should only have JSDoc on them // when o...
java
private boolean isTypeAnnotationAllowedForName(Node n) { checkState(n.isName(), n); // Only allow type annotations on nodes used as an lvalue. if (!NodeUtil.isLValue(n)) { return false; } // Don't allow JSDoc on a name in an assignment. Simple names should only have JSDoc on them // when o...
[ "private", "boolean", "isTypeAnnotationAllowedForName", "(", "Node", "n", ")", "{", "checkState", "(", "n", ".", "isName", "(", ")", ",", "n", ")", ";", "// Only allow type annotations on nodes used as an lvalue.", "if", "(", "!", "NodeUtil", ".", "isLValue", "(",...
Is it valid to have a type annotation on the given NAME node?
[ "Is", "it", "valid", "to", "have", "a", "type", "annotation", "on", "the", "given", "NAME", "node?" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L597-L607
24,139
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.validateImplicitCast
private void validateImplicitCast(Node n, JSDocInfo info) { if (!inExterns && info != null && info.isImplicitCast()) { report(n, TypeCheck.ILLEGAL_IMPLICIT_CAST); } }
java
private void validateImplicitCast(Node n, JSDocInfo info) { if (!inExterns && info != null && info.isImplicitCast()) { report(n, TypeCheck.ILLEGAL_IMPLICIT_CAST); } }
[ "private", "void", "validateImplicitCast", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "if", "(", "!", "inExterns", "&&", "info", "!=", "null", "&&", "info", ".", "isImplicitCast", "(", ")", ")", "{", "report", "(", "n", ",", "TypeCheck", "."...
Checks that an @implicitCast annotation is in the externs
[ "Checks", "that", "an" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L685-L689
24,140
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.validateClosurePrimitive
private void validateClosurePrimitive(Node n, JSDocInfo info) { if (info == null || !info.hasClosurePrimitiveId()) { return; } if (!isJSDocOnFunctionNode(n, info)) { report(n, MISPLACED_ANNOTATION, "closurePrimitive", "must be on a function node"); } }
java
private void validateClosurePrimitive(Node n, JSDocInfo info) { if (info == null || !info.hasClosurePrimitiveId()) { return; } if (!isJSDocOnFunctionNode(n, info)) { report(n, MISPLACED_ANNOTATION, "closurePrimitive", "must be on a function node"); } }
[ "private", "void", "validateClosurePrimitive", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "if", "(", "info", "==", "null", "||", "!", "info", ".", "hasClosurePrimitiveId", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "isJSDocOnFunct...
Checks that a @closurePrimitive {id} is on a function
[ "Checks", "that", "a" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L692-L700
24,141
google/closure-compiler
src/com/google/javascript/jscomp/CheckJSDoc.java
CheckJSDoc.validateReturnJsDoc
private void validateReturnJsDoc(Node n, JSDocInfo info) { if (!n.isReturn() || info == null) { return; } // @type is handled in validateTypeAnnotations method. if (info.containsDeclaration() && !info.hasType()) { report(n, JSDOC_ON_RETURN); } }
java
private void validateReturnJsDoc(Node n, JSDocInfo info) { if (!n.isReturn() || info == null) { return; } // @type is handled in validateTypeAnnotations method. if (info.containsDeclaration() && !info.hasType()) { report(n, JSDOC_ON_RETURN); } }
[ "private", "void", "validateReturnJsDoc", "(", "Node", "n", ",", "JSDocInfo", "info", ")", "{", "if", "(", "!", "n", ".", "isReturn", "(", ")", "||", "info", "==", "null", ")", "{", "return", ";", "}", "// @type is handled in validateTypeAnnotations method.", ...
Checks that there are no annotations on return.
[ "Checks", "that", "there", "are", "no", "annotations", "on", "return", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckJSDoc.java#L703-L711
24,142
google/closure-compiler
src/com/google/javascript/jscomp/DestructuringGlobalNameExtractor.java
DestructuringGlobalNameExtractor.addAfter
private static void addAfter(Node originalLvalue, Node newLvalue, Node newRvalue) { Node parent = originalLvalue.getParent(); if (parent.isAssign()) { // create `(<originalLvalue = ...>, <newLvalue = newRvalue>)` Node newAssign = IR.assign(newLvalue, newRvalue).srcref(parent); Node newComma = ...
java
private static void addAfter(Node originalLvalue, Node newLvalue, Node newRvalue) { Node parent = originalLvalue.getParent(); if (parent.isAssign()) { // create `(<originalLvalue = ...>, <newLvalue = newRvalue>)` Node newAssign = IR.assign(newLvalue, newRvalue).srcref(parent); Node newComma = ...
[ "private", "static", "void", "addAfter", "(", "Node", "originalLvalue", ",", "Node", "newLvalue", ",", "Node", "newRvalue", ")", "{", "Node", "parent", "=", "originalLvalue", ".", "getParent", "(", ")", ";", "if", "(", "parent", ".", "isAssign", "(", ")", ...
Adds the new assign or name declaration after the original assign or name declaration
[ "Adds", "the", "new", "assign", "or", "name", "declaration", "after", "the", "original", "assign", "or", "name", "declaration" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DestructuringGlobalNameExtractor.java#L115-L146
24,143
google/closure-compiler
src/com/google/javascript/jscomp/DestructuringGlobalNameExtractor.java
DestructuringGlobalNameExtractor.makeNewRvalueForDestructuringKey
private static Node makeNewRvalueForDestructuringKey( Node stringKey, Node rvalue, Set<AstChange> newNodes, Ref ref) { if (stringKey.getOnlyChild().isDefaultValue()) { Node defaultValue = stringKey.getFirstChild().getSecondChild().detach(); // Assume `rvalue` has no side effects since it's a qname...
java
private static Node makeNewRvalueForDestructuringKey( Node stringKey, Node rvalue, Set<AstChange> newNodes, Ref ref) { if (stringKey.getOnlyChild().isDefaultValue()) { Node defaultValue = stringKey.getFirstChild().getSecondChild().detach(); // Assume `rvalue` has no side effects since it's a qname...
[ "private", "static", "Node", "makeNewRvalueForDestructuringKey", "(", "Node", "stringKey", ",", "Node", "rvalue", ",", "Set", "<", "AstChange", ">", "newNodes", ",", "Ref", "ref", ")", "{", "if", "(", "stringKey", ".", "getOnlyChild", "(", ")", ".", "isDefau...
Makes a default value expression from the rvalue, or otherwise just returns it <p>e.g. for `const {x = defaultValue} = y;`, and the new rvalue `rvalue`, returns `void 0 === rvalue ? defaultValue : rvalue`
[ "Makes", "a", "default", "value", "expression", "from", "the", "rvalue", "or", "otherwise", "just", "returns", "it" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DestructuringGlobalNameExtractor.java#L176-L192
24,144
google/closure-compiler
src/com/google/javascript/jscomp/DestructuringGlobalNameExtractor.java
DestructuringGlobalNameExtractor.createNewObjectPatternFromSuccessiveKeys
private static Node createNewObjectPatternFromSuccessiveKeys(Node stringKey) { Node newPattern = stringKey.getParent().cloneNode(); // copies the JSType for (Node next = stringKey.getNext(); next != null; ) { Node newKey = next; next = newKey.getNext(); newPattern.addChildToBack(newKey.detach(...
java
private static Node createNewObjectPatternFromSuccessiveKeys(Node stringKey) { Node newPattern = stringKey.getParent().cloneNode(); // copies the JSType for (Node next = stringKey.getNext(); next != null; ) { Node newKey = next; next = newKey.getNext(); newPattern.addChildToBack(newKey.detach(...
[ "private", "static", "Node", "createNewObjectPatternFromSuccessiveKeys", "(", "Node", "stringKey", ")", "{", "Node", "newPattern", "=", "stringKey", ".", "getParent", "(", ")", ".", "cloneNode", "(", ")", ";", "// copies the JSType", "for", "(", "Node", "next", ...
Removes any keys after the given key, and adds them in order to a new object pattern
[ "Removes", "any", "keys", "after", "the", "given", "key", "and", "adds", "them", "in", "order", "to", "a", "new", "object", "pattern" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DestructuringGlobalNameExtractor.java#L195-L203
24,145
google/closure-compiler
src/com/google/javascript/rhino/jstype/UnionType.java
UnionType.rebuildAlternates
private void rebuildAlternates() { UnionTypeBuilder builder = UnionTypeBuilder.create(registry); builder.addAlternates(alternates); alternates = builder.getAlternates(); }
java
private void rebuildAlternates() { UnionTypeBuilder builder = UnionTypeBuilder.create(registry); builder.addAlternates(alternates); alternates = builder.getAlternates(); }
[ "private", "void", "rebuildAlternates", "(", ")", "{", "UnionTypeBuilder", "builder", "=", "UnionTypeBuilder", ".", "create", "(", "registry", ")", ";", "builder", ".", "addAlternates", "(", "alternates", ")", ";", "alternates", "=", "builder", ".", "getAlternat...
Use UnionTypeBuilder to rebuild the list of alternates and hashcode of the current UnionType.
[ "Use", "UnionTypeBuilder", "to", "rebuild", "the", "list", "of", "alternates", "and", "hashcode", "of", "the", "current", "UnionType", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/UnionType.java#L107-L111
24,146
google/closure-compiler
src/com/google/javascript/rhino/jstype/UnionType.java
UnionType.checkUnionEquivalenceHelper
boolean checkUnionEquivalenceHelper(UnionType that, EquivalenceMethod eqMethod, EqCache eqCache) { List<JSType> thatAlternates = that.getAlternates(); if (eqMethod == EquivalenceMethod.IDENTITY && alternates.size() != thatAlternates.size()) { return false; } for (int i = 0; i < thatAlternates.size...
java
boolean checkUnionEquivalenceHelper(UnionType that, EquivalenceMethod eqMethod, EqCache eqCache) { List<JSType> thatAlternates = that.getAlternates(); if (eqMethod == EquivalenceMethod.IDENTITY && alternates.size() != thatAlternates.size()) { return false; } for (int i = 0; i < thatAlternates.size...
[ "boolean", "checkUnionEquivalenceHelper", "(", "UnionType", "that", ",", "EquivalenceMethod", "eqMethod", ",", "EqCache", "eqCache", ")", "{", "List", "<", "JSType", ">", "thatAlternates", "=", "that", ".", "getAlternates", "(", ")", ";", "if", "(", "eqMethod", ...
Two union types are equal if, after flattening nested union types, they have the same number of alternates and all alternates are equal.
[ "Two", "union", "types", "are", "equal", "if", "after", "flattening", "nested", "union", "types", "they", "have", "the", "same", "number", "of", "alternates", "and", "all", "alternates", "are", "equal", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/UnionType.java#L339-L351
24,147
google/closure-compiler
src/com/google/javascript/jscomp/RewritePolyfills.java
RewritePolyfills.removeUnneededPolyfills
private void removeUnneededPolyfills(Node parent, Node runtimeEnd) { Node node = parent.getFirstChild(); while (node != null && node != runtimeEnd) { Node next = node.getNext(); if (NodeUtil.isExprCall(node)) { Node call = node.getFirstChild(); Node name = call.getFirstChild(); ...
java
private void removeUnneededPolyfills(Node parent, Node runtimeEnd) { Node node = parent.getFirstChild(); while (node != null && node != runtimeEnd) { Node next = node.getNext(); if (NodeUtil.isExprCall(node)) { Node call = node.getFirstChild(); Node name = call.getFirstChild(); ...
[ "private", "void", "removeUnneededPolyfills", "(", "Node", "parent", ",", "Node", "runtimeEnd", ")", "{", "Node", "node", "=", "parent", ".", "getFirstChild", "(", ")", ";", "while", "(", "node", "!=", "null", "&&", "node", "!=", "runtimeEnd", ")", "{", ...
that already contains the library) is the same or lower than languageOut.
[ "that", "already", "contains", "the", "library", ")", "is", "the", "same", "or", "lower", "than", "languageOut", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RewritePolyfills.java#L188-L205
24,148
google/closure-compiler
src/com/google/javascript/jscomp/PolymerPass.java
PolymerPass.rewritePolymer1ClassDefinition
private void rewritePolymer1ClassDefinition(Node node, Node parent, NodeTraversal traversal) { Node grandparent = parent.getParent(); if (grandparent.isConst()) { compiler.report(JSError.make(node, POLYMER_INVALID_DECLARATION)); return; } PolymerClassDefinition def = PolymerClassDefinition.e...
java
private void rewritePolymer1ClassDefinition(Node node, Node parent, NodeTraversal traversal) { Node grandparent = parent.getParent(); if (grandparent.isConst()) { compiler.report(JSError.make(node, POLYMER_INVALID_DECLARATION)); return; } PolymerClassDefinition def = PolymerClassDefinition.e...
[ "private", "void", "rewritePolymer1ClassDefinition", "(", "Node", "node", ",", "Node", "parent", ",", "NodeTraversal", "traversal", ")", "{", "Node", "grandparent", "=", "parent", ".", "getParent", "(", ")", ";", "if", "(", "grandparent", ".", "isConst", "(", ...
Polymer 1.x and Polymer 2 Legacy Element Definitions
[ "Polymer", "1", ".", "x", "and", "Polymer", "2", "Legacy", "Element", "Definitions" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PolymerPass.java#L130-L155
24,149
google/closure-compiler
src/com/google/javascript/jscomp/PolymerPass.java
PolymerPass.rewritePolymer2ClassDefinition
private void rewritePolymer2ClassDefinition(Node node, NodeTraversal traversal) { PolymerClassDefinition def = PolymerClassDefinition.extractFromClassNode(node, compiler, globalNames); if (def != null) { PolymerClassRewriter rewriter = new PolymerClassRewriter( compiler, ...
java
private void rewritePolymer2ClassDefinition(Node node, NodeTraversal traversal) { PolymerClassDefinition def = PolymerClassDefinition.extractFromClassNode(node, compiler, globalNames); if (def != null) { PolymerClassRewriter rewriter = new PolymerClassRewriter( compiler, ...
[ "private", "void", "rewritePolymer2ClassDefinition", "(", "Node", "node", ",", "NodeTraversal", "traversal", ")", "{", "PolymerClassDefinition", "def", "=", "PolymerClassDefinition", ".", "extractFromClassNode", "(", "node", ",", "compiler", ",", "globalNames", ")", "...
Polymer 2.x Class Nodes
[ "Polymer", "2", ".", "x", "Class", "Nodes" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PolymerPass.java#L158-L173
24,150
google/closure-compiler
src/com/google/javascript/jscomp/PolymerPass.java
PolymerPass.appendPolymerElementExterns
private void appendPolymerElementExterns(final PolymerClassDefinition def) { if (!nativeExternsAdded.add(def.nativeBaseElement)) { return; } Node block = IR.block(); Node baseExterns = polymerElementExterns.cloneTree(); String polymerElementType = PolymerPassStaticUtils.getPolymerElementType...
java
private void appendPolymerElementExterns(final PolymerClassDefinition def) { if (!nativeExternsAdded.add(def.nativeBaseElement)) { return; } Node block = IR.block(); Node baseExterns = polymerElementExterns.cloneTree(); String polymerElementType = PolymerPassStaticUtils.getPolymerElementType...
[ "private", "void", "appendPolymerElementExterns", "(", "final", "PolymerClassDefinition", "def", ")", "{", "if", "(", "!", "nativeExternsAdded", ".", "add", "(", "def", ".", "nativeBaseElement", ")", ")", "{", "return", ";", "}", "Node", "block", "=", "IR", ...
Duplicates the PolymerElement externs with a different element base class if needed. For example, if the base class is HTMLInputElement, then a class PolymerInputElement will be added. If the element does not extend a native HTML element, this method is a no-op.
[ "Duplicates", "the", "PolymerElement", "externs", "with", "a", "different", "element", "base", "class", "if", "needed", ".", "For", "example", "if", "the", "base", "class", "is", "HTMLInputElement", "then", "a", "class", "PolymerInputElement", "will", "be", "add...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PolymerPass.java#L192-L230
24,151
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.validTemplateTypeName
private static boolean validTemplateTypeName(String name) { return !name.isEmpty() && CharMatcher.javaLetterOrDigit().or(CharMatcher.is('_')).matchesAllOf(name); }
java
private static boolean validTemplateTypeName(String name) { return !name.isEmpty() && CharMatcher.javaLetterOrDigit().or(CharMatcher.is('_')).matchesAllOf(name); }
[ "private", "static", "boolean", "validTemplateTypeName", "(", "String", "name", ")", "{", "return", "!", "name", ".", "isEmpty", "(", ")", "&&", "CharMatcher", ".", "javaLetterOrDigit", "(", ")", ".", "or", "(", "CharMatcher", ".", "is", "(", "'", "'", "...
The types in @template annotations must contain only letters, digits, and underscores.
[ "The", "types", "in" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L1276-L1279
24,152
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.recordDescription
private JsDocToken recordDescription(JsDocToken token) { // Find marker's description (if applicable). if (jsdocBuilder.shouldParseDocumentation()) { ExtractionInfo descriptionInfo = extractMultilineTextualBlock(token); token = descriptionInfo.token; } else { token = eatTokensUntilEOL(toke...
java
private JsDocToken recordDescription(JsDocToken token) { // Find marker's description (if applicable). if (jsdocBuilder.shouldParseDocumentation()) { ExtractionInfo descriptionInfo = extractMultilineTextualBlock(token); token = descriptionInfo.token; } else { token = eatTokensUntilEOL(toke...
[ "private", "JsDocToken", "recordDescription", "(", "JsDocToken", "token", ")", "{", "// Find marker's description (if applicable).", "if", "(", "jsdocBuilder", ".", "shouldParseDocumentation", "(", ")", ")", "{", "ExtractionInfo", "descriptionInfo", "=", "extractMultilineTe...
Records a marker's description if there is one available and record it in the current marker.
[ "Records", "a", "marker", "s", "description", "if", "there", "is", "one", "available", "and", "record", "it", "in", "the", "current", "marker", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L1285-L1294
24,153
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.parseAndRecordTypeNode
private Node parseAndRecordTypeNode( JsDocToken token, int lineno, int startCharno, boolean matchingLC, boolean onlyParseSimpleNames) { Node typeNode; if (onlyParseSimpleNames) { typeNode = parseTypeNameAnnotation(token); } else { typeNode = parseTypeExpressionAnno...
java
private Node parseAndRecordTypeNode( JsDocToken token, int lineno, int startCharno, boolean matchingLC, boolean onlyParseSimpleNames) { Node typeNode; if (onlyParseSimpleNames) { typeNode = parseTypeNameAnnotation(token); } else { typeNode = parseTypeExpressionAnno...
[ "private", "Node", "parseAndRecordTypeNode", "(", "JsDocToken", "token", ",", "int", "lineno", ",", "int", "startCharno", ",", "boolean", "matchingLC", ",", "boolean", "onlyParseSimpleNames", ")", "{", "Node", "typeNode", ";", "if", "(", "onlyParseSimpleNames", ")...
Looks for a parameter type expression at the current token and if found, returns it. Note that this method consumes input. @param token The current token. @param lineno The line of the type expression. @param startCharno The starting character position of the type expression. @param matchingLC Whether the type express...
[ "Looks", "for", "a", "parameter", "type", "expression", "at", "the", "current", "token", "and", "if", "found", "returns", "it", ".", "Note", "that", "this", "method", "consumes", "input", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L1513-L1529
24,154
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.extractSingleLineBlock
private ExtractionInfo extractSingleLineBlock() { // Get the current starting point. stream.update(); int lineno = stream.getLineno(); int charno = stream.getCharno() + 1; String line = getRemainingJSDocLine().trim(); // Record the textual description. if (line.length() > 0) { jsdoc...
java
private ExtractionInfo extractSingleLineBlock() { // Get the current starting point. stream.update(); int lineno = stream.getLineno(); int charno = stream.getCharno() + 1; String line = getRemainingJSDocLine().trim(); // Record the textual description. if (line.length() > 0) { jsdoc...
[ "private", "ExtractionInfo", "extractSingleLineBlock", "(", ")", "{", "// Get the current starting point.", "stream", ".", "update", "(", ")", ";", "int", "lineno", "=", "stream", ".", "getLineno", "(", ")", ";", "int", "charno", "=", "stream", ".", "getCharno",...
Extracts the text found on the current line starting at token. Note that token = token.info; should be called after this method is used to update the token properly in the parser. @return The extraction information.
[ "Extracts", "the", "text", "found", "on", "the", "current", "line", "starting", "at", "token", ".", "Note", "that", "token", "=", "token", ".", "info", ";", "should", "be", "called", "after", "this", "method", "is", "used", "to", "update", "the", "token"...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L1679-L1695
24,155
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.extractMultilineComment
private ExtractionInfo extractMultilineComment( JsDocToken token, WhitespaceOption option, boolean isMarker, boolean includeAnnotations) { StringBuilder builder = new StringBuilder(); int startLineno = -1; int startCharno = -1; if (isMarker) { stream.update(); startLineno = stream.ge...
java
private ExtractionInfo extractMultilineComment( JsDocToken token, WhitespaceOption option, boolean isMarker, boolean includeAnnotations) { StringBuilder builder = new StringBuilder(); int startLineno = -1; int startCharno = -1; if (isMarker) { stream.update(); startLineno = stream.ge...
[ "private", "ExtractionInfo", "extractMultilineComment", "(", "JsDocToken", "token", ",", "WhitespaceOption", "option", ",", "boolean", "isMarker", ",", "boolean", "includeAnnotations", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", ...
Extracts text from the stream until the end of the comment, end of the file, or an annotation token is encountered. If the text is being extracted for a JSDoc marker, the first line in the stream will always be included in the extract text. @param token The starting token. @param option How to handle whitespace. @para...
[ "Extracts", "text", "from", "the", "stream", "until", "the", "end", "of", "the", "comment", "end", "of", "the", "file", "or", "an", "annotation", "token", "is", "encountered", ".", "If", "the", "text", "is", "being", "extracted", "for", "a", "JSDoc", "ma...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L1773-L1880
24,156
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.parseParametersType
private Node parseParametersType(JsDocToken token) { Node paramsType = newNode(Token.PARAM_LIST); boolean isVarArgs = false; Node paramType = null; if (token != JsDocToken.RIGHT_PAREN) { do { if (paramType != null) { // skip past the comma next(); skipEOLs(); ...
java
private Node parseParametersType(JsDocToken token) { Node paramsType = newNode(Token.PARAM_LIST); boolean isVarArgs = false; Node paramType = null; if (token != JsDocToken.RIGHT_PAREN) { do { if (paramType != null) { // skip past the comma next(); skipEOLs(); ...
[ "private", "Node", "parseParametersType", "(", "JsDocToken", "token", ")", "{", "Node", "paramsType", "=", "newNode", "(", "Token", ".", "PARAM_LIST", ")", ";", "boolean", "isVarArgs", "=", "false", ";", "Node", "paramType", "=", "null", ";", "if", "(", "t...
order-checking in two places, we just do all of it in type resolution.
[ "order", "-", "checking", "in", "two", "places", "we", "just", "do", "all", "of", "it", "in", "type", "resolution", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L2371-L2424
24,157
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.parseUnionTypeWithAlternate
private Node parseUnionTypeWithAlternate(JsDocToken token, Node alternate) { Node union = newNode(Token.PIPE); if (alternate != null) { union.addChildToBack(alternate); } Node expr = null; do { if (expr != null) { skipEOLs(); token = next(); checkState(token == J...
java
private Node parseUnionTypeWithAlternate(JsDocToken token, Node alternate) { Node union = newNode(Token.PIPE); if (alternate != null) { union.addChildToBack(alternate); } Node expr = null; do { if (expr != null) { skipEOLs(); token = next(); checkState(token == J...
[ "private", "Node", "parseUnionTypeWithAlternate", "(", "JsDocToken", "token", ",", "Node", "alternate", ")", "{", "Node", "union", "=", "newNode", "(", "Token", ".", "PIPE", ")", ";", "if", "(", "alternate", "!=", "null", ")", "{", "union", ".", "addChildT...
Create a new union type, with an alternate that has already been parsed. The alternate may be null.
[ "Create", "a", "new", "union", "type", "with", "an", "alternate", "that", "has", "already", "been", "parsed", ".", "The", "alternate", "may", "be", "null", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L2459-L2496
24,158
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.match
private boolean match(JsDocToken token1, JsDocToken token2) { unreadToken = next(); return unreadToken == token1 || unreadToken == token2; }
java
private boolean match(JsDocToken token1, JsDocToken token2) { unreadToken = next(); return unreadToken == token1 || unreadToken == token2; }
[ "private", "boolean", "match", "(", "JsDocToken", "token1", ",", "JsDocToken", "token2", ")", "{", "unreadToken", "=", "next", "(", ")", ";", "return", "unreadToken", "==", "token1", "||", "unreadToken", "==", "token2", ";", "}" ]
Tests that the next symbol of the token stream matches one of the specified tokens.
[ "Tests", "that", "the", "next", "symbol", "of", "the", "token", "stream", "matches", "one", "of", "the", "specified", "tokens", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L2712-L2715
24,159
google/closure-compiler
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
JsDocInfoParser.lookAheadFor
private boolean lookAheadFor(char expect) { boolean matched = false; int c; while (true) { c = stream.getChar(); if (c == ' ') { continue; } else if (c == expect) { matched = true; break; } else { break; } } stream.ungetChar(c); retur...
java
private boolean lookAheadFor(char expect) { boolean matched = false; int c; while (true) { c = stream.getChar(); if (c == ' ') { continue; } else if (c == expect) { matched = true; break; } else { break; } } stream.ungetChar(c); retur...
[ "private", "boolean", "lookAheadFor", "(", "char", "expect", ")", "{", "boolean", "matched", "=", "false", ";", "int", "c", ";", "while", "(", "true", ")", "{", "c", "=", "stream", ".", "getChar", "(", ")", ";", "if", "(", "c", "==", "'", "'", ")...
Look ahead by advancing the character stream. Does not modify the token stream. @return Whether we found the char.
[ "Look", "ahead", "by", "advancing", "the", "character", "stream", ".", "Does", "not", "modify", "the", "token", "stream", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java#L2800-L2816
24,160
google/closure-compiler
src/com/google/javascript/jscomp/TypeTransformation.java
TypeTransformation.getCallParams
private ImmutableList<Node> getCallParams(Node n) { Preconditions.checkArgument(n.isCall(), "Expected a call node, found %s", n); ImmutableList.Builder<Node> builder = new ImmutableList.Builder<>(); for (int i = 0; i < getCallParamCount(n); i++) { builder.add(getCallArgument(n, i)); } return b...
java
private ImmutableList<Node> getCallParams(Node n) { Preconditions.checkArgument(n.isCall(), "Expected a call node, found %s", n); ImmutableList.Builder<Node> builder = new ImmutableList.Builder<>(); for (int i = 0; i < getCallParamCount(n); i++) { builder.add(getCallArgument(n, i)); } return b...
[ "private", "ImmutableList", "<", "Node", ">", "getCallParams", "(", "Node", "n", ")", "{", "Preconditions", ".", "checkArgument", "(", "n", ".", "isCall", "(", ")", ",", "\"Expected a call node, found %s\"", ",", "n", ")", ";", "ImmutableList", ".", "Builder",...
Copying is unnecessarily inefficient.
[ "Copying", "is", "unnecessarily", "inefficient", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeTransformation.java#L220-L227
24,161
google/closure-compiler
src/com/google/javascript/jscomp/AliasStrings.java
AliasStrings.replaceStringsWithAliases
private void replaceStringsWithAliases() { for (Entry<String, StringInfo> entry : stringInfoMap.entrySet()) { String literal = entry.getKey(); StringInfo info = entry.getValue(); if (shouldReplaceWithAlias(literal, info)) { for (StringOccurrence occurrence : info.occurrences) { r...
java
private void replaceStringsWithAliases() { for (Entry<String, StringInfo> entry : stringInfoMap.entrySet()) { String literal = entry.getKey(); StringInfo info = entry.getValue(); if (shouldReplaceWithAlias(literal, info)) { for (StringOccurrence occurrence : info.occurrences) { r...
[ "private", "void", "replaceStringsWithAliases", "(", ")", "{", "for", "(", "Entry", "<", "String", ",", "StringInfo", ">", "entry", ":", "stringInfoMap", ".", "entrySet", "(", ")", ")", "{", "String", "literal", "=", "entry", ".", "getKey", "(", ")", ";"...
Replace strings with references to alias variables.
[ "Replace", "strings", "with", "references", "to", "alias", "variables", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AliasStrings.java#L215-L226
24,162
google/closure-compiler
src/com/google/javascript/jscomp/AliasStrings.java
AliasStrings.addAliasDeclarationNodes
private void addAliasDeclarationNodes() { for (Entry<String, StringInfo> entry : stringInfoMap.entrySet()) { StringInfo info = entry.getValue(); if (!info.isAliased) { continue; } String alias = info.getVariableName(entry.getKey()); Node var = IR.var(IR.name(alias), IR.string(e...
java
private void addAliasDeclarationNodes() { for (Entry<String, StringInfo> entry : stringInfoMap.entrySet()) { StringInfo info = entry.getValue(); if (!info.isAliased) { continue; } String alias = info.getVariableName(entry.getKey()); Node var = IR.var(IR.name(alias), IR.string(e...
[ "private", "void", "addAliasDeclarationNodes", "(", ")", "{", "for", "(", "Entry", "<", "String", ",", "StringInfo", ">", "entry", ":", "stringInfoMap", ".", "entrySet", "(", ")", ")", "{", "StringInfo", "info", "=", "entry", ".", "getValue", "(", ")", "...
Creates a var declaration for each aliased string. Var declarations are inserted as close to the first use of the string as possible.
[ "Creates", "a", "var", "declaration", "for", "each", "aliased", "string", ".", "Var", "declarations", "are", "inserted", "as", "close", "to", "the", "first", "use", "of", "the", "string", "as", "possible", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AliasStrings.java#L232-L249
24,163
google/closure-compiler
src/com/google/javascript/jscomp/AliasStrings.java
AliasStrings.shouldReplaceWithAlias
private static boolean shouldReplaceWithAlias(String str, StringInfo info) { // Optimize for code size. Are aliases smaller than strings? // // This logic optimizes for the size of uncompressed code, but it tends to // get good results for the size of the gzipped code too. // // gzip actually p...
java
private static boolean shouldReplaceWithAlias(String str, StringInfo info) { // Optimize for code size. Are aliases smaller than strings? // // This logic optimizes for the size of uncompressed code, but it tends to // get good results for the size of the gzipped code too. // // gzip actually p...
[ "private", "static", "boolean", "shouldReplaceWithAlias", "(", "String", "str", ",", "StringInfo", "info", ")", "{", "// Optimize for code size. Are aliases smaller than strings?", "//", "// This logic optimizes for the size of uncompressed code, but it tends to", "// get good results...
Dictates the policy for replacing a string with an alias. @param str The string literal @param info Accumulated information about a string
[ "Dictates", "the", "policy", "for", "replacing", "a", "string", "with", "an", "alias", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AliasStrings.java#L257-L277
24,164
google/closure-compiler
src/com/google/javascript/jscomp/AliasStrings.java
AliasStrings.replaceStringWithAliasName
private void replaceStringWithAliasName(StringOccurrence occurrence, String name, StringInfo info) { Node nameNode = IR.name(name); occurrence.parent.replaceChild(occurrence.node, nameNode); ...
java
private void replaceStringWithAliasName(StringOccurrence occurrence, String name, StringInfo info) { Node nameNode = IR.name(name); occurrence.parent.replaceChild(occurrence.node, nameNode); ...
[ "private", "void", "replaceStringWithAliasName", "(", "StringOccurrence", "occurrence", ",", "String", "name", ",", "StringInfo", "info", ")", "{", "Node", "nameNode", "=", "IR", ".", "name", "(", "name", ")", ";", "occurrence", ".", "parent", ".", "replaceChi...
Replaces a string literal with a reference to the string's alias variable.
[ "Replaces", "a", "string", "literal", "with", "a", "reference", "to", "the", "string", "s", "alias", "variable", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AliasStrings.java#L282-L290
24,165
google/closure-compiler
src/com/google/javascript/jscomp/AliasStrings.java
AliasStrings.outputStringUsage
private void outputStringUsage() { StringBuilder sb = new StringBuilder("Strings used more than once:\n"); for (Entry<String, StringInfo> stringInfoEntry : stringInfoMap.entrySet()) { StringInfo info = stringInfoEntry.getValue(); if (info.numOccurrences > 1) { sb.append(info.numOccurrences);...
java
private void outputStringUsage() { StringBuilder sb = new StringBuilder("Strings used more than once:\n"); for (Entry<String, StringInfo> stringInfoEntry : stringInfoMap.entrySet()) { StringInfo info = stringInfoEntry.getValue(); if (info.numOccurrences > 1) { sb.append(info.numOccurrences);...
[ "private", "void", "outputStringUsage", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"Strings used more than once:\\n\"", ")", ";", "for", "(", "Entry", "<", "String", ",", "StringInfo", ">", "stringInfoEntry", ":", "stringInfoMap", "....
Outputs a log of all strings used more than once in the code.
[ "Outputs", "a", "log", "of", "all", "strings", "used", "more", "than", "once", "in", "the", "code", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AliasStrings.java#L295-L308
24,166
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.processDefineCall
private void processDefineCall(NodeTraversal t, Node n, Node parent) { Node left = n.getFirstChild(); Node args = left.getNext(); if (verifyDefine(t, parent, left, args)) { Node nameNode = args; maybeAddNameToSymbolTable(left); maybeAddStringToSymbolTable(nameNode); this.defineCall...
java
private void processDefineCall(NodeTraversal t, Node n, Node parent) { Node left = n.getFirstChild(); Node args = left.getNext(); if (verifyDefine(t, parent, left, args)) { Node nameNode = args; maybeAddNameToSymbolTable(left); maybeAddStringToSymbolTable(nameNode); this.defineCall...
[ "private", "void", "processDefineCall", "(", "NodeTraversal", "t", ",", "Node", "n", ",", "Node", "parent", ")", "{", "Node", "left", "=", "n", ".", "getFirstChild", "(", ")", ";", "Node", "args", "=", "left", ".", "getNext", "(", ")", ";", "if", "("...
Handles a goog.define call.
[ "Handles", "a", "goog", ".", "define", "call", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L385-L396
24,167
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.processBaseClassCall
private void processBaseClassCall(NodeTraversal t, Node n) { // Two things must hold for every goog.base call: // 1) We must be calling it on "this". // 2) We must be calling it on a prototype method of the same name as // the one we're in, OR we must be calling it from a constructor. // If both ...
java
private void processBaseClassCall(NodeTraversal t, Node n) { // Two things must hold for every goog.base call: // 1) We must be calling it on "this". // 2) We must be calling it on a prototype method of the same name as // the one we're in, OR we must be calling it from a constructor. // If both ...
[ "private", "void", "processBaseClassCall", "(", "NodeTraversal", "t", ",", "Node", "n", ")", "{", "// Two things must hold for every goog.base call:", "// 1) We must be calling it on \"this\".", "// 2) We must be calling it on a prototype method of the same name as", "// the one we're...
Processes the base class call.
[ "Processes", "the", "base", "class", "call", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L399-L503
24,168
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.processInheritsCall
private void processInheritsCall(Node n) { if (n.getChildCount() == 3) { Node subClass = n.getSecondChild(); Node superClass = subClass.getNext(); if (subClass.isUnscopedQualifiedName() && superClass.isUnscopedQualifiedName()) { knownClosureSubclasses.add(subClass.getQualifiedName()); ...
java
private void processInheritsCall(Node n) { if (n.getChildCount() == 3) { Node subClass = n.getSecondChild(); Node superClass = subClass.getNext(); if (subClass.isUnscopedQualifiedName() && superClass.isUnscopedQualifiedName()) { knownClosureSubclasses.add(subClass.getQualifiedName()); ...
[ "private", "void", "processInheritsCall", "(", "Node", "n", ")", "{", "if", "(", "n", ".", "getChildCount", "(", ")", "==", "3", ")", "{", "Node", "subClass", "=", "n", ".", "getSecondChild", "(", ")", ";", "Node", "superClass", "=", "subClass", ".", ...
Processes the goog.inherits call.
[ "Processes", "the", "goog", ".", "inherits", "call", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L686-L694
24,169
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.getEnclosingDeclNameNode
private static Node getEnclosingDeclNameNode(Node n) { Node fn = NodeUtil.getEnclosingFunction(n); return fn == null ? null : NodeUtil.getNameNode(fn); }
java
private static Node getEnclosingDeclNameNode(Node n) { Node fn = NodeUtil.getEnclosingFunction(n); return fn == null ? null : NodeUtil.getNameNode(fn); }
[ "private", "static", "Node", "getEnclosingDeclNameNode", "(", "Node", "n", ")", "{", "Node", "fn", "=", "NodeUtil", ".", "getEnclosingFunction", "(", "n", ")", ";", "return", "fn", "==", "null", "?", "null", ":", "NodeUtil", ".", "getNameNode", "(", "fn", ...
Returns the qualified name node of the function whose scope we're in, or null if it cannot be found.
[ "Returns", "the", "qualified", "name", "node", "of", "the", "function", "whose", "scope", "we", "re", "in", "or", "null", "if", "it", "cannot", "be", "found", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L700-L703
24,170
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.baseUsedInClass
private boolean baseUsedInClass(Node n){ for (Node curr = n; curr != null; curr = curr.getParent()){ if (curr.isClassMembers()) { return true; } } return false; }
java
private boolean baseUsedInClass(Node n){ for (Node curr = n; curr != null; curr = curr.getParent()){ if (curr.isClassMembers()) { return true; } } return false; }
[ "private", "boolean", "baseUsedInClass", "(", "Node", "n", ")", "{", "for", "(", "Node", "curr", "=", "n", ";", "curr", "!=", "null", ";", "curr", "=", "curr", ".", "getParent", "(", ")", ")", "{", "if", "(", "curr", ".", "isClassMembers", "(", ")"...
Verify if goog.base call is used in a class
[ "Verify", "if", "goog", ".", "base", "call", "is", "used", "in", "a", "class" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L706-L713
24,171
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.verifyProvide
private boolean verifyProvide(Node methodName, Node arg) { if (!verifyLastArgumentIsString(methodName, arg)) { return false; } if (!NodeUtil.isValidQualifiedName( compiler.getOptions().getLanguageIn().toFeatureSet(), arg.getString())) { compiler.report( JSError.make( ...
java
private boolean verifyProvide(Node methodName, Node arg) { if (!verifyLastArgumentIsString(methodName, arg)) { return false; } if (!NodeUtil.isValidQualifiedName( compiler.getOptions().getLanguageIn().toFeatureSet(), arg.getString())) { compiler.report( JSError.make( ...
[ "private", "boolean", "verifyProvide", "(", "Node", "methodName", ",", "Node", "arg", ")", "{", "if", "(", "!", "verifyLastArgumentIsString", "(", "methodName", ",", "arg", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "NodeUtil", ".", "isV...
Verifies that a provide method call has exactly one argument, and that it's a string literal and that the contents of the string are valid JS tokens. Reports a compile error if it doesn't. @return Whether the argument checked out okay
[ "Verifies", "that", "a", "provide", "method", "call", "has", "exactly", "one", "argument", "and", "that", "it", "s", "a", "string", "literal", "and", "that", "the", "contents", "of", "the", "string", "are", "valid", "JS", "tokens", ".", "Reports", "a", "...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L831-L848
24,172
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.verifyDefine
private boolean verifyDefine(NodeTraversal t, Node parent, Node methodName, Node args) { // Calls to goog.define must be in the global hoist scope. This is copied from // validate(Un)aliasablePrimitiveCall. // TODO(sdh): loosen this restriction if the results are assigned? if (!compiler.getOptions().sh...
java
private boolean verifyDefine(NodeTraversal t, Node parent, Node methodName, Node args) { // Calls to goog.define must be in the global hoist scope. This is copied from // validate(Un)aliasablePrimitiveCall. // TODO(sdh): loosen this restriction if the results are assigned? if (!compiler.getOptions().sh...
[ "private", "boolean", "verifyDefine", "(", "NodeTraversal", "t", ",", "Node", "parent", ",", "Node", "methodName", ",", "Node", "args", ")", "{", "// Calls to goog.define must be in the global hoist scope. This is copied from", "// validate(Un)aliasablePrimitiveCall.", "// TOD...
Verifies that a goog.define method call has exactly two arguments, with the first a string literal whose contents is a valid JS qualified name. Reports a compile error if it doesn't. @return Whether the argument checked out okay
[ "Verifies", "that", "a", "goog", ".", "define", "method", "call", "has", "exactly", "two", "arguments", "with", "the", "first", "a", "string", "literal", "whose", "contents", "is", "a", "valid", "JS", "qualified", "name", ".", "Reports", "a", "compile", "e...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L856-L901
24,173
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.verifyLastArgumentIsString
private boolean verifyLastArgumentIsString(Node methodName, Node arg) { return verifyNotNull(methodName, arg) && verifyOfType(methodName, arg, Token.STRING) && verifyIsLast(methodName, arg); }
java
private boolean verifyLastArgumentIsString(Node methodName, Node arg) { return verifyNotNull(methodName, arg) && verifyOfType(methodName, arg, Token.STRING) && verifyIsLast(methodName, arg); }
[ "private", "boolean", "verifyLastArgumentIsString", "(", "Node", "methodName", ",", "Node", "arg", ")", "{", "return", "verifyNotNull", "(", "methodName", ",", "arg", ")", "&&", "verifyOfType", "(", "methodName", ",", "arg", ",", "Token", ".", "STRING", ")", ...
Verifies that a method call has exactly one argument, and that it's a string literal. Reports a compile error if it doesn't. @return Whether the argument checked out okay
[ "Verifies", "that", "a", "method", "call", "has", "exactly", "one", "argument", "and", "that", "it", "s", "a", "string", "literal", ".", "Reports", "a", "compile", "error", "if", "it", "doesn", "t", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L956-L960
24,174
google/closure-compiler
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
ProcessClosurePrimitives.verifySetCssNameMapping
private boolean verifySetCssNameMapping(Node methodName, Node firstArg) { DiagnosticType diagnostic = null; if (firstArg == null) { diagnostic = NULL_ARGUMENT_ERROR; } else if (!firstArg.isObjectLit()) { diagnostic = EXPECTED_OBJECTLIT_ERROR; } else if (firstArg.getNext() != null) { No...
java
private boolean verifySetCssNameMapping(Node methodName, Node firstArg) { DiagnosticType diagnostic = null; if (firstArg == null) { diagnostic = NULL_ARGUMENT_ERROR; } else if (!firstArg.isObjectLit()) { diagnostic = EXPECTED_OBJECTLIT_ERROR; } else if (firstArg.getNext() != null) { No...
[ "private", "boolean", "verifySetCssNameMapping", "(", "Node", "methodName", ",", "Node", "firstArg", ")", "{", "DiagnosticType", "diagnostic", "=", "null", ";", "if", "(", "firstArg", "==", "null", ")", "{", "diagnostic", "=", "NULL_ARGUMENT_ERROR", ";", "}", ...
Verifies that setCssNameMapping is called with the correct methods. @return Whether the arguments checked out okay
[ "Verifies", "that", "setCssNameMapping", "is", "called", "with", "the", "correct", "methods", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java#L996-L1015
24,175
google/closure-compiler
src/com/google/javascript/rhino/JSTypeExpression.java
JSTypeExpression.makeOptionalArg
public static JSTypeExpression makeOptionalArg(JSTypeExpression expr) { if (expr.isOptionalArg() || expr.isVarArgs()) { return expr; } else { return new JSTypeExpression( new Node(Token.EQUALS, expr.root), expr.sourceName); } }
java
public static JSTypeExpression makeOptionalArg(JSTypeExpression expr) { if (expr.isOptionalArg() || expr.isVarArgs()) { return expr; } else { return new JSTypeExpression( new Node(Token.EQUALS, expr.root), expr.sourceName); } }
[ "public", "static", "JSTypeExpression", "makeOptionalArg", "(", "JSTypeExpression", "expr", ")", "{", "if", "(", "expr", ".", "isOptionalArg", "(", ")", "||", "expr", ".", "isVarArgs", "(", ")", ")", "{", "return", "expr", ";", "}", "else", "{", "return", ...
Make the given type expression into an optional type expression, if possible.
[ "Make", "the", "given", "type", "expression", "into", "an", "optional", "type", "expression", "if", "possible", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/JSTypeExpression.java#L73-L80
24,176
google/closure-compiler
src/com/google/javascript/rhino/TypeDeclarationsIR.java
TypeDeclarationsIR.namedType
public static TypeDeclarationNode namedType(Iterable<String> segments) { Iterator<String> segmentsIt = segments.iterator(); Node node = IR.name(segmentsIt.next()); while (segmentsIt.hasNext()) { node = IR.getprop(node, IR.string(segmentsIt.next())); } return new TypeDeclarationNode(Token.NAMED...
java
public static TypeDeclarationNode namedType(Iterable<String> segments) { Iterator<String> segmentsIt = segments.iterator(); Node node = IR.name(segmentsIt.next()); while (segmentsIt.hasNext()) { node = IR.getprop(node, IR.string(segmentsIt.next())); } return new TypeDeclarationNode(Token.NAMED...
[ "public", "static", "TypeDeclarationNode", "namedType", "(", "Iterable", "<", "String", ">", "segments", ")", "{", "Iterator", "<", "String", ">", "segmentsIt", "=", "segments", ".", "iterator", "(", ")", ";", "Node", "node", "=", "IR", ".", "name", "(", ...
Produces a tree structure similar to the Rhino AST of a qualified name expression, under a top-level NAMED_TYPE node. <p>Example: <pre> NAMED_TYPE NAME goog STRING ui STRING Window </pre>
[ "Produces", "a", "tree", "structure", "similar", "to", "the", "Rhino", "AST", "of", "a", "qualified", "name", "expression", "under", "a", "top", "-", "level", "NAMED_TYPE", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/TypeDeclarationsIR.java#L125-L132
24,177
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.maybeAddFunction
void maybeAddFunction(Function fn, JSModule module) { String name = fn.getName(); FunctionState functionState = getOrCreateFunctionState(name); // TODO(johnlenz): Maybe "smarten" FunctionState by adding this logic to it? // If the function has multiple definitions, don't inline it. if (functionSta...
java
void maybeAddFunction(Function fn, JSModule module) { String name = fn.getName(); FunctionState functionState = getOrCreateFunctionState(name); // TODO(johnlenz): Maybe "smarten" FunctionState by adding this logic to it? // If the function has multiple definitions, don't inline it. if (functionSta...
[ "void", "maybeAddFunction", "(", "Function", "fn", ",", "JSModule", "module", ")", "{", "String", "name", "=", "fn", ".", "getName", "(", ")", ";", "FunctionState", "functionState", "=", "getOrCreateFunctionState", "(", "name", ")", ";", "// TODO(johnlenz): Mayb...
Updates the FunctionState object for the given function. Checks if the given function matches the criteria for an inlinable function.
[ "Updates", "the", "FunctionState", "object", "for", "the", "given", "function", ".", "Checks", "if", "the", "given", "function", "matches", "the", "criteria", "for", "an", "inlinable", "function", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L265-L359
24,178
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.isCandidateFunction
private boolean isCandidateFunction(Function fn) { // Don't inline exported functions. String fnName = fn.getName(); if (compiler.getCodingConvention().isExported(fnName)) { // TODO(johnlenz): Should we allow internal references to be inlined? // An exported name can be replaced externally, any ...
java
private boolean isCandidateFunction(Function fn) { // Don't inline exported functions. String fnName = fn.getName(); if (compiler.getCodingConvention().isExported(fnName)) { // TODO(johnlenz): Should we allow internal references to be inlined? // An exported name can be replaced externally, any ...
[ "private", "boolean", "isCandidateFunction", "(", "Function", "fn", ")", "{", "// Don't inline exported functions.", "String", "fnName", "=", "fn", ".", "getName", "(", ")", ";", "if", "(", "compiler", ".", "getCodingConvention", "(", ")", ".", "isExported", "("...
Checks if the given function matches the criteria for an inlinable function.
[ "Checks", "if", "the", "given", "function", "matches", "the", "criteria", "for", "an", "inlinable", "function", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L378-L398
24,179
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.trimCandidatesNotMeetingMinimumRequirements
private void trimCandidatesNotMeetingMinimumRequirements() { Iterator<Entry<String, FunctionState>> i; for (i = fns.entrySet().iterator(); i.hasNext(); ) { FunctionState functionState = i.next().getValue(); if (!functionState.hasExistingFunctionDefinition() || !functionState.canInline()) { i...
java
private void trimCandidatesNotMeetingMinimumRequirements() { Iterator<Entry<String, FunctionState>> i; for (i = fns.entrySet().iterator(); i.hasNext(); ) { FunctionState functionState = i.next().getValue(); if (!functionState.hasExistingFunctionDefinition() || !functionState.canInline()) { i...
[ "private", "void", "trimCandidatesNotMeetingMinimumRequirements", "(", ")", "{", "Iterator", "<", "Entry", "<", "String", ",", "FunctionState", ">", ">", "i", ";", "for", "(", "i", "=", "fns", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "i...
Remove entries that aren't a valid inline candidates, from the list of encountered names.
[ "Remove", "entries", "that", "aren", "t", "a", "valid", "inline", "candidates", "from", "the", "list", "of", "encountered", "names", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L638-L646
24,180
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.trimCandidatesUsingOnCost
private void trimCandidatesUsingOnCost() { Iterator<Entry<String, FunctionState>> i; for (i = fns.entrySet().iterator(); i.hasNext(); ) { FunctionState functionState = i.next().getValue(); if (functionState.hasReferences()) { // Only inline function if it decreases the code size. boo...
java
private void trimCandidatesUsingOnCost() { Iterator<Entry<String, FunctionState>> i; for (i = fns.entrySet().iterator(); i.hasNext(); ) { FunctionState functionState = i.next().getValue(); if (functionState.hasReferences()) { // Only inline function if it decreases the code size. boo...
[ "private", "void", "trimCandidatesUsingOnCost", "(", ")", "{", "Iterator", "<", "Entry", "<", "String", ",", "FunctionState", ">", ">", "i", ";", "for", "(", "i", "=", "fns", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNe...
Remove entries from the list of candidates that can't be inlined.
[ "Remove", "entries", "from", "the", "list", "of", "candidates", "that", "can", "t", "be", "inlined", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L649-L666
24,181
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.minimizeCost
private boolean minimizeCost(FunctionState functionState) { if (!inliningLowersCost(functionState)) { // Try again without Block inlining references if (functionState.hasBlockInliningReferences()) { functionState.setRemove(false); functionState.removeBlockInliningReferences(); if...
java
private boolean minimizeCost(FunctionState functionState) { if (!inliningLowersCost(functionState)) { // Try again without Block inlining references if (functionState.hasBlockInliningReferences()) { functionState.setRemove(false); functionState.removeBlockInliningReferences(); if...
[ "private", "boolean", "minimizeCost", "(", "FunctionState", "functionState", ")", "{", "if", "(", "!", "inliningLowersCost", "(", "functionState", ")", ")", "{", "// Try again without Block inlining references", "if", "(", "functionState", ".", "hasBlockInliningReferences...
Determines if the function is worth inlining and potentially trims references that increase the cost. @return Whether inlining the references lowers the overall cost.
[ "Determines", "if", "the", "function", "is", "worth", "inlining", "and", "potentially", "trims", "references", "that", "increase", "the", "cost", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L674-L688
24,182
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.findCalledFunctions
private Set<String> findCalledFunctions(Node node) { Set<String> changed = new HashSet<>(); findCalledFunctions(NodeUtil.getFunctionBody(node), changed); return changed; }
java
private Set<String> findCalledFunctions(Node node) { Set<String> changed = new HashSet<>(); findCalledFunctions(NodeUtil.getFunctionBody(node), changed); return changed; }
[ "private", "Set", "<", "String", ">", "findCalledFunctions", "(", "Node", "node", ")", "{", "Set", "<", "String", ">", "changed", "=", "new", "HashSet", "<>", "(", ")", ";", "findCalledFunctions", "(", "NodeUtil", ".", "getFunctionBody", "(", "node", ")", ...
This functions that may be called directly.
[ "This", "functions", "that", "may", "be", "called", "directly", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L767-L771
24,183
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.decomposeExpressions
private void decomposeExpressions() { for (FunctionState functionState : fns.values()) { if (functionState.canInline()) { for (Reference ref : functionState.getReferences()) { if (ref.requiresDecomposition) { injector.maybePrepareCall(ref); } } } } }
java
private void decomposeExpressions() { for (FunctionState functionState : fns.values()) { if (functionState.canInline()) { for (Reference ref : functionState.getReferences()) { if (ref.requiresDecomposition) { injector.maybePrepareCall(ref); } } } } }
[ "private", "void", "decomposeExpressions", "(", ")", "{", "for", "(", "FunctionState", "functionState", ":", "fns", ".", "values", "(", ")", ")", "{", "if", "(", "functionState", ".", "canInline", "(", ")", ")", "{", "for", "(", "Reference", "ref", ":", ...
For any call-site that needs it, prepare the call-site for inlining by rewriting the containing expression.
[ "For", "any", "call", "-", "site", "that", "needs", "it", "prepare", "the", "call", "-", "site", "for", "inlining", "by", "rewriting", "the", "containing", "expression", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L790-L800
24,184
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.removeInlinedFunctions
void removeInlinedFunctions() { for (Map.Entry<String, FunctionState> entry : fns.entrySet()) { String name = entry.getKey(); FunctionState functionState = entry.getValue(); if (functionState.canRemove()) { Function fn = functionState.getFn(); checkState(functionState.canInline());...
java
void removeInlinedFunctions() { for (Map.Entry<String, FunctionState> entry : fns.entrySet()) { String name = entry.getKey(); FunctionState functionState = entry.getValue(); if (functionState.canRemove()) { Function fn = functionState.getFn(); checkState(functionState.canInline());...
[ "void", "removeInlinedFunctions", "(", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "FunctionState", ">", "entry", ":", "fns", ".", "entrySet", "(", ")", ")", "{", "String", "name", "=", "entry", ".", "getKey", "(", ")", ";", "Funct...
Removed inlined functions that no longer have any references.
[ "Removed", "inlined", "functions", "that", "no", "longer", "have", "any", "references", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L803-L816
24,185
google/closure-compiler
src/com/google/javascript/jscomp/InlineFunctions.java
InlineFunctions.verifyAllReferencesInlined
void verifyAllReferencesInlined(String name, FunctionState functionState) { for (Reference ref : functionState.getReferences()) { if (!ref.inlined) { Node parent = ref.callNode.getParent(); throw new IllegalStateException( "Call site missed (" + name ...
java
void verifyAllReferencesInlined(String name, FunctionState functionState) { for (Reference ref : functionState.getReferences()) { if (!ref.inlined) { Node parent = ref.callNode.getParent(); throw new IllegalStateException( "Call site missed (" + name ...
[ "void", "verifyAllReferencesInlined", "(", "String", "name", ",", "FunctionState", "functionState", ")", "{", "for", "(", "Reference", "ref", ":", "functionState", ".", "getReferences", "(", ")", ")", "{", "if", "(", "!", "ref", ".", "inlined", ")", "{", "...
Check to verify that expression rewriting didn't make a call inaccessible.
[ "Check", "to", "verify", "that", "expression", "rewriting", "didn", "t", "make", "a", "call", "inaccessible", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/InlineFunctions.java#L819-L832
24,186
google/closure-compiler
src/com/google/javascript/jscomp/DiagnosticType.java
DiagnosticType.error
public static DiagnosticType error(String name, String descriptionFormat) { return make(name, CheckLevel.ERROR, descriptionFormat); }
java
public static DiagnosticType error(String name, String descriptionFormat) { return make(name, CheckLevel.ERROR, descriptionFormat); }
[ "public", "static", "DiagnosticType", "error", "(", "String", "name", ",", "String", "descriptionFormat", ")", "{", "return", "make", "(", "name", ",", "CheckLevel", ".", "ERROR", ",", "descriptionFormat", ")", ";", "}" ]
Create a DiagnosticType at level CheckLevel.ERROR @param name An identifier @param descriptionFormat A format string @return A new DiagnosticType
[ "Create", "a", "DiagnosticType", "at", "level", "CheckLevel", ".", "ERROR" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DiagnosticType.java#L49-L51
24,187
google/closure-compiler
src/com/google/javascript/jscomp/DiagnosticType.java
DiagnosticType.warning
public static DiagnosticType warning(String name, String descriptionFormat) { return make(name, CheckLevel.WARNING, descriptionFormat); }
java
public static DiagnosticType warning(String name, String descriptionFormat) { return make(name, CheckLevel.WARNING, descriptionFormat); }
[ "public", "static", "DiagnosticType", "warning", "(", "String", "name", ",", "String", "descriptionFormat", ")", "{", "return", "make", "(", "name", ",", "CheckLevel", ".", "WARNING", ",", "descriptionFormat", ")", ";", "}" ]
Create a DiagnosticType at level CheckLevel.WARNING @param name An identifier @param descriptionFormat A format string @return A new DiagnosticType
[ "Create", "a", "DiagnosticType", "at", "level", "CheckLevel", ".", "WARNING" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DiagnosticType.java#L60-L62
24,188
google/closure-compiler
src/com/google/javascript/jscomp/DiagnosticType.java
DiagnosticType.disabled
public static DiagnosticType disabled(String name, String descriptionFormat) { return make(name, CheckLevel.OFF, descriptionFormat); }
java
public static DiagnosticType disabled(String name, String descriptionFormat) { return make(name, CheckLevel.OFF, descriptionFormat); }
[ "public", "static", "DiagnosticType", "disabled", "(", "String", "name", ",", "String", "descriptionFormat", ")", "{", "return", "make", "(", "name", ",", "CheckLevel", ".", "OFF", ",", "descriptionFormat", ")", ";", "}" ]
Create a DiagnosticType at level CheckLevel.OFF @param name An identifier @param descriptionFormat A format string @return A new DiagnosticType
[ "Create", "a", "DiagnosticType", "at", "level", "CheckLevel", ".", "OFF" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DiagnosticType.java#L71-L74
24,189
google/closure-compiler
src/com/google/javascript/jscomp/DiagnosticType.java
DiagnosticType.make
public static DiagnosticType make(String name, CheckLevel level, String descriptionFormat) { return new DiagnosticType(name, level, new MessageFormat(descriptionFormat)); }
java
public static DiagnosticType make(String name, CheckLevel level, String descriptionFormat) { return new DiagnosticType(name, level, new MessageFormat(descriptionFormat)); }
[ "public", "static", "DiagnosticType", "make", "(", "String", "name", ",", "CheckLevel", "level", ",", "String", "descriptionFormat", ")", "{", "return", "new", "DiagnosticType", "(", "name", ",", "level", ",", "new", "MessageFormat", "(", "descriptionFormat", ")...
Create a DiagnosticType at a given CheckLevel. @param name An identifier @param level Either CheckLevel.ERROR or CheckLevel.WARNING @param descriptionFormat A format string @return A new DiagnosticType
[ "Create", "a", "DiagnosticType", "at", "a", "given", "CheckLevel", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DiagnosticType.java#L84-L88
24,190
google/closure-compiler
src/com/google/javascript/jscomp/TypeInferencePass.java
TypeInferencePass.process
@Override public void process(Node externsRoot, Node jsRoot) { Node externsAndJs = jsRoot.getParent(); checkState(externsAndJs != null); checkState(externsRoot == null || externsAndJs.hasChild(externsRoot)); inferAllScopes(externsAndJs); }
java
@Override public void process(Node externsRoot, Node jsRoot) { Node externsAndJs = jsRoot.getParent(); checkState(externsAndJs != null); checkState(externsRoot == null || externsAndJs.hasChild(externsRoot)); inferAllScopes(externsAndJs); }
[ "@", "Override", "public", "void", "process", "(", "Node", "externsRoot", ",", "Node", "jsRoot", ")", "{", "Node", "externsAndJs", "=", "jsRoot", ".", "getParent", "(", ")", ";", "checkState", "(", "externsAndJs", "!=", "null", ")", ";", "checkState", "(",...
Main entry point for type inference when running over the whole tree. @param externsRoot The root of the externs parse tree. @param jsRoot The root of the input parse tree to be checked.
[ "Main", "entry", "point", "for", "type", "inference", "when", "running", "over", "the", "whole", "tree", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeInferencePass.java#L61-L68
24,191
google/closure-compiler
src/com/google/javascript/jscomp/TypeInferencePass.java
TypeInferencePass.inferAllScopes
void inferAllScopes(Node node) { // Type analysis happens in two major phases. // 1) Finding all the symbols. // 2) Propagating all the inferred types. // // The order of this analysis is non-obvious. In a complete inference // system, we may need to backtrack arbitrarily far. But the compile-ti...
java
void inferAllScopes(Node node) { // Type analysis happens in two major phases. // 1) Finding all the symbols. // 2) Propagating all the inferred types. // // The order of this analysis is non-obvious. In a complete inference // system, we may need to backtrack arbitrarily far. But the compile-ti...
[ "void", "inferAllScopes", "(", "Node", "node", ")", "{", "// Type analysis happens in two major phases.", "// 1) Finding all the symbols.", "// 2) Propagating all the inferred types.", "//", "// The order of this analysis is non-obvious. In a complete inference", "// system, we may need to b...
Entry point for type inference when running over part of the tree.
[ "Entry", "point", "for", "type", "inference", "when", "running", "over", "part", "of", "the", "tree", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeInferencePass.java#L71-L108
24,192
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java
PeepholeMinimizeConditions.optimizeSubtree
@Override @SuppressWarnings("fallthrough") public Node optimizeSubtree(Node node) { switch (node.getToken()) { case THROW: case RETURN: { Node result = tryRemoveRedundantExit(node); if (result != node) { return result; } return tryReplaceExitWithBreak(node);...
java
@Override @SuppressWarnings("fallthrough") public Node optimizeSubtree(Node node) { switch (node.getToken()) { case THROW: case RETURN: { Node result = tryRemoveRedundantExit(node); if (result != node) { return result; } return tryReplaceExitWithBreak(node);...
[ "@", "Override", "@", "SuppressWarnings", "(", "\"fallthrough\"", ")", "public", "Node", "optimizeSubtree", "(", "Node", "node", ")", "{", "switch", "(", "node", ".", "getToken", "(", ")", ")", "{", "case", "THROW", ":", "case", "RETURN", ":", "{", "Node...
Tries to apply our various peephole minimizations on the passed in node.
[ "Tries", "to", "apply", "our", "various", "peephole", "minimizations", "on", "the", "passed", "in", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L60-L108
24,193
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java
PeepholeMinimizeConditions.tryMinimizeExprResult
private Node tryMinimizeExprResult(Node n) { Node originalExpr = n.getFirstChild(); MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalExpr); MeasuredNode mNode = minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT); if (mNode.isNot()) { // Remove the leading NO...
java
private Node tryMinimizeExprResult(Node n) { Node originalExpr = n.getFirstChild(); MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalExpr); MeasuredNode mNode = minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT); if (mNode.isNot()) { // Remove the leading NO...
[ "private", "Node", "tryMinimizeExprResult", "(", "Node", "n", ")", "{", "Node", "originalExpr", "=", "n", ".", "getFirstChild", "(", ")", ";", "MinimizedCondition", "minCond", "=", "MinimizedCondition", ".", "fromConditionNode", "(", "originalExpr", ")", ";", "M...
Try to remove leading NOTs from EXPR_RESULTS. Returns the replacement for n or the original if no replacement was necessary.
[ "Try", "to", "remove", "leading", "NOTs", "from", "EXPR_RESULTS", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L444-L456
24,194
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java
PeepholeMinimizeConditions.tryMinimizeHook
private Node tryMinimizeHook(Node n) { Node originalCond = n.getFirstChild(); MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalCond); MeasuredNode mNode = minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT); if (mNode.isNot()) { // Swap the HOOK Node th...
java
private Node tryMinimizeHook(Node n) { Node originalCond = n.getFirstChild(); MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalCond); MeasuredNode mNode = minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT); if (mNode.isNot()) { // Swap the HOOK Node th...
[ "private", "Node", "tryMinimizeHook", "(", "Node", "n", ")", "{", "Node", "originalCond", "=", "n", ".", "getFirstChild", "(", ")", ";", "MinimizedCondition", "minCond", "=", "MinimizedCondition", ".", "fromConditionNode", "(", "originalCond", ")", ";", "Measure...
Try flipping HOOKs that have negated conditions. Returns the replacement for n or the original if no replacement was necessary.
[ "Try", "flipping", "HOOKs", "that", "have", "negated", "conditions", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L464-L480
24,195
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java
PeepholeMinimizeConditions.consumesDanglingElse
private static boolean consumesDanglingElse(Node n) { while (true) { switch (n.getToken()) { case IF: if (n.getChildCount() < 3) { return true; } // This IF node has no else clause. n = n.getLastChild(); continue; case BLOCK: ...
java
private static boolean consumesDanglingElse(Node n) { while (true) { switch (n.getToken()) { case IF: if (n.getChildCount() < 3) { return true; } // This IF node has no else clause. n = n.getLastChild(); continue; case BLOCK: ...
[ "private", "static", "boolean", "consumesDanglingElse", "(", "Node", "n", ")", "{", "while", "(", "true", ")", "{", "switch", "(", "n", ".", "getToken", "(", ")", ")", "{", "case", "IF", ":", "if", "(", "n", ".", "getChildCount", "(", ")", "<", "3"...
Does a statement consume a 'dangling else'? A statement consumes a 'dangling else' if an 'else' token following the statement would be considered by the parser to be part of the statement.
[ "Does", "a", "statement", "consume", "a", "dangling", "else", "?", "A", "statement", "consumes", "a", "dangling", "else", "if", "an", "else", "token", "following", "the", "statement", "would", "be", "considered", "by", "the", "parser", "to", "be", "part", ...
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L915-L942
24,196
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java
PeepholeMinimizeConditions.isPropertyAssignmentInExpression
private static boolean isPropertyAssignmentInExpression(Node n) { Predicate<Node> isPropertyAssignmentInExpressionPredicate = new Predicate<Node>() { @Override public boolean apply(Node input) { return (input.isGetProp() && input.getParent().isAssign()); } }; r...
java
private static boolean isPropertyAssignmentInExpression(Node n) { Predicate<Node> isPropertyAssignmentInExpressionPredicate = new Predicate<Node>() { @Override public boolean apply(Node input) { return (input.isGetProp() && input.getParent().isAssign()); } }; r...
[ "private", "static", "boolean", "isPropertyAssignmentInExpression", "(", "Node", "n", ")", "{", "Predicate", "<", "Node", ">", "isPropertyAssignmentInExpressionPredicate", "=", "new", "Predicate", "<", "Node", ">", "(", ")", "{", "@", "Override", "public", "boolea...
Does the expression contain a property assignment?
[ "Does", "the", "expression", "contain", "a", "property", "assignment?" ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L954-L966
24,197
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java
PeepholeMinimizeConditions.tryMinimizeCondition
private Node tryMinimizeCondition(Node n) { n = performConditionSubstitutions(n); MinimizedCondition minCond = MinimizedCondition.fromConditionNode(n); return replaceNode( n, minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED)); }
java
private Node tryMinimizeCondition(Node n) { n = performConditionSubstitutions(n); MinimizedCondition minCond = MinimizedCondition.fromConditionNode(n); return replaceNode( n, minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED)); }
[ "private", "Node", "tryMinimizeCondition", "(", "Node", "n", ")", "{", "n", "=", "performConditionSubstitutions", "(", "n", ")", ";", "MinimizedCondition", "minCond", "=", "MinimizedCondition", ".", "fromConditionNode", "(", "n", ")", ";", "return", "replaceNode",...
Try to minimize condition expression, as there are additional assumptions that can be made when it is known that the final result is a boolean. @return The replacement for n, or the original if no change was made.
[ "Try", "to", "minimize", "condition", "expression", "as", "there", "are", "additional", "assumptions", "that", "can", "be", "made", "when", "it", "is", "known", "that", "the", "final", "result", "is", "a", "boolean", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L975-L981
24,198
google/closure-compiler
src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java
PeepholeMinimizeConditions.maybeReplaceChildWithNumber
private Node maybeReplaceChildWithNumber(Node n, Node parent, int num) { Node newNode = IR.number(num); if (!newNode.isEquivalentTo(n)) { parent.replaceChild(n, newNode); reportChangeToEnclosingScope(newNode); markFunctionsDeleted(n); return newNode; } return n; }
java
private Node maybeReplaceChildWithNumber(Node n, Node parent, int num) { Node newNode = IR.number(num); if (!newNode.isEquivalentTo(n)) { parent.replaceChild(n, newNode); reportChangeToEnclosingScope(newNode); markFunctionsDeleted(n); return newNode; } return n; }
[ "private", "Node", "maybeReplaceChildWithNumber", "(", "Node", "n", ",", "Node", "parent", ",", "int", "num", ")", "{", "Node", "newNode", "=", "IR", ".", "number", "(", "num", ")", ";", "if", "(", "!", "newNode", ".", "isEquivalentTo", "(", "n", ")", ...
Replaces a node with a number node if the new number node is not equivalent to the current node. Returns the replacement for n if it was replaced, otherwise returns n.
[ "Replaces", "a", "node", "with", "a", "number", "node", "if", "the", "new", "number", "node", "is", "not", "equivalent", "to", "the", "current", "node", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeMinimizeConditions.java#L1140-L1151
24,199
google/closure-compiler
src/com/google/javascript/jscomp/ComposeWarningsGuard.java
ComposeWarningsGuard.enables
@Override public boolean enables(DiagnosticGroup group) { for (WarningsGuard guard : guards) { if (guard.enables(group)) { return true; } else if (guard.disables(group)) { return false; } } return false; }
java
@Override public boolean enables(DiagnosticGroup group) { for (WarningsGuard guard : guards) { if (guard.enables(group)) { return true; } else if (guard.disables(group)) { return false; } } return false; }
[ "@", "Override", "public", "boolean", "enables", "(", "DiagnosticGroup", "group", ")", "{", "for", "(", "WarningsGuard", "guard", ":", "guards", ")", "{", "if", "(", "guard", ".", "enables", "(", "group", ")", ")", "{", "return", "true", ";", "}", "els...
Determines whether this guard will "elevate" the status of any disabled diagnostic type in the group to a warning or an error.
[ "Determines", "whether", "this", "guard", "will", "elevate", "the", "status", "of", "any", "disabled", "diagnostic", "type", "in", "the", "group", "to", "a", "warning", "or", "an", "error", "." ]
d81e36740f6a9e8ac31a825ee8758182e1dc5aae
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ComposeWarningsGuard.java#L146-L157