Class PropertyAccess
- All Implemented Interfaces:
Expression
Property access represents an indexing of the scope or another expression, e.g. foo, foo.bar or foo().bar are
all property access expressions.
PropertyAccess can also be a 'select-all' style property, which can be used within a StructDeclaration to
select all of the output members or another expression in to a struct, e.g {foo.*} or {foo().*}.
-
Constructor Summary
ConstructorsConstructorDescriptionPropertyAccess(Optional<Expression> receiver, List<Token> identifiers) Creates a newPropertyAccessinstance. -
Method Summary
Modifier and TypeMethodDescription<T,R> R accept(ExpressionVisitor<T, R> visitor, T data) protected voidappendSource(StringBuilder appendTo) Implementers extend this to append their source to the given string builder.protected booleanbooleanIf here, this is the thing that is being accessed, e.g.inthashCode()booleanbooleanbooleanstatic PropertyAccessstatic PropertyAccessfinal StringtoSource()final StringtoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface nz.org.riskscape.rl.ast.Expression
isA
-
Constructor Details
-
PropertyAccess
Creates a new
PropertyAccessinstance.- Parameters:
receiver- If here, this is the thing that is being accessed, e.g. infoo(bar).bazthenfoo(bar)is the receiver. Without this, the property is looked up against the scope, which is usually a struct.identifiers-
-
-
Method Details
-
of
-
of
-
and
-
appendSource
Implementers extend this to append their source to the given string builder. Done via string builder to encourage a more efficient implementation than is possible with concatenating multiple toString calls that typically contruct a string builder anyway.
-
getAccessString
-
getFirstIdentifier
- Returns:
- the first token from this
PropertyAccessobjects list of identifiers, e.g. returnfoofromfoo.bar.baz
-
getLastIdentifier
- Returns:
- the last token from this
PropertyAccessobjects list of identifiers, e.g. returnbazfromfoo.bar.baz. Returns the same asgetFirstIdentifier()if only one identifier exists.
-
isSingleIdentifier
public boolean isSingleIdentifier()- Returns:
- true if this is the most basic of property access expressions, e.g. just identifies a property, e.g
foobut notfoo.barand notbar().foo
-
accept
-
getBoundary
- Returns:
- a pair of tokens that represent the start and end of this expression, to be used when giving users information about where errors have occurred. If the expression has been rebuilt then the boundary may be empty or it may be from the original expression. Intended for use in problems to trace errors back to their source.
-
isTrailingSelectAll
public boolean isTrailingSelectAll()- Returns:
- true if this expression has a trailing select-all, e.g.
foo.bar.*
-
isReceiverSelectAll
public boolean isReceiverSelectAll()- Returns:
- true if the expression is in the form
EXPRESSION INDEX ASTERISK, e.gfoo().*`
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getReceiver
If here, this is the thing that is being accessed, e.g. in
foo(bar).bazthenfoo(bar)is the receiver. Without this, the property is looked up against the scope, which is usually a struct. -
getIdentifiers
-
toString
-
toSource
- Specified by:
toSourcein interfaceExpression- Returns:
- a normalized version of the AST that can be parsed to be exactly the same AST as this
-