com.intellij.psi.tree
Class IElementType

java.lang.Object
  extended by com.intellij.psi.tree.IElementType
Direct Known Subclasses:
CustomHighlighterTokenType.CustomElementType, IAspectElementType, IChameleonElementType, IDTDElementType, IJavaDocElementType, IJavaElementType, IJspElementType, IXmlElementType

public class IElementType
extends java.lang.Object

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:
Lexer.getTokenType(), ASTNode.getElementType()

Nested Class Summary
static interface IElementType.Predicate
          Predicate for matching element types.
 
Field Summary
static IElementType[] EMPTY_ARRAY
           
static IElementType.Predicate TRUE
          Default enumeration predicate which matches all token types.
 
Constructor Summary
  IElementType(java.lang.String debugName, Language language)
          Creates and registers a new element type for the specified language.
protected IElementType(java.lang.String debugName, Language language, boolean register)
           
 
Method Summary
static IElementType[] enumerate(IElementType.Predicate p)
          Enumerates all registered token types which match the specified predicate.
static IElementType find(short idx)
          Returns the element type registered at the specified index.
 short getIndex()
          Returns the index of the element type in the table of all registered element types.
 Language getLanguage()
          Returns the language associated with the element type.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRUE

public static final IElementType.Predicate TRUE
Default enumeration predicate which matches all token types.

See Also:
enumerate(com.intellij.psi.tree.IElementType.Predicate)

EMPTY_ARRAY

public static final IElementType[] EMPTY_ARRAY
Constructor Detail

IElementType

public IElementType(@NotNull@NonNls
                    java.lang.String debugName,
                    @NotNull
                    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(java.lang.String debugName,
                       Language language,
                       boolean register)
Method Detail

enumerate

public static IElementType[] enumerate(IElementType.Predicate p)
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.

getLanguage

@NotNull
public Language 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.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

find

public static IElementType find(short idx)
Returns the element type registered at the specified index.

Parameters:
idx - the indx for which the element type should be returned.
Returns:
the element type at the specified index.