Class PossibleGenericSymbol

All Implemented Interfaces:
Serializable, ICanBeGeneric, ICanCaptureVariables, IScope, IScopedSymbol, ISymbol, ITokenReference
Direct Known Subclasses:
AggregateSymbol, FunctionSymbol

public class PossibleGenericSymbol extends CaptureScopedSymbol implements ICanBeGeneric
Added as a common symbol type for both Functions and Aggregates that could possibly be generic in nature and also be a parameterised type. This is quite (very) complex, as in ek9 both classes and functions can be: A 'GenericType' Have 'Type Parameters' Can be 'Parameterised Types' through the use of 'Type Arguments' This can result in 'Parameterised Types' actually still being a 'GenericType'. It's hard to get your (mine) head around all this.
See Also:
  • Constructor Details

    • PossibleGenericSymbol

      public PossibleGenericSymbol(String name, IScope enclosingScope)
    • PossibleGenericSymbol

      public PossibleGenericSymbol(String name, Optional<ISymbol> type, IScope enclosingScope)
  • Method Details

    • clone

      public ScopedSymbol 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 CaptureScopedSymbol
    • cloneIntoPossibleGenericSymbol

      protected PossibleGenericSymbol cloneIntoPossibleGenericSymbol(PossibleGenericSymbol newCopy)
    • isParameterisedType

      public boolean isParameterisedType()
      Description copied from interface: ISymbol
      So just to add to the confusion. A type that has been used with a type that is generic in nature with some parameters. So this would normally result in a type that is now concrete. i.e. List (generic in nature) and String (concrete) so this resulting type 'List of String' isAParameterisedType=true and isGenericInNature=false. But if List were parameterised with another generic parameter it would still be of a generic nature. For example, consider List T and Iterator I when we defined List T and use the Iterator with it; we parameterise Iterator with 'T'. But they are still both 'isGenericTypeParameter' it only when we use List (and by implication Iterator) with String do they both stop being generic in nature.
      Specified by:
      isParameterisedType in interface ISymbol
      Returns:
      true if a parameterised type (note parameterised not just of a generic nature).
    • getGenericType

      public Optional<PossibleGenericSymbol> getGenericType()
      Description copied from interface: ICanBeGeneric
      Not only can a class/function that implements this interface be generic in nature, they can also be a 'parameterised type'.
      Specified by:
      getGenericType in interface ICanBeGeneric
    • setGenericType

      public void setGenericType(Optional<PossibleGenericSymbol> genericType)
      Used parameterizing a generic type with type arguments.
    • setGenericType

      public void setGenericType(PossibleGenericSymbol genericType)
    • isGenericInNature

      public boolean isGenericInNature()
      Description copied from interface: ISymbol
      Is this symbol a type that is generic in nature i.e. can it be parameterised with types. Aggregate Symbols can be defined to accept one or more parameters ie S and T.
      Specified by:
      isGenericInNature in interface ISymbol
    • isOpenForExtension

      public boolean isOpenForExtension()
      Description copied from interface: ICanBeGeneric
      Is the symbol open for extension or not. Typically this means a function is open/abstract and therefore can/must be extended. The same with classes and components.
      Specified by:
      isOpenForExtension in interface ICanBeGeneric
    • setOpenForExtension

      public void setOpenForExtension(boolean open)
    • isConceptualTypeParameter

      public boolean isConceptualTypeParameter()
      Is this itself a 'conceptual' type.
      Specified by:
      isConceptualTypeParameter in interface ISymbol
    • setConceptualTypeParameter

      public void setConceptualTypeParameter(boolean conceptualTypeParameter)
      Set this type symbol to be conceptual in nature.
    • getGenericSymbolReferences

      public List<PossibleGenericSymbol> getGenericSymbolReferences()
      Description copied from interface: ICanBeGeneric
      Used to keep track of any generic types/functions used in a generic type that use some or all of the generic type parameters or arguments. For example a 'List of type T' might use or return an 'Iterator of type T'. It is the 'Iterator' that would be a generic symbol reference.
      Specified by:
      getGenericSymbolReferences in interface ICanBeGeneric
    • addGenericSymbolReference

      public void addGenericSymbolReference(PossibleGenericSymbol genericSymbolReference)
      Add a reference to a parameterised function. I'm still in two minds about adding these references. Leave as is at the moment, and then see what I think later on.
      Specified by:
      addGenericSymbolReference in interface ICanBeGeneric
    • addTypeParameterOrArgument

      public void addTypeParameterOrArgument(ISymbol typeParameterOrArgument)
      Add a parameter type to this scope.
      Specified by:
      addTypeParameterOrArgument in interface ICanBeGeneric
    • 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.
    • getAnyGenericParamsAsFriendlyNames

      protected String getAnyGenericParamsAsFriendlyNames()
    • getAnyConceptualTypeParameters

      public List<ISymbol> getAnyConceptualTypeParameters()
      If this scope has been parameterised, then go through those parameters and return a list of all those that are generic 'T' in nature and not actually concrete types.
      Specified by:
      getAnyConceptualTypeParameters in interface ICanBeGeneric
    • getTypeParameterOrArguments

      public List<ISymbol> getTypeParameterOrArguments()
      Specified by:
      getTypeParameterOrArguments in interface ICanBeGeneric
    • resolveFromParameterTypes

      public Optional<ISymbol> resolveFromParameterTypes(SymbolSearch search)
      Used when the type/function is one that is generic/template. It will have a number of parameterTypes, these are 'T' and the like. The conceptual or concrete types.
    • 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 CaptureScopedSymbol
    • resolve

      public Optional<ISymbol> resolve(SymbolSearch search)
      So this is where we alter the mechanism of normal symbol resolution.
      Specified by:
      resolve in interface IScope
      Overrides:
      resolve in class ScopedSymbol
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class CaptureScopedSymbol