public final class BraceContext extends Object
It may be necessary to provide a completely unrelated context, such is in the example of if-else statement. The 'else' does not provide enough information itself as it is just a negation of earlier condition. Such related piece of text can be reported as 'related' BraceContext instance. Note that related instances may be chained - see the example below.
The infrastructure uses the provided information to present the context to the user. If a 'related' positions are present the infrastructure will attempt to present the source on the 'context' and 'related' positions in the source text order (e.g. displays portion of the document); contents between 'context' and 'related' positions may be suppressed.
An example of context and related areas for Java (PHP) if-elseif-else, with the origin t
// vvvvvvvvvvvvvvvvv -- related
if (condition1) {
// vvvvvvvvvvvvvvvvvvvvvvvvvvv -- related
} else if (elsecondition) {
...
} else {
// ^^^^^^ -- context
...
}
// ^ -- origin/caret location
Modifier and Type | Method and Description |
---|---|
static BraceContext |
create(Position start,
Position end)
Creates a new context area for the brace.
|
BraceContext |
createRelated(Position start,
Position end)
Creates a new BraceContext related to this one.
|
Position |
getEnd() |
BraceContext |
getRelated() |
Position |
getStart() |
public Position getStart()
public Position getEnd()
public BraceContext getRelated()
null
for none.public BraceContext createRelated(Position start, Position end)
start
- start of the contextual textend
- end of the textpublic static BraceContext create(Position start, Position end)
start
- start of the textend
- end of the text