Class MethodSymbol

All Implemented Interfaces:
Serializable, IMayReturnSymbol, IScope, IScopedSymbol, ISymbol, ITokenReference
Direct Known Subclasses:
CallSymbol, ServiceOperationSymbol, StreamCallSymbol

public class MethodSymbol extends ScopedSymbol implements IMayReturnSymbol
Represents some type of method that exists on an aggregate type scope. Or it could just be a function type concept at the module level. So it really is some type of callable 'thing' that has a scope of its own. This scope is used to hold incoming parameters. It can also have some form of visibility/access modifiers and holds the concept of being overridable in terms of inheritance. In some cases it may also be defined as one of the 'operators' such as '+' or '$' for example.
See Also:
  • Constructor Details

    • MethodSymbol

      public MethodSymbol(String name, IScope enclosingScope)
      Create new method symbol of a specific name with an enclosing scope (i.e. a class).
    • MethodSymbol

      public MethodSymbol(String name, ISymbol type, IScope enclosingScope)
      Typically used for cloning constructors.
    • MethodSymbol

      public MethodSymbol(String name, Optional<ISymbol> type, IScope enclosingScope)
      Create new method symbol of a specific name with an enclosing scope (i.e. a class).
  • Method Details

    • getParentScope

      public IScope getParentScope()
      For actual methods this will be the aggregate they are part of.
    • clone

      public MethodSymbol clone(ISymbol withType, IScope withParentAsAppropriate)
    • clone

      public MethodSymbol clone(IScope withParentAsAppropriate)
      Description copied from interface: ISymbol
      Clone the symbol and re-parent if this symbol like a method should have a parent. Other symbols like VariableSymbols are un-parented
      Specified by:
      clone in interface IScope
      Specified by:
      clone in interface IScopedSymbol
      Specified by:
      clone in interface ISymbol
      Overrides:
      clone in class ScopedSymbol
    • cloneIntoMethodSymbol

      protected MethodSymbol cloneIntoMethodSymbol(MethodSymbol newCopy)
    • copyMethodProperties

      public MethodSymbol copyMethodProperties(MethodSymbol newCopy)
      Just copies the properties over.
    • resolveInThisScopeOnly

      public Optional<ISymbol> resolveInThisScopeOnly(SymbolSearch search)
      Description copied from interface: IScope
      Just look in own scope.
      Specified by:
      resolveInThisScopeOnly in interface IScope
      Overrides:
      resolveInThisScopeOnly in class ScopedSymbol
    • resolve

      public Optional<ISymbol> resolve(SymbolSearch search)
      Description copied from interface: IScope
      Find the nearest symbol of that name up the scope tree.
      Specified by:
      resolve in interface IScope
      Overrides:
      resolve in class ScopedSymbol
    • isSynthetic

      public boolean isSynthetic()
    • setSynthetic

      public void setSynthetic(boolean synthetic)
    • isOverride

      public boolean isOverride()
    • setOverride

      public void setOverride(boolean override)
    • getAccessModifier

      public String getAccessModifier()
    • setAccessModifier

      public void setAccessModifier(String accessModifier)
    • isPrivate

      public boolean isPrivate()
      Specified by:
      isPrivate in interface ISymbol
    • isProtected

      public boolean isProtected()
      Specified by:
      isProtected in interface ISymbol
    • isPublic

      public boolean isPublic()
      Specified by:
      isPublic in interface ISymbol
    • isUsedAsProxyForDelegate

      public boolean isUsedAsProxyForDelegate()
    • getUsedAsProxyForDelegate

      public String getUsedAsProxyForDelegate()
    • setUsedAsProxyForDelegate

      public void setUsedAsProxyForDelegate(String delegateName)
      Set this method to be marked so at it delegates any calls to a delegate.
    • isEk9ReturnsThis

      public boolean isEk9ReturnsThis()
    • setEk9ReturnsThis

      public void setEk9ReturnsThis(boolean ek9ReturnsThis)
    • isMarkedNoClone

      public boolean isMarkedNoClone()
    • setMarkedNoClone

      public void setMarkedNoClone(boolean markedNoClone)
    • isMarkedAsDispatcher

      public boolean isMarkedAsDispatcher()
    • setMarkedAsDispatcher

      public void setMarkedAsDispatcher(boolean markedAsDispatcher)
    • isMarkedAbstract

      public boolean isMarkedAbstract()
      Specified by:
      isMarkedAbstract in interface ISymbol
    • setMarkedAbstract

      public void setMarkedAbstract(boolean markedAbstract)
    • isNotMarkedAbstract

      public boolean isNotMarkedAbstract()
    • isConstant

      public boolean isConstant()
      Specified by:
      isConstant in interface ISymbol
    • isConstructor

      public boolean isConstructor()
    • isNotConstructor

      public boolean isNotConstructor()
    • setConstructor

      public MethodSymbol setConstructor(boolean constructor)
    • isOperator

      public boolean isOperator()
    • setOperator

      public MethodSymbol setOperator(boolean operator)
    • isReturningSymbolPresent

      public boolean isReturningSymbolPresent()
      Some methods have a named return symbol 'like rtn as String' for example. In other cases a method will not return anything (We use 'Void') in the case as the 'type'. So when a Returning Symbol is set we use the type of the returning variable as the type return on the method.
      Specified by:
      isReturningSymbolPresent in interface IMayReturnSymbol
    • getReturningSymbol

      public ISymbol getReturningSymbol()
      Provide a symbol that is returned from this method. Note in EK9 this is not just a type but actually a variable symbol (that has a type).
      Specified by:
      getReturningSymbol in interface IMayReturnSymbol
    • setReturningSymbol

      public void setReturningSymbol(VariableSymbol returningSymbol)
      Sets the returning symbol (variable not just type).
      Specified by:
      setReturningSymbol in interface IMayReturnSymbol
    • justSetReturningSymbol

      protected void justSetReturningSymbol(ISymbol returningSymbol)
    • isSignatureMatchTo

      public boolean isSignatureMatchTo(MethodSymbol toMethod)
      Does the signature of this method match that of the method passed in. Not the name of the method just the signature of the parameter types and special treatment for the return type - this can be coerced back or be a super type. This also takes into account polymorphism and promotions.
    • isExactSignatureMatchTo

      public boolean isExactSignatureMatchTo(MethodSymbol toMethod)
      This method just checks that the signature has exactly the same types as parameters. So this is 'exact' in addition it does not check the return type at all, nor the method name. It just focuses on the number order and type of the parameters matching.
    • isParameterSignatureMatchTo

      public boolean isParameterSignatureMatchTo(List<ISymbol> params)
      Very important method; that checks if the parameter list provided can match the parameters declared for this method. But this takes into account polymorphism and promotions.
    • getCallParameters

      public List<ISymbol> getCallParameters()
      Added convenience method to make the parameters a bit more obvious.
    • setCallParameters

      public void setCallParameters(List<ISymbol> params)
      Typically used when making synthetic methods you want to add in all the params from another method or something.
      Parameters:
      params - The parameters to pass to the method.
    • getFriendlyName

      public String getFriendlyName()
      Description copied from interface: ISymbol
      Provide the name an end user would need to see on the screen. Normally this is just 'getName' but in the case of Templates We use a very nasty internal naming for List of SomeClass - which will probably be something like _List_hashed_version_of_ComeClass and the end user needs to see 'List of SomeClass' for it to be meaningful.
      Specified by:
      getFriendlyName in interface ISymbol
      Overrides:
      getFriendlyName in class Symbol
      Returns:
      a user presentable of the symbol name.
    • doGetFriendlyName

      protected String doGetFriendlyName(String withName, Optional<ISymbol> theType)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class ScopedSymbol
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ScopedSymbol
    • toString

      public String toString()
      Overrides:
      toString in class Symbol