Skip to content

Commit 5bf1932

Browse files
authored
Merge pull request #121 from ponder-lab/issue_120
Issue 120
2 parents 7bbb147 + 9cefeaf commit 5bf1932

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,8 @@ protected CGNode getEnclosingMethodNode() throws IOException, CoreException, NoE
640640

641641
if (nodes.isEmpty())
642642
throw new NoEnclosingMethodNodeFoundException(methodReference);
643-
else if (nodes.size() == 1 || nodes.size() > 1 && allFake(nodes, this.getAnalysisEngine().getCallGraph()))
644-
return nodes.iterator().next(); // just return the first.
645643
else
646-
throw new IllegalStateException("Unexpected number of nodes: " + nodes.size());
647-
644+
return nodes.iterator().next(); // just return the first.
648645
}
649646

650647
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public static JDTIdentityMapper getJDTIdentifyMapper(ASTNode node) {
414414
* check whether the annotation is "EntryPoint"
415415
*/
416416
private static boolean isEntryPointClass(TypeName typeName) {
417-
return (AnalysisUtils.walaTypeNameToJavaName(typeName).equals(ENTRYPOINT));
417+
return AnalysisUtils.walaTypeNameToJavaName(typeName).equals(ENTRYPOINT);
418418
}
419419

420420
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package p;
2+
3+
import java.util.stream.DoubleStream;
4+
5+
import edu.cuny.hunter.streamrefactoring.annotations.*;
6+
7+
public class A {
8+
@EntryPoint
9+
void n() {
10+
m();
11+
m();
12+
}
13+
14+
void m() {
15+
DoubleStream.of(1.111).count();
16+
}
17+
}

edu.cuny.hunter.streamrefactoring.tests/test cases/edu/cuny/hunter/streamrefactoring/ui/tests/ConvertStreamToParallelRefactoringTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,13 @@ public void testDoubleStreamOf() throws Exception {
427427

428428
}
429429

430+
public void testMultipleCallsToEnclosingMethod() throws Exception {
431+
helper(new StreamAnalysisExpectedResult("DoubleStream.of(1.111)",
432+
Collections.singleton(ExecutionMode.SEQUENTIAL), Collections.singleton(Ordering.ORDERED), false, false,
433+
false, Collections.singleton(TransformationAction.CONVERT_TO_PARALLEL), PreconditionSuccess.P2,
434+
Refactoring.CONVERT_SEQUENTIAL_STREAM_TO_PARALLEL, RefactoringStatus.OK, Collections.emptySet()));
435+
}
436+
430437
public void testHashSetParallelStream() throws Exception {
431438
helper(new StreamAnalysisExpectedResult("new HashSet<>().parallelStream()",
432439
Collections.singleton(ExecutionMode.PARALLEL), Collections.singleton(Ordering.UNORDERED), false, false,

0 commit comments

Comments
 (0)