java.lang.Object
com.intellij.psi.tree.IElementType
- Direct Known Subclasses:
ILazyParseableElementType,OuterLanguageElementType,TokenWrapper
Interface for token types returned from lexical analysis and for types
of nodes in the AST tree. All used element types are added to a registry which
can be enumerated or accessed by index.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacePredicate for matching element types. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IElementType[]static final shortstatic final IElementType.PredicateDefault enumeration predicate which matches all token types. -
Constructor Summary
ConstructorsModifierConstructorDescriptionIElementType(@NonNls @NotNull String debugName, @Nullable Language language) Creates and registers a new element type for the specified language.protectedIElementType(@NonNls @NotNull String debugName, @Nullable Language language, boolean register) Allows to construct element types for some temporary purposes without registering them. -
Method Summary
Modifier and TypeMethodDescriptionstatic IElementType @NotNull []enumerate(@NotNull IElementType.Predicate p) Enumerates all registered token types which match the specified predicate.static IElementTypefind(short idx) Returns the element type registered at the specified index.final shortgetIndex()Returns the index of the element type in the table of all registered element types.@NotNull LanguageReturns the language associated with the element type.inthashCode()booleanControls whitespace balancing behavior of PsiBuilder.toString()static voidunregisterElementTypes(@NotNull Language language) static voidunregisterElementTypes(@NotNull ClassLoader loader)
-
Field Details
-
EMPTY_ARRAY
-
TRUE
Default enumeration predicate which matches all token types.- See Also:
-
FIRST_TOKEN_INDEX
public static final short FIRST_TOKEN_INDEX- See Also:
-
-
Constructor Details
-
IElementType
public IElementType(@NonNls @NotNull @NonNls @NotNull String debugName, @Nullable @Nullable Language language) Creates and registers a new element type for the specified language.- Parameters:
debugName- the name of the element type, used for debugging purposes.language- the language with which the element type is associated.
-
IElementType
protected IElementType(@NonNls @NotNull @NonNls @NotNull String debugName, @Nullable @Nullable Language language, boolean register) Allows to construct element types for some temporary purposes without registering them. This is not default behavior and not recommended. A lot of other functionality (e.g.TokenSet) won't work with such element types. Please useIElementType(String, Language)unless you know what you're doing.
-
-
Method Details
-
unregisterElementTypes
-
unregisterElementTypes
-
getLanguage
Returns the language associated with the element type.- Returns:
- the associated language.
-
getIndex
public final short getIndex()Returns the index of the element type in the table of all registered element types.- Returns:
- the element type index.
-
hashCode
public int hashCode() -
toString
-
isLeftBound
public boolean isLeftBound()Controls whitespace balancing behavior of PsiBuilder.By default, empty composite elements (containing no children) are bounded to the right (previous) neighbour, forming following tree:
[previous_element] [whitespace] [empty_element] <empty> [next_element]Left-bound elements are bounded to the left (next) neighbour instead:
[previous_element] [empty_element] <empty> [whitespace] [next_element]See com.intellij.lang.impl.PsiBuilderImpl.prepareLightTree() for details.
- Returns:
- true if empty elements of this type should be bound to the left.
-
find
Returns the element type registered at the specified index.- Parameters:
idx- the index for which the element type should be returned.- Returns:
- the element type at the specified index.
- Throws:
IndexOutOfBoundsException- if the index is out of registered elements' range.
-
enumerate
Enumerates all registered token types which match the specified predicate.- Parameters:
p- the predicate which should be matched by the element types.- Returns:
- the array of matching element types.
-