本文整理汇总了Java中consulo.codeInsight.completion.CompletionProvider类的典型用法代码示例。如果您正苦于以下问题:Java CompletionProvider类的具体用法?Java CompletionProvider怎么用?Java CompletionProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompletionProvider类属于consulo.codeInsight.completion包,在下文中一共展示了CompletionProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ShaderLabCGCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public ShaderLabCGCompletionContributor()
{
extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider()
{
@RequiredReadAction
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull final CompletionResultSet result)
{
Place shreds = InjectedLanguageUtil.getShreds(parameters.getOriginalFile());
for(PsiLanguageInjectionHost.Shred shred : shreds)
{
PsiLanguageInjectionHost host = shred.getHost();
if(host instanceof ShaderCGScript)
{
ShaderLabFile containingFile = (ShaderLabFile) host.getContainingFile();
ShaderReference.consumeProperties(containingFile, result::addElement);
}
}
}
});
}
示例2: CGCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public CGCompletionContributor()
{
extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider()
{
@RequiredReadAction
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
for(String keyword : CGKeywords.KEYWORDS)
{
result.addElement(LookupElementBuilder.create(keyword).bold());
}
for(String m : ourMethods)
{
result.addElement(LookupElementBuilder.create(m + "()").withIcon(AllIcons.Nodes.Method).withInsertHandler(ParenthesesInsertHandler.getInstance(true)));
}
}
});
}
示例3: extend
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
static void extend(CompletionContributor contributor)
{
contributor.extend(CompletionType.BASIC, CSharpPatterns.expressionStart(), new CompletionProvider()
{
@RequiredReadAction
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
PsiElement position = parameters.getPosition();
if(!CSharpModuleUtil.findLanguageVersion(position).isAtLeast(CSharpLanguageVersion._3_0))
{
return;
}
CSharpReferenceExpressionEx parent = (CSharpReferenceExpressionEx) position.getParent();
if(parent.getQualifier() != null || parent.kind() != CSharpReferenceExpression.ResolveToKind.ANY_MEMBER)
{
return;
}
CSharpCompletionUtil.elementToLookup(result, CSharpSoftTokens.FROM_KEYWORD, null, null);
}
});
}
示例4: ThriftKeywordCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public ThriftKeywordCompletionContributor()
{
extend(CompletionType.BASIC, psiElement().andOr(psiElement(ThriftTokenTypes.IDENTIFIER), psiElement(ThriftTokenTypes.STIDENTIFIER)), new CompletionProvider()
{
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
final Collection<String> suggestedKeywords = suggestKeywords(parameters.getPosition());
suggestedKeywords.retainAll(ThriftUtils.getKeywords());
for(String keyword : suggestedKeywords)
{
result.addElement(LookupElementBuilder.create(keyword));
}
}
});
}
示例5: RncCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public RncCompletionContributor()
{
CompletionProvider provider = new CompletionProvider()
{
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
String[] keywords = getKeywords(parameters.getPosition());
for(String keyword : keywords)
{
result.addElement(TailTypeDecorator.withTail(LookupElementBuilder.create(keyword).bold(), TailType.SPACE));
}
}
};
extend(null, psiElement().afterLeaf(psiElement(RncTokenTypes.KEYWORD_DEFAULT)), provider);
extend(null, psiElement().andNot(psiElement().inside(psiElement(RncTokenTypes.LITERAL))).
andNot(psiElement().afterLeaf(psiElement().withElementType(RncTokenTypes.KEYWORDS))), provider);
}
示例6: DtdCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public DtdCompletionContributor()
{
extend(CompletionType.BASIC, psiElement(), new CompletionProvider()
{
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
PsiElement position = parameters.getPosition();
PsiElement prev = PsiTreeUtil.prevVisibleLeaf(position);
if(prev != null && hasDtdKeywordCompletion(prev))
{
addKeywordCompletions(result.withPrefixMatcher(keywordPrefix(position, result.getPrefixMatcher().getPrefix())));
}
if(prev != null && prev.textMatches("%"))
{
addEntityCompletions(result, position);
}
}
});
}
示例7: HtmlCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public HtmlCompletionContributor()
{
extend(CompletionType.BASIC, psiElement().inside(XmlPatterns.xmlAttributeValue()), new CompletionProvider()
{
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
final PsiElement position = parameters.getPosition();
if(!hasHtmlAttributesCompletion(position))
{
return;
}
final XmlAttributeValue attributeValue = PsiTreeUtil.getParentOfType(position, XmlAttributeValue.class, false);
if(attributeValue != null && attributeValue.getParent() instanceof XmlAttribute)
{
for(String element : addSpecificCompletions((XmlAttribute) attributeValue.getParent()))
{
result.addElement(LookupElementBuilder.create(element));
}
}
}
});
}
示例8: ManifestCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public ManifestCompletionContributor() {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(ManifestTokenType.HEADER_NAME).withLanguage(ManifestLanguage.INSTANCE),
new CompletionProvider() {
public void addCompletions(@NotNull CompletionParameters completionparameters,
ProcessingContext processingcontext,
@NotNull CompletionResultSet completionresultset) {
for (HeaderParserEP ep : HeaderParserEP.EP_NAME.getExtensions()) {
if(ep.key.isEmpty()) { //dont show default ep
continue;
}
completionresultset.addElement(LookupElementBuilder.create(ep.key));
}
}
});
}
示例9: CSharpDocCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public CSharpDocCompletionContributor()
{
extend(CompletionType.BASIC, StandardPatterns.psiElement(CSharpDocTokenType.XML_NAME), new CompletionProvider()
{
@RequiredReadAction
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
PsiElement parent = parameters.getPosition().getParent();
if(parent instanceof CSharpDocTagImpl)
{
Collection<CSharpDocTagInfo> tags = CSharpDocTagManager.getInstance().getTags();
for(CSharpDocTagInfo tag : tags)
{
result.addElement(LookupElementBuilder.create(tag.getName()));
}
}
else if(parent instanceof CSharpDocAttribute)
{
CSharpDocTagInfo tagInfo = ((CSharpDocAttribute) parent).getTagInfo();
if(tagInfo == null)
{
return;
}
for(CSharpDocAttributeInfo attributeInfo : tagInfo.getAttributes())
{
result.addElement(LookupElementBuilder.create(attributeInfo.getName()));
}
}
}
});
}
示例10: HaxeSmartCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public HaxeSmartCompletionContributor() {
final PsiElementPattern.Capture<PsiElement> idInExpression =
psiElement().withSuperParent(1, HaxeIdentifier.class).withSuperParent(2, HaxeReference.class);
extend(CompletionType.SMART,
idInExpression.and(psiElement().withSuperParent(3, HaxeVarInit.class)),
new CompletionProvider() {
@Override
public void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
tryAddVariantsForEnums(result, parameters.getPosition());
}
});
}
示例11: CustomFileTypeCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public CustomFileTypeCompletionContributor() {
extend(CompletionType.BASIC, psiElement().inFile(psiFile().withFileType(instanceOf(CustomSyntaxTableFileType.class))), new CompletionProvider() {
@RequiredReadAction
@Override
public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull CompletionResultSet result) {
if (inCommentOrLiteral(parameters)) {
return;
}
FileType fileType = parameters.getOriginalFile().getFileType();
if (!(fileType instanceof CustomSyntaxTableFileType)) {
return;
}
SyntaxTable syntaxTable = ((CustomSyntaxTableFileType)fileType).getSyntaxTable();
String prefix = findPrefix(parameters.getPosition(), parameters.getOffset());
CompletionResultSet resultSetWithPrefix = result.withPrefixMatcher(prefix);
addVariants(resultSetWithPrefix, syntaxTable.getKeywords1());
addVariants(resultSetWithPrefix, syntaxTable.getKeywords2());
addVariants(resultSetWithPrefix, syntaxTable.getKeywords3());
addVariants(resultSetWithPrefix, syntaxTable.getKeywords4());
WordCompletionContributor.addWordCompletionVariants(resultSetWithPrefix, parameters, Collections.<String>emptySet());
}
});
}
示例12: PostfixTemplateCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public PostfixTemplateCompletionContributor() {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider() {
@RequiredReadAction
@Override
public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull CompletionResultSet result) {
Editor editor = parameters.getEditor();
if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates() ||
editor.getCaretModel().getCaretCount() != 1) {
/**
* disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
*/
return;
}
PsiFile originalFile = parameters.getOriginalFile();
PostfixLiveTemplate postfixLiveTemplate = PostfixTemplateCompletionContributor.getPostfixLiveTemplate(originalFile, editor);
if (postfixLiveTemplate != null) {
postfixLiveTemplate.addCompletions(parameters, result.withPrefixMatcher(new MyPrefixMatcher(result.getPrefixMatcher().getPrefix())));
String possibleKey = postfixLiveTemplate.computeTemplateKeyWithoutContextChecking(new CustomTemplateCallback(editor, originalFile));
if (possibleKey != null) {
result = result.withPrefixMatcher(possibleKey);
result.restartCompletionOnPrefixChange(
StandardPatterns.string().oneOf(postfixLiveTemplate.getAllTemplateKeys(originalFile, parameters.getOffset())));
}
}
}
});
}
示例13: XmlNonFirstCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public XmlNonFirstCompletionContributor()
{
extend(CompletionType.BASIC, psiElement().inside(xmlAttribute()), new XmlAttributeReferenceCompletionProvider());
extend(CompletionType.BASIC, psiElement().inside(xmlTag()), new TagNameReferenceCompletionProvider());
extend(CompletionType.BASIC, psiElement().inside(XmlPatterns.xmlAttributeValue()), new CompletionProvider()
{
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
PsiElement position = parameters.getPosition();
if(position.getNode().getElementType() != XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN)
{
return;
}
XmlAttribute attr = PsiTreeUtil.getParentOfType(position, XmlAttribute.class);
if(attr != null && !hasEnumerationReference(parameters, result))
{
final XmlAttributeDescriptor descriptor = attr.getDescriptor();
if(descriptor != null)
{
if(descriptor.isFixed() && descriptor.getDefaultValue() != null)
{
result.addElement(LookupElementBuilder.create(descriptor.getDefaultValue()));
return;
}
for(String value : getEnumeratedValues(attr))
{
result.addElement(LookupElementBuilder.create(value));
}
}
}
}
});
}
示例14: JavaScriptKeywordCompletionContributor
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public JavaScriptKeywordCompletionContributor()
{
extend(CompletionType.BASIC, StandardPatterns.psiElement().withParent(JSReferenceExpression.class), new CompletionProvider()
{
@RequiredReadAction
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
PsiElement position = parameters.getPosition();
JSReferenceExpression parent = (JSReferenceExpression) position.getParent();
if(parent.getQualifier() != null)
{
return;
}
boolean parentIsStatement = parent.getParent() instanceof JSExpressionStatement;
LookupElementBuilder functionKeyword = LookupElementBuilder.create("function");
functionKeyword = functionKeyword.bold();
if(parentIsStatement)
{
functionKeyword = functionKeyword.withInsertHandler(SpaceInsertHandler.INSTANCE);
}
else
{
functionKeyword = functionKeyword.withInsertHandler(ParenthesesInsertHandler.getInstance(false));
functionKeyword = functionKeyword.withPresentableText("function()");
}
result.addElement(functionKeyword);
result.addElement(LookupElementBuilder.create("var").withInsertHandler(SpaceInsertHandler.INSTANCE).bold());
}
});
}
示例15: extend
import consulo.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
static void extend(CompletionContributor contributor)
{
contributor.extend(CompletionType.BASIC, psiElement().andNot(psiElement().inside(DotNetXXXAccessor.class)), new CompletionProvider()
{
@RequiredReadAction
@Override
public void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet resultSet)
{
PsiElement position = completionParameters.getPosition();
final CSharpXXXAccessorOwner accessorOwner = PsiTreeUtil.getParentOfType(position, CSharpXXXAccessorOwner.class);
if(accessorOwner == null)
{
return;
}
PsiElement leftBrace = accessorOwner.getLeftBrace();
if(leftBrace == null)
{
return;
}
int textOffset = position.getTextOffset();
PsiElement rightBrace = accessorOwner.getRightBrace();
int rightTextRange = rightBrace == null ? -1 : rightBrace.getTextOffset();
if((rightTextRange == -1 || textOffset < rightTextRange) && textOffset > leftBrace.getTextOffset())
{
if(accessorOwner.hasModifier(DotNetModifier.ABSTRACT))
{
buildAccessorKeywordsCompletion(resultSet, accessorOwner, null);
}
else
{
buildAccessorKeywordsCompletion(resultSet, accessorOwner, new InsertHandler<LookupElement>()
{
@Override
@RequiredWriteAction
public void handleInsert(InsertionContext context, LookupElement item)
{
if(context.getCompletionChar() == '{')
{
context.setAddCompletionChar(false);
Editor editor = context.getEditor();
CaretModel caretModel = editor.getCaretModel();
int offset = caretModel.getOffset();
context.getDocument().insertString(offset, "{\n}");
caretModel.moveToOffset(offset + 1);
PsiElement elementAt = context.getFile().findElementAt(offset - 1);
context.commitDocument();
DotNetXXXAccessor accessor = PsiTreeUtil.getParentOfType(elementAt, DotNetXXXAccessor.class);
if(accessor != null)
{
CodeStyleManager.getInstance(context.getProject()).reformat(accessor);
}
EditorWriteActionHandler actionHandler = (EditorWriteActionHandler) EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
actionHandler.executeWriteAction(editor, DataManager.getInstance().getDataContext(editor.getContentComponent()));
}
}
});
}
}
}
});
}