use of com.intellij.psi.PsiPackage in project component-runtime by Talend.
the class SuggestionServiceImpl method computeKeySuggestions.
@Override
public List<LookupElement> computeKeySuggestions(final Project project, final Module module, final String packageName, final List<String> containerElements, final String query) {
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
final PsiPackage pkg = javaPsiFacade.findPackage(packageName);
if (pkg == null) {
return Collections.emptyList();
}
final String defaultFamily = getFamilyFromPackageInfo(pkg, module);
return Stream.concat(of(pkg.getClasses()).flatMap(this::unwrapInnerClasses).filter(c -> AnnotationUtil.findAnnotation(c, PARTITION_MAPPER, PROCESSOR, EMITTER) != null).flatMap(clazz -> fromComponent(clazz, defaultFamily)), of(pkg.getClasses()).flatMap(this::unwrapInnerClasses).filter(c -> of(c.getAllFields()).anyMatch(f -> AnnotationUtil.findAnnotation(f, OPTION) != null)).flatMap(c -> fromConfiguration(defaultFamily, c.getName(), c))).filter(s -> containerElements.isEmpty() || !containerElements.contains(s.getKey())).filter(s -> query == null || query.isEmpty() || s.getKey().startsWith(query)).map(s -> s.newLookupElement(withPriority(s.getType()))).collect(toList());
}
use of com.intellij.psi.PsiPackage in project android by JetBrains.
the class DataBindingProjectComponent method getOrCreateDataBindingPsiPackage.
/**
* Returns a {@linkplain PsiPackage} instance for the given package name.
* <p>
* If it does not exist in the cache, a new one is created.
*
* @param packageName The qualified package name
* @return A {@linkplain PsiPackage} that represents the given qualified name
*/
public synchronized PsiPackage getOrCreateDataBindingPsiPackage(String packageName) {
PsiPackage pkg = myDataBindingPsiPackages.get(packageName);
if (pkg == null) {
pkg = new PsiPackageImpl(PsiManager.getInstance(myProject), packageName) {
@Override
public boolean isValid() {
return true;
}
};
myDataBindingPsiPackages.put(packageName, pkg);
}
return pkg;
}
use of com.intellij.psi.PsiPackage in project android by JetBrains.
the class AndroidMultiModuleRenameTest method testLibraryPackageRename.
// Check that renaming package in a library module would rename corresponding reference in AndroidManifest.xml
public void testLibraryPackageRename() throws Exception {
final VirtualFile manifestFile = myFixture.copyFileToProject("rename/AndroidManifest_library_before.xml", LIBRARY_PATH + "/src/AndroidManifest.xml");
myFixture.configureFromExistingVirtualFile(manifestFile);
// At least one Java source has to be copied for .findPackage to return non-null instance
myFixture.copyFileToProject("rename/LibraryClass.java", LIBRARY_PATH + "/src/com/works/customization/my/library/LibraryClass.java");
final PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage("com.works.customization.my.library");
assertNotNull(aPackage);
new RenameProcessor(getProject(), aPackage, "com.works.customization.my.library2", true, true).run();
FileDocumentManager.getInstance().saveAllDocuments();
myFixture.checkResultByFile("rename/AndroidManifest_library_after.xml");
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class DescriptionCheckerUtil method getDescriptionsDirs.
public static PsiDirectory[] getDescriptionsDirs(Module module, DescriptionType descriptionType) {
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(module.getProject());
final PsiPackage psiPackage = javaPsiFacade.findPackage(descriptionType.getDescriptionFolder());
if (psiPackage != null) {
return psiPackage.getDirectories(GlobalSearchScope.moduleWithDependenciesScope(module));
}
return PsiDirectory.EMPTY_ARRAY;
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class JavaTemplateCompletionProcessor method nextTabOnItemSelected.
@Override
public boolean nextTabOnItemSelected(final ExpressionContext context, final LookupElement item) {
final List<? extends PsiElement> elements = JavaCompletionUtil.getAllPsiElements(item);
if (elements != null && elements.size() == 1 && elements.get(0) instanceof PsiPackage) {
return false;
}
Editor editor = context.getEditor();
if (editor != null && editor.getUserData(JavaMethodCallElement.ARGUMENT_TEMPLATE_ACTIVE) != null) {
return item.as(ClassConditionKey.create(SmartCompletionDecorator.class)) != null;
}
return true;
}
Aggregations