Search in sources :

Example 31 with PsiClass

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

the class JavaFXRenameTest method doTestHandler.

@NotNull
public PsiClass doTestHandler(String newName, String className) throws Exception {
    if (className == null) {
        className = getTestName(false);
        myFixture.configureByFiles(getTestName(true) + ".fxml", getTestName(false) + ".java");
    } else {
        myFixture.configureByFiles(getTestName(true) + ".fxml", getTestName(false) + ".java", className.replace('.', '/') + ".java");
    }
    final MapDataContext dataContext = new MapDataContext();
    dataContext.put(CommonDataKeys.EDITOR, getEditor());
    dataContext.put(PsiElementRenameHandler.DEFAULT_NAME, newName);
    final JavaFxPropertyRenameHandler renameHandler = new JavaFxPropertyRenameHandler();
    assertTrue(renameHandler.isAvailableOnDataContext(dataContext));
    renameHandler.invoke(getProject(), getEditor(), null, dataContext);
    myFixture.checkResultByFile(getTestName(true) + "_after.fxml");
    final PsiClass psiClass = myFixture.findClass(className);
    assertNotNull(psiClass);
    return psiClass;
}
Also used : JavaFxPropertyRenameHandler(org.jetbrains.plugins.javaFX.refactoring.JavaFxPropertyRenameHandler) MapDataContext(com.intellij.testFramework.MapDataContext) PsiClass(com.intellij.psi.PsiClass) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with PsiClass

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

the class JavaFXRenameTest method testPrivateSuperHandler.

public void testPrivateSuperHandler() throws Exception {
    final String newName = "newHandlerName";
    final String fxmlPath = getTestName(true) + ".fxml";
    final String fxmlPathAfter = getTestName(true) + "_after.fxml";
    final String baseClassName = getTestName(false) + "Base";
    myFixture.configureByFiles(baseClassName + ".java", getTestName(false) + ".java", fxmlPath);
    doRenameWithAutomaticRenamers(newName);
    myFixture.checkResultByFile(fxmlPath, fxmlPathAfter, false);
    final PsiClass psiClass = myFixture.findClass(baseClassName);
    assertNotNull(psiClass);
    assertMethodExists(psiClass, newName);
}
Also used : PsiClass(com.intellij.psi.PsiClass)

Example 33 with PsiClass

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

the class InsertComponentProcessor method checkAddDependencyOnInsert.

private boolean checkAddDependencyOnInsert(final ComponentItem item) {
    if (item.getClassName().equals(HSpacer.class.getName()) || item.getClassName().equals(VSpacer.class.getName())) {
        // this is mostly required for IDEA developers, so that developers don't receive prompt to offer ui-designer-impl dependency
        return true;
    }
    PsiManager manager = PsiManager.getInstance(myEditor.getProject());
    final GlobalSearchScope projectScope = GlobalSearchScope.allScope(myEditor.getProject());
    final GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(myEditor.getModule());
    final PsiClass componentClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), projectScope);
    if (componentClass != null && JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), moduleScope) == null) {
        final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myEditor.getProject()).getFileIndex();
        List<OrderEntry> entries = fileIndex.getOrderEntriesForFile(componentClass.getContainingFile().getVirtualFile());
        if (entries.size() > 0) {
            if (entries.get(0) instanceof ModuleSourceOrderEntry) {
                if (!checkAddModuleDependency(item, (ModuleSourceOrderEntry) entries.get(0)))
                    return false;
            } else if (entries.get(0) instanceof LibraryOrderEntry) {
                if (!checkAddLibraryDependency(item, (LibraryOrderEntry) entries.get(0)))
                    return false;
            }
        }
    }
    return true;
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiClass(com.intellij.psi.PsiClass) PsiManager(com.intellij.psi.PsiManager)

Example 34 with PsiClass

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

the class Java15FormInspection method checkComponentProperties.

protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
    final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
    final PsiManager psiManager = PsiManager.getInstance(module.getProject());
    final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
    if (aClass == null) {
        return;
    }
    for (final IProperty prop : component.getModifiedProperties()) {
        final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
        if (getter == null)
            continue;
        final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
        if (Java15APIUsageInspection.getLastIncompatibleLanguageLevel(getter, languageLevel) != null) {
            registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
        }
    }
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) IProperty(com.intellij.uiDesigner.lw.IProperty) PsiMethod(com.intellij.psi.PsiMethod) LanguageLevel(com.intellij.pom.java.LanguageLevel) PsiClass(com.intellij.psi.PsiClass) PsiManager(com.intellij.psi.PsiManager)

Example 35 with PsiClass

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

the class AddComponentAction method assignDefaultIcon.

private static void assignDefaultIcon(final Project project, final ComponentItem itemToBeAdded) {
    Palette palette = Palette.getInstance(project);
    if (itemToBeAdded.getIconPath() == null || itemToBeAdded.getIconPath().length() == 0) {
        PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(itemToBeAdded.getClassName().replace('$', '.'), ProjectScope.getAllScope(project));
        while (aClass != null) {
            final ComponentItem item = palette.getItem(aClass.getQualifiedName());
            if (item != null) {
                String iconPath = item.getIconPath();
                if (iconPath != null && iconPath.length() > 0) {
                    itemToBeAdded.setIconPath(iconPath);
                    return;
                }
            }
            aClass = aClass.getSuperClass();
        }
    }
}
Also used : PsiClass(com.intellij.psi.PsiClass)

Aggregations

PsiClass (com.intellij.psi.PsiClass)598 PsiElement (com.intellij.psi.PsiElement)113 PsiMethod (com.intellij.psi.PsiMethod)97 Nullable (org.jetbrains.annotations.Nullable)75 NotNull (org.jetbrains.annotations.NotNull)60 Project (com.intellij.openapi.project.Project)59 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)57 Module (com.intellij.openapi.module.Module)55 PsiFile (com.intellij.psi.PsiFile)49 VirtualFile (com.intellij.openapi.vfs.VirtualFile)47 ArrayList (java.util.ArrayList)37 PsiField (com.intellij.psi.PsiField)36 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)25 Location (com.intellij.execution.Location)20 File (java.io.File)16 HashSet (java.util.HashSet)16 PsiClassType (com.intellij.psi.PsiClassType)15 PsiPackage (com.intellij.psi.PsiPackage)15 List (java.util.List)15 PsiType (com.intellij.psi.PsiType)13