use of com.intellij.psi.PsiType 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.PsiType in project intellij-community by JetBrains.
the class GroovyMapValueTypeEnhancer method getReferenceType.
@Override
public PsiType getReferenceType(GrReferenceExpression ref, @Nullable PsiElement resolved) {
if (resolved != null)
return null;
GrExpression qualifierExpression = ref.getQualifierExpression();
if (qualifierExpression == null)
return null;
PsiType mapType = qualifierExpression.getType();
if (!InheritanceUtil.isInheritor(mapType, CommonClassNames.JAVA_UTIL_MAP)) {
return null;
}
PsiElement qResolved;
if (qualifierExpression instanceof GrReferenceExpression) {
qResolved = ((GrReferenceExpression) qualifierExpression).resolve();
} else if (qualifierExpression instanceof GrMethodCall) {
qResolved = ((GrMethodCall) qualifierExpression).resolveMethod();
} else {
return null;
}
String key = ref.getReferenceName();
if (key == null)
return null;
for (GroovyMapContentProvider provider : GroovyMapContentProvider.EP_NAME.getExtensions()) {
PsiType type = provider.getValueType(qualifierExpression, qResolved, key);
if (type != null) {
return type;
}
}
if (mapType instanceof GrMapType) {
return ((GrMapType) mapType).getTypeByStringKey(key);
}
return null;
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class EquivalenceChecker method safeCastExpressionsAreEquivalent.
private static boolean safeCastExpressionsAreEquivalent(GrSafeCastExpression expression1, GrSafeCastExpression expression2) {
final GrExpression operand1 = expression1.getOperand();
final GrExpression operand2 = expression2.getOperand();
if (!expressionsAreEquivalent(operand1, operand2)) {
return false;
}
final GrTypeElement typeElement1 = expression1.getCastTypeElement();
final GrTypeElement typeElement2 = expression2.getCastTypeElement();
final PsiType safe1 = typeElement1 == null ? null : typeElement1.getType();
final PsiType safe2 = typeElement2 == null ? null : typeElement2.getType();
return typesAreEquivalent(safe1, safe2);
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class EquivalenceChecker method variablesAreEquivalent.
private static boolean variablesAreEquivalent(@NotNull GrVariable var1, @NotNull GrVariable var2) {
final GrExpression initializer1 = var1.getInitializerGroovy();
final GrExpression initializer2 = var2.getInitializerGroovy();
if (!expressionsAreEquivalent(initializer1, initializer2)) {
return false;
}
final PsiType type1 = var1.getType();
final PsiType type2 = var2.getType();
if (!typesAreEquivalent(type1, type2)) {
return false;
}
final String name1 = var1.getName();
final String name2 = var2.getName();
return name1.equals(name2);
}
use of com.intellij.psi.PsiType 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