Package com.google.javascript.jscomp
Class ClosureCodingConvention
java.lang.Object
com.google.javascript.jscomp.CodingConventions.Proxy
com.google.javascript.jscomp.ClosureCodingConvention
- All Implemented Interfaces:
CodingConvention,Serializable
This describes the Closure-specific JavaScript coding conventions.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA function that will throw an exception when if the value is not an instanceof a specific type.Nested classes/interfaces inherited from interface com.google.javascript.jscomp.CodingConvention
CodingConvention.AssertionFunctionSpec, CodingConvention.Bind, CodingConvention.DelegateRelationship, CodingConvention.ObjectLiteralCast, CodingConvention.SubclassRelationship, CodingConvention.SubclassType -
Field Summary
Fields inherited from class com.google.javascript.jscomp.CodingConventions.Proxy
nextConvention -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplySingletonGetter(FunctionType functionType, FunctionType getterType, ObjectType objectType) In many JS libraries, the function that adds a singleton getter to a class adds properties to the class.voidapplySubclassRelationship(FunctionType parentCtor, FunctionType childCtor, CodingConvention.SubclassType type) Closure's goog.inherits adds asuperClass_property to the subclass, and aconstructorproperty.describeFunctionBind(Node n, boolean useTypeInfo) A Bind instance or null.extractClassNameIfProvide(Node node, Node parent) Extracts X from goog.provide('X'), if the applied Node is goog.extractClassNameIfRequire(Node node, Node parent) Extracts X from goog.require('X'), if the applied Node is goog.Function name for abstract methods.Returns the set of AssertionFunction.getClassesDefinedByCall(Node callNode) Checks if the given method defines a subclass relationship, and if it does, returns information on that relationship.Use closure's implementation.Use closure's implementation.Gets the name of the global object.Gets a collection of all properties that are defined indirectly on global objects.getObjectLiteralCast(Node callNode) Checks if the given method performs a object literal cast, and if it does, returns information on the cast.getSingletonGetterClassName(Node callNode) Checks if the given method defines a singleton getter, and if it does, returns the name of the class with the singleton getter.Checks if the given CALL node is forward-declaring any types, and returns the name of the types if it is.booleanisOptionalParameter(Node parameter) This checks whether a given parameter name should be treated as an optional parameter as far as type checking or function call arg count checking is concerned.booleanChecks whether a name should be considered private.booleanisPropertyTestFunction(Node call) Whether this CALL function is testing for the existence of a property.booleanisSuperClassReference(String propertyName) Returns true if passed a string referring to the superclass.booleanisVarArgsParameter(Node parameter) This checks whether a given parameter should be treated as a marker for a variable argument list function.Methods inherited from class com.google.javascript.jscomp.CodingConventions.Proxy
applyDelegateRelationship, checkForCallingConventionDefiningCalls, defineDelegateProxyPrototypeProperties, describeFunctionBind, getDelegateRelationship, getDelegateSuperclassName, isConstant, isConstantKey, isExported, isExported, isInlinableFunction, isPrototypeAlias, isValidEnumKey
-
Constructor Details
-
ClosureCodingConvention
public ClosureCodingConvention() -
ClosureCodingConvention
-
-
Method Details
-
applySubclassRelationship
public void applySubclassRelationship(FunctionType parentCtor, FunctionType childCtor, CodingConvention.SubclassType type) Closure's goog.inherits adds asuperClass_property to the subclass, and aconstructorproperty.- Specified by:
applySubclassRelationshipin interfaceCodingConvention- Overrides:
applySubclassRelationshipin classCodingConventions.Proxy
-
getClassesDefinedByCall
Checks if the given method defines a subclass relationship, and if it does, returns information on that relationship. By default, always returns null. Meant to be overridden by subclasses.Understands several different inheritance patterns that occur in Google code (various uses of
inheritsandmixin).- Specified by:
getClassesDefinedByCallin interfaceCodingConvention- Overrides:
getClassesDefinedByCallin classCodingConventions.Proxy- Parameters:
callNode- A CALL node.
-
isSuperClassReference
Description copied from interface:CodingConventionReturns true if passed a string referring to the superclass. The string will usually be from the string node at the right of a GETPROP, e.g. this.superClass_.- Specified by:
isSuperClassReferencein interfaceCodingConvention- Overrides:
isSuperClassReferencein classCodingConventions.Proxy
-
extractClassNameIfProvide
Extracts X from goog.provide('X'), if the applied Node is goog.- Specified by:
extractClassNameIfProvidein interfaceCodingConvention- Overrides:
extractClassNameIfProvidein classCodingConventions.Proxy- Returns:
- The extracted class name, or null.
-
extractClassNameIfRequire
Extracts X from goog.require('X'), if the applied Node is goog.- Specified by:
extractClassNameIfRequirein interfaceCodingConvention- Overrides:
extractClassNameIfRequirein classCodingConventions.Proxy- Returns:
- The extracted class name, or null.
-
getExportPropertyFunction
Use closure's implementation.- Specified by:
getExportPropertyFunctionin interfaceCodingConvention- Overrides:
getExportPropertyFunctionin classCodingConventions.Proxy- Returns:
- closure's function name for exporting properties.
-
getExportSymbolFunction
Use closure's implementation.- Specified by:
getExportSymbolFunctionin interfaceCodingConvention- Overrides:
getExportSymbolFunctionin classCodingConventions.Proxy- Returns:
- closure's function name for exporting symbols.
-
identifyTypeDeclarationCall
Description copied from interface:CodingConventionChecks if the given CALL node is forward-declaring any types, and returns the name of the types if it is.- Specified by:
identifyTypeDeclarationCallin interfaceCodingConvention- Overrides:
identifyTypeDeclarationCallin classCodingConventions.Proxy
-
getAbstractMethodName
Description copied from interface:CodingConventionFunction name for abstract methods. An abstract method can be assigned to an interface method instead of an function expression in order to avoid linter warnings produced by assigning a function without a return value where a return value is expected.- Specified by:
getAbstractMethodNamein interfaceCodingConvention- Overrides:
getAbstractMethodNamein classCodingConventions.Proxy- Returns:
- function name.
-
getSingletonGetterClassName
Description copied from interface:CodingConventionChecks if the given method defines a singleton getter, and if it does, returns the name of the class with the singleton getter. By default, always returns null. Meant to be overridden by subclasses. addSingletonGetter needs a coding convention because in the general case, it can't be inlined. The function inliner sees that it creates an alias to the given class in an inner closure, and bails out.- Specified by:
getSingletonGetterClassNamein interfaceCodingConvention- Overrides:
getSingletonGetterClassNamein classCodingConventions.Proxy- Parameters:
callNode- A CALL node.
-
applySingletonGetter
public void applySingletonGetter(FunctionType functionType, FunctionType getterType, ObjectType objectType) Description copied from interface:CodingConventionIn many JS libraries, the function that adds a singleton getter to a class adds properties to the class.- Specified by:
applySingletonGetterin interfaceCodingConvention- Overrides:
applySingletonGetterin classCodingConventions.Proxy
-
getGlobalObject
Description copied from interface:CodingConventionGets the name of the global object.- Specified by:
getGlobalObjectin interfaceCodingConvention- Overrides:
getGlobalObjectin classCodingConventions.Proxy
-
isPropertyTestFunction
Description copied from interface:CodingConventionWhether this CALL function is testing for the existence of a property.- Specified by:
isPropertyTestFunctionin interfaceCodingConvention- Overrides:
isPropertyTestFunctionin classCodingConventions.Proxy
-
getObjectLiteralCast
Description copied from interface:CodingConventionChecks if the given method performs a object literal cast, and if it does, returns information on the cast. By default, always returns null. Meant to be overridden by subclasses.- Specified by:
getObjectLiteralCastin interfaceCodingConvention- Overrides:
getObjectLiteralCastin classCodingConventions.Proxy- Parameters:
callNode- A CALL node.
-
isOptionalParameter
Description copied from interface:CodingConventionThis checks whether a given parameter name should be treated as an optional parameter as far as type checking or function call arg count checking is concerned. Note that an optional function parameter may be declared as a simple type and is automatically converted to a union of the declared type and Undefined.- Specified by:
isOptionalParameterin interfaceCodingConvention- Overrides:
isOptionalParameterin classCodingConventions.Proxy- Parameters:
parameter- The parameter's node.- Returns:
trueif the parameter should be treated as an optional parameter.
-
isVarArgsParameter
Description copied from interface:CodingConventionThis checks whether a given parameter should be treated as a marker for a variable argument list function. A VarArgs parameter must be the last parameter in a function declaration.- Specified by:
isVarArgsParameterin interfaceCodingConvention- Overrides:
isVarArgsParameterin classCodingConventions.Proxy- Parameters:
parameter- The parameter's node.- Returns:
trueif the parameter should be treated as a variable length parameter.
-
isPrivate
Description copied from interface:CodingConventionChecks whether a name should be considered private. Private global variables and functions can only be referenced within the source file in which they are declared. Private properties and methods should only be accessed by the class that defines them.- Specified by:
isPrivatein interfaceCodingConvention- Overrides:
isPrivatein classCodingConventions.Proxy- Parameters:
name- The name of a global variable or function, or a method or property.- Returns:
trueif the name should be considered private.
-
getAssertionFunctions
Description copied from interface:CodingConventionReturns the set of AssertionFunction.- Specified by:
getAssertionFunctionsin interfaceCodingConvention- Overrides:
getAssertionFunctionsin classCodingConventions.Proxy
-
describeFunctionBind
Description copied from interface:CodingConventionA Bind instance or null.- Specified by:
describeFunctionBindin interfaceCodingConvention- Overrides:
describeFunctionBindin classCodingConventions.ProxyuseTypeInfo- If we believe type information is reliable enough to use to figure out what the bind function is.
-
getIndirectlyDeclaredProperties
Description copied from interface:CodingConventionGets a collection of all properties that are defined indirectly on global objects. (For example, Closure defines superClass_ in the goog.inherits call).- Specified by:
getIndirectlyDeclaredPropertiesin interfaceCodingConvention- Overrides:
getIndirectlyDeclaredPropertiesin classCodingConventions.Proxy
-