本文整理汇总了Java中com.intellij.lang.injection.MultiHostRegistrar.addPlace方法的典型用法代码示例。如果您正苦于以下问题:Java MultiHostRegistrar.addPlace方法的具体用法?Java MultiHostRegistrar.addPlace怎么用?Java MultiHostRegistrar.addPlace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.lang.injection.MultiHostRegistrar
的用法示例。
在下文中一共展示了MultiHostRegistrar.addPlace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
}
示例3: 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