use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class SpringLoadedPositionManager method getOuterClassName.
@Nullable
private static String getOuterClassName(final SourcePosition position) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
PsiElement element = findElementAt(position);
if (element == null)
return null;
PsiElement sourceImage = PsiTreeUtil.getParentOfType(element, GrClosableBlock.class, GrTypeDefinition.class, PsiClassImpl.class);
if (sourceImage instanceof PsiClass) {
return getClassNameForJvm((PsiClass) sourceImage);
}
return null;
} finally {
accessToken.finish();
}
}
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));
}
Aggregations