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


Java CompletionParameters类代码示例

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


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

示例1: extendWithTemplateDefinitionLevelKeywords

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
/**
 * Complete the "visibility" and "stricthtml" keywords in template definition open tags.
 */
private void extendWithTemplateDefinitionLevelKeywords() {
  extend(
      CompletionType.BASIC,
      psiElement().andOr(psiElement().inside(SoyBeginTemplate.class)),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            @NotNull CompletionParameters completionParameters,
            ProcessingContext processingContext,
            @NotNull CompletionResultSet completionResultSet) {
          if (isPrecededBy(completionParameters.getPosition(),
              elt -> elt instanceof SoyTemplateDefinitionIdentifier)) {
            completionResultSet.addElement(
                LookupElementBuilder.create("visibility=\"private\""));
            completionResultSet.addElement(
                LookupElementBuilder.create("stricthtml=\"true\""));
          }
        }
      });
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:24,代码来源:SoyCompletionContributor.java

示例2: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    List<TSVarExpr> variables = new ArrayList<>();
    for (PsiElement current = parameters.getPosition().getPrevSibling(); current != null; current = current.getPrevSibling()) {
        if (current.getNode().getElementType().equals(TSTypes.FUNCTION))
            break;

        if (current.getNode().getElementType().equals(TSTypes.LOCALVAR)) {
            String prefixless = current.getText().substring(1);
            result.addElement(
                    LookupElementBuilder.create(prefixless)
                    .withPresentableText(current.getText())
                    .withCaseSensitivity(false)
            );
        }
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:18,代码来源:TSLocalVariableCompletionContributor.java

示例3: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    String namespace = parameters.getPosition().getPrevSibling().getPrevSibling().getText();

    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);

    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() == TSFunctionType.GLOBAL)
            continue;
        if (namespace != null && !function.getNamespace().equalsIgnoreCase(namespace))
            continue;

        result.addElement(
                LookupElementBuilder.create(function.getFunctionName())
                        .withCaseSensitivity(false)
                        .withPresentableText(function.getNamespace() + "::" + function.getFunctionName())
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:23,代码来源:TSGlobalNSCallCompletionContributor.java

示例4: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    //All global functions
    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() != TSFunctionType.GLOBAL)
            continue;

        result.addElement(
                LookupElementBuilder.create(function)
                        .withCaseSensitivity(false)
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:18,代码来源:TSGlobalCallCompletionContributor.java

示例5: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
    MerlinService merlin = ApplicationManager.getApplication().getComponent(MerlinService.class);

    PsiFile originalFile = parameters.getOriginalFile();
    String text = originalFile.getText();
    LineNumbering lineNumbering = new LineNumbering(text);

    String suitablePrefix = findSuitablePrefix(parameters, text);

    MerlinPosition position = lineNumbering.offsetToPosition(parameters.getOffset());
    MerlinCompletion completion = merlin.completions(originalFile.getName(), text, position, suitablePrefix);

    for (MerlinCompletionEntry entry : completion.entries) {
        resultSet.addElement(LookupElementBuilder.
                create(entry.name).
                withIcon(getIcon(entry)).
                withTypeText(entry.desc));
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:21,代码来源:MerlinCompletionProvider.java

示例6: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getOriginalElement();
    if (position == null || !(position instanceof XmlElement)) {
        return;
    }


    DiIndex diIndex = DiIndex.getInstance(position.getProject());
    PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) position);
    if (phpClass != null) {
        Method constructor = phpClass.getConstructor();
        if (constructor != null) {
            for (Parameter parameter : constructor.getParameters()) {
                result.addElement(
                        LookupElementBuilder
                                .create(parameter.getName())
                                .withIcon(parameter.getIcon())
                );
            }
        }
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PhpConstructorArgumentCompletionProvider.java

示例7: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getOriginalElement();
    if (position == null) {
        return;
    }

    Collection<String> keys = LayoutIndex.getAllKeys(ContainerNameIndex.KEY, position.getProject());
    for (String key: keys) {
        result.addElement(
            LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON)
        );
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:17,代码来源:LayoutContainerCompletionContributor.java

示例8: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getOriginalElement();
    if (position == null) {
        return;
    }
    String prefix = result.getPrefixMatcher().getPrefix();

    Collection<String> moduleNames
            = FileBasedIndex.getInstance().getAllKeys(ModuleNameIndex.KEY, position.getProject());


    moduleNames.removeIf(m -> !m.startsWith(prefix));
    for (String moduleName : moduleNames) {
        result.addElement(
                LookupElementBuilder
                        .create(moduleName)
                        .withIcon(AllIcons.Modules.ModulesNode)
        );
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:24,代码来源:ModuleNameCompletionProvider.java

示例9: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getOriginalElement();
    if (position == null) {
        return;
    }

    Collection<String> keys = LayoutIndex.getAllKeys(BlockNameIndex.KEY, position.getProject());
    for (String key: keys) {
        result.addElement(
            LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON)
        );
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:17,代码来源:LayoutBlockCompletionContributor.java

示例10: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getOriginalElement();
    if (position == null) {
        return;
    }

    String prefix = result.getPrefixMatcher().getPrefix();

    DiIndex index = DiIndex.getInstance(position.getProject());
    Collection<String> elements = index.getAllVirtualTypeElementNames(new PlainPrefixMatcher(prefix), position.getResolveScope());

    for (String elementName:elements) {
        result.addElement(
                LookupElementBuilder
                        .create(elementName)
                        .withIcon(PhpIcons.CLASS_ICON)
        );
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:23,代码来源:VirtualTypeCompletionProvider.java

示例11: findViewVfs

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
private Collection<VirtualFile> findViewVfs(CompletionParameters parameters, CompletionResultSet result)
{
    Collection<VirtualFile> viewVfs = new ArrayList<>();

    Pattern pattern = Pattern.compile(RegExUtil.Magento.MODULE_NAME);
    Matcher matcher = pattern.matcher(result.getPrefixMatcher().getPrefix());

    if (matcher.find()) {
        viewVfs.addAll(
            FileBasedIndexUtil.findViewVfsByModuleName(matcher.group(0), parameters.getPosition().getProject())
        );
    } else {
        VirtualFile moduleVf =
            VfsUtil.findVfUp(parameters.getOriginalFile().getVirtualFile(), "registration.php");

        viewVfs.addAll(
            FileBasedIndexUtil.findViewVfsByModuleVf(moduleVf, parameters.getPosition().getProject())
        );
    }

    return viewVfs;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:23,代码来源:FilePathCompletionProvider.java

示例12: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getOriginalElement();
    if (position == null) {
        return;
    }

    List<XmlFile> targets = LayoutIndex.getLayoutFiles(position.getProject());
    if (targets.size() > 0) {
        for (XmlFile file : targets) {
            result.addElement(
                LookupElementBuilder
                        .create(file.getVirtualFile().getNameWithoutExtension())
                        .withIcon(PhpIcons.XML_TAG_ICON)
            );
        }
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:21,代码来源:LayoutUpdateCompletionContributor.java

示例13: addCompletions

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    PsiElement position = parameters.getPosition().getOriginalElement();
    if (position == null) {
        return;
    }

    PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) position);
    if (phpClass != null) {
        for (Method method : phpClass.getMethods()) {
            result.addElement(
                    LookupElementBuilder
                            .create(method.getName())
                            .withIcon(method.getIcon())
            );
        }
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:21,代码来源:PhpServiceMethodCompletionContributor.java

示例14: extendWithParameterTypes

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
/**
 * Complete types in {@param ...} .
 */
private void extendWithParameterTypes() {
  // Complete types in @param.
  extend(
      CompletionType.BASIC,
      psiElement()
          .andOr(
              psiElement().inside(SoyAtParamSingle.class).afterLeaf(":"),
              psiElement().inside(SoyAtInjectSingle.class).afterLeaf(":"),

              // List type literal.
              psiElement().inside(SoyListType.class).afterLeaf("<"),

              // Map type literal.
              psiElement().inside(SoyMapType.class).afterLeaf("<"),
              psiElement().inside(SoyMapType.class).afterLeaf(",")),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            @NotNull CompletionParameters completionParameters,
            ProcessingContext processingContext,
            @NotNull CompletionResultSet completionResultSet) {
          completionResultSet.addAllElements(soyTypeLiterals);
        }
      });
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:29,代码来源:SoyCompletionContributor.java

示例15: EmojiResourceCompletionContributor

import com.intellij.codeInsight.completion.CompletionParameters; //导入依赖的package包/类
public EmojiResourceCompletionContributor() {
	extend(CompletionType.BASIC, PlatformPatterns.psiElement(PsiElement.class), new CompletionProvider<CompletionParameters>() {
		@Override
		protected void addCompletions(@NotNull CompletionParameters completionParameters,
									  ProcessingContext processingContext,
									  @NotNull CompletionResultSet completionResultSet) {
			Document document = completionParameters.getEditor().getDocument();
			int lineStart = document.getLineStartOffset(document.getLineNumber(completionParameters.getOffset()));
			String lineText = document.getText(new TextRange(lineStart, completionParameters.getOffset()));
			if (includeCount(lineText) == 1) {
				for (Map.Entry<String, Icon> iconEntry : EmojiUtil.getEmojiMap().entrySet()) {
					completionResultSet.addElement(LookupElementBuilder.create(iconEntry.getKey(), ":" + iconEntry.getKey() + ":")
							.withIcon(iconEntry.getValue())
							.withInsertHandler((insertionContext, lookupElement) -> {
								int startOffset = insertionContext.getStartOffset();
								Document insertDocument = insertionContext.getDocument();
								if (startOffset > 0 && insertDocument.getCharsSequence().charAt(startOffset - 1) == ':') {
									insertDocument.deleteString(startOffset - 1, startOffset);
								}
							}));
				}
			}
		}
	});
}
 
开发者ID:syuchan1005,项目名称:EmojiPrefix,代码行数:26,代码来源:EmojiResourceCompletionContributor.java


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