Package org.sonar.python.semantic
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.sonar.plugins.python.api.symbols.Symbol
Symbol.Kind
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<String>validForPythonVersions
-
Constructor Summary
Constructors Constructor Description SymbolImpl(String name, String fullyQualifiedName)SymbolImpl(SymbolsProtos.VarSymbol varSymbol, String moduleName, boolean isFromClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChildSymbol(Symbol symbol)StringannotatedTypeName()Returns fully qualified name of the type if anySymbolImplcopyWithoutUsages()SymbolImplcopyWithoutUsages(String name)StringfullyQualifiedName()Map<String,Symbol>getChildrenSymbolByName()InferredTypeinferredType()Note that, for symbols that have been deserialized from protobuf, we compute their type lazily.booleanis(Symbol.Kind... kinds)Symbol.Kindkind()Stringname()voidremoveUsages()voidsetAnnotatedTypeName(TypeAnnotation typeAnnotation)voidsetInferredType(InferredType inferredType)voidsetKind(Symbol.Kind kind)List<Usage>usages()Set<String>validForPythonVersions()
-
-
-
Constructor Detail
-
SymbolImpl
public SymbolImpl(SymbolsProtos.VarSymbol varSymbol, String moduleName, boolean isFromClass)
-
-
Method Detail
-
fullyQualifiedName
@CheckForNull public String fullyQualifiedName()
- Specified by:
fullyQualifiedNamein interfaceSymbol
-
is
public boolean is(Symbol.Kind... kinds)
-
kind
public Symbol.Kind kind()
-
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_varhas typeFoo, 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:SymbolReturns fully qualified name of the type if any- Specified by:
annotatedTypeNamein interfaceSymbol
-
setAnnotatedTypeName
public void setAnnotatedTypeName(TypeAnnotation typeAnnotation)
-
copyWithoutUsages
public SymbolImpl copyWithoutUsages()
-
copyWithoutUsages
public SymbolImpl copyWithoutUsages(String name)
-
removeUsages
public void removeUsages()
-
-