use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project intellij-community by JetBrains.
the class ChangeListCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull final CompletionResultSet result) {
final PsiFile file = parameters.getOriginalFile();
final Document document = PsiDocumentManager.getInstance(file.getProject()).getCachedDocument(file);
if (document == null)
return;
ComboBox comboBox = document.getUserData(COMBO_BOX_KEY);
if (comboBox == null)
return;
final CompletionResultSet resultSet = result.withPrefixMatcher(new PlainPrefixMatcher(document.getText()));
for (int i = 0; i < comboBox.getItemCount(); i++) {
resultSet.addElement(LookupElementBuilder.create(comboBox.getItemAt(i)));
}
}
use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project intellij-community by JetBrains.
the class ListTemplatesHandler method showTemplatesLookup.
public static void showTemplatesLookup(final Project project, final Editor editor, Map<TemplateImpl, String> template2Argument) {
final LookupImpl lookup = (LookupImpl) LookupManager.getInstance(project).createLookup(editor, LookupElement.EMPTY_ARRAY, "", new LookupArranger.DefaultArranger());
for (TemplateImpl template : template2Argument.keySet()) {
String prefix = computePrefix(template, template2Argument.get(template));
lookup.addItem(createTemplateElement(template), new PlainPrefixMatcher(prefix));
}
showLookup(lookup, template2Argument);
}
use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project Perl5-IDEA by Camelcade.
the class PerlVariableNameCompletionProvider method addCompletions.
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
PsiElement variableNameElement = parameters.getPosition();
boolean isDeclaration = VARIABLE_NAME_IN_DECLARATION_PATTERN.accepts(variableNameElement);
boolean isFullQualified = PerlPackageUtil.isFullQualifiedName(variableNameElement.getText());
PsiElement originalPosition = parameters.getOriginalPosition();
if (originalPosition instanceof PerlVariableNameElement) {
resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(originalPosition.getText()));
}
// declaration helper
if (isDeclaration) {
PerlVariableCompletionUtil.fillWithUnresolvedVars((PerlVariableNameElement) variableNameElement, resultSet);
} else if (!isFullQualified) {
PerlVariableCompletionUtil.fillWithLExicalVariables(variableNameElement, resultSet);
}
// built ins
if (VARIABLE_NAME_IN_LOCAL_DECLARATION_PATTERN.accepts(variableNameElement)) {
PerlVariableCompletionUtil.fillWithBuiltInVariables(variableNameElement, resultSet);
}
// imports
if (!isDeclaration && !isFullQualified) {
fillWithImportedVariables(variableNameElement, resultSet);
}
// fqn names
if (!isDeclaration) {
fillWithFullQualifiedVariables(variableNameElement, resultSet);
}
}
use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project Perl5-IDEA by Camelcade.
the class PerlPackageSubCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement method = parameters.getPosition().getParent();
assert method instanceof PsiPerlMethod : "Expected PsiPerlMethod, got " + method.getClass();
String explicitNamespace = ((PsiPerlMethod) method).getExplicitPackageName();
String currentPrefixMatcher = result.getPrefixMatcher().getPrefix();
String newPrefixMathcer = (explicitNamespace == null ? currentPrefixMatcher : (explicitNamespace + PerlPackageUtil.PACKAGE_SEPARATOR) + currentPrefixMatcher);
result = result.withPrefixMatcher(new PlainPrefixMatcher(newPrefixMathcer));
if (!((PsiPerlMethod) method).isObjectMethod()) {
PerlPackageCompletionUtil.fillWithAllPackageNamesWithAutocompletion(parameters.getPosition(), result);
} else {
if (!StringUtil.equals(PerlPackageUtil.SUPER_PACKAGE_FULL, newPrefixMathcer)) {
LookupElementBuilder newElement = PerlPackageCompletionUtil.getPackageLookupElementWithAutocomplete(method.getProject(), PerlPackageUtil.SUPER_PACKAGE_FULL, null);
newElement.putUserData(PerlCompletionWeighter.WEIGHT, -1);
result.addElement(newElement);
}
}
}
use of com.intellij.codeInsight.completion.PlainPrefixMatcher in project Intellij-Plugin by getgauge.
the class StaticArgCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
String prefix = getPrefix(parameters);
resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
PsiFile specFile = parameters.getOriginalFile();
SpecDetail specDetail = PsiTreeUtil.getChildOfType(specFile, SpecDetail.class);
List<SpecStep> stepsInFile = new ArrayList<>();
addContextSteps(specDetail, stepsInFile);
addStepsInScenarios(specFile, stepsInFile);
Set<String> staticArgs = getArgsFromSteps(stepsInFile);
for (String arg : staticArgs) {
if (arg != null) {
LookupElementBuilder item = LookupElementBuilder.create(arg);
resultSet.addElement(item);
}
}
}
Aggregations