Skip to content

Commit 0fe5b98

Browse files
committed
Also include StreamSupport type in workaround for #80.
1 parent 7f9e14f commit 0fe5b98

File tree

1 file changed

+24
-6
lines changed
  • edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/safe

1 file changed

+24
-6
lines changed

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919

2020
public class Util {
2121

22+
/**
23+
* {@link Atom} corresponding the the stream() method.
24+
*/
25+
private static final Atom STREAM_METHOD_NAME_ATOM = Atom.findOrCreateAsciiAtom("stream");
26+
27+
/**
28+
* The {@link TypeName} of the type {@link java.util.Arrays}.
29+
*/
30+
private static final TypeName ARRAYS_TYPE_NAME = TypeName.string2TypeName("Ljava/util/Arrays");
31+
32+
/**
33+
* The {@link TypeName} for the type {@link java.util.stream.StreamSupport}.
34+
*/
35+
private static final TypeName STREAM_SUPPORT_TYPE_NAME = TypeName
36+
.string2TypeName("Ljava/util/stream/StreamSupport");
37+
2238
private Util() {
2339
}
2440

@@ -75,19 +91,21 @@ public static boolean instanceKeyCorrespondsWithInstantiationInstruction(Instanc
7591
else if (callSiteReference.getProgramCounter() == instructionCallSite.getProgramCounter()) {
7692
// compare declared targets.
7793
MethodReference callSiteDeclaredTarget = callSiteReference.getDeclaredTarget();
94+
TypeName callSiteTargetDeclaringClassName = callSiteDeclaredTarget.getDeclaringClass().getName();
95+
7896
MethodReference instructionCallDeclaredTarget = instructionCallSite.getDeclaredTarget();
97+
TypeName instructionTargetDeclaringClassName = instructionCallDeclaredTarget.getDeclaringClass()
98+
.getName();
7999

80-
if (callSiteDeclaredTarget.getDeclaringClass().getName()
81-
.equals(instructionCallDeclaredTarget.getDeclaringClass().getName())
82-
&& callSiteDeclaredTarget.getDeclaringClass().getName()
83-
.equals(TypeName.string2TypeName("Ljava/util/Arrays"))
100+
if (callSiteTargetDeclaringClassName.equals(instructionTargetDeclaringClassName)
101+
&& (callSiteTargetDeclaringClassName.equals(ARRAYS_TYPE_NAME)
102+
|| callSiteTargetDeclaringClassName.equals(STREAM_SUPPORT_TYPE_NAME))
84103
&& callSiteDeclaredTarget.getName().equals(instructionCallDeclaredTarget.getName())
85-
&& callSiteDeclaredTarget.getName().equals(Atom.findOrCreateAsciiAtom("stream")))
104+
&& callSiteDeclaredTarget.getName().equals(STREAM_METHOD_NAME_ATOM))
86105
return true;
87106
}
88107
}
89108
}
90109
return false;
91110
}
92-
93111
}

0 commit comments

Comments
 (0)