HighlightVisitor in injection

In my custom language plugin I have java injection. I noticed that in injections do not work for visitors such as DefaultHighlighVisitor  and HighlighVisitorIml. This is normal behavior, or is it possible to somehow fix it? In language that I realize can be very large inserts java code, and I would be happy if the visitors could get to work in injections.

Any ideas?

4 comments
Comment actions Permalink

Thanks for answer. I looked at this but I still can't understand why HighlightVisitorImpl is not parsing inserted elements. I have inject element thant implements PsiLanguageInjectionHost, and class that extend MultiplePsiFilesPerDocumentFileViewProvider for HTML support.
But when I used debug I saw that filter in runHighlightVisitorsForInjected() return only DefaultHighlightVisitor at the same time highlights in highlightInjectedSyntax() worked well.

When I tried extend HighlightVisitorImpl, override method suitableForFile  and add class as extension in plugin.xml - highlight in injected elements missed. I think i created some loop by this brutal method.
@Override
public boolean suitableForFile(@NotNull final PsiFile file) {
      return file.getViewProvider() instanceof RythmFileViewProvider;          // it's my fileViewProvider that extend MultiplePsiFilesPerDocumentFileViewProvider and implements TemplateLanguageFileViewProvider
 }

0
Comment actions Permalink

Did you specify Java as the language when you injected it? Perhaps link some code.

0
Comment actions Permalink

Did you specify Java as the language when you injected it? Perhaps link some code.

Yeh, I wrote this:

class RythmInjector implements MultiHostInjector

@Override
 public void getLanguagesToInject(@NotNull MultiHostRegistrar multiHostRegistrar, @NotNull PsiElement element) {
      multiHostRegistrar.startInjecting(JavaLanguage.INSTANCE).addPlace(getPrefix(), getSuffix(), element, new TextRange(0, getTextLength())).doneInjecting();
 }
And I registered Injector.
        <multiHostInjector implementation="com.hamstercoders.plugin.ide.injection.RythmInjector"/>


Sorry, now I can not upload my code anywhere to give a link to it.:(

0

Please sign in to leave a comment.