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


Java InjectedLanguagePlaces类代码示例

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


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

示例1: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host, @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar) {
  if (!(host instanceof XmlText)) return;

  final XmlText xmlText = (XmlText)host;

  if (!MavenPluginParamInfo.isSimpleText(xmlText)) return;

  MavenPluginParamInfo.ParamInfoList infoList = MavenPluginParamInfo.getParamInfoList(xmlText);
  for (MavenPluginParamInfo.ParamInfo info : infoList) {
    Language language = info.getLanguage();

    if (language == null) {
      MavenParamLanguageProvider provider = info.getLanguageProvider();
      if (provider != null) {
        language = provider.getLanguage(xmlText, infoList.getDomCfg());
      }
    }

    if (language != null) {
      injectionPlacesRegistrar.addPlace(language, TextRange.from(0, host.getTextLength()), info.getLanguageInjectionPrefix(), info.getLanguageInjectionSuffix());
      return;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MavenPluginConfigurationLanguageInjector.java

示例2: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectedLanguagePlaces) {
    if (host.getLanguage().isKindOf(JavaScriptLanguage) &&
            host.getClass().getSimpleName().equals(TEMPLATE_STRING)) {
        String hostText = host.getText();
        if (!hostText.contains("${") &&
                hostText.startsWith(prefix) && hostText.endsWith(suffix)) {
            injectedLanguagePlaces.addPlace(
                    GraphQLLanguage.INSTANCE,
                    new TextRange(
                            prefix.length(),
                            hostText.length() - suffix.length()
                    ),
                    null, null);
        }
    }
}
 
开发者ID:Gregoor,项目名称:graphql-intellij-plugin,代码行数:18,代码来源:GraphQLLanguageInjector.java

示例3: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(
        @NotNull PsiLanguageInjectionHost host,
        @NotNull InjectedLanguagePlaces injectionPlacesRegistrar)
{
    // we accept only PHP literal expressions, such as docBlocks and string for PointcutBuilder->method('<expr>')
    if (!(host instanceof StringLiteralExpression)) {
        return;
    }

    StringLiteralExpression literalExpression = (StringLiteralExpression) host;

    boolean enableInjection = CodePattern.isInsideAnnotation(literalExpression, GO_AOP_ANNOTATION);
    enableInjection |= CodePattern.isInsidePointcutBuilderMethod(literalExpression);

    if (enableInjection) {
        TextRange rangeInsideHost = new TextRange(1, Math.max(literalExpression.getTextLength()-1, 1));
        injectionPlacesRegistrar.addPlace(PointcutQueryLanguage.INSTANCE, rangeInsideHost, null, null);
    }
}
 
开发者ID:goaop,项目名称:idea-plugin,代码行数:21,代码来源:PointcutQueryLanguageInjector.java

示例4: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host,
                                 @NotNull final InjectedLanguagePlaces places) {
    final boolean isSelectQuery = host.getText().trim().toUpperCase().startsWith("SELECT");
    final boolean isDataSetFile = host.getContainingFile().getText().startsWith("<dataset>");
    if (isDataSetFile && isSelectQuery) {
        final Language language = Language.findLanguageByID("SQL");
        if (language != null) {
            try {
                places.addPlace(language, TextRange.from(0, host.getTextLength()), null, null);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:kTT,项目名称:dbunit-extractor,代码行数:17,代码来源:SQLInjector.java

示例5: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(
    @NotNull final PsiLanguageInjectionHost host,
    @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar
) {
    final PsiElement hostParent = host.getParent();
    if (host instanceof ImpexStringImpl) {
        final String hostString = StringUtil.unquoteString(host.getText()).toLowerCase();
        if (StringUtil.trim(hostString).startsWith("select ")) {
            registerInjectionPlace(injectionPlacesRegistrar, host);
        }
    }

    if (hostParent != null) {
        if (hostParent.getParent() instanceof PsiMethodCallExpressionImpl) {
            final PsiMethodCallExpressionImpl callExpression = (PsiMethodCallExpressionImpl) hostParent.getParent();
            final PsiMethod method = callExpression.resolveMethod();
            if (method != null) {
                final PsiClass containingClass = method.getContainingClass();
                if (containingClass != null
                    && "FlexibleSearchService".equals(containingClass.getName())
                    && "search".equals(method.getName())) {

                    registerInjectionPlace(injectionPlacesRegistrar, host);
                }
            }
        }
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:30,代码来源:FlexibleSearchInjector.java

示例6: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host,
                                 @NotNull InjectedLanguagePlaces injectedLanguagePlaces) {
    if (MuleConfigUtils.isMuleFile(host.getContainingFile())) {
        if (host instanceof XmlAttributeValue) {
            // Try to inject a language, somewhat abusing the lazy evaluation of predicates :(
            for (Pair<String, String> language : languages) {
                if (tryInjectLanguage(language.getFirst(), language.getSecond(), host, injectedLanguagePlaces)) {
                    break;
                }
            }
        } else if (host instanceof XmlText) {
            final XmlTag tag = ((XmlText) host).getParentTag();
            if (tag != null) {
                final QName tagName = MuleConfigUtils.getQName(tag);
                if (tagName.equals(globalFunctions) || tagName.equals(expressionComponent) || tagName.equals(expressionTransformer)) {
                    final String scriptingName = MelLanguage.MEL_LANGUAGE_ID;
                    injectLanguage(host, injectedLanguagePlaces, scriptingName);
                } else if (tagName.equals(scriptingScript)) {
                    final String engine = tag.getAttributeValue("engine");
                    if (engine != null) {
                        injectLanguage(host, injectedLanguagePlaces, StringUtil.capitalize(engine));
                    }
                } else if (tagName.equals(dwSetPayload) || tagName.equals(dwSetProperty) || tagName.equals(dwSetVariable) || tagName.equals(dwSetSessionVar)) {
                    injectLanguage(host, injectedLanguagePlaces, WEAVE_LANGUAGE_ID);
                }
            }
        }
    }
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:31,代码来源:MuleLanguageInjector.java

示例7: injectLanguage

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
private void injectLanguage(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectedLanguagePlaces, String scriptingName) {
    final Language requiredLanguage = Language.findLanguageByID(scriptingName);
    if (requiredLanguage != null) {
        final TextRange range = TextRange.from(0, host.getTextRange().getLength());
        injectedLanguagePlaces.addPlace(requiredLanguage, range, null, null);
    }
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:8,代码来源:MuleLanguageInjector.java

示例8: tryInjectLanguage

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
private boolean tryInjectLanguage(@NotNull String langPrefix,
                                  @NotNull String languageId,
                                  @NotNull PsiLanguageInjectionHost host,
                                  @NotNull InjectedLanguagePlaces injectedLanguagePlaces) {
    if (isExpectedLocalName(langPrefix, host)) {
        injectLanguage(langPrefix, languageId, host, injectedLanguagePlaces);
        return true;
    }
    return false;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:11,代码来源:MuleLanguageInjector.java

示例9: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {

    if (!(host instanceof CupJavaImpl) || !(settings.ENABLE_JAVA_INJECTION)) {
        return;
    }
    final CupJavaImpl cupJavaCode = (CupJavaImpl) host;
    final String text = cupJavaCode.getText();
    if (!(text.startsWith(PREFIX) && text.endsWith(SUFFIX))) {
        return;
    }
    injectionPlacesRegistrar.addPlace(JavaLanguage.INSTANCE, new TextRange(SUFFIX.length(), text.length() - SUFFIX.length()), "public class Dummy { public void dummyMethod(){", "}}");
}
 
开发者ID:Tirke,项目名称:cup-plugin,代码行数:14,代码来源:CupJavaInjector.java

示例10: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
    Iterator it = myInjectionConfiguration.getInjections("fusion").iterator();
    while(it.hasNext()) {
        BaseInjection injection = (BaseInjection) it.next();
        if (injection.acceptsPsiElement(host)) {
            Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
            if (language != null) {
                injectionPlacesRegistrar.addPlace(language, new TextRange(0, host.getTextLength()), "", "");
            }
        }
    }
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:14,代码来源:FusionLanguageInjector.java

示例11: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
  if (!(host instanceof XmlAttributeValue)) {
    return;
  }
  String valueText = ((XmlAttributeValue)host).getValue();
  if (valueText.length() <= PREFIX_BINDING_EXPR.length() || !valueText.startsWith(PREFIX_BINDING_EXPR)) {
    return;
  }

  PsiElement parent = host.getParent();
  if (!(parent instanceof XmlAttribute)) return;
  GenericAttributeValue element = DomManager.getDomManager(host.getProject()).getDomElement((XmlAttribute)parent);
  if (element == null || !(element.getParent() instanceof AndroidDomElement)) return;

  // Parser only parses the expression, not the prefix '@{' or the suffix '}'. Extract the start/end index of the expression.
  String unescapedValue = host.getText();
  int startIndex = unescapedValue.indexOf(PREFIX_BINDING_EXPR.charAt(0)) + PREFIX_BINDING_EXPR.length();
  int endIndex;
  if (valueText.endsWith("}")) {
    endIndex = unescapedValue.lastIndexOf('}');
  } else {
    if (host.getNode().getLastChildNode().getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      endIndex = host.getLastChild().getStartOffsetInParent();
    } else {
      endIndex = unescapedValue.length();
    }
  }
  injectionPlacesRegistrar.addPlace(DbLanguage.INSTANCE, TextRange.from(startIndex, endIndex-startIndex), null, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:DbLanguageInjector.java

示例12: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
	if(ApplicationManager.getApplication().isUnitTestMode()) {
		// intellij unit test env doesn't properly support language injection in combination with formatter tests, so skip injection in that case
		return;
	}
	if (host instanceof PsiComment && host.getLanguage() == JSGraphQLEndpointLanguage.INSTANCE) {
		injectionPlacesRegistrar.addPlace(JSGraphQLEndpointDocLanguage.INSTANCE, TextRange.create(0, host.getTextLength()), "", "");
	}
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:11,代码来源:JSGraphQLEndpointDocInjector.java

示例13: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
  if (host instanceof HaxeRegularExpression) {
    final String text = host.getText();
    final TextRange textRange = new TextRange(text.indexOf('/') + 1, text.lastIndexOf('/'));
    injectionPlacesRegistrar.addPlace(RegExpLanguage.INSTANCE, textRange, null, null);
  }
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:9,代码来源:RegexLanguageInjector.java

示例14: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host, @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar) {
  if (host instanceof RestLine) {
    int start = 0;
    int end = host.getTextLength() - 1;
    final String text = host.getText();
    final List<String> strings = StringUtil.split(text, "\n", false);

    boolean gotExample = false;

    int currentPosition = 0;
    boolean endsWithSlash = false;
    for (String string : strings) {
      final String trimmedString = string.trim();
      if (!trimmedString.startsWith(">>>") && !trimmedString.startsWith("...") && gotExample && start < end) {
        gotExample = false;
        if (!endsWithSlash)
          injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end),  null, null);
      }
      if (endsWithSlash) {
        endsWithSlash = false;
        injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(),
                                          TextRange.create(start, getEndOffset(currentPosition, string)),  null, null);
      }

      if (trimmedString.startsWith(">>>")) {
        if (trimmedString.endsWith("\\"))
          endsWithSlash = true;

        if (!gotExample)
          start = currentPosition;

        gotExample = true;
        end = getEndOffset(currentPosition, string);
      }
      else if (trimmedString.startsWith("...") && gotExample) {
        if (trimmedString.endsWith("\\"))
          endsWithSlash = true;

        end = getEndOffset(currentPosition, string);
      }
      currentPosition += string.length();
    }
    if (gotExample && start < end)
      injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end),  null, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:PyRestDocstringLanguageInjector.java

示例15: getLanguagesToInject

import com.intellij.psi.InjectedLanguagePlaces; //导入依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host, @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar) {
  if (!(host instanceof PyStringLiteralExpression)) {
    return;
  }
  final Module module = ModuleUtilCore.findModuleForPsiElement(host);
  if (module == null || !PyDocumentationSettings.getInstance(module).isAnalyzeDoctest()) return;

  final PyDocStringOwner
    docStringOwner = PsiTreeUtil.getParentOfType(host, PyDocStringOwner.class);
  if (docStringOwner != null && host.equals(docStringOwner.getDocStringExpression())) {
    int start = 0;
    int end = host.getTextLength() - 1;
    final String text = host.getText();

    final Pair<String,String> quotes = PythonStringUtil.getQuotes(text);
    final List<String> strings = StringUtil.split(text, "\n", false);

    boolean gotExample = false;

    int currentPosition = 0;
    int maxPosition = text.length();
    boolean endsWithSlash = false;
    for (String string : strings) {
      final String trimmedString = string.trim();
      if (!trimmedString.startsWith(">>>") && !trimmedString.startsWith("...") && gotExample && start < end) {
        gotExample = false;
        if (!endsWithSlash)
          injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end),  null, null);
      }
      final String closingQuote = quotes == null ? text.substring(0, 1) : quotes.second;

      if (endsWithSlash && !trimmedString.endsWith("\\")) {
        endsWithSlash = false;
        injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(),
                                          TextRange.create(start, getEndOffset(currentPosition, string, maxPosition, closingQuote)),  null, null);
      }

      if (trimmedString.startsWith(">>>")) {
        if (trimmedString.endsWith("\\"))
          endsWithSlash = true;

        if (!gotExample)
          start = currentPosition;

        gotExample = true;
        end = getEndOffset(currentPosition, string, maxPosition, closingQuote);
      }
      else if (trimmedString.startsWith("...") && gotExample) {
        if (trimmedString.endsWith("\\"))
          endsWithSlash = true;

        end = getEndOffset(currentPosition, string, maxPosition, closingQuote);
      }
      currentPosition += string.length();
    }
    if (gotExample && start < end)
      injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end),  null, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:61,代码来源:PyDocstringLanguageInjector.java


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