use of com.intellij.codeInsight.lookup.LookupElement in project android by JetBrains.
the class AndroidXmlResourcesDomTest method testCustomXmlFileCompletion2.
public void testCustomXmlFileCompletion2() throws Throwable {
VirtualFile file = copyFileToProject(getTestName(true) + ".xml");
myFixture.configureFromExistingVirtualFile(file);
myFixture.complete(CompletionType.BASIC);
final LookupElement[] lookupElements = myFixture.getLookupElements();
assertNotNull(lookupElements);
for (LookupElement element : lookupElements) {
if ("http://www.w3.org/1999/xhtml".equals(element.getLookupString())) {
return;
}
}
fail(Arrays.asList(lookupElements).toString());
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-plugins by JetBrains.
the class AngularJavaScriptCompletionContributor method addCompletionVariants.
static void addCompletionVariants(@NotNull CompletionResultSet result, Collection<String> keys, @Nullable final String comment) {
for (String key : keys) {
if (StringUtil.isEmptyOrSpaces(key)) {
continue;
}
LookupElementBuilder builder = LookupElementBuilder.create(key);
if (comment != null) {
builder = builder.withTailText(comment, true);
}
final LookupElement item = JSCompletionUtil.withJSLookupPriority(builder, JSLookupPriority.LOCAL_SCOPE_MAX_PRIORITY);
result.addElement(item);
}
}
use of com.intellij.codeInsight.lookup.LookupElement in project android by JetBrains.
the class DataBindingCompletionUtil method fillClassNames.
private static void fillClassNames(@NotNull CompletionResultSet resultSet, @NotNull String packagePrefix, @NotNull Module module) {
final Project project = module.getProject();
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
PsiPackage basePackage = javaPsiFacade.findPackage(packagePrefix);
if (basePackage == null) {
PsiClass aClass = javaPsiFacade.findClass(packagePrefix, module.getModuleWithDependenciesAndLibrariesScope(false));
if (aClass != null) {
PsiClass[] innerClasses = aClass.getInnerClasses();
for (PsiClass innerClass : innerClasses) {
resultSet.addElement(new JavaPsiClassReferenceElement(innerClass));
}
}
// TODO: add completions for java.lang classes
} else {
GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope(false);
PsiPackage[] subPackages = basePackage.getSubPackages(scope);
for (PsiPackage pkg : subPackages) {
// many res folders also show up as package suggestions - eg. drawable-hdpi, which is clearly not a package.
if (pkg.getSubPackages(scope).length > 0 || pkg.getClasses(scope).length > 0) {
// For some reason, we see some invalid packages here - eg. META-INF. Filter them out.
String name = pkg.getName();
boolean invalidPkg = false;
// can only be null for default package, which this is not, as it's a subpackage.
assert name != null;
for (int i = 0; i < name.length(); i++) {
if (!Character.isJavaIdentifierPart(name.charAt(i))) {
invalidPkg = true;
break;
}
}
if (invalidPkg) {
// skip adding this package.
continue;
}
LookupElement element = new TailTypeDecorator<LookupElement>(LookupElementBuilder.createWithIcon(pkg)) {
@Nullable
@Override
protected TailType computeTailType(InsertionContext context) {
return TailType.DOT;
}
@Override
public void handleInsert(InsertionContext context) {
super.handleInsert(context);
AutoPopupController.getInstance(project).scheduleAutoPopup(context.getEditor());
}
};
resultSet.addElement(element);
}
}
for (PsiClass psiClass : basePackage.getClasses(scope)) {
resultSet.addElement(new JavaPsiClassReferenceElement(psiClass));
}
}
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-elixir by KronicDeth.
the class CallDefinitionClauseTest method testIssue457ShorterName.
/*
* Tests
*/
public void testIssue457ShorterName() {
String name = "fo";
LookupElement lookupElement = lookupElement(name);
LookupElementPresentation lookupElementPresentation = new LookupElementPresentation();
lookupElement.renderElement(lookupElementPresentation);
assertEquals(name, lookupElementPresentation.getItemText());
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-elixir by KronicDeth.
the class CallDefinitionClauseTest method testIssue457LongerNameIssue503.
public void testIssue457LongerNameIssue503() {
String name = "fooo";
LookupElement lookupElement = lookupElement(name);
LookupElementPresentation lookupElementPresentation = new LookupElementPresentation();
lookupElement.renderElement(lookupElementPresentation);
assertEquals(name, lookupElementPresentation.getItemText());
}
Aggregations