本文整理匯總了Java中com.intellij.codeInsight.completion.CompletionResultSet.addElement方法的典型用法代碼示例。如果您正苦於以下問題:Java CompletionResultSet.addElement方法的具體用法?Java CompletionResultSet.addElement怎麽用?Java CompletionResultSet.addElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.codeInsight.completion.CompletionResultSet
的用法示例。
在下文中一共展示了CompletionResultSet.addElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
List<TSVarExpr> variables = new ArrayList<>();
for (PsiElement current = parameters.getPosition().getPrevSibling(); current != null; current = current.getPrevSibling()) {
if (current.getNode().getElementType().equals(TSTypes.FUNCTION))
break;
if (current.getNode().getElementType().equals(TSTypes.LOCALVAR)) {
String prefixless = current.getText().substring(1);
result.addElement(
LookupElementBuilder.create(prefixless)
.withPresentableText(current.getText())
.withCaseSensitivity(false)
);
}
}
}
示例2: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
String namespace = parameters.getPosition().getPrevSibling().getPrevSibling().getText();
Project project = parameters.getOriginalFile().getProject();
Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
for (TSFnDeclStmt function : functions) {
if (function.getFunctionType() == TSFunctionType.GLOBAL)
continue;
if (namespace != null && !function.getNamespace().equalsIgnoreCase(namespace))
continue;
result.addElement(
LookupElementBuilder.create(function.getFunctionName())
.withCaseSensitivity(false)
.withPresentableText(function.getNamespace() + "::" + function.getFunctionName())
.withTailText(function.getArgList())
.withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
);
}
}
示例3: complete
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
static void complete(Project project, PsiModuleName name, @NotNull CompletionResultSet resultSet) {
// Get the correct module
Collection<PsiModule> modules = StubIndex.getElements(IndexKeys.MODULES, name.getName(), project, GlobalSearchScope.allScope(project), PsiModule.class);
if (!modules.isEmpty()) {
for (PsiModule module : modules) {
Collection<PsiNamedElement> expressions = module.getExpressions();
for (PsiNamedElement expression : expressions) {
resultSet.addElement(
LookupElementBuilder.create(expression).
withIcon(PsiIconUtil.getProvidersIcon(expression, 0)).
withTypeText(PsiInferredTypeUtil.getTypeInfo(expression))
);
}
}
}
}
示例4: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
MerlinService merlin = ApplicationManager.getApplication().getComponent(MerlinService.class);
PsiFile originalFile = parameters.getOriginalFile();
String text = originalFile.getText();
LineNumbering lineNumbering = new LineNumbering(text);
String suitablePrefix = findSuitablePrefix(parameters, text);
MerlinPosition position = lineNumbering.offsetToPosition(parameters.getOffset());
MerlinCompletion completion = merlin.completions(originalFile.getName(), text, position, suitablePrefix);
for (MerlinCompletionEntry entry : completion.entries) {
resultSet.addElement(LookupElementBuilder.
create(entry.name).
withIcon(getIcon(entry)).
withTypeText(entry.desc));
}
}
示例5: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
final PsiFile originalFile = parameters.getOriginalFile();
final Collection<ImpexMacroDeclaration> macroDeclarations = PsiTreeUtil.findChildrenOfType(
originalFile, ImpexMacroDeclaration.class
);
if (macroDeclarations.isEmpty()) {
return;
}
for (final ImpexMacroDeclaration macroDeclaration : macroDeclarations) {
final PsiElement declaration = macroDeclaration.getFirstChild();
result.addElement(LookupElementBuilder.create(declaration.getText())
.withIcon(HybrisIcons.MACROS));
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:23,代碼來源:ImpexMacrosCompletionProvider.java
示例6: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
Collection<String> keys = LayoutIndex.getAllKeys(BlockNameIndex.KEY, position.getProject());
for (String key: keys) {
result.addElement(
LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON)
);
}
}
示例7: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
String prefix = result.getPrefixMatcher().getPrefix();
Collection<String> moduleNames
= FileBasedIndex.getInstance().getAllKeys(ModuleNameIndex.KEY, position.getProject());
moduleNames.removeIf(m -> !m.startsWith(prefix));
for (String moduleName : moduleNames) {
result.addElement(
LookupElementBuilder
.create(moduleName)
.withIcon(AllIcons.Modules.ModulesNode)
);
}
}
示例8: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet)
{
final int offset = completionParameters.getOffset() - 1;
final PsiFile originalFile = completionParameters.getOriginalFile();
if (RamlUtils.isRamlFile(originalFile))
{
final String text = originalFile.getText();
System.out.println("text = " + text);
System.out.println("offset = " + offset);
final Suggestions suggestions = new RamlSuggester().suggestions(text, offset);
final List<Suggestion> suggestionList = suggestions.getSuggestions();
for (Suggestion suggestion : suggestionList)
{
final LookupElementBuilder map = LookupElementBuilder.create(suggestion.getValue())
.withPresentableText(suggestion.getLabel())
.withLookupString(suggestion.getLabel())
.withLookupString(suggestion.getValue());
completionResultSet.addElement(map);
}
}
}
示例9: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
final Project project = completionParameters.getOriginalFile().getProject();
final MuleElementDefinitionService instance = MuleElementDefinitionService.getInstance(project);
final List<MuleModuleDefinition> definitions = instance.getDefinitions();
for (MuleModuleDefinition definition : definitions) {
final List<MuleElementDefinition> elementDefinitions = definition.getElementDefinitions();
for (MuleElementDefinition elementDefinition : elementDefinitions) {
final LookupElementBuilder lookupElement =
LookupElementBuilder.create(elementDefinition.getName())
.withCaseSensitivity(false)
.withLookupString(definition.getName() + ":" + elementDefinition.getName())
.withTypeText("\t" + StringUtil.capitalizeWords(elementDefinition.getType().name().toLowerCase(), "_", true, false), true)
.withPresentableText(definition.getName() + ":" + elementDefinition.getName())
.withInsertHandler(new MuleElementInsertHandler(elementDefinition.getName(), definition.getName(), definition.getNamespace(), definition.getLocationLookup()));
completionResultSet.addElement(lookupElement);
}
}
completionResultSet.stopHere();
}
示例10: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
MethodReference methodRef = ClassUtils.getMethodRef(completionParameters.getPosition(), 10);
PsiElement position = completionParameters.getPosition();
if (methodRef != null) {
Method method = (Method) methodRef.resolve();
int paramPosition = ClassUtils.indexForElementInParameterList(completionParameters.getPosition());
// attribute plus model parameters
if (method != null && paramPosition > 0 && method.getParameters().length > paramPosition) {
if (method.getParameters()[paramPosition].getName().equals("attribute") &&
method.getParameters()[paramPosition - 1].getName().equals("model")) {
PsiElement element = methodRef.getParameters()[paramPosition - 1];
if (element instanceof Variable) {
PhpClass classByVariable = ClassUtils.getClassByVariable((Variable) element);
if (classByVariable != null &&
ClassUtils.isClassInherit(classByVariable, "yii\\base\\Model", PhpIndex.getInstance(position.getProject()) )) {
Collection<Field> classFields = ClassUtils.getClassFields(classByVariable);
PhpExpression position2 = (PhpExpression) completionParameters.getPosition().getParent();
for (Field field : classFields) {
LookupElementBuilder lookupBuilder = buildLookup(field, position2);
completionResultSet.addElement(lookupBuilder);
}
}
}
}
}
}
}
示例11: addAllElementsWithPriority
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
private void addAllElementsWithPriority(@Nullable ArrayList<LookupElementBuilder> lookups, @NotNull CompletionResultSet completionResultSet, double priority, boolean bold) {
if (lookups != null) {
for (LookupElementBuilder element : lookups) {
element = element.withBoldness(bold);
completionResultSet.addElement(PrioritizedLookupElement.withPriority(element, priority));
}
}
}
示例12: completeMatchingType
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
public void completeMatchingType(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet resultSet) {
for (SpecialType specialType : supportedTypes) {
resultSet.addElement(LookupElementBuilder.create(specialType.name()));
}
CptCompletionUtil.addCompletions(parameters, resultSet);
}
示例13: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
public void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
Validate.notNull(parameters);
Validate.notNull(result);
final PsiElement psiElementUnderCaret = parameters.getPosition();
final ImpexAttribute impexAttribute = PsiTreeUtil.getParentOfType(
psiElementUnderCaret, ImpexAttribute.class
);
if (impexAttribute == null) {
return;
}
final String modifierName = impexAttribute.getAnyAttributeName().getText();
final ImpexModifier impexModifier = AttributeModifier.getByModifierName(modifierName);
if (null != impexModifier) {
for (String possibleValue : impexModifier.getModifierValues()) {
result.addElement(LookupElementBuilder.create(possibleValue));
}
} else {
// show error message when not defined within hybris API
Notifications.Bus.notify(new Notification(
ImpexLanguage.getInstance().getDisplayName(),
"possible error in your impex",
"You typed an unknown hybris-ATTRIBUTE-modifier with name '" + modifierName + "'.",
NotificationType.WARNING
));
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:39,代碼來源:ImpexHeaderAttributeModifierValueCompletionProvider.java
示例14: completeMatchingType
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
public void completeMatchingType(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet resultSet) {
for (SpecialType specialType : SpecialType.values()) {
resultSet.addElement(LookupElementBuilder.create(specialType.name()));
}
CptCompletionUtil.addCompletions(parameters, resultSet);
}
示例15: addCompletions
import com.intellij.codeInsight.completion.CompletionResultSet; //導入方法依賴的package包/類
@Override
public void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
Validate.notNull(parameters);
Validate.notNull(result);
final PsiElement psiElementUnderCaret = parameters.getPosition();
final ImpexAttribute impexAttribute = PsiTreeUtil.getParentOfType(
psiElementUnderCaret, ImpexAttribute.class
);
if (impexAttribute == null) {
return;
}
final String modifierName = impexAttribute.getAnyAttributeName().getText();
final ImpexModifier impexModifier = TypeModifier.getByModifierName(modifierName);
if (null != impexModifier) {
for (String possibleValue : impexModifier.getModifierValues()) {
result.addElement(LookupElementBuilder.create(possibleValue));
}
} else {
// show error message when not defined within hybris API
Notifications.Bus.notify(new Notification(
ImpexLanguage.getInstance().getDisplayName(),
"possible error in your impex",
"You typed an unknown hybris-TYPE-modifier with name '" + modifierName + "'.",
NotificationType.WARNING
));
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:40,代碼來源:ImpexHeaderTypeModifierValueCompletionProvider.java