Search in sources :

Example 21 with PsiClassType

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;
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) PsiClass(com.intellij.psi.PsiClass) PsiType(com.intellij.psi.PsiType)

Example 22 with PsiClassType

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;
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) PsiType(com.intellij.psi.PsiType)

Example 23 with PsiClassType

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));
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) PsiCall(com.intellij.psi.PsiCall) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement)

Example 24 with PsiClassType

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;
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement)

Example 25 with PsiClassType

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);
}
Also used : Project(com.intellij.openapi.project.Project) PsiClassType(com.intellij.psi.PsiClassType) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiClassType (com.intellij.psi.PsiClassType)39 PsiType (com.intellij.psi.PsiType)20 PsiClass (com.intellij.psi.PsiClass)16 PsiElement (com.intellij.psi.PsiElement)10 NotNull (org.jetbrains.annotations.NotNull)5 Nullable (org.jetbrains.annotations.Nullable)4 UExpression (org.jetbrains.uast.UExpression)4 Location (com.android.tools.klint.detector.api.Location)3 PsiPrimitiveType (com.intellij.psi.PsiPrimitiveType)3 ArrayList (java.util.ArrayList)3 AbstractResourceRepository (com.android.ide.common.res2.AbstractResourceRepository)2 ResourceItem (com.android.ide.common.res2.ResourceItem)2 ResourceUrl (com.android.ide.common.resources.ResourceUrl)2 PsiCFGClass (com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGClass)2 PsiCFGMethod (com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGMethod)2 JavaEvaluator (com.android.tools.klint.client.api.JavaEvaluator)2 LintClient (com.android.tools.klint.client.api.LintClient)2 Project (com.intellij.openapi.project.Project)2 PsiArrayType (com.intellij.psi.PsiArrayType)2 PsiField (com.intellij.psi.PsiField)2