ILanguage, ILanguageController and Language Support Infrastructure
From KDevelop
The language support infrastructure is designed to be similar to project management. Its goals are:
- use as many language supports as necessary at the same time
- be able to load several language supports for one source file good examples are mixed-source files like .php (php+html), .rhtml (ruby + html)
- be not dependent on projects
The language support infrastructure can be represented with following diagram (use fixed font to see it):
|------------------|
|---->| ILanguageSupport |
|-----------| | |------------------|
|---->| ILanguage |----|
| |-----------| | |------------------|
| |---->| BackgroundParser |
|---------------------| | |------------------|
| ILanguageController |--|
|---------------------| | |------------------|
| |---->| ILanguageSupport |
| |-----------| | |------------------|
|---->| ILanguage |----|
|-----------| | |------------------|
|---->| BackgroundParser |
|------------------|
LanguageController holds the set of already loaded languages and provides means to load more. For each language (defined by its "name") Language object exists. Each such language has a background parser and a actual support plugin that implements ILanguageSupport. This way the basic shell functionality (like language loading algorithm and background parser) is separated from language-specific stuff (like parsing).
Unlike KDevelop3, language support plugin is loaded not among with a project. Instead, when the source file is opened, the language controller asks plugin controller whether there are any language plugins (those that implement ILanguageSupport) that support a mime type of the file (those who set X-KDevelop-SupportedMimeTypes=...).
For each language support plugin found, the Language object (that implements ILanguage interface) is created and language support plugin is associated with it. Then each language is asked to return a ParseJob to process the file. This way several language supports are able to parse one file.
If Language object for given mimetype already exists, it is used and no plugin loading is performed.