public interface MultiHostRegistrar
MultiHostRegistrar
by registering your own implementation of MultiHostInjector
andMultiHostInjector.getLanguagesToInject(MultiHostRegistrar, com.intellij.psi.PsiElement)
method.Modifier and Type | Method and Description |
---|---|
MultiHostRegistrar |
addPlace(java.lang.String prefix,
java.lang.String suffix,
PsiLanguageInjectionHost host,
TextRange rangeInsideHost)
Specifies the range in the host file to be considered as injected file part.
|
void |
doneInjecting()
The final part of the injecting process.
|
MultiHostRegistrar |
startInjecting(Language language)
Start injecting the
language in this place.
After you call startInjecting(Language) you will have to call
addPlace(String, String, PsiLanguageInjectionHost, TextRange) one or several times
and then call doneInjecting() .After that the text in ranges (denoted by one or several addPlace(String, String, PsiLanguageInjectionHost, TextRange) calls)
will be treated by IDE as a code in the language .For example, in this Java fragment String x = "<start>"+"</start>"; if you call - startInjecting(XMLLanguage.getInstance()); - addPlace(null, null, literal1, insideRange1); - addPlace(null, null, literal2, insideRange2); - doneInjecting(); You will have XML language injected in these string literals, along with its completion, navigation etc niceties. |
default MultiHostRegistrar |
startInjecting(Language language,
java.lang.String extension)
The variant of
startInjecting(Language) with explicitly specified file extension. |
MultiHostRegistrar startInjecting(Language language)
language
in this place.
After you call startInjecting(Language)
you will have to call
addPlace(String, String, PsiLanguageInjectionHost, TextRange)
one or several times
and then call doneInjecting()
.addPlace(String, String, PsiLanguageInjectionHost, TextRange)
calls)
will be treated by IDE as a code in the language
.String x = "<start>"+"</start>";
startInjecting(XMLLanguage.getInstance());
addPlace(null, null, literal1, insideRange1);
addPlace(null, null, literal2, insideRange2);
doneInjecting();
default MultiHostRegistrar startInjecting(Language language, java.lang.String extension)
startInjecting(Language)
with explicitly specified file extension.extension
- the created injected file name will have. Some parsers require specific extension. By default the extension is taken from the host file.MultiHostRegistrar addPlace(java.lang.String prefix, java.lang.String suffix, PsiLanguageInjectionHost host, TextRange rangeInsideHost)
prefix
- this part will be appended before.String html = "Hello <b>world</b>";
addPlace("<html><body>", "</body></html>", literal, insideRange);
suffix
- this part will be appended after.host
- the text range of which the language will be injected into.rangeInsideHost
- into which the language will be injected.String s = "xyz";
addPlace(prefix, suffix, literal, new TextRange(1, 4));
to inject inside double quotes.addPlace(prefix, suffix, literal, new TextRange(0, 5));
instead,for the required workflow.
void doneInjecting()
for a required workflow.