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


Java CompletionProvider类代码示例

本文整理汇总了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);
				}
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:23,代码来源:ShaderLabCGCompletionContributor.java

示例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)));
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:21,代码来源:CGCompletionContributor.java

示例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);
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:24,代码来源:CSharpLinqCompletionContributor.java

示例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));
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-apache-thrift,代码行数:17,代码来源:ThriftKeywordCompletionContributor.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:19,代码来源:RncCompletionContributor.java

示例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);
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:21,代码来源:DtdCompletionContributor.java

示例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));
				}
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:24,代码来源:HtmlCompletionContributor.java

示例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));
             }
           }
         });
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:ManifestCompletionContributor.java

示例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()));
				}
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:33,代码来源:CSharpDocCompletionContributor.java

示例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());
           }
         });
}
 
开发者ID:consulo,项目名称:consulo-haxe,代码行数:15,代码来源:HaxeSmartCompletionContributor.java

示例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());
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:CustomFileTypeCompletionContributor.java

示例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())));
        }
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:PostfixTemplateCompletionContributor.java

示例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));
					}
				}
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:36,代码来源:XmlNonFirstCompletionContributor.java

示例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());
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:36,代码来源:JavaScriptKeywordCompletionContributor.java

示例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()));
							}
						}
					});
				}
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:71,代码来源:CSharpAccessorCompletionContributor.java


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