use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class LiteralConstructorSearcher method isCorrectReference.
private boolean isCorrectReference(LiteralConstructorReference reference) {
if (reference.isReferenceTo(myConstructor)) {
return true;
}
if (!myIncludeOverloads) {
return false;
}
PsiClassType constructedClassType = reference.getConstructedClassType();
if (constructedClassType == null)
return false;
final PsiClass psiClass = constructedClassType.resolve();
return myConstructor.getManager().areElementsEquivalent(myConstructor.getContainingClass(), psiClass);
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class GrHighlightOverridingMethodsHandler method getTargets.
@Override
public List<PsiClass> getTargets() {
GrReferenceList list = GroovyTokenTypes.kEXTENDS == myTarget.getNode().getElementType() ? myClass.getExtendsClause() : myClass.getImplementsClause();
if (list == null)
return Collections.emptyList();
final PsiClassType[] classTypes = list.getReferencedTypes();
return ChooseClassAndDoHighlightRunnable.resolveClasses(classTypes);
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class GrMemberInfoStorage method buildSubClassesMapForList.
private void buildSubClassesMapForList(final PsiClassType[] classesList, GrTypeDefinition aClass) {
for (int i = 0; i < classesList.length; i++) {
PsiClassType element = classesList[i];
PsiClass resolved = element.resolve();
if (resolved instanceof GrTypeDefinition) {
GrTypeDefinition superClass = (GrTypeDefinition) resolved;
getSubclasses(superClass).add(aClass);
buildSubClassesMap(superClass);
}
}
}
use of com.intellij.psi.PsiClassType in project kotlin by JetBrains.
the class HandlerDetector method checkClass.
@Override
public void checkClass(@NonNull JavaContext context, @NonNull UClass declaration) {
// Only consider static inner classes
if (context.getEvaluator().isStatic(declaration)) {
return;
}
boolean isAnonymous = declaration instanceof UAnonymousClass;
if (declaration.getContainingClass() == null && !isAnonymous) {
return;
}
//// Only flag handlers using the default looper
//noinspection unchecked
UCallExpression invocation = UastUtils.getParentOfType(declaration, UObjectLiteralExpression.class, true, UMethod.class);
if (invocation != null) {
if (isAnonymous && invocation.getValueArgumentCount() > 0) {
for (UExpression expression : invocation.getValueArguments()) {
PsiType type = expression.getExpressionType();
if (type instanceof PsiClassType && LOOPER_CLS.equals(type.getCanonicalText())) {
return;
}
}
}
} else if (hasLooperConstructorParameter(declaration)) {
// possibly used correctly from elsewhere
return;
}
Location location = context.getUastNameLocation(declaration);
String name;
if (isAnonymous) {
name = "anonymous " + ((UAnonymousClass) declaration).getBaseClassReference().getQualifiedName();
} else {
name = declaration.getQualifiedName();
}
//noinspection VariableNotUsedInsideIf
context.reportUast(ISSUE, declaration, location, String.format("This Handler class should be static or leaks might occur (%1$s)", name));
}
use of com.intellij.psi.PsiClassType in project kotlin by JetBrains.
the class JavaScriptInterfaceDetector method visitMethod.
@Override
public void visitMethod(@NonNull JavaContext context, @Nullable UastVisitor visitor, @NonNull UCallExpression call, @NonNull UMethod method) {
if (context.getMainProject().getTargetSdk() < 17) {
return;
}
List<UExpression> arguments = call.getValueArguments();
if (arguments.size() != 2) {
return;
}
JavaEvaluator evaluator = context.getEvaluator();
if (!JavaEvaluator.isMemberInClass(method, WEB_VIEW_CLS)) {
return;
}
UExpression first = arguments.get(0);
PsiType evaluated = TypeEvaluator.evaluate(context, first);
if (evaluated instanceof PsiClassType) {
PsiClassType classType = (PsiClassType) evaluated;
PsiClass cls = classType.resolve();
if (cls == null) {
return;
}
if (isJavaScriptAnnotated(cls)) {
return;
}
Location location = context.getUastNameLocation(call);
String message = String.format("None of the methods in the added interface (%1$s) have been annotated " + "with `@android.webkit.JavascriptInterface`; they will not " + "be visible in API 17", cls.getName());
context.report(ISSUE, call, location, message);
}
}
Aggregations