本文整理匯總了Java中com.intellij.codeInsight.completion.CompletionContributor類的典型用法代碼示例。如果您正苦於以下問題:Java CompletionContributor類的具體用法?Java CompletionContributor怎麽用?Java CompletionContributor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CompletionContributor類屬於com.intellij.codeInsight.completion包,在下文中一共展示了CompletionContributor類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extend
import com.intellij.codeInsight.completion.CompletionContributor; //導入依賴的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);
}
});
}
示例2: isAutoPopup
import com.intellij.codeInsight.completion.CompletionContributor; //導入依賴的package包/類
private static boolean isAutoPopup(@NotNull Editor editor, @NotNull PsiFile file, char charTyped) {
final int offset = editor.getCaretModel().getOffset() - 1;
if (offset >= 0) {
final PsiElement element = file.findElementAt(offset);
if (element != null) {
final List<CompletionContributor> list = CompletionContributor.forLanguage(element.getLanguage());
for (CompletionContributor contributor : list) {
if (contributor.invokeAutoPopup(element, charTyped)) return true;
}
}
}
return false;
}
示例3: isAutoPopup
import com.intellij.codeInsight.completion.CompletionContributor; //導入依賴的package包/類
private static boolean isAutoPopup(@Nonnull Editor editor, @Nonnull PsiFile file, char charTyped) {
final int offset = editor.getCaretModel().getOffset() - 1;
if (offset >= 0) {
final PsiElement element = file.findElementAt(offset);
if (element != null) {
final List<CompletionContributor> list = CompletionContributor.forLanguage(element.getLanguage());
for (CompletionContributor contributor : list) {
if (contributor.invokeAutoPopup(element, charTyped)) return true;
}
}
}
return false;
}
示例4: extend
import com.intellij.codeInsight.completion.CompletionContributor; //導入依賴的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()));
}
}
});
}
}
}
});
}
示例5: extend
import com.intellij.codeInsight.completion.CompletionContributor; //導入依賴的package包/類
static void extend(CompletionContributor contributor)
{
contributor.extend(CompletionType.BASIC, CSharpPatterns.fieldStart(), new CompletionProvider()
{
@RequiredReadAction
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
CSharpFieldDeclaration currentElement = PsiTreeUtil.getParentOfType(parameters.getPosition(), CSharpFieldDeclaration.class);
assert currentElement != null;
DotNetModifierList modifierList = currentElement.getModifierList();
if(modifierList != null)
{
int textLength = modifierList.getTextLength();
if(textLength > 0)
{
return;
}
}
PsiElement nextSibling = UsefulPsiTreeUtil.getNextSiblingSkippingWhiteSpacesAndComments(currentElement);
TextRange textRange = nextSibling == null ? null : new TextRange(currentElement.getTextRange().getEndOffset(), nextSibling.getTextRange().getStartOffset());
if(textRange != null && !StringUtil.containsLineBreak(textRange.subSequence(currentElement.getContainingFile().getText())))
{
return;
}
CSharpTypeDeclaration typeDeclaration = PsiTreeUtil.getParentOfType(parameters.getPosition(), CSharpTypeDeclaration.class);
if(typeDeclaration == null)
{
return;
}
Consumer<LookupElement> delegate = lookupElement ->
{
if(lookupElement != null)
{
CSharpCompletionSorting.force(lookupElement, CSharpCompletionSorting.KindSorter.Type.overrideMember);
result.consume(lookupElement);
}
};
for(CSharpMemberAddByCompletionContributor completionContributor : EP_NAME.getExtensions())
{
completionContributor.processCompletion(parameters, context, delegate, typeDeclaration);
}
}
});
}