P
- Type of the (P)arent object containing this collection (e.g., SelectorPart
s have Selector
s as the parent).T
- The (T)ype of units to be grouped with.public interface Groupable<P,T extends Groupable<P,T>> extends Syntax
SyntaxCollection
.
Note that uniqueness within the same SyntaxCollection
is enforced, which means that if you prepend or append an
instance that already exists in the SyntaxCollection
it will be moved. This also means that if you prepend or append an
instance to a difference SyntaxCollection
it will be moved out of the original collection as well. If this is not what
you want then try looking at Syntax.copy()
.
To remove a unit from the syntax tree, use destroy()
. A destroyed unit cannot be placed back in the tree (among other
reasons because it may have bypassed necessary subscription methods), however it can still be copied.
SyntaxCollection
Modifier and Type | Method and Description |
---|---|
Groupable<P,T> |
append(T unit)
Appends the given unit after this one.
|
void |
destroy()
Removes this unit from its collection.
|
SyntaxCollection<P,T> |
group()
Gets the group
SyntaxCollection of this unit. |
Groupable<P,T> |
group(SyntaxCollection<P,T> group)
Sets the group.
|
boolean |
isDestroyed()
Whether the unit has been destroyed.
|
boolean |
isFirst()
Gets whether this unit is the first within its group.
|
boolean |
isLast()
Gets whether this unit is the last within its group.
|
Optional<T> |
next()
Gets the unit following this one in the same collection, if there is one.
|
P |
parent()
Gets the parent
Syntax unit that owns the SyntaxCollection that contains this unit. |
Groupable<P,T> |
prepend(T unit)
Prepends the given unit before this one.
|
Optional<T> |
previous()
Gets the unit preceding this one in the same collection, if there is one.
|
Groupable<P,T> |
replaceWith(T unit)
Replaces this unit with the given one.
|
Groupable<P,T> |
unlink()
Severs the connection between this unit and its collection.
|
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, copy, hasAnnotation, hasAnnotation, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, toString, writesOwnComments, writesOwnOrphanedComments
isWritable, write
propagateBroadcast, shouldBreakBroadcast, status, status
boolean isFirst()
Please note, if you are making decisions based on this value then keep in mind that any rework plugins may add or remove
new units before or after this one. As such, this usually means it's best that plugins with Rework
methods
utilizing this value are registered last.
boolean isLast()
Please note, if you are making decisions based on this value then keep in mind that any rework plugins may add or remove
new units before or after this one. As such, this usually means it's best that plugins with Rework
methods
utilizing this value are registered last.
Optional<T> next()
Optional
if there isn't one.Optional<T> previous()
Optional
if there isn't one.Groupable<P,T> prepend(T unit)
Note that uniqueness within the same SyntaxCollection
is enforced, which means that if you prepend or append an
instance that already exists in the SyntaxCollection
it will be moved. This also means that if you prepend or
append an instance to a difference SyntaxCollection
it will be moved out of the original collection as well. If
this is not what you want then try looking at Syntax.copy()
.
unit
- The unit to prepend.IllegalStateException
- If this unit is currently detached (doesn't belong to any collection) or it has been destroyed.Groupable<P,T> append(T unit)
Note that uniqueness within the same SyntaxCollection
is enforced, which means that if you prepend or append an
instance that already exists in the SyntaxCollection
it will be moved. This also means that if you prepend or
append an instance to a difference SyntaxCollection
it will be moved out of the original collection as well. If
this is not what you want then try looking at Syntax.copy()
.
unit
- The unit to append.IllegalStateException
- If this unit is currently detached (doesn't belong to any group) or it has been destroyed.Groupable<P,T> replaceWith(T unit)
Specifically, it prepends the unit to this one, then calls destroy()
on this unit. Note that destroy()
basically makes this unit worthless, so do not do anything with it afterwards (like trying to put it back in the tree).
unit
- Replace with this unit.Groupable<P,T> unlink()
destroy()
instead.void destroy()
Once removed, the unit cannot be re-added to any collection, however it can still be copied. Destroyed units will no longer be broadcasted to any subsequent plugins.
boolean isDestroyed()
Groupable<P,T> group(SyntaxCollection<P,T> group)
group
- The group group.SyntaxCollection<P,T> group()
SyntaxCollection
of this unit.
This can be used to find all peers of the unit (e.g., all other declarations in the same rule as this one).
SyntaxCollection
. If working with this term before it has been properly linked then this may
return null. This is not the case for normal subscription methods.P parent()
Syntax
unit that owns the SyntaxCollection
that contains this unit. See SyntaxCollection.parent()
.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.