saker.build Documentation TaskDoc JavaDoc Packages
public interface ScriptToken
A script token represents a single entity in the source code that is handled as a unit.

Script tokens have a region that they take up in the source code. This region is specified by an offset and length.

Script tokens have a type which can be used to handle them differently with its enclosing model. E.g. syntax highlighting. If two tokens have the same type, they should be displayed the same way in an IDE. Token types are arbitrary strings defined by their enclosing model.

Token regions should not overlap in a given script model.

Methods
public default int
Gets the region end offset of this token.
public int
Gets the length of the token.
public int
Gets the offset of the token in the associated document.
public String
Gets the type of this token.
public default boolean
Checks if this token takes up any characters.
public default int getEndOffset()
Gets the region end offset of this token.

The returned value is and exclusive offset.

The default implementation returns

 getOffset() + getLength()
 
The end offset.
public abstract int getLength()
Gets the length of the token.

The length defines how many characters a token take up in the source code.

A token length may be zero.

The length.
public abstract int getOffset()
Gets the offset of the token in the associated document.

The offset is zero based and inclusive.

The offset.
public abstract String getType()
Gets the type of this token.

The type can be an arbitrary string, in relation with the enclosing script model.

The type.
public default boolean isEmpty()
Checks if this token takes up any characters.

The default implementation simply checks if getLength() is zero.