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,600 | google/closure-compiler | src/com/google/javascript/rhino/jstype/TemplateTypeMap.java | TemplateTypeMap.concatImmutableLists | private static <T> ImmutableList<T> concatImmutableLists(
ImmutableList<T> first, ImmutableList<T> second) {
if (first.isEmpty()) {
return second;
}
if (second.isEmpty()) {
return first;
}
return ImmutableList.<T>builder().addAll(first).addAll(second).build();
} | java | private static <T> ImmutableList<T> concatImmutableLists(
ImmutableList<T> first, ImmutableList<T> second) {
if (first.isEmpty()) {
return second;
}
if (second.isEmpty()) {
return first;
}
return ImmutableList.<T>builder().addAll(first).addAll(second).build();
} | [
"private",
"static",
"<",
"T",
">",
"ImmutableList",
"<",
"T",
">",
"concatImmutableLists",
"(",
"ImmutableList",
"<",
"T",
">",
"first",
",",
"ImmutableList",
"<",
"T",
">",
"second",
")",
"{",
"if",
"(",
"first",
".",
"isEmpty",
"(",
")",
")",
"{",
... | Concatenates two ImmutableList instances. If either input is empty, the other is returned;
otherwise, a new ImmutableList instance is created that contains the contents of both
arguments. | [
"Concatenates",
"two",
"ImmutableList",
"instances",
".",
"If",
"either",
"input",
"is",
"empty",
"the",
"other",
"is",
"returned",
";",
"otherwise",
"a",
"new",
"ImmutableList",
"instance",
"is",
"created",
"that",
"contains",
"the",
"contents",
"of",
"both",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/TemplateTypeMap.java#L382-L392 |
24,601 | google/closure-compiler | src/com/google/javascript/jscomp/ModuleIdentifier.java | ModuleIdentifier.forClosure | public static ModuleIdentifier forClosure(String name) {
String normalizedName = name;
if (normalizedName.startsWith("goog:")) {
normalizedName = normalizedName.substring("goog:".length());
}
String namespace = normalizedName;
String moduleName = normalizedName;
int splitPoint = normalize... | java | public static ModuleIdentifier forClosure(String name) {
String normalizedName = name;
if (normalizedName.startsWith("goog:")) {
normalizedName = normalizedName.substring("goog:".length());
}
String namespace = normalizedName;
String moduleName = normalizedName;
int splitPoint = normalize... | [
"public",
"static",
"ModuleIdentifier",
"forClosure",
"(",
"String",
"name",
")",
"{",
"String",
"normalizedName",
"=",
"name",
";",
"if",
"(",
"normalizedName",
".",
"startsWith",
"(",
"\"goog:\"",
")",
")",
"{",
"normalizedName",
"=",
"normalizedName",
".",
... | Returns an identifier for a Closure namespace.
@param name The Closure namespace. It may be in one of the formats `name.space`,
`goog:name.space` or `goog:moduleName:name.space`, where the latter specifies that the
module and namespace names are different. | [
"Returns",
"an",
"identifier",
"for",
"a",
"Closure",
"namespace",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ModuleIdentifier.java#L59-L74 |
24,602 | google/closure-compiler | src/com/google/javascript/jscomp/ModuleIdentifier.java | ModuleIdentifier.forFile | public static ModuleIdentifier forFile(String filepath) {
String normalizedName = ModuleNames.fileToModuleName(filepath);
return new AutoValue_ModuleIdentifier(filepath, normalizedName, normalizedName);
} | java | public static ModuleIdentifier forFile(String filepath) {
String normalizedName = ModuleNames.fileToModuleName(filepath);
return new AutoValue_ModuleIdentifier(filepath, normalizedName, normalizedName);
} | [
"public",
"static",
"ModuleIdentifier",
"forFile",
"(",
"String",
"filepath",
")",
"{",
"String",
"normalizedName",
"=",
"ModuleNames",
".",
"fileToModuleName",
"(",
"filepath",
")",
";",
"return",
"new",
"AutoValue_ModuleIdentifier",
"(",
"filepath",
",",
"normaliz... | Returns an identifier for an ES or CommonJS module.
@param filepath Path to the ES or CommonJS module. | [
"Returns",
"an",
"identifier",
"for",
"an",
"ES",
"or",
"CommonJS",
"module",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ModuleIdentifier.java#L81-L84 |
24,603 | google/closure-compiler | src/com/google/javascript/jscomp/ValidityCheck.java | ValidityCheck.checkAst | private void checkAst(Node externs, Node root) {
astValidator.validateCodeRoot(externs);
astValidator.validateCodeRoot(root);
} | java | private void checkAst(Node externs, Node root) {
astValidator.validateCodeRoot(externs);
astValidator.validateCodeRoot(root);
} | [
"private",
"void",
"checkAst",
"(",
"Node",
"externs",
",",
"Node",
"root",
")",
"{",
"astValidator",
".",
"validateCodeRoot",
"(",
"externs",
")",
";",
"astValidator",
".",
"validateCodeRoot",
"(",
"root",
")",
";",
"}"
] | Check that the AST is structurally accurate. | [
"Check",
"that",
"the",
"AST",
"is",
"structurally",
"accurate",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ValidityCheck.java#L66-L69 |
24,604 | google/closure-compiler | src/com/google/javascript/jscomp/ValidityCheck.java | ValidityCheck.checkNormalization | private void checkNormalization(Node externs, Node root) {
// Verify nothing has inappropriately denormalize the AST.
CodeChangeHandler handler = new ForbiddenChange();
compiler.addChangeHandler(handler);
// TODO(johnlenz): Change these normalization checks Preconditions and
// Exceptions into Erro... | java | private void checkNormalization(Node externs, Node root) {
// Verify nothing has inappropriately denormalize the AST.
CodeChangeHandler handler = new ForbiddenChange();
compiler.addChangeHandler(handler);
// TODO(johnlenz): Change these normalization checks Preconditions and
// Exceptions into Erro... | [
"private",
"void",
"checkNormalization",
"(",
"Node",
"externs",
",",
"Node",
"root",
")",
"{",
"// Verify nothing has inappropriately denormalize the AST.",
"CodeChangeHandler",
"handler",
"=",
"new",
"ForbiddenChange",
"(",
")",
";",
"compiler",
".",
"addChangeHandler",... | Verifies that the normalization pass does nothing on an already-normalized tree. | [
"Verifies",
"that",
"the",
"normalization",
"pass",
"does",
"nothing",
"on",
"an",
"already",
"-",
"normalized",
"tree",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ValidityCheck.java#L80-L100 |
24,605 | google/closure-compiler | src/com/google/javascript/jscomp/CrossChunkMethodMotion.java | CrossChunkMethodMotion.moveMethods | private void moveMethods(Collection<NameInfo> allNameInfo) {
boolean hasStubDeclaration = idGenerator.hasGeneratedAnyIds();
for (NameInfo nameInfo : allNameInfo) {
if (!nameInfo.isReferenced()) {
// The code below can't do anything with unreferenced name
// infos. They should be skipped t... | java | private void moveMethods(Collection<NameInfo> allNameInfo) {
boolean hasStubDeclaration = idGenerator.hasGeneratedAnyIds();
for (NameInfo nameInfo : allNameInfo) {
if (!nameInfo.isReferenced()) {
// The code below can't do anything with unreferenced name
// infos. They should be skipped t... | [
"private",
"void",
"moveMethods",
"(",
"Collection",
"<",
"NameInfo",
">",
"allNameInfo",
")",
"{",
"boolean",
"hasStubDeclaration",
"=",
"idGenerator",
".",
"hasGeneratedAnyIds",
"(",
")",
";",
"for",
"(",
"NameInfo",
"nameInfo",
":",
"allNameInfo",
")",
"{",
... | Move methods deeper in the chunk graph when possible. | [
"Move",
"methods",
"deeper",
"in",
"the",
"chunk",
"graph",
"when",
"possible",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CrossChunkMethodMotion.java#L107-L148 |
24,606 | google/closure-compiler | src/com/google/javascript/jscomp/CrossChunkMethodMotion.java | CrossChunkMethodMotion.tryToMoveMemberFunction | private void tryToMoveMemberFunction(
NameInfo nameInfo, JSModule deepestCommonModuleRef, ClassMemberFunction classMemberFunction) {
// We should only move a property across chunks if:
// 1) We can move it deeper in the chunk graph,
// 2) and it's a normal member function, and not a GETTER_DEF or a S... | java | private void tryToMoveMemberFunction(
NameInfo nameInfo, JSModule deepestCommonModuleRef, ClassMemberFunction classMemberFunction) {
// We should only move a property across chunks if:
// 1) We can move it deeper in the chunk graph,
// 2) and it's a normal member function, and not a GETTER_DEF or a S... | [
"private",
"void",
"tryToMoveMemberFunction",
"(",
"NameInfo",
"nameInfo",
",",
"JSModule",
"deepestCommonModuleRef",
",",
"ClassMemberFunction",
"classMemberFunction",
")",
"{",
"// We should only move a property across chunks if:",
"// 1) We can move it deeper in the chunk graph,",
... | If possible, move a class instance member function definition to the deepest chunk common to
all uses of the method.
@param nameInfo information about all definitions of the given property name
@param deepestCommonModuleRef all uses of the method are either in this chunk or in chunks that
depend on it
@param classMemb... | [
"If",
"possible",
"move",
"a",
"class",
"instance",
"member",
"function",
"definition",
"to",
"the",
"deepest",
"chunk",
"common",
"to",
"all",
"uses",
"of",
"the",
"method",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CrossChunkMethodMotion.java#L419-L453 |
24,607 | google/closure-compiler | src/com/google/javascript/jscomp/AccessControlUtils.java | AccessControlUtils.getOverriddenPropertyVisibility | static Visibility getOverriddenPropertyVisibility(ObjectType objectType, String propertyName) {
return objectType != null
? objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility()
: Visibility.INHERITED;
} | java | static Visibility getOverriddenPropertyVisibility(ObjectType objectType, String propertyName) {
return objectType != null
? objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility()
: Visibility.INHERITED;
} | [
"static",
"Visibility",
"getOverriddenPropertyVisibility",
"(",
"ObjectType",
"objectType",
",",
"String",
"propertyName",
")",
"{",
"return",
"objectType",
"!=",
"null",
"?",
"objectType",
".",
"getOwnPropertyJSDocInfo",
"(",
"propertyName",
")",
".",
"getVisibility",
... | Returns the original visibility of an overridden property. | [
"Returns",
"the",
"original",
"visibility",
"of",
"an",
"overridden",
"property",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AccessControlUtils.java#L157-L161 |
24,608 | google/closure-compiler | src/com/google/javascript/rhino/jstype/EnumType.java | EnumType.defineElement | public boolean defineElement(String name, Node definingNode) {
elements.add(name);
return defineDeclaredProperty(name, elementsType, definingNode);
} | java | public boolean defineElement(String name, Node definingNode) {
elements.add(name);
return defineDeclaredProperty(name, elementsType, definingNode);
} | [
"public",
"boolean",
"defineElement",
"(",
"String",
"name",
",",
"Node",
"definingNode",
")",
"{",
"elements",
".",
"add",
"(",
"name",
")",
";",
"return",
"defineDeclaredProperty",
"(",
"name",
",",
"elementsType",
",",
"definingNode",
")",
";",
"}"
] | Defines a new element on this enum.
@param name the name of the new element
@param definingNode the {@code Node} that defines this new element
@return true iff the new element is added successfully | [
"Defines",
"a",
"new",
"element",
"on",
"this",
"enum",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/EnumType.java#L100-L103 |
24,609 | google/closure-compiler | src/com/google/javascript/jscomp/deps/JsFileLineParser.java | JsFileLineParser.parseJsString | String parseJsString(String jsStringLiteral) throws ParseException {
valueMatcher.reset(jsStringLiteral);
if (!valueMatcher.matches()) {
throw new ParseException("Syntax error in JS String literal", true /* fatal */);
}
return valueMatcher.group(1) != null ? valueMatcher.group(1) : valueMatcher.gr... | java | String parseJsString(String jsStringLiteral) throws ParseException {
valueMatcher.reset(jsStringLiteral);
if (!valueMatcher.matches()) {
throw new ParseException("Syntax error in JS String literal", true /* fatal */);
}
return valueMatcher.group(1) != null ? valueMatcher.group(1) : valueMatcher.gr... | [
"String",
"parseJsString",
"(",
"String",
"jsStringLiteral",
")",
"throws",
"ParseException",
"{",
"valueMatcher",
".",
"reset",
"(",
"jsStringLiteral",
")",
";",
"if",
"(",
"!",
"valueMatcher",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"ParseExcepti... | Parses a JS string literal.
@param jsStringLiteral The literal. Must look like "asdf" or 'asdf'
@throws ParseException Thrown if there is a string literal that cannot be parsed. | [
"Parses",
"a",
"JS",
"string",
"literal",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/JsFileLineParser.java#L297-L303 |
24,610 | google/closure-compiler | src/com/google/javascript/rhino/jstype/PropertyMap.java | PropertyMap.getPrimaryParent | PropertyMap getPrimaryParent() {
if (parentSource == null) {
return null;
}
ObjectType iProto = parentSource.getImplicitPrototype();
return iProto == null ? null : iProto.getPropertyMap();
} | java | PropertyMap getPrimaryParent() {
if (parentSource == null) {
return null;
}
ObjectType iProto = parentSource.getImplicitPrototype();
return iProto == null ? null : iProto.getPropertyMap();
} | [
"PropertyMap",
"getPrimaryParent",
"(",
")",
"{",
"if",
"(",
"parentSource",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"ObjectType",
"iProto",
"=",
"parentSource",
".",
"getImplicitPrototype",
"(",
")",
";",
"return",
"iProto",
"==",
"null",
"?",
... | Returns the direct parent of this property map. | [
"Returns",
"the",
"direct",
"parent",
"of",
"this",
"property",
"map",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/PropertyMap.java#L90-L96 |
24,611 | google/closure-compiler | src/com/google/javascript/rhino/jstype/PropertyMap.java | PropertyMap.collectPropertyNamesHelper | private void collectPropertyNamesHelper(
Set<String> props, Set<PropertyMap> cache) {
if (!cache.add(this)) {
return;
}
props.addAll(properties.keySet());
PropertyMap primaryParent = getPrimaryParent();
if (primaryParent != null) {
primaryParent.collectPropertyNamesHelper(props, ca... | java | private void collectPropertyNamesHelper(
Set<String> props, Set<PropertyMap> cache) {
if (!cache.add(this)) {
return;
}
props.addAll(properties.keySet());
PropertyMap primaryParent = getPrimaryParent();
if (primaryParent != null) {
primaryParent.collectPropertyNamesHelper(props, ca... | [
"private",
"void",
"collectPropertyNamesHelper",
"(",
"Set",
"<",
"String",
">",
"props",
",",
"Set",
"<",
"PropertyMap",
">",
"cache",
")",
"{",
"if",
"(",
"!",
"cache",
".",
"add",
"(",
"this",
")",
")",
"{",
"return",
";",
"}",
"props",
".",
"addA... | Use cache to avoid stack overflow. | [
"Use",
"cache",
"to",
"avoid",
"stack",
"overflow",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/PropertyMap.java#L158-L174 |
24,612 | google/closure-compiler | src/com/google/javascript/jscomp/VarCheck.java | VarCheck.createSynthesizedExternVar | static void createSynthesizedExternVar(AbstractCompiler compiler, String varName) {
Node nameNode = IR.name(varName);
// Mark the variable as constant if it matches the coding convention
// for constant vars.
// NOTE(nicksantos): honestly, I'm not sure how much this matters.
// AFAIK, all people wh... | java | static void createSynthesizedExternVar(AbstractCompiler compiler, String varName) {
Node nameNode = IR.name(varName);
// Mark the variable as constant if it matches the coding convention
// for constant vars.
// NOTE(nicksantos): honestly, I'm not sure how much this matters.
// AFAIK, all people wh... | [
"static",
"void",
"createSynthesizedExternVar",
"(",
"AbstractCompiler",
"compiler",
",",
"String",
"varName",
")",
"{",
"Node",
"nameNode",
"=",
"IR",
".",
"name",
"(",
"varName",
")",
";",
"// Mark the variable as constant if it matches the coding convention",
"// for c... | Create a new variable in a synthetic script. This will prevent
subsequent compiler passes from crashing. | [
"Create",
"a",
"new",
"variable",
"in",
"a",
"synthetic",
"script",
".",
"This",
"will",
"prevent",
"subsequent",
"compiler",
"passes",
"from",
"crashing",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/VarCheck.java#L328-L344 |
24,613 | google/closure-compiler | src/com/google/javascript/jscomp/VarCheck.java | VarCheck.hasDuplicateDeclarationSuppression | static boolean hasDuplicateDeclarationSuppression(
AbstractCompiler compiler, Node n, Node origVar) {
// For VarCheck and VariableReferenceCheck, variables in externs do not generate duplicate
// warnings.
if (isExternNamespace(n)) {
return true;
}
return TypeValidator.hasDuplicateDeclar... | java | static boolean hasDuplicateDeclarationSuppression(
AbstractCompiler compiler, Node n, Node origVar) {
// For VarCheck and VariableReferenceCheck, variables in externs do not generate duplicate
// warnings.
if (isExternNamespace(n)) {
return true;
}
return TypeValidator.hasDuplicateDeclar... | [
"static",
"boolean",
"hasDuplicateDeclarationSuppression",
"(",
"AbstractCompiler",
"compiler",
",",
"Node",
"n",
",",
"Node",
"origVar",
")",
"{",
"// For VarCheck and VariableReferenceCheck, variables in externs do not generate duplicate",
"// warnings.",
"if",
"(",
"isExternNa... | Returns true if duplication warnings are suppressed on either n or origVar. | [
"Returns",
"true",
"if",
"duplication",
"warnings",
"are",
"suppressed",
"on",
"either",
"n",
"or",
"origVar",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/VarCheck.java#L434-L442 |
24,614 | google/closure-compiler | src/com/google/javascript/jscomp/VarCheck.java | VarCheck.isExternNamespace | static boolean isExternNamespace(Node n) {
return n.getParent().isVar() && n.isFromExterns() && NodeUtil.isNamespaceDecl(n);
} | java | static boolean isExternNamespace(Node n) {
return n.getParent().isVar() && n.isFromExterns() && NodeUtil.isNamespaceDecl(n);
} | [
"static",
"boolean",
"isExternNamespace",
"(",
"Node",
"n",
")",
"{",
"return",
"n",
".",
"getParent",
"(",
")",
".",
"isVar",
"(",
")",
"&&",
"n",
".",
"isFromExterns",
"(",
")",
"&&",
"NodeUtil",
".",
"isNamespaceDecl",
"(",
"n",
")",
";",
"}"
] | Returns true if n is the name of a variable that declares a namespace in an externs file. | [
"Returns",
"true",
"if",
"n",
"is",
"the",
"name",
"of",
"a",
"variable",
"that",
"declares",
"a",
"namespace",
"in",
"an",
"externs",
"file",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/VarCheck.java#L445-L447 |
24,615 | google/closure-compiler | src/com/google/javascript/jscomp/lint/CheckJSDocStyle.java | CheckJSDocStyle.isFunctionThatShouldHaveJsDoc | private boolean isFunctionThatShouldHaveJsDoc(NodeTraversal t, Node function) {
if (!(t.inGlobalHoistScope() || t.inModuleScope())) {
// TODO(b/233631820): this should check for the module hoist scope instead
return false;
}
if (NodeUtil.isFunctionDeclaration(function)) {
return true;
... | java | private boolean isFunctionThatShouldHaveJsDoc(NodeTraversal t, Node function) {
if (!(t.inGlobalHoistScope() || t.inModuleScope())) {
// TODO(b/233631820): this should check for the module hoist scope instead
return false;
}
if (NodeUtil.isFunctionDeclaration(function)) {
return true;
... | [
"private",
"boolean",
"isFunctionThatShouldHaveJsDoc",
"(",
"NodeTraversal",
"t",
",",
"Node",
"function",
")",
"{",
"if",
"(",
"!",
"(",
"t",
".",
"inGlobalHoistScope",
"(",
")",
"||",
"t",
".",
"inModuleScope",
"(",
")",
")",
")",
"{",
"// TODO(b/233631820... | Whether the given function should have JSDoc. True if it's a function declared
in the global scope, or a method on a class which is declared in the global scope. | [
"Whether",
"the",
"given",
"function",
"should",
"have",
"JSDoc",
".",
"True",
"if",
"it",
"s",
"a",
"function",
"declared",
"in",
"the",
"global",
"scope",
"or",
"a",
"method",
"on",
"a",
"class",
"which",
"is",
"declared",
"in",
"the",
"global",
"scope... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/lint/CheckJSDocStyle.java#L242-L274 |
24,616 | google/closure-compiler | src/com/google/javascript/jscomp/lint/CheckJSDocStyle.java | CheckJSDocStyle.checkInlineParams | private void checkInlineParams(NodeTraversal t, Node function) {
Node paramList = NodeUtil.getFunctionParameters(function);
for (Node param : paramList.children()) {
JSDocInfo jsDoc = param.getJSDocInfo();
if (jsDoc == null) {
t.report(param, MISSING_PARAMETER_JSDOC);
return;
... | java | private void checkInlineParams(NodeTraversal t, Node function) {
Node paramList = NodeUtil.getFunctionParameters(function);
for (Node param : paramList.children()) {
JSDocInfo jsDoc = param.getJSDocInfo();
if (jsDoc == null) {
t.report(param, MISSING_PARAMETER_JSDOC);
return;
... | [
"private",
"void",
"checkInlineParams",
"(",
"NodeTraversal",
"t",
",",
"Node",
"function",
")",
"{",
"Node",
"paramList",
"=",
"NodeUtil",
".",
"getFunctionParameters",
"(",
"function",
")",
";",
"for",
"(",
"Node",
"param",
":",
"paramList",
".",
"children",... | Checks that the inline type annotations are correct. | [
"Checks",
"that",
"the",
"inline",
"type",
"annotations",
"are",
"correct",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/lint/CheckJSDocStyle.java#L332-L346 |
24,617 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/IRFactory.java | IRFactory.transformNodeWithInlineJsDoc | Node transformNodeWithInlineJsDoc(ParseTree node) {
JSDocInfo info = handleInlineJsDoc(node);
Node irNode = transformDispatcher.process(node);
if (info != null) {
irNode.setJSDocInfo(info);
}
setSourceInfo(irNode, node);
return irNode;
} | java | Node transformNodeWithInlineJsDoc(ParseTree node) {
JSDocInfo info = handleInlineJsDoc(node);
Node irNode = transformDispatcher.process(node);
if (info != null) {
irNode.setJSDocInfo(info);
}
setSourceInfo(irNode, node);
return irNode;
} | [
"Node",
"transformNodeWithInlineJsDoc",
"(",
"ParseTree",
"node",
")",
"{",
"JSDocInfo",
"info",
"=",
"handleInlineJsDoc",
"(",
"node",
")",
";",
"Node",
"irNode",
"=",
"transformDispatcher",
".",
"process",
"(",
"node",
")",
";",
"if",
"(",
"info",
"!=",
"n... | Names and destructuring patterns, in parameters or variable declarations are special,
because they can have inline type docs attached.
<pre>function f(/** string */ x) {}</pre> annotates 'x' as a string.
@see <a href="http://code.google.com/p/jsdoc-toolkit/wiki/InlineDocs">
Using Inline Doc Comments</a> | [
"Names",
"and",
"destructuring",
"patterns",
"in",
"parameters",
"or",
"variable",
"declarations",
"are",
"special",
"because",
"they",
"can",
"have",
"inline",
"type",
"docs",
"attached",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/IRFactory.java#L752-L760 |
24,618 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/IRFactory.java | IRFactory.createJsDocInfoParser | private JsDocInfoParser createJsDocInfoParser(Comment node) {
String comment = node.value;
int lineno = lineno(node.location.start);
int charno = charno(node.location.start);
int position = node.location.start.offset;
// The JsDocInfoParser expects the comment without the initial '/**'.
int num... | java | private JsDocInfoParser createJsDocInfoParser(Comment node) {
String comment = node.value;
int lineno = lineno(node.location.start);
int charno = charno(node.location.start);
int position = node.location.start.offset;
// The JsDocInfoParser expects the comment without the initial '/**'.
int num... | [
"private",
"JsDocInfoParser",
"createJsDocInfoParser",
"(",
"Comment",
"node",
")",
"{",
"String",
"comment",
"=",
"node",
".",
"value",
";",
"int",
"lineno",
"=",
"lineno",
"(",
"node",
".",
"location",
".",
"start",
")",
";",
"int",
"charno",
"=",
"charn... | Creates a JsDocInfoParser and parses the JsDoc string.
Used both for handling individual JSDoc comments and for handling
file-level JSDoc comments (@fileoverview and @license).
@param node The JsDoc Comment node to parse.
@return A JsDocInfoParser. Will contain either fileoverview JsDoc, or
normal JsDoc, or no JsDoc ... | [
"Creates",
"a",
"JsDocInfoParser",
"and",
"parses",
"the",
"JsDoc",
"string",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/IRFactory.java#L901-L928 |
24,619 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/IRFactory.java | IRFactory.parseInlineTypeDoc | private JSDocInfo parseInlineTypeDoc(Comment node) {
String comment = node.value;
int lineno = lineno(node.location.start);
int charno = charno(node.location.start);
// The JsDocInfoParser expects the comment without the initial '/**'.
int numOpeningChars = 3;
JsDocInfoParser parser =
new... | java | private JSDocInfo parseInlineTypeDoc(Comment node) {
String comment = node.value;
int lineno = lineno(node.location.start);
int charno = charno(node.location.start);
// The JsDocInfoParser expects the comment without the initial '/**'.
int numOpeningChars = 3;
JsDocInfoParser parser =
new... | [
"private",
"JSDocInfo",
"parseInlineTypeDoc",
"(",
"Comment",
"node",
")",
"{",
"String",
"comment",
"=",
"node",
".",
"value",
";",
"int",
"lineno",
"=",
"lineno",
"(",
"node",
".",
"location",
".",
"start",
")",
";",
"int",
"charno",
"=",
"charno",
"("... | Parses inline type info. | [
"Parses",
"inline",
"type",
"info",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/IRFactory.java#L933-L951 |
24,620 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/IRFactory.java | IRFactory.setLength | void setLength(
Node node, SourcePosition start, SourcePosition end) {
node.setLength(end.offset - start.offset);
} | java | void setLength(
Node node, SourcePosition start, SourcePosition end) {
node.setLength(end.offset - start.offset);
} | [
"void",
"setLength",
"(",
"Node",
"node",
",",
"SourcePosition",
"start",
",",
"SourcePosition",
"end",
")",
"{",
"node",
".",
"setLength",
"(",
"end",
".",
"offset",
"-",
"start",
".",
"offset",
")",
";",
"}"
] | Set the length on the node if we're in IDE mode. | [
"Set",
"the",
"length",
"on",
"the",
"node",
"if",
"we",
"re",
"in",
"IDE",
"mode",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/IRFactory.java#L954-L957 |
24,621 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/IRFactory.java | IRFactory.cloneProps | Node cloneProps(Node n) {
if (!n.hasProps()) {
n.clonePropsFrom(templateNode);
}
for (Node child : n.children()) {
cloneProps(child);
}
return n;
} | java | Node cloneProps(Node n) {
if (!n.hasProps()) {
n.clonePropsFrom(templateNode);
}
for (Node child : n.children()) {
cloneProps(child);
}
return n;
} | [
"Node",
"cloneProps",
"(",
"Node",
"n",
")",
"{",
"if",
"(",
"!",
"n",
".",
"hasProps",
"(",
")",
")",
"{",
"n",
".",
"clonePropsFrom",
"(",
"templateNode",
")",
";",
"}",
"for",
"(",
"Node",
"child",
":",
"n",
".",
"children",
"(",
")",
")",
"... | Clone the properties from the template node recursively, skips nodes that
have properties already. | [
"Clone",
"the",
"properties",
"from",
"the",
"template",
"node",
"recursively",
"skips",
"nodes",
"that",
"have",
"properties",
"already",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/IRFactory.java#L3673-L3681 |
24,622 | google/closure-compiler | src/com/google/javascript/jscomp/gwt/client/GwtRunner.java | GwtRunner.getDefaultFlags | private static Flags getDefaultFlags() {
if (defaultFlags != null) {
return defaultFlags;
}
defaultFlags = new Flags();
defaultFlags.angularPass = false;
defaultFlags.applyInputSourceMaps = true;
defaultFlags.assumeFunctionWrapper = false;
defaultFlags.checksOnly = false;
defaultFl... | java | private static Flags getDefaultFlags() {
if (defaultFlags != null) {
return defaultFlags;
}
defaultFlags = new Flags();
defaultFlags.angularPass = false;
defaultFlags.applyInputSourceMaps = true;
defaultFlags.assumeFunctionWrapper = false;
defaultFlags.checksOnly = false;
defaultFl... | [
"private",
"static",
"Flags",
"getDefaultFlags",
"(",
")",
"{",
"if",
"(",
"defaultFlags",
"!=",
"null",
")",
"{",
"return",
"defaultFlags",
";",
"}",
"defaultFlags",
"=",
"new",
"Flags",
"(",
")",
";",
"defaultFlags",
".",
"angularPass",
"=",
"false",
";"... | Lazy initialize due to GWT. If things are exported then Object is not available when the static
initialization runs. | [
"Lazy",
"initialize",
"due",
"to",
"GWT",
".",
"If",
"things",
"are",
"exported",
"then",
"Object",
"is",
"not",
"available",
"when",
"the",
"static",
"initialization",
"runs",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/gwt/client/GwtRunner.java#L161-L221 |
24,623 | google/closure-compiler | src/com/google/javascript/jscomp/PassFactory.java | PassFactory.createEmptyPass | public static PassFactory createEmptyPass(String name) {
return new PassFactory(name, true) {
@Override
protected CompilerPass create(final AbstractCompiler compiler) {
return new CompilerPass() {
@Override
public void process(Node externs, Node root) {}
};
}
... | java | public static PassFactory createEmptyPass(String name) {
return new PassFactory(name, true) {
@Override
protected CompilerPass create(final AbstractCompiler compiler) {
return new CompilerPass() {
@Override
public void process(Node externs, Node root) {}
};
}
... | [
"public",
"static",
"PassFactory",
"createEmptyPass",
"(",
"String",
"name",
")",
"{",
"return",
"new",
"PassFactory",
"(",
"name",
",",
"true",
")",
"{",
"@",
"Override",
"protected",
"CompilerPass",
"create",
"(",
"final",
"AbstractCompiler",
"compiler",
")",
... | Create a no-op pass that can only run once. Used to break up loops. | [
"Create",
"a",
"no",
"-",
"op",
"pass",
"that",
"can",
"only",
"run",
"once",
".",
"Used",
"to",
"break",
"up",
"loops",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PassFactory.java#L93-L108 |
24,624 | google/closure-compiler | src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java | CheckMissingAndExtraRequires.isClassOrConstantName | private static boolean isClassOrConstantName(String name) {
return name != null && name.length() > 1 && Character.isUpperCase(name.charAt(0));
} | java | private static boolean isClassOrConstantName(String name) {
return name != null && name.length() > 1 && Character.isUpperCase(name.charAt(0));
} | [
"private",
"static",
"boolean",
"isClassOrConstantName",
"(",
"String",
"name",
")",
"{",
"return",
"name",
"!=",
"null",
"&&",
"name",
".",
"length",
"(",
")",
">",
"1",
"&&",
"Character",
".",
"isUpperCase",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
... | Return true if the name looks like a class name or a constant name. | [
"Return",
"true",
"if",
"the",
"name",
"looks",
"like",
"a",
"class",
"name",
"or",
"a",
"constant",
"name",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java#L138-L140 |
24,625 | google/closure-compiler | src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java | CheckMissingAndExtraRequires.getClassNames | private static ImmutableList<String> getClassNames(String qualifiedName) {
ImmutableList.Builder<String> classNames = ImmutableList.builder();
List<String> parts = DOT_SPLITTER.splitToList(qualifiedName);
for (int i = 0; i < parts.size(); i++) {
String part = parts.get(i);
if (isClassOrConstantN... | java | private static ImmutableList<String> getClassNames(String qualifiedName) {
ImmutableList.Builder<String> classNames = ImmutableList.builder();
List<String> parts = DOT_SPLITTER.splitToList(qualifiedName);
for (int i = 0; i < parts.size(); i++) {
String part = parts.get(i);
if (isClassOrConstantN... | [
"private",
"static",
"ImmutableList",
"<",
"String",
">",
"getClassNames",
"(",
"String",
"qualifiedName",
")",
"{",
"ImmutableList",
".",
"Builder",
"<",
"String",
">",
"classNames",
"=",
"ImmutableList",
".",
"builder",
"(",
")",
";",
"List",
"<",
"String",
... | or null if no part refers to a class. | [
"or",
"null",
"if",
"no",
"part",
"refers",
"to",
"a",
"class",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java#L144-L154 |
24,626 | google/closure-compiler | src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java | CheckMissingAndExtraRequires.maybeAddGoogScopeUsage | private void maybeAddGoogScopeUsage(NodeTraversal t, Node n, Node parent) {
checkState(NodeUtil.isNameDeclaration(n));
if (n.hasOneChild() && parent == googScopeBlock) {
Node rhs = n.getFirstFirstChild();
if (rhs != null && rhs.isQualifiedName()) {
Node root = NodeUtil.getRootOfQualifiedName... | java | private void maybeAddGoogScopeUsage(NodeTraversal t, Node n, Node parent) {
checkState(NodeUtil.isNameDeclaration(n));
if (n.hasOneChild() && parent == googScopeBlock) {
Node rhs = n.getFirstFirstChild();
if (rhs != null && rhs.isQualifiedName()) {
Node root = NodeUtil.getRootOfQualifiedName... | [
"private",
"void",
"maybeAddGoogScopeUsage",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
",",
"Node",
"parent",
")",
"{",
"checkState",
"(",
"NodeUtil",
".",
"isNameDeclaration",
"(",
"n",
")",
")",
";",
"if",
"(",
"n",
".",
"hasOneChild",
"(",
")",
"&&... | "var Dog = some.cute.Dog;" counts as a usage of some.cute.Dog, if it's immediately inside a
goog.scope function. | [
"var",
"Dog",
"=",
"some",
".",
"cute",
".",
"Dog",
";",
"counts",
"as",
"a",
"usage",
"of",
"some",
".",
"cute",
".",
"Dog",
"if",
"it",
"s",
"immediately",
"inside",
"a",
"goog",
".",
"scope",
"function",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java#L633-L647 |
24,627 | google/closure-compiler | src/com/google/javascript/jscomp/TranspilationPasses.java | TranspilationPasses.addPostCheckTranspilationPasses | public static void addPostCheckTranspilationPasses(
List<PassFactory> passes, CompilerOptions options) {
if (options.needsTranspilationFrom(FeatureSet.ES_NEXT)) {
passes.add(rewriteCatchWithNoBinding);
}
if (options.needsTranspilationFrom(ES2018)) {
passes.add(rewriteAsyncIteration);
... | java | public static void addPostCheckTranspilationPasses(
List<PassFactory> passes, CompilerOptions options) {
if (options.needsTranspilationFrom(FeatureSet.ES_NEXT)) {
passes.add(rewriteCatchWithNoBinding);
}
if (options.needsTranspilationFrom(ES2018)) {
passes.add(rewriteAsyncIteration);
... | [
"public",
"static",
"void",
"addPostCheckTranspilationPasses",
"(",
"List",
"<",
"PassFactory",
">",
"passes",
",",
"CompilerOptions",
"options",
")",
"{",
"if",
"(",
"options",
".",
"needsTranspilationFrom",
"(",
"FeatureSet",
".",
"ES_NEXT",
")",
")",
"{",
"pa... | Adds transpilation passes that should run after all checks are done. | [
"Adds",
"transpilation",
"passes",
"that",
"should",
"run",
"after",
"all",
"checks",
"are",
"done",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TranspilationPasses.java#L79-L140 |
24,628 | google/closure-compiler | src/com/google/javascript/jscomp/TranspilationPasses.java | TranspilationPasses.processTranspile | static void processTranspile(
AbstractCompiler compiler, Node combinedRoot, FeatureSet featureSet, Callback... callbacks) {
if (compiler.getOptions().needsTranspilationFrom(featureSet)) {
FeatureSet languageOutFeatures = compiler.getOptions().getOutputFeatureSet();
for (Node singleRoot : combinedR... | java | static void processTranspile(
AbstractCompiler compiler, Node combinedRoot, FeatureSet featureSet, Callback... callbacks) {
if (compiler.getOptions().needsTranspilationFrom(featureSet)) {
FeatureSet languageOutFeatures = compiler.getOptions().getOutputFeatureSet();
for (Node singleRoot : combinedR... | [
"static",
"void",
"processTranspile",
"(",
"AbstractCompiler",
"compiler",
",",
"Node",
"combinedRoot",
",",
"FeatureSet",
"featureSet",
",",
"Callback",
"...",
"callbacks",
")",
"{",
"if",
"(",
"compiler",
".",
"getOptions",
"(",
")",
".",
"needsTranspilationFrom... | Process transpilations if the input language needs transpilation from certain features, on any
JS file that has features not present in the compiler's output language mode.
@param compiler An AbstractCompiler
@param combinedRoot The combined root for all JS files.
@param featureSet The features which this pass helps t... | [
"Process",
"transpilations",
"if",
"the",
"input",
"language",
"needs",
"transpilation",
"from",
"certain",
"features",
"on",
"any",
"JS",
"file",
"that",
"has",
"features",
"not",
"present",
"in",
"the",
"compiler",
"s",
"output",
"language",
"mode",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TranspilationPasses.java#L526-L547 |
24,629 | google/closure-compiler | src/com/google/javascript/jscomp/TranspilationPasses.java | TranspilationPasses.hotSwapTranspile | static void hotSwapTranspile(
AbstractCompiler compiler, Node scriptRoot, FeatureSet featureSet, Callback... callbacks) {
if (compiler.getOptions().needsTranspilationFrom(featureSet)) {
FeatureSet languageOutFeatures = compiler.getOptions().getOutputFeatureSet();
if (doesScriptHaveUnsupportedFeatu... | java | static void hotSwapTranspile(
AbstractCompiler compiler, Node scriptRoot, FeatureSet featureSet, Callback... callbacks) {
if (compiler.getOptions().needsTranspilationFrom(featureSet)) {
FeatureSet languageOutFeatures = compiler.getOptions().getOutputFeatureSet();
if (doesScriptHaveUnsupportedFeatu... | [
"static",
"void",
"hotSwapTranspile",
"(",
"AbstractCompiler",
"compiler",
",",
"Node",
"scriptRoot",
",",
"FeatureSet",
"featureSet",
",",
"Callback",
"...",
"callbacks",
")",
"{",
"if",
"(",
"compiler",
".",
"getOptions",
"(",
")",
".",
"needsTranspilationFrom",... | Hot-swap ES6+ transpilations if the input language needs transpilation from certain features,
on any JS file that has features not present in the compiler's output language mode.
@param compiler An AbstractCompiler
@param scriptRoot The SCRIPT root for the JS file.
@param featureSet The features which this pass helps ... | [
"Hot",
"-",
"swap",
"ES6",
"+",
"transpilations",
"if",
"the",
"input",
"language",
"needs",
"transpilation",
"from",
"certain",
"features",
"on",
"any",
"JS",
"file",
"that",
"has",
"features",
"not",
"present",
"in",
"the",
"compiler",
"s",
"output",
"lang... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TranspilationPasses.java#L558-L569 |
24,630 | google/closure-compiler | src/com/google/javascript/jscomp/TranspilationPasses.java | TranspilationPasses.createFeatureRemovalPass | private static HotSwapPassFactory createFeatureRemovalPass(
String passName, final Feature featureToRemove, final Feature... moreFeaturesToRemove) {
return new HotSwapPassFactory(passName) {
@Override
protected HotSwapCompilerPass create(final AbstractCompiler compiler) {
return new HotSwa... | java | private static HotSwapPassFactory createFeatureRemovalPass(
String passName, final Feature featureToRemove, final Feature... moreFeaturesToRemove) {
return new HotSwapPassFactory(passName) {
@Override
protected HotSwapCompilerPass create(final AbstractCompiler compiler) {
return new HotSwa... | [
"private",
"static",
"HotSwapPassFactory",
"createFeatureRemovalPass",
"(",
"String",
"passName",
",",
"final",
"Feature",
"featureToRemove",
",",
"final",
"Feature",
"...",
"moreFeaturesToRemove",
")",
"{",
"return",
"new",
"HotSwapPassFactory",
"(",
"passName",
")",
... | Returns a pass that just removes features from the AST FeatureSet.
<p>Doing this indicates that the AST no longer contains uses of the features, or that they are
no longer of concern for some other reason. | [
"Returns",
"a",
"pass",
"that",
"just",
"removes",
"features",
"from",
"the",
"AST",
"FeatureSet",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TranspilationPasses.java#L594-L617 |
24,631 | google/closure-compiler | src/com/google/javascript/jscomp/GlobalNamespace.java | GlobalNamespace.scanNewNodes | void scanNewNodes(Set<AstChange> newNodes) {
BuildGlobalNamespace builder = new BuildGlobalNamespace();
for (AstChange info : newNodes) {
if (!info.node.isQualifiedName() && !NodeUtil.mayBeObjectLitKey(info.node)) {
continue;
}
scanFromNode(builder, info.module, info.scope, info.node)... | java | void scanNewNodes(Set<AstChange> newNodes) {
BuildGlobalNamespace builder = new BuildGlobalNamespace();
for (AstChange info : newNodes) {
if (!info.node.isQualifiedName() && !NodeUtil.mayBeObjectLitKey(info.node)) {
continue;
}
scanFromNode(builder, info.module, info.scope, info.node)... | [
"void",
"scanNewNodes",
"(",
"Set",
"<",
"AstChange",
">",
"newNodes",
")",
"{",
"BuildGlobalNamespace",
"builder",
"=",
"new",
"BuildGlobalNamespace",
"(",
")",
";",
"for",
"(",
"AstChange",
"info",
":",
"newNodes",
")",
"{",
"if",
"(",
"!",
"info",
".",
... | If the client adds new nodes to the AST, scan these new nodes to see if they've added any
references to the global namespace.
@param newNodes New nodes to check. | [
"If",
"the",
"client",
"adds",
"new",
"nodes",
"to",
"the",
"AST",
"scan",
"these",
"new",
"nodes",
"to",
"see",
"if",
"they",
"ve",
"added",
"any",
"references",
"to",
"the",
"global",
"namespace",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GlobalNamespace.java#L228-L237 |
24,632 | google/closure-compiler | src/com/google/javascript/jscomp/GlobalNamespace.java | GlobalNamespace.process | private void process() {
if (hasExternsRoot()) {
sourceKind = SourceKind.EXTERN;
NodeTraversal.traverse(compiler, externsRoot, new BuildGlobalNamespace());
}
sourceKind = SourceKind.CODE;
NodeTraversal.traverse(compiler, root, new BuildGlobalNamespace());
generated = true;
externsSc... | java | private void process() {
if (hasExternsRoot()) {
sourceKind = SourceKind.EXTERN;
NodeTraversal.traverse(compiler, externsRoot, new BuildGlobalNamespace());
}
sourceKind = SourceKind.CODE;
NodeTraversal.traverse(compiler, root, new BuildGlobalNamespace());
generated = true;
externsSc... | [
"private",
"void",
"process",
"(",
")",
"{",
"if",
"(",
"hasExternsRoot",
"(",
")",
")",
"{",
"sourceKind",
"=",
"SourceKind",
".",
"EXTERN",
";",
"NodeTraversal",
".",
"traverse",
"(",
"compiler",
",",
"externsRoot",
",",
"new",
"BuildGlobalNamespace",
"(",... | Builds the namespace lazily. | [
"Builds",
"the",
"namespace",
"lazily",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GlobalNamespace.java#L261-L271 |
24,633 | google/closure-compiler | src/com/google/javascript/jscomp/GlobalNamespace.java | GlobalNamespace.isGlobalNameReference | private boolean isGlobalNameReference(String name, Scope s) {
String topVarName = getTopVarName(name);
return isGlobalVarReference(topVarName, s);
} | java | private boolean isGlobalNameReference(String name, Scope s) {
String topVarName = getTopVarName(name);
return isGlobalVarReference(topVarName, s);
} | [
"private",
"boolean",
"isGlobalNameReference",
"(",
"String",
"name",
",",
"Scope",
"s",
")",
"{",
"String",
"topVarName",
"=",
"getTopVarName",
"(",
"name",
")",
";",
"return",
"isGlobalVarReference",
"(",
"topVarName",
",",
"s",
")",
";",
"}"
] | Determines whether a name reference in a particular scope is a global name reference.
@param name A variable or property name (e.g. "a" or "a.b.c.d")
@param s The scope in which the name is referenced
@return Whether the name reference is a global name reference | [
"Determines",
"whether",
"a",
"name",
"reference",
"in",
"a",
"particular",
"scope",
"is",
"a",
"global",
"name",
"reference",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GlobalNamespace.java#L280-L283 |
24,634 | google/closure-compiler | src/com/google/javascript/jscomp/GlobalNamespace.java | GlobalNamespace.getTopVarName | private static String getTopVarName(String name) {
int firstDotIndex = name.indexOf('.');
return firstDotIndex == -1 ? name : name.substring(0, firstDotIndex);
} | java | private static String getTopVarName(String name) {
int firstDotIndex = name.indexOf('.');
return firstDotIndex == -1 ? name : name.substring(0, firstDotIndex);
} | [
"private",
"static",
"String",
"getTopVarName",
"(",
"String",
"name",
")",
"{",
"int",
"firstDotIndex",
"=",
"name",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"return",
"firstDotIndex",
"==",
"-",
"1",
"?",
"name",
":",
"name",
".",
"substring",
"(",
"... | Gets the top variable name from a possibly namespaced name.
@param name A variable or qualified property name (e.g. "a" or "a.b.c.d")
@return The top variable name (e.g. "a") | [
"Gets",
"the",
"top",
"variable",
"name",
"from",
"a",
"possibly",
"namespaced",
"name",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GlobalNamespace.java#L291-L294 |
24,635 | google/closure-compiler | src/com/google/javascript/jscomp/GlobalNamespace.java | GlobalNamespace.isGlobalVarReference | private boolean isGlobalVarReference(String name, Scope s) {
Var v = s.getVar(name);
if (v == null && externsScope != null) {
v = externsScope.getVar(name);
}
return v != null && !v.isLocal();
} | java | private boolean isGlobalVarReference(String name, Scope s) {
Var v = s.getVar(name);
if (v == null && externsScope != null) {
v = externsScope.getVar(name);
}
return v != null && !v.isLocal();
} | [
"private",
"boolean",
"isGlobalVarReference",
"(",
"String",
"name",
",",
"Scope",
"s",
")",
"{",
"Var",
"v",
"=",
"s",
".",
"getVar",
"(",
"name",
")",
";",
"if",
"(",
"v",
"==",
"null",
"&&",
"externsScope",
"!=",
"null",
")",
"{",
"v",
"=",
"ext... | Determines whether a variable name reference in a particular scope is a global variable
reference.
@param name A variable name (e.g. "a")
@param s The scope in which the name is referenced
@return Whether the name reference is a global variable reference | [
"Determines",
"whether",
"a",
"variable",
"name",
"reference",
"in",
"a",
"particular",
"scope",
"is",
"a",
"global",
"variable",
"reference",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GlobalNamespace.java#L304-L310 |
24,636 | google/closure-compiler | src/com/google/javascript/jscomp/CodePrinter.java | CodePrinter.toSource | private static String toSource(
Node root,
Format outputFormat,
CompilerOptions options,
SourceMap sourceMap,
boolean tagAsTypeSummary,
boolean tagAsStrict,
boolean lineBreak,
CodeGeneratorFactory codeGeneratorFactory) {
checkState(options.sourceMapDetailLevel != null... | java | private static String toSource(
Node root,
Format outputFormat,
CompilerOptions options,
SourceMap sourceMap,
boolean tagAsTypeSummary,
boolean tagAsStrict,
boolean lineBreak,
CodeGeneratorFactory codeGeneratorFactory) {
checkState(options.sourceMapDetailLevel != null... | [
"private",
"static",
"String",
"toSource",
"(",
"Node",
"root",
",",
"Format",
"outputFormat",
",",
"CompilerOptions",
"options",
",",
"SourceMap",
"sourceMap",
",",
"boolean",
"tagAsTypeSummary",
",",
"boolean",
"tagAsStrict",
",",
"boolean",
"lineBreak",
",",
"C... | Converts a tree to JS code | [
"Converts",
"a",
"tree",
"to",
"JS",
"code"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CodePrinter.java#L845-L888 |
24,637 | google/closure-compiler | src/com/google/javascript/jscomp/AstValidator.java | AstValidator.validateClassDeclaration | private void validateClassDeclaration(Node n, boolean isAmbient) {
validateClassHelper(n, isAmbient);
validateName(n.getFirstChild());
} | java | private void validateClassDeclaration(Node n, boolean isAmbient) {
validateClassHelper(n, isAmbient);
validateName(n.getFirstChild());
} | [
"private",
"void",
"validateClassDeclaration",
"(",
"Node",
"n",
",",
"boolean",
"isAmbient",
")",
"{",
"validateClassHelper",
"(",
"n",
",",
"isAmbient",
")",
";",
"validateName",
"(",
"n",
".",
"getFirstChild",
"(",
")",
")",
";",
"}"
] | In a class declaration, unlike a class expression,
the class name is required. | [
"In",
"a",
"class",
"declaration",
"unlike",
"a",
"class",
"expression",
"the",
"class",
"name",
"is",
"required",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstValidator.java#L723-L726 |
24,638 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.removeChild | public final void removeChild(Node child) {
checkState(child.parent == this, "%s is not the parent of %s", this, child);
checkNotNull(child.previous);
Node last = first.previous;
Node prevSibling = child.previous;
Node nextSibling = child.next;
if (first == child) {
first = nextSibling;
... | java | public final void removeChild(Node child) {
checkState(child.parent == this, "%s is not the parent of %s", this, child);
checkNotNull(child.previous);
Node last = first.previous;
Node prevSibling = child.previous;
Node nextSibling = child.next;
if (first == child) {
first = nextSibling;
... | [
"public",
"final",
"void",
"removeChild",
"(",
"Node",
"child",
")",
"{",
"checkState",
"(",
"child",
".",
"parent",
"==",
"this",
",",
"\"%s is not the parent of %s\"",
",",
"this",
",",
"child",
")",
";",
"checkNotNull",
"(",
"child",
".",
"previous",
")",... | Detach a child from its parent and siblings. | [
"Detach",
"a",
"child",
"from",
"its",
"parent",
"and",
"siblings",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L952-L976 |
24,639 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.replaceChild | public final void replaceChild(Node child, Node newChild) {
checkArgument(newChild.next == null, "The new child node has next siblings.");
checkArgument(newChild.previous == null, "The new child node has previous siblings.");
checkArgument(newChild.parent == null, "The new child node already has a parent.")... | java | public final void replaceChild(Node child, Node newChild) {
checkArgument(newChild.next == null, "The new child node has next siblings.");
checkArgument(newChild.previous == null, "The new child node has previous siblings.");
checkArgument(newChild.parent == null, "The new child node already has a parent.")... | [
"public",
"final",
"void",
"replaceChild",
"(",
"Node",
"child",
",",
"Node",
"newChild",
")",
"{",
"checkArgument",
"(",
"newChild",
".",
"next",
"==",
"null",
",",
"\"The new child node has next siblings.\"",
")",
";",
"checkArgument",
"(",
"newChild",
".",
"p... | Detaches child from Node and replaces it with newChild. | [
"Detaches",
"child",
"from",
"Node",
"and",
"replaces",
"it",
"with",
"newChild",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L986-L1025 |
24,640 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.clonePropsFrom | public final Node clonePropsFrom(Node other) {
checkState(this.propListHead == null, "Node has existing properties.");
this.propListHead = other.propListHead;
return this;
} | java | public final Node clonePropsFrom(Node other) {
checkState(this.propListHead == null, "Node has existing properties.");
this.propListHead = other.propListHead;
return this;
} | [
"public",
"final",
"Node",
"clonePropsFrom",
"(",
"Node",
"other",
")",
"{",
"checkState",
"(",
"this",
".",
"propListHead",
"==",
"null",
",",
"\"Node has existing properties.\"",
")",
";",
"this",
".",
"propListHead",
"=",
"other",
".",
"propListHead",
";",
... | Clone the properties from the provided node without copying
the property object. The receiving node may not have any
existing properties.
@param other The node to clone properties from.
@return this node. | [
"Clone",
"the",
"properties",
"from",
"the",
"provided",
"node",
"without",
"copying",
"the",
"property",
"object",
".",
"The",
"receiving",
"node",
"may",
"not",
"have",
"any",
"existing",
"properties",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1057-L1061 |
24,641 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.getIntProp | public final int getIntProp(Prop propType) {
PropListItem item = lookupProperty(propType);
if (item == null) {
return 0;
}
return item.getIntValue();
} | java | public final int getIntProp(Prop propType) {
PropListItem item = lookupProperty(propType);
if (item == null) {
return 0;
}
return item.getIntValue();
} | [
"public",
"final",
"int",
"getIntProp",
"(",
"Prop",
"propType",
")",
"{",
"PropListItem",
"item",
"=",
"lookupProperty",
"(",
"propType",
")",
";",
"if",
"(",
"item",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"return",
"item",
".",
"getIntValue",... | Returns the integer value for the property, or 0 if the property
is not defined. | [
"Returns",
"the",
"integer",
"value",
"for",
"the",
"property",
"or",
"0",
"if",
"the",
"property",
"is",
"not",
"defined",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1112-L1118 |
24,642 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.getSortedPropTypes | private byte[] getSortedPropTypes() {
int count = 0;
for (PropListItem x = propListHead; x != null; x = x.next) {
count++;
}
byte[] keys = new byte[count];
for (PropListItem x = propListHead; x != null; x = x.next) {
count--;
keys[count] = x.propType;
}
Arrays.sort(keys);... | java | private byte[] getSortedPropTypes() {
int count = 0;
for (PropListItem x = propListHead; x != null; x = x.next) {
count++;
}
byte[] keys = new byte[count];
for (PropListItem x = propListHead; x != null; x = x.next) {
count--;
keys[count] = x.propType;
}
Arrays.sort(keys);... | [
"private",
"byte",
"[",
"]",
"getSortedPropTypes",
"(",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"PropListItem",
"x",
"=",
"propListHead",
";",
"x",
"!=",
"null",
";",
"x",
"=",
"x",
".",
"next",
")",
"{",
"count",
"++",
";",
"}",
"by... | Gets all the property types, in sorted order. | [
"Gets",
"all",
"the",
"property",
"types",
"in",
"sorted",
"order",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1188-L1202 |
24,643 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.setString | public void setString(String value) {
if (this.token == Token.STRING || this.token == Token.NAME) {
throw new IllegalStateException(
"String node not created with Node.newString");
} else {
throw new UnsupportedOperationException(this + " is not a string node");
}
} | java | public void setString(String value) {
if (this.token == Token.STRING || this.token == Token.NAME) {
throw new IllegalStateException(
"String node not created with Node.newString");
} else {
throw new UnsupportedOperationException(this + " is not a string node");
}
} | [
"public",
"void",
"setString",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"this",
".",
"token",
"==",
"Token",
".",
"STRING",
"||",
"this",
".",
"token",
"==",
"Token",
".",
"NAME",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"String node... | Can only be called for a Token.STRING or Token.NAME.
@param value the value to set. | [
"Can",
"only",
"be",
"called",
"for",
"a",
"Token",
".",
"STRING",
"or",
"Token",
".",
"NAME",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1243-L1250 |
24,644 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.setStaticSourceFileFrom | public final void setStaticSourceFileFrom(Node other) {
// Make sure source file prop nodes are not duplicated.
if (other.propListHead != null
&& (this.propListHead == null
|| (this.propListHead.propType == Prop.SOURCE_FILE.ordinal()
&& this.propListHead.next == null))) {
... | java | public final void setStaticSourceFileFrom(Node other) {
// Make sure source file prop nodes are not duplicated.
if (other.propListHead != null
&& (this.propListHead == null
|| (this.propListHead.propType == Prop.SOURCE_FILE.ordinal()
&& this.propListHead.next == null))) {
... | [
"public",
"final",
"void",
"setStaticSourceFileFrom",
"(",
"Node",
"other",
")",
"{",
"// Make sure source file prop nodes are not duplicated.",
"if",
"(",
"other",
".",
"propListHead",
"!=",
"null",
"&&",
"(",
"this",
".",
"propListHead",
"==",
"null",
"||",
"(",
... | Source position management | [
"Source",
"position",
"management"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1431-L1448 |
24,645 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.setLengthForTree | public final void setLengthForTree(int length) {
this.length = length;
for (Node child = first; child != null; child = child.next) {
child.setLengthForTree(length);
}
} | java | public final void setLengthForTree(int length) {
this.length = length;
for (Node child = first; child != null; child = child.next) {
child.setLengthForTree(length);
}
} | [
"public",
"final",
"void",
"setLengthForTree",
"(",
"int",
"length",
")",
"{",
"this",
".",
"length",
"=",
"length",
";",
"for",
"(",
"Node",
"child",
"=",
"first",
";",
"child",
"!=",
"null",
";",
"child",
"=",
"child",
".",
"next",
")",
"{",
"child... | Useful to set length of a transpiled node tree to map back to the length of original node. | [
"Useful",
"to",
"set",
"length",
"of",
"a",
"transpiled",
"node",
"tree",
"to",
"map",
"back",
"to",
"the",
"length",
"of",
"original",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1527-L1533 |
24,646 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.getAncestor | @Nullable
public final Node getAncestor(int level) {
checkArgument(level >= 0);
Node node = this;
while (node != null && level-- > 0) {
node = node.getParent();
}
return node;
} | java | @Nullable
public final Node getAncestor(int level) {
checkArgument(level >= 0);
Node node = this;
while (node != null && level-- > 0) {
node = node.getParent();
}
return node;
} | [
"@",
"Nullable",
"public",
"final",
"Node",
"getAncestor",
"(",
"int",
"level",
")",
"{",
"checkArgument",
"(",
"level",
">=",
"0",
")",
";",
"Node",
"node",
"=",
"this",
";",
"while",
"(",
"node",
"!=",
"null",
"&&",
"level",
"--",
">",
"0",
")",
... | Gets the ancestor node relative to this.
@param level 0 = this, 1 = the parent, etc. | [
"Gets",
"the",
"ancestor",
"node",
"relative",
"to",
"this",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1733-L1741 |
24,647 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.hasXChildren | public final boolean hasXChildren(int x) {
int c = 0;
for (Node n = first; n != null && c <= x; n = n.next) {
c++;
}
return c == x;
} | java | public final boolean hasXChildren(int x) {
int c = 0;
for (Node n = first; n != null && c <= x; n = n.next) {
c++;
}
return c == x;
} | [
"public",
"final",
"boolean",
"hasXChildren",
"(",
"int",
"x",
")",
"{",
"int",
"c",
"=",
"0",
";",
"for",
"(",
"Node",
"n",
"=",
"first",
";",
"n",
"!=",
"null",
"&&",
"c",
"<=",
"x",
";",
"n",
"=",
"n",
".",
"next",
")",
"{",
"c",
"++",
"... | Check for has exactly the number of specified children.
@return Whether the node has exactly the number of children specified. | [
"Check",
"for",
"has",
"exactly",
"the",
"number",
"of",
"specified",
"children",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1857-L1863 |
24,648 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.hasChild | public final boolean hasChild(Node child) {
for (Node n = first; n != null; n = n.next) {
if (child == n) {
return true;
}
}
return false;
} | java | public final boolean hasChild(Node child) {
for (Node n = first; n != null; n = n.next) {
if (child == n) {
return true;
}
}
return false;
} | [
"public",
"final",
"boolean",
"hasChild",
"(",
"Node",
"child",
")",
"{",
"for",
"(",
"Node",
"n",
"=",
"first",
";",
"n",
"!=",
"null",
";",
"n",
"=",
"n",
".",
"next",
")",
"{",
"if",
"(",
"child",
"==",
"n",
")",
"{",
"return",
"true",
";",
... | Intended for testing and verification only. | [
"Intended",
"for",
"testing",
"and",
"verification",
"only",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L1874-L1881 |
24,649 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.getQualifiedName | @Nullable
public final String getQualifiedName() {
switch (token) {
case NAME:
String name = getString();
return name.isEmpty() ? null : name;
case GETPROP:
StringBuilder builder = getQualifiedNameForGetProp(0);
return builder != null ? builder.toString() : null;
... | java | @Nullable
public final String getQualifiedName() {
switch (token) {
case NAME:
String name = getString();
return name.isEmpty() ? null : name;
case GETPROP:
StringBuilder builder = getQualifiedNameForGetProp(0);
return builder != null ? builder.toString() : null;
... | [
"@",
"Nullable",
"public",
"final",
"String",
"getQualifiedName",
"(",
")",
"{",
"switch",
"(",
"token",
")",
"{",
"case",
"NAME",
":",
"String",
"name",
"=",
"getString",
"(",
")",
";",
"return",
"name",
".",
"isEmpty",
"(",
")",
"?",
"null",
":",
"... | This function takes a set of GETPROP nodes and produces a string that is each property
separated by dots. If the node ultimately under the left sub-tree is not a simple name, this is
not a valid qualified name.
@return a null if this is not a qualified name, or a dot-separated string of the name and
properties. | [
"This",
"function",
"takes",
"a",
"set",
"of",
"GETPROP",
"nodes",
"and",
"produces",
"a",
"string",
"that",
"is",
"each",
"property",
"separated",
"by",
"dots",
".",
"If",
"the",
"node",
"ultimately",
"under",
"the",
"left",
"sub",
"-",
"tree",
"is",
"n... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L2022-L2038 |
24,650 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.getOriginalQualifiedName | @Nullable
public final String getOriginalQualifiedName() {
if (token == Token.NAME || getBooleanProp(Prop.IS_MODULE_NAME)) {
String name = getOriginalName();
if (name == null) {
name = getString();
}
return name.isEmpty() ? null : name;
} else if (token == Token.GETPROP) {
... | java | @Nullable
public final String getOriginalQualifiedName() {
if (token == Token.NAME || getBooleanProp(Prop.IS_MODULE_NAME)) {
String name = getOriginalName();
if (name == null) {
name = getString();
}
return name.isEmpty() ? null : name;
} else if (token == Token.GETPROP) {
... | [
"@",
"Nullable",
"public",
"final",
"String",
"getOriginalQualifiedName",
"(",
")",
"{",
"if",
"(",
"token",
"==",
"Token",
".",
"NAME",
"||",
"getBooleanProp",
"(",
"Prop",
".",
"IS_MODULE_NAME",
")",
")",
"{",
"String",
"name",
"=",
"getOriginalName",
"(",... | This function takes a set of GETPROP nodes and produces a string that is each property
separated by dots. If the node ultimately under the left sub-tree is not a simple name, this is
not a valid qualified name. This method returns the original name of each segment rather than
the renamed version.
@return a null if thi... | [
"This",
"function",
"takes",
"a",
"set",
"of",
"GETPROP",
"nodes",
"and",
"produces",
"a",
"string",
"that",
"is",
"each",
"property",
"separated",
"by",
"dots",
".",
"If",
"the",
"node",
"ultimately",
"under",
"the",
"left",
"sub",
"-",
"tree",
"is",
"n... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L2083-L2109 |
24,651 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.detachChildren | public final void detachChildren() {
for (Node child = first; child != null;) {
Node nextChild = child.next;
child.parent = null;
child.next = null;
child.previous = null;
child = nextChild;
}
first = null;
} | java | public final void detachChildren() {
for (Node child = first; child != null;) {
Node nextChild = child.next;
child.parent = null;
child.next = null;
child.previous = null;
child = nextChild;
}
first = null;
} | [
"public",
"final",
"void",
"detachChildren",
"(",
")",
"{",
"for",
"(",
"Node",
"child",
"=",
"first",
";",
"child",
"!=",
"null",
";",
")",
"{",
"Node",
"nextChild",
"=",
"child",
".",
"next",
";",
"child",
".",
"parent",
"=",
"null",
";",
"child",
... | Removes all children from this node and isolates the children from each
other. | [
"Removes",
"all",
"children",
"from",
"this",
"node",
"and",
"isolates",
"the",
"children",
"from",
"each",
"other",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L2277-L2286 |
24,652 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.setIsSyntheticBlock | public final void setIsSyntheticBlock(boolean val) {
checkState(token == Token.BLOCK);
putBooleanProp(Prop.SYNTHETIC, val);
} | java | public final void setIsSyntheticBlock(boolean val) {
checkState(token == Token.BLOCK);
putBooleanProp(Prop.SYNTHETIC, val);
} | [
"public",
"final",
"void",
"setIsSyntheticBlock",
"(",
"boolean",
"val",
")",
"{",
"checkState",
"(",
"token",
"==",
"Token",
".",
"BLOCK",
")",
";",
"putBooleanProp",
"(",
"Prop",
".",
"SYNTHETIC",
",",
"val",
")",
";",
"}"
] | Sets whether this is a synthetic block that should not be considered
a real source block. | [
"Sets",
"whether",
"this",
"is",
"a",
"synthetic",
"block",
"that",
"should",
"not",
"be",
"considered",
"a",
"real",
"source",
"block",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L2575-L2578 |
24,653 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.getDirectives | @SuppressWarnings("unchecked")
@Nullable
public final Set<String> getDirectives() {
return (Set<String>) getProp(Prop.DIRECTIVES);
} | java | @SuppressWarnings("unchecked")
@Nullable
public final Set<String> getDirectives() {
return (Set<String>) getProp(Prop.DIRECTIVES);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Nullable",
"public",
"final",
"Set",
"<",
"String",
">",
"getDirectives",
"(",
")",
"{",
"return",
"(",
"Set",
"<",
"String",
">",
")",
"getProp",
"(",
"Prop",
".",
"DIRECTIVES",
")",
";",
"}"
] | Returns the set of ES5 directives for this node. | [
"Returns",
"the",
"set",
"of",
"ES5",
"directives",
"for",
"this",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L2596-L2600 |
24,654 | google/closure-compiler | src/com/google/javascript/rhino/Node.java | Node.writeEncodedInt | @GwtIncompatible("ObjectOutput")
private void writeEncodedInt(ObjectOutput out, int value) throws IOException {
while (value > 0X7f || value < 0) {
out.writeByte(((value & 0X7f) | 0x80));
value >>>= 7;
}
out.writeByte(value);
} | java | @GwtIncompatible("ObjectOutput")
private void writeEncodedInt(ObjectOutput out, int value) throws IOException {
while (value > 0X7f || value < 0) {
out.writeByte(((value & 0X7f) | 0x80));
value >>>= 7;
}
out.writeByte(value);
} | [
"@",
"GwtIncompatible",
"(",
"\"ObjectOutput\"",
")",
"private",
"void",
"writeEncodedInt",
"(",
"ObjectOutput",
"out",
",",
"int",
"value",
")",
"throws",
"IOException",
"{",
"while",
"(",
"value",
">",
"0X7f",
"||",
"value",
"<",
"0",
")",
"{",
"out",
".... | Encode integers using variable length encoding.
Encodes an integer as a sequence of 7-bit values with a continuation bit. For example the
number 3912 (0111 0100 1000) is encoded in two bytes as follows 0xC80E (1100 1000 0000 1110),
i.e. first byte will be the lower 7 bits with a continuation bit set and second byte wi... | [
"Encode",
"integers",
"using",
"variable",
"length",
"encoding",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/Node.java#L3504-L3511 |
24,655 | google/closure-compiler | src/com/google/javascript/jscomp/DartSuperAccessorsPass.java | DartSuperAccessorsPass.normalizeAssignmentOp | private static Node normalizeAssignmentOp(Node n) {
Node lhs = n.getFirstChild();
Node rhs = n.getLastChild();
Node newRhs = new Node(NodeUtil.getOpFromAssignmentOp(n),
lhs.cloneTree(), rhs.cloneTree()).srcrefTree(n);
return replace(n, IR.assign(lhs.cloneTree(), newRhs).srcrefTree(n));
} | java | private static Node normalizeAssignmentOp(Node n) {
Node lhs = n.getFirstChild();
Node rhs = n.getLastChild();
Node newRhs = new Node(NodeUtil.getOpFromAssignmentOp(n),
lhs.cloneTree(), rhs.cloneTree()).srcrefTree(n);
return replace(n, IR.assign(lhs.cloneTree(), newRhs).srcrefTree(n));
} | [
"private",
"static",
"Node",
"normalizeAssignmentOp",
"(",
"Node",
"n",
")",
"{",
"Node",
"lhs",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"Node",
"rhs",
"=",
"n",
".",
"getLastChild",
"(",
")",
";",
"Node",
"newRhs",
"=",
"new",
"Node",
"(",
"N... | Transforms `a += b` to `a = a + b`. | [
"Transforms",
"a",
"+",
"=",
"b",
"to",
"a",
"=",
"a",
"+",
"b",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DartSuperAccessorsPass.java#L89-L95 |
24,656 | google/closure-compiler | src/com/google/javascript/jscomp/DartSuperAccessorsPass.java | DartSuperAccessorsPass.renameProperty | private Node renameProperty(Node propertyName) {
checkArgument(propertyName.isString());
if (!renameProperties) {
return propertyName;
}
Node call = IR.call(
IR.name(NodeUtil.JSC_PROPERTY_NAME_FN).srcref(propertyName),
propertyName);
call.srcref(propertyName);
call.putBoole... | java | private Node renameProperty(Node propertyName) {
checkArgument(propertyName.isString());
if (!renameProperties) {
return propertyName;
}
Node call = IR.call(
IR.name(NodeUtil.JSC_PROPERTY_NAME_FN).srcref(propertyName),
propertyName);
call.srcref(propertyName);
call.putBoole... | [
"private",
"Node",
"renameProperty",
"(",
"Node",
"propertyName",
")",
"{",
"checkArgument",
"(",
"propertyName",
".",
"isString",
"(",
")",
")",
";",
"if",
"(",
"!",
"renameProperties",
")",
"{",
"return",
"propertyName",
";",
"}",
"Node",
"call",
"=",
"I... | Wraps a property string in a JSCompiler_renameProperty call.
<p>Should only be called in phases running before {@link RenameProperties},
if such a pass is even used (see {@link #renameProperties}). | [
"Wraps",
"a",
"property",
"string",
"in",
"a",
"JSCompiler_renameProperty",
"call",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DartSuperAccessorsPass.java#L174-L186 |
24,657 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessTweaks.java | ProcessTweaks.replaceGetCompilerOverridesCalls | private void replaceGetCompilerOverridesCalls(
List<TweakFunctionCall> calls) {
for (TweakFunctionCall call : calls) {
Node callNode = call.callNode;
Node objNode = createCompilerDefaultValueOverridesVarNode(callNode);
callNode.replaceWith(objNode);
compiler.reportChangeToEnclosingScop... | java | private void replaceGetCompilerOverridesCalls(
List<TweakFunctionCall> calls) {
for (TweakFunctionCall call : calls) {
Node callNode = call.callNode;
Node objNode = createCompilerDefaultValueOverridesVarNode(callNode);
callNode.replaceWith(objNode);
compiler.reportChangeToEnclosingScop... | [
"private",
"void",
"replaceGetCompilerOverridesCalls",
"(",
"List",
"<",
"TweakFunctionCall",
">",
"calls",
")",
"{",
"for",
"(",
"TweakFunctionCall",
"call",
":",
"calls",
")",
"{",
"Node",
"callNode",
"=",
"call",
".",
"callNode",
";",
"Node",
"objNode",
"="... | Passes the compiler default value overrides to the JS by replacing calls
to goog.tweak.getCompilerOverrids_ with a map of tweak ID->default value; | [
"Passes",
"the",
"compiler",
"default",
"value",
"overrides",
"to",
"the",
"JS",
"by",
"replacing",
"calls",
"to",
"goog",
".",
"tweak",
".",
"getCompilerOverrids_",
"with",
"a",
"map",
"of",
"tweak",
"ID",
"-",
">",
"default",
"value",
";"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessTweaks.java#L222-L230 |
24,658 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessTweaks.java | ProcessTweaks.stripAllCalls | private void stripAllCalls(Map<String, TweakInfo> tweakInfos) {
for (TweakInfo tweakInfo : tweakInfos.values()) {
boolean isRegistered = tweakInfo.isRegistered();
for (TweakFunctionCall functionCall : tweakInfo.functionCalls) {
Node callNode = functionCall.callNode;
Node parent = callNod... | java | private void stripAllCalls(Map<String, TweakInfo> tweakInfos) {
for (TweakInfo tweakInfo : tweakInfos.values()) {
boolean isRegistered = tweakInfo.isRegistered();
for (TweakFunctionCall functionCall : tweakInfo.functionCalls) {
Node callNode = functionCall.callNode;
Node parent = callNod... | [
"private",
"void",
"stripAllCalls",
"(",
"Map",
"<",
"String",
",",
"TweakInfo",
">",
"tweakInfos",
")",
"{",
"for",
"(",
"TweakInfo",
"tweakInfo",
":",
"tweakInfos",
".",
"values",
"(",
")",
")",
"{",
"boolean",
"isRegistered",
"=",
"tweakInfo",
".",
"isR... | Removes all CALL nodes in the given TweakInfos, replacing calls to getter
functions with the tweak's default value. | [
"Removes",
"all",
"CALL",
"nodes",
"in",
"the",
"given",
"TweakInfos",
"replacing",
"calls",
"to",
"getter",
"functions",
"with",
"the",
"tweak",
"s",
"default",
"value",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessTweaks.java#L236-L264 |
24,659 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessTweaks.java | ProcessTweaks.createCompilerDefaultValueOverridesVarNode | private Node createCompilerDefaultValueOverridesVarNode(
Node sourceInformationNode) {
Node objNode = IR.objectlit().srcref(sourceInformationNode);
for (Entry<String, Node> entry : compilerDefaultValueOverrides.entrySet()) {
Node objKeyNode = IR.stringKey(entry.getKey())
.useSourceInfoIfMi... | java | private Node createCompilerDefaultValueOverridesVarNode(
Node sourceInformationNode) {
Node objNode = IR.objectlit().srcref(sourceInformationNode);
for (Entry<String, Node> entry : compilerDefaultValueOverrides.entrySet()) {
Node objKeyNode = IR.stringKey(entry.getKey())
.useSourceInfoIfMi... | [
"private",
"Node",
"createCompilerDefaultValueOverridesVarNode",
"(",
"Node",
"sourceInformationNode",
")",
"{",
"Node",
"objNode",
"=",
"IR",
".",
"objectlit",
"(",
")",
".",
"srcref",
"(",
"sourceInformationNode",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
... | Creates a JS object that holds a map of tweakId -> default value override. | [
"Creates",
"a",
"JS",
"object",
"that",
"holds",
"a",
"map",
"of",
"tweakId",
"-",
">",
"default",
"value",
"override",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessTweaks.java#L269-L281 |
24,660 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessTweaks.java | ProcessTweaks.applyCompilerDefaultValueOverrides | private void applyCompilerDefaultValueOverrides(
Map<String, TweakInfo> tweakInfos) {
for (Entry<String, Node> entry : compilerDefaultValueOverrides.entrySet()) {
String tweakId = entry.getKey();
TweakInfo tweakInfo = tweakInfos.get(tweakId);
if (tweakInfo == null) {
compiler.report(... | java | private void applyCompilerDefaultValueOverrides(
Map<String, TweakInfo> tweakInfos) {
for (Entry<String, Node> entry : compilerDefaultValueOverrides.entrySet()) {
String tweakId = entry.getKey();
TweakInfo tweakInfo = tweakInfos.get(tweakId);
if (tweakInfo == null) {
compiler.report(... | [
"private",
"void",
"applyCompilerDefaultValueOverrides",
"(",
"Map",
"<",
"String",
",",
"TweakInfo",
">",
"tweakInfos",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"Node",
">",
"entry",
":",
"compilerDefaultValueOverrides",
".",
"entrySet",
"(",
")",
"... | Sets the default values of tweaks based on compiler options. | [
"Sets",
"the",
"default",
"values",
"of",
"tweaks",
"based",
"on",
"compiler",
"options",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessTweaks.java#L284-L303 |
24,661 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryFoldTry | private Node tryFoldTry(Node n) {
checkState(n.isTry(), n);
Node body = n.getFirstChild();
Node catchBlock = body.getNext();
Node finallyBlock = catchBlock.getNext();
// Removes TRYs that had its CATCH removed and/or empty FINALLY.
if (!catchBlock.hasChildren() && (finallyBlock == null || !fina... | java | private Node tryFoldTry(Node n) {
checkState(n.isTry(), n);
Node body = n.getFirstChild();
Node catchBlock = body.getNext();
Node finallyBlock = catchBlock.getNext();
// Removes TRYs that had its CATCH removed and/or empty FINALLY.
if (!catchBlock.hasChildren() && (finallyBlock == null || !fina... | [
"private",
"Node",
"tryFoldTry",
"(",
"Node",
"n",
")",
"{",
"checkState",
"(",
"n",
".",
"isTry",
"(",
")",
",",
"n",
")",
";",
"Node",
"body",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"Node",
"catchBlock",
"=",
"body",
".",
"getNext",
"(",
... | Remove try blocks without catch blocks and with empty or not
existent finally blocks.
Or, only leave the finally blocks if try body blocks are empty
@return the replacement node, if changed, or the original if not | [
"Remove",
"try",
"blocks",
"without",
"catch",
"blocks",
"and",
"with",
"empty",
"or",
"not",
"existent",
"finally",
"blocks",
".",
"Or",
"only",
"leave",
"the",
"finally",
"blocks",
"if",
"try",
"body",
"blocks",
"are",
"empty"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L181-L209 |
24,662 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryFoldExpr | private Node tryFoldExpr(Node subtree) {
Node result = trySimplifyUnusedResult(subtree.getFirstChild());
if (result == null) {
Node parent = subtree.getParent();
// If the EXPR_RESULT no longer has any children, remove it as well.
if (parent.isLabel()) {
Node replacement = IR.block().s... | java | private Node tryFoldExpr(Node subtree) {
Node result = trySimplifyUnusedResult(subtree.getFirstChild());
if (result == null) {
Node parent = subtree.getParent();
// If the EXPR_RESULT no longer has any children, remove it as well.
if (parent.isLabel()) {
Node replacement = IR.block().s... | [
"private",
"Node",
"tryFoldExpr",
"(",
"Node",
"subtree",
")",
"{",
"Node",
"result",
"=",
"trySimplifyUnusedResult",
"(",
"subtree",
".",
"getFirstChild",
"(",
")",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"Node",
"parent",
"=",
"subtree",
... | Try folding EXPR_RESULT nodes by removing useless Ops and expressions.
@return the replacement node, if changed, or the original if not | [
"Try",
"folding",
"EXPR_RESULT",
"nodes",
"by",
"removing",
"useless",
"Ops",
"and",
"expressions",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L262-L277 |
24,663 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryOptimizeSwitch | private Node tryOptimizeSwitch(Node n) {
checkState(n.isSwitch(), n);
Node defaultCase = tryOptimizeDefaultCase(n);
// Generally, it is unsafe to remove other cases when the default case is not the last one.
if (defaultCase == null || n.getLastChild().isDefaultCase()) {
Node cond = n.getFirstChi... | java | private Node tryOptimizeSwitch(Node n) {
checkState(n.isSwitch(), n);
Node defaultCase = tryOptimizeDefaultCase(n);
// Generally, it is unsafe to remove other cases when the default case is not the last one.
if (defaultCase == null || n.getLastChild().isDefaultCase()) {
Node cond = n.getFirstChi... | [
"private",
"Node",
"tryOptimizeSwitch",
"(",
"Node",
"n",
")",
"{",
"checkState",
"(",
"n",
".",
"isSwitch",
"(",
")",
",",
"n",
")",
";",
"Node",
"defaultCase",
"=",
"tryOptimizeDefaultCase",
"(",
"n",
")",
";",
"// Generally, it is unsafe to remove other cases... | Remove useless switches and cases. | [
"Remove",
"useless",
"switches",
"and",
"cases",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L525-L605 |
24,664 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.removeCase | private void removeCase(Node switchNode, Node caseNode) {
NodeUtil.redeclareVarsInsideBranch(caseNode);
switchNode.removeChild(caseNode);
reportChangeToEnclosingScope(switchNode);
} | java | private void removeCase(Node switchNode, Node caseNode) {
NodeUtil.redeclareVarsInsideBranch(caseNode);
switchNode.removeChild(caseNode);
reportChangeToEnclosingScope(switchNode);
} | [
"private",
"void",
"removeCase",
"(",
"Node",
"switchNode",
",",
"Node",
"caseNode",
")",
"{",
"NodeUtil",
".",
"redeclareVarsInsideBranch",
"(",
"caseNode",
")",
";",
"switchNode",
".",
"removeChild",
"(",
"caseNode",
")",
";",
"reportChangeToEnclosingScope",
"("... | Remove the case from the switch redeclaring any variables declared in it.
@param caseNode The case to remove. | [
"Remove",
"the",
"case",
"from",
"the",
"switch",
"redeclaring",
"any",
"variables",
"declared",
"in",
"it",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L651-L655 |
24,665 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryOptimizeBlock | Node tryOptimizeBlock(Node n) {
// Remove any useless children
for (Node c = n.getFirstChild(); c != null; ) {
Node next = c.getNext(); // save c.next, since 'c' may be removed
if (!isUnremovableNode(c) && !mayHaveSideEffects(c)) {
checkNormalization(!NodeUtil.isFunctionDeclaration(n), "fun... | java | Node tryOptimizeBlock(Node n) {
// Remove any useless children
for (Node c = n.getFirstChild(); c != null; ) {
Node next = c.getNext(); // save c.next, since 'c' may be removed
if (!isUnremovableNode(c) && !mayHaveSideEffects(c)) {
checkNormalization(!NodeUtil.isFunctionDeclaration(n), "fun... | [
"Node",
"tryOptimizeBlock",
"(",
"Node",
"n",
")",
"{",
"// Remove any useless children",
"for",
"(",
"Node",
"c",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"c",
"!=",
"null",
";",
")",
"{",
"Node",
"next",
"=",
"c",
".",
"getNext",
"(",
")",
";... | Try removing unneeded block nodes and their useless children | [
"Try",
"removing",
"unneeded",
"block",
"nodes",
"and",
"their",
"useless",
"children"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L753-L783 |
24,666 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryOptimizeConditionalAfterAssign | private void tryOptimizeConditionalAfterAssign(Node n) {
Node next = n.getNext();
// Look for patterns like the following and replace the if-condition with
// a constant value so it can later be folded:
// var a = /a/;
// if (a) {foo(a)}
// or
// a = 0;
// a ? foo(a) : c;
//... | java | private void tryOptimizeConditionalAfterAssign(Node n) {
Node next = n.getNext();
// Look for patterns like the following and replace the if-condition with
// a constant value so it can later be folded:
// var a = /a/;
// if (a) {foo(a)}
// or
// a = 0;
// a ? foo(a) : c;
//... | [
"private",
"void",
"tryOptimizeConditionalAfterAssign",
"(",
"Node",
"n",
")",
"{",
"Node",
"next",
"=",
"n",
".",
"getNext",
"(",
")",
";",
"// Look for patterns like the following and replace the if-condition with",
"// a constant value so it can later be folded:",
"// var ... | Attempt to replace the condition of if or hook immediately that is a
reference to a name that is assigned immediately before. | [
"Attempt",
"to",
"replace",
"the",
"condition",
"of",
"if",
"or",
"hook",
"immediately",
"that",
"is",
"a",
"reference",
"to",
"a",
"name",
"that",
"is",
"assigned",
"immediately",
"before",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L798-L838 |
24,667 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryFoldWhile | Node tryFoldWhile(Node n) {
checkArgument(n.isWhile());
Node cond = NodeUtil.getConditionExpression(n);
if (NodeUtil.getPureBooleanValue(cond) != TernaryValue.FALSE) {
return n;
}
NodeUtil.redeclareVarsInsideBranch(n);
reportChangeToEnclosingScope(n.getParent());
NodeUtil.removeChild(n... | java | Node tryFoldWhile(Node n) {
checkArgument(n.isWhile());
Node cond = NodeUtil.getConditionExpression(n);
if (NodeUtil.getPureBooleanValue(cond) != TernaryValue.FALSE) {
return n;
}
NodeUtil.redeclareVarsInsideBranch(n);
reportChangeToEnclosingScope(n.getParent());
NodeUtil.removeChild(n... | [
"Node",
"tryFoldWhile",
"(",
"Node",
"n",
")",
"{",
"checkArgument",
"(",
"n",
".",
"isWhile",
"(",
")",
")",
";",
"Node",
"cond",
"=",
"NodeUtil",
".",
"getConditionExpression",
"(",
"n",
")",
";",
"if",
"(",
"NodeUtil",
".",
"getPureBooleanValue",
"(",... | Removes WHILEs that always evaluate to false. | [
"Removes",
"WHILEs",
"that",
"always",
"evaluate",
"to",
"false",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1076-L1087 |
24,668 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryFoldFor | Node tryFoldFor(Node n) {
checkArgument(n.isVanillaFor());
Node init = n.getFirstChild();
Node cond = init.getNext();
Node increment = cond.getNext();
if (!init.isEmpty() && !NodeUtil.isNameDeclaration(init)) {
init = trySimplifyUnusedResult(init);
if (init == null) {
init = IR... | java | Node tryFoldFor(Node n) {
checkArgument(n.isVanillaFor());
Node init = n.getFirstChild();
Node cond = init.getNext();
Node increment = cond.getNext();
if (!init.isEmpty() && !NodeUtil.isNameDeclaration(init)) {
init = trySimplifyUnusedResult(init);
if (init == null) {
init = IR... | [
"Node",
"tryFoldFor",
"(",
"Node",
"n",
")",
"{",
"checkArgument",
"(",
"n",
".",
"isVanillaFor",
"(",
")",
")",
";",
"Node",
"init",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"Node",
"cond",
"=",
"init",
".",
"getNext",
"(",
")",
";",
"Node",... | Removes FORs that always evaluate to false. | [
"Removes",
"FORs",
"that",
"always",
"evaluate",
"to",
"false",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1092-L1141 |
24,669 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryFoldDoAway | Node tryFoldDoAway(Node n) {
checkArgument(n.isDo());
Node cond = NodeUtil.getConditionExpression(n);
if (NodeUtil.getImpureBooleanValue(cond) != TernaryValue.FALSE) {
return n;
}
Node block = NodeUtil.getLoopCodeBlock(n);
if (n.getParent().isLabel() || hasUnnamedBreakOrContinue(block)) ... | java | Node tryFoldDoAway(Node n) {
checkArgument(n.isDo());
Node cond = NodeUtil.getConditionExpression(n);
if (NodeUtil.getImpureBooleanValue(cond) != TernaryValue.FALSE) {
return n;
}
Node block = NodeUtil.getLoopCodeBlock(n);
if (n.getParent().isLabel() || hasUnnamedBreakOrContinue(block)) ... | [
"Node",
"tryFoldDoAway",
"(",
"Node",
"n",
")",
"{",
"checkArgument",
"(",
"n",
".",
"isDo",
"(",
")",
")",
";",
"Node",
"cond",
"=",
"NodeUtil",
".",
"getConditionExpression",
"(",
"n",
")",
";",
"if",
"(",
"NodeUtil",
".",
"getImpureBooleanValue",
"(",... | Removes DOs that always evaluate to false. This leaves the
statements that were in the loop in a BLOCK node.
The block will be removed in a later pass, if possible. | [
"Removes",
"DOs",
"that",
"always",
"evaluate",
"to",
"false",
".",
"This",
"leaves",
"the",
"statements",
"that",
"were",
"in",
"the",
"loop",
"in",
"a",
"BLOCK",
"node",
".",
"The",
"block",
"will",
"be",
"removed",
"in",
"a",
"later",
"pass",
"if",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1148-L1170 |
24,670 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryFoldEmptyDo | Node tryFoldEmptyDo(Node n) {
checkArgument(n.isDo());
Node body = NodeUtil.getLoopCodeBlock(n);
if (body.isBlock() && !body.hasChildren()) {
Node cond = NodeUtil.getConditionExpression(n);
Node forNode =
IR.forNode(IR.empty().srcref(n),
cond.detach(),
... | java | Node tryFoldEmptyDo(Node n) {
checkArgument(n.isDo());
Node body = NodeUtil.getLoopCodeBlock(n);
if (body.isBlock() && !body.hasChildren()) {
Node cond = NodeUtil.getConditionExpression(n);
Node forNode =
IR.forNode(IR.empty().srcref(n),
cond.detach(),
... | [
"Node",
"tryFoldEmptyDo",
"(",
"Node",
"n",
")",
"{",
"checkArgument",
"(",
"n",
".",
"isDo",
"(",
")",
")",
";",
"Node",
"body",
"=",
"NodeUtil",
".",
"getLoopCodeBlock",
"(",
"n",
")",
";",
"if",
"(",
"body",
".",
"isBlock",
"(",
")",
"&&",
"!",
... | Removes DOs that have empty bodies into FORs, which are
much easier for the CFA to analyze. | [
"Removes",
"DOs",
"that",
"have",
"empty",
"bodies",
"into",
"FORs",
"which",
"are",
"much",
"easier",
"for",
"the",
"CFA",
"to",
"analyze",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1176-L1192 |
24,671 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryOptimizeObjectPattern | Node tryOptimizeObjectPattern(Node pattern) {
checkArgument(pattern.isObjectPattern(), pattern);
if (pattern.hasChildren() && pattern.getLastChild().isRest()) {
// don't remove any elements in `const {f: [], ...rest} = obj` because that affects what's
// assigned to `rest`. only the last element ca... | java | Node tryOptimizeObjectPattern(Node pattern) {
checkArgument(pattern.isObjectPattern(), pattern);
if (pattern.hasChildren() && pattern.getLastChild().isRest()) {
// don't remove any elements in `const {f: [], ...rest} = obj` because that affects what's
// assigned to `rest`. only the last element ca... | [
"Node",
"tryOptimizeObjectPattern",
"(",
"Node",
"pattern",
")",
"{",
"checkArgument",
"(",
"pattern",
".",
"isObjectPattern",
"(",
")",
",",
"pattern",
")",
";",
"if",
"(",
"pattern",
".",
"hasChildren",
"(",
")",
"&&",
"pattern",
".",
"getLastChild",
"(",
... | Removes string keys with an empty pattern as their child | [
"Removes",
"string",
"keys",
"with",
"an",
"empty",
"pattern",
"as",
"their",
"child"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1195-L1220 |
24,672 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryOptimizeArrayPattern | Node tryOptimizeArrayPattern(Node pattern) {
checkArgument(pattern.isArrayPattern(), pattern);
for (Node lastChild = pattern.getLastChild(); lastChild != null; ) {
if (lastChild.isEmpty() || isRemovableDestructuringTarget(lastChild)) {
Node prev = lastChild.getPrevious();
pattern.removeCh... | java | Node tryOptimizeArrayPattern(Node pattern) {
checkArgument(pattern.isArrayPattern(), pattern);
for (Node lastChild = pattern.getLastChild(); lastChild != null; ) {
if (lastChild.isEmpty() || isRemovableDestructuringTarget(lastChild)) {
Node prev = lastChild.getPrevious();
pattern.removeCh... | [
"Node",
"tryOptimizeArrayPattern",
"(",
"Node",
"pattern",
")",
"{",
"checkArgument",
"(",
"pattern",
".",
"isArrayPattern",
"(",
")",
",",
"pattern",
")",
";",
"for",
"(",
"Node",
"lastChild",
"=",
"pattern",
".",
"getLastChild",
"(",
")",
";",
"lastChild",... | Removes trailing EMPTY nodes and empty array patterns | [
"Removes",
"trailing",
"EMPTY",
"nodes",
"and",
"empty",
"array",
"patterns"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1223-L1240 |
24,673 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.hasUnnamedBreakOrContinue | static boolean hasUnnamedBreakOrContinue(Node n) {
return NodeUtil.has(n, IS_UNNAMED_BREAK_PREDICATE, CAN_CONTAIN_BREAK_PREDICATE)
|| NodeUtil.has(n, IS_UNNAMED_CONTINUE_PREDICATE, CAN_CONTAIN_CONTINUE_PREDICATE);
} | java | static boolean hasUnnamedBreakOrContinue(Node n) {
return NodeUtil.has(n, IS_UNNAMED_BREAK_PREDICATE, CAN_CONTAIN_BREAK_PREDICATE)
|| NodeUtil.has(n, IS_UNNAMED_CONTINUE_PREDICATE, CAN_CONTAIN_CONTINUE_PREDICATE);
} | [
"static",
"boolean",
"hasUnnamedBreakOrContinue",
"(",
"Node",
"n",
")",
"{",
"return",
"NodeUtil",
".",
"has",
"(",
"n",
",",
"IS_UNNAMED_BREAK_PREDICATE",
",",
"CAN_CONTAIN_BREAK_PREDICATE",
")",
"||",
"NodeUtil",
".",
"has",
"(",
"n",
",",
"IS_UNNAMED_CONTINUE_... | Returns whether a node has any unhandled breaks or continue. | [
"Returns",
"whether",
"a",
"node",
"has",
"any",
"unhandled",
"breaks",
"or",
"continue",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1259-L1262 |
24,674 | google/closure-compiler | src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java | PeepholeRemoveDeadCode.tryFoldForCondition | private void tryFoldForCondition(Node forCondition) {
if (NodeUtil.getPureBooleanValue(forCondition) == TernaryValue.TRUE) {
reportChangeToEnclosingScope(forCondition);
forCondition.replaceWith(IR.empty());
}
} | java | private void tryFoldForCondition(Node forCondition) {
if (NodeUtil.getPureBooleanValue(forCondition) == TernaryValue.TRUE) {
reportChangeToEnclosingScope(forCondition);
forCondition.replaceWith(IR.empty());
}
} | [
"private",
"void",
"tryFoldForCondition",
"(",
"Node",
"forCondition",
")",
"{",
"if",
"(",
"NodeUtil",
".",
"getPureBooleanValue",
"(",
"forCondition",
")",
"==",
"TernaryValue",
".",
"TRUE",
")",
"{",
"reportChangeToEnclosingScope",
"(",
"forCondition",
")",
";"... | Remove always true loop conditions. | [
"Remove",
"always",
"true",
"loop",
"conditions",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PeepholeRemoveDeadCode.java#L1267-L1272 |
24,675 | google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java | Es6RewriteBlockScopedDeclaration.visitBlockScopedName | private void visitBlockScopedName(NodeTraversal t, Node decl, Node nameNode) {
Scope scope = t.getScope();
Node parent = decl.getParent();
// Normalize "let x;" to "let x = undefined;" if in a loop, since we later convert x
// to be $jscomp$loop$0.x and want to reset the property to undefined every loop... | java | private void visitBlockScopedName(NodeTraversal t, Node decl, Node nameNode) {
Scope scope = t.getScope();
Node parent = decl.getParent();
// Normalize "let x;" to "let x = undefined;" if in a loop, since we later convert x
// to be $jscomp$loop$0.x and want to reset the property to undefined every loop... | [
"private",
"void",
"visitBlockScopedName",
"(",
"NodeTraversal",
"t",
",",
"Node",
"decl",
",",
"Node",
"nameNode",
")",
"{",
"Scope",
"scope",
"=",
"t",
".",
"getScope",
"(",
")",
";",
"Node",
"parent",
"=",
"decl",
".",
"getParent",
"(",
")",
";",
"/... | Renames block-scoped declarations that shadow a variable in an outer scope
<p>Also normalizes declarations with no initializer in a loop to be initialized to undefined. | [
"Renames",
"block",
"-",
"scoped",
"declarations",
"that",
"shadow",
"a",
"variable",
"in",
"an",
"outer",
"scope"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java#L141-L172 |
24,676 | google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java | Es6RewriteBlockScopedDeclaration.inLoop | private boolean inLoop(Node n) {
Node enclosingNode = NodeUtil.getEnclosingNode(n, isLoopOrFunction);
return enclosingNode != null && !enclosingNode.isFunction();
} | java | private boolean inLoop(Node n) {
Node enclosingNode = NodeUtil.getEnclosingNode(n, isLoopOrFunction);
return enclosingNode != null && !enclosingNode.isFunction();
} | [
"private",
"boolean",
"inLoop",
"(",
"Node",
"n",
")",
"{",
"Node",
"enclosingNode",
"=",
"NodeUtil",
".",
"getEnclosingNode",
"(",
"n",
",",
"isLoopOrFunction",
")",
";",
"return",
"enclosingNode",
"!=",
"null",
"&&",
"!",
"enclosingNode",
".",
"isFunction",
... | Whether n is inside a loop. If n is inside a function which is inside a loop, we do not
consider it to be inside a loop. | [
"Whether",
"n",
"is",
"inside",
"a",
"loop",
".",
"If",
"n",
"is",
"inside",
"a",
"function",
"which",
"is",
"inside",
"a",
"loop",
"we",
"do",
"not",
"consider",
"it",
"to",
"be",
"inside",
"a",
"loop",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java#L178-L181 |
24,677 | google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java | Es6RewriteBlockScopedDeclaration.createAssignNode | private Node createAssignNode(Node lhs, Node rhs) {
Node assignNode = IR.assign(lhs, rhs);
if (shouldAddTypesOnNewAstNodes) {
assignNode.setJSType(rhs.getJSType());
}
return assignNode;
} | java | private Node createAssignNode(Node lhs, Node rhs) {
Node assignNode = IR.assign(lhs, rhs);
if (shouldAddTypesOnNewAstNodes) {
assignNode.setJSType(rhs.getJSType());
}
return assignNode;
} | [
"private",
"Node",
"createAssignNode",
"(",
"Node",
"lhs",
",",
"Node",
"rhs",
")",
"{",
"Node",
"assignNode",
"=",
"IR",
".",
"assign",
"(",
"lhs",
",",
"rhs",
")",
";",
"if",
"(",
"shouldAddTypesOnNewAstNodes",
")",
"{",
"assignNode",
".",
"setJSType",
... | Creates an ASSIGN node with type information matching its RHS. | [
"Creates",
"an",
"ASSIGN",
"node",
"with",
"type",
"information",
"matching",
"its",
"RHS",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java#L709-L715 |
24,678 | google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java | Es6RewriteBlockScopedDeclaration.createCommaNode | private Node createCommaNode(Node expr1, Node expr2) {
Node commaNode = IR.comma(expr1, expr2);
if (shouldAddTypesOnNewAstNodes) {
commaNode.setJSType(expr2.getJSType());
}
return commaNode;
} | java | private Node createCommaNode(Node expr1, Node expr2) {
Node commaNode = IR.comma(expr1, expr2);
if (shouldAddTypesOnNewAstNodes) {
commaNode.setJSType(expr2.getJSType());
}
return commaNode;
} | [
"private",
"Node",
"createCommaNode",
"(",
"Node",
"expr1",
",",
"Node",
"expr2",
")",
"{",
"Node",
"commaNode",
"=",
"IR",
".",
"comma",
"(",
"expr1",
",",
"expr2",
")",
";",
"if",
"(",
"shouldAddTypesOnNewAstNodes",
")",
"{",
"commaNode",
".",
"setJSType... | Creates a COMMA node with type information matching its second argument. | [
"Creates",
"a",
"COMMA",
"node",
"with",
"type",
"information",
"matching",
"its",
"second",
"argument",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java#L718-L724 |
24,679 | google/closure-compiler | src/com/google/javascript/jscomp/SourceFile.java | SourceFile.getLine | public String getLine(int lineNumber) {
findLineOffsets();
if (lineNumber > lineOffsets.length) {
return null;
}
if (lineNumber < 1) {
lineNumber = 1;
}
int pos = lineOffsets[lineNumber - 1];
String js = "";
try {
// NOTE(nicksantos): Right now, this is optimized for ... | java | public String getLine(int lineNumber) {
findLineOffsets();
if (lineNumber > lineOffsets.length) {
return null;
}
if (lineNumber < 1) {
lineNumber = 1;
}
int pos = lineOffsets[lineNumber - 1];
String js = "";
try {
// NOTE(nicksantos): Right now, this is optimized for ... | [
"public",
"String",
"getLine",
"(",
"int",
"lineNumber",
")",
"{",
"findLineOffsets",
"(",
")",
";",
"if",
"(",
"lineNumber",
">",
"lineOffsets",
".",
"length",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"lineNumber",
"<",
"1",
")",
"{",
"lineNum... | Gets the source line for the indicated line number.
@param lineNumber the line number, 1 being the first line of the file.
@return The line indicated. Does not include the newline at the end
of the file. Returns {@code null} if it does not exist,
or if there was an IO exception. | [
"Gets",
"the",
"source",
"line",
"for",
"the",
"indicated",
"line",
"number",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/SourceFile.java#L243-L276 |
24,680 | google/closure-compiler | src/com/google/javascript/jscomp/SourceFile.java | SourceFile.getRegion | public Region getRegion(int lineNumber) {
String js = "";
try {
js = getCode();
} catch (IOException e) {
return null;
}
int pos = 0;
int startLine = Math.max(1,
lineNumber - (SOURCE_EXCERPT_REGION_LENGTH + 1) / 2 + 1);
for (int n = 1; n < startLine; n++) {
int next... | java | public Region getRegion(int lineNumber) {
String js = "";
try {
js = getCode();
} catch (IOException e) {
return null;
}
int pos = 0;
int startLine = Math.max(1,
lineNumber - (SOURCE_EXCERPT_REGION_LENGTH + 1) / 2 + 1);
for (int n = 1; n < startLine; n++) {
int next... | [
"public",
"Region",
"getRegion",
"(",
"int",
"lineNumber",
")",
"{",
"String",
"js",
"=",
"\"\"",
";",
"try",
"{",
"js",
"=",
"getCode",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"int",
"pos",
"=",
... | Get a region around the indicated line number. The exact definition of a
region is implementation specific, but it must contain the line indicated
by the line number. A region must not start or end by a carriage return.
@param lineNumber the line number, 1 being the first line of the file.
@return The line indicated. ... | [
"Get",
"a",
"region",
"around",
"the",
"indicated",
"line",
"number",
".",
"The",
"exact",
"definition",
"of",
"a",
"region",
"is",
"implementation",
"specific",
"but",
"it",
"must",
"contain",
"the",
"line",
"indicated",
"by",
"the",
"line",
"number",
".",
... | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/SourceFile.java#L287-L327 |
24,681 | google/closure-compiler | src/com/google/javascript/jscomp/VariableMap.java | VariableMap.save | @GwtIncompatible("com.google.io.Files")
public void save(String filename) throws IOException {
Files.write(toBytes(), new File(filename));
} | java | @GwtIncompatible("com.google.io.Files")
public void save(String filename) throws IOException {
Files.write(toBytes(), new File(filename));
} | [
"@",
"GwtIncompatible",
"(",
"\"com.google.io.Files\"",
")",
"public",
"void",
"save",
"(",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"Files",
".",
"write",
"(",
"toBytes",
"(",
")",
",",
"new",
"File",
"(",
"filename",
")",
")",
";",
"}"
] | Saves the variable map to a file. | [
"Saves",
"the",
"variable",
"map",
"to",
"a",
"file",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/VariableMap.java#L81-L84 |
24,682 | google/closure-compiler | src/com/google/javascript/jscomp/VariableMap.java | VariableMap.toBytes | @GwtIncompatible("java.io.ByteArrayOutputStream")
public byte[] toBytes() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(baos, UTF_8);
try {
// The output order should be stable.
for (Map.Entry<String, String> entry :
ImmutableSorte... | java | @GwtIncompatible("java.io.ByteArrayOutputStream")
public byte[] toBytes() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(baos, UTF_8);
try {
// The output order should be stable.
for (Map.Entry<String, String> entry :
ImmutableSorte... | [
"@",
"GwtIncompatible",
"(",
"\"java.io.ByteArrayOutputStream\"",
")",
"public",
"byte",
"[",
"]",
"toBytes",
"(",
")",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"Writer",
"writer",
"=",
"new",
"OutputStreamWriter",
... | Serializes the variable map to a byte array. | [
"Serializes",
"the",
"variable",
"map",
"to",
"a",
"byte",
"array",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/VariableMap.java#L102-L122 |
24,683 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java | TypeTransformationParser.parseTypeTransformation | public boolean parseTypeTransformation() {
Config config =
Config.builder()
.setLanguageMode(Config.LanguageMode.ECMASCRIPT6)
.setStrictMode(Config.StrictMode.SLOPPY)
.build();
// TODO(lpino): ParserRunner reports errors if the expression is not
// ES6 valid. We n... | java | public boolean parseTypeTransformation() {
Config config =
Config.builder()
.setLanguageMode(Config.LanguageMode.ECMASCRIPT6)
.setStrictMode(Config.StrictMode.SLOPPY)
.build();
// TODO(lpino): ParserRunner reports errors if the expression is not
// ES6 valid. We n... | [
"public",
"boolean",
"parseTypeTransformation",
"(",
")",
"{",
"Config",
"config",
"=",
"Config",
".",
"builder",
"(",
")",
".",
"setLanguageMode",
"(",
"Config",
".",
"LanguageMode",
".",
"ECMASCRIPT6",
")",
".",
"setStrictMode",
"(",
"Config",
".",
"StrictMo... | Takes a type transformation expression, transforms it to an AST using
the ParserRunner of the JSCompiler and then verifies that it is a valid
AST.
@return true if the parsing was successful otherwise it returns false and
at least one warning is reported | [
"Takes",
"a",
"type",
"transformation",
"expression",
"transforms",
"it",
"to",
"an",
"AST",
"using",
"the",
"ParserRunner",
"of",
"the",
"JSCompiler",
"and",
"then",
"verifies",
"that",
"it",
"is",
"a",
"valid",
"AST",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java#L250-L278 |
24,684 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java | TypeTransformationParser.validBooleanExpression | private boolean validBooleanExpression(Node expr) {
if (isBooleanOperation(expr)) {
return validBooleanOperation(expr);
}
if (!isOperation(expr)) {
warnInvalidExpression("boolean", expr);
return false;
}
if (!isValidPredicate(getCallName(expr))) {
warnInvalid("boolean predic... | java | private boolean validBooleanExpression(Node expr) {
if (isBooleanOperation(expr)) {
return validBooleanOperation(expr);
}
if (!isOperation(expr)) {
warnInvalidExpression("boolean", expr);
return false;
}
if (!isValidPredicate(getCallName(expr))) {
warnInvalid("boolean predic... | [
"private",
"boolean",
"validBooleanExpression",
"(",
"Node",
"expr",
")",
"{",
"if",
"(",
"isBooleanOperation",
"(",
"expr",
")",
")",
"{",
"return",
"validBooleanOperation",
"(",
"expr",
")",
";",
"}",
"if",
"(",
"!",
"isOperation",
"(",
"expr",
")",
")",... | A boolean expression must be a boolean predicate or a boolean
type predicate | [
"A",
"boolean",
"expression",
"must",
"be",
"a",
"boolean",
"predicate",
"or",
"a",
"boolean",
"type",
"predicate"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java#L572-L599 |
24,685 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java | TypeTransformationParser.validOperationExpression | private boolean validOperationExpression(Node expr) {
String name = getCallName(expr);
Keywords keyword = nameToKeyword(name);
switch (keyword) {
case COND:
return validConditionalExpression(expr);
case MAPUNION:
return validMapunionExpression(expr);
case MAPRECORD:
... | java | private boolean validOperationExpression(Node expr) {
String name = getCallName(expr);
Keywords keyword = nameToKeyword(name);
switch (keyword) {
case COND:
return validConditionalExpression(expr);
case MAPUNION:
return validMapunionExpression(expr);
case MAPRECORD:
... | [
"private",
"boolean",
"validOperationExpression",
"(",
"Node",
"expr",
")",
"{",
"String",
"name",
"=",
"getCallName",
"(",
"expr",
")",
";",
"Keywords",
"keyword",
"=",
"nameToKeyword",
"(",
"name",
")",
";",
"switch",
"(",
"keyword",
")",
"{",
"case",
"C... | An operation expression is a cond or a mapunion | [
"An",
"operation",
"expression",
"is",
"a",
"cond",
"or",
"a",
"mapunion"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java#L794-L815 |
24,686 | google/closure-compiler | src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java | TypeTransformationParser.validTypeTransformationExpression | private boolean validTypeTransformationExpression(Node expr) {
if (!isValidExpression(expr)) {
warnInvalidExpression("type transformation", expr);
return false;
}
if (isTypeVar(expr) || isTypeName(expr)) {
return true;
}
// Check for valid keyword
String name = getCallName(expr... | java | private boolean validTypeTransformationExpression(Node expr) {
if (!isValidExpression(expr)) {
warnInvalidExpression("type transformation", expr);
return false;
}
if (isTypeVar(expr) || isTypeName(expr)) {
return true;
}
// Check for valid keyword
String name = getCallName(expr... | [
"private",
"boolean",
"validTypeTransformationExpression",
"(",
"Node",
"expr",
")",
"{",
"if",
"(",
"!",
"isValidExpression",
"(",
"expr",
")",
")",
"{",
"warnInvalidExpression",
"(",
"\"type transformation\"",
",",
"expr",
")",
";",
"return",
"false",
";",
"}"... | Checks the structure of the AST of a type transformation expression
in @template T := TTLExp =: | [
"Checks",
"the",
"structure",
"of",
"the",
"AST",
"of",
"a",
"type",
"transformation",
"expression",
"in"
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java#L821-L845 |
24,687 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessCommonJSModules.java | ProcessCommonJSModules.removeIIFEWrapper | private boolean removeIIFEWrapper(Node root) {
checkState(root.isScript());
Node n = root.getFirstChild();
// Sometimes scripts start with a semicolon for easy concatenation.
// Skip any empty statements from those
while (n != null && n.isEmpty()) {
n = n.getNext();
}
// An IIFE wrap... | java | private boolean removeIIFEWrapper(Node root) {
checkState(root.isScript());
Node n = root.getFirstChild();
// Sometimes scripts start with a semicolon for easy concatenation.
// Skip any empty statements from those
while (n != null && n.isEmpty()) {
n = n.getNext();
}
// An IIFE wrap... | [
"private",
"boolean",
"removeIIFEWrapper",
"(",
"Node",
"root",
")",
"{",
"checkState",
"(",
"root",
".",
"isScript",
"(",
")",
")",
";",
"Node",
"n",
"=",
"root",
".",
"getFirstChild",
"(",
")",
";",
"// Sometimes scripts start with a semicolon for easy concatena... | UMD modules are often wrapped in an IIFE for cases where they are used as scripts instead of
modules. Remove the wrapper.
@return Whether an IIFE wrapper was found and removed. | [
"UMD",
"modules",
"are",
"often",
"wrapped",
"in",
"an",
"IIFE",
"for",
"cases",
"where",
"they",
"are",
"used",
"as",
"scripts",
"instead",
"of",
"modules",
".",
"Remove",
"the",
"wrapper",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessCommonJSModules.java#L398-L468 |
24,688 | google/closure-compiler | src/com/google/javascript/jscomp/ProcessCommonJSModules.java | ProcessCommonJSModules.removeWebpackModuleShim | private void removeWebpackModuleShim(Node root) {
checkState(root.isScript());
Node n = root.getFirstChild();
// Sometimes scripts start with a semicolon for easy concatenation.
// Skip any empty statements from those
while (n != null && n.isEmpty()) {
n = n.getNext();
}
// An IIFE w... | java | private void removeWebpackModuleShim(Node root) {
checkState(root.isScript());
Node n = root.getFirstChild();
// Sometimes scripts start with a semicolon for easy concatenation.
// Skip any empty statements from those
while (n != null && n.isEmpty()) {
n = n.getNext();
}
// An IIFE w... | [
"private",
"void",
"removeWebpackModuleShim",
"(",
"Node",
"root",
")",
"{",
"checkState",
"(",
"root",
".",
"isScript",
"(",
")",
")",
";",
"Node",
"n",
"=",
"root",
".",
"getFirstChild",
"(",
")",
";",
"// Sometimes scripts start with a semicolon for easy concat... | For AMD wrappers, webpack adds a shim for the "module" variable. We need that to be a free var
so we remove the shim. | [
"For",
"AMD",
"wrappers",
"webpack",
"adds",
"a",
"shim",
"for",
"the",
"module",
"variable",
".",
"We",
"need",
"that",
"to",
"be",
"a",
"free",
"var",
"so",
"we",
"remove",
"the",
"shim",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessCommonJSModules.java#L474-L554 |
24,689 | google/closure-compiler | src/com/google/javascript/jscomp/LinkedFlowScope.java | LinkedFlowScope.createEntryLattice | public static LinkedFlowScope createEntryLattice(TypedScope scope) {
return new LinkedFlowScope(HamtPMap.<TypedScope, OverlayScope>empty(), scope, scope);
} | java | public static LinkedFlowScope createEntryLattice(TypedScope scope) {
return new LinkedFlowScope(HamtPMap.<TypedScope, OverlayScope>empty(), scope, scope);
} | [
"public",
"static",
"LinkedFlowScope",
"createEntryLattice",
"(",
"TypedScope",
"scope",
")",
"{",
"return",
"new",
"LinkedFlowScope",
"(",
"HamtPMap",
".",
"<",
"TypedScope",
",",
"OverlayScope",
">",
"empty",
"(",
")",
",",
"scope",
",",
"scope",
")",
";",
... | Creates an entry lattice for the flow. | [
"Creates",
"an",
"entry",
"lattice",
"for",
"the",
"flow",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/LinkedFlowScope.java#L98-L100 |
24,690 | google/closure-compiler | src/com/google/javascript/jscomp/LinkedFlowScope.java | LinkedFlowScope.getSlot | @Override
public StaticTypedSlot getSlot(String name) {
OverlayScope scope = getOverlayScopeForVar(name, false);
return scope != null ? scope.getSlot(name) : syntacticScope.getSlot(name);
} | java | @Override
public StaticTypedSlot getSlot(String name) {
OverlayScope scope = getOverlayScopeForVar(name, false);
return scope != null ? scope.getSlot(name) : syntacticScope.getSlot(name);
} | [
"@",
"Override",
"public",
"StaticTypedSlot",
"getSlot",
"(",
"String",
"name",
")",
"{",
"OverlayScope",
"scope",
"=",
"getOverlayScopeForVar",
"(",
"name",
",",
"false",
")",
";",
"return",
"scope",
"!=",
"null",
"?",
"scope",
".",
"getSlot",
"(",
"name",
... | Get the slot for the given symbol. | [
"Get",
"the",
"slot",
"for",
"the",
"given",
"symbol",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/LinkedFlowScope.java#L175-L179 |
24,691 | google/closure-compiler | src/com/google/javascript/jscomp/LinkedFlowScope.java | LinkedFlowScope.equalSlots | private static boolean equalSlots(StaticTypedSlot slotA, StaticTypedSlot slotB) {
return slotA == slotB || !slotA.getType().differsFrom(slotB.getType());
} | java | private static boolean equalSlots(StaticTypedSlot slotA, StaticTypedSlot slotB) {
return slotA == slotB || !slotA.getType().differsFrom(slotB.getType());
} | [
"private",
"static",
"boolean",
"equalSlots",
"(",
"StaticTypedSlot",
"slotA",
",",
"StaticTypedSlot",
"slotB",
")",
"{",
"return",
"slotA",
"==",
"slotB",
"||",
"!",
"slotA",
".",
"getType",
"(",
")",
".",
"differsFrom",
"(",
"slotB",
".",
"getType",
"(",
... | Determines whether two slots are meaningfully different for the purposes of data flow analysis. | [
"Determines",
"whether",
"two",
"slots",
"are",
"meaningfully",
"different",
"for",
"the",
"purposes",
"of",
"data",
"flow",
"analysis",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/LinkedFlowScope.java#L302-L304 |
24,692 | google/closure-compiler | src/com/google/javascript/jscomp/PerformanceTracker.java | PerformanceTracker.updateAfterDeserialize | void updateAfterDeserialize(Node jsRoot) {
// TODO(bradfordcsmith): Restore line counts for inputs and externs.
this.jsRoot = jsRoot;
if (!tracksAstSize()) {
return;
}
this.initAstSize = this.astSize = NodeUtil.countAstSize(this.jsRoot);
if (!tracksSize()) {
return;
}
Perform... | java | void updateAfterDeserialize(Node jsRoot) {
// TODO(bradfordcsmith): Restore line counts for inputs and externs.
this.jsRoot = jsRoot;
if (!tracksAstSize()) {
return;
}
this.initAstSize = this.astSize = NodeUtil.countAstSize(this.jsRoot);
if (!tracksSize()) {
return;
}
Perform... | [
"void",
"updateAfterDeserialize",
"(",
"Node",
"jsRoot",
")",
"{",
"// TODO(bradfordcsmith): Restore line counts for inputs and externs.",
"this",
".",
"jsRoot",
"=",
"jsRoot",
";",
"if",
"(",
"!",
"tracksAstSize",
"(",
")",
")",
"{",
"return",
";",
"}",
"this",
"... | Updates the saved jsRoot and resets the size tracking fields accordingly.
@param jsRoot | [
"Updates",
"the",
"saved",
"jsRoot",
"and",
"resets",
"the",
"size",
"tracking",
"fields",
"accordingly",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PerformanceTracker.java#L125-L141 |
24,693 | google/closure-compiler | src/com/google/javascript/jscomp/PerformanceTracker.java | PerformanceTracker.recordPassStop | void recordPassStop(String passName, long runtime) {
int allocMem = getAllocatedMegabytes();
Stats logStats = this.currentPass.pop();
checkState(passName.equals(logStats.pass));
this.log.add(logStats);
// Update fields that aren't related to code size
logStats.runtime = runtime;
logStats.al... | java | void recordPassStop(String passName, long runtime) {
int allocMem = getAllocatedMegabytes();
Stats logStats = this.currentPass.pop();
checkState(passName.equals(logStats.pass));
this.log.add(logStats);
// Update fields that aren't related to code size
logStats.runtime = runtime;
logStats.al... | [
"void",
"recordPassStop",
"(",
"String",
"passName",
",",
"long",
"runtime",
")",
"{",
"int",
"allocMem",
"=",
"getAllocatedMegabytes",
"(",
")",
";",
"Stats",
"logStats",
"=",
"this",
".",
"currentPass",
".",
"pop",
"(",
")",
";",
"checkState",
"(",
"pass... | Collects information about a pass P after P finishes running, eg, how much
time P took and what was its impact on code size.
@param passName short name of the pass
@param runtime execution time in milliseconds | [
"Collects",
"information",
"about",
"a",
"pass",
"P",
"after",
"P",
"finishes",
"running",
"eg",
"how",
"much",
"time",
"P",
"took",
"and",
"what",
"was",
"its",
"impact",
"on",
"code",
"size",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PerformanceTracker.java#L150-L168 |
24,694 | google/closure-compiler | src/com/google/javascript/jscomp/deps/DependencyFile.java | DependencyFile.loadGraph | private void loadGraph() throws ServiceException {
dependencies.clear();
logger.info("Loading dependency graph");
// Parse the deps.js file.
ErrorManager errorManager = new LoggerErrorManager(logger);
DepsFileParser parser =
new DepsFileParser(errorManager);
List<DependencyInfo> depInf... | java | private void loadGraph() throws ServiceException {
dependencies.clear();
logger.info("Loading dependency graph");
// Parse the deps.js file.
ErrorManager errorManager = new LoggerErrorManager(logger);
DepsFileParser parser =
new DepsFileParser(errorManager);
List<DependencyInfo> depInf... | [
"private",
"void",
"loadGraph",
"(",
")",
"throws",
"ServiceException",
"{",
"dependencies",
".",
"clear",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"Loading dependency graph\"",
")",
";",
"// Parse the deps.js file.",
"ErrorManager",
"errorManager",
"=",
"new",
... | Loads the dependency graph. | [
"Loads",
"the",
"dependency",
"graph",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/DependencyFile.java#L85-L125 |
24,695 | google/closure-compiler | src/com/google/javascript/jscomp/AstFactory.java | AstFactory.createIf | Node createIf(Node cond, Node then) {
return IR.ifNode(cond, then);
} | java | Node createIf(Node cond, Node then) {
return IR.ifNode(cond, then);
} | [
"Node",
"createIf",
"(",
"Node",
"cond",
",",
"Node",
"then",
")",
"{",
"return",
"IR",
".",
"ifNode",
"(",
"cond",
",",
"then",
")",
";",
"}"
] | Returns a new IF node.
<p>Blocks have no type information, so this is functionally the same as calling {@code
IR.ifNode(cond, then)}. It exists so that a pass can be consistent about always using {@code
AstFactory} to create new nodes. | [
"Returns",
"a",
"new",
"IF",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L132-L134 |
24,696 | google/closure-compiler | src/com/google/javascript/jscomp/AstFactory.java | AstFactory.createFor | Node createFor(Node init, Node cond, Node incr, Node body) {
return IR.forNode(init, cond, incr, body);
} | java | Node createFor(Node init, Node cond, Node incr, Node body) {
return IR.forNode(init, cond, incr, body);
} | [
"Node",
"createFor",
"(",
"Node",
"init",
",",
"Node",
"cond",
",",
"Node",
"incr",
",",
"Node",
"body",
")",
"{",
"return",
"IR",
".",
"forNode",
"(",
"init",
",",
"cond",
",",
"incr",
",",
"body",
")",
";",
"}"
] | Returns a new FOR node.
<p>Blocks have no type information, so this is functionally the same as calling {@code
IR.forNode(init, cond, incr, body)}. It exists so that a pass can be consistent about always
using {@code AstFactory} to create new nodes. | [
"Returns",
"a",
"new",
"FOR",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L154-L156 |
24,697 | google/closure-compiler | src/com/google/javascript/jscomp/AstFactory.java | AstFactory.createThisForFunction | Node createThisForFunction(Node functionNode) {
final Node result = IR.thisNode();
if (isAddingTypes()) {
result.setJSType(getTypeOfThisForFunctionNode(functionNode));
}
return result;
} | java | Node createThisForFunction(Node functionNode) {
final Node result = IR.thisNode();
if (isAddingTypes()) {
result.setJSType(getTypeOfThisForFunctionNode(functionNode));
}
return result;
} | [
"Node",
"createThisForFunction",
"(",
"Node",
"functionNode",
")",
"{",
"final",
"Node",
"result",
"=",
"IR",
".",
"thisNode",
"(",
")",
";",
"if",
"(",
"isAddingTypes",
"(",
")",
")",
"{",
"result",
".",
"setJSType",
"(",
"getTypeOfThisForFunctionNode",
"("... | Creates a THIS node with the correct type for the given function node. | [
"Creates",
"a",
"THIS",
"node",
"with",
"the",
"correct",
"type",
"for",
"the",
"given",
"function",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L257-L263 |
24,698 | google/closure-compiler | src/com/google/javascript/jscomp/AstFactory.java | AstFactory.createSuperForFunction | Node createSuperForFunction(Node functionNode) {
final Node result = IR.superNode();
if (isAddingTypes()) {
result.setJSType(getTypeOfSuperForFunctionNode(functionNode));
}
return result;
} | java | Node createSuperForFunction(Node functionNode) {
final Node result = IR.superNode();
if (isAddingTypes()) {
result.setJSType(getTypeOfSuperForFunctionNode(functionNode));
}
return result;
} | [
"Node",
"createSuperForFunction",
"(",
"Node",
"functionNode",
")",
"{",
"final",
"Node",
"result",
"=",
"IR",
".",
"superNode",
"(",
")",
";",
"if",
"(",
"isAddingTypes",
"(",
")",
")",
"{",
"result",
".",
"setJSType",
"(",
"getTypeOfSuperForFunctionNode",
... | Creates a SUPER node with the correct type for the given function node. | [
"Creates",
"a",
"SUPER",
"node",
"with",
"the",
"correct",
"type",
"for",
"the",
"given",
"function",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L266-L272 |
24,699 | google/closure-compiler | src/com/google/javascript/jscomp/AstFactory.java | AstFactory.createThisAliasReferenceForFunction | Node createThisAliasReferenceForFunction(String aliasName, Node functionNode) {
final Node result = IR.name(aliasName);
if (isAddingTypes()) {
result.setJSType(getTypeOfThisForFunctionNode(functionNode));
}
return result;
} | java | Node createThisAliasReferenceForFunction(String aliasName, Node functionNode) {
final Node result = IR.name(aliasName);
if (isAddingTypes()) {
result.setJSType(getTypeOfThisForFunctionNode(functionNode));
}
return result;
} | [
"Node",
"createThisAliasReferenceForFunction",
"(",
"String",
"aliasName",
",",
"Node",
"functionNode",
")",
"{",
"final",
"Node",
"result",
"=",
"IR",
".",
"name",
"(",
"aliasName",
")",
";",
"if",
"(",
"isAddingTypes",
"(",
")",
")",
"{",
"result",
".",
... | Creates a NAME node having the type of "this" appropriate for the given function node. | [
"Creates",
"a",
"NAME",
"node",
"having",
"the",
"type",
"of",
"this",
"appropriate",
"for",
"the",
"given",
"function",
"node",
"."
] | d81e36740f6a9e8ac31a825ee8758182e1dc5aae | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L309-L315 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.