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,300 | google/closure-compiler | src/com/google/javascript/jscomp/NodeUtil.java | NodeUtil.getInvocationArgsCount | static int getInvocationArgsCount(Node invocation) {
if (invocation.isTaggedTemplateLit()) {
Iterable<Node> args = new TemplateArgsIterable(invocation.getLastChild());
return Iterables.size(args) + 1;
} else {
return invocation.getChildCount() - 1;
}
} | java | static int getInvocationArgsCount(Node invocation) {
if (invocation.isTaggedTemplateLit()) {
Iterable<Node> args = new TemplateArgsIterable(invocation.getLastChild());
return Iterables.size(args) + 1;
} else {
return invocation.getChildCount() - 1;
}
} | [
"static",
"int",
"getInvocationArgsCount",
"(",
"Node",
"invocation",
")",
"{",
"if",
"(",
"invocation",
".",
"isTaggedTemplateLit",
"(",
")",
")",
"{",
"Iterable",
"<",
"Node",
">",
"args",
"=",
"new",
"TemplateArgsIterable",
"(",
"invocation",
".",
"getLastC... | Returns the number of arguments in this invocation. For template literals it takes into
account the implicit first argument of ITemplateArray | [
"Returns",
"the",
"number",
"of",
"arguments",
"in",
"this",
"invocation",
".",
"For",
"template",
"literals",
"it",
"takes",
"into",
"account",
"the",
"implicit",
"first",
"argument",
"of",
"ITemplateArray"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5883-L5890 |
24,301 | google/closure-compiler | src/com/google/javascript/jscomp/NodeUtil.java | NodeUtil.getAllVarsDeclaredInFunction | static void getAllVarsDeclaredInFunction(
final Map<String, Var> nameVarMap,
final List<Var> orderedVars,
AbstractCompiler compiler,
ScopeCreator scopeCreator,
final Scope scope) {
checkState(nameVarMap.isEmpty());
checkState(orderedVars.isEmpty());
checkState(scope.isFunction... | java | static void getAllVarsDeclaredInFunction(
final Map<String, Var> nameVarMap,
final List<Var> orderedVars,
AbstractCompiler compiler,
ScopeCreator scopeCreator,
final Scope scope) {
checkState(nameVarMap.isEmpty());
checkState(orderedVars.isEmpty());
checkState(scope.isFunction... | [
"static",
"void",
"getAllVarsDeclaredInFunction",
"(",
"final",
"Map",
"<",
"String",
",",
"Var",
">",
"nameVarMap",
",",
"final",
"List",
"<",
"Var",
">",
"orderedVars",
",",
"AbstractCompiler",
"compiler",
",",
"ScopeCreator",
"scopeCreator",
",",
"final",
"Sc... | Records a mapping of names to vars of everything reachable in a function. Should only be called
with a function scope. Does not enter new control flow areas aka embedded functions.
@param nameVarMap an empty map that gets populated with the keys being variable names and
values being variable objects
@param orderedVars... | [
"Records",
"a",
"mapping",
"of",
"names",
"to",
"vars",
"of",
"everything",
"reachable",
"in",
"a",
"function",
".",
"Should",
"only",
"be",
"called",
"with",
"a",
"function",
"scope",
".",
"Does",
"not",
"enter",
"new",
"control",
"flow",
"areas",
"aka",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5935-L5972 |
24,302 | google/closure-compiler | src/com/google/javascript/jscomp/NodeUtil.java | NodeUtil.isObjLitProperty | public static boolean isObjLitProperty(Node node) {
return node.isStringKey()
|| node.isGetterDef()
|| node.isSetterDef()
|| node.isMemberFunctionDef()
|| node.isComputedProp();
} | java | public static boolean isObjLitProperty(Node node) {
return node.isStringKey()
|| node.isGetterDef()
|| node.isSetterDef()
|| node.isMemberFunctionDef()
|| node.isComputedProp();
} | [
"public",
"static",
"boolean",
"isObjLitProperty",
"(",
"Node",
"node",
")",
"{",
"return",
"node",
".",
"isStringKey",
"(",
")",
"||",
"node",
".",
"isGetterDef",
"(",
")",
"||",
"node",
".",
"isSetterDef",
"(",
")",
"||",
"node",
".",
"isMemberFunctionDe... | Returns true if the node is a property of an object literal. | [
"Returns",
"true",
"if",
"the",
"node",
"is",
"a",
"property",
"of",
"an",
"object",
"literal",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L5975-L5981 |
24,303 | google/closure-compiler | src/com/google/javascript/jscomp/NodeUtil.java | NodeUtil.addFeatureToScript | static void addFeatureToScript(Node scriptNode, Feature feature) {
checkState(scriptNode.isScript(), scriptNode);
FeatureSet currentFeatures = getFeatureSetOfScript(scriptNode);
FeatureSet newFeatures =
currentFeatures != null
? currentFeatures.with(feature)
: FeatureSet.BARE... | java | static void addFeatureToScript(Node scriptNode, Feature feature) {
checkState(scriptNode.isScript(), scriptNode);
FeatureSet currentFeatures = getFeatureSetOfScript(scriptNode);
FeatureSet newFeatures =
currentFeatures != null
? currentFeatures.with(feature)
: FeatureSet.BARE... | [
"static",
"void",
"addFeatureToScript",
"(",
"Node",
"scriptNode",
",",
"Feature",
"feature",
")",
"{",
"checkState",
"(",
"scriptNode",
".",
"isScript",
"(",
")",
",",
"scriptNode",
")",
";",
"FeatureSet",
"currentFeatures",
"=",
"getFeatureSetOfScript",
"(",
"... | Adds the given features to a SCRIPT node's FeatureSet property. | [
"Adds",
"the",
"given",
"features",
"to",
"a",
"SCRIPT",
"node",
"s",
"FeatureSet",
"property",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L6003-L6011 |
24,304 | google/closure-compiler | src/com/google/javascript/jscomp/DestructuredTarget.java | DestructuredTarget.inferType | JSType inferType() {
JSType inferredType = inferTypeWithoutUsingDefaultValue();
if (!inferredType.isUnknownType() && hasDefaultValue()) {
JSType defaultValueType = getDefaultValue().getJSType();
if (defaultValueType == null) {
defaultValueType = registry.getNativeType(JSTypeNative.UNKNOWN_TY... | java | JSType inferType() {
JSType inferredType = inferTypeWithoutUsingDefaultValue();
if (!inferredType.isUnknownType() && hasDefaultValue()) {
JSType defaultValueType = getDefaultValue().getJSType();
if (defaultValueType == null) {
defaultValueType = registry.getNativeType(JSTypeNative.UNKNOWN_TY... | [
"JSType",
"inferType",
"(",
")",
"{",
"JSType",
"inferredType",
"=",
"inferTypeWithoutUsingDefaultValue",
"(",
")",
";",
"if",
"(",
"!",
"inferredType",
".",
"isUnknownType",
"(",
")",
"&&",
"hasDefaultValue",
"(",
")",
")",
"{",
"JSType",
"defaultValueType",
... | Infers the type of this target
<p>e.g. given `a` in const {a = 3} = {}; returns `number` | [
"Infers",
"the",
"type",
"of",
"this",
"target"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DestructuredTarget.java#L282-L294 |
24,305 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.process | @Override
public void process(Node externs, Node root) {
checkState(compiler.getLifeCycleStage().isNormalized());
if (!allowRemovalOfExternProperties) {
referencedPropertyNames.addAll(compiler.getExternProperties());
}
traverseAndRemoveUnusedReferences(root);
// This pass may remove definiti... | java | @Override
public void process(Node externs, Node root) {
checkState(compiler.getLifeCycleStage().isNormalized());
if (!allowRemovalOfExternProperties) {
referencedPropertyNames.addAll(compiler.getExternProperties());
}
traverseAndRemoveUnusedReferences(root);
// This pass may remove definiti... | [
"@",
"Override",
"public",
"void",
"process",
"(",
"Node",
"externs",
",",
"Node",
"root",
")",
"{",
"checkState",
"(",
"compiler",
".",
"getLifeCycleStage",
"(",
")",
".",
"isNormalized",
"(",
")",
")",
";",
"if",
"(",
"!",
"allowRemovalOfExternProperties",... | Traverses the root, removing all unused variables. Multiple traversals
may occur to ensure all unused variables are removed. | [
"Traverses",
"the",
"root",
"removing",
"all",
"unused",
"variables",
".",
"Multiple",
"traversals",
"may",
"occur",
"to",
"ensure",
"all",
"unused",
"variables",
"are",
"removed",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L242-L251 |
24,306 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.traverseAndRemoveUnusedReferences | private void traverseAndRemoveUnusedReferences(Node root) {
// Create scope from parent of root node, which also has externs as a child, so we'll
// have extern definitions in scope.
Scope scope = scopeCreator.createScope(root.getParent(), null);
if (!scope.hasSlot(NodeUtil.JSC_PROPERTY_NAME_FN)) {
... | java | private void traverseAndRemoveUnusedReferences(Node root) {
// Create scope from parent of root node, which also has externs as a child, so we'll
// have extern definitions in scope.
Scope scope = scopeCreator.createScope(root.getParent(), null);
if (!scope.hasSlot(NodeUtil.JSC_PROPERTY_NAME_FN)) {
... | [
"private",
"void",
"traverseAndRemoveUnusedReferences",
"(",
"Node",
"root",
")",
"{",
"// Create scope from parent of root node, which also has externs as a child, so we'll",
"// have extern definitions in scope.",
"Scope",
"scope",
"=",
"scopeCreator",
".",
"createScope",
"(",
"r... | Traverses a node recursively. Call this once per pass. | [
"Traverses",
"a",
"node",
"recursively",
".",
"Call",
"this",
"once",
"per",
"pass",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L256-L277 |
24,307 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.traverseClass | private void traverseClass(Node classNode, Scope scope) {
checkArgument(classNode.isClass());
if (NodeUtil.isClassDeclaration(classNode)) {
traverseClassDeclaration(classNode, scope);
} else {
traverseClassExpression(classNode, scope);
}
} | java | private void traverseClass(Node classNode, Scope scope) {
checkArgument(classNode.isClass());
if (NodeUtil.isClassDeclaration(classNode)) {
traverseClassDeclaration(classNode, scope);
} else {
traverseClassExpression(classNode, scope);
}
} | [
"private",
"void",
"traverseClass",
"(",
"Node",
"classNode",
",",
"Scope",
"scope",
")",
"{",
"checkArgument",
"(",
"classNode",
".",
"isClass",
"(",
")",
")",
";",
"if",
"(",
"NodeUtil",
".",
"isClassDeclaration",
"(",
"classNode",
")",
")",
"{",
"traver... | Handle a class that is not the RHS child of an assignment or a variable declaration
initializer.
<p>For
@param classNode
@param scope | [
"Handle",
"a",
"class",
"that",
"is",
"not",
"the",
"RHS",
"child",
"of",
"an",
"assignment",
"or",
"a",
"variable",
"declaration",
"initializer",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L1198-L1205 |
24,308 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.traverseFunction | private void traverseFunction(Node function, Scope parentScope) {
checkState(function.getChildCount() == 3, function);
checkState(function.isFunction(), function);
final Node paramlist = NodeUtil.getFunctionParameters(function);
final Node body = function.getLastChild();
checkState(body.getNext() =... | java | private void traverseFunction(Node function, Scope parentScope) {
checkState(function.getChildCount() == 3, function);
checkState(function.isFunction(), function);
final Node paramlist = NodeUtil.getFunctionParameters(function);
final Node body = function.getLastChild();
checkState(body.getNext() =... | [
"private",
"void",
"traverseFunction",
"(",
"Node",
"function",
",",
"Scope",
"parentScope",
")",
"{",
"checkState",
"(",
"function",
".",
"getChildCount",
"(",
")",
"==",
"3",
",",
"function",
")",
";",
"checkState",
"(",
"function",
".",
"isFunction",
"(",... | Traverses a function
ES6 scopes of a function include the parameter scope and the body scope
of the function.
Note that CATCH blocks also create a new scope, but only for the
catch variable. Declarations within the block actually belong to the
enclosing scope. Because we don't remove catch variables, there's
no need ... | [
"Traverses",
"a",
"function"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L1295-L1325 |
24,309 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.removeUnreferencedFunctionArgs | private void removeUnreferencedFunctionArgs(Scope fparamScope) {
// Notice that removing unreferenced function args breaks
// Function.prototype.length. In advanced mode, we don't really care
// about this: we consider "length" the equivalent of reflecting on
// the function's lexical source.
//
... | java | private void removeUnreferencedFunctionArgs(Scope fparamScope) {
// Notice that removing unreferenced function args breaks
// Function.prototype.length. In advanced mode, we don't really care
// about this: we consider "length" the equivalent of reflecting on
// the function's lexical source.
//
... | [
"private",
"void",
"removeUnreferencedFunctionArgs",
"(",
"Scope",
"fparamScope",
")",
"{",
"// Notice that removing unreferenced function args breaks",
"// Function.prototype.length. In advanced mode, we don't really care",
"// about this: we consider \"length\" the equivalent of reflecting on"... | Removes unreferenced arguments from a function declaration and when
possible the function's callSites.
@param fparamScope The function parameter | [
"Removes",
"unreferenced",
"arguments",
"from",
"a",
"function",
"declaration",
"and",
"when",
"possible",
"the",
"function",
"s",
"callSites",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L1339-L1367 |
24,310 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.markUnusedParameters | private void markUnusedParameters(Node paramList, Scope fparamScope) {
for (Node param = paramList.getFirstChild(); param != null; param = param.getNext()) {
if (param.isUnusedParameter()) {
continue;
}
Node lValue = nameOfParam(param);
if (lValue == null) {
continue;
... | java | private void markUnusedParameters(Node paramList, Scope fparamScope) {
for (Node param = paramList.getFirstChild(); param != null; param = param.getNext()) {
if (param.isUnusedParameter()) {
continue;
}
Node lValue = nameOfParam(param);
if (lValue == null) {
continue;
... | [
"private",
"void",
"markUnusedParameters",
"(",
"Node",
"paramList",
",",
"Scope",
"fparamScope",
")",
"{",
"for",
"(",
"Node",
"param",
"=",
"paramList",
".",
"getFirstChild",
"(",
")",
";",
"param",
"!=",
"null",
";",
"param",
"=",
"param",
".",
"getNext... | Mark any remaining unused parameters as being unused so it can be used elsewhere.
@param paramList list of function's parameters
@param fparamScope | [
"Mark",
"any",
"remaining",
"unused",
"parameters",
"as",
"being",
"unused",
"so",
"it",
"can",
"be",
"used",
"elsewhere",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L1415-L1432 |
24,311 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.maybeRemoveUnusedTrailingParameters | private void maybeRemoveUnusedTrailingParameters(Node argList, Scope fparamScope) {
Node lastArg;
while ((lastArg = argList.getLastChild()) != null) {
Node lValue = lastArg;
if (lastArg.isDefaultValue()) {
lValue = lastArg.getFirstChild();
if (NodeUtil.mayHaveSideEffects(lastArg.getL... | java | private void maybeRemoveUnusedTrailingParameters(Node argList, Scope fparamScope) {
Node lastArg;
while ((lastArg = argList.getLastChild()) != null) {
Node lValue = lastArg;
if (lastArg.isDefaultValue()) {
lValue = lastArg.getFirstChild();
if (NodeUtil.mayHaveSideEffects(lastArg.getL... | [
"private",
"void",
"maybeRemoveUnusedTrailingParameters",
"(",
"Node",
"argList",
",",
"Scope",
"fparamScope",
")",
"{",
"Node",
"lastArg",
";",
"while",
"(",
"(",
"lastArg",
"=",
"argList",
".",
"getLastChild",
"(",
")",
")",
"!=",
"null",
")",
"{",
"Node",... | Strip as many unreferenced args off the end of the function declaration as possible. We start
from the end of the function declaration because removing parameters from the middle of the
param list could mess up the interpretation of parameters being sent over by any function
calls.
@param argList list of function's ar... | [
"Strip",
"as",
"many",
"unreferenced",
"args",
"off",
"the",
"end",
"of",
"the",
"function",
"declaration",
"as",
"possible",
".",
"We",
"start",
"from",
"the",
"end",
"of",
"the",
"function",
"declaration",
"because",
"removing",
"parameters",
"from",
"the",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L1443-L1479 |
24,312 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.removeUnreferencedVarsAndPolyfills | private void removeUnreferencedVarsAndPolyfills() {
for (Entry<Var, VarInfo> entry : varInfoMap.entrySet()) {
Var var = entry.getKey();
VarInfo varInfo = entry.getValue();
if (!varInfo.isRemovable()) {
continue;
}
// Regardless of what happens to the original declaration,
... | java | private void removeUnreferencedVarsAndPolyfills() {
for (Entry<Var, VarInfo> entry : varInfoMap.entrySet()) {
Var var = entry.getKey();
VarInfo varInfo = entry.getValue();
if (!varInfo.isRemovable()) {
continue;
}
// Regardless of what happens to the original declaration,
... | [
"private",
"void",
"removeUnreferencedVarsAndPolyfills",
"(",
")",
"{",
"for",
"(",
"Entry",
"<",
"Var",
",",
"VarInfo",
">",
"entry",
":",
"varInfoMap",
".",
"entrySet",
"(",
")",
")",
"{",
"Var",
"var",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Va... | Removes any vars in the scope that were not referenced. Removes any assignments to those
variables as well. | [
"Removes",
"any",
"vars",
"in",
"the",
"scope",
"that",
"were",
"not",
"referenced",
".",
"Removes",
"any",
"assignments",
"to",
"those",
"variables",
"as",
"well",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L1568-L1615 |
24,313 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.isLocalDefaultValueAssignment | private static boolean isLocalDefaultValueAssignment(Node targetNode, Node valueNode) {
return valueNode.isOr()
&& targetNode.isQualifiedName()
&& valueNode.getFirstChild().isEquivalentTo(targetNode)
&& NodeUtil.evaluatesToLocalValue(valueNode.getLastChild());
} | java | private static boolean isLocalDefaultValueAssignment(Node targetNode, Node valueNode) {
return valueNode.isOr()
&& targetNode.isQualifiedName()
&& valueNode.getFirstChild().isEquivalentTo(targetNode)
&& NodeUtil.evaluatesToLocalValue(valueNode.getLastChild());
} | [
"private",
"static",
"boolean",
"isLocalDefaultValueAssignment",
"(",
"Node",
"targetNode",
",",
"Node",
"valueNode",
")",
"{",
"return",
"valueNode",
".",
"isOr",
"(",
")",
"&&",
"targetNode",
".",
"isQualifiedName",
"(",
")",
"&&",
"valueNode",
".",
"getFirstC... | True if targetNode is a qualified name and the valueNode is of the form `targetQualifiedName ||
localValue`. | [
"True",
"if",
"targetNode",
"is",
"a",
"qualified",
"name",
"and",
"the",
"valueNode",
"is",
"of",
"the",
"form",
"targetQualifiedName",
"||",
"localValue",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L2292-L2297 |
24,314 | google/closure-compiler | src/com/google/javascript/jscomp/RemoveUnusedCode.java | RemoveUnusedCode.createPolyfillInfo | private PolyfillInfo createPolyfillInfo(Node call, Scope scope, String name) {
checkState(scope.isGlobal());
checkState(call.getParent().isExprResult());
// Make the removable and polyfill info. Add continuations for all arguments.
RemovableBuilder builder = new RemovableBuilder();
for (Node n = ca... | java | private PolyfillInfo createPolyfillInfo(Node call, Scope scope, String name) {
checkState(scope.isGlobal());
checkState(call.getParent().isExprResult());
// Make the removable and polyfill info. Add continuations for all arguments.
RemovableBuilder builder = new RemovableBuilder();
for (Node n = ca... | [
"private",
"PolyfillInfo",
"createPolyfillInfo",
"(",
"Node",
"call",
",",
"Scope",
"scope",
",",
"String",
"name",
")",
"{",
"checkState",
"(",
"scope",
".",
"isGlobal",
"(",
")",
")",
";",
"checkState",
"(",
"call",
".",
"getParent",
"(",
")",
".",
"is... | Makes a new PolyfillInfo, including the correct Removable. Parses the name to determine whether
this is a global, static, or prototype polyfill. | [
"Makes",
"a",
"new",
"PolyfillInfo",
"including",
"the",
"correct",
"Removable",
".",
"Parses",
"the",
"name",
"to",
"determine",
"whether",
"this",
"is",
"a",
"global",
"static",
"or",
"prototype",
"polyfill",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L2625-L2650 |
24,315 | google/closure-compiler | src/com/google/javascript/jscomp/gwt/client/JsfileParser.java | JsfileParser.assoc | private static Set<JsArray<String>> assoc() {
return new TreeSet<>(Ordering.<String>natural().lexicographical().onResultOf(JsArray::asList));
} | java | private static Set<JsArray<String>> assoc() {
return new TreeSet<>(Ordering.<String>natural().lexicographical().onResultOf(JsArray::asList));
} | [
"private",
"static",
"Set",
"<",
"JsArray",
"<",
"String",
">",
">",
"assoc",
"(",
")",
"{",
"return",
"new",
"TreeSet",
"<>",
"(",
"Ordering",
".",
"<",
"String",
">",
"natural",
"(",
")",
".",
"lexicographical",
"(",
")",
".",
"onResultOf",
"(",
"J... | Returns an associative multimap. | [
"Returns",
"an",
"associative",
"multimap",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/gwt/client/JsfileParser.java#L406-L408 |
24,316 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.isNominalConstructor | public final boolean isNominalConstructor() {
if (isConstructor() || isInterface()) {
FunctionType fn = toMaybeFunctionType();
if (fn == null) {
return false;
}
// Programmer-defined constructors will have a link
// back to the original function in the source tree.
// St... | java | public final boolean isNominalConstructor() {
if (isConstructor() || isInterface()) {
FunctionType fn = toMaybeFunctionType();
if (fn == null) {
return false;
}
// Programmer-defined constructors will have a link
// back to the original function in the source tree.
// St... | [
"public",
"final",
"boolean",
"isNominalConstructor",
"(",
")",
"{",
"if",
"(",
"isConstructor",
"(",
")",
"||",
"isInterface",
"(",
")",
")",
"{",
"FunctionType",
"fn",
"=",
"toMaybeFunctionType",
"(",
")",
";",
"if",
"(",
"fn",
"==",
"null",
")",
"{",
... | Whether this type is the original constructor of a nominal type.
Does not include structural constructors. | [
"Whether",
"this",
"type",
"is",
"the",
"original",
"constructor",
"of",
"a",
"nominal",
"type",
".",
"Does",
"not",
"include",
"structural",
"constructors",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L598-L616 |
24,317 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.deepestResolvedTypeNameOf | @Nullable
private String deepestResolvedTypeNameOf(ObjectType objType) {
if (!objType.isResolved() || !(objType instanceof ProxyObjectType)) {
return objType.getReferenceName();
}
ObjectType internal = ((ProxyObjectType) objType).getReferencedObjTypeInternal();
return (internal != null && inter... | java | @Nullable
private String deepestResolvedTypeNameOf(ObjectType objType) {
if (!objType.isResolved() || !(objType instanceof ProxyObjectType)) {
return objType.getReferenceName();
}
ObjectType internal = ((ProxyObjectType) objType).getReferencedObjTypeInternal();
return (internal != null && inter... | [
"@",
"Nullable",
"private",
"String",
"deepestResolvedTypeNameOf",
"(",
"ObjectType",
"objType",
")",
"{",
"if",
"(",
"!",
"objType",
".",
"isResolved",
"(",
")",
"||",
"!",
"(",
"objType",
"instanceof",
"ProxyObjectType",
")",
")",
"{",
"return",
"objType",
... | Named types may be proxies of concrete types. | [
"Named",
"types",
"may",
"be",
"proxies",
"of",
"concrete",
"types",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L792-L802 |
24,318 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.findPropertyTypeWithoutConsideringTemplateTypes | @ForOverride
@Nullable
protected JSType findPropertyTypeWithoutConsideringTemplateTypes(String propertyName) {
ObjectType autoboxObjType = ObjectType.cast(autoboxesTo());
if (autoboxObjType != null) {
return autoboxObjType.findPropertyType(propertyName);
}
return null;
} | java | @ForOverride
@Nullable
protected JSType findPropertyTypeWithoutConsideringTemplateTypes(String propertyName) {
ObjectType autoboxObjType = ObjectType.cast(autoboxesTo());
if (autoboxObjType != null) {
return autoboxObjType.findPropertyType(propertyName);
}
return null;
} | [
"@",
"ForOverride",
"@",
"Nullable",
"protected",
"JSType",
"findPropertyTypeWithoutConsideringTemplateTypes",
"(",
"String",
"propertyName",
")",
"{",
"ObjectType",
"autoboxObjType",
"=",
"ObjectType",
".",
"cast",
"(",
"autoboxesTo",
"(",
")",
")",
";",
"if",
"(",... | Looks up a property on this type, but without properly replacing any templates in the result.
<p>Subclasses can override this if they need more complicated logic for property lookup than
just autoboxing to an object.
<p>This is only for use by {@code findPropertyType(JSType)}. Call that method instead if you
need to ... | [
"Looks",
"up",
"a",
"property",
"on",
"this",
"type",
"but",
"without",
"properly",
"replacing",
"any",
"templates",
"in",
"the",
"result",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L910-L918 |
24,319 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.autobox | public JSType autobox() {
JSType restricted = restrictByNotNullOrUndefined();
JSType autobox = restricted.autoboxesTo();
return autobox == null ? restricted : autobox;
} | java | public JSType autobox() {
JSType restricted = restrictByNotNullOrUndefined();
JSType autobox = restricted.autoboxesTo();
return autobox == null ? restricted : autobox;
} | [
"public",
"JSType",
"autobox",
"(",
")",
"{",
"JSType",
"restricted",
"=",
"restrictByNotNullOrUndefined",
"(",
")",
";",
"JSType",
"autobox",
"=",
"restricted",
".",
"autoboxesTo",
"(",
")",
";",
"return",
"autobox",
"==",
"null",
"?",
"restricted",
":",
"a... | Dereferences a type for property access.
Filters null/undefined and autoboxes the resulting type.
Never returns null. | [
"Dereferences",
"a",
"type",
"for",
"property",
"access",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L980-L984 |
24,320 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.getLeastSupertype | @SuppressWarnings("AmbiguousMethodReference")
static JSType getLeastSupertype(JSType thisType, JSType thatType) {
boolean areEquivalent = thisType.isEquivalentTo(thatType);
return areEquivalent ? thisType :
filterNoResolvedType(
thisType.registry.createUnionType(thisType, thatType));
} | java | @SuppressWarnings("AmbiguousMethodReference")
static JSType getLeastSupertype(JSType thisType, JSType thatType) {
boolean areEquivalent = thisType.isEquivalentTo(thatType);
return areEquivalent ? thisType :
filterNoResolvedType(
thisType.registry.createUnionType(thisType, thatType));
} | [
"@",
"SuppressWarnings",
"(",
"\"AmbiguousMethodReference\"",
")",
"static",
"JSType",
"getLeastSupertype",
"(",
"JSType",
"thisType",
",",
"JSType",
"thatType",
")",
"{",
"boolean",
"areEquivalent",
"=",
"thisType",
".",
"isEquivalentTo",
"(",
"thatType",
")",
";",... | A generic implementation meant to be used as a helper for common getLeastSupertype
implementations. | [
"A",
"generic",
"implementation",
"meant",
"to",
"be",
"used",
"as",
"a",
"helper",
"for",
"common",
"getLeastSupertype",
"implementations",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L1168-L1174 |
24,321 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.isSubtypeHelper | static boolean isSubtypeHelper(JSType thisType, JSType thatType,
ImplCache implicitImplCache, SubtypingMode subtypingMode) {
checkNotNull(thisType);
// unknown
if (thatType.isUnknownType()) {
return true;
}
// all type
if (thatType.isAllType()) {
return true;
}
// equal... | java | static boolean isSubtypeHelper(JSType thisType, JSType thatType,
ImplCache implicitImplCache, SubtypingMode subtypingMode) {
checkNotNull(thisType);
// unknown
if (thatType.isUnknownType()) {
return true;
}
// all type
if (thatType.isAllType()) {
return true;
}
// equal... | [
"static",
"boolean",
"isSubtypeHelper",
"(",
"JSType",
"thisType",
",",
"JSType",
"thatType",
",",
"ImplCache",
"implicitImplCache",
",",
"SubtypingMode",
"subtypingMode",
")",
"{",
"checkNotNull",
"(",
"thisType",
")",
";",
"// unknown",
"if",
"(",
"thatType",
".... | if implicitImplCache is null, there is no structural interface matching | [
"if",
"implicitImplCache",
"is",
"null",
"there",
"is",
"no",
"structural",
"interface",
"matching"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L1540-L1632 |
24,322 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.isBivariantType | static boolean isBivariantType(JSType type) {
ObjectType objType = type.toObjectType();
return objType != null
// && objType.isNativeObjectType()
&& BIVARIANT_TYPES.contains(objType.getReferenceName());
} | java | static boolean isBivariantType(JSType type) {
ObjectType objType = type.toObjectType();
return objType != null
// && objType.isNativeObjectType()
&& BIVARIANT_TYPES.contains(objType.getReferenceName());
} | [
"static",
"boolean",
"isBivariantType",
"(",
"JSType",
"type",
")",
"{",
"ObjectType",
"objType",
"=",
"type",
".",
"toObjectType",
"(",
")",
";",
"return",
"objType",
"!=",
"null",
"// && objType.isNativeObjectType()",
"&&",
"BIVARIANT_TYPES",
".",
"contains",
"(... | Determines if the supplied type should be checked as a bivariant
templatized type rather the standard invariant templatized type
rules. | [
"Determines",
"if",
"the",
"supplied",
"type",
"should",
"be",
"checked",
"as",
"a",
"bivariant",
"templatized",
"type",
"rather",
"the",
"standard",
"invariant",
"templatized",
"type",
"rules",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L1639-L1644 |
24,323 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.isIThenableSubtype | static boolean isIThenableSubtype(JSType type) {
if (type.isTemplatizedType()) {
TemplatizedType ttype = type.toMaybeTemplatizedType();
return ttype.getTemplateTypeMap().hasTemplateKey(ttype.registry.getThenableValueKey());
}
return false;
} | java | static boolean isIThenableSubtype(JSType type) {
if (type.isTemplatizedType()) {
TemplatizedType ttype = type.toMaybeTemplatizedType();
return ttype.getTemplateTypeMap().hasTemplateKey(ttype.registry.getThenableValueKey());
}
return false;
} | [
"static",
"boolean",
"isIThenableSubtype",
"(",
"JSType",
"type",
")",
"{",
"if",
"(",
"type",
".",
"isTemplatizedType",
"(",
")",
")",
"{",
"TemplatizedType",
"ttype",
"=",
"type",
".",
"toMaybeTemplatizedType",
"(",
")",
";",
"return",
"ttype",
".",
"getTe... | Determines if the specified type is exempt from standard invariant templatized typing rules. | [
"Determines",
"if",
"the",
"specified",
"type",
"is",
"exempt",
"from",
"standard",
"invariant",
"templatized",
"typing",
"rules",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L1649-L1655 |
24,324 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.resolve | public final JSType resolve(ErrorReporter reporter) {
if (resolved) {
if (resolveResult == null) {
// If there is a circular definition, keep the NamedType around. This is not ideal,
// but is still a better type than unknown.
return this;
}
return resolveResult;
}
... | java | public final JSType resolve(ErrorReporter reporter) {
if (resolved) {
if (resolveResult == null) {
// If there is a circular definition, keep the NamedType around. This is not ideal,
// but is still a better type than unknown.
return this;
}
return resolveResult;
}
... | [
"public",
"final",
"JSType",
"resolve",
"(",
"ErrorReporter",
"reporter",
")",
"{",
"if",
"(",
"resolved",
")",
"{",
"if",
"(",
"resolveResult",
"==",
"null",
")",
"{",
"// If there is a circular definition, keep the NamedType around. This is not ideal,",
"// but is still... | Resolve this type in the given scope.
The returned value must be equal to {@code this}, as defined by
{@link #isEquivalentTo}. It may or may not be the same object. This method
may modify the internal state of {@code this}, as long as it does
so in a way that preserves Object equality.
For efficiency, we should only ... | [
"Resolve",
"this",
"type",
"in",
"the",
"given",
"scope",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L1684-L1697 |
24,325 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.safeResolve | static final JSType safeResolve(
JSType type, ErrorReporter reporter) {
return type == null ? null : type.resolve(reporter);
} | java | static final JSType safeResolve(
JSType type, ErrorReporter reporter) {
return type == null ? null : type.resolve(reporter);
} | [
"static",
"final",
"JSType",
"safeResolve",
"(",
"JSType",
"type",
",",
"ErrorReporter",
"reporter",
")",
"{",
"return",
"type",
"==",
"null",
"?",
"null",
":",
"type",
".",
"resolve",
"(",
"reporter",
")",
";",
"}"
] | A null-safe resolve.
@see #resolve | [
"A",
"null",
"-",
"safe",
"resolve",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L1733-L1736 |
24,326 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.toAnnotationString | public final String toAnnotationString(Nullability nullability) {
return nullability == Nullability.EXPLICIT
? appendAsNonNull(new StringBuilder(), true).toString()
: appendTo(new StringBuilder(), true).toString();
} | java | public final String toAnnotationString(Nullability nullability) {
return nullability == Nullability.EXPLICIT
? appendAsNonNull(new StringBuilder(), true).toString()
: appendTo(new StringBuilder(), true).toString();
} | [
"public",
"final",
"String",
"toAnnotationString",
"(",
"Nullability",
"nullability",
")",
"{",
"return",
"nullability",
"==",
"Nullability",
".",
"EXPLICIT",
"?",
"appendAsNonNull",
"(",
"new",
"StringBuilder",
"(",
")",
",",
"true",
")",
".",
"toString",
"(",
... | Don't call from this package; use appendAsNonNull instead. | [
"Don",
"t",
"call",
"from",
"this",
"package",
";",
"use",
"appendAsNonNull",
"instead",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L1779-L1783 |
24,327 | google/closure-compiler | src/com/google/javascript/rhino/jstype/JSType.java | JSType.getInstantiatedTypeArgument | public JSType getInstantiatedTypeArgument(JSType supertype) {
TemplateType templateType =
Iterables.getOnlyElement(supertype.getTemplateTypeMap().getTemplateKeys());
return getTemplateTypeMap().getResolvedTemplateType(templateType);
} | java | public JSType getInstantiatedTypeArgument(JSType supertype) {
TemplateType templateType =
Iterables.getOnlyElement(supertype.getTemplateTypeMap().getTemplateKeys());
return getTemplateTypeMap().getResolvedTemplateType(templateType);
} | [
"public",
"JSType",
"getInstantiatedTypeArgument",
"(",
"JSType",
"supertype",
")",
"{",
"TemplateType",
"templateType",
"=",
"Iterables",
".",
"getOnlyElement",
"(",
"supertype",
".",
"getTemplateTypeMap",
"(",
")",
".",
"getTemplateKeys",
"(",
")",
")",
";",
"re... | Returns the template type argument in this type's map corresponding to the supertype's template
parameter, or the UNKNOWN_TYPE if the supertype template key is not present.
<p>Note: this only supports arguments that have a singleton list of template keys, and will
throw an exception for arguments with zero or multiple... | [
"Returns",
"the",
"template",
"type",
"argument",
"in",
"this",
"type",
"s",
"map",
"corresponding",
"to",
"the",
"supertype",
"s",
"template",
"parameter",
"or",
"the",
"UNKNOWN_TYPE",
"if",
"the",
"supertype",
"template",
"key",
"is",
"not",
"present",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSType.java#L2108-L2112 |
24,328 | google/closure-compiler | src/com/google/javascript/jscomp/AnalyzePrototypeProperties.java | AnalyzePrototypeProperties.getAllNameInfo | public Collection<NameInfo> getAllNameInfo() {
List<NameInfo> result = new ArrayList<>(propertyNameInfo.values());
result.addAll(varNameInfo.values());
return result;
} | java | public Collection<NameInfo> getAllNameInfo() {
List<NameInfo> result = new ArrayList<>(propertyNameInfo.values());
result.addAll(varNameInfo.values());
return result;
} | [
"public",
"Collection",
"<",
"NameInfo",
">",
"getAllNameInfo",
"(",
")",
"{",
"List",
"<",
"NameInfo",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
"propertyNameInfo",
".",
"values",
"(",
")",
")",
";",
"result",
".",
"addAll",
"(",
"varNameInfo",
... | Returns information on all prototype properties. | [
"Returns",
"information",
"on",
"all",
"prototype",
"properties",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AnalyzePrototypeProperties.java#L162-L166 |
24,329 | google/closure-compiler | src/com/google/javascript/jscomp/AnalyzePrototypeProperties.java | AnalyzePrototypeProperties.getNameInfoForName | private NameInfo getNameInfoForName(String name, SymbolType type) {
Map<String, NameInfo> map = type == PROPERTY ? propertyNameInfo : varNameInfo;
if (map.containsKey(name)) {
return map.get(name);
} else {
NameInfo nameInfo = new NameInfo(name);
map.put(name, nameInfo);
symbolGraph.... | java | private NameInfo getNameInfoForName(String name, SymbolType type) {
Map<String, NameInfo> map = type == PROPERTY ? propertyNameInfo : varNameInfo;
if (map.containsKey(name)) {
return map.get(name);
} else {
NameInfo nameInfo = new NameInfo(name);
map.put(name, nameInfo);
symbolGraph.... | [
"private",
"NameInfo",
"getNameInfoForName",
"(",
"String",
"name",
",",
"SymbolType",
"type",
")",
"{",
"Map",
"<",
"String",
",",
"NameInfo",
">",
"map",
"=",
"type",
"==",
"PROPERTY",
"?",
"propertyNameInfo",
":",
"varNameInfo",
";",
"if",
"(",
"map",
"... | Gets the name info for the property or variable of a given name, and creates a new one if
necessary.
@param name The name of the symbol.
@param type The type of symbol. | [
"Gets",
"the",
"name",
"info",
"for",
"the",
"property",
"or",
"variable",
"of",
"a",
"given",
"name",
"and",
"creates",
"a",
"new",
"one",
"if",
"necessary",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AnalyzePrototypeProperties.java#L175-L185 |
24,330 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.trackMessage | private void trackMessage(
NodeTraversal t, JsMessage message, String msgName,
Node msgNode, boolean isUnnamedMessage) {
if (!isUnnamedMessage) {
MessageLocation location = new MessageLocation(message, msgNode);
messageNames.put(msgName, location);
} else {
Var var = t.getScope().g... | java | private void trackMessage(
NodeTraversal t, JsMessage message, String msgName,
Node msgNode, boolean isUnnamedMessage) {
if (!isUnnamedMessage) {
MessageLocation location = new MessageLocation(message, msgNode);
messageNames.put(msgName, location);
} else {
Var var = t.getScope().g... | [
"private",
"void",
"trackMessage",
"(",
"NodeTraversal",
"t",
",",
"JsMessage",
"message",
",",
"String",
"msgName",
",",
"Node",
"msgNode",
",",
"boolean",
"isUnnamedMessage",
")",
"{",
"if",
"(",
"!",
"isUnnamedMessage",
")",
"{",
"MessageLocation",
"location"... | Track a message for later retrieval.
This is used for tracking duplicates, and for figuring out message
fallback. Not all message types are trackable, because that would
require a more sophisticated analysis. e.g.,
function f(s) { s.MSG_UNNAMED_X = 'Some untrackable message'; } | [
"Track",
"a",
"message",
"for",
"later",
"retrieval",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L346-L358 |
24,331 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.isLegalMessageVarAlias | private static boolean isLegalMessageVarAlias(Node msgNode, String msgKey) {
if (msgNode.isGetProp()
&& msgNode.isQualifiedName()
&& msgNode.getLastChild().getString().equals(msgKey)) {
// Case: `foo.Thing.MSG_EXAMPLE = bar.OtherThing.MSG_EXAMPLE;`
//
// This kind of construct is c... | java | private static boolean isLegalMessageVarAlias(Node msgNode, String msgKey) {
if (msgNode.isGetProp()
&& msgNode.isQualifiedName()
&& msgNode.getLastChild().getString().equals(msgKey)) {
// Case: `foo.Thing.MSG_EXAMPLE = bar.OtherThing.MSG_EXAMPLE;`
//
// This kind of construct is c... | [
"private",
"static",
"boolean",
"isLegalMessageVarAlias",
"(",
"Node",
"msgNode",
",",
"String",
"msgKey",
")",
"{",
"if",
"(",
"msgNode",
".",
"isGetProp",
"(",
")",
"&&",
"msgNode",
".",
"isQualifiedName",
"(",
")",
"&&",
"msgNode",
".",
"getLastChild",
"(... | Defines any special cases that are exceptions to what would otherwise be illegal message
assignments.
<p>These exceptions are generally due to the pass being designed before new syntax was
introduced. | [
"Defines",
"any",
"special",
"cases",
"that",
"are",
"exceptions",
"to",
"what",
"would",
"otherwise",
"be",
"illegal",
"message",
"assignments",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L367-L394 |
24,332 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.getTrackedMessage | private JsMessage getTrackedMessage(NodeTraversal t, String msgName) {
boolean isUnnamedMessage = isUnnamedMessageName(msgName);
if (!isUnnamedMessage) {
MessageLocation location = messageNames.get(msgName);
return location == null ? null : location.message;
} else {
Var var = t.getScope()... | java | private JsMessage getTrackedMessage(NodeTraversal t, String msgName) {
boolean isUnnamedMessage = isUnnamedMessageName(msgName);
if (!isUnnamedMessage) {
MessageLocation location = messageNames.get(msgName);
return location == null ? null : location.message;
} else {
Var var = t.getScope()... | [
"private",
"JsMessage",
"getTrackedMessage",
"(",
"NodeTraversal",
"t",
",",
"String",
"msgName",
")",
"{",
"boolean",
"isUnnamedMessage",
"=",
"isUnnamedMessageName",
"(",
"msgName",
")",
";",
"if",
"(",
"!",
"isUnnamedMessage",
")",
"{",
"MessageLocation",
"loca... | Get a previously tracked message. | [
"Get",
"a",
"previously",
"tracked",
"message",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L397-L409 |
24,333 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.checkIfMessageDuplicated | private void checkIfMessageDuplicated(String msgName, Node msgNode) {
if (messageNames.containsKey(msgName)) {
MessageLocation location = messageNames.get(msgName);
compiler.report(JSError.make(msgNode, MESSAGE_DUPLICATE_KEY,
msgName, location.messageNode.getSourceFileName(),
Integer... | java | private void checkIfMessageDuplicated(String msgName, Node msgNode) {
if (messageNames.containsKey(msgName)) {
MessageLocation location = messageNames.get(msgName);
compiler.report(JSError.make(msgNode, MESSAGE_DUPLICATE_KEY,
msgName, location.messageNode.getSourceFileName(),
Integer... | [
"private",
"void",
"checkIfMessageDuplicated",
"(",
"String",
"msgName",
",",
"Node",
"msgNode",
")",
"{",
"if",
"(",
"messageNames",
".",
"containsKey",
"(",
"msgName",
")",
")",
"{",
"MessageLocation",
"location",
"=",
"messageNames",
".",
"get",
"(",
"msgNa... | Checks if message already processed. If so - it generates 'message
duplicated' compiler error.
@param msgName the name of the message
@param msgNode the node that represents JS message | [
"Checks",
"if",
"message",
"already",
"processed",
".",
"If",
"so",
"-",
"it",
"generates",
"message",
"duplicated",
"compiler",
"error",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L418-L425 |
24,334 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.maybeInitMetaDataFromJsDoc | private static boolean maybeInitMetaDataFromJsDoc(Builder builder, Node node) {
boolean messageHasDesc = false;
JSDocInfo info = node.getJSDocInfo();
if (info != null) {
String desc = info.getDescription();
if (desc != null) {
builder.setDesc(desc);
messageHasDesc = true;
}... | java | private static boolean maybeInitMetaDataFromJsDoc(Builder builder, Node node) {
boolean messageHasDesc = false;
JSDocInfo info = node.getJSDocInfo();
if (info != null) {
String desc = info.getDescription();
if (desc != null) {
builder.setDesc(desc);
messageHasDesc = true;
}... | [
"private",
"static",
"boolean",
"maybeInitMetaDataFromJsDoc",
"(",
"Builder",
"builder",
",",
"Node",
"node",
")",
"{",
"boolean",
"messageHasDesc",
"=",
"false",
";",
"JSDocInfo",
"info",
"=",
"node",
".",
"getJSDocInfo",
"(",
")",
";",
"if",
"(",
"info",
"... | Initializes the meta data in a message builder given a node that may
contain JsDoc properties.
@param builder the message builder whose meta data will be initialized
@param node the node with the message's JSDoc properties
@return true if message has JsDoc with valid description in @desc
annotation | [
"Initializes",
"the",
"meta",
"data",
"in",
"a",
"message",
"builder",
"given",
"a",
"node",
"that",
"may",
"contain",
"JsDoc",
"properties",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L550-L568 |
24,335 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.extractFromReturnDescendant | private static void extractFromReturnDescendant(Builder builder, Node node)
throws MalformedException {
switch (node.getToken()) {
case STRING:
builder.appendStringPart(node.getString());
break;
case NAME:
builder.appendPlaceholderReference(node.getString());
break... | java | private static void extractFromReturnDescendant(Builder builder, Node node)
throws MalformedException {
switch (node.getToken()) {
case STRING:
builder.appendStringPart(node.getString());
break;
case NAME:
builder.appendPlaceholderReference(node.getString());
break... | [
"private",
"static",
"void",
"extractFromReturnDescendant",
"(",
"Builder",
"builder",
",",
"Node",
"node",
")",
"throws",
"MalformedException",
"{",
"switch",
"(",
"node",
".",
"getToken",
"(",
")",
")",
"{",
"case",
"STRING",
":",
"builder",
".",
"appendStri... | Appends value parts to the message builder by traversing the descendants
of the given RETURN node.
@param builder the message builder
@param node the node from where we extract a message
@throws MalformedException if the parsed message is invalid | [
"Appends",
"value",
"parts",
"to",
"the",
"message",
"builder",
"by",
"traversing",
"the",
"descendants",
"of",
"the",
"given",
"RETURN",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L688-L707 |
24,336 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.parseMessageTextNode | private static void parseMessageTextNode(Builder builder, Node node)
throws MalformedException {
String value = extractStringFromStringExprNode(node);
while (true) {
int phBegin = value.indexOf(PH_JS_PREFIX);
if (phBegin < 0) {
// Just a string literal
builder.appendStringPart... | java | private static void parseMessageTextNode(Builder builder, Node node)
throws MalformedException {
String value = extractStringFromStringExprNode(node);
while (true) {
int phBegin = value.indexOf(PH_JS_PREFIX);
if (phBegin < 0) {
// Just a string literal
builder.appendStringPart... | [
"private",
"static",
"void",
"parseMessageTextNode",
"(",
"Builder",
"builder",
",",
"Node",
"node",
")",
"throws",
"MalformedException",
"{",
"String",
"value",
"=",
"extractStringFromStringExprNode",
"(",
"node",
")",
";",
"while",
"(",
"true",
")",
"{",
"int"... | Appends the message parts in a JS message value extracted from the given
text node.
@param builder the JS message builder to append parts to
@param node the node with string literal that contains the message text
@throws MalformedException if {@code value} contains a reference to
an unregistered placeholder | [
"Appends",
"the",
"message",
"parts",
"in",
"a",
"JS",
"message",
"value",
"extracted",
"from",
"the",
"given",
"text",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L817-L854 |
24,337 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.visitFallbackFunctionCall | private void visitFallbackFunctionCall(NodeTraversal t, Node call) {
// Check to make sure the function call looks like:
// goog.getMsgWithFallback(MSG_1, MSG_2);
if (call.getChildCount() != 3
|| !call.getSecondChild().isName()
|| !call.getLastChild().isName()) {
compiler.report(JSErro... | java | private void visitFallbackFunctionCall(NodeTraversal t, Node call) {
// Check to make sure the function call looks like:
// goog.getMsgWithFallback(MSG_1, MSG_2);
if (call.getChildCount() != 3
|| !call.getSecondChild().isName()
|| !call.getLastChild().isName()) {
compiler.report(JSErro... | [
"private",
"void",
"visitFallbackFunctionCall",
"(",
"NodeTraversal",
"t",
",",
"Node",
"call",
")",
"{",
"// Check to make sure the function call looks like:",
"// goog.getMsgWithFallback(MSG_1, MSG_2);",
"if",
"(",
"call",
".",
"getChildCount",
"(",
")",
"!=",
"3",
"||"... | Visit a call to goog.getMsgWithFallback. | [
"Visit",
"a",
"call",
"to",
"goog",
".",
"getMsgWithFallback",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L857-L890 |
24,338 | google/closure-compiler | src/com/google/javascript/jscomp/JsMessageVisitor.java | JsMessageVisitor.isMessageName | boolean isMessageName(String identifier, boolean isNewStyleMessage) {
return identifier.startsWith(MSG_PREFIX) &&
(style == JsMessage.Style.CLOSURE || isNewStyleMessage ||
!identifier.endsWith(DESC_SUFFIX));
} | java | boolean isMessageName(String identifier, boolean isNewStyleMessage) {
return identifier.startsWith(MSG_PREFIX) &&
(style == JsMessage.Style.CLOSURE || isNewStyleMessage ||
!identifier.endsWith(DESC_SUFFIX));
} | [
"boolean",
"isMessageName",
"(",
"String",
"identifier",
",",
"boolean",
"isNewStyleMessage",
")",
"{",
"return",
"identifier",
".",
"startsWith",
"(",
"MSG_PREFIX",
")",
"&&",
"(",
"style",
"==",
"JsMessage",
".",
"Style",
".",
"CLOSURE",
"||",
"isNewStyleMessa... | Returns whether the given JS identifier is a valid JS message name. | [
"Returns",
"whether",
"the",
"given",
"JS",
"identifier",
"is",
"a",
"valid",
"JS",
"message",
"name",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JsMessageVisitor.java#L922-L926 |
24,339 | google/closure-compiler | src/com/google/javascript/jscomp/DiagnosticGroup.java | DiagnosticGroup.forType | public static synchronized DiagnosticGroup forType(DiagnosticType type) {
singletons.computeIfAbsent(type, DiagnosticGroup::new);
return singletons.get(type);
} | java | public static synchronized DiagnosticGroup forType(DiagnosticType type) {
singletons.computeIfAbsent(type, DiagnosticGroup::new);
return singletons.get(type);
} | [
"public",
"static",
"synchronized",
"DiagnosticGroup",
"forType",
"(",
"DiagnosticType",
"type",
")",
"{",
"singletons",
".",
"computeIfAbsent",
"(",
"type",
",",
"DiagnosticGroup",
"::",
"new",
")",
";",
"return",
"singletons",
".",
"get",
"(",
"type",
")",
"... | Create a diagnostic group that matches only the given type. | [
"Create",
"a",
"diagnostic",
"group",
"that",
"matches",
"only",
"the",
"given",
"type",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DiagnosticGroup.java#L84-L87 |
24,340 | google/closure-compiler | src/com/google/javascript/jscomp/DiagnosticGroup.java | DiagnosticGroup.isSubGroup | boolean isSubGroup(DiagnosticGroup group) {
for (DiagnosticType type : group.types) {
if (!matches(type)) {
return false;
}
}
return true;
} | java | boolean isSubGroup(DiagnosticGroup group) {
for (DiagnosticType type : group.types) {
if (!matches(type)) {
return false;
}
}
return true;
} | [
"boolean",
"isSubGroup",
"(",
"DiagnosticGroup",
"group",
")",
"{",
"for",
"(",
"DiagnosticType",
"type",
":",
"group",
".",
"types",
")",
"{",
"if",
"(",
"!",
"matches",
"(",
"type",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
... | Returns whether all of the types in the given group are in this group. | [
"Returns",
"whether",
"all",
"of",
"the",
"types",
"in",
"the",
"given",
"group",
"are",
"in",
"this",
"group",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DiagnosticGroup.java#L107-L114 |
24,341 | google/closure-compiler | src/com/google/javascript/jscomp/StrictModeCheck.java | StrictModeCheck.checkWith | private static void checkWith(NodeTraversal t, Node n) {
JSDocInfo info = n.getJSDocInfo();
boolean allowWith =
info != null && info.getSuppressions().contains("with");
if (!allowWith) {
t.report(n, USE_OF_WITH);
}
} | java | private static void checkWith(NodeTraversal t, Node n) {
JSDocInfo info = n.getJSDocInfo();
boolean allowWith =
info != null && info.getSuppressions().contains("with");
if (!allowWith) {
t.report(n, USE_OF_WITH);
}
} | [
"private",
"static",
"void",
"checkWith",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"JSDocInfo",
"info",
"=",
"n",
".",
"getJSDocInfo",
"(",
")",
";",
"boolean",
"allowWith",
"=",
"info",
"!=",
"null",
"&&",
"info",
".",
"getSuppressions",
"... | Reports a warning for with statements. | [
"Reports",
"a",
"warning",
"for",
"with",
"statements",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/StrictModeCheck.java#L120-L127 |
24,342 | google/closure-compiler | src/com/google/javascript/jscomp/StrictModeCheck.java | StrictModeCheck.isDeclaration | private static boolean isDeclaration(Node n) {
switch (n.getParent().getToken()) {
case LET:
case CONST:
case VAR:
case CATCH:
return true;
case FUNCTION:
return n == n.getParent().getFirstChild();
case PARAM_LIST:
return n.getGrandparent().isFunction();
... | java | private static boolean isDeclaration(Node n) {
switch (n.getParent().getToken()) {
case LET:
case CONST:
case VAR:
case CATCH:
return true;
case FUNCTION:
return n == n.getParent().getFirstChild();
case PARAM_LIST:
return n.getGrandparent().isFunction();
... | [
"private",
"static",
"boolean",
"isDeclaration",
"(",
"Node",
"n",
")",
"{",
"switch",
"(",
"n",
".",
"getParent",
"(",
")",
".",
"getToken",
"(",
")",
")",
"{",
"case",
"LET",
":",
"case",
"CONST",
":",
"case",
"VAR",
":",
"case",
"CATCH",
":",
"r... | Determines if the given name is a declaration, which can be a declaration
of a variable, function, or argument. | [
"Determines",
"if",
"the",
"given",
"name",
"is",
"a",
"declaration",
"which",
"can",
"be",
"a",
"declaration",
"of",
"a",
"variable",
"function",
"or",
"argument",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/StrictModeCheck.java#L133-L149 |
24,343 | google/closure-compiler | src/com/google/javascript/jscomp/StrictModeCheck.java | StrictModeCheck.checkAssignment | private static void checkAssignment(NodeTraversal t, Node n) {
if (n.getFirstChild().isName()) {
if ("arguments".equals(n.getFirstChild().getString())) {
t.report(n, ARGUMENTS_ASSIGNMENT);
} else if ("eval".equals(n.getFirstChild().getString())) {
// Note that assignment to eval is alrea... | java | private static void checkAssignment(NodeTraversal t, Node n) {
if (n.getFirstChild().isName()) {
if ("arguments".equals(n.getFirstChild().getString())) {
t.report(n, ARGUMENTS_ASSIGNMENT);
} else if ("eval".equals(n.getFirstChild().getString())) {
// Note that assignment to eval is alrea... | [
"private",
"static",
"void",
"checkAssignment",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"if",
"(",
"n",
".",
"getFirstChild",
"(",
")",
".",
"isName",
"(",
")",
")",
"{",
"if",
"(",
"\"arguments\"",
".",
"equals",
"(",
"n",
".",
"getFi... | Checks that an assignment is not to the "arguments" object. | [
"Checks",
"that",
"an",
"assignment",
"is",
"not",
"to",
"the",
"arguments",
"object",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/StrictModeCheck.java#L152-L162 |
24,344 | google/closure-compiler | src/com/google/javascript/jscomp/StrictModeCheck.java | StrictModeCheck.checkDelete | private static void checkDelete(NodeTraversal t, Node n) {
if (n.getFirstChild().isName()) {
Var v = t.getScope().getVar(n.getFirstChild().getString());
if (v != null) {
t.report(n, DELETE_VARIABLE);
}
}
} | java | private static void checkDelete(NodeTraversal t, Node n) {
if (n.getFirstChild().isName()) {
Var v = t.getScope().getVar(n.getFirstChild().getString());
if (v != null) {
t.report(n, DELETE_VARIABLE);
}
}
} | [
"private",
"static",
"void",
"checkDelete",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"if",
"(",
"n",
".",
"getFirstChild",
"(",
")",
".",
"isName",
"(",
")",
")",
"{",
"Var",
"v",
"=",
"t",
".",
"getScope",
"(",
")",
".",
"getVar",
... | Checks that variables, functions, and arguments are not deleted. | [
"Checks",
"that",
"variables",
"functions",
"and",
"arguments",
"are",
"not",
"deleted",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/StrictModeCheck.java#L165-L172 |
24,345 | google/closure-compiler | src/com/google/javascript/jscomp/StrictModeCheck.java | StrictModeCheck.checkObjectLiteralOrClass | private static void checkObjectLiteralOrClass(NodeTraversal t, Node n) {
Set<String> getters = new HashSet<>();
Set<String> setters = new HashSet<>();
Set<String> staticGetters = new HashSet<>();
Set<String> staticSetters = new HashSet<>();
for (Node key = n.getFirstChild();
key != null;
... | java | private static void checkObjectLiteralOrClass(NodeTraversal t, Node n) {
Set<String> getters = new HashSet<>();
Set<String> setters = new HashSet<>();
Set<String> staticGetters = new HashSet<>();
Set<String> staticSetters = new HashSet<>();
for (Node key = n.getFirstChild();
key != null;
... | [
"private",
"static",
"void",
"checkObjectLiteralOrClass",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"Set",
"<",
"String",
">",
"getters",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"Set",
"<",
"String",
">",
"setters",
"=",
"new",
"HashSet"... | Checks that object literal keys or class method names are valid. | [
"Checks",
"that",
"object",
"literal",
"keys",
"or",
"class",
"method",
"names",
"are",
"valid",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/StrictModeCheck.java#L175-L213 |
24,346 | google/closure-compiler | src/com/google/javascript/jscomp/GenerateExports.java | GenerateExports.addExportMethod | private void addExportMethod(Map<String, Node> exports, String export, Node context) {
// We can export as a property if any of the following conditions holds:
// a) ES6 class members, which the above `addExportForEs6Method` handles
// b) this is a property on a name which is also being exported
// c) t... | java | private void addExportMethod(Map<String, Node> exports, String export, Node context) {
// We can export as a property if any of the following conditions holds:
// a) ES6 class members, which the above `addExportForEs6Method` handles
// b) this is a property on a name which is also being exported
// c) t... | [
"private",
"void",
"addExportMethod",
"(",
"Map",
"<",
"String",
",",
"Node",
">",
"exports",
",",
"String",
"export",
",",
"Node",
"context",
")",
"{",
"// We can export as a property if any of the following conditions holds:",
"// a) ES6 class members, which the above `addE... | Emits a call to either goog.exportProperty or goog.exportSymbol.
<p>Attempts to optimize by creating a property export instead of a symbol export, because
property exports are significantly simpler/faster.
@param export The fully qualified name of the object we want to export
@param context The node on which the @exp... | [
"Emits",
"a",
"call",
"to",
"either",
"goog",
".",
"exportProperty",
"or",
"goog",
".",
"exportSymbol",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GenerateExports.java#L135-L169 |
24,347 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeReplaceKnownMethods.java | PeepholeReplaceKnownMethods.jsSplitMatch | private static int jsSplitMatch(String stringValue, int startIndex,
String separator) {
if (startIndex + separator.length() > stringValue.length()) {
return -1;
}
int matchIndex = stringValue.indexOf(separator, startIndex);
if (matchIndex < 0) {
return -1... | java | private static int jsSplitMatch(String stringValue, int startIndex,
String separator) {
if (startIndex + separator.length() > stringValue.length()) {
return -1;
}
int matchIndex = stringValue.indexOf(separator, startIndex);
if (matchIndex < 0) {
return -1... | [
"private",
"static",
"int",
"jsSplitMatch",
"(",
"String",
"stringValue",
",",
"int",
"startIndex",
",",
"String",
"separator",
")",
"{",
"if",
"(",
"startIndex",
"+",
"separator",
".",
"length",
"(",
")",
">",
"stringValue",
".",
"length",
"(",
")",
")",
... | Support function for jsSplit, find the first occurrence of
separator within stringValue starting at startIndex. | [
"Support",
"function",
"for",
"jsSplit",
"find",
"the",
"first",
"occurrence",
"of",
"separator",
"within",
"stringValue",
"starting",
"at",
"startIndex",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeReplaceKnownMethods.java#L843-L857 |
24,348 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeReplaceKnownMethods.java | PeepholeReplaceKnownMethods.jsSplit | private String[] jsSplit(String stringValue, String separator, int limit) {
checkArgument(limit >= 0);
checkArgument(stringValue != null);
// For limits of 0, return an empty array
if (limit == 0) {
return new String[0];
}
// If a separator is not specified, return the entire string as
... | java | private String[] jsSplit(String stringValue, String separator, int limit) {
checkArgument(limit >= 0);
checkArgument(stringValue != null);
// For limits of 0, return an empty array
if (limit == 0) {
return new String[0];
}
// If a separator is not specified, return the entire string as
... | [
"private",
"String",
"[",
"]",
"jsSplit",
"(",
"String",
"stringValue",
",",
"String",
"separator",
",",
"int",
"limit",
")",
"{",
"checkArgument",
"(",
"limit",
">=",
"0",
")",
";",
"checkArgument",
"(",
"stringValue",
"!=",
"null",
")",
";",
"// For limi... | Implement the JS String.split method using a string separator. | [
"Implement",
"the",
"JS",
"String",
".",
"split",
"method",
"using",
"a",
"string",
"separator",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeReplaceKnownMethods.java#L862-L906 |
24,349 | google/closure-compiler | src/com/google/javascript/jscomp/AbstractCompiler.java | AbstractCompiler.getPropertyAccessKind | final PropertyAccessKind getPropertyAccessKind(String property) {
return getExternGetterAndSetterProperties()
.getOrDefault(property, PropertyAccessKind.NORMAL)
.unionWith(
getSourceGetterAndSetterProperties().getOrDefault(property, PropertyAccessKind.NORMAL));
} | java | final PropertyAccessKind getPropertyAccessKind(String property) {
return getExternGetterAndSetterProperties()
.getOrDefault(property, PropertyAccessKind.NORMAL)
.unionWith(
getSourceGetterAndSetterProperties().getOrDefault(property, PropertyAccessKind.NORMAL));
} | [
"final",
"PropertyAccessKind",
"getPropertyAccessKind",
"(",
"String",
"property",
")",
"{",
"return",
"getExternGetterAndSetterProperties",
"(",
")",
".",
"getOrDefault",
"(",
"property",
",",
"PropertyAccessKind",
".",
"NORMAL",
")",
".",
"unionWith",
"(",
"getSourc... | Returns any property seen in the externs or source with the given name was a getter, setter, or
both.
<p>This defaults to {@link PropertyAccessKind#NORMAL} for any property not known to have a
getter or setter, even for property names that do not exist in the given program. | [
"Returns",
"any",
"property",
"seen",
"in",
"the",
"externs",
"or",
"source",
"with",
"the",
"given",
"name",
"was",
"a",
"getter",
"setter",
"or",
"both",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AbstractCompiler.java#L650-L655 |
24,350 | google/closure-compiler | src/com/google/javascript/jscomp/AbstractCompiler.java | AbstractCompiler.setAnnotation | void setAnnotation(String key, Object object) {
checkArgument(object != null, "The stored annotation value cannot be null.");
Preconditions.checkArgument(
!annotationMap.containsKey(key), "Cannot overwrite the existing annotation '%s'.", key);
annotationMap.put(key, object);
} | java | void setAnnotation(String key, Object object) {
checkArgument(object != null, "The stored annotation value cannot be null.");
Preconditions.checkArgument(
!annotationMap.containsKey(key), "Cannot overwrite the existing annotation '%s'.", key);
annotationMap.put(key, object);
} | [
"void",
"setAnnotation",
"(",
"String",
"key",
",",
"Object",
"object",
")",
"{",
"checkArgument",
"(",
"object",
"!=",
"null",
",",
"\"The stored annotation value cannot be null.\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"annotationMap",
".",
... | Sets an annotation for the given key.
@param key the annotation key
@param object the object to store as the annotation | [
"Sets",
"an",
"annotation",
"for",
"the",
"given",
"key",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AbstractCompiler.java#L688-L693 |
24,351 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeFoldConstants.java | PeepholeFoldConstants.tryFoldAddConstantString | private Node tryFoldAddConstantString(Node n, Node left, Node right) {
if (left.isString() || right.isString()
|| left.isArrayLit() || right.isArrayLit()) {
// Add strings.
String leftString = NodeUtil.getStringValue(left);
String rightString = NodeUtil.getStringValue(right);
if (lef... | java | private Node tryFoldAddConstantString(Node n, Node left, Node right) {
if (left.isString() || right.isString()
|| left.isArrayLit() || right.isArrayLit()) {
// Add strings.
String leftString = NodeUtil.getStringValue(left);
String rightString = NodeUtil.getStringValue(right);
if (lef... | [
"private",
"Node",
"tryFoldAddConstantString",
"(",
"Node",
"n",
",",
"Node",
"left",
",",
"Node",
"right",
")",
"{",
"if",
"(",
"left",
".",
"isString",
"(",
")",
"||",
"right",
".",
"isString",
"(",
")",
"||",
"left",
".",
"isArrayLit",
"(",
")",
"... | Try to fold an ADD node with constant operands | [
"Try",
"to",
"fold",
"an",
"ADD",
"node",
"with",
"constant",
"operands"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeFoldConstants.java#L704-L719 |
24,352 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeFoldConstants.java | PeepholeFoldConstants.tryFoldShift | private Node tryFoldShift(Node n, Node left, Node right) {
if (left.isNumber() &&
right.isNumber()) {
double result;
double lval = left.getDouble();
double rval = right.getDouble();
// only the lower 5 bits are used when shifting, so don't do anything
// if the shift amount i... | java | private Node tryFoldShift(Node n, Node left, Node right) {
if (left.isNumber() &&
right.isNumber()) {
double result;
double lval = left.getDouble();
double rval = right.getDouble();
// only the lower 5 bits are used when shifting, so don't do anything
// if the shift amount i... | [
"private",
"Node",
"tryFoldShift",
"(",
"Node",
"n",
",",
"Node",
"left",
",",
"Node",
"right",
")",
"{",
"if",
"(",
"left",
".",
"isNumber",
"(",
")",
"&&",
"right",
".",
"isNumber",
"(",
")",
")",
"{",
"double",
"result",
";",
"double",
"lval",
"... | Try to fold shift operations | [
"Try",
"to",
"fold",
"shift",
"operations"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeFoldConstants.java#L961-L1012 |
24,353 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeFoldConstants.java | PeepholeFoldConstants.inForcedStringContext | private static boolean inForcedStringContext(Node n) {
if (n.getParent().isGetElem()
&& n.getParent().getLastChild() == n) {
return true;
}
// we can fold in the case "" + new String("")
return n.getParent().isAdd();
} | java | private static boolean inForcedStringContext(Node n) {
if (n.getParent().isGetElem()
&& n.getParent().getLastChild() == n) {
return true;
}
// we can fold in the case "" + new String("")
return n.getParent().isAdd();
} | [
"private",
"static",
"boolean",
"inForcedStringContext",
"(",
"Node",
"n",
")",
"{",
"if",
"(",
"n",
".",
"getParent",
"(",
")",
".",
"isGetElem",
"(",
")",
"&&",
"n",
".",
"getParent",
"(",
")",
".",
"getLastChild",
"(",
")",
"==",
"n",
")",
"{",
... | Returns whether this node must be coerced to a string. | [
"Returns",
"whether",
"this",
"node",
"must",
"be",
"coerced",
"to",
"a",
"string",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeFoldConstants.java#L1250-L1258 |
24,354 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeFoldConstants.java | PeepholeFoldConstants.tryFlattenArrayOrObjectLit | private Node tryFlattenArrayOrObjectLit(Node parentLit) {
for (Node child = parentLit.getFirstChild(); child != null; ) {
// We have to store the next element here because nodes may be inserted below.
Node spread = child;
child = child.getNext();
if (!spread.isSpread()) {
continue;
... | java | private Node tryFlattenArrayOrObjectLit(Node parentLit) {
for (Node child = parentLit.getFirstChild(); child != null; ) {
// We have to store the next element here because nodes may be inserted below.
Node spread = child;
child = child.getNext();
if (!spread.isSpread()) {
continue;
... | [
"private",
"Node",
"tryFlattenArrayOrObjectLit",
"(",
"Node",
"parentLit",
")",
"{",
"for",
"(",
"Node",
"child",
"=",
"parentLit",
".",
"getFirstChild",
"(",
")",
";",
"child",
"!=",
"null",
";",
")",
"{",
"// We have to store the next element here because nodes ma... | Flattens array- or object-literals that contain spreads of other literals.
<p>Does not recurse into nested spreads because this method is already called as part of a
postorder traversal and nested spreads will already have been flattened.
<p>Example: `[0, ...[1, 2, 3], 4, ...[5]]` => `[0, 1, 2, 3, 4, 5]` | [
"Flattens",
"array",
"-",
"or",
"object",
"-",
"literals",
"that",
"contain",
"spreads",
"of",
"other",
"literals",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeFoldConstants.java#L1428-L1448 |
24,355 | google/closure-compiler | src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java | SourceMapGeneratorV3.setWrapperPrefix | @Override
public void setWrapperPrefix(String prefix) {
// Determine the current line and character position.
int prefixLine = 0;
int prefixIndex = 0;
for (int i = 0; i < prefix.length(); ++i) {
if (prefix.charAt(i) == '\n') {
prefixLine++;
prefixIndex = 0;
} else {
... | java | @Override
public void setWrapperPrefix(String prefix) {
// Determine the current line and character position.
int prefixLine = 0;
int prefixIndex = 0;
for (int i = 0; i < prefix.length(); ++i) {
if (prefix.charAt(i) == '\n') {
prefixLine++;
prefixIndex = 0;
} else {
... | [
"@",
"Override",
"public",
"void",
"setWrapperPrefix",
"(",
"String",
"prefix",
")",
"{",
"// Determine the current line and character position.",
"int",
"prefixLine",
"=",
"0",
";",
"int",
"prefixIndex",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"... | Sets the prefix used for wrapping the generated source file before
it is written. This ensures that the source map is adjusted for the
change in character offsets.
@param prefix The prefix that is added before the generated source code. | [
"Sets",
"the",
"prefix",
"used",
"for",
"wrapping",
"the",
"generated",
"source",
"file",
"before",
"it",
"is",
"written",
".",
"This",
"ensures",
"that",
"the",
"source",
"map",
"is",
"adjusted",
"for",
"the",
"change",
"in",
"character",
"offsets",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java#L166-L182 |
24,356 | google/closure-compiler | src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java | SourceMapGeneratorV3.setStartingPosition | @Override
public void setStartingPosition(int offsetLine, int offsetIndex) {
checkState(offsetLine >= 0);
checkState(offsetIndex >= 0);
offsetPosition = new FilePosition(offsetLine, offsetIndex);
} | java | @Override
public void setStartingPosition(int offsetLine, int offsetIndex) {
checkState(offsetLine >= 0);
checkState(offsetIndex >= 0);
offsetPosition = new FilePosition(offsetLine, offsetIndex);
} | [
"@",
"Override",
"public",
"void",
"setStartingPosition",
"(",
"int",
"offsetLine",
",",
"int",
"offsetIndex",
")",
"{",
"checkState",
"(",
"offsetLine",
">=",
"0",
")",
";",
"checkState",
"(",
"offsetIndex",
">=",
"0",
")",
";",
"offsetPosition",
"=",
"new"... | Sets the source code that exists in the buffer for which the
generated code is being generated. This ensures that the source map
accurately reflects the fact that the source is being appended to
an existing buffer and as such, does not start at line 0, position 0
but rather some other line and position.
@param offsetL... | [
"Sets",
"the",
"source",
"code",
"that",
"exists",
"in",
"the",
"buffer",
"for",
"which",
"the",
"generated",
"code",
"is",
"being",
"generated",
".",
"This",
"ensures",
"that",
"the",
"source",
"map",
"accurately",
"reflects",
"the",
"fact",
"that",
"the",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java#L194-L199 |
24,357 | google/closure-compiler | src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java | SourceMapGeneratorV3.addExtension | public void addExtension(String name, Object object)
throws SourceMapParseException{
if (!name.startsWith("x_")){
throw new SourceMapParseException("Extension '" + name +
"' must start with 'x_'");
}
this.extensions.put(name, object);
} | java | public void addExtension(String name, Object object)
throws SourceMapParseException{
if (!name.startsWith("x_")){
throw new SourceMapParseException("Extension '" + name +
"' must start with 'x_'");
}
this.extensions.put(name, object);
} | [
"public",
"void",
"addExtension",
"(",
"String",
"name",
",",
"Object",
"object",
")",
"throws",
"SourceMapParseException",
"{",
"if",
"(",
"!",
"name",
".",
"startsWith",
"(",
"\"x_\"",
")",
")",
"{",
"throw",
"new",
"SourceMapParseException",
"(",
"\"Extensi... | Adds field extensions to the json source map. The value is allowed to be
any value accepted by json, eg. string, JsonObject, JsonArray, etc.
Extensions must follow the format x_orgranization_field (based on V3
proposal), otherwise a {@code SourceMapParseExtension} will be thrown.
@param name The name of the extension... | [
"Adds",
"field",
"extensions",
"to",
"the",
"json",
"source",
"map",
".",
"The",
"value",
"is",
"allowed",
"to",
"be",
"any",
"value",
"accepted",
"by",
"json",
"eg",
".",
"string",
"JsonObject",
"JsonArray",
"etc",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java#L448-L455 |
24,358 | google/closure-compiler | src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java | SourceMapGeneratorV3.appendFirstField | private static void appendFirstField(
Appendable out, String name, CharSequence value)
throws IOException {
appendFieldStart(out, name, true);
out.append(value);
} | java | private static void appendFirstField(
Appendable out, String name, CharSequence value)
throws IOException {
appendFieldStart(out, name, true);
out.append(value);
} | [
"private",
"static",
"void",
"appendFirstField",
"(",
"Appendable",
"out",
",",
"String",
"name",
",",
"CharSequence",
"value",
")",
"throws",
"IOException",
"{",
"appendFieldStart",
"(",
"out",
",",
"name",
",",
"true",
")",
";",
"out",
".",
"append",
"(",
... | Source map field helpers. | [
"Source",
"map",
"field",
"helpers",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java#L553-L558 |
24,359 | google/closure-compiler | src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java | SourceMapGeneratorV3.prepMappings | private int prepMappings() throws IOException {
// Mark any unused mappings.
(new MappingTraversal()).traverse(new UsedMappingCheck());
// Renumber used mappings and keep track of the last line.
int id = 0;
int maxLine = 0;
for (Mapping m : mappings) {
if (m.used) {
m.id = id++;
... | java | private int prepMappings() throws IOException {
// Mark any unused mappings.
(new MappingTraversal()).traverse(new UsedMappingCheck());
// Renumber used mappings and keep track of the last line.
int id = 0;
int maxLine = 0;
for (Mapping m : mappings) {
if (m.used) {
m.id = id++;
... | [
"private",
"int",
"prepMappings",
"(",
")",
"throws",
"IOException",
"{",
"// Mark any unused mappings.",
"(",
"new",
"MappingTraversal",
"(",
")",
")",
".",
"traverse",
"(",
"new",
"UsedMappingCheck",
"(",
")",
")",
";",
"// Renumber used mappings and keep track of t... | Assigns sequential ids to used mappings, and returns the last line mapped. | [
"Assigns",
"sequential",
"ids",
"to",
"used",
"mappings",
"and",
"returns",
"the",
"last",
"line",
"mapped",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java#L591-L608 |
24,360 | google/closure-compiler | src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java | SourceMapGeneratorV3.appendIndexMapTo | @Override
public void appendIndexMapTo(
Appendable out, String name, List<SourceMapSection> sections)
throws IOException {
// Add the header fields.
out.append("{\n");
appendFirstField(out, "version", "3");
appendField(out, "file", escapeString(name));
// Add the line character maps.
... | java | @Override
public void appendIndexMapTo(
Appendable out, String name, List<SourceMapSection> sections)
throws IOException {
// Add the header fields.
out.append("{\n");
appendFirstField(out, "version", "3");
appendField(out, "file", escapeString(name));
// Add the line character maps.
... | [
"@",
"Override",
"public",
"void",
"appendIndexMapTo",
"(",
"Appendable",
"out",
",",
"String",
"name",
",",
"List",
"<",
"SourceMapSection",
">",
"sections",
")",
"throws",
"IOException",
"{",
"// Add the header fields.",
"out",
".",
"append",
"(",
"\"{\\n\"",
... | Appends the index source map to the given buffer.
@param out The stream to which the map will be appended.
@param name The name of the generated source file that this source map
represents.
@param sections An ordered list of map sections to include in the index.
@throws IOException | [
"Appends",
"the",
"index",
"source",
"map",
"to",
"the",
"given",
"buffer",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java#L820-L856 |
24,361 | google/closure-compiler | src/com/google/javascript/jscomp/webservice/common/Protocol.java | Protocol.resetMaximumInputSize | public static final void resetMaximumInputSize() {
String maxInputSizeStr = System.getProperty(Protocol.MAX_INPUT_SIZE_KEY);
if (maxInputSizeStr == null) {
maxInputSize = Protocol.FALLBACK_MAX_INPUT_SIZE;
} else {
maxInputSize = Integer.parseInt(maxInputSizeStr);
}
} | java | public static final void resetMaximumInputSize() {
String maxInputSizeStr = System.getProperty(Protocol.MAX_INPUT_SIZE_KEY);
if (maxInputSizeStr == null) {
maxInputSize = Protocol.FALLBACK_MAX_INPUT_SIZE;
} else {
maxInputSize = Integer.parseInt(maxInputSizeStr);
}
} | [
"public",
"static",
"final",
"void",
"resetMaximumInputSize",
"(",
")",
"{",
"String",
"maxInputSizeStr",
"=",
"System",
".",
"getProperty",
"(",
"Protocol",
".",
"MAX_INPUT_SIZE_KEY",
")",
";",
"if",
"(",
"maxInputSizeStr",
"==",
"null",
")",
"{",
"maxInputSize... | Reset the maximum input size so that the property key is rechecked.
This is needed for testing code because we are caching the maximum
input size value. | [
"Reset",
"the",
"maximum",
"input",
"size",
"so",
"that",
"the",
"property",
"key",
"is",
"rechecked",
".",
"This",
"is",
"needed",
"for",
"testing",
"code",
"because",
"we",
"are",
"caching",
"the",
"maximum",
"input",
"size",
"value",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/webservice/common/Protocol.java#L355-L363 |
24,362 | google/closure-compiler | src/com/google/javascript/jscomp/graph/LinkedDirectedGraph.java | LinkedDirectedGraph.isConnectedInDirection | public boolean isConnectedInDirection(
DiGraphNode<N, E> dNode1,
Predicate<E> edgeMatcher,
DiGraphNode<N, E> dNode2) {
// Verify the nodes.
List<DiGraphEdge<N, E>> outEdges = dNode1.getOutEdges();
int outEdgesLen = outEdges.size();
List<DiGraphEdge<N, E>> inEdges = dNode2.getInEdges()... | java | public boolean isConnectedInDirection(
DiGraphNode<N, E> dNode1,
Predicate<E> edgeMatcher,
DiGraphNode<N, E> dNode2) {
// Verify the nodes.
List<DiGraphEdge<N, E>> outEdges = dNode1.getOutEdges();
int outEdgesLen = outEdges.size();
List<DiGraphEdge<N, E>> inEdges = dNode2.getInEdges()... | [
"public",
"boolean",
"isConnectedInDirection",
"(",
"DiGraphNode",
"<",
"N",
",",
"E",
">",
"dNode1",
",",
"Predicate",
"<",
"E",
">",
"edgeMatcher",
",",
"DiGraphNode",
"<",
"N",
",",
"E",
">",
"dNode2",
")",
"{",
"// Verify the nodes.",
"List",
"<",
"DiG... | DiGraphNode look ups can be expensive for a large graph operation, prefer this
method if you have the DiGraphNodes available. | [
"DiGraphNode",
"look",
"ups",
"can",
"be",
"expensive",
"for",
"a",
"large",
"graph",
"operation",
"prefer",
"this",
"method",
"if",
"you",
"have",
"the",
"DiGraphNodes",
"available",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/graph/LinkedDirectedGraph.java#L244-L274 |
24,363 | google/closure-compiler | src/com/google/javascript/jscomp/CheckMissingGetCssName.java | CheckMissingGetCssName.insideGetCssNameCall | private static boolean insideGetCssNameCall(Node n) {
Node parent = n.getParent();
return parent.isCall() &&
parent.getFirstChild().matchesQualifiedName(GET_CSS_NAME_FUNCTION);
} | java | private static boolean insideGetCssNameCall(Node n) {
Node parent = n.getParent();
return parent.isCall() &&
parent.getFirstChild().matchesQualifiedName(GET_CSS_NAME_FUNCTION);
} | [
"private",
"static",
"boolean",
"insideGetCssNameCall",
"(",
"Node",
"n",
")",
"{",
"Node",
"parent",
"=",
"n",
".",
"getParent",
"(",
")",
";",
"return",
"parent",
".",
"isCall",
"(",
")",
"&&",
"parent",
".",
"getFirstChild",
"(",
")",
".",
"matchesQua... | Returns whether the node is an argument of a goog.getCssName call. | [
"Returns",
"whether",
"the",
"node",
"is",
"an",
"argument",
"of",
"a",
"goog",
".",
"getCssName",
"call",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckMissingGetCssName.java#L87-L91 |
24,364 | google/closure-compiler | src/com/google/javascript/jscomp/ReferenceCollection.java | ReferenceCollection.isWellDefined | protected boolean isWellDefined() {
int size = references.size();
if (size == 0) {
return false;
}
// If this is a declaration that does not instantiate the variable,
// it's not well-defined.
Reference init = getInitializingReference();
if (init == null) {
return false;
}
... | java | protected boolean isWellDefined() {
int size = references.size();
if (size == 0) {
return false;
}
// If this is a declaration that does not instantiate the variable,
// it's not well-defined.
Reference init = getInitializingReference();
if (init == null) {
return false;
}
... | [
"protected",
"boolean",
"isWellDefined",
"(",
")",
"{",
"int",
"size",
"=",
"references",
".",
"size",
"(",
")",
";",
"if",
"(",
"size",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"// If this is a declaration that does not instantiate the variable,",
"// ... | Determines if the variable for this reference collection is "well-defined." A variable is
well-defined if we can prove at compile-time that it's assigned a value before it's used.
<p>Notice that if this function returns false, this doesn't imply that the variable is used
before it's assigned. It just means that we don... | [
"Determines",
"if",
"the",
"variable",
"for",
"this",
"reference",
"collection",
"is",
"well",
"-",
"defined",
".",
"A",
"variable",
"is",
"well",
"-",
"defined",
"if",
"we",
"can",
"prove",
"at",
"compile",
"-",
"time",
"that",
"it",
"s",
"assigned",
"a... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ReferenceCollection.java#L53-L75 |
24,365 | google/closure-compiler | src/com/google/javascript/jscomp/ReferenceCollection.java | ReferenceCollection.isEscaped | boolean isEscaped() {
Scope hoistScope = null;
for (Reference ref : references) {
if (hoistScope == null) {
hoistScope = ref.getScope().getClosestHoistScope();
} else if (hoistScope != ref.getScope().getClosestHoistScope()) {
return true;
}
}
return false;
} | java | boolean isEscaped() {
Scope hoistScope = null;
for (Reference ref : references) {
if (hoistScope == null) {
hoistScope = ref.getScope().getClosestHoistScope();
} else if (hoistScope != ref.getScope().getClosestHoistScope()) {
return true;
}
}
return false;
} | [
"boolean",
"isEscaped",
"(",
")",
"{",
"Scope",
"hoistScope",
"=",
"null",
";",
"for",
"(",
"Reference",
"ref",
":",
"references",
")",
"{",
"if",
"(",
"hoistScope",
"==",
"null",
")",
"{",
"hoistScope",
"=",
"ref",
".",
"getScope",
"(",
")",
".",
"g... | Whether the variable is escaped into an inner function. | [
"Whether",
"the",
"variable",
"is",
"escaped",
"into",
"an",
"inner",
"function",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ReferenceCollection.java#L78-L88 |
24,366 | google/closure-compiler | src/com/google/javascript/jscomp/ReferenceCollection.java | ReferenceCollection.getInitializingReferenceForConstants | Reference getInitializingReferenceForConstants() {
int size = references.size();
for (int i = 0; i < size; i++) {
if (isInitializingDeclarationAt(i) || isInitializingAssignmentAt(i)) {
return references.get(i);
}
}
return null;
} | java | Reference getInitializingReferenceForConstants() {
int size = references.size();
for (int i = 0; i < size; i++) {
if (isInitializingDeclarationAt(i) || isInitializingAssignmentAt(i)) {
return references.get(i);
}
}
return null;
} | [
"Reference",
"getInitializingReferenceForConstants",
"(",
")",
"{",
"int",
"size",
"=",
"references",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"isInitializingDeclarationAt",... | Constants are allowed to be defined after their first use. | [
"Constants",
"are",
"allowed",
"to",
"be",
"defined",
"after",
"their",
"first",
"use",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ReferenceCollection.java#L141-L149 |
24,367 | google/closure-compiler | src/com/google/javascript/jscomp/CheckSideEffects.java | CheckSideEffects.protectSideEffects | private void protectSideEffects() {
if (!problemNodes.isEmpty()) {
if (!preserveFunctionInjected) {
addExtern(compiler);
}
for (Node n : problemNodes) {
Node name = IR.name(PROTECTOR_FN).srcref(n);
name.putBooleanProp(Node.IS_CONSTANT_NAME, true);
Node replacement =... | java | private void protectSideEffects() {
if (!problemNodes.isEmpty()) {
if (!preserveFunctionInjected) {
addExtern(compiler);
}
for (Node n : problemNodes) {
Node name = IR.name(PROTECTOR_FN).srcref(n);
name.putBooleanProp(Node.IS_CONSTANT_NAME, true);
Node replacement =... | [
"private",
"void",
"protectSideEffects",
"(",
")",
"{",
"if",
"(",
"!",
"problemNodes",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"!",
"preserveFunctionInjected",
")",
"{",
"addExtern",
"(",
"compiler",
")",
";",
"}",
"for",
"(",
"Node",
"n",
":",... | Protect side-effect free nodes by making them parameters
to a extern function call. This call will be removed
after all the optimizations passes have run. | [
"Protect",
"side",
"-",
"effect",
"free",
"nodes",
"by",
"making",
"them",
"parameters",
"to",
"a",
"extern",
"function",
"call",
".",
"This",
"call",
"will",
"be",
"removed",
"after",
"all",
"the",
"optimizations",
"passes",
"have",
"run",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckSideEffects.java#L174-L189 |
24,368 | google/closure-compiler | src/com/google/javascript/jscomp/CheckSideEffects.java | CheckSideEffects.addExtern | static void addExtern(AbstractCompiler compiler) {
Node name = IR.name(PROTECTOR_FN);
name.putBooleanProp(Node.IS_CONSTANT_NAME, true);
Node var = IR.var(name);
JSDocInfoBuilder builder = new JSDocInfoBuilder(false);
var.setJSDocInfo(builder.build());
CompilerInput input = compiler.getSynthesize... | java | static void addExtern(AbstractCompiler compiler) {
Node name = IR.name(PROTECTOR_FN);
name.putBooleanProp(Node.IS_CONSTANT_NAME, true);
Node var = IR.var(name);
JSDocInfoBuilder builder = new JSDocInfoBuilder(false);
var.setJSDocInfo(builder.build());
CompilerInput input = compiler.getSynthesize... | [
"static",
"void",
"addExtern",
"(",
"AbstractCompiler",
"compiler",
")",
"{",
"Node",
"name",
"=",
"IR",
".",
"name",
"(",
"PROTECTOR_FN",
")",
";",
"name",
".",
"putBooleanProp",
"(",
"Node",
".",
"IS_CONSTANT_NAME",
",",
"true",
")",
";",
"Node",
"var",
... | Injects JSCOMPILER_PRESEVE into the synthetic externs | [
"Injects",
"JSCOMPILER_PRESEVE",
"into",
"the",
"synthetic",
"externs"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckSideEffects.java#L192-L204 |
24,369 | google/closure-compiler | src/com/google/javascript/jscomp/CodeGenerator.java | CodeGenerator.unrollBinaryOperator | private void unrollBinaryOperator(
Node n, Token op, String opStr, Context context,
Context rhsContext, int leftPrecedence, int rightPrecedence) {
Node firstNonOperator = n.getFirstChild();
while (firstNonOperator.getToken() == op) {
firstNonOperator = firstNonOperator.getFirstChild();
}
... | java | private void unrollBinaryOperator(
Node n, Token op, String opStr, Context context,
Context rhsContext, int leftPrecedence, int rightPrecedence) {
Node firstNonOperator = n.getFirstChild();
while (firstNonOperator.getToken() == op) {
firstNonOperator = firstNonOperator.getFirstChild();
}
... | [
"private",
"void",
"unrollBinaryOperator",
"(",
"Node",
"n",
",",
"Token",
"op",
",",
"String",
"opStr",
",",
"Context",
"context",
",",
"Context",
"rhsContext",
",",
"int",
"leftPrecedence",
",",
"int",
"rightPrecedence",
")",
"{",
"Node",
"firstNonOperator",
... | We could use addList recursively here, but sometimes we produce
very deeply nested operators and run out of stack space, so we
just unroll the recursion when possible.
We assume nodes are left-recursive. | [
"We",
"could",
"use",
"addList",
"recursively",
"here",
"but",
"sometimes",
"we",
"produce",
"very",
"deeply",
"nested",
"operators",
"and",
"run",
"out",
"of",
"stack",
"space",
"so",
"we",
"just",
"unroll",
"the",
"recursion",
"when",
"possible",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CodeGenerator.java#L1460-L1476 |
24,370 | google/closure-compiler | src/com/google/javascript/jscomp/CodeGenerator.java | CodeGenerator.addArrayList | void addArrayList(Node firstInList) {
boolean lastWasEmpty = false;
for (Node n = firstInList; n != null; n = n.getNext()) {
if (n != firstInList) {
cc.listSeparator();
}
addExpr(n, 1, Context.OTHER);
lastWasEmpty = n.isEmpty();
}
if (lastWasEmpty) {
cc.listSeparat... | java | void addArrayList(Node firstInList) {
boolean lastWasEmpty = false;
for (Node n = firstInList; n != null; n = n.getNext()) {
if (n != firstInList) {
cc.listSeparator();
}
addExpr(n, 1, Context.OTHER);
lastWasEmpty = n.isEmpty();
}
if (lastWasEmpty) {
cc.listSeparat... | [
"void",
"addArrayList",
"(",
"Node",
"firstInList",
")",
"{",
"boolean",
"lastWasEmpty",
"=",
"false",
";",
"for",
"(",
"Node",
"n",
"=",
"firstInList",
";",
"n",
"!=",
"null",
";",
"n",
"=",
"n",
".",
"getNext",
"(",
")",
")",
"{",
"if",
"(",
"n",... | This function adds a comma-separated list as is specified by an ARRAYLIT
node with the associated skipIndexes array. This is a space optimization
since we avoid creating a whole Node object for each empty array literal
slot.
@param firstInList The first in the node list (chained through the next
property). | [
"This",
"function",
"adds",
"a",
"comma",
"-",
"separated",
"list",
"as",
"is",
"specified",
"by",
"an",
"ARRAYLIT",
"node",
"with",
"the",
"associated",
"skipIndexes",
"array",
".",
"This",
"is",
"a",
"space",
"optimization",
"since",
"we",
"avoid",
"creati... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CodeGenerator.java#L1712-L1725 |
24,371 | google/closure-compiler | src/com/google/javascript/jscomp/CodeGenerator.java | CodeGenerator.escapeUnrecognizedCharacters | private String escapeUnrecognizedCharacters(String s) {
// TODO(yitingwang) Move this method to a suitable place
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
// From the SingleEscapeCharacter grammar production.
... | java | private String escapeUnrecognizedCharacters(String s) {
// TODO(yitingwang) Move this method to a suitable place
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
// From the SingleEscapeCharacter grammar production.
... | [
"private",
"String",
"escapeUnrecognizedCharacters",
"(",
"String",
"s",
")",
"{",
"// TODO(yitingwang) Move this method to a suitable place",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"s",
... | Helper to escape the characters that might be misinterpreted
@param s the string to modify
@return the string with unrecognizable characters escaped. | [
"Helper",
"to",
"escape",
"the",
"characters",
"that",
"might",
"be",
"misinterpreted"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CodeGenerator.java#L1927-L1965 |
24,372 | google/closure-compiler | src/com/google/javascript/jscomp/CodeGenerator.java | CodeGenerator.getFirstNonEmptyChild | private static Node getFirstNonEmptyChild(Node n) {
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
if (c.isBlock()) {
Node result = getFirstNonEmptyChild(c);
if (result != null) {
return result;
}
} else if (!c.isEmpty()) {
return c;
}
... | java | private static Node getFirstNonEmptyChild(Node n) {
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
if (c.isBlock()) {
Node result = getFirstNonEmptyChild(c);
if (result != null) {
return result;
}
} else if (!c.isEmpty()) {
return c;
}
... | [
"private",
"static",
"Node",
"getFirstNonEmptyChild",
"(",
"Node",
"n",
")",
"{",
"for",
"(",
"Node",
"c",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"c",
"!=",
"null",
";",
"c",
"=",
"c",
".",
"getNext",
"(",
")",
")",
"{",
"if",
"(",
"c",
... | Gets the first non-empty child of the given node. | [
"Gets",
"the",
"first",
"non",
"-",
"empty",
"child",
"of",
"the",
"given",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CodeGenerator.java#L2007-L2019 |
24,373 | google/closure-compiler | src/com/google/javascript/jscomp/CodeGenerator.java | CodeGenerator.getContextForArrowFunctionBody | private static Context getContextForArrowFunctionBody(Context context) {
return context.inForInInitClause()
? Context.START_OF_ARROW_FN_IN_FOR_INIT
: Context.START_OF_ARROW_FN_BODY;
} | java | private static Context getContextForArrowFunctionBody(Context context) {
return context.inForInInitClause()
? Context.START_OF_ARROW_FN_IN_FOR_INIT
: Context.START_OF_ARROW_FN_BODY;
} | [
"private",
"static",
"Context",
"getContextForArrowFunctionBody",
"(",
"Context",
"context",
")",
"{",
"return",
"context",
".",
"inForInInitClause",
"(",
")",
"?",
"Context",
".",
"START_OF_ARROW_FN_IN_FOR_INIT",
":",
"Context",
".",
"START_OF_ARROW_FN_BODY",
";",
"}... | If we're at the start of an arrow function body, we need parentheses around object literals and
object patterns. We also must also pass the IN_FOR_INIT_CLAUSE flag into subexpressions. | [
"If",
"we",
"re",
"at",
"the",
"start",
"of",
"an",
"arrow",
"function",
"body",
"we",
"need",
"parentheses",
"around",
"object",
"literals",
"and",
"object",
"patterns",
".",
"We",
"also",
"must",
"also",
"pass",
"the",
"IN_FOR_INIT_CLAUSE",
"flag",
"into",... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CodeGenerator.java#L2093-L2097 |
24,374 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessDefines.java | ProcessDefines.isValidDefineType | private boolean isValidDefineType(JSTypeExpression expression) {
JSTypeRegistry registry = compiler.getTypeRegistry();
JSType type = registry.evaluateTypeExpressionInGlobalScope(expression);
return !type.isUnknownType()
&& type.isSubtypeOf(registry.getNativeType(NUMBER_STRING_BOOLEAN));
} | java | private boolean isValidDefineType(JSTypeExpression expression) {
JSTypeRegistry registry = compiler.getTypeRegistry();
JSType type = registry.evaluateTypeExpressionInGlobalScope(expression);
return !type.isUnknownType()
&& type.isSubtypeOf(registry.getNativeType(NUMBER_STRING_BOOLEAN));
} | [
"private",
"boolean",
"isValidDefineType",
"(",
"JSTypeExpression",
"expression",
")",
"{",
"JSTypeRegistry",
"registry",
"=",
"compiler",
".",
"getTypeRegistry",
"(",
")",
";",
"JSType",
"type",
"=",
"registry",
".",
"evaluateTypeExpressionInGlobalScope",
"(",
"expre... | Only defines of literal number, string, or boolean are supported. | [
"Only",
"defines",
"of",
"literal",
"number",
"string",
"or",
"boolean",
"are",
"supported",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessDefines.java#L192-L197 |
24,375 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessDefines.java | ProcessDefines.getConstantDeclValue | private static Node getConstantDeclValue(Node name) {
Node parent = name.getParent();
if (parent == null) {
return null;
}
if (name.isName()) {
if (parent.isConst()) {
return name.getFirstChild();
} else if (!parent.isVar()) {
return null;
}
JSDocInfo jsdoc ... | java | private static Node getConstantDeclValue(Node name) {
Node parent = name.getParent();
if (parent == null) {
return null;
}
if (name.isName()) {
if (parent.isConst()) {
return name.getFirstChild();
} else if (!parent.isVar()) {
return null;
}
JSDocInfo jsdoc ... | [
"private",
"static",
"Node",
"getConstantDeclValue",
"(",
"Node",
"name",
")",
"{",
"Node",
"parent",
"=",
"name",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"name",
".",
"isNa... | Checks whether the NAME node is inside either a CONST or a @const VAR. Returns the RHS node if
so, otherwise returns null. | [
"Checks",
"whether",
"the",
"NAME",
"node",
"is",
"inside",
"either",
"a",
"CONST",
"or",
"a"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessDefines.java#L612-L630 |
24,376 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessDefines.java | ProcessDefines.setDefineInfoNotAssignable | private static void setDefineInfoNotAssignable(DefineInfo info, NodeTraversal t) {
info.setNotAssignable(
format(REASON_DEFINE_NOT_ASSIGNABLE, t.getLineNumber(), t.getSourceName()));
} | java | private static void setDefineInfoNotAssignable(DefineInfo info, NodeTraversal t) {
info.setNotAssignable(
format(REASON_DEFINE_NOT_ASSIGNABLE, t.getLineNumber(), t.getSourceName()));
} | [
"private",
"static",
"void",
"setDefineInfoNotAssignable",
"(",
"DefineInfo",
"info",
",",
"NodeTraversal",
"t",
")",
"{",
"info",
".",
"setNotAssignable",
"(",
"format",
"(",
"REASON_DEFINE_NOT_ASSIGNABLE",
",",
"t",
".",
"getLineNumber",
"(",
")",
",",
"t",
".... | Records the fact that because of the current node in the node traversal, the define can't ever
be assigned again.
@param info Represents the define variable.
@param t The current traversal. | [
"Records",
"the",
"fact",
"that",
"because",
"of",
"the",
"current",
"node",
"in",
"the",
"node",
"traversal",
"the",
"define",
"can",
"t",
"ever",
"be",
"assigned",
"again",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessDefines.java#L639-L642 |
24,377 | google/closure-compiler | src/com/google/javascript/jscomp/ExternExportsPass.java | ExternExportsPass.computePathPrefixes | private static ImmutableList<String> computePathPrefixes(String path) {
List<String> pieces = Q_NAME_SPLITTER.splitToList(path);
ImmutableList.Builder<String> pathPrefixes = ImmutableList.builder();
String partial = pieces.get(0); // There will always be at least 1.
pathPrefixes.add(partial);
for (... | java | private static ImmutableList<String> computePathPrefixes(String path) {
List<String> pieces = Q_NAME_SPLITTER.splitToList(path);
ImmutableList.Builder<String> pathPrefixes = ImmutableList.builder();
String partial = pieces.get(0); // There will always be at least 1.
pathPrefixes.add(partial);
for (... | [
"private",
"static",
"ImmutableList",
"<",
"String",
">",
"computePathPrefixes",
"(",
"String",
"path",
")",
"{",
"List",
"<",
"String",
">",
"pieces",
"=",
"Q_NAME_SPLITTER",
".",
"splitToList",
"(",
"path",
")",
";",
"ImmutableList",
".",
"Builder",
"<",
"... | Computes a list of the path prefixes constructed from the components of the path.
<pre>
E.g., if the path is:
"a.b.c"
then then path prefixes will be
["a","a.b","a.b.c"]:
</pre> | [
"Computes",
"a",
"list",
"of",
"the",
"path",
"prefixes",
"constructed",
"from",
"the",
"components",
"of",
"the",
"path",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ExternExportsPass.java#L477-L489 |
24,378 | google/closure-compiler | src/com/google/javascript/jscomp/ClosureCheckModule.java | ClosureCheckModule.isExportLhs | private boolean isExportLhs(Node lhs) {
if (!lhs.isQualifiedName()) {
return false;
}
return lhs.matchesQualifiedName("exports")
|| (lhs.isGetProp() && lhs.getFirstChild().matchesQualifiedName("exports"));
} | java | private boolean isExportLhs(Node lhs) {
if (!lhs.isQualifiedName()) {
return false;
}
return lhs.matchesQualifiedName("exports")
|| (lhs.isGetProp() && lhs.getFirstChild().matchesQualifiedName("exports"));
} | [
"private",
"boolean",
"isExportLhs",
"(",
"Node",
"lhs",
")",
"{",
"if",
"(",
"!",
"lhs",
".",
"isQualifiedName",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"lhs",
".",
"matchesQualifiedName",
"(",
"\"exports\"",
")",
"||",
"(",
"lhs",
... | Is this the LHS of a goog.module export? i.e. Either "exports" or "exports.name" | [
"Is",
"this",
"the",
"LHS",
"of",
"a",
"goog",
".",
"module",
"export?",
"i",
".",
"e",
".",
"Either",
"exports",
"or",
"exports",
".",
"name"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ClosureCheckModule.java#L367-L373 |
24,379 | google/closure-compiler | src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java | DefaultDependencyResolver.getDependencies | @Override
public List<String> getDependencies(String code)
throws ServiceException {
return getDependencies(parseRequires(code, true));
} | java | @Override
public List<String> getDependencies(String code)
throws ServiceException {
return getDependencies(parseRequires(code, true));
} | [
"@",
"Override",
"public",
"List",
"<",
"String",
">",
"getDependencies",
"(",
"String",
"code",
")",
"throws",
"ServiceException",
"{",
"return",
"getDependencies",
"(",
"parseRequires",
"(",
"code",
",",
"true",
")",
")",
";",
"}"
] | Gets a list of dependencies for the provided code. | [
"Gets",
"a",
"list",
"of",
"dependencies",
"for",
"the",
"provided",
"code",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java#L71-L75 |
24,380 | google/closure-compiler | src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java | DefaultDependencyResolver.getDependencies | @Override
public List<String> getDependencies(Collection<String> symbols)
throws ServiceException {
return getDependencies(symbols, new HashSet<String>());
} | java | @Override
public List<String> getDependencies(Collection<String> symbols)
throws ServiceException {
return getDependencies(symbols, new HashSet<String>());
} | [
"@",
"Override",
"public",
"List",
"<",
"String",
">",
"getDependencies",
"(",
"Collection",
"<",
"String",
">",
"symbols",
")",
"throws",
"ServiceException",
"{",
"return",
"getDependencies",
"(",
"symbols",
",",
"new",
"HashSet",
"<",
"String",
">",
"(",
"... | Gets a list of dependencies for the provided list of symbols. | [
"Gets",
"a",
"list",
"of",
"dependencies",
"for",
"the",
"provided",
"list",
"of",
"symbols",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java#L78-L82 |
24,381 | google/closure-compiler | src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java | DefaultDependencyResolver.parseRequires | private static Collection<String> parseRequires(String code, boolean addClosureBase) {
ErrorManager errorManager = new LoggerErrorManager(logger);
JsFileParser parser = new JsFileParser(errorManager);
DependencyInfo deps =
parser.parseFile("<unknown path>", "<unknown path>", code);
List<String> ... | java | private static Collection<String> parseRequires(String code, boolean addClosureBase) {
ErrorManager errorManager = new LoggerErrorManager(logger);
JsFileParser parser = new JsFileParser(errorManager);
DependencyInfo deps =
parser.parseFile("<unknown path>", "<unknown path>", code);
List<String> ... | [
"private",
"static",
"Collection",
"<",
"String",
">",
"parseRequires",
"(",
"String",
"code",
",",
"boolean",
"addClosureBase",
")",
"{",
"ErrorManager",
"errorManager",
"=",
"new",
"LoggerErrorManager",
"(",
"logger",
")",
";",
"JsFileParser",
"parser",
"=",
"... | Parses a block of code for goog.require statements and extracts the required symbols. | [
"Parses",
"a",
"block",
"of",
"code",
"for",
"goog",
".",
"require",
"statements",
"and",
"extracts",
"the",
"required",
"symbols",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java#L142-L154 |
24,382 | google/closure-compiler | src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java | DefaultDependencyResolver.getDependencyInfo | private DependencyInfo getDependencyInfo(String symbol) {
for (DependencyFile depsFile : depsFiles) {
DependencyInfo di = depsFile.getDependencyInfo(symbol);
if (di != null) {
return di;
}
}
return null;
} | java | private DependencyInfo getDependencyInfo(String symbol) {
for (DependencyFile depsFile : depsFiles) {
DependencyInfo di = depsFile.getDependencyInfo(symbol);
if (di != null) {
return di;
}
}
return null;
} | [
"private",
"DependencyInfo",
"getDependencyInfo",
"(",
"String",
"symbol",
")",
"{",
"for",
"(",
"DependencyFile",
"depsFile",
":",
"depsFiles",
")",
"{",
"DependencyInfo",
"di",
"=",
"depsFile",
".",
"getDependencyInfo",
"(",
"symbol",
")",
";",
"if",
"(",
"d... | Looks at each of the dependency files for dependency information. | [
"Looks",
"at",
"each",
"of",
"the",
"dependency",
"files",
"for",
"dependency",
"information",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/DefaultDependencyResolver.java#L157-L165 |
24,383 | google/closure-compiler | src/com/google/javascript/rhino/jstype/NamedType.java | NamedType.resolveViaRegistry | private boolean resolveViaRegistry(ErrorReporter reporter) {
JSType type = registry.getType(resolutionScope, reference);
if (type != null) {
setReferencedAndResolvedType(type, reporter);
return true;
}
return false;
} | java | private boolean resolveViaRegistry(ErrorReporter reporter) {
JSType type = registry.getType(resolutionScope, reference);
if (type != null) {
setReferencedAndResolvedType(type, reporter);
return true;
}
return false;
} | [
"private",
"boolean",
"resolveViaRegistry",
"(",
"ErrorReporter",
"reporter",
")",
"{",
"JSType",
"type",
"=",
"registry",
".",
"getType",
"(",
"resolutionScope",
",",
"reference",
")",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"setReferencedAndResolvedTyp... | Resolves a named type by looking it up in the registry.
@return True if we resolved successfully. | [
"Resolves",
"a",
"named",
"type",
"by",
"looking",
"it",
"up",
"in",
"the",
"registry",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/NamedType.java#L274-L281 |
24,384 | google/closure-compiler | src/com/google/javascript/rhino/jstype/NamedType.java | NamedType.resolveViaProperties | private void resolveViaProperties(ErrorReporter reporter) {
String[] componentNames = reference.split("\\.", -1);
if (componentNames[0].length() == 0) {
handleUnresolvedType(reporter, /* ignoreForwardReferencedTypes= */ true);
return;
}
StaticTypedSlot slot = resolutionScope.getSlot(compone... | java | private void resolveViaProperties(ErrorReporter reporter) {
String[] componentNames = reference.split("\\.", -1);
if (componentNames[0].length() == 0) {
handleUnresolvedType(reporter, /* ignoreForwardReferencedTypes= */ true);
return;
}
StaticTypedSlot slot = resolutionScope.getSlot(compone... | [
"private",
"void",
"resolveViaProperties",
"(",
"ErrorReporter",
"reporter",
")",
"{",
"String",
"[",
"]",
"componentNames",
"=",
"reference",
".",
"split",
"(",
"\"\\\\.\"",
",",
"-",
"1",
")",
";",
"if",
"(",
"componentNames",
"[",
"0",
"]",
".",
"length... | Resolves a named type by looking up its first component in the scope, and subsequent components
as properties. The scope must have been fully parsed and a symbol table constructed. | [
"Resolves",
"a",
"named",
"type",
"by",
"looking",
"up",
"its",
"first",
"component",
"in",
"the",
"scope",
"and",
"subsequent",
"components",
"as",
"properties",
".",
"The",
"scope",
"must",
"have",
"been",
"fully",
"parsed",
"and",
"a",
"symbol",
"table",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/NamedType.java#L287-L347 |
24,385 | google/closure-compiler | src/com/google/javascript/rhino/jstype/NamedType.java | NamedType.handleUnresolvedType | private void handleUnresolvedType(
ErrorReporter reporter, boolean ignoreForwardReferencedTypes) {
boolean isForwardDeclared =
ignoreForwardReferencedTypes && registry.isForwardDeclaredType(reference);
if (!isForwardDeclared) {
String msg = "Bad type annotation. Unknown type " + reference;
... | java | private void handleUnresolvedType(
ErrorReporter reporter, boolean ignoreForwardReferencedTypes) {
boolean isForwardDeclared =
ignoreForwardReferencedTypes && registry.isForwardDeclaredType(reference);
if (!isForwardDeclared) {
String msg = "Bad type annotation. Unknown type " + reference;
... | [
"private",
"void",
"handleUnresolvedType",
"(",
"ErrorReporter",
"reporter",
",",
"boolean",
"ignoreForwardReferencedTypes",
")",
"{",
"boolean",
"isForwardDeclared",
"=",
"ignoreForwardReferencedTypes",
"&&",
"registry",
".",
"isForwardDeclaredType",
"(",
"reference",
")",... | type name. | [
"type",
"name",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/NamedType.java#L384-L399 |
24,386 | google/closure-compiler | src/com/google/javascript/jscomp/CoalesceVariableNames.java | CoalesceVariableNames.computeVariableNamesInterferenceGraph | private UndiGraph<Var, Void> computeVariableNamesInterferenceGraph(
ControlFlowGraph<Node> cfg, Set<? extends Var> escaped) {
UndiGraph<Var, Void> interferenceGraph = LinkedUndirectedGraph.create();
// First create a node for each non-escaped variable. We add these nodes in the order in which
// they... | java | private UndiGraph<Var, Void> computeVariableNamesInterferenceGraph(
ControlFlowGraph<Node> cfg, Set<? extends Var> escaped) {
UndiGraph<Var, Void> interferenceGraph = LinkedUndirectedGraph.create();
// First create a node for each non-escaped variable. We add these nodes in the order in which
// they... | [
"private",
"UndiGraph",
"<",
"Var",
",",
"Void",
">",
"computeVariableNamesInterferenceGraph",
"(",
"ControlFlowGraph",
"<",
"Node",
">",
"cfg",
",",
"Set",
"<",
"?",
"extends",
"Var",
">",
"escaped",
")",
"{",
"UndiGraph",
"<",
"Var",
",",
"Void",
">",
"i... | In order to determine when it is appropriate to coalesce two variables, we use a live variables
analysis to make sure they are not alive at the same time. We take every pairing of variables
and for every CFG node, determine whether the two variables are alive at the same time. If two
variables are alive at the same tim... | [
"In",
"order",
"to",
"determine",
"when",
"it",
"is",
"appropriate",
"to",
"coalesce",
"two",
"variables",
"we",
"use",
"a",
"live",
"variables",
"analysis",
"to",
"make",
"sure",
"they",
"are",
"not",
"alive",
"at",
"the",
"same",
"time",
".",
"We",
"ta... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CoalesceVariableNames.java#L263-L376 |
24,387 | google/closure-compiler | src/com/google/javascript/jscomp/CoalesceVariableNames.java | CoalesceVariableNames.isInMultipleLvalueDecl | private boolean isInMultipleLvalueDecl(Var v) {
Token declarationType = v.declarationType();
switch (declarationType) {
case LET:
case CONST:
case VAR:
Node nameDecl = NodeUtil.getEnclosingNode(v.getNode(), NodeUtil::isNameDeclaration);
return NodeUtil.findLhsNodesInNode(nameDe... | java | private boolean isInMultipleLvalueDecl(Var v) {
Token declarationType = v.declarationType();
switch (declarationType) {
case LET:
case CONST:
case VAR:
Node nameDecl = NodeUtil.getEnclosingNode(v.getNode(), NodeUtil::isNameDeclaration);
return NodeUtil.findLhsNodesInNode(nameDe... | [
"private",
"boolean",
"isInMultipleLvalueDecl",
"(",
"Var",
"v",
")",
"{",
"Token",
"declarationType",
"=",
"v",
".",
"declarationType",
"(",
")",
";",
"switch",
"(",
"declarationType",
")",
"{",
"case",
"LET",
":",
"case",
"CONST",
":",
"case",
"VAR",
":"... | Returns whether this variable's declaration also declares other names.
<p>For example, this would return true for `x` in `let [x, y, z] = []`; | [
"Returns",
"whether",
"this",
"variable",
"s",
"declaration",
"also",
"declares",
"other",
"names",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CoalesceVariableNames.java#L383-L394 |
24,388 | google/closure-compiler | src/com/google/javascript/jscomp/CoalesceVariableNames.java | CoalesceVariableNames.removeVarDeclaration | private static void removeVarDeclaration(Node name) {
Node var = NodeUtil.getEnclosingNode(name, NodeUtil::isNameDeclaration);
Node parent = var.getParent();
if (var.getFirstChild().isDestructuringLhs()) {
// convert `const [x] = arr` to `[x] = arr`
// a precondition for this method is that `x`... | java | private static void removeVarDeclaration(Node name) {
Node var = NodeUtil.getEnclosingNode(name, NodeUtil::isNameDeclaration);
Node parent = var.getParent();
if (var.getFirstChild().isDestructuringLhs()) {
// convert `const [x] = arr` to `[x] = arr`
// a precondition for this method is that `x`... | [
"private",
"static",
"void",
"removeVarDeclaration",
"(",
"Node",
"name",
")",
"{",
"Node",
"var",
"=",
"NodeUtil",
".",
"getEnclosingNode",
"(",
"name",
",",
"NodeUtil",
"::",
"isNameDeclaration",
")",
";",
"Node",
"parent",
"=",
"var",
".",
"getParent",
"(... | Remove variable declaration if the variable has been coalesced with another variable that has
already been declared.
<p>A precondition is that if the variable has already been declared, it must be the only lvalue
in said declaration. For example, this method will not accept `var x = 1, y = 2`. In theory we
could leave... | [
"Remove",
"variable",
"declaration",
"if",
"the",
"variable",
"has",
"been",
"coalesced",
"with",
"another",
"variable",
"that",
"has",
"already",
"been",
"declared",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CoalesceVariableNames.java#L462-L501 |
24,389 | google/closure-compiler | src/com/google/javascript/jscomp/CoalesceVariableNames.java | CoalesceVariableNames.makeDeclarationVar | private static void makeDeclarationVar(Var coalescedName) {
if (coalescedName.isLet() || coalescedName.isConst()) {
Node declNode =
NodeUtil.getEnclosingNode(coalescedName.getParentNode(), NodeUtil::isNameDeclaration);
declNode.setToken(Token.VAR);
}
} | java | private static void makeDeclarationVar(Var coalescedName) {
if (coalescedName.isLet() || coalescedName.isConst()) {
Node declNode =
NodeUtil.getEnclosingNode(coalescedName.getParentNode(), NodeUtil::isNameDeclaration);
declNode.setToken(Token.VAR);
}
} | [
"private",
"static",
"void",
"makeDeclarationVar",
"(",
"Var",
"coalescedName",
")",
"{",
"if",
"(",
"coalescedName",
".",
"isLet",
"(",
")",
"||",
"coalescedName",
".",
"isConst",
"(",
")",
")",
"{",
"Node",
"declNode",
"=",
"NodeUtil",
".",
"getEnclosingNo... | Because the code has already been normalized by the time this pass runs, we can safely
redeclare any let and const coalesced variables as vars | [
"Because",
"the",
"code",
"has",
"already",
"been",
"normalized",
"by",
"the",
"time",
"this",
"pass",
"runs",
"we",
"can",
"safely",
"redeclare",
"any",
"let",
"and",
"const",
"coalesced",
"variables",
"as",
"vars"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CoalesceVariableNames.java#L507-L513 |
24,390 | google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteClass.java | Es6RewriteClass.visitMethod | private void visitMethod(Node member, ClassDeclarationMetadata metadata) {
Node qualifiedMemberAccess = getQualifiedMemberAccess(member, metadata);
Node method = member.getLastChild().detach();
// Use the source info from the method (a FUNCTION) not the MEMBER_FUNCTION_DEF
// because the MEMBER_FUNCTIO... | java | private void visitMethod(Node member, ClassDeclarationMetadata metadata) {
Node qualifiedMemberAccess = getQualifiedMemberAccess(member, metadata);
Node method = member.getLastChild().detach();
// Use the source info from the method (a FUNCTION) not the MEMBER_FUNCTION_DEF
// because the MEMBER_FUNCTIO... | [
"private",
"void",
"visitMethod",
"(",
"Node",
"member",
",",
"ClassDeclarationMetadata",
"metadata",
")",
"{",
"Node",
"qualifiedMemberAccess",
"=",
"getQualifiedMemberAccess",
"(",
"member",
",",
"metadata",
")",
";",
"Node",
"method",
"=",
"member",
".",
"getLa... | Handles transpilation of a standard class member function. Getters, setters, and the
constructor are not handled here. | [
"Handles",
"transpilation",
"of",
"a",
"standard",
"class",
"member",
"function",
".",
"Getters",
"setters",
"and",
"the",
"constructor",
"are",
"not",
"handled",
"here",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteClass.java#L500-L523 |
24,391 | google/closure-compiler | src/com/google/javascript/jscomp/modules/ResolveExportResult.java | ResolveExportResult.copy | ResolveExportResult copy(Node sourceNode, Binding.CreatedBy createdBy) {
checkNotNull(sourceNode);
if (binding == null) {
return this;
}
return new ResolveExportResult(binding.copy(sourceNode, createdBy), state);
} | java | ResolveExportResult copy(Node sourceNode, Binding.CreatedBy createdBy) {
checkNotNull(sourceNode);
if (binding == null) {
return this;
}
return new ResolveExportResult(binding.copy(sourceNode, createdBy), state);
} | [
"ResolveExportResult",
"copy",
"(",
"Node",
"sourceNode",
",",
"Binding",
".",
"CreatedBy",
"createdBy",
")",
"{",
"checkNotNull",
"(",
"sourceNode",
")",
";",
"if",
"(",
"binding",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"Reso... | Creates a new result that has the given node for the source of the binding and given type of
binding. | [
"Creates",
"a",
"new",
"result",
"that",
"has",
"the",
"given",
"node",
"for",
"the",
"source",
"of",
"the",
"binding",
"and",
"given",
"type",
"of",
"binding",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/modules/ResolveExportResult.java#L47-L55 |
24,392 | google/closure-compiler | src/com/google/debugging/sourcemap/Util.java | Util.appendHexJavaScriptRepresentation | private static void appendHexJavaScriptRepresentation(
int codePoint, Appendable out)
throws IOException {
if (Character.isSupplementaryCodePoint(codePoint)) {
// Handle supplementary Unicode values which are not representable in
// JavaScript. We deal with these by escaping them as two 4B ... | java | private static void appendHexJavaScriptRepresentation(
int codePoint, Appendable out)
throws IOException {
if (Character.isSupplementaryCodePoint(codePoint)) {
// Handle supplementary Unicode values which are not representable in
// JavaScript. We deal with these by escaping them as two 4B ... | [
"private",
"static",
"void",
"appendHexJavaScriptRepresentation",
"(",
"int",
"codePoint",
",",
"Appendable",
"out",
")",
"throws",
"IOException",
"{",
"if",
"(",
"Character",
".",
"isSupplementaryCodePoint",
"(",
"codePoint",
")",
")",
"{",
"// Handle supplementary U... | Returns a JavaScript representation of the character in a hex escaped
format.
@param codePoint The code point to append.
@param out The buffer to which the hex representation should be appended. | [
"Returns",
"a",
"JavaScript",
"representation",
"of",
"the",
"character",
"in",
"a",
"hex",
"escaped",
"format",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/debugging/sourcemap/Util.java#L111-L129 |
24,393 | google/closure-compiler | src/com/google/javascript/jscomp/DisambiguateProperties.java | DisambiguateProperties.getProperty | protected Property getProperty(String name) {
if (!properties.containsKey(name)) {
properties.put(name, new Property(name));
}
return properties.get(name);
} | java | protected Property getProperty(String name) {
if (!properties.containsKey(name)) {
properties.put(name, new Property(name));
}
return properties.get(name);
} | [
"protected",
"Property",
"getProperty",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"!",
"properties",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"properties",
".",
"put",
"(",
"name",
",",
"new",
"Property",
"(",
"name",
")",
")",
";",
"}",
"re... | Returns the property for the given name, creating it if necessary. | [
"Returns",
"the",
"property",
"for",
"the",
"given",
"name",
"creating",
"it",
"if",
"necessary",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DisambiguateProperties.java#L407-L412 |
24,394 | google/closure-compiler | src/com/google/javascript/jscomp/DisambiguateProperties.java | DisambiguateProperties.renameProperties | void renameProperties() {
int propsRenamed = 0;
int propsSkipped = 0;
int instancesRenamed = 0;
int instancesSkipped = 0;
int singleTypeProps = 0;
Set<String> reported = new HashSet<>();
for (Property prop : properties.values()) {
if (prop.shouldRename()) {
UnionFind<JSType> p... | java | void renameProperties() {
int propsRenamed = 0;
int propsSkipped = 0;
int instancesRenamed = 0;
int instancesSkipped = 0;
int singleTypeProps = 0;
Set<String> reported = new HashSet<>();
for (Property prop : properties.values()) {
if (prop.shouldRename()) {
UnionFind<JSType> p... | [
"void",
"renameProperties",
"(",
")",
"{",
"int",
"propsRenamed",
"=",
"0",
";",
"int",
"propsSkipped",
"=",
"0",
";",
"int",
"instancesRenamed",
"=",
"0",
";",
"int",
"instancesSkipped",
"=",
"0",
";",
"int",
"singleTypeProps",
"=",
"0",
";",
"Set",
"<"... | Renames all properties with references on more than one type. | [
"Renames",
"all",
"properties",
"with",
"references",
"on",
"more",
"than",
"one",
"type",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DisambiguateProperties.java#L800-L858 |
24,395 | google/closure-compiler | src/com/google/javascript/jscomp/DisambiguateProperties.java | DisambiguateProperties.buildPropNames | private Map<JSType, String> buildPropNames(Property prop) {
UnionFind<JSType> pTypes = prop.getTypes();
String pname = prop.name;
Map<JSType, String> names = new HashMap<>();
for (Set<JSType> set : pTypes.allEquivalenceClasses()) {
checkState(!set.isEmpty());
JSType representative = pTypes.f... | java | private Map<JSType, String> buildPropNames(Property prop) {
UnionFind<JSType> pTypes = prop.getTypes();
String pname = prop.name;
Map<JSType, String> names = new HashMap<>();
for (Set<JSType> set : pTypes.allEquivalenceClasses()) {
checkState(!set.isEmpty());
JSType representative = pTypes.f... | [
"private",
"Map",
"<",
"JSType",
",",
"String",
">",
"buildPropNames",
"(",
"Property",
"prop",
")",
"{",
"UnionFind",
"<",
"JSType",
">",
"pTypes",
"=",
"prop",
".",
"getTypes",
"(",
")",
";",
"String",
"pname",
"=",
"prop",
".",
"name",
";",
"Map",
... | Chooses a name to use for renaming in each equivalence class and maps
the representative type of that class to that name. | [
"Chooses",
"a",
"name",
"to",
"use",
"for",
"renaming",
"in",
"each",
"equivalence",
"class",
"and",
"maps",
"the",
"representative",
"type",
"of",
"that",
"class",
"to",
"that",
"name",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DisambiguateProperties.java#L864-L887 |
24,396 | google/closure-compiler | src/com/google/javascript/jscomp/DisambiguateProperties.java | DisambiguateProperties.getTypesToSkipForType | private ImmutableSet<JSType> getTypesToSkipForType(JSType type) {
type = type.restrictByNotNullOrUndefined();
if (type.isUnionType()) {
ImmutableSet.Builder<JSType> types = ImmutableSet.builder();
types.add(type);
for (JSType alt : type.getUnionMembers()) {
types.addAll(getTypesToSkipF... | java | private ImmutableSet<JSType> getTypesToSkipForType(JSType type) {
type = type.restrictByNotNullOrUndefined();
if (type.isUnionType()) {
ImmutableSet.Builder<JSType> types = ImmutableSet.builder();
types.add(type);
for (JSType alt : type.getUnionMembers()) {
types.addAll(getTypesToSkipF... | [
"private",
"ImmutableSet",
"<",
"JSType",
">",
"getTypesToSkipForType",
"(",
"JSType",
"type",
")",
"{",
"type",
"=",
"type",
".",
"restrictByNotNullOrUndefined",
"(",
")",
";",
"if",
"(",
"type",
".",
"isUnionType",
"(",
")",
")",
"{",
"ImmutableSet",
".",
... | Returns a set of types that should be skipped given the given type. This is
necessary for interfaces, as all super interfaces must also be skipped. | [
"Returns",
"a",
"set",
"of",
"types",
"that",
"should",
"be",
"skipped",
"given",
"the",
"given",
"type",
".",
"This",
"is",
"necessary",
"for",
"interfaces",
"as",
"all",
"super",
"interfaces",
"must",
"also",
"be",
"skipped",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DisambiguateProperties.java#L917-L930 |
24,397 | google/closure-compiler | src/com/google/javascript/jscomp/DisambiguateProperties.java | DisambiguateProperties.getTypeAlternatives | private Iterable<? extends JSType> getTypeAlternatives(JSType type) {
if (type.isUnionType()) {
return type.getUnionMembers();
} else {
ObjectType objType = type.toMaybeObjectType();
FunctionType constructor = objType != null ? objType.getConstructor() : null;
if (constructor != null && ... | java | private Iterable<? extends JSType> getTypeAlternatives(JSType type) {
if (type.isUnionType()) {
return type.getUnionMembers();
} else {
ObjectType objType = type.toMaybeObjectType();
FunctionType constructor = objType != null ? objType.getConstructor() : null;
if (constructor != null && ... | [
"private",
"Iterable",
"<",
"?",
"extends",
"JSType",
">",
"getTypeAlternatives",
"(",
"JSType",
"type",
")",
"{",
"if",
"(",
"type",
".",
"isUnionType",
"(",
")",
")",
"{",
"return",
"type",
".",
"getUnionMembers",
"(",
")",
";",
"}",
"else",
"{",
"Ob... | Returns the alternatives if this is a type that represents multiple
types, and null if not. Union and interface types can correspond to
multiple other types. | [
"Returns",
"the",
"alternatives",
"if",
"this",
"is",
"a",
"type",
"that",
"represents",
"multiple",
"types",
"and",
"null",
"if",
"not",
".",
"Union",
"and",
"interface",
"types",
"can",
"correspond",
"to",
"multiple",
"other",
"types",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DisambiguateProperties.java#L960-L976 |
24,398 | google/closure-compiler | src/com/google/javascript/jscomp/DisambiguateProperties.java | DisambiguateProperties.getTypeWithProperty | private ObjectType getTypeWithProperty(String field, JSType type) {
if (type == null) {
return null;
}
ObjectType foundType = gtwpCacheGet(field, type);
if (foundType != null) {
return foundType.equals(bottomObjectType) ? null : foundType;
}
if (type.isEnumElementType()) {
fo... | java | private ObjectType getTypeWithProperty(String field, JSType type) {
if (type == null) {
return null;
}
ObjectType foundType = gtwpCacheGet(field, type);
if (foundType != null) {
return foundType.equals(bottomObjectType) ? null : foundType;
}
if (type.isEnumElementType()) {
fo... | [
"private",
"ObjectType",
"getTypeWithProperty",
"(",
"String",
"field",
",",
"JSType",
"type",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"ObjectType",
"foundType",
"=",
"gtwpCacheGet",
"(",
"field",
",",
"type",
")",
... | Returns the type in the chain from the given type that contains the given
field or null if it is not found anywhere.
Can return a subtype of the input type. | [
"Returns",
"the",
"type",
"in",
"the",
"chain",
"from",
"the",
"given",
"type",
"that",
"contains",
"the",
"given",
"field",
"or",
"null",
"if",
"it",
"is",
"not",
"found",
"anywhere",
".",
"Can",
"return",
"a",
"subtype",
"of",
"the",
"input",
"type",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DisambiguateProperties.java#L983-L1062 |
24,399 | google/closure-compiler | src/com/google/javascript/jscomp/DisambiguateProperties.java | DisambiguateProperties.getInstanceIfPrototype | @Nullable
private static JSType getInstanceIfPrototype(JSType maybePrototype) {
if (maybePrototype.isFunctionPrototypeType()) {
FunctionType constructor = maybePrototype.toObjectType().getOwnerFunction();
if (constructor != null) {
if (!constructor.hasInstanceType()) {
// this can ha... | java | @Nullable
private static JSType getInstanceIfPrototype(JSType maybePrototype) {
if (maybePrototype.isFunctionPrototypeType()) {
FunctionType constructor = maybePrototype.toObjectType().getOwnerFunction();
if (constructor != null) {
if (!constructor.hasInstanceType()) {
// this can ha... | [
"@",
"Nullable",
"private",
"static",
"JSType",
"getInstanceIfPrototype",
"(",
"JSType",
"maybePrototype",
")",
"{",
"if",
"(",
"maybePrototype",
".",
"isFunctionPrototypeType",
"(",
")",
")",
"{",
"FunctionType",
"constructor",
"=",
"maybePrototype",
".",
"toObject... | Returns the corresponding instance if `maybePrototype` is a prototype of a constructor,
otherwise null | [
"Returns",
"the",
"corresponding",
"instance",
"if",
"maybePrototype",
"is",
"a",
"prototype",
"of",
"a",
"constructor",
"otherwise",
"null"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DisambiguateProperties.java#L1076-L1089 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.