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);
}
}
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());
}
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());
}
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);
}
}
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);
}
Aggregations