use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-plugins by JetBrains.
the class BeanPropertyPathReference method getVariants.
@NotNull
public Object[] getVariants() {
final PsiClass psiClass = getPsiClass();
if (psiClass == null) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
final Map<String, PsiMethod> properties = PropertyUtil.getAllProperties(psiClass, true, !isLast() || referenceSet.isSupportsReadOnlyProperties());
final Object[] variants = new Object[properties.size()];
int i = 0;
for (final Map.Entry<String, PsiMethod> entry : properties.entrySet()) {
final String propertyName = entry.getKey();
final PsiMethod psiMethod = entry.getValue();
final PsiType propertyType = PropertyUtil.getPropertyType(psiMethod);
assert propertyType != null;
final LookupElementBuilder variant = LookupElementBuilder.create(psiMethod, propertyName).withIcon(psiMethod.getIcon(0)).withStrikeoutness(psiMethod.isDeprecated()).withTypeText(propertyType.getPresentableText());
variants[i++] = variant;
}
return variants;
}
use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.
the class JavaModuleCompletion method lookupElement.
private static LookupElementBuilder lookupElement(PsiNamedElement e) {
LookupElementBuilder lookup = LookupElementBuilder.create(e).withInsertHandler(FQN_INSERT_HANDLER);
String fqn = e instanceof PsiClass ? ((PsiClass) e).getQualifiedName() : ((PsiQualifiedNamedElement) e).getQualifiedName();
return fqn != null ? lookup.withPresentableText(fqn) : lookup;
}
use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.
the class AntDomPropertyReference method getVariants.
@NotNull
@Override
public Object[] getVariants() {
final AntDomProject project = myInvocationContextElement.getParentOfType(AntDomProject.class, true);
if (project != null) {
final Collection<String> variants = PropertyResolver.resolve(project.getContextAntProject(), getCanonicalText(), myInvocationContextElement).getSecond();
Object[] result = new Object[variants.size()];
int idx = 0;
for (String variant : variants) {
final LookupElementBuilder builder = LookupElementBuilder.create(variant).withCaseSensitivity(false);
final LookupElement element = AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE.applyPolicy(builder);
result[idx++] = element;
}
return result;
}
return EMPTY_ARRAY;
}
use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.
the class AntDomTargetReference method getVariants.
@NotNull
public Object[] getVariants() {
final TargetResolver.Result result = doResolve(getCanonicalText());
if (result == null) {
return EMPTY_ARRAY;
}
final Map<String, AntDomTarget> variants = result.getVariants();
final List resVariants = new ArrayList();
final Set<String> existing = getExistingNames();
for (String s : variants.keySet()) {
if (existing.contains(s)) {
continue;
}
final LookupElementBuilder builder = LookupElementBuilder.create(s).withCaseSensitivity(false);
final LookupElement element = AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE.applyPolicy(builder);
resVariants.add(element);
}
return ContainerUtil.toArray(resVariants, new Object[resVariants.size()]);
}
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;
}
Aggregations