org.netbeans.modules.lexer/2 1.39.1 1

org.netbeans.spi.lexer
Class LanguageEmbedding<T extends TokenId>

java.lang.Object
  extended by org.netbeans.spi.lexer.LanguageEmbedding<T>

public final class LanguageEmbedding<T extends TokenId>
extends Object

Description of a particular language embedding including starting and ending skipped regions of a token containing this embedding and a definition of an embedded language hierarchy.


Method Summary
static
<T extends TokenId>
LanguageEmbedding<T>
create(Language<T> language, int startSkipLength, int endSkipLength)
          Create language embedding that does not join embedded sections.
static
<T extends TokenId>
LanguageEmbedding<T>
create(Language<T> language, int startSkipLength, int endSkipLength, boolean joinSections)
          Construct new language embedding for the given parameters or get an existing cached one.
 int endSkipLength()
          Get length of the ending part of the token (for which the embedding is being created) that should be skipped so it will be excluded from lexing and no tokens will be created for it.
 boolean joinSections()
          Whether sections with this embedding should be joined with the other sections with this embedding at the same level.
 Language<T> language()
          Get the embedded language.
 int startSkipLength()
          Get length of the initial part of the token (for which the embedding is being created) that should be skipped so it will be excluded from lexing and no tokens will be created for it.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static <T extends TokenId> LanguageEmbedding<T> create(Language<T> language,
                                                              int startSkipLength,
                                                              int endSkipLength)
Create language embedding that does not join embedded sections.

See Also:
create(Language, int, int, boolean)

create

public static <T extends TokenId> LanguageEmbedding<T> create(Language<T> language,
                                                              int startSkipLength,
                                                              int endSkipLength,
                                                              boolean joinSections)
Construct new language embedding for the given parameters or get an existing cached one.

Parameters:
language - non-null language.
startSkipLength - >=0 number of characters in an initial part of the token for which the language embedding is defined that should be excluded from the embedded section. The excluded characters will not be lexed and there will be no tokens created for them.
endSkipLength - >=0 number of characters at the end of the token for which the language embedding is defined that should be excluded from the embedded section. The excluded characters will not be lexed and there will be no tokens created for them.
joinSections - whether sections with this embedding should be joined across the input source or whether they should stay separate. See also joinSections().
Returns:
non-null language embedding instance.

language

public Language<T> language()
Get the embedded language.

Returns:
non-null embedded language.

startSkipLength

public int startSkipLength()
Get length of the initial part of the token (for which the embedding is being created) that should be skipped so it will be excluded from lexing and no tokens will be created for it.

Returns:
>=0 number of characters in an initial part of the token (for which the language embedding is defined) that should be excluded from the embedded section. The excluded characters will not be lexed and there will be no tokens created for them.

endSkipLength

public int endSkipLength()
Get length of the ending part of the token (for which the embedding is being created) that should be skipped so it will be excluded from lexing and no tokens will be created for it.

Returns:
>=0 number of characters at the end of the token (for which the language embedding is defined) that should be excluded from the embedded section. The excluded characters will not be lexed and there will be no tokens created for them.

joinSections

public boolean joinSections()
Whether sections with this embedding should be joined with the other sections with this embedding at the same level.
For example for HTML sections embedded in JSP this flag should be true:
  <!-- HTML comment start
      <% System.out.println("Hello"); %>
           still in HTML comment --<
 

Only the embedded sections with the same language path will be joined.
When a particular embedded section would get relexed till its end then the next section may get relexed as well. For example if someone would add "-->" at the end of the first line in the example above then the third line that used to be comment will be relexed and it will become an html text.
Generally relexing of a next section happens in the following cases:

Returns:
joinSections whether sections with this embedding should be joined across the input source or whether they should stay separate.

toString

public String toString()
Overrides:
toString in class Object

org.netbeans.modules.lexer/2 1.39.1 1

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.