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


Java MultiHostRegistrar.startInjecting方法代码示例

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


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

示例1: 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

示例2: 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

示例3: registerInjection

import com.intellij.lang.injection.MultiHostRegistrar; //导入方法依赖的package包/类
protected PyInjectionUtil.InjectionResult registerInjection(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
  final Language language = getInjectedLanguage(context);
  if (language != null) {
    final PsiElement element = PyInjectionUtil.getLargestStringLiteral(context);
    if (element != null) {
      registrar.startInjecting(language);
      final PyInjectionUtil.InjectionResult result = PyInjectionUtil.registerStringLiteralInjection(element, registrar);
      if (result.isInjected()) {
        registrar.doneInjecting();
      }
      return result;
    }
  }
  return PyInjectionUtil.InjectionResult.EMPTY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PyInjectorBase.java

示例4: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
  final PsiElement contextParent = context.getParent();
  if (PyInjectionUtil.getLargestStringLiteral(context) == context && contextParent instanceof PyArgumentList) {
    final PyExpression[] args = ((PyArgumentList)contextParent).getArguments();
    int index = ArrayUtil.indexOf(args, context);
    PyCallExpression call = PsiTreeUtil.getParentOfType(context, PyCallExpression.class);
    if (call != null) {
      final PyExpression callee = call.getCallee();
      if (callee instanceof PyReferenceExpression && canBeRegexpCall(callee)) {
        final PsiPolyVariantReference ref = ((PyReferenceExpression)callee).getReference(PyResolveContext.noImplicits());
        if (ref != null) {
          final PsiElement element = ref.resolve();
          if (element != null && ScopeUtil.getScopeOwner(element) instanceof PyFile &&
              element.getContainingFile().getName().equals("re.py") && isRegexpMethod(element, index)) {
            final Language language = isVerbose(call) ? PythonVerboseRegexpLanguage.INSTANCE : PythonRegexpLanguage.INSTANCE;
            registrar.startInjecting(language);
            final PyInjectionUtil.InjectionResult result = PyInjectionUtil.registerStringLiteralInjection(context, registrar);
            if (result.isInjected()) {
              registrar.doneInjecting();
              if (!result.isStrict()) {
                final PsiFile file = getInjectedFile(registrar);
                if (file != null) {
                  file.putUserData(InjectedLanguageUtil.FRANKENSTEIN_INJECTION, Boolean.TRUE);
                }
              }
            }
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:PythonRegexpInjector.java

示例5: getLanguagesToInject

import com.intellij.lang.injection.MultiHostRegistrar; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {


    if(JSGraphQLLanguageInjectionUtil.isJSGraphQLLanguageInjectionTarget(context)) {

        final JSStringTemplateExpression template = (JSStringTemplateExpression)context;

        final TextRange graphQlTextRange = JSGraphQLLanguageInjectionUtil.getGraphQLTextRange(template);
        if(graphQlTextRange.isEmpty()) {
            // all whitespace
            return;
        }

        registrar.startInjecting(JSGraphQLLanguage.INSTANCE);

        final StringBuilder sb = new StringBuilder();
        final TextRange[] stringRanges = template.getStringRanges();
        int stringIndex = 0;
        boolean insideTemplate = false;
        for (ASTNode astNode : template.getNode().getChildren(null)) {
            if(astNode.getElementType() == JSTokenTypes.BACKQUOTE) {
                insideTemplate = true;
                continue;
            }
            if(astNode.getElementType() == JSTokenTypes.STRING_TEMPLATE_PART) {
                registrar.addPlace(sb.toString(), "", (PsiLanguageInjectionHost) template, stringRanges[stringIndex]);
                stringIndex++;
                sb.setLength(0);
            } else if(insideTemplate) {
                sb.append(astNode.getText());
            }
        }

        registrar.doneInjecting();
    }
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:38,代码来源:JSGraphQLTemplateFragmentLanguageInjector.java


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