Skip to content

Commit 775540b

Browse files
committed
Progress.
1 parent d679e3b commit 775540b

File tree

5 files changed

+173
-117
lines changed

5 files changed

+173
-117
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/messages/messages.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Name=Optimize Streams
22
CategoryName=Stream Changes
33
CategoryDescription=Optimizes Java 8 streams
44
StreamsNotSpecified=No streams to refactor.
5-
CheckingPreconditions=Checking preconditions...
5+
CheckingPreconditions=Checking preconditions (may take a while)...
66
CompilingSource=Compiling source ...
7-
CreatingChange=Creating change...
7+
CreatingChange=Creating change...
8+
NoStreamsHavePassedThePreconditions=No streams have passed preconditions.

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,6 @@ public Set<Stream> getStreamSet() {
466466
return this.streamSet;
467467
}
468468

469-
private ITypeHierarchy getTypeHierarchy(IType type, Optional<IProgressMonitor> monitor) throws JavaModelException {
470-
try {
471-
ITypeHierarchy ret = this.getTypeToTypeHierarchyMap().get(type);
472-
473-
if (ret == null) {
474-
ret = type.newTypeHierarchy(monitor.orElseGet(NullProgressMonitor::new));
475-
this.getTypeToTypeHierarchyMap().put(type, ret);
476-
}
477-
478-
return ret;
479-
} finally {
480-
monitor.ifPresent(IProgressMonitor::done);
481-
}
482-
}
483-
484469
protected Map<ITypeRoot, CompilationUnit> getTypeRootToCompilationUnitMap() {
485470
return this.typeRootToCompilationUnitMap;
486471
}
@@ -493,19 +478,35 @@ public Set<Stream> getUnoptimizableStreams() {
493478
return this.getStreamSet().parallelStream().filter(s -> s.getStatus().hasError()).collect(Collectors.toSet());
494479
}
495480

