public class PExtent extends Extent
The differences with Extent
is that instances of
PExtent
can contain special markers which are not
Java code and represent special parameters which can be
instantiated by typically other extents. These special
markers are called holes and are introduced by
a specific "magic" character.
An extent's holes are stored in order
of appearance in the extent, and must never overlap. This
is guaranteed by the associated PExtent.Builder
class.
Modifier and Type | Class and Description |
---|---|
static class |
PExtent.Builder
Builder class for parameterized extends
|
static class |
PExtent.Hole
A
PExtent.Hole represents a special part of an extent
which is bound to some PExtent.Hole.name and can be instantiated later
on. |
Modifier and Type | Field and Description |
---|---|
static PExtent |
DUMMY
A dummy extent for convenience, with no holes
|
List<PExtent.Hole> |
holes
The (possibly empty) list of holes in this parameterized extent.
|
Constructor and Description |
---|
PExtent(PExtent ext)
A copy constructor for parameterized extents
|
Modifier and Type | Method and Description |
---|---|
CExtent |
compose(String ruleName,
Map<String,CExtent> replacements)
NB: Except in the special case where the receiver had no holes
the returned
Extent will be inlined, i.e. information about
the original location in the source will be lost. |
boolean |
equals(@Nullable Object obj) |
String |
find()
The string must be of length
CExtent.realLength() . |
int |
hashCode() |
static PExtent |
inlined(String contents)
This is equivalent to
ofExtent(Extent.inlined(contents)) . |
Extent |
instantiate(Map<String,Extent> replacements)
NB: Except in the special case where the receiver had no holes
the returned
Extent will be inlined, i.e. information about
the original location in the source will be lost. |
static PExtent |
ofExtent(Extent extent) |
String |
toString() |
endPos, filename, findOrigin, length, realLength, startCol, startLine, startPos
public final List<PExtent.Hole> holes
The list must be strictly ordered in the sense that all holes appear in increasing order of offset, and that all the ranges described by the holes are disjoint.
public static final PExtent DUMMY
public PExtent(PExtent ext)
ext
- public String find()
CExtent
CExtent.realLength()
.public static PExtent ofExtent(Extent extent)
extent
- PExtent
, with no holespublic static PExtent inlined(String contents)
ofExtent(Extent.inlined(contents))
.contents
- contents
,
which must not contain any holespublic Extent instantiate(Map<String,Extent> replacements)
Extent
will be inlined, i.e. information about
the original location in the source will be lost.
TODO This should be temporary as it should be possible to keep a
tree of the original locations that led to a composite extent.
replacements
- holes
are replaced to extents according
to the replacement map replacements
IllegalArgumentException
- if the replacements
map
does not cover all the possible holes in the receiverpublic CExtent compose(String ruleName, Map<String,CExtent> replacements)
Extent
will be inlined, i.e. information about
the original location in the source will be lost.
TODO This should be temporary as it should be possible to keep a
tree of the original locations that led to a composite extent.
ruleName
- the ground rule which triggered this instantiationreplacements
- holes
are replaced to extents according
to the replacement map replacements
IllegalArgumentException
- if the replacements
map
does not cover all the possible holes in the receiver