当前位置: 首页>>代码示例>>Java>>正文


Java LookupElementPresentation类代码示例

本文整理汇总了Java中com.intellij.codeInsight.lookup.LookupElementPresentation的典型用法代码示例。如果您正苦于以下问题:Java LookupElementPresentation类的具体用法?Java LookupElementPresentation怎么用?Java LookupElementPresentation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LookupElementPresentation类属于com.intellij.codeInsight.lookup包,在下文中一共展示了LookupElementPresentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderElement

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);

    if (myMessage.getKey() instanceof StringLiteralExpression) {
        presentation.setItemText(((StringLiteralExpression) myMessage.getKey()).getContents());
        presentation.setIcon(myMessage.getKey().getIcon(0));
    }

    PhpExpression value = (PhpExpression) myMessage.getValue();
    if (value != null) {
        String text = Util.PhpExpressionValue(value);

        if (!text.isEmpty()) {
            presentation.setTailText(" = " + text, true);
        }

        presentation.setTypeText(value.getType().toString());
        presentation.setTypeGrayed(true);
    }
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:22,代码来源:MessageLookupElement.java

示例2: setTailTextLabel

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
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);
    myTailComponent.append(trimmed, new SimpleTextAttributes(style, getTailTextColor(isSelected, fragment, foreground, nonFocusedSelection)));
    allowedWidth -= RealLookupElementPresentation.getStringWidth(trimmed, fontMetrics);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LookupCellRenderer.java

