@Immutable public final class ClosureCodingConvention extends CodingConventions.Proxy
CodingConvention.AssertionFunctionLookup, CodingConvention.AssertionFunctionSpec, CodingConvention.Bind, CodingConvention.Cache, CodingConvention.DelegateRelationship, CodingConvention.ObjectLiteralCast, CodingConvention.SubclassRelationship, CodingConvention.SubclassType
nextConvention
Constructor and Description |
---|
ClosureCodingConvention() |
ClosureCodingConvention(CodingConvention wrapped) |
Modifier and Type | Method and Description |
---|---|
void |
applySingletonGetter(NominalTypeBuilder classType,
FunctionType getterType)
In many JS libraries, the function that adds a singleton getter to a class
adds properties to the class.
|
void |
applySubclassRelationship(NominalTypeBuilder parent,
NominalTypeBuilder child,
CodingConvention.SubclassType type)
Closure's goog.inherits adds a
superClass_ property to the
subclass, and a constructor property. |
CodingConvention.Cache |
describeCachingCall(Node node)
Builds a
CodingConvention.Cache instance from the given call node and returns that instance, or null
if the Node does not resemble a cache utility call. |
CodingConvention.Bind |
describeFunctionBind(Node n,
boolean callerChecksTypes,
boolean iCheckTypes)
A Bind instance or null.
|
java.lang.String |
extractClassNameIfProvide(Node node,
Node parent)
Extracts X from goog.provide('X'), if the applied Node is goog.
|
java.lang.String |
extractClassNameIfRequire(Node node,
Node parent)
Extracts X from goog.require('X'), if the applied Node is goog.
|
boolean |
extractIsModuleFile(Node node,
Node parent)
Convenience method for determining if the node indicates the file
is a "module" file (a file whose top level symbols are not in global
scope).
|
java.lang.String |
getAbstractMethodName()
Function name for abstract methods.
|
com.google.common.collect.ImmutableCollection<CodingConvention.AssertionFunctionSpec> |
getAssertionFunctions()
Returns the set of AssertionFunction.
|
CodingConvention.SubclassRelationship |
getClassesDefinedByCall(Node callNode)
Checks if the given method defines a subclass relationship,
and if it does, returns information on that relationship.
|
java.lang.String |
getExportPropertyFunction()
Use closure's implementation.
|
java.lang.String |
getExportSymbolFunction()
Use closure's implementation.
|
java.lang.String |
getGlobalObject()
Gets the name of the global object.
|
com.google.common.collect.ImmutableCollection<java.lang.String> |
getIndirectlyDeclaredProperties()
Gets a collection of all properties that are defined indirectly on global
objects.
|
CodingConvention.ObjectLiteralCast |
getObjectLiteralCast(Node callNode)
Checks if the given method performs a object literal cast, and if it does,
returns information on the cast.
|
java.lang.String |
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.
|
java.util.List<java.lang.String> |
identifyTypeDeclarationCall(Node n)
Checks if the given CALL node is forward-declaring any types,
and returns the name of the types if it is.
|
boolean |
isAliasingGlobalThis(Node n)
Whether this statement is creating an alias of the global object
|
boolean |
isClassFactoryCall(Node callNode)
Checks if the given method is a call to a class factory, such a factory returns a
unique class.
|
boolean |
isFunctionCallThatAlwaysThrows(Node n)
Used by CheckMissingReturn.
|
boolean |
isPrivate(java.lang.String name)
Checks whether a name should be considered private.
|
boolean |
isPropertyRenameFunction(java.lang.String name)
Whether this CALL function is returning the string name for a property, but allows renaming.
|
boolean |
isPropertyTestFunction(Node call)
Whether this CALL function is testing for the existence of a property.
|
boolean |
isSuperClassReference(java.lang.String propertyName)
Returns true if passed a string referring to the superclass.
|
applyDelegateRelationship, blockRenamingForProperty, checkForCallingConventionDefinitions, defineDelegateProxyPrototypeProperties, describeFunctionBind, getDelegateRelationship, getDelegateSuperclassName, getPackageName, hasPrivacyConvention, isConstant, isConstantKey, isExported, isExported, isInlinableFunction, isOptionalParameter, isPrototypeAlias, isValidEnumKey, isVarArgsParameter
public ClosureCodingConvention()
public ClosureCodingConvention(CodingConvention wrapped)
public void applySubclassRelationship(NominalTypeBuilder parent, NominalTypeBuilder child, CodingConvention.SubclassType type)
superClass_
property to the
subclass, and a constructor
property.applySubclassRelationship
in interface CodingConvention
applySubclassRelationship
in class CodingConventions.Proxy
public CodingConvention.SubclassRelationship getClassesDefinedByCall(Node callNode)
Understands several different inheritance patterns that occur in
Google code (various uses of inherits
and mixin
).
getClassesDefinedByCall
in interface CodingConvention
getClassesDefinedByCall
in class CodingConventions.Proxy
callNode
- A CALL node.public boolean isClassFactoryCall(Node callNode)
CodingConvention
isClassFactoryCall
in interface CodingConvention
isClassFactoryCall
in class CodingConventions.Proxy
callNode
- A CALL node.public boolean isSuperClassReference(java.lang.String propertyName)
CodingConvention
isSuperClassReference
in interface CodingConvention
isSuperClassReference
in class CodingConventions.Proxy
public boolean extractIsModuleFile(Node node, Node parent)
CodingConvention
extractIsModuleFile
in interface CodingConvention
extractIsModuleFile
in class CodingConventions.Proxy
public java.lang.String extractClassNameIfProvide(Node node, Node parent)
extractClassNameIfProvide
in interface CodingConvention
extractClassNameIfProvide
in class CodingConventions.Proxy
public java.lang.String extractClassNameIfRequire(Node node, Node parent)
extractClassNameIfRequire
in interface CodingConvention
extractClassNameIfRequire
in class CodingConventions.Proxy
public java.lang.String getExportPropertyFunction()
getExportPropertyFunction
in interface CodingConvention
getExportPropertyFunction
in class CodingConventions.Proxy
public java.lang.String getExportSymbolFunction()
getExportSymbolFunction
in interface CodingConvention
getExportSymbolFunction
in class CodingConventions.Proxy
public java.util.List<java.lang.String> identifyTypeDeclarationCall(Node n)
CodingConvention
identifyTypeDeclarationCall
in interface CodingConvention
identifyTypeDeclarationCall
in class CodingConventions.Proxy
public java.lang.String getAbstractMethodName()
CodingConvention
getAbstractMethodName
in interface CodingConvention
getAbstractMethodName
in class CodingConventions.Proxy
public java.lang.String getSingletonGetterClassName(Node callNode)
CodingConvention
getSingletonGetterClassName
in interface CodingConvention
getSingletonGetterClassName
in class CodingConventions.Proxy
callNode
- A CALL node.public void applySingletonGetter(NominalTypeBuilder classType, FunctionType getterType)
CodingConvention
applySingletonGetter
in interface CodingConvention
applySingletonGetter
in class CodingConventions.Proxy
public java.lang.String getGlobalObject()
CodingConvention
getGlobalObject
in interface CodingConvention
getGlobalObject
in class CodingConventions.Proxy
public boolean isAliasingGlobalThis(Node n)
CodingConvention
isAliasingGlobalThis
in interface CodingConvention
isAliasingGlobalThis
in class CodingConventions.Proxy
public boolean isPropertyTestFunction(Node call)
CodingConvention
isPropertyTestFunction
in interface CodingConvention
isPropertyTestFunction
in class CodingConventions.Proxy
public boolean isPropertyRenameFunction(java.lang.String name)
CodingConvention
isPropertyRenameFunction
in interface CodingConvention
isPropertyRenameFunction
in class CodingConventions.Proxy
public boolean isFunctionCallThatAlwaysThrows(Node n)
CodingConvention
isFunctionCallThatAlwaysThrows
in interface CodingConvention
isFunctionCallThatAlwaysThrows
in class CodingConventions.Proxy
public CodingConvention.ObjectLiteralCast getObjectLiteralCast(Node callNode)
CodingConvention
getObjectLiteralCast
in interface CodingConvention
getObjectLiteralCast
in class CodingConventions.Proxy
callNode
- A CALL node.public boolean isPrivate(java.lang.String name)
CodingConvention
isPrivate
in interface CodingConvention
isPrivate
in class CodingConventions.Proxy
name
- The name of a global variable or function, or a method or
property.true
if the name should be considered private.public com.google.common.collect.ImmutableCollection<CodingConvention.AssertionFunctionSpec> getAssertionFunctions()
CodingConvention
getAssertionFunctions
in interface CodingConvention
getAssertionFunctions
in class CodingConventions.Proxy
public CodingConvention.Bind describeFunctionBind(Node n, boolean callerChecksTypes, boolean iCheckTypes)
CodingConvention
describeFunctionBind
in interface CodingConvention
describeFunctionBind
in class CodingConventions.Proxy
callerChecksTypes
- Trust that the caller of this method has verified
that the bound node has a function type.iCheckTypes
- Check that the bound node has a function type.public CodingConvention.Cache describeCachingCall(Node node)
CodingConvention
CodingConvention.Cache
instance from the given call node and returns that instance, or null
if the Node
does not resemble a cache utility call.
This should match calls to a cache utility method. This type of node is specially considered for side-effects since conventionally storing something on a cache object would be seen as a side-effect.
describeCachingCall
in interface CodingConvention
describeCachingCall
in class CodingConventions.Proxy
public com.google.common.collect.ImmutableCollection<java.lang.String> getIndirectlyDeclaredProperties()
CodingConvention
getIndirectlyDeclaredProperties
in interface CodingConvention
getIndirectlyDeclaredProperties
in class CodingConventions.Proxy
Copyright © 2009-2019 Google. All Rights Reserved.