Search in sources :

Example 1 with PackageScope

use of com.intellij.psi.search.PackageScope in project intellij-community by JetBrains.

the class GenerateVisitorByHierarchyAction method generateEverything.

public static String generateEverything(final PsiPackage psiPackage, final PsiClass rootClass, final String visitorName) {
    final String visitorQName = PsiNameHelper.getShortClassName(visitorName).equals(visitorName) ? psiPackage.getQualifiedName() + "." + visitorName : visitorName;
    final PsiDirectory directory = PackageUtil.findOrCreateDirectoryForPackage(rootClass.getProject(), StringUtil.getPackageName(visitorQName), null, false);
    generateVisitorClass(visitorQName, rootClass, directory, new PackageScope(psiPackage, false, false));
    return visitorQName;
}
Also used : PackageScope(com.intellij.psi.search.PackageScope)

Example 2 with PackageScope

use of com.intellij.psi.search.PackageScope in project intellij-plugins by JetBrains.

the class ValidatorManagerImpl method findValidationFilesFor.

@NotNull
@Override
public List<XmlFile> findValidationFilesFor(@NotNull final PsiClass clazz) {
    final PsiFile psiFile = clazz.getContainingFile().getOriginalFile();
    final PsiDirectory containingDirectory = psiFile.getContainingDirectory();
    if (containingDirectory == null) {
        return Collections.emptyList();
    }
    final PsiPackage containingPackage = JavaDirectoryService.getInstance().getPackage(containingDirectory);
    if (containingPackage == null) {
        return Collections.emptyList();
    }
    final PackageScope searchScope = new PackageScope(containingPackage, false, true);
    final List<DomFileElement<Validators>> validationRoots = DomService.getInstance().getFileElements(Validators.class, clazz.getProject(), searchScope);
    final List<DomFileElement<Validators>> filtered = ContainerUtil.filter(validationRoots, validatorDomFileElement -> {
        final String fileName = validatorDomFileElement.getFile().getName();
        return StringUtil.startsWith(fileName, clazz.getName());
    });
    return ContainerUtil.map(filtered, validatorsDomFileElement -> validatorsDomFileElement.getFile());
}
Also used : PackageScope(com.intellij.psi.search.PackageScope) DomFileElement(com.intellij.util.xml.DomFileElement) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with PackageScope

use of com.intellij.psi.search.PackageScope in project intellij-plugins by JetBrains.

the class FieldNameConverterImpl method findBeanPropertyClass.

@Override
protected PsiClass findBeanPropertyClass(@NotNull final DomElement domElement) {
    final XmlElement xmlElement = domElement.getXmlElement();
    assert xmlElement != null;
    final PsiFile psiFile = xmlElement.getContainingFile().getOriginalFile();
    final PsiDirectory containingDirectory = psiFile.getContainingDirectory();
    if (containingDirectory == null) {
        return null;
    }
    final PsiPackage containingPackage = JavaDirectoryService.getInstance().getPackage(containingDirectory);
    if (containingPackage == null) {
        return null;
    }
    // ClassName-[method-]validation.xml
    final String validationFileName = psiFile.getName();
    final String actionClassName = StringUtil.split(validationFileName, "-").get(0);
    final String qualifiedActionClassName = StringUtil.getQualifiedName(containingPackage.getQualifiedName(), actionClassName);
    final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(psiFile.getProject());
    return psiFacade.findClass(qualifiedActionClassName, new PackageScope(containingPackage, false, false));
}
Also used : PackageScope(com.intellij.psi.search.PackageScope) XmlElement(com.intellij.psi.xml.XmlElement)

Aggregations

PackageScope (com.intellij.psi.search.PackageScope)3 XmlElement (com.intellij.psi.xml.XmlElement)1 DomFileElement (com.intellij.util.xml.DomFileElement)1 NotNull (org.jetbrains.annotations.NotNull)1