496-
private boolean getUseImplicitBenchmarkEntrypoints() {
481+
public boolean getUseImplicitBenchmarkEntrypoints() {
497482
return this.useImplicitBenchmarkEntrypoints;
498483
}
499484

500-
private boolean getUseImplicitEntrypoints() {
485+
public boolean getUseImplicitEntrypoints() {
501486
return this.useImplicitEntrypoints;
502487
}
503488

504-
private boolean getUseImplicitJavaFXEntrypoints() {
489+
public void setUseImplicitBenchmarkEntrypoints(boolean useImplicitBenchmarkEntrypoints) {
490+
this.useImplicitBenchmarkEntrypoints = useImplicitBenchmarkEntrypoints;
491+
}
492+
493+
public void setUseImplicitEntrypoints(boolean useImplicitEntrypoints) {
494+
this.useImplicitEntrypoints = useImplicitEntrypoints;
495+
}
496+
497+
public void setUseImplicitJavaFXEntrypoints(boolean useImplicitJavaFXEntrypoints) {
498+
this.useImplicitJavaFXEntrypoints = useImplicitJavaFXEntrypoints;
499+
}
500+
501+
public void setUseImplicitTestEntrypoints(boolean useImplicitTestEntrypoints) {
502+
this.useImplicitTestEntrypoints = useImplicitTestEntrypoints;
503+
}
504+
505+
public boolean getUseImplicitJavaFXEntrypoints() {
505506
return this.useImplicitJavaFXEntrypoints;
506507
}
507508

508-
private boolean getUseImplicitTestEntrypoints() {
509+
public boolean getUseImplicitTestEntrypoints() {
509510
return this.useImplicitTestEntrypoints;
510511
}
511512

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/utils/RefactoringAvailabilityTester.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.eclipse.jdt.internal.corext.refactoring.Checks;
1616
import org.eclipse.jdt.internal.corext.util.JdtFlags;
1717

18-
import edu.cuny.hunter.streamrefactoring.core.refactorings.ConvertToParallelStreamRefactoringProcessor;
18+
import edu.cuny.hunter.streamrefactoring.core.refactorings.OptimizeStreamsRefactoringProcessor;
1919

2020
/**
2121
* @author <a href="mailto:[email protected]">Raffi
@@ -64,7 +64,7 @@ private RefactoringAvailabilityTester() {
6464
// }
6565
//
6666
// // ensure that there is a target method.
67-
// IMethod targetMethod = ConvertToParallelStreamRefactoringProcessor.getTargetMethod(method,
67+
// IMethod targetMethod = OptimizeStreamsRefactoringProcessor.getTargetMethod(method,
6868
// monitor);
6969
// if (targetMethod == null) // no possible target.
7070
// return false;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package edu.cuny.hunter.streamrefactoring.ui.handlers;
22

3-
import java.util.Formatter;
43
import java.util.HashSet;
54
import java.util.List;
65
import java.util.Optional;
@@ -10,24 +9,15 @@
109
import org.eclipse.core.commands.ExecutionEvent;
1110
import org.eclipse.core.commands.ExecutionException;
1211
import org.eclipse.core.runtime.IProgressMonitor;
13-
import org.eclipse.core.runtime.IStatus;
14-
import org.eclipse.core.runtime.Status;
15-
import org.eclipse.jdt.core.ICompilationUnit;
1612
import org.eclipse.jdt.core.IJavaElement;
1713
import org.eclipse.jdt.core.IJavaProject;
18-
import org.eclipse.jdt.core.IMethod;
19-
import org.eclipse.jdt.core.IPackageFragment;
20-
import org.eclipse.jdt.core.IPackageFragmentRoot;
21-
import org.eclipse.jdt.core.IType;
2214
import org.eclipse.jdt.core.JavaModelException;
2315
import org.eclipse.jdt.internal.ui.JavaPlugin;
2416
import org.eclipse.jdt.internal.ui.util.SelectionUtil;
25-
import org.eclipse.jdt.ui.JavaElementLabels;
2617
import org.eclipse.jface.dialogs.MessageDialog;
2718
import org.eclipse.jface.viewers.ISelection;
2819
import org.eclipse.swt.widgets.Shell;
2920
import org.eclipse.ui.handlers.HandlerUtil;
30-
import org.osgi.framework.FrameworkUtil;
3121

3222
import edu.cuny.hunter.streamrefactoring.ui.messages.Messages;
3323
import edu.cuny.hunter.streamrefactoring.ui.wizards.OptimizeStreamRefactoringWizard;
@@ -70,85 +60,4 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
7060
}
7161
return null;
7262
}
73-
74-
private Set<IMethod> extractMethodsFromClass(IType type, Optional<IProgressMonitor> monitor)
75-
throws JavaModelException {
76-
Set<IMethod> methodSet = new HashSet<>();
77-
78-
if (type.isClass())
79-
for (IMethod method : type.getMethods())
80-
// if (RefactoringAvailabilityTester.isInterfaceMigrationAvailable(method,
81-
// monitor)) {
82-
if (true) {
83-
this.logPossiblyMigratableMethod(method);
84-
methodSet.add(method);
85-
} else
86-
this.logNonMigratableMethod(method);
87-
88-
return methodSet;
89-
}
90-
91-
private Set<IMethod> extractMethodsFromCompilationUnit(ICompilationUnit cu, Optional<IProgressMonitor> monitor)
92-
throws JavaModelException {
93-
Set<IMethod> methodSet = new HashSet<>();
94-
IType[] types = cu.getTypes();
95-
96-
for (IType iType : types)
97-
methodSet.addAll(this.extractMethodsFromClass(iType, monitor));
98-
99-
return methodSet;
100-
}
101-
102-
private Set<IMethod> extractMethodsFromJavaProject(IJavaProject jProj, Optional<IProgressMonitor> monitor)
103-
throws JavaModelException {
104-
Set<IMethod> methodSet = new HashSet<>();
105-
106-
IPackageFragmentRoot[] roots = jProj.getPackageFragmentRoots();
107-
for (IPackageFragmentRoot iPackageFragmentRoot : roots)
108-
methodSet.addAll(this.extractMethodsFromPackageFragmentRoot(iPackageFragmentRoot, monitor));
109-
110-
return methodSet;
111-
}
112-
113-
private Set<IMethod> extractMethodsFromPackageFragment(IPackageFragment frag, Optional<IProgressMonitor> monitor)
114-
throws JavaModelException {
115-
Set<IMethod> methodSet = new HashSet<>();
116-
ICompilationUnit[] units = frag.getCompilationUnits();
117-
118-
for (ICompilationUnit iCompilationUnit : units)
119-
methodSet.addAll(this.extractMethodsFromCompilationUnit(iCompilationUnit, monitor));
120-
121-
return methodSet;
122-
}
123-
124-
private Set<IMethod> extractMethodsFromPackageFragmentRoot(IPackageFragmentRoot root,
125-
Optional<IProgressMonitor> monitor) throws JavaModelException {
126-
Set<IMethod> methodSet = new HashSet<>();
127-
128-
IJavaElement[] children = root.getChildren();
129-
for (IJavaElement child : children)
130-
if (child.getElementType() == IJavaElement.PACKAGE_FRAGMENT)
131-
methodSet.addAll(this.extractMethodsFromPackageFragment((IPackageFragment) child, monitor));
132-
133-
return methodSet;
134-
}
135-
136-
private void logMethod(IMethod method, String format) {
137-
Formatter formatter = new Formatter();
138-
139-
formatter.format(format, JavaElementLabels.getElementLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED));
140-
141-
JavaPlugin.log(new Status(IStatus.INFO, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(),
142-
formatter.toString()));
143-
144-
formatter.close();
145-
}
146-
147-
private void logNonMigratableMethod(IMethod method) {
148-
this.logMethod(method, "Method: %s is not migratable.");
149-
}
150-
151-
private void logPossiblyMigratableMethod(IMethod method) {
152-
this.logMethod(method, "Method: %s is possibly migratable.");
153-
}
15463
}

0 commit comments

Comments
 (0)