示例3: getTailTextColor

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
private static Color getTailTextColor(boolean isSelected, LookupElementPresentation.TextFragment fragment, Color defaultForeground, boolean nonFocusedSelection) {
  if (nonFocusedSelection) {
    return defaultForeground;
  }

  if (fragment.isGrayed()) {
    return getGrayedForeground(isSelected);
  }

  if (!isSelected) {
    final Color tailForeground = fragment.getForegroundColor();
    if (tailForeground != null) {
      return tailForeground;
    }
  }

  return defaultForeground;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LookupCellRenderer.java

示例4: getFontAbleToDisplay

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
@Nullable
Font getFontAbleToDisplay(LookupElementPresentation p) {
  String sampleString = p.getItemText() + p.getTailText() + p.getTypeText();

  // assume a single font can display all lookup item chars
  Set<Font> fonts = ContainerUtil.newHashSet();
  for (int i = 0; i < sampleString.length(); i++) {
    fonts.add(EditorUtil.fontForChar(sampleString.charAt(i), Font.PLAIN, myLookup.getEditor()).getFont());
  }

  eachFont: for (Font font : fonts) {
    if (font.equals(myNormalFont)) continue;
    
    for (int i = 0; i < sampleString.length(); i++) {
      if (!font.canDisplay(sampleString.charAt(i))) {
        continue eachFont;
      }
    }
    return font;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LookupCellRenderer.java

示例5: weigh

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
@Override
public Comparable weigh(@NotNull final LookupElement element, @NotNull final CompletionLocation location) {
  if (!PsiUtilCore.findLanguageFromElement(location.getCompletionParameters().getPosition()).isKindOf(PythonLanguage.getInstance())) {
    return 0;
  }

  final String name = element.getLookupString();
  final LookupElementPresentation presentation = LookupElementPresentation.renderElement(element);
  // move dict keys to the top
  if ("dict key".equals(presentation.getTypeText())) {
    return element.getLookupString().length();
  }
  if (name.startsWith(DOUBLE_UNDER)) {
    if (name.endsWith(DOUBLE_UNDER)) return -10; // __foo__ is lowest
    else return -5; // __foo is lower than normal
  }
  return 0; // default
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PythonCompletionWeigher.java

示例6: doTestTagNameIcons

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
private void doTestTagNameIcons(String fileName) throws IOException {
  VirtualFile file = copyFileToProject(fileName);
  myFixture.configureFromExistingVirtualFile(file);
  final LookupElement[] elements = myFixture.complete(CompletionType.BASIC);
  final Set<String> elementsToCheck = new HashSet<String>(Arrays.asList(
    "view", "include", "requestFocus", "fragment", "Button"));

  for (LookupElement element : elements) {
    final String s = element.getLookupString();
    final Object obj = element.getObject();

    if (elementsToCheck.contains(s)) {
      LookupElementPresentation presentation = new LookupElementPresentation();
      element.renderElement(presentation);
      assertNotNull("no icon for element: " + element, presentation.getIcon());

      if ("Button".equals(s)) {
        assertInstanceOf(obj, PsiClass.class);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AndroidLayoutDomTest.java

示例7: decorateLookupElement

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
public static void decorateLookupElement(@NotNull LookupElementPresentation lookupElement, @NotNull JsonRawLookupElement jsonLookup) {

        if(jsonLookup.getTailText() != null) {
            lookupElement.setTailText(jsonLookup.getTailText(), true);
        }

        if(jsonLookup.getTypeText() != null) {
            lookupElement.setTypeText(jsonLookup.getTypeText());
            lookupElement.setTypeGrayed(true);
        }

        String iconString = jsonLookup.getIcon();
        if(iconString != null) {
            Icon icon = getLookupIconOnString(iconString);
            if(icon != null) {
                lookupElement.setIcon(icon);
            }
        }

    }
 
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:21,代码来源:JsonParseUtil.java

示例8: assertCompletionLookupContainsPresentableItem

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
public void assertCompletionLookupContainsPresentableItem(LanguageFileType languageFileType, String configureByText, LookupElementPresentationAssert.Assert presentationAssert) {

        myFixture.configureByText(languageFileType, configureByText);
        myFixture.completeBasic();

        LookupElement[] lookupElements = myFixture.getLookupElements();
        if(lookupElements == null) {
            fail("failed to find lookup presentable on empty collection");
        }

        for (LookupElement lookupElement : lookupElements) {
            LookupElementPresentation presentation = new LookupElementPresentation();
            lookupElement.renderElement(presentation);

            if(presentationAssert.match(presentation)) {
                return;
            }
        }

        fail("failed to find lookup presentable");
    }
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:22,代码来源:ShopwareLightCodeInsightFixtureTestCase.java

示例9: renderElement

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
@Override
public void renderElement(LookupElementPresentation presentation) {
  super.renderElement(presentation);
  if (sudden) {
    presentation.setItemTextBold(true);
    if (!presentation.isReal() || !((RealLookupElementPresentation)presentation).isLookupSelectionTouched()) {
      char shortcutChar = myTemplate.getShortcutChar();
      if (shortcutChar == TemplateSettings.DEFAULT_CHAR) {
        shortcutChar = TemplateSettings.getInstance().getDefaultShortcutChar();
      }
      presentation.setTypeText("  [" + KeyEvent.getKeyText(shortcutChar) + "] ");
    }
    presentation.setTailText(" (" + myTemplate.getDescription() + ")", true);
  } else {
    presentation.setTypeText(myTemplate.getDescription());

  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:LiveTemplateLookupElement.java

示例10: renderElement

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
public void renderElement(LookupElementPresentation presentation) {

        if(this.useClassNameAsLookupString) {
            presentation.setItemText(className.getPresentableFQN());
            presentation.setTypeText(getLookupString());
        } else {
            presentation.setItemText(getLookupString());
            presentation.setTypeText(className.getPresentableFQN());
        }

        presentation.setTypeGrayed(true);
        if(isWeak) {
            // @TODO: remove weak
            presentation.setIcon(getWeakIcon());
        } else {
            presentation.setIcon(getIcon());
        }


    }
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:21,代码来源:DoctrineEntityLookupElement.java

示例11: renderElement

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);

    presentation.setItemTextBold(withBoldness);
    presentation.setIcon(Symfony2Icons.DOCTRINE);
    presentation.setTypeGrayed(true);

    if(this.doctrineModelField.getTypeName() != null) {
        presentation.setTypeText(this.doctrineModelField.getTypeName());
    }

    if(this.doctrineModelField.getRelationType() != null) {
        presentation.setTailText(String.format("(%s)", this.doctrineModelField.getRelationType()), true);
    }

    if(this.doctrineModelField.getRelation() != null) {
        presentation.setTypeText(this.doctrineModelField.getRelation());
        presentation.setIcon(PhpIcons.CLASS_ICON);
    }

}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:23,代码来源:DoctrineModelFieldLookupElement.java

示例12: renderElement

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
@Override
public void renderElement(LookupElementPresentation presentation) {

    // provides parent and string alias name
    List<String> tailsText = new ArrayList<>();

    String getName = PhpElementsUtil.getMethodReturnAsString(phpClass, "getName");
    if(getName != null) {
        tailsText.add(getName);
    }

    // @TODO: getParent should
    String getParent = PhpElementsUtil.getMethodReturnAsString(phpClass, "getParent");
    if(getParent != null && !getParent.equals("form")) {
        tailsText.add(getParent);
    }

    if(tailsText.size() > 0) {
        presentation.setTailText("(" + StringUtils.join(tailsText, ",") + ")", true);
    }

    presentation.setIcon(Symfony2Icons.FORM_TYPE);

    super.renderElement(presentation);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:26,代码来源:FormClassConstantsLookupElement.java

示例13: formatTail

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
/**
 * "(GET|POST, var1, var2)"
 */
private void formatTail(@NotNull LookupElementPresentation presentation) {
    List<String> tails = new ArrayList<>();

    Collection<String> methods = route.getMethods();
    if(methods.size() > 0) {
        tails.add(StringUtils.join(ContainerUtil.map(methods, String::toUpperCase), "|"));
    }

    Set<String> variables = this.route.getVariables();
    if(variables.size() > 0) {
        tails.addAll(variables);
    }

    if(tails.size() > 0) {
        presentation.setTailText("(" + StringUtils.join(tails, ", ") + ")", true);
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:21,代码来源:RouteLookupElement.java

示例14: renderElement

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(containerParameter.getName());

    String value = containerParameter.getValue();
    if(value != null && StringUtils.isNotBlank(value)) {
        presentation.setTypeText(value);
    }

    presentation.setTypeGrayed(true);
    presentation.setIcon(Symfony2Icons.PARAMETER);

    if(this.containerParameter.isWeak()) {
        presentation.setIcon(Symfony2Icons.PARAMETER_OPACITY);
    }

}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:ParameterLookupElement.java

示例15: testGetEventNameLookupElementsForEventAnnotations

import com.intellij.codeInsight.lookup.LookupElementPresentation; //导入依赖的package包/类
/**
 * @see EventDispatcherSubscriberUtil#getEventNameLookupElements
 */
public void testGetEventNameLookupElementsForEventAnnotations() {
    Collection<LookupElement> eventNameLookupElements = EventDispatcherSubscriberUtil.getEventNameLookupElements(getProject());
    ContainerUtil.find(eventNameLookupElements, lookupElement ->
        lookupElement.getLookupString().equals("bar.pre_bar")
    );

    ContainerUtil.find(eventNameLookupElements, lookupElement ->
        lookupElement.getLookupString().equals("bar.post_bar")
    );

    ContainerUtil.find(eventNameLookupElements, lookupElement -> {
        if(!"bar.post_bar".equals(lookupElement.getLookupString())) {
            return false;
        }

        LookupElementPresentation lookupElementPresentation = new LookupElementPresentation();
        lookupElement.renderElement(lookupElementPresentation);

        return "My\\MyFooEvent".equals(lookupElementPresentation.getTypeText());
    });
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:25,代码来源:EventDispatcherSubscriberUtilTest.java


注:本文中的com.intellij.codeInsight.lookup.LookupElementPresentation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。