Package com.google.javascript.jscomp
Class CodingConventions.Proxy
java.lang.Object
com.google.javascript.jscomp.CodingConventions.Proxy
- All Implemented Interfaces:
CodingConvention,Serializable
- Direct Known Subclasses:
ClosureCodingConvention,GoogleCodingConvention,JqueryCodingConvention
- Enclosing class:
- CodingConventions
A convention that wraps another.
When you want to support a new library, you should subclass this
delegate, and override the methods that you want to customize.
This way, a person using jQuery and Closure Library can create a new
coding convention by creating a jQueryCodingConvention that delegates
to a ClosureCodingConvention that delegates to a DefaultCodingConvention.
- See Also:
-
Nested Class Summary
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyDelegateRelationship(ObjectType delegateSuperclass, ObjectType delegateBase, ObjectType delegator, FunctionType delegateProxy, FunctionType findDelegate) In many JS libraries, the function that creates a delegate relationship also adds properties to the delegator and delegate base.voidapplySingletonGetter(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) In many JS libraries, the function that produces inheritance also adds properties to the superclass and/or subclass.voidcheckForCallingConventionDefiningCalls(Node n, Map<String, String> delegateCallingConventions) Checks for function calls that set the calling conventions on delegate methods.voiddefineDelegateProxyPrototypeProperties(JSTypeRegistry registry, StaticScope<JSType> scope, List<ObjectType> delegateProxyPrototypes, Map<String, String> delegateCallingConventions) Defines the delegate proxy prototype properties.A Bind instance or null.describeFunctionBind(Node n, boolean useTypeInfo) A Bind instance or null.extractClassNameIfProvide(Node node, Node parent) Convenience method for determining provided dependencies amongst different JS scripts.extractClassNameIfRequire(Node node, Node parent) Convenience method for determining required dependencies amongst different JS scripts.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.getDelegateRelationship(Node callNode) Function name used when exporting properties.Function name used when exporting symbols.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.booleanisConstant(String variableName) This checks whether a given variable name, such as a name in all-caps should be treated as if it had the @const annotation.booleanisConstantKey(String keyName) This checks whether a given key of an object literal, such as a name in all-caps should be treated as if it had the @const annotation.final booleanisExported(String name) Should be isExported(name, true) || isExported(name, false);booleanisExported(String name, boolean local) Checks whether a global variable or function name should be treated as exported, or externally referenceable.booleanbooleanisOptionalParameter(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.booleanisPrototypeAlias(Node getProp) Whether this GETPROP node is an alias for an object prototype.booleanisSuperClassReference(String propertyName) Returns true if passed a string referring to the superclass.booleanisValidEnumKey(String key) This checks that a givenkeymay be used as a key for an enum.booleanisVarArgsParameter(Node parameter) This checks whether a given parameter should be treated as a marker for a variable argument list function.
-
Field Details
-
nextConvention
-
-
Constructor Details
-
Proxy
-
-
Method Details
-
isConstant
Description copied from interface:CodingConventionThis checks whether a given variable name, such as a name in all-caps should be treated as if it had the @const annotation.- Specified by:
isConstantin interfaceCodingConvention- Parameters:
variableName- potentially constant variable name- Returns:
trueif the name should be treated as a constant.
-
isConstantKey
Description copied from interface:CodingConventionThis checks whether a given key of an object literal, such as a name in all-caps should be treated as if it had the @const annotation.- Specified by:
isConstantKeyin interfaceCodingConvention
-
isValidEnumKey
Description copied from interface:CodingConventionThis checks that a givenkeymay be used as a key for an enum.- Specified by:
isValidEnumKeyin interfaceCodingConvention- Parameters:
key- the potential key to an enum- Returns:
trueif thekeymay be used as an enum key,falseotherwise
-
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- 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- Parameters:
parameter- The parameter's node.- Returns:
trueif the parameter should be treated as a variable length parameter.
-
isExported
Description copied from interface:CodingConventionChecks whether a global variable or function name should be treated as exported, or externally referenceable.- Specified by:
isExportedin interfaceCodingConvention- Parameters:
name- A global variable or function name.local-trueif the name is a local variable.- Returns:
trueif the name should be considered exported.
-
isExported
Description copied from interface:CodingConventionShould be isExported(name, true) || isExported(name, false);- Specified by:
isExportedin interfaceCodingConvention
-
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- Parameters:
name- The name of a global variable or function, or a method or property.- Returns:
trueif the name should be considered private.
-
getClassesDefinedByCall
Description copied from interface:CodingConventionChecks 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.- Specified by:
getClassesDefinedByCallin interfaceCodingConvention- 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
-
extractClassNameIfProvide
Description copied from interface:CodingConventionConvenience method for determining provided dependencies amongst different JS scripts.- Specified by:
extractClassNameIfProvidein interfaceCodingConvention
-
extractClassNameIfRequire
Description copied from interface:CodingConventionConvenience method for determining required dependencies amongst different JS scripts.- Specified by:
extractClassNameIfRequirein interfaceCodingConvention
-
getExportPropertyFunction
Description copied from interface:CodingConventionFunction name used when exporting properties. Signature: fn(object, publicName, symbol).- Specified by:
getExportPropertyFunctionin interfaceCodingConvention- Returns:
- function name.
-
getExportSymbolFunction
Description copied from interface:CodingConventionFunction name used when exporting symbols. Signature: fn(publicPath, object).- Specified by:
getExportSymbolFunctionin interfaceCodingConvention- Returns:
- function name.
-
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
-
applySubclassRelationship
public void applySubclassRelationship(FunctionType parentCtor, FunctionType childCtor, CodingConvention.SubclassType type) Description copied from interface:CodingConventionIn many JS libraries, the function that produces inheritance also adds properties to the superclass and/or subclass.- Specified by:
applySubclassRelationshipin interfaceCodingConvention
-
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- 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- 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
-
isInlinableFunction
- Specified by:
isInlinableFunctionin interfaceCodingConvention- Returns:
- Whether the function is inlinable by convention.
-
getDelegateRelationship
- Specified by:
getDelegateRelationshipin interfaceCodingConvention- Returns:
- the delegate relationship created by the call or null.
-
applyDelegateRelationship
public void applyDelegateRelationship(ObjectType delegateSuperclass, ObjectType delegateBase, ObjectType delegator, FunctionType delegateProxy, FunctionType findDelegate) Description copied from interface:CodingConventionIn many JS libraries, the function that creates a delegate relationship also adds properties to the delegator and delegate base.- Specified by:
applyDelegateRelationshipin interfaceCodingConvention
-
getDelegateSuperclassName
- Specified by:
getDelegateSuperclassNamein interfaceCodingConvention- Returns:
- the name of the delegate superclass.
-
checkForCallingConventionDefiningCalls
public void checkForCallingConventionDefiningCalls(Node n, Map<String, String> delegateCallingConventions) Description copied from interface:CodingConventionChecks for function calls that set the calling conventions on delegate methods.- Specified by:
checkForCallingConventionDefiningCallsin interfaceCodingConvention
-
defineDelegateProxyPrototypeProperties
public void defineDelegateProxyPrototypeProperties(JSTypeRegistry registry, StaticScope<JSType> scope, List<ObjectType> delegateProxyPrototypes, Map<String, String> delegateCallingConventions) Description copied from interface:CodingConventionDefines the delegate proxy prototype properties. Their types depend on properties of the delegate base methods.- Specified by:
defineDelegateProxyPrototypePropertiesin interfaceCodingConventiondelegateProxyPrototypes- List of delegate proxy prototypes.
-
getGlobalObject
Description copied from interface:CodingConventionGets the name of the global object.- Specified by:
getGlobalObjectin interfaceCodingConvention
-
getAssertionFunctions
Description copied from interface:CodingConventionReturns the set of AssertionFunction.- Specified by:
getAssertionFunctionsin interfaceCodingConvention
-
describeFunctionBind
Description copied from interface:CodingConventionA Bind instance or null.- Specified by:
describeFunctionBindin interfaceCodingConvention
-
describeFunctionBind
Description copied from interface:CodingConventionA Bind instance or null.- Specified by:
describeFunctionBindin interfaceCodingConventionuseTypeInfo- If we believe type information is reliable enough to use to figure out what the bind function is.
-
isPropertyTestFunction
Description copied from interface:CodingConventionWhether this CALL function is testing for the existence of a property.- Specified by:
isPropertyTestFunctionin interfaceCodingConvention
-
isPrototypeAlias
Description copied from interface:CodingConventionWhether this GETPROP node is an alias for an object prototype.- Specified by:
isPrototypeAliasin interfaceCodingConvention
-
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- Parameters:
callNode- A CALL node.
-
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
-