use of com.perl5.lang.perl.psi.impl.PsiPerlPerlRegexImpl in project Perl5-IDEA by Camelcade.
the class Perl5RegexpInjector method getLanguagesToInject.
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
assert context instanceof PsiPerlPerlRegexImpl : "Got " + context;
if (!((PsiPerlPerlRegexImpl) context).isValidHost() || context.getTextLength() == 0) {
return;
}
int[] sourceOffset = new int[] { 0 };
boolean[] hasStarted = new boolean[] { false };
context.acceptChildren(new PsiElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (PsiUtilCore.getElementType(element) == REGEX_TOKEN) {
if (!hasStarted[0]) {
registrar.startInjecting(Perl5RegexpLanguage.INSTANCE);
hasStarted[0] = true;
}
registrar.addPlace(null, null, (PsiPerlPerlRegexImpl) context, TextRange.from(sourceOffset[0], element.getTextLength()));
}
sourceOffset[0] += element.getTextLength();
}
});
if (hasStarted[0]) {
registrar.doneInjecting();
}
}
Aggregations