use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class GroovyTestFramework method findOrCreateSetUpMethod.
@Override
protected PsiMethod findOrCreateSetUpMethod(PsiClass clazz) throws IncorrectOperationException {
LOG.assertTrue(clazz.getLanguage() == GroovyLanguage.INSTANCE);
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(clazz.getProject());
final PsiMethod patternMethod = createSetUpPatternMethod(factory);
final PsiClass baseClass = clazz.getSuperClass();
if (baseClass != null) {
final PsiMethod baseMethod = baseClass.findMethodBySignature(patternMethod, false);
if (baseMethod != null && baseMethod.hasModifierProperty(PsiModifier.PUBLIC)) {
PsiUtil.setModifierProperty(patternMethod, PsiModifier.PROTECTED, false);
PsiUtil.setModifierProperty(patternMethod, PsiModifier.PUBLIC, true);
}
}
PsiMethod inClass = clazz.findMethodBySignature(patternMethod, false);
if (inClass == null) {
PsiMethod testMethod = JUnitUtil.findFirstTestMethod(clazz);
if (testMethod != null) {
return (PsiMethod) clazz.addBefore(patternMethod, testMethod);
}
return (PsiMethod) clazz.add(patternMethod);
} else if (inClass.getBody() == null) {
return (PsiMethod) inClass.replace(patternMethod);
}
return inClass;
}
use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class MavenPluginCustomParameterValueConverter method getConverter.
@Override
public Converter getConverter(@NotNull GenericDomValue domElement) {
Project project = domElement.getManager().getProject();
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
PsiClass psiClass = psiFacade.findClass(myType, GlobalSearchScope.allScope(project));
if (psiClass != null) {
GenericDomValueConvertersRegistry convertersRegistry = MavenDomConvertersRegistry.getInstance().getConvertersRegistry();
return convertersRegistry.getConverter(domElement, psiFacade.getElementFactory().createType(psiClass));
}
return null;
}
use of com.intellij.psi.PsiClass in project kotlin by JetBrains.
the class JavaClassFinderImpl method findClass.
@Nullable
@Override
public JavaClass findClass(@NotNull ClassId classId) {
PsiClass psiClass = javaFacade.findClass(classId, javaSearchScope);
if (psiClass == null)
return null;
JavaClassImpl javaClass = new JavaClassImpl(psiClass);
FqName fqName = classId.asSingleFqName();
if (!fqName.equals(javaClass.getFqName())) {
throw new IllegalStateException("Requested " + fqName + ", got " + javaClass.getFqName());
}
if (psiClass instanceof KtLightClassMarker) {
throw new IllegalStateException("Kotlin light classes should not be found by JavaPsiFacade, resolving: " + fqName);
}
return javaClass;
}
use of com.intellij.psi.PsiClass in project kotlin by JetBrains.
the class JavaAnnotationImpl method computeClassId.
@Nullable
private static ClassId computeClassId(@NotNull PsiClass psiClass) {
PsiClass container = psiClass.getContainingClass();
if (container != null) {
ClassId parentClassId = computeClassId(container);
String name = psiClass.getName();
return parentClassId == null || name == null ? null : parentClassId.createNestedClassId(Name.identifier(name));
}
String fqName = psiClass.getQualifiedName();
return fqName == null ? null : ClassId.topLevel(new FqName(fqName));
}
use of com.intellij.psi.PsiClass in project kotlin by JetBrains.
the class JavaAnnotationImpl method getClassId.
@Override
@Nullable
public ClassId getClassId() {
PsiClass resolved = resolvePsi();
if (resolved != null)
return computeClassId(resolved);
// External annotations do not have PSI behind them,
// so we can only heuristically reconstruct annotation class ids from qualified names
String qualifiedName = getPsi().getQualifiedName();
if (qualifiedName != null)
return ClassId.topLevel(new FqName(qualifiedName));
return null;
}
Aggregations