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;
}
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);
}
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;
}
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));
}
}
}
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();
}
}
}
Aggregations