|
org.netbeans.modules.lexer/2 1.19.0 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.api.lexer.Language<T>
Language describes a set of token ids
that comprise the given language.
Each language corresponds to a certain mime-type.
An input source may be lexed by using an existing language
- see TokenHierarchy
which is an entry point into the Lexer API.
Language hierarchy is represented by an unmodifiable set of TokenId
s
that can be retrieved by tokenIds()
and token categories
tokenCategories()
.
The language cannot be instantiated directly.
Instead it should be obtained from LanguageHierarchy.language()
on an existing language hierarchy.
LanguageHierarchy
,
TokenId
Method Summary | |
---|---|
String |
dumpInfo()
Dump list of token ids for this language into string. |
boolean |
equals(Object obj)
The languages are equal only if they are the same objects. |
static Language<? extends TokenId> |
find(String mimePath)
Finds a language by its mime type. |
int |
hashCode()
The hashCode of the language is the identity hashCode. |
int |
maxOrdinal()
Get maximum ordinal of all the token ids that this language contains. |
Set<T> |
merge(Collection<T> tokenIds1,
Collection<T> tokenIds2)
Merge two collections of token ids from this language into an efficient indexed set (the implementation similar to EnumSet ). |
String |
mimeType()
Gets the mime type of this language. |
List<String> |
nonPrimaryTokenCategories(T tokenId)
Get list of non-primary token categories (not containing the primary category) for the particular token id. |
Set<String> |
tokenCategories()
Get names of all token categories of this language. |
List<String> |
tokenCategories(T tokenId)
Get list of all token categories for the particular token id. |
Set<T> |
tokenCategoryMembers(String tokenCategory)
Get members of the category with given name. |
T |
tokenId(int ordinal)
Get tokenId for the given ordinal. |
T |
tokenId(String name)
Find the tokenId from its name. |
Set<T> |
tokenIds()
Get unmodifiable set of ids contained in this language. |
String |
toString()
|
T |
validTokenId(int ordinal)
Similar to tokenId(int) however it guarantees
that it will always return non-null tokenId. |
T |
validTokenId(String name)
Similar to tokenId(String) but guarantees a valid tokenId to be returned. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static Language<? extends TokenId> find(String mimePath)
This method uses information from LanguageProvider
s registered
in the default lookup to find Language
for a given
mime path.
Netbeans provide an implementation of LanguageProvider
that reads data from the Editors
folder on the system filesystem.
Therefore Netbeans modules can register their Language
s
in MimeLookup as any other mime-type related service.
Since this method takes mimePath
as a parameter it is
possible to look up Language
registered for
a mime type that is embedded in some other mime type (i.e. the nesting
can go any number of levels deep). In reality, however, there is usually
no difference between a language, which uses its own file and the same
language embedded in some other language's file (e.g. there is no difference
between java language in hello.java
and a java scriplet in
goodbye.jsp
). Therefore Language
s are
usually registered only for top level mime types and if a language
can be embedded in another language the embedded language is referenced
by its top level mime type.
mimePath
- The mime path of the language you want to find.
Language
of the language registered
for the given mimePath
.public Set<T> tokenIds()
public T tokenId(int ordinal)
ordinal
- ordinal to be translated to corresponding tokenId.
IndexOutOfBoundsException
.
IndexOutOfBoundsException
- if the ordinal is
<0 or higher than maxOrdinal()
.public T validTokenId(int ordinal)
tokenId(int)
however it guarantees
that it will always return non-null tokenId. Typically for a lexer
just being developed it's possible that there are some integer
token ids defined in the generated lexer for which there is
no correspondence in the language. The lexer wrapper should
always call this method if it expects to find a valid
counterpart for given integer id.
ordinal
- ordinal to translate to token id.
IndexOutOfBoundsException
- if the ordinal is
<0 or higher than maxOrdinal()
or when there is no corresponding
token id for it.public T tokenId(String name)
name
- name of the tokenId to find.
public T validTokenId(String name)
tokenId(String)
but guarantees a valid tokenId to be returned.
IllegalArgumentException
- if no token in this language has the given name.public int maxOrdinal()
-1
if the language contains no token ids.public Set<String> tokenCategories()
public Set<T> tokenCategoryMembers(String tokenCategory)
tokenCategory
- non-null name of the category.
public List<String> tokenCategories(T tokenId)
IllegalArgumentException
- if the given token id does not belong
to this language.public List<String> nonPrimaryTokenCategories(T tokenId)
tokenCategories(TokenId)
.
IllegalArgumentException
- if the given token id does not belong
to this language.public Set<T> merge(Collection<T> tokenIds1, Collection<T> tokenIds2)
EnumSet
).
tokenIds1
- non-null collection of token ids to be contained in the returned set.tokenIds2
- collection of token ids to be contained in the returned set.
public String mimeType()
public boolean equals(Object obj)
public int hashCode()
public String dumpInfo()
public String toString()
|
org.netbeans.modules.lexer/2 1.19.0 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |