|
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.spi.lexer.LanguageProvider
public abstract class LanguageProvider
The Language provider. This class is a hook into the
lexer framework allowing modules to provide a language resolution service.
Whenever a Language is not explicitly known the
framework tries to determine it by asking LanguageProviders registered
in the Lookup.getDefault().
Languages might be needed for a mime type or mime path
of a Document used as an input source or they might be needed for
some tokens that contain text in an another (embedded) language. In both cases
a Language can either be explicitely provided by setting
the document's property or implementing the LanguageHierarchy.embedded()
method respectively or the framework will use LanguageProviders to
create the appropriate Language.
| Field Summary | |
|---|---|
static String |
PROP_EMBEDDED_LANGUAGE
The name of the property, which should be fired when the embedded language to Language mapping changes. |
static String |
PROP_LANGUAGE
The name of the property, which should be fired when the mime paths to Language mapping changes. |
| Constructor Summary | |
|---|---|
protected |
LanguageProvider()
The default constructor for subclasses. |
| Method Summary | |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener l)
Add a listener for change notifications. |
abstract Language<? extends TokenId> |
findLanguage(String mimePath)
Finds Language for a given mime path. |
abstract LanguageEmbedding<? extends TokenId> |
findLanguageEmbedding(Token<? extends TokenId> token,
LanguagePath languagePath,
InputAttributes inputAttributes)
Finds LanguageEmbedding that will define what language is
embedded in a given token. |
protected void |
firePropertyChange(String propertyName)
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove a listener. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PROP_LANGUAGE
Language mapping changes.
public static final String PROP_EMBEDDED_LANGUAGE
Language mapping changes.
| Constructor Detail |
|---|
protected LanguageProvider()
| Method Detail |
|---|
public abstract Language<? extends TokenId> findLanguage(String mimePath)
Language for a given mime path.
The lexer framework uses this method to find a Language
for Documents that are used as an input source. If the document
itself does not specify its Language the framework
will consult registered LanguageProviders to find out the
Language appropriate for the document's mime type.
mimePath - The mime path or mime type to get a Language
for. It is allowed to pass in an empty string or null.
Language registered for the given
mime path or null if no such Language exists.public abstract LanguageEmbedding<? extends TokenId> findLanguageEmbedding(Token<? extends TokenId> token, LanguagePath languagePath, InputAttributes inputAttributes)
LanguageEmbedding that will define what language is
embedded in a given token.
If a Token contains text in a different language that could
further be used for lexing of this Token the framework will try
to find out the Language of that language by asking
the Token's own Language first and then
by consulting registered LanguageProviders. The LanguageProviders
are expected to return a LanguageEmbedding for tokens they
care about and null for the rest. The first non-null
LanguageEmbedding found will be used.
LanguageEmbedding instances returned from this method
must not reference any of the attributes passed in and especially not
the token instance.
token - The Token to get the Language
for.languagePath - The LanguagePath of the token, which
embedded language should be returned.inputAttributes - The attributes that could affect the creation of
the embedded Language. It may be null
if there are no extra attributes.
LanguageEmbedding for the given Token
or null if the token can't embedd any language
or the token is unknown to this LanguageProvider.public final void addPropertyChangeListener(PropertyChangeListener l)
l - The listener to add.public final void removePropertyChangeListener(PropertyChangeListener l)
l - The listener to remove.protected final void firePropertyChange(String propertyName)
|
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 | |||||||||