本文整理汇总了Java中com.intellij.codeInsight.completion.CompletionType类的典型用法代码示例。如果您正苦于以下问题:Java CompletionType类的具体用法?Java CompletionType怎么用?Java CompletionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompletionType类属于com.intellij.codeInsight.completion包,在下文中一共展示了CompletionType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extendWithTemplateDefinitionLevelKeywords
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的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\""));
}
}
});
}
示例2: extendWithParameterTypes
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的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);
}
});
}
示例3: EmojiResourceCompletionContributor
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的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);
}
}));
}
}
}
});
}
示例4: ExtensionsNameContributor
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public ExtensionsNameContributor() {
extend(
CompletionType.BASIC,
tagAttributePattern("extension", "name", null),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
final HybrisProjectSettings hybrisProjectSettings
= HybrisProjectSettingsComponent.getInstance(parameters.getOriginalFile().getProject())
.getState();
final Set<String> extensions = hybrisProjectSettings.getCompleteSetOfAvailableExtensionsInHybris();
extensions.forEach(name -> result.addElement(LookupElementBuilder.create(name)));
}
}
);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:ExtensionsNameContributor.java
示例5: ProjectViewKeywordCompletionContributor
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public ProjectViewKeywordCompletionContributor() {
extend(
CompletionType.BASIC,
psiElement()
.withLanguage(ProjectViewLanguage.INSTANCE)
.withElementType(ProjectViewTokenType.IDENTIFIERS)
.andOr(psiElement().afterLeaf("\n"), psiElement().afterLeaf(psiElement().isNull())),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(
CompletionParameters parameters,
ProcessingContext context,
CompletionResultSet result) {
result.addAllElements(keywordLookups);
}
});
}
示例6: BuiltInSymbolCompletionContributor
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public BuiltInSymbolCompletionContributor() {
extend(
CompletionType.BASIC,
psiElement()
.withLanguage(BuildFileLanguage.INSTANCE)
.andNot(psiComment())
.withParent(ReferenceExpression.class)
.andNot(psiElement().inside(FuncallExpression.class))
.andNot(psiElement().afterLeaf(psiElement().withText("."))),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(
CompletionParameters parameters,
ProcessingContext context,
CompletionResultSet result) {
for (String symbol : BuiltInNamesProvider.GLOBALS) {
result.addElement(LookupElementBuilder.create(symbol));
}
}
});
}
示例7: testInsertDependency
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public void testInsertDependency() throws IOException {
createProjectPom("<groupId>test</groupId>\n" +
"<artifactId>project</artifactId>\n" +
"<version>1</version>\n" +
"<dependencies>\n" +
" <dependency>ju<caret></dependency>\n" +
"</dependencies>\n");
configTest(myProjectPom);
myFixture.complete(CompletionType.SMART);
assertContain(myFixture.getLookupElementStrings(), "4.0", "3.8.2");
myFixture.checkResult(createPomXml("<groupId>test</groupId>\n" +
"<artifactId>project</artifactId>\n" +
"<version>1</version>\n" +
"<dependencies>\n" +
" <dependency>\n" +
" <groupId>junit</groupId>\n" +
" <artifactId>junit</artifactId>\n" +
" <version><caret></version>\n" +
" </dependency>\n" +
"</dependencies>\n"));
}
示例8: performTestCompletionVariants
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
/**
* Tests completion variants on the input file {@code fileBefore} at caret position, verifying
* that all the entries in {@code expectedVariants} are present in the completion variants.
*/
protected void performTestCompletionVariants(String fileBefore, String... expectedVariants)
throws IOException {
copyFileToProject(fileBefore);
// TODO: figure out why this doesn't work getCompletionVariants() seems to return an empty list
// myFixture.testCompletionVariants(fileBefore, expectedVariants);
LookupElement[] completions = myFixture.complete(CompletionType.BASIC);
assertNotNull("Expected at least one completion in " + fileBefore, completions);
// Transform array of LookupElement into a List of Strings.
List<String> completionVariants =
Lists.transform(Arrays.asList(completions), new Function<LookupElement, String>() {
@Override
public String apply(LookupElement input) {
return input.getLookupString();
}
});
for (String variant : expectedVariants) {
assertContainsElements(completionVariants, variant);
}
}
示例9: testJavaAfterAmbeCompletion
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public void testJavaAfterAmbeCompletion() {
myFixture.configureByText("JavaCaretInMiddleOptionsTestData.java", getJavaAfterAmpOptionsTestData());
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assertThat(strings, Matchers.not(Matchers.contains("timer:trigger?repeatCount=10")));
assertThat(strings, Matchers.contains("timer:trigger?repeatCount=10&bridgeErrorHandler",
"timer:trigger?repeatCount=10&daemon",
"timer:trigger?repeatCount=10&delay",
"timer:trigger?repeatCount=10&exceptionHandler",
"timer:trigger?repeatCount=10&exchangePattern",
"timer:trigger?repeatCount=10&fixedRate",
"timer:trigger?repeatCount=10&pattern",
"timer:trigger?repeatCount=10&period",
"timer:trigger?repeatCount=10&synchronous",
"timer:trigger?repeatCount=10&time",
"timer:trigger?repeatCount=10&timer"));
assertTrue("There is less options", strings.size() < 13);
}
示例10: assertHasCompletions
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
private void assertHasCompletions(String path, String... expectedCompletions) throws Exception {
VirtualFile file = getProject().getBaseDir().findFileByRelativePath(path);
assertNotNull(file);
myFixture.configureFromExistingVirtualFile(file);
LookupElement[] elements = myFixture.complete(CompletionType.BASIC);
assertNotNull(elements);
Set<String> suggestions = Sets.newHashSetWithExpectedSize(elements.length);
for (LookupElement element : elements) {
suggestions.add(element.getLookupString());
}
for (String expected : expectedCompletions) {
String msg = String.format("%1$s not in available completions: {%2$s}", expected, Joiner.on(',').join(suggestions));
assertTrue(msg, suggestions.contains(expected));
}
}
示例11: testXmlAfterAmbeCompletion
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public void testXmlAfterAmbeCompletion() {
myFixture.configureByText("XmlCaretInMiddleOptionsTestData.xml", getXmlfterAmpOptionsTestData());
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assertThat(strings, not(contains("timer:trigger?repeatCount=10")));
assertThat(strings, contains("&bridgeErrorHandler",
"&daemon",
"&delay",
"&exceptionHandler",
"&exchangePattern",
"&fixedRate",
"&pattern",
"&period",
"&synchronous",
"&time",
"&timer"));
assertTrue("There is less options", strings.size() < 13);
}
示例12: doTestNamespaceCompletion
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
protected void doTestNamespaceCompletion(boolean systemNamespace, boolean customNamespace) throws IOException {
final VirtualFile file = copyFileToProject(getTestName(true) + ".xml");
myFixture.configureFromExistingVirtualFile(file);
myFixture.complete(CompletionType.BASIC);
final List<String> variants = myFixture.getLookupElementStrings();
assertNotNull(variants);
final List<String> expectedVariants = new ArrayList<String>();
if (systemNamespace) {
expectedVariants.add("http://schemas.android.com/apk/res/android");
}
if (customNamespace) {
expectedVariants.add("http://schemas.android.com/apk/res/p1.p2");
}
expectedVariants.add(SdkConstants.TOOLS_URI);
assertEquals(expectedVariants, variants);
}
示例13: testActiveQuery_Prefix
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public void testActiveQuery_Prefix() {
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
" \\test\\PersonModel::find()->where('per<caret>');");
myFixture.complete(CompletionType.BASIC);
assertEquals("'person'", myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getText());
}
示例14: testQuery_Prefix
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
public void testQuery_Prefix() {
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
" (new \\yii\\db\\Query())->where('per<caret>');");
myFixture.complete(CompletionType.BASIC);
assertEquals("'person'", myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getText());
}
示例15: extendWithVariableNamesInScope
import com.intellij.codeInsight.completion.CompletionType; //导入依赖的package包/类
/**
* Complete variable names that are in lang when in an expression.
*/
private void extendWithVariableNamesInScope() {
extend(
CompletionType.BASIC,
psiElement().andOr(
psiElement().inside(SoyExpr.class),
psiElement().inside(SoyBeginIf.class),
psiElement().inside(SoyBeginElseIf.class),
psiElement().inside(SoyBeginFor.class),
psiElement().inside(SoyBeginForeach.class),
psiElement().inside(SoyPrintStatement.class),
psiElement().inside(SoyBeginParamTag.class).and(
psiElement().afterLeafSkipping(psiElement(PsiWhiteSpace.class),
psiElement(SoyTypes.COLON)))
),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(
@NotNull CompletionParameters completionParameters,
ProcessingContext processingContext,
@NotNull CompletionResultSet completionResultSet) {
Collection<Variable> params =
Scope.getScopeOrEmpty(completionParameters.getPosition()).getVariables();
completionResultSet.addAllElements(
params
.stream()
.map(param -> "$" + param.name)
.map(LookupElementBuilder::create)
.collect(Collectors.toList()));
}
});
}