Skip to content

Commit a83e860

Browse files
committed
Internalize transformation.
1 parent 58ad4b0 commit a83e860

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,21 +772,38 @@ public String toString() {
772772
return builder.toString();
773773
}
774774

775-
public void convertToParallel(CompilationUnitRewrite rewrite) {
775+
protected void convertToParallel(CompilationUnitRewrite rewrite) {
776776
LOGGER.info("Converting to parallel.");
777777
MethodInvocation creation = this.getCreation();
778778
ASTRewrite astRewrite = rewrite.getASTRewrite();
779779
SimpleName newMethodName = creation.getAST().newSimpleName("parallelStream");
780780
astRewrite.replace(creation.getName(), newMethodName, null);
781781
}
782782

783-
public void convertToSequential(CompilationUnitRewrite rewrite) {
783+
protected void convertToSequential(CompilationUnitRewrite rewrite) {
784784
// TODO Auto-generated method stub
785785
LOGGER.info("Converting to sequential.");
786786
}
787787

788-
public void unorder(CompilationUnitRewrite rewrite) {
788+
protected void unorder(CompilationUnitRewrite rewrite) {
789789
// TODO Auto-generated method stub
790790
LOGGER.info("Unordering.");
791791
}
792+
793+
public void transform(CompilationUnitRewrite rewrite) {
794+
// for each stream transformation.
795+
for (TransformationAction action : getActions()) {
796+
switch (action) {
797+
case CONVERT_TO_PARALLEL:
798+
convertToParallel(rewrite);
799+
break;
800+
case CONVERT_TO_SEQUENTIAL:
801+
convertToSequential(rewrite);
802+
break;
803+
case UNORDER:
804+
unorder(rewrite);
805+
break;
806+
}
807+
}
808+
}
792809
}

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/refactorings/OptimizeStreamsRefactoringProcessor.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import edu.cuny.hunter.streamrefactoring.core.analysis.PreconditionFailure;
5858
import edu.cuny.hunter.streamrefactoring.core.analysis.Stream;
5959
import edu.cuny.hunter.streamrefactoring.core.analysis.StreamAnalyzer;
60-
import edu.cuny.hunter.streamrefactoring.core.analysis.TransformationAction;
6160
import edu.cuny.hunter.streamrefactoring.core.descriptors.OptimizeStreamRefactoringDescriptor;
6261
import edu.cuny.hunter.streamrefactoring.core.messages.Messages;
6362
import edu.cuny.hunter.streamrefactoring.core.utils.TimeCollector;
@@ -349,21 +348,7 @@ public Change createChange(IProgressMonitor pm) throws CoreException, OperationC
349348
for (Stream stream : optimizableStreams) {
350349
CompilationUnitRewrite rewrite = getCompilationUnitRewrite(stream.getEnclosingEclipseMethod().getCompilationUnit(),
351350
stream.getEnclosingCompilationUnit());
352-
353-
// for each stream transformation.
354-
for (TransformationAction action : stream.getActions()) {
355-
switch (action) {
356-
case CONVERT_TO_PARALLEL:
357-
stream.convertToParallel(rewrite);
358-
break;
359-
case CONVERT_TO_SEQUENTIAL:
360-
stream.convertToSequential(rewrite);
361-
break;
362-
case UNORDER:
363-
stream.unorder(rewrite);
364-
break;
365-
}
366-
}
351+
stream.transform(rewrite);
367352
pm.worked(1);
368353
}
369354

0 commit comments

Comments
 (0)