use of org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression in project intellij-community by JetBrains.
the class InstanceOfInstruction method getInstanceof.
@Nullable
private Pair<GrExpression, PsiType> getInstanceof() {
final PsiElement element = getElement();
if (element instanceof GrInstanceOfExpression) {
GrExpression operand = ((GrInstanceOfExpression) element).getOperand();
final GrTypeElement typeElement = ((GrInstanceOfExpression) element).getTypeElement();
if (operand instanceof GrReferenceExpression && ((GrReferenceExpression) operand).getQualifier() == null && typeElement != null) {
return Pair.create(((GrInstanceOfExpression) element).getOperand(), typeElement.getType());
}
} else if (element instanceof GrBinaryExpression && ControlFlowBuilderUtil.isInstanceOfBinary((GrBinaryExpression) element)) {
GrExpression left = ((GrBinaryExpression) element).getLeftOperand();
GrExpression right = ((GrBinaryExpression) element).getRightOperand();
if (right == null)
return null;
GroovyResolveResult result = ((GrReferenceExpression) right).advancedResolve();
final PsiElement resolved = result.getElement();
if (resolved instanceof PsiClass) {
PsiClassType type = JavaPsiFacade.getElementFactory(element.getProject()).createType((PsiClass) resolved, result.getSubstitutor());
return new Pair<>(left, type);
}
}
return null;
}
Aggregations