use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class AsTypeTransformation method couldApply.
@Override
protected boolean couldApply(@NotNull GrSafeCastExpression expression) {
GrTypeElement typeElement = expression.getCastTypeElement();
if (typeElement == null)
return false;
PsiType type = typeElement.getType();
return type instanceof PsiClassType && ((PsiClassType) type).getParameterCount() == 0;
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class GroovyUntypedAccessInspection method buildVisitor.
@Override
@NotNull
protected BaseInspectionVisitor buildVisitor() {
return new BaseInspectionVisitor() {
@Override
public void visitReferenceExpression(@NotNull GrReferenceExpression refExpr) {
super.visitReferenceExpression(refExpr);
if (PsiUtil.isThisOrSuperRef(refExpr))
return;
GroovyResolveResult resolveResult = refExpr.advancedResolve();
PsiElement resolved = resolveResult.getElement();
if (resolved != null) {
if (GrHighlightUtil.isDeclarationAssignment(refExpr) || resolved instanceof PsiPackage)
return;
} else {
GrExpression qualifier = refExpr.getQualifierExpression();
if (qualifier == null && GrHighlightUtil.isDeclarationAssignment(refExpr))
return;
}
final PsiType refExprType = refExpr.getType();
if (refExprType == null) {
if (resolved != null) {
registerError(refExpr);
}
} else if (refExprType instanceof PsiClassType && ((PsiClassType) refExprType).resolve() == null) {
registerError(refExpr);
}
}
};
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class GrExpressionCategory method getClassType.
@Nullable
public static PsiClass getClassType(GrExpression expr) {
final PsiType type = expr.getType();
if (type instanceof PsiClassType) {
PsiClassType classType = (PsiClassType) type;
return classType.resolve();
} else {
final String text = type.getPresentableText();
final Project project = expr.getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
return facade.findClass(text, GlobalSearchScope.allScope(project));
}
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class GdslType method getName.
public String getName() {
PsiType type = psiType;
if (type instanceof PsiWildcardType) {
type = ((PsiWildcardType) type).getBound();
}
if (type instanceof PsiClassType) {
final PsiClass resolve = ((PsiClassType) type).resolve();
if (resolve != null) {
return resolve.getName();
}
final String canonicalText = type.getCanonicalText();
final int i = canonicalText.indexOf('<');
if (i < 0)
return canonicalText;
return canonicalText.substring(0, i);
}
if (type == null) {
return "";
}
return type.getCanonicalText();
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class GroovyMethodReturnNamedArgumentProvider method getNamedArguments.
@Override
public void getNamedArguments(@NotNull GrCall call, @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, @NotNull Map<String, NamedArgumentDescriptor> result) {
PsiElement resolve = resolveResult.getElement();
if (!forCompletion || !(resolve instanceof PsiMethod))
return;
PsiType returnType = ((PsiMethod) resolve).getReturnType();
if (!(returnType instanceof PsiClassType))
return;
Map<String, NamedArgumentDescriptor> map = new HashMap<>();
GroovyConstructorNamedArgumentProvider.processClass(call, (PsiClassType) returnType, argumentName, map);
for (String name : map.keySet()) {
result.put(name, NamedArgumentDescriptor.SIMPLE_UNLIKELY);
}
}
Aggregations