Search in sources :

Example 11 with LookupElementPresentation

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

the class LookupCellRenderer method setTailTextLabel.

private void setTailTextLabel(boolean isSelected, LookupElementPresentation presentation, Color foreground, int allowedWidth, boolean nonFocusedSelection, FontMetrics fontMetrics) {
    int style = getStyle(false, presentation.isStrikeout(), false);
    for (LookupElementPresentation.TextFragment fragment : presentation.getTailFragments()) {
        if (allowedWidth < 0) {
            return;
        }
        String trimmed = trimLabelText(fragment.text, allowedWidth, fontMetrics);
        int fragmentStyle = fragment.isItalic() ? style | SimpleTextAttributes.STYLE_ITALIC : style;
        myTailComponent.append(trimmed, new SimpleTextAttributes(fragmentStyle, getTailTextColor(isSelected, fragment, foreground, nonFocusedSelection)));
        allowedWidth -= RealLookupElementPresentation.getStringWidth(trimmed, fontMetrics);
    }
}
Also used : RealLookupElementPresentation(com.intellij.codeInsight.lookup.RealLookupElementPresentation) LookupElementPresentation(com.intellij.codeInsight.lookup.LookupElementPresentation) LookupValueWithUIHint(com.intellij.codeInsight.lookup.LookupValueWithUIHint)

Example 12 with LookupElementPresentation

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

the class SecondSmartTypeCompletionTest method testEmptyMapPresentation2.

public void testEmptyMapPresentation2() {
    configure();
    LookupElementPresentation presentation = new LookupElementPresentation();
    myItems[0].renderElement(presentation);
    assertEquals("Collections.emptyMap", presentation.getItemText());
}
Also used : LookupElementPresentation(com.intellij.codeInsight.lookup.LookupElementPresentation)

Example 13 with LookupElementPresentation

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

the class SmartTypeCompletionTest method testClassLiteral.

public void testClassLiteral() throws Exception {
    doActionTest();
    assertStringItems("String.class");
    LookupElementPresentation p = new LookupElementPresentation();
    myFixture.getLookupElements()[0].renderElement(p);
    assertEquals("String.class", p.getItemText());
    assertEquals(" (java.lang)", p.getTailText());
    assertNull(p.getTypeText());
}
Also used : LookupElementPresentation(com.intellij.codeInsight.lookup.LookupElementPresentation)

Example 14 with LookupElementPresentation

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

the class JavaChainLookupElement method renderElement.

@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);
    final LookupElementPresentation qualifierPresentation = new LookupElementPresentation();
    myQualifier.renderElement(qualifierPresentation);
    String name = maybeAddParentheses(qualifierPresentation.getItemText());
    final String qualifierText = myQualifier.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY) != null ? "(" + name + ")" : name;
    presentation.setItemText(qualifierText + "." + presentation.getItemText());
    if (myQualifier instanceof JavaPsiClassReferenceElement) {
        presentation.appendTailText(((JavaPsiClassReferenceElement) myQualifier).getLocationString(), false);
    }
    if (qualifierPresentation.isStrikeout()) {
        presentation.setStrikeout(true);
    }
}
Also used : LookupElementPresentation(com.intellij.codeInsight.lookup.LookupElementPresentation)

Example 15 with LookupElementPresentation

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

the class CompletionHintsTest method complete.

private void complete(String partOfItemText) {
    LookupElement[] elements = myFixture.completeBasic();
    LookupElement element = Stream.of(elements).filter(e -> {
        LookupElementPresentation p = new LookupElementPresentation();
        e.renderElement(p);
        return (p.getItemText() + p.getTailText()).contains(partOfItemText);
    }).findAny().get();
    selectItem(element);
}
Also used : LookupElementPresentation(com.intellij.codeInsight.lookup.LookupElementPresentation) LookupElement(com.intellij.codeInsight.lookup.LookupElement)

Aggregations

LookupElementPresentation (com.intellij.codeInsight.lookup.LookupElementPresentation)18 LookupElement (com.intellij.codeInsight.lookup.LookupElement)10 LookupValueWithUIHint (com.intellij.codeInsight.lookup.LookupValueWithUIHint)2 RealLookupElementPresentation (com.intellij.codeInsight.lookup.RealLookupElementPresentation)2 SingleLineEmmetFilter (com.intellij.codeInsight.template.emmet.filters.SingleLineEmmetFilter)1 XmlZenCodingGenerator (com.intellij.codeInsight.template.emmet.generators.XmlZenCodingGenerator)1 ZenCodingGenerator (com.intellij.codeInsight.template.emmet.generators.ZenCodingGenerator)1 FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)1 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)1 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)1 AccessToken (com.intellij.openapi.application.AccessToken)1 Editor (com.intellij.openapi.editor.Editor)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 JBList (com.intellij.ui.components.JBList)1 ThrowableRunnable (com.intellij.util.ThrowableRunnable)1 HashSet (com.intellij.util.containers.HashSet)1