Java Code Examples for com.intellij.codeInsight.completion.CompletionParameters#getInvocationCount()
The following examples show how to use
com.intellij.codeInsight.completion.CompletionParameters#getInvocationCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommitCompletionContributor.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Override public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { PsiFile file = parameters.getOriginalFile(); Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); if (document != null) { DataContext dataContext = document.getUserData(CommitMessage.DATA_CONTEXT_KEY); if (dataContext != null) { result.stopHere(); if (parameters.getInvocationCount() > 0) { ChangeList[] lists = dataContext.getData(VcsDataKeys.CHANGE_LISTS); if (lists != null) { String prefix = TextFieldWithAutoCompletionListProvider.getCompletionPrefix(parameters); CompletionResultSet insensitive = result.caseInsensitive().withPrefixMatcher(new CamelHumpMatcher(prefix)); for (ChangeList list : lists) { for (Change change : list.getChanges()) { VirtualFile virtualFile = change.getVirtualFile(); if (virtualFile != null) { LookupElementBuilder element = LookupElementBuilder.create(virtualFile.getName()). withIcon(VirtualFilePresentation.getAWTIcon(virtualFile)); insensitive.addElement(element); } } } } } } } }
Example 2
Source File: CompletionContributorForInplaceRename.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Override public void fillCompletionVariants(@Nonnull CompletionParameters parameters, @Nonnull CompletionResultSet result) { final Editor editor = parameters.getEditor(); final TemplateState state = TemplateManagerImpl.getTemplateState(editor); if (state != null) { if (editor.getUserData(InplaceRefactoring.INPLACE_RENAMER) != null && parameters.getInvocationCount() == 0) { result.stopHere(); } } }
Example 3
Source File: VariableNameCompletionProvider.java From BashSupport with Apache License 2.0 | 4 votes |
@Override protected void addBashCompletions(String currentText, CompletionParameters parameters, ProcessingContext context, CompletionResultSet result) { PsiElement element = parameters.getPosition(); BashVar varElement = PsiTreeUtil.getContextOfType(element, BashVar.class, false); boolean dollarPrefix = currentText != null && currentText.startsWith("$"); boolean insideExpansion = element.getParent() != null && element.getParent().getParent() instanceof BashParameterExpansion; if (varElement == null && !dollarPrefix && !insideExpansion) { return; } int invocationCount = parameters.getInvocationCount(); int resultLength = 0; PsiElement original = parameters.getOriginalPosition(); BashVar varElementOriginal = original != null ? PsiTreeUtil.getContextOfType(original, BashVar.class, false) : null; if (varElement != null) { // only keep vars of included files when starting in the original file PsiElement originalRef = varElementOriginal != null ? varElementOriginal : original; if (originalRef != null) { resultLength += addCollectedVariables(original, result, new BashVarVariantsProcessor(originalRef, false, true)); } // only keep vars of the dummy file when starting in the dummy file resultLength += addCollectedVariables(element, result, new BashVarVariantsProcessor(varElement, true, false)); } else { // not in a variable element, but collect all known variable names at this offset in the current file if (original != null) { resultLength += addCollectedVariables(original, result, new BashVarVariantsProcessor(original, false, true)); } resultLength += addCollectedVariables(element, result, new BashVarVariantsProcessor(element, false, true)); } if (currentText != null && (dollarPrefix || insideExpansion) && (invocationCount >= 2 || resultLength == 0)) { Project project = element.getProject(); addBuiltInVariables(result, project); addGlobalVariables(result, project); } else { result.addLookupAdvertisement("Press twice for global variables"); } }