use of com.intellij.psi.PsiClassType in project timber by JakeWharton.
the class WrongTimberUsageDetector method isSubclassOf.
private static boolean isSubclassOf(JavaContext context, PsiExpression expression, Class<?> cls) {
PsiType expressionType = expression.getType();
if (expressionType instanceof PsiClassType) {
PsiClassType classType = (PsiClassType) expressionType;
PsiClass resolvedClass = classType.resolve();
return context.getEvaluator().extendsClass(resolvedClass, cls.getName(), false);
}
return false;
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class PsiExtendedTypeVisitor method visitClassType.
public X visitClassType(final PsiClassType classType) {
super.visitClassType(classType);
final PsiClassType.ClassResolveResult result = classType.resolveGenerics();
if (result.getElement() != null) {
for (final PsiType type : result.getSubstitutor().getSubstitutionMap().values()) {
if (type != null) {
type.accept(this);
}
}
}
return null;
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class InlineToAnonymousClassTest method doTestCanBeInvokedOnReference.
private void doTestCanBeInvokedOnReference(boolean canBeInvokedOnReference) throws Exception {
configureByFile("/refactoring/inlineToAnonymousClass/" + getTestName(false) + ".java");
PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
PsiCall callToInline = InlineToAnonymousClassHandler.findCallToInline(myEditor);
PsiClass classToInline = (PsiClass) element;
assertEquals(null, InlineToAnonymousClassHandler.getCannotInlineMessage(classToInline));
final PsiClassType superType = InlineToAnonymousClassProcessor.getSuperType(classToInline);
assertTrue(superType != null);
assertEquals(canBeInvokedOnReference, InlineToAnonymousClassHandler.canBeInvokedOnReference(callToInline, superType));
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class ExcludeDeclaredFilter method isAcceptable.
@Override
public boolean isAcceptable(Object element, PsiElement context) {
PsiElement cachedVar = context;
if (myCurrentContext.get() != context) {
myCurrentContext = new SoftReference<>(context);
while (cachedVar != null && !(getFilter().isAcceptable(cachedVar, cachedVar.getContext()))) cachedVar = cachedVar.getContext();
myCachedVar = new SoftReference<>(cachedVar);
}
if (element instanceof PsiMethod && myCachedVar.get() instanceof PsiMethod) {
final PsiMethod currentMethod = (PsiMethod) element;
final PsiMethod candidate = (PsiMethod) myCachedVar.get();
return !candidate.getManager().areElementsEquivalent(candidate, currentMethod) && !isOverridingMethod(currentMethod, candidate);
} else if (element instanceof PsiClassType) {
final PsiClass psiClass = ((PsiClassType) element).resolve();
return isAcceptable(psiClass, context);
} else if (context != null) {
if (element instanceof PsiElement)
return !context.getManager().areElementsEquivalent(myCachedVar.get(), (PsiElement) element);
return true;
}
return true;
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class BinopInstruction method getNonNullStringValue.
public DfaValue getNonNullStringValue(final DfaValueFactory factory) {
PsiElement anchor = getPsiAnchor();
Project project = myProject;
PsiClassType string = PsiType.getJavaLangString(PsiManager.getInstance(project), anchor == null ? GlobalSearchScope.allScope(project) : anchor.getResolveScope());
return factory.createTypeValue(string, Nullness.NOT_NULL);
}
Aggregations