Interface JElementSymbol

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <R,​P>
      R
      acceptVisitor​(SymbolVisitor<R,​P> visitor, P param)
      Dispatch to the appropriate visit method of the visitor and returns its result.
      boolean equals​(Object o)
      Two symbols representing the same program element should be equal.
      String getSimpleName()
      Gets the name with which this declaration may be referred to, eg the name of the method, or the simple name of the class.
      TypeSystem getTypeSystem()
      Returns the type system that created this symbol.
      default boolean isUnresolved()
      Returns true if this symbol is a placeholder, created to fill-in an unresolved reference.
      default boolean nameEquals​(@NonNull String name)
      Returns true if the simple name of this symbol is the same as the given name.
      default @Nullable JavaNode tryGetNode()
      Returns the node that declares this symbol.
    • Method Detail

      • getSimpleName

        String getSimpleName()
        Gets the name with which this declaration may be referred to, eg the name of the method, or the simple name of the class.
        Returns:
        the name
      • nameEquals

        default boolean nameEquals​(@NonNull String name)
        Returns true if the simple name of this symbol is the same as the given name.
        Parameters:
        name - Simple name
        Throws:
        NullPointerException - If the parameter is null
      • getTypeSystem

        TypeSystem getTypeSystem()
        Returns the type system that created this symbol. The symbol uses this instance to create new types, for example to reflect its superclass.
      • isUnresolved

        default boolean isUnresolved()
        Returns true if this symbol is a placeholder, created to fill-in an unresolved reference. Depending on the type of this symbol, this may be:

        We try to recover some information about the missing symbol from the references we found, currently this includes only the number of type parameters of an unresolved class.

        Rules should care about unresolved symbols to avoid false positives or logic errors. The equivalent for types is TypeSystem.UNKNOWN.

        The following symbols are never unresolved, because they are lexically scoped:

      • tryGetNode

        default @Nullable JavaNode tryGetNode()
        Returns the node that declares this symbol. Eg for JMethodSymbol, it's an ASTMethodDeclaration. Will only return non-null if the symbol is declared in the file currently being analysed.
      • equals

        boolean equals​(Object o)
        Two symbols representing the same program element should be equal. So eg two JClassSymbol, even if their implementation class is different, should compare publicly observable properties (their binary name is enough). #hashCode() must of course be consistent with this contract.

        Symbols should only be compared using this method, never with ==, because their unicity is not guaranteed.

        Overrides:
        equals in class Object
        Parameters:
        o - Comparand
        Returns:
        True if the other is a symbol for the same program element
      • acceptVisitor

        <R,​P> R acceptVisitor​(SymbolVisitor<R,​P> visitor,
                                    P param)
        Dispatch to the appropriate visit method of the visitor and returns its result.