use of com.jetbrains.lang.dart.util.DartClassResolveResult in project intellij-plugins by JetBrains.
the class DartReferenceImpl method resolveDartClass.
@NotNull
@Override
public DartClassResolveResult resolveDartClass() {
if (this instanceof DartSuperExpression) {
final DartClass dartClass = PsiTreeUtil.getParentOfType(this, DartClass.class);
return dartClass == null ? DartClassResolveResult.EMPTY : dartClass.getSuperClassResolvedOrObjectClass();
}
if (this instanceof DartNewExpression) {
final DartClassResolveResult result = DartResolveUtil.resolveClassByType(PsiTreeUtil.getChildOfType(this, DartType.class));
result.specialize(this);
return result;
}
if (this instanceof DartCallExpression) {
final DartExpression expression = ((DartCallExpression) this).getExpression();
final DartClassResolveResult leftResult = tryGetLeftResolveResult(expression);
if (expression instanceof DartReference) {
final DartClassResolveResult result = DartResolveUtil.getDartClassResolveResult(((DartReference) expression).resolve(), leftResult.getSpecialization());
result.specialize(this);
return result;
}
}
if (this instanceof DartCascadeReferenceExpression) {
PsiElement parent = this.getParent();
if (parent instanceof DartValueExpression) {
final List<DartExpression> expressionList = ((DartValueExpression) parent).getExpressionList();
final DartExpression firstExpression = expressionList.isEmpty() ? null : expressionList.get(0);
if (firstExpression instanceof DartReference) {
return ((DartReference) firstExpression).resolveDartClass();
}
}
}
if (this instanceof DartAwaitExpression) {
final DartExpression expression = ((DartAwaitExpression) this).getExpression();
if (expression instanceof DartReference) {
final DartClassResolveResult result = ((DartReference) expression).resolveDartClass();
final DartClass resolvedClass = result.getDartClass();
if (resolvedClass != null && "Future".equals(resolvedClass.getName())) {
final DartClassResolveResult unwrappedFuture = result.getSpecialization().get(resolvedClass, "T");
return unwrappedFuture == null ? DartClassResolveResult.EMPTY : unwrappedFuture;
} else {
return result;
}
}
}
return DartResolveUtil.getDartClassResolveResult(resolve(), tryGetLeftResolveResult(this).getSpecialization());
}
Aggregations