com.intellij.lang
Class Language

java.lang.Object
  extended by com.intellij.lang.Language

public abstract class Language
extends java.lang.Object

The base class for all programming language support implementations. Specific language implementations should inherit from this class and its register instance wrapped with LanguageFileType instance through FileTypeManager.getInstance().registerFileType There should be exactly one instance of each Language. It is usually created when creating LanguageFileType and can be retrieved later with findInstance(Class).


Field Summary
static Language ANY
           
 
Constructor Summary
protected Language(java.lang.String id)
           
protected Language(java.lang.String ID, java.lang.String... mimeTypes)
           
 
Method Summary
static
<T extends Language>
T
findInstance(java.lang.Class<T> klass)
           
 Annotator getAnnotator()
          Override this method to provide on-the-fly error highlighting with quickfixes as well as parse tree based syntax annotations like highlighting instance variables in java.
 Commenter getCommenter()
          Override this method to provide comment-by-block and/or comment-by-line actions implementations for your language.
 ExternalAnnotator getExternalAnnotator()
          Same as getAnnotator() but is being run once against whole file.
 FindUsagesProvider getFindUsagesProvider()
          Override this method to provide find usages capability for the elements of your language For this functionality to work properly ParserDefinition implementation is necessary.
 FoldingBuilder getFoldingBuilder()
          Override this method to provide code folding capabilities when editing files of this language.
 FormattingModelBuilder getFormattingModelBuilder()
          Override this method to provide code formatter (aka pretty print, aka code beauitifier) for your language implementation.
 java.lang.String getID()
          Returns a user-readable name of the language.
 java.lang.String[] getMimeTypes()
          Returns the list of MIME types corresponding to the language.
 NamesValidator getNamesValidator()
          Override this method to customize algorithm of identifier validation and language keyword set.
 PairedBraceMatcher getPairedBraceMatcher()
          Override this method to provide paired brace matching and highlighting ability for editors of the language.
 ParserDefinition getParserDefinition()
          Override this method to provide parser implementation.
 TokenSet getReadableTextContainerElements()
          Word completion feature related method.
 RefactoringSupportProvider getRefactoringSupportProvider()
          Override this method to provide common refactorings implementation for the elements of your language.
static java.util.Collection<Language> getRegisteredLanguages()
           
 StructureViewBuilder getStructureViewBuilder(PsiFile psiFile)
          Override this method to provide structure view and file structure popup content for the files of your language.
 SurroundDescriptor[] getSurroundDescriptors()
          Override this method to provide 'surround with...' feature implementation for editors of the files in your language.
 SyntaxHighlighter getSyntaxHighlighter(Project project)
          Override this method to provide syntax highlighting (coloring) capabilities for your language implementation.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY

public static final Language ANY
Constructor Detail

Language

protected Language(java.lang.String id)

Language

protected Language(java.lang.String ID,
                   java.lang.String... mimeTypes)
Method Detail

getRegisteredLanguages

public static java.util.Collection<Language> getRegisteredLanguages()
Returns:
collection of all languages registered so far.

findInstance

public static <T extends Language> T findInstance(java.lang.Class<T> klass)
Parameters:
klass - java.lang.Class of the particular language. Serves key purpose.
Returns:
instance of the klass language registered if any.

getSyntaxHighlighter

@NotNull
public SyntaxHighlighter getSyntaxHighlighter(Project project)
Override this method to provide syntax highlighting (coloring) capabilities for your language implementation. By syntax highlighting we mean highlighting of keywords, comments, braces etc. where lexing the file content is enough to identify proper highlighting attributes.

Default implementation doesn't highlight anything.

Parameters:
project - might be necessary to gather various project settings from.
Returns:
SyntaxHighlighter interface implementation for this particular language.

getFormattingModelBuilder

@Nullable
public FormattingModelBuilder getFormattingModelBuilder()
Override this method to provide code formatter (aka pretty print, aka code beauitifier) for your language implementation. Note that formatter implementation is necessary to make smart enter and smart end functions to work properly.

Returns:
FormattingModelBuilder interface implementation for this particular language or null if no formatting capabilities provided.

getParserDefinition

@Nullable
public ParserDefinition getParserDefinition()
Override this method to provide parser implementation. Parsed tree (AST) and program structure interface (PSI) based on AST is necessary for most of IDEA smart functions like in-editor error highlighting, advanced syntax highlighting, error-checking, intention actions, inspections, folding, finding usages, refactoring, file structure view etc.

