當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。