public class JMethod extends JNode implements JMember, CanBeAbstract
Modifier and Type | Class and Description |
---|---|
static class |
JMethod.Specialization
AST representation of @SpecializeMethod.
|
HasName.Util
HasJsInfo.JsMemberType
Modifier and Type | Field and Description |
---|---|
static Comparator<JMethod> |
BY_SIGNATURE_COMPARATOR |
static JMethod |
NULL_METHOD |
protected String |
signature |
BY_NAME_COMPARATOR
Constructor and Description |
---|
JMethod(SourceInfo info,
String name,
JDeclaredType enclosingType,
JType returnType,
boolean isAbstract,
boolean isStatic,
boolean isFinal,
AccessModifier access)
These are only supposed to be constructed by JProgram.
|
Modifier and Type | Method and Description |
---|---|
void |
addOverriddenMethod(JMethod overriddenMethod)
Add a method that this method overrides.
|
void |
addOverridingMethod(JMethod overridingMethod)
Add a method that overrides this method.
|
void |
addThrownException(JClassType exceptionType) |
void |
addThrownExceptions(List<JClassType> exceptionTypes) |
boolean |
canBeImplementedExternally() |
boolean |
canBePolymorphic()
Returns true if this method can participate in virtual dispatch.
|
boolean |
canBeReferencedExternally() |
JParameter |
cloneParameter(JParameter from)
Adds a new parameter to this method that is a copy of
from . |
JParameter |
createFinalParameter(SourceInfo info,
String name,
JType type)
Adds a new final parameter to this method.
|
JParameter |
createParameter(SourceInfo info,
String name,
JType type)
Adds a new parameter to this method.
|
JParameter |
createParameter(SourceInfo info,
String name,
JType type,
boolean isFinal,
boolean isVarargs)
Adds a new parameter to this method.
|
JParameter |
createThisParameter(SourceInfo info,
JType type)
Creates a parameter to hold the value of this in devirtualized methods.
|
void |
disallowDevirtualization() |
boolean |
exposesNonJsMember()
Returns
true if this method is the first JsMember in the method hierarchy that exposes
an existing non-JsMember inside a class. |
boolean |
exposesPackagePrivateMethod()
Returns
true if this method is the first method in the method hierarchy that increases
the visibility of a package private method. |
void |
freezeParamTypes() |
AccessModifier |
getAccess() |
JAbstractMethodBody |
getBody() |
JDeclaredType |
getEnclosingType() |
static JMethod |
getExternalizedMethod(String fullClassName,
String signature,
boolean isStatic)
Creates an externalized representation for a method that needs to be resolved.
|
InliningMode |
getInliningMode() |
HasJsInfo.JsMemberType |
getJsMemberType() |
String |
getJsName() |
String |
getJsNamespace() |
String |
getJsniSignature(boolean includeEnclosingClass,
boolean includeReturnType) |
String |
getName() |
List<JType> |
getOriginalParamTypes() |
JType |
getOriginalReturnType() |
Set<JMethod> |
getOverriddenMethods()
Returns the transitive closure of all the methods this method overrides; this set is ordered
from most specific to least specific, where class methods appear before interface methods.
|
Set<JMethod> |
getOverridingMethods()
Returns the transitive closure of all the methods that override this method; caveat this
list is only complete in monolithic compiles and should not be used in incremental compiles.
|
List<JParameter> |
getParams()
Returns the parameters of this method.
|
String |
getQualifiedJsName() |
String |
getQualifiedName() |
String |
getSignature() |
JMethod.Specialization |
getSpecialization() |
Set<String> |
getSuppressedWarnings() |
List<JClassType> |
getThrownExceptions() |
JType |
getType()
Returns the type of this expression.
|
boolean |
hasSideEffects() |
boolean |
isAbstract() |
boolean |
isConstructor() |
boolean |
isDefaultMethod() |
boolean |
isDevirtualizationAllowed() |
boolean |
isExternal() |
boolean |
isFinal() |
boolean |
isForwarding() |
boolean |
isInliningAllowed() |
boolean |
isJsConstructor() |
boolean |
isJsInteropEntryPoint() |
boolean |
isJsMethodVarargs() |
boolean |
isJsNative() |
boolean |
isJsniMethod() |
boolean |
isJsOverlay() |
boolean |
isOrOverridesJsFunctionMethod() |
boolean |
isPackagePrivate() |
boolean |
isPrivate() |
boolean |
isPublic() |
boolean |
isStatic() |
boolean |
isSynthetic() |
boolean |
isSyntheticAccidentalOverride() |
boolean |
needsDynamicDispatch()
Returns
true if this method can participate in instance
dispatch. |
void |
removeParam(int index)
Removes the parameter at the specified index.
|
void |
removeSpecialization() |
void |
resolve(JType originalReturnType,
List<JType> originalParamTypes,
JType returnType,
List<JClassType> thrownExceptions)
Resolve an external references during AST stitching.
|
void |
setAbstract(boolean isAbstract) |
void |
setBody(JAbstractMethodBody body) |
void |
setDefaultMethod(boolean defaultMethod) |
void |
setFinal() |
void |
setFinal(boolean isFinal) |
void |
setForwarding() |
void |
setHasSideEffects(boolean hasSideEffects) |
void |
setInliningMode(InliningMode inliningMode) |
void |
setJsMemberInfo(HasJsInfo.JsMemberType type,
String namespace,
String name,
boolean exported) |
void |
setJsOverlay() |
void |
setOriginalTypes(JType returnType,
List<JType> paramTypes) |
void |
setSpecialization(List<JType> paramTypes,
JType returnsType,
String targetMethod) |
void |
setSuppressedWarnings(Set<String> suppressedWarnings) |
void |
setSynthetic() |
void |
setSyntheticAccidentalOverride() |
void |
setType(JType newType) |
void |
traverse(JVisitor visitor,
Context ctx)
Causes this object to have the visitor visit itself and its children.
|
protected void |
visitChildren(JVisitor visitor) |
protected Object |
writeReplace() |
getSourceInfo, setSourceInfo, toSource, toString
getSourceInfo
public static final Comparator<JMethod> BY_SIGNATURE_COMPARATOR
public static final JMethod NULL_METHOD
protected transient String signature
public JMethod(SourceInfo info, String name, JDeclaredType enclosingType, JType returnType, boolean isAbstract, boolean isStatic, boolean isFinal, AccessModifier access)
public void setJsMemberInfo(HasJsInfo.JsMemberType type, String namespace, String name, boolean exported)
setJsMemberInfo
in interface HasJsInfo
public boolean isJsInteropEntryPoint()
isJsInteropEntryPoint
in interface HasJsInfo
public boolean canBeReferencedExternally()
canBeReferencedExternally
in interface HasJsInfo
public boolean canBeImplementedExternally()
canBeImplementedExternally
in interface HasJsInfo
public JParameter createFinalParameter(SourceInfo info, String name, JType type)
public JParameter createParameter(SourceInfo info, String name, JType type)
public JParameter createParameter(SourceInfo info, String name, JType type, boolean isFinal, boolean isVarargs)
public JParameter cloneParameter(JParameter from)
from
.public JParameter createThisParameter(SourceInfo info, JType type)
public String getJsNamespace()
getJsNamespace
in interface HasJsName
public String getQualifiedJsName()
getQualifiedJsName
in interface HasJsName
public boolean isJsConstructor()
public boolean exposesNonJsMember()
true
if this method is the first JsMember in the method hierarchy that exposes
an existing non-JsMember inside a class.public HasJsInfo.JsMemberType getJsMemberType()
getJsMemberType
in interface HasJsInfo
public boolean isOrOverridesJsFunctionMethod()
public boolean isJsNative()
isJsNative
in interface CanBeJsNative
public boolean isJsOverlay()
isJsOverlay
in interface HasJsInfo
public void setSyntheticAccidentalOverride()
public boolean isSyntheticAccidentalOverride()
public void setSpecialization(List<JType> paramTypes, JType returnsType, String targetMethod)
public JMethod.Specialization getSpecialization()
public void removeSpecialization()
public boolean isInliningAllowed()
public InliningMode getInliningMode()
public void setInliningMode(InliningMode inliningMode)
public boolean hasSideEffects()
public void setHasSideEffects(boolean hasSideEffects)
public void setDefaultMethod(boolean defaultMethod)
public void setJsOverlay()
setJsOverlay
in interface HasJsInfo
public boolean isDefaultMethod()
public boolean isDevirtualizationAllowed()
public void disallowDevirtualization()
public boolean isJsMethodVarargs()
isJsMethodVarargs
in interface HasJsInfo
public static JMethod getExternalizedMethod(String fullClassName, String signature, boolean isStatic)
fullClassName
- the class where the method is defined.signature
- the signature of the method (including its name).public void addOverriddenMethod(JMethod overriddenMethod)
public void addOverridingMethod(JMethod overridingMethod)
public void addThrownException(JClassType exceptionType)
public void addThrownExceptions(List<JClassType> exceptionTypes)
public boolean canBePolymorphic()
public void freezeParamTypes()
public boolean exposesPackagePrivateMethod()
true
if this method is the first method in the method hierarchy that increases
the visibility of a package private method.public AccessModifier getAccess()
public JAbstractMethodBody getBody()
public JDeclaredType getEnclosingType()
getEnclosingType
in interface HasEnclosingType
public String getQualifiedName()
getQualifiedName
in interface JMember
public JType getOriginalReturnType()
public Set<JMethod> getOverriddenMethods()
public Set<JMethod> getOverridingMethods()
public List<JParameter> getParams()
public String getSignature()
public String getJsniSignature(boolean includeEnclosingClass, boolean includeReturnType)
public List<JClassType> getThrownExceptions()
public JType getType()
HasType
public boolean isAbstract()
isAbstract
in interface CanBeAbstract
public boolean isConstructor()
public boolean isPackagePrivate()
public boolean isExternal()
isExternal
in interface JMember
public boolean isFinal()
isFinal
in interface CanBeFinal
public boolean isForwarding()
public boolean isJsniMethod()
public boolean isStatic()
isStatic
in interface CanBeStatic
public boolean isSynthetic()
isSynthetic
in interface JMember
public boolean needsDynamicDispatch()
true
if this method can participate in instance
dispatch.needsDynamicDispatch
in interface JMember
public void removeParam(int index)
public void resolve(JType originalReturnType, List<JType> originalParamTypes, JType returnType, List<JClassType> thrownExceptions)
public void setAbstract(boolean isAbstract)
public void setBody(JAbstractMethodBody body)
public void setFinal()
setFinal
in interface CanBeSetFinal
public void setFinal(boolean isFinal)
public void setForwarding()
public void setSynthetic()
public void setType(JType newType)
public Set<String> getSuppressedWarnings()
getSuppressedWarnings
in interface CanHaveSuppressedWarnings
public void setSuppressedWarnings(Set<String> suppressedWarnings)
setSuppressedWarnings
in interface CanHaveSuppressedWarnings
public void traverse(JVisitor visitor, Context ctx)
JNode
protected void visitChildren(JVisitor visitor)
protected Object writeReplace()
Copyright © 2018. All rights reserved.