当前位置: 首页>>代码示例>>Java>>正文


Java MultiHostRegistrar类代码示例

本文整理汇总了Java中com.intellij.lang.injection.MultiHostRegistrar的典型用法代码示例。如果您正苦于以下问题:Java MultiHostRegistrar类的具体用法?Java MultiHostRegistrar怎么用?Java MultiHostRegistrar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MultiHostRegistrar类属于com.intellij.lang.injection包,在下文中一共展示了MultiHostRegistrar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final MultiHostRegistrar injectionPlacesRegistrar, @NotNull PsiElement context) {
  final PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;
  InjectedLanguagePlaces placesRegistrar = new InjectedLanguagePlaces() {
    @Override
    public void addPlace(@NotNull Language language, @NotNull TextRange rangeInsideHost, @NonNls @Nullable String prefix, @NonNls @Nullable String suffix) {
      injectionPlacesRegistrar
        .startInjecting(language)
        .addPlace(prefix, suffix, host, rangeInsideHost)
        .doneInjecting();
    }
  };
  for (LanguageInjector injector : Extensions.getExtensions(LanguageInjector.EXTENSION_POINT_NAME)) {
    injector.getLanguagesToInject(host, placesRegistrar);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InjectedLanguageManagerImpl.java

示例2: startInjecting

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
@Override
@NotNull
public MultiHostRegistrar startInjecting(@NotNull Language language) {
  escapers = new SmartList<LiteralTextEscaper<? extends PsiLanguageInjectionHost>>();
  shreds = new SmartList<PsiLanguageInjectionHost.Shred>();
  outChars = new StringBuilder();

  if (!cleared) {
    clear();
    throw new IllegalStateException("Seems you haven't called doneInjecting()");
  }

  if (LanguageParserDefinitions.INSTANCE.forLanguage(language) == null) {
    ReferenceInjector injector = ReferenceInjector.findById(language.getID());
    if (injector == null) {
      throw new UnsupportedOperationException("Cannot inject language '" + language + "' since its getParserDefinition() returns null");
    }
    myLanguage = null;
    myReferenceInjector = injector;
  }
  myLanguage = language;

  return this;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MultiHostRegistrarImpl.java

示例3: registerCommentInjection

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
@NotNull
private static PyInjectionUtil.InjectionResult registerCommentInjection(@NotNull MultiHostRegistrar registrar,
                                                                        @NotNull PsiLanguageInjectionHost host) {
  final String text = host.getText();
  final Matcher m = PyTypingTypeProvider.TYPE_COMMENT_PATTERN.matcher(text);
  if (m.matches()) {
    final String annotationText = m.group(1);
    if (annotationText != null && isTypingAnnotation(annotationText)) {
      final int start = m.start(1);
      final int end = m.end(1);
      if (start < end && allowInjectionInComment(host)) {
        final Language language = PyDocstringLanguageDialect.getInstance();
        registrar.startInjecting(language);
        registrar.addPlace("", "", host, TextRange.create(start, end));
        registrar.doneInjecting();
        return new PyInjectionUtil.InjectionResult(true, true);
      }
    }
  }
  return PyInjectionUtil.InjectionResult.EMPTY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyTypingAnnotationInjector.java

示例4: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement host) {
  Pair<ASTNode, ASTNode> pair = parseConditionalCommentBoundaries(host);
  if (pair == null) {
    return;
  }
  final TextRange textRange = host.getTextRange();
  final int startOffset = textRange.getStartOffset();
  Language language = host.getParent().getLanguage();
  ASTNode conditionalStart = pair.first;
  ASTNode conditionalEnd = pair.second;
  TextRange range = new UnfairTextRange(conditionalStart.getTextRange().getEndOffset() - startOffset, conditionalEnd.getStartOffset() - startOffset);
  if (range.getStartOffset() < range.getEndOffset()) {
    registrar.startInjecting(language).addPlace(null, null, (PsiLanguageInjectionHost)host, range).doneInjecting();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:HtmlConditionalCommentInjector.java

示例5: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement host) {
  if (!host.isValid() || !(host instanceof XmlText) || !HtmlUtil.isHtmlTagContainingFile(host)) {
    return;
  }
  XmlTag scriptTag = ((XmlText)host).getParentTag();

  if (scriptTag == null) {
    return;
  }
  final Language language = getScriptLanguageToInject(scriptTag);

  if (language == null || HtmlScriptInjectionBlockerExtension.isInjectionBlocked(scriptTag, language)) {
    return;
  }

  if (LanguageUtil.isInjectableLanguage(language)) {
    registrar
      .startInjecting(language)
      .addPlace(null, null, (PsiLanguageInjectionHost)host, TextRange.create(0, host.getTextLength()))
      .doneInjecting();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:HtmlScriptLanguageInjector.java

示例6: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
  if (!(context instanceof PsiLanguageInjectionHost) || !((PsiLanguageInjectionHost)context).isValidHost()) return;
  PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;

  PsiFile containingFile = context.getContainingFile();
  InjectedLanguage injectedLanguage = myRegistry.getLanguageFor(host, containingFile);
  Language language = injectedLanguage != null ? injectedLanguage.getLanguage() : null;
  if (language == null) return;

  final ElementManipulator<PsiLanguageInjectionHost> manipulator = ElementManipulators.getManipulator(host);
  if (manipulator == null) return;
  List<Trinity<PsiLanguageInjectionHost, InjectedLanguage,TextRange>> trinities =
    Collections.singletonList(Trinity.create(host, injectedLanguage, manipulator.getRangeInElement(host)));
  InjectorUtils.registerInjection(language, trinities, containingFile, registrar);
  InjectorUtils.registerSupport(myRegistry.getLanguageInjectionSupport(), false, registrar);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TemporaryPlacesInjector.java

示例7: registerInjectionSimple

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
public static boolean registerInjectionSimple(@NotNull PsiLanguageInjectionHost host,
                                              @NotNull BaseInjection injection,
                                              @Nullable LanguageInjectionSupport support,
                                              @NotNull MultiHostRegistrar registrar) {
  Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
  if (language == null) return false;

  InjectedLanguage injectedLanguage =
    InjectedLanguage.create(injection.getInjectedLanguageId(), injection.getPrefix(), injection.getSuffix(), false);

  List<TextRange> ranges = injection.getInjectedArea(host);
  List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list = ContainerUtil.newArrayListWithCapacity(ranges.size());

  for (TextRange range : ranges) {
    list.add(Trinity.create(host, injectedLanguage, range));
  }
  //if (host.getChildren().length > 0) {
  //  host.putUserData(LanguageInjectionSupport.HAS_UNPARSABLE_FRAGMENTS, Boolean.TRUE);
  //}
  registerInjection(language, list, host.getContainingFile(), registrar);
  if (support != null) {
    registerSupport(support, true, registrar);
  }
  return !ranges.isEmpty();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:InjectorUtils.java

示例8: registerInjection

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
public static void registerInjection(Language language, List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list, PsiFile containingFile, MultiHostRegistrar registrar) {
  // if language isn't injected when length == 0, subsequent edits will not cause the language to be injected as well.
  // Maybe IDEA core is caching a bit too aggressively here?
  if (language == null/* && (pair.second.getLength() > 0*/) {
    return;
  }
  boolean injectionStarted = false;
  for (Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange> trinity : list) {
    final PsiLanguageInjectionHost host = trinity.first;
    if (host.getContainingFile() != containingFile) continue;

    final TextRange textRange = trinity.third;
    final InjectedLanguage injectedLanguage = trinity.second;

    if (!injectionStarted) {
      registrar.startInjecting(language);
      injectionStarted = true;
    }
    registrar.addPlace(injectedLanguage.getPrefix(), injectedLanguage.getSuffix(), host, textRange);
  }
  if (injectionStarted) {
    registrar.doneInjecting();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:InjectorUtils.java

示例9: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
  if (!(context instanceof PsiLanguageInjectionHost) || context instanceof PsiComment) return;
  if (!((PsiLanguageInjectionHost)context).isValidHost()) return;
  PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;

  boolean applicableFound = false;
  for (LanguageInjectionSupport support : mySupports) {
    if (!support.isApplicableTo(host)) continue;
    if (support == myInjectorSupport && applicableFound) continue;
    applicableFound = true;

    BaseInjection injection = support.findCommentInjection(host, null);
    if (injection == null) continue;
    if (!InjectorUtils.registerInjectionSimple(host, injection, support, registrar)) continue;
    return;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CommentLanguageInjector.java

示例10: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement host) {
  if (SCRIPT_PATTERN.accepts(host)) {
    final List<String> registeredLanguages = JavaFxPsiUtil.parseInjectedLanguages((XmlFile)host.getContainingFile());
    for (Language language : Language.getRegisteredLanguages()) {
      for (String registeredLanguage : registeredLanguages) {
        if (StringUtil.equalsIgnoreCase(language.getID(), registeredLanguage)) {
          registrar.startInjecting(language)
            .addPlace(null, null, (PsiLanguageInjectionHost) host,
                      TextRange.from(0, host.getTextLength() - 1))
            .doneInjecting();
          break;
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ScriptLanguageInjector.java

示例11: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final MultiHostRegistrar injectionPlacesRegistrar, @NotNull PsiElement context) {
  final PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;
  InjectedLanguagePlaces placesRegistrar = new InjectedLanguagePlaces() {
    @Override
    public void addPlace(@NotNull Language language, @NotNull TextRange rangeInsideHost, @NonNls @Nullable String prefix, @NonNls @Nullable String suffix) {
      ProperTextRange.assertProperRange(rangeInsideHost);
      injectionPlacesRegistrar
        .startInjecting(language)
        .addPlace(prefix, suffix, host, rangeInsideHost)
        .doneInjecting();
    }
  };
  for (LanguageInjector injector : Extensions.getExtensions(LanguageInjector.EXTENSION_POINT_NAME)) {
    injector.getLanguagesToInject(host, placesRegistrar);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:InjectedLanguageManagerImpl.java

示例12: startInjecting

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
@Override
@NotNull
public MultiHostRegistrar startInjecting(@NotNull Language language) {
  escapers = new SmartList<LiteralTextEscaper<? extends PsiLanguageInjectionHost>>();
  shreds = new SmartList<PsiLanguageInjectionHost.Shred>();
  outChars = new StringBuilder();

  if (!cleared) {
    clear();
    throw new IllegalStateException("Seems you haven't called doneInjecting()");
  }

  if (LanguageParserDefinitions.INSTANCE.forLanguage(language) == null) {
    throw new UnsupportedOperationException("Cannot inject language '" + language + "' since its getParserDefinition() returns null");
  }
  myLanguage = language;

  return this;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:MultiHostRegistrarImpl.java

示例13: registerInjectionSimple

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
public static boolean registerInjectionSimple(@NotNull PsiLanguageInjectionHost host,
                                              @NotNull BaseInjection injection,
                                              @Nullable LanguageInjectionSupport support,
                                              @NotNull MultiHostRegistrar registrar) {
  Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
  if (language == null) return false;

  InjectedLanguage injectedLanguage =
    InjectedLanguage.create(injection.getInjectedLanguageId(), injection.getPrefix(), injection.getSuffix(), false);

  List<TextRange> ranges = injection.getInjectedArea(host);
  List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list = ContainerUtil.newArrayListWithExpectedSize(ranges.size());

  for (TextRange range : ranges) {
    list.add(Trinity.create(host, injectedLanguage, range));
  }
  //if (host.getChildren().length > 0) {
  //  host.putUserData(LanguageInjectionSupport.HAS_UNPARSABLE_FRAGMENTS, Boolean.TRUE);
  //}
  registerInjection(language, list, host.getContainingFile(), registrar);
  if (support != null) {
    registerSupport(support, true, registrar);
  }
  return !ranges.isEmpty();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:InjectorUtils.java

示例14: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
  if (!(context instanceof PsiLanguageInjectionHost) || !((PsiLanguageInjectionHost)context).isValidHost()) return;
  PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;

  boolean applicableFound = false;
  for (LanguageInjectionSupport support : mySupports) {
    if (!support.isApplicableTo(host)) continue;
    if (support == myInjectorSupport && applicableFound) continue;
    applicableFound = true;

    BaseInjection injection = support.findCommentInjection(host, null);
    if (injection == null) continue;
    if (!InjectorUtils.registerInjectionSimple(host, injection, support, registrar)) continue;
    return;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:CommentLanguageInjector.java

示例15: processAnnotations

import com.intellij.lang.injection.MultiHostRegistrar; //导入依赖的package包/类
private static void processAnnotations(MultiHostRegistrar registrar,
                                       PsiLanguageInjectionHost host,
                                       PsiModifierListOwner annotationOwner) {
  final Pair<String, ? extends Set<String>> pair =
    Configuration.getInstance().getAdvancedConfiguration().getLanguageAnnotationPair();

  final PsiAnnotation[] annotations = getAnnotationFrom(annotationOwner, pair, true, true);
  if (annotations.length > 0) {
    BaseInjection injection = new BaseInjection(GroovyLanguageInjectionSupport.GROOVY_SUPPORT_ID);

    injection.setPrefix(StringUtil.notNullize(AnnotationUtilEx.calcAnnotationValue(annotations, "prefix")));
    injection.setSuffix(StringUtil.notNullize(AnnotationUtilEx.calcAnnotationValue(annotations, "suffix")));
    injection.setInjectedLanguageId(StringUtil.notNullize(AnnotationUtilEx.calcAnnotationValue(annotations, "value")));

    LanguageInjectionSupport support = InjectorUtils.findInjectionSupport(GroovyLanguageInjectionSupport.GROOVY_SUPPORT_ID);
    InjectorUtils.registerInjectionSimple(host, injection, support, registrar);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:GrConcatenationInjector.java


注:本文中的com.intellij.lang.injection.MultiHostRegistrar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。