T
- See "T" described in the Groupable
documentation.P
- See "P" described in the Groupable
documentation.public abstract class AbstractGroupable<P,T extends Groupable<P,T>> extends AbstractSyntax implements Groupable<P,T>
Groupable
s.Constructor and Description |
---|
AbstractGroupable()
Creates a new instance with no line or number specified (used for dynamically created
Syntax units). |
AbstractGroupable(int line,
int column)
Creates a new instance with the given line and column numbers.
|
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.
|
boolean |
isWritable()
Returns whether this unit should actually be written.
|
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.
|
protected abstract T |
self()
Should return "this".
|
Groupable<P,T> |
unlink()
Severs the connection between this unit and its collection.
|
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, copiedFrom, copy, equals, hasAnnotation, hasAnnotation, hashCode, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, propagateBroadcast, shouldBreakBroadcast, status, status, toString, toString, writesOwnComments, writesOwnOrphanedComments
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, copy, hasAnnotation, hasAnnotation, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, toString, writesOwnComments, writesOwnOrphanedComments
propagateBroadcast, shouldBreakBroadcast, status, status
public AbstractGroupable()
Syntax
units).public AbstractGroupable(int line, int column)
line
- The line number.column
- The column number.protected abstract T self()
AbstractGroupable
class.public boolean isFirst()
Groupable
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.
public boolean isLast()
Groupable
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.
public Optional<T> previous()
Groupable
public Optional<T> next()
Groupable
public Groupable<P,T> prepend(T unit)
Groupable
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()
.
public Groupable<P,T> append(T unit)
Groupable
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()
.
public Groupable<P,T> replaceWith(T unit)
Groupable
Specifically, it prepends the unit to this one, then calls Groupable.destroy()
on this unit. Note that Groupable.destroy()
basically makes this unit worthless, so do not do anything with it afterwards (like trying to put it back in the tree).
public Groupable<P,T> unlink()
Groupable
Groupable.destroy()
instead.public void destroy()
Groupable
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.
public boolean isDestroyed()
Groupable
public Groupable<P,T> group(SyntaxCollection<P,T> group)
Groupable
public SyntaxCollection<P,T> group()
Groupable
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).
public P parent()
Groupable
Syntax
unit that owns the SyntaxCollection
that contains this unit. See SyntaxCollection.parent()
.public boolean isWritable()
Writable
Usually this should just return true, however some units that are detachable or otherwise potentially invalid should first check their state and respond appropriately.
isWritable
in interface Writable
isWritable
in class AbstractSyntax
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.