本文整理汇总了Java中com.intellij.codeInsight.lookup.LookupElementBuilder.withIcon方法的典型用法代码示例。如果您正苦于以下问题:Java LookupElementBuilder.withIcon方法的具体用法?Java LookupElementBuilder.withIcon怎么用?Java LookupElementBuilder.withIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.lookup.LookupElementBuilder
的用法示例。
在下文中一共展示了LookupElementBuilder.withIcon方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSmartCompletionSuggestionsContextPath
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public static List<LookupElement> addSmartCompletionSuggestionsContextPath(String val, ComponentModel component,
Map<String, String> existing, boolean xmlMode, PsiElement psiElement) {
List<LookupElement> answer = new ArrayList<>();
// show the syntax as the only choice for now
LookupElementBuilder builder = LookupElementBuilder.create(val);
builder = builder.withIcon(getCamelPreferenceService().getCamelIcon());
builder = builder.withBoldness(true);
builder = builder.withPresentableText(component.getSyntax());
LookupElement element = builder.withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
answer.add(element);
val = removeUnknownEnum(val, psiElement);
List<LookupElement> old = addSmartCompletionContextPathEnumSuggestions(val, component, existing);
if (!old.isEmpty()) {
answer.addAll(old);
}
return answer;
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:21,代码来源:CamelSmartCompletionEndpointOptions.java
示例2: createVariant
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Override
public Object createVariant(final Object variant, final String name, final PsiElement psiElement) {
final LookupElementBuilder builder;
if (psiElement != null) {
builder = LookupElementBuilder.create(psiElement, name);
}
else {
builder = LookupElementBuilder.create(name);
}
return builder.withIcon(ElementPresentationManager.getIcon(variant));
}
示例3: buildLookup
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@NotNull
public static LookupElementBuilder buildLookup(Object field, boolean showSchema, Project project) {
String lookupString = "-";
if (field instanceof DasObject) {
lookupString = ((DasObject) field).getName();
lookupString = RemoveTablePrefix(lookupString, project);
}
if (field instanceof Field) {
lookupString = ((Field) field).getName();
}
LookupElementBuilder builder = LookupElementBuilder.create(field, lookupString);
if (field instanceof Field) {
builder = builder.withTypeText(((Field) field).getType().toString())
.withIcon(((Field) field).getIcon());
}
if (field instanceof PhpDocProperty) {
builder = builder.withTypeText(((PhpDocProperty) field).getType().toString())
.withIcon(((PhpDocProperty) field).getIcon());
}
if (field instanceof DasColumn) {
DasColumn column = (DasColumn) field;
builder = builder.withTypeText(column.getDataType().typeName, true);
if (column.getDbParent() != null && showSchema && column.getDbParent().getDbParent() != null) {
builder = builder.withTailText(" (" + column.getDbParent().getDbParent().getName() + "." + RemoveTablePrefix(column.getDbParent().getName(), project) + ")", true);
}
if (column instanceof DasColumn)
builder = builder.withIcon(TypePresentationService.getService().getIcon(field));
if (column instanceof DbColumnImpl)
builder = builder.withIcon(((DbColumnImpl) column).getIcon());
}
if (field instanceof DasTable) {
DasTable table = (DasTable) field;
DasObject tableSchema = table.getDbParent();
if (tableSchema != null) {
if (tableSchema instanceof DbNamespaceImpl) {
Object dataSource = tableSchema.getDbParent();
// DbDataSourceImpl dataSource = (DbDataSourceImpl) ((DbNamespaceImpl) tableSchema).getDbParent();
if (dataSource != null && dataSource instanceof DbDataSourceImpl ) {
builder = builder.withTypeText(((DbDataSourceImpl)dataSource).getName(), true);
}
if (dataSource != null && dataSource instanceof DbDataSourceImpl ) {
builder = builder.withTypeText(((DbDataSourceImpl)dataSource).getName(), true);
}
}
}
if (showSchema && tableSchema != null) {
builder = builder.withTailText(" (" + table.getDbParent().getName() + ")", true);
}
if (table instanceof DasTable)
builder = builder.withIcon(TypePresentationService.getService().getIcon(table));
if (table instanceof DbElement)
builder = builder.withIcon(((DbElement) table).getIcon());
builder = builder.withInsertHandler((insertionContext, lookupElement) -> {
if (Yii2SupportSettings.getInstance(project).insertWithTablePrefix) {
Document document = insertionContext.getDocument();
int insertPosition = insertionContext.getSelectionEndOffset();
document.insertString(insertPosition - lookupElement.getLookupString().length(), "{{%");
document.insertString(insertPosition + 3, "}}");
insertionContext.getEditor().getCaretModel().getCurrentCaret().moveToOffset(insertPosition + 5);
}
});
}
return builder;
}
示例4: addSmartCompletionContextPathEnumSuggestions
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static List<LookupElement> addSmartCompletionContextPathEnumSuggestions(String val, ComponentModel component,
Map<String, String> existing) {
List<LookupElement> answer = new ArrayList<>();
double priority = 100.0d;
// lets help the suggestion list if we are editing the context-path and only have 1 enum type option
// and the option has not been in use yet, then we can populate the list with the enum values.
long enums = component.getEndpointOptions().stream().filter(o -> "path".equals(o.getKind()) && !o.getEnums().isEmpty()).count();
if (enums == 1) {
for (EndpointOptionModel option : component.getEndpointOptions()) {
// only add support for enum in the context-path smart completion
if ("path".equals(option.getKind()) && !option.getEnums().isEmpty()) {
String name = option.getName();
// only add if not already used
String old = existing != null ? existing.get(name) : "";
if (existing == null || old == null || old.isEmpty()) {
// add all enum as choices
for (String choice : option.getEnums().split(",")) {
String key = choice;
String lookup = val + key;
LookupElementBuilder builder = LookupElementBuilder.create(lookup);
// only show the option in the UI
builder = builder.withPresentableText(choice);
// lets use the option name as the type so its visible
builder = builder.withTypeText(name, true);
builder = builder.withIcon(AllIcons.Nodes.Enum);
if ("true".equals(option.getDeprecated())) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
// its an enum so always auto complete the choices
LookupElement element = builder.withAutoCompletionPolicy(AutoCompletionPolicy.ALWAYS_AUTOCOMPLETE);
// they should be in the exact order
element = PrioritizedLookupElement.withPriority(element, priority);
priority -= 1.0d;
answer.add(element);
}
}
}
}
}
return answer;
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:56,代码来源:CamelSmartCompletionEndpointOptions.java
示例5: addVariants
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static void addVariants(final CompletionResultSet result,
final XmlAttribute[] attributes,
final XmlAttributeDescriptor[] descriptors,
XmlAttribute attribute,
@Nullable InsertHandler<LookupElement> replacementInsertHandler) {
final XmlTag tag = attribute.getParent();
final PsiFile file = tag.getContainingFile();
final XmlExtension extension = XmlExtension.getExtension(file);
final String prefix = attribute.getName().contains(":") && ((XmlAttributeImpl) attribute).getRealLocalName().length() > 0
? attribute.getNamespacePrefix() + ":"
: null;
CompletionData
completionData = CompletionUtil.getCompletionDataByElement(attribute, attribute.getContainingFile().getOriginalFile());
boolean caseSensitive = !(completionData instanceof HtmlCompletionData) || ((HtmlCompletionData)completionData).isCaseSensitive();
for (XmlAttributeDescriptor descriptor : descriptors) {
if (isValidVariant(attribute, descriptor, attributes, extension)) {
String name = descriptor.getName(tag);
InsertHandler<LookupElement> insertHandler = XmlAttributeInsertHandler.INSTANCE;
if (tag instanceof HtmlTag &&
HtmlUtil.isShortNotationOfBooleanAttributePreferred() &&
HtmlUtil.isBooleanAttribute(descriptor, tag)) {
insertHandler = null;
}
if (replacementInsertHandler != null) {
insertHandler = replacementInsertHandler;
}
else if (descriptor instanceof NamespaceAwareXmlAttributeDescriptor) {
final String namespace = ((NamespaceAwareXmlAttributeDescriptor)descriptor).getNamespace(tag);
if (file instanceof XmlFile &&
namespace != null &&
namespace.length() > 0 &&
!name.contains(":") &&
tag.getPrefixByNamespace(namespace) == null) {
insertHandler = new XmlAttributeInsertHandler(namespace);
}
}
if (prefix == null || name.startsWith(prefix)) {
if (prefix != null && name.length() > prefix.length()) {
name = descriptor.getName(tag).substring(prefix.length());
}
LookupElementBuilder element = LookupElementBuilder.create(name);
if (descriptor instanceof PsiPresentableMetaData) {
element = element.withIcon(((PsiPresentableMetaData)descriptor).getIcon());
}
final int separator = name.indexOf(':');
if (separator > 0) {
element = element.withLookupString(name.substring(separator + 1));
}
element = element
.withCaseSensitivity(caseSensitive)
.withInsertHandler(insertHandler);
result.addElement(
descriptor.isRequired() ? PrioritizedLookupElement.withPriority(element.appendTailText("(required)", true), 100) :
HtmlUtil.isOwnHtmlAttribute(descriptor) ? PrioritizedLookupElement.withPriority(element, 50) : element);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:XmlAttributeReferenceCompletionProvider.java
示例6: addTagNameVariants
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Override
public void addTagNameVariants(List<LookupElement> elements, @NotNull XmlTag tag, String prefix) {
final List<String> namespaces;
if (prefix.isEmpty()) {
namespaces = new ArrayList<String>(Arrays.asList(tag.knownNamespaces()));
namespaces.add(XmlUtil.EMPTY_URI); // empty namespace
}
else {
namespaces = new ArrayList<String>(Collections.singletonList(tag.getNamespace()));
}
PsiFile psiFile = tag.getContainingFile();
XmlExtension xmlExtension = XmlExtension.getExtension(psiFile);
List<String> nsInfo = new ArrayList<String>();
List<XmlElementDescriptor> variants = TagNameVariantCollector.getTagDescriptors(tag, namespaces, nsInfo);
if (variants.isEmpty() && psiFile instanceof XmlFile && ((XmlFile)psiFile).getRootTag() == tag) {
getRootTagsVariants(tag, elements);
return;
}
final Set<String> visited = new HashSet<String>();
for (int i = 0; i < variants.size(); i++) {
XmlElementDescriptor descriptor = variants.get(i);
String qname = descriptor.getName(tag);
if (!visited.add(qname)) continue;
if (!prefix.isEmpty() && qname.startsWith(prefix + ":")) {
qname = qname.substring(prefix.length() + 1);
}
PsiElement declaration = descriptor.getDeclaration();
if (declaration != null && !declaration.isValid()) {
LOG.error(descriptor + " contains invalid declaration: " + declaration);
}
LookupElementBuilder lookupElement = declaration == null ? LookupElementBuilder.create(qname) : LookupElementBuilder.create(declaration, qname);
final int separator = qname.indexOf(':');
if (separator > 0) {
lookupElement = lookupElement.withLookupString(qname.substring(separator + 1));
}
String ns = nsInfo.get(i);
if (StringUtil.isNotEmpty(ns)) {
lookupElement = lookupElement.withTypeText(ns, true);
}
if (descriptor instanceof PsiPresentableMetaData) {
lookupElement = lookupElement.withIcon(((PsiPresentableMetaData)descriptor).getIcon());
}
if (xmlExtension.useXmlTagInsertHandler()) {
lookupElement = lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE);
}
elements.add(PrioritizedLookupElement.withPriority(lookupElement, separator > 0 ? 0 : 1));
}
}
示例7: completeTagNames
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static boolean completeTagNames(@NotNull AndroidFacet facet, @NotNull XmlFile xmlFile, @NotNull CompletionResultSet resultSet) {
if (ManifestDomFileDescription.isManifestFile(xmlFile, facet)) {
resultSet.addElement(LookupElementBuilder.create("manifest"));
return false;
}
else if (LayoutDomFileDescription.isLayoutFile(xmlFile)) {
final Map<String,PsiClass> classMap = facet.getClassMap(
AndroidUtils.VIEW_CLASS_NAME, SimpleClassMapConstructor.getInstance());
for (String rootTag : AndroidLayoutUtil.getPossibleRoots(facet)) {
final PsiClass aClass = classMap.get(rootTag);
LookupElementBuilder builder = aClass != null
? LookupElementBuilder.create(aClass, rootTag)
: LookupElementBuilder.create(rootTag);
final Icon icon = AndroidDomElementDescriptorProvider.getIconForViewTag(rootTag);
if (icon != null) {
builder = builder.withIcon(icon);
}
resultSet.addElement(builder);
}
return false;
}
else if (AnimationDomFileDescription.isAnimationFile(xmlFile)) {
addAll(AndroidAnimationUtils.getPossibleChildren(facet), resultSet);
return false;
}
else if (AnimatorDomFileDescription.isAnimatorFile(xmlFile)) {
addAll(AndroidAnimatorUtil.getPossibleChildren(), resultSet);
return false;
}
else if (XmlResourceDomFileDescription.isXmlResourceFile(xmlFile)) {
addAll(AndroidXmlResourcesUtil.getPossibleRoots(facet), resultSet);
return false;
}
else if (AndroidDrawableDomUtil.isDrawableResourceFile(xmlFile)) {
addAll(AndroidDrawableDomUtil.getPossibleRoots(facet), resultSet);
return false;
}
else if (TransitionDomFileDescription.isTransitionFile(xmlFile)) {
addAll(TransitionDomUtil.getPossibleRoots(), resultSet);
return false;
}
else if (ColorDomFileDescription.isColorResourceFile(xmlFile)) {
addAll(Arrays.asList(DrawableStateListDomFileDescription.SELECTOR_TAG_NAME), resultSet);
return false;
}
return true;
}
示例8: addCompletions
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement mapOrArgumentList = findMapOrArgumentList(parameters);
if (mapOrArgumentList == null) {
return;
}
if (isMapKeyCompletion(parameters)) {
result.stopHere();
}
Map<String, NamedArgumentDescriptor> map = calcNamedArgumentsForCall(mapOrArgumentList);
if (map == null) {
return;
}
if (map.isEmpty()) {
map = findOtherNamedArgumentsInFile(mapOrArgumentList);
}
for (GrNamedArgument argument : getSiblingNamedArguments(mapOrArgumentList)) {
map.remove(argument.getLabelName());
}
for (Map.Entry<String, NamedArgumentDescriptor> entry : map.entrySet()) {
LookupElementBuilder lookup = LookupElementBuilder.create(entry.getValue(), entry.getKey())
.withInsertHandler(NamedArgumentInsertHandler.INSTANCE)
.withTailText(":");
if (entry.getValue().getPriority() == NamedArgumentDescriptor.Priority.UNLIKELY) {
lookup.withItemTextForeground(GroovySyntaxHighlighter.MAP_KEY.getDefaultAttributes().getForegroundColor());
}
else {
lookup = lookup.withIcon(JetgroovyIcons.Groovy.DynamicProperty);
}
result.addElement(lookup);
}
}