Returns:
ParserDefinition interface implementation for this particular language or null if no parsing capabilities provided.

getFoldingBuilder

@Nullable
public FoldingBuilder getFoldingBuilder()
Override this method to provide code folding capabilities when editing files of this language. Please note getParserDefinition() should return parser implementation for folding building to work properly.

Returns:
FoldingBuilder interface implementation for this particular language or null if no folding capabilities provided.

getPairedBraceMatcher

@Nullable
public PairedBraceMatcher getPairedBraceMatcher()
Override this method to provide paired brace matching and highlighting ability for editors of the language. For this functionality to work properly own SyntaxHighlighter implementation is necessary.

Returns:
PairedBraceMatcher interface implementation for this particular language or null if no brace matching capabilities provided.

getCommenter

@Nullable
public Commenter getCommenter()
Override this method to provide comment-by-block and/or comment-by-line actions implementations for your language. For this functionality to work properly ParserDefinition implementation is necessary.

Returns:
Commenter interface implementation for this particular language or null if no auto-commenting capabilities provided.

getReadableTextContainerElements

@NotNull
public TokenSet getReadableTextContainerElements()
Word completion feature related method. It supposed to return token types of the places where word completion should be enabled. Default implementation delegates to parser definition and returns comment tokens so words completion is enabled in comments if parser definition is implemented.

Returns:
set of token types where word completion should be enabled.

getAnnotator

@Nullable
public Annotator getAnnotator()
Override this method to provide on-the-fly error highlighting with quickfixes as well as parse tree based syntax annotations like highlighting instance variables in java. For this functionality to work properly ParserDefinition implementation is necessary. Note that syntax errors flagged by parser in ParserDefinition are highlighted automatically. Annotator is run against changed parts of the parse tree incrementally.

Returns:
Annotator interface implementation for this particular language or null if no error and syntax highlighting capabilities provided.

getExternalAnnotator

@Nullable
public ExternalAnnotator getExternalAnnotator()
Same as getAnnotator() but is being run once against whole file. It's most proper to use when integrating external validation tools like xerces schema validator for XML.

Returns:
external annotator for a whole file. Since this annotating is expensive due to nonincrementality, it is run last

getFindUsagesProvider

@NotNull
public FindUsagesProvider getFindUsagesProvider()
Override this method to provide find usages capability for the elements of your language For this functionality to work properly ParserDefinition implementation is necessary.

Default implementation returns mock find usages provider uncapable to search anything.

Returns:
FindUsagesProvider interface implementation for this particular language.

getStructureViewBuilder

@Nullable
public StructureViewBuilder getStructureViewBuilder(PsiFile psiFile)
Override this method to provide structure view and file structure popup content for the files of your language.

Parameters:
psiFile -
Returns:
StructureViewBuilder interface implementation for this particular language or null if no file structure implementation.

getRefactoringSupportProvider

@Nullable
public RefactoringSupportProvider getRefactoringSupportProvider()
Override this method to provide common refactorings implementation for the elements of your language. For the time being only safe delete refactoring is implemented. Note that rename refactoring will be automatically enabled with FindUsagesProvider and ParserDefinition.

Returns:
RefactoringSupportProvider interface implementation for this particular language or null if no safe delete refactoring implementation is necessary.

getNamesValidator

@NotNull
public NamesValidator getNamesValidator()
Override this method to customize algorithm of identifier validation and language keyword set. Default implementation provides java language identifier validation and java language keyword set. For the time being the information provided is used in rename refactoring only.

Returns:
NamesValidator interface implementation for this particular language. null value must not be returned.
Since:
5.0.1

getSurroundDescriptors

@NotNull
public SurroundDescriptor[] getSurroundDescriptors()
Override this method to provide 'surround with...' feature implementation for editors of the files in your language.

Default implementation returns empty array of SurroundDescriptor implementations thus disabling the feature.

Returns:
SurroundDescriptor interface implementations for this particular language.

toString

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

getMimeTypes

public java.lang.String[] getMimeTypes()
Returns the list of MIME types corresponding to the language. The language MIME type is used for specifying the base language of a JSP page.

Returns:
The list of MIME types.

getID

@NotNull
public java.lang.String getID()
Returns a user-readable name of the language.

Returns:
the name of the language.