Class SymbolImpl

java.lang.Object
org.sonar.python.semantic.SymbolImpl
All Implemented Interfaces:
Symbol
Direct Known Subclasses:
AmbiguousSymbolImpl, ClassSymbolImpl, FunctionSymbolImpl

public class SymbolImpl extends Object implements Symbol
  • Field Details

    • validForPythonVersions

      protected Set<String> validForPythonVersions
  • Constructor Details

    • SymbolImpl

      public SymbolImpl(String name, @Nullable String fullyQualifiedName)
    • SymbolImpl

      public SymbolImpl(String name, @Nullable String fullyQualifiedName, @Nullable String annotatedTypeName)
    • SymbolImpl

      public SymbolImpl(SymbolsProtos.VarSymbol varSymbol, String moduleName, boolean isFromClass)
  • Method Details

    • name

      public String name()
      Specified by:
      name in interface Symbol
    • usages

      public List<Usage> usages()
      Specified by:
      usages in interface Symbol
    • fullyQualifiedName

      @CheckForNull public String fullyQualifiedName()
      Specified by:
      fullyQualifiedName in interface Symbol
    • is

      public boolean is(Symbol.Kind... kinds)
      Specified by:
      is in interface Symbol
    • kind

      public Symbol.Kind kind()
      Specified by:
      kind in interface Symbol
    • setKind

      public void setKind(Symbol.Kind kind)
    • addChildSymbol

      public void addChildSymbol(Symbol symbol)
    • inferredType

      public InferredType inferredType()
      Note that, for symbols that have been deserialized from protobuf, we compute their type lazily.
         a_var : Foo
         ...
         class Foo: ...
       
      Here, a_var has type Foo, which is defined later. Hence, by resolving types lazily, we avoid having to topologically sort dependencies between types declaration and their usages.
    • setInferredType

      public void setInferredType(InferredType inferredType)
    • annotatedTypeName

      public String annotatedTypeName()
      Description copied from interface: Symbol
      Returns fully qualified name of the type if any
      Specified by:
      annotatedTypeName in interface Symbol
    • setAnnotatedTypeName

      public void setAnnotatedTypeName(TypeAnnotation typeAnnotation)
    • copyWithoutUsages

      public SymbolImpl copyWithoutUsages()
    • copyWithoutUsages

      public SymbolImpl copyWithoutUsages(String name)
    • removeUsages

      public void removeUsages()
    • getChildrenSymbolByName

      public Map<String,Symbol> getChildrenSymbolByName()
    • validForPythonVersions

      public Set<String> validForPythonVersions()