Search in sources :

Example 36 with PsiPackage

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());
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) PsiPackage(com.intellij.psi.PsiPackage) PsiType(com.intellij.psi.PsiType) JavaPsiFacade(com.intellij.psi.JavaPsiFacade) FilenameIndex(com.intellij.psi.search.FilenameIndex) DISPLAY_NAME(org.talend.sdk.component.intellij.completion.properties.Suggestion.DISPLAY_NAME) CompletionParameters(com.intellij.codeInsight.completion.CompletionParameters) Collections.singletonList(java.util.Collections.singletonList) PsiClass(com.intellij.psi.PsiClass) PsiEnumConstant(com.intellij.psi.PsiEnumConstant) PsiClassReferenceType(com.intellij.psi.impl.source.PsiClassReferenceType) Project(com.intellij.openapi.project.Project) JavaRecursiveElementWalkingVisitor(com.intellij.psi.JavaRecursiveElementWalkingVisitor) ROOT(java.util.Locale.ROOT) Module(com.intellij.openapi.module.Module) PLACEHOLDER(org.talend.sdk.component.intellij.completion.properties.Suggestion.PLACEHOLDER) Suggestion(org.talend.sdk.component.intellij.completion.properties.Suggestion) LookupElement(com.intellij.codeInsight.lookup.LookupElement) Collections.emptyList(java.util.Collections.emptyList) Optional.ofNullable(java.util.Optional.ofNullable) Stream.of(java.util.stream.Stream.of) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiJavaFile(com.intellij.psi.PsiJavaFile) Objects(java.util.Objects) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Stream(java.util.stream.Stream) AnnotationUtil(com.intellij.codeInsight.AnnotationUtil) PsiAnnotation(com.intellij.psi.PsiAnnotation) JvmModifier(com.intellij.lang.jvm.JvmModifier) Collections(java.util.Collections) PsiAnnotationMemberValue(com.intellij.psi.PsiAnnotationMemberValue) PsiPackage(com.intellij.psi.PsiPackage)

Example 37 with PsiPackage

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;
}
Also used : PsiPackageImpl(com.intellij.psi.impl.file.PsiPackageImpl) PsiPackage(com.intellij.psi.PsiPackage)

Example 38 with PsiPackage

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");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiPackage(com.intellij.psi.PsiPackage)

Example 39 with PsiPackage

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;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) PsiPackage(com.intellij.psi.PsiPackage)

Example 40 with PsiPackage

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;
}
Also used : PsiPackage(com.intellij.psi.PsiPackage) Editor(com.intellij.openapi.editor.Editor)

Aggregations

PsiPackage (com.intellij.psi.PsiPackage)93 PsiDirectory (com.intellij.psi.PsiDirectory)24 PsiClass (com.intellij.psi.PsiClass)22 Module (com.intellij.openapi.module.Module)19 Project (com.intellij.openapi.project.Project)14 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 JavaAnalysisScope (com.intellij.analysis.JavaAnalysisScope)12 PsiFile (com.intellij.psi.PsiFile)12 PsiElement (com.intellij.psi.PsiElement)11 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)10 NotNull (org.jetbrains.annotations.NotNull)10 CyclicDependenciesBuilder (com.intellij.cyclicDependencies.CyclicDependenciesBuilder)9 Nullable (org.jetbrains.annotations.Nullable)9 AnalysisScope (com.intellij.analysis.AnalysisScope)8 HashSet (java.util.HashSet)6 List (java.util.List)5 LookupElement (com.intellij.codeInsight.lookup.LookupElement)4 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)4 ArrayList (java.util.ArrayList)4