Class IdentifierTreeImpl
- java.lang.Object
-
- org.sonar.javascript.tree.impl.JavaScriptTree
-
- org.sonar.javascript.tree.impl.expression.IdentifierTreeImpl
-
- All Implemented Interfaces:
TypableTree,BindingElementTree,ImportSubClauseTree,ExpressionTree,IdentifierTree,JsxElementNameTree,Tree
public class IdentifierTreeImpl extends JavaScriptTree implements IdentifierTree, TypableTree
-
-
Constructor Summary
Constructors Constructor Description IdentifierTreeImpl(Tree.Kind kind, InternalSyntaxToken nameToken)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(DoubleDispatchVisitor visitor)voidadd(Type type)List<IdentifierTree>bindingIdentifiers()Iterator<Tree>childrenIterator()Creates iterator for children of this node.Tree.KindgetKind()SyntaxTokenidentifierToken()Stringname()Scopescope()voidscope(Scope scope)voidsetSymbolUsage(Usage usage)Optional<Symbol>symbol()Optional<Usage>symbolUsage()StringtoString()TypeSettypes()Returns an unmodifiable set of the possible types for the expression.-
Methods inherited from class org.sonar.javascript.tree.impl.JavaScriptTree
childrenStream, descendants, firstToken, is, isAncestorOf, isLeaf, lastToken, parent, setParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.sonar.plugins.javascript.api.tree.Tree
childrenStream, descendants, firstToken, is, isAncestorOf, lastToken, parent
-
-
-
-
Constructor Detail
-
IdentifierTreeImpl
public IdentifierTreeImpl(Tree.Kind kind, InternalSyntaxToken nameToken)
-
-
Method Detail
-
getKind
public Tree.Kind getKind()
- Specified by:
getKindin classJavaScriptTree
-
identifierToken
public SyntaxToken identifierToken()
- Specified by:
identifierTokenin interfaceIdentifierTree
-
name
public String name()
- Specified by:
namein interfaceIdentifierTree
-
toString
public String toString()
- Overrides:
toStringin classJavaScriptTree
-
symbolUsage
public Optional<Usage> symbolUsage()
- Specified by:
symbolUsagein interfaceIdentifierTree- Returns:
Usagecorresponding to this identifier. Empty optional is returned when there is no symbol available for this identifier (seeIdentifierTree.symbol())
-
symbol
public final Optional<Symbol> symbol()
- Specified by:
symbolin interfaceIdentifierTree- Returns:
Symbolwhich is referenced by this identifier. NoSymbolis returned in several cases:- for
Tree.Kind.PROPERTY_IDENTIFIER - for unresolved symbol (i.e. symbol being read without being written)
Tree.Kind.BINDING_IDENTIFIER(used for symbol declaration) always has corresponding symbol. Note that this method is a shortcut for {@link IdentifierTree#symbolUsage()#symbol()}.- for
-
setSymbolUsage
public void setSymbolUsage(Usage usage)
-
types
public TypeSet types()
Description copied from interface:ExpressionTreeReturns an unmodifiable set of the possible types for the expression. Attempts to modify the returned set, whether direct or via its iterator, will result in an UnsupportedOperationException.- Specified by:
typesin interfaceExpressionTree
-
add
public void add(Type type)
- Specified by:
addin interfaceTypableTree
-
childrenIterator
public Iterator<Tree> childrenIterator()
Description copied from class:JavaScriptTreeCreates iterator for children of this node. Note that iterator may containnullelements.- Specified by:
childrenIteratorin classJavaScriptTree
-
accept
public void accept(DoubleDispatchVisitor visitor)
-
scope
public Scope scope()
- Specified by:
scopein interfaceIdentifierTree- Returns:
Scopeinstance in which this identifier appear
-
scope
public void scope(Scope scope)
-
bindingIdentifiers
public List<IdentifierTree> bindingIdentifiers()
- Specified by:
bindingIdentifiersin interfaceBindingElementTree
-
-