Skip to content

Commit c9ea1c8

Browse files
committed
Add null checks.
1 parent 07be8dd commit c9ea1c8

File tree

1 file changed

+21
-4
lines changed
  • edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis

1 file changed

+21
-4
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Util.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,27 @@ public static boolean matches(SSAInstruction instruction, MethodInvocation invoc
763763

764764
private static boolean matches(TypeReference methodDeclaringType, MethodReference method,
765765
MethodInvocation invocation) {
766-
if (getBinaryName(methodDeclaringType).equals(invocation.getExpression().resolveTypeBinding().getBinaryName()))
767-
// FIXME: This matching needs much work #153.
768-
if (method.getName().toString().equals(invocation.resolveMethodBinding().getName()))
769-
return true;
766+
String declaringTypeBinaryName = getBinaryName(methodDeclaringType);
767+
768+
if (declaringTypeBinaryName != null) {
769+
Expression expression = invocation.getExpression();
770+
771+
if (expression != null) {
772+
ITypeBinding typeBinding = expression.resolveTypeBinding();
773+
774+
if (typeBinding != null) {
775+
String expressionBinaryName = typeBinding.getBinaryName();
776+
777+
if (declaringTypeBinaryName.equals(expressionBinaryName))
778+
// FIXME: This matching needs much work #153.
779+
if (method.getName().toString().equals(invocation.resolveMethodBinding().getName()))
780+
return true;
781+
} else
782+
LOGGER.warning("typeBinding is null for expression: " + expression);
783+
} else
784+
LOGGER.warning("expression is null for invocation: " + invocation);
785+
} else
786+
LOGGER.warning("Binary name is null for method declarying type: " + methodDeclaringType);
770787
return false;
771788
}
772789

0 commit comments

Comments
 (0)