Search in sources :

Example 41 with LookupElementBuilder

use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.

the class AntDomMacrodefAttributeReference method getVariants.

@NotNull
public Object[] getVariants() {
    final AntDomMacroDef parentMacrodef = getParentMacrodef();
    if (parentMacrodef != null) {
        final List variants = new ArrayList();
        for (AntDomMacrodefAttribute attribute : parentMacrodef.getMacroAttributes()) {
            final String attribName = attribute.getName().getStringValue();
            if (attribName != null && attribName.length() > 0) {
                final LookupElementBuilder builder = LookupElementBuilder.create(attribName);
                final LookupElement element = AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE.applyPolicy(builder);
                variants.add(element);
            }
        }
        return ContainerUtil.toArray(variants, new Object[variants.size()]);
    }
    return EMPTY_ARRAY;
}
Also used : ArrayList(java.util.ArrayList) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) ArrayList(java.util.ArrayList) List(java.util.List) LookupElement(com.intellij.codeInsight.lookup.LookupElement) NotNull(org.jetbrains.annotations.NotNull)

Example 42 with LookupElementBuilder

use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.

the class ActionOrGroupResolveConverter method createLookupElement.

@Nullable
@Override
public LookupElement createLookupElement(ActionOrGroup actionOrGroup) {
    if (actionOrGroup instanceof Action) {
        Action action = (Action) actionOrGroup;
        String msg = action.getId().getStringValue() + " in " + DomUtil.getFile(action) + " " + action.isValid() + " ";
        DomImplUtil.assertValidity(action, msg);
        final PsiElement element = getPsiElement(actionOrGroup);
        if (element == null) {
            throw new IllegalStateException("no PSI: " + msg);
        }
        LookupElementBuilder builder = LookupElementBuilder.create(ObjectUtils.assertNotNull(element), ObjectUtils.assertNotNull(getName(action)));
        final String text = action.getText().getStringValue();
        if (StringUtil.isNotEmpty(text)) {
            String withoutMnemonic = StringUtil.replace(text, "_", "");
            builder = builder.withTailText(" \"" + withoutMnemonic + "\"", true);
        }
        return builder;
    }
    return super.createLookupElement(actionOrGroup);
}
Also used : LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 43 with LookupElementBuilder

use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.

the class TaskAutoCompletionListProvider method createLookupBuilder.

@Override
public LookupElementBuilder createLookupBuilder(@NotNull final Task task) {
    LookupElementBuilder builder = super.createLookupBuilder(task);
    builder = builder.withLookupString(task.getSummary());
    if (task.isClosed()) {
        builder = builder.strikeout();
    }
    return builder;
}
Also used : LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder)

Example 44 with LookupElementBuilder

use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.

the class FileInfoManager method _getLookupItem.

public LookupElementBuilder _getLookupItem(@NotNull final PsiFile file, String name, Icon icon) {
    LookupElementBuilder builder = LookupElementBuilder.create(file, name).withIcon(icon);
    final String info = _getInfo(file);
    if (info != null) {
        return builder.withTailText(String.format(" (%s)", info), true);
    }
    return builder;
}
Also used : LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder)

Example 45 with LookupElementBuilder

use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.

the class MavenArtifactCoordinatesArtifactIdConverter method createLookupElement.

@Nullable
@Override
public LookupElement createLookupElement(String s) {
    LookupElementBuilder res = LookupElementBuilder.create(s);
    res = res.withInsertHandler(MavenArtifactInsertHandler.INSTANCE);
    return res;
}
Also used : LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)57 LookupElement (com.intellij.codeInsight.lookup.LookupElement)20 NotNull (org.jetbrains.annotations.NotNull)16 PsiElement (com.intellij.psi.PsiElement)13 Nullable (org.jetbrains.annotations.Nullable)9 PsiFile (com.intellij.psi.PsiFile)7 Document (com.intellij.openapi.editor.Document)5 ArrayList (java.util.ArrayList)5 PlainPrefixMatcher (com.intellij.codeInsight.completion.PlainPrefixMatcher)3 PrioritizedLookupElement (com.intellij.codeInsight.completion.PrioritizedLookupElement)3 Editor (com.intellij.openapi.editor.Editor)3 TextRange (com.intellij.openapi.util.TextRange)3 PsiPresentableMetaData (com.intellij.psi.meta.PsiPresentableMetaData)3 XmlFile (com.intellij.psi.xml.XmlFile)3 XmlExtension (com.intellij.xml.XmlExtension)3 com.intellij.codeInsight.completion (com.intellij.codeInsight.completion)2 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)2 InsertionContext (com.intellij.codeInsight.completion.InsertionContext)2 ParenthesesInsertHandler (com.intellij.codeInsight.completion.util.ParenthesesInsertHandler)2 AutoCompletionPolicy (com.intellij.codeInsight.lookup.AutoCompletionPolicy)2