Skip to content

Commit 59c62ee

Browse files
committed
Add environmental variable to control use of implicit entrypoints.
1 parent 5040e73 commit 59c62ee

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,35 +130,43 @@ public static void setLoggingLevel(int level) {
130130

131131
private Set<Stream> streamSet;
132132

133+
private boolean useImplicitEntrypoints = true;
134+
133135
public ConvertToParallelStreamRefactoringProcessor() throws JavaModelException {
134-
this(null, null, false, Optional.empty());
136+
this(null, null, false, true, Optional.empty());
135137
}
136138

137139
public ConvertToParallelStreamRefactoringProcessor(IJavaProject[] javaProjects,
138-
final CodeGenerationSettings settings, boolean layer, Optional<IProgressMonitor> monitor)
139-
throws JavaModelException {
140+
final CodeGenerationSettings settings, boolean layer, boolean useImplicitEntrypoints,
141+
Optional<IProgressMonitor> monitor) throws JavaModelException {
140142
try {
141143
this.javaProjects = javaProjects;
142144
this.settings = settings;
143145
this.layer = layer;
144-
146+
this.useImplicitEntrypoints = useImplicitEntrypoints;
145147
} finally {
146148
monitor.ifPresent(IProgressMonitor::done);
147149
}
148150
}
149151

150152
public ConvertToParallelStreamRefactoringProcessor(final CodeGenerationSettings settings,
151153
Optional<IProgressMonitor> monitor) throws JavaModelException {
152-
this(null, settings, false, monitor);
154+
this(null, settings, false, true, monitor);
153155
}
154156

155157
public ConvertToParallelStreamRefactoringProcessor(IJavaProject[] javaProjects,
156158
final CodeGenerationSettings settings, Optional<IProgressMonitor> monitor) throws JavaModelException {
157-
this(javaProjects, settings, false, monitor);
159+
this(javaProjects, settings, false, true, monitor);
160+
}
161+
162+
public ConvertToParallelStreamRefactoringProcessor(IJavaProject[] javaProjects,
163+
final CodeGenerationSettings settings, boolean useImplicitJoinpoints, Optional<IProgressMonitor> monitor)
164+
throws JavaModelException {
165+
this(javaProjects, settings, false, useImplicitJoinpoints, monitor);
158166
}
159167

160168
public ConvertToParallelStreamRefactoringProcessor(Optional<IProgressMonitor> monitor) throws JavaModelException {
161-
this(null, null, false, monitor);
169+
this(null, null, false, true, monitor);
162170
}
163171

164172
private RefactoringStatus checkExistence(IMember member, PreconditionFailure failure) {
@@ -175,7 +183,7 @@ public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, fi
175183
SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.CheckingPreconditions,
176184
this.getJavaProjects().length * 1000);
177185
final RefactoringStatus status = new RefactoringStatus();
178-
StreamAnalyzer analyzer = new StreamAnalyzer();
186+
StreamAnalyzer analyzer = new StreamAnalyzer(false, this.getUseImplicitEntrypoints());
179187
setStreamSet(analyzer.getStreamSet());
180188

181189
for (IJavaProject jproj : this.getJavaProjects()) {
@@ -194,7 +202,7 @@ public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, fi
194202
}
195203
}
196204
}
197-
205+
198206
analyzer.analyze();
199207

200208
RefactoringStatus collectedStatus = getStreamSet().stream().map(Stream::getStatus)
@@ -224,6 +232,10 @@ public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, fi
224232
}
225233
}
226234

235+
private boolean getUseImplicitEntrypoints() {
236+
return this.useImplicitEntrypoints;
237+
}
238+
227239
@Override
228240
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
229241
throws CoreException, OperationCanceledException {

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,17 @@ public static ProcessorBasedRefactoring createRefactoring(IJavaProject[] project
4646
public static ConvertToParallelStreamRefactoringProcessor createConvertToParallelStreamRefactoringProcessor(
4747
IJavaProject[] projects, Optional<IProgressMonitor> monitor) throws JavaModelException {
4848
CodeGenerationSettings settings = JavaPreferencesSettings.getCodeGenerationSettings(projects[0]);
49-
ConvertToParallelStreamRefactoringProcessor processor = new ConvertToParallelStreamRefactoringProcessor(projects,
50-
settings, monitor);
49+
ConvertToParallelStreamRefactoringProcessor processor = new ConvertToParallelStreamRefactoringProcessor(
50+
projects, settings, monitor);
51+
return processor;
52+
}
53+
54+
public static ConvertToParallelStreamRefactoringProcessor createConvertToParallelStreamRefactoringProcessor(
55+
IJavaProject[] projects, boolean useImplicitJoinpoints, Optional<IProgressMonitor> monitor)
56+
throws JavaModelException {
57+
CodeGenerationSettings settings = JavaPreferencesSettings.getCodeGenerationSettings(projects[0]);
58+
ConvertToParallelStreamRefactoringProcessor processor = new ConvertToParallelStreamRefactoringProcessor(
59+
projects, settings, useImplicitJoinpoints, monitor);
5160
return processor;
5261
}
5362

@@ -133,7 +142,7 @@ public static ASTNode stripParenthesizedExpressions(ASTNode node) {
133142
} else
134143
return node;
135144
}
136-
145+
137146
public static String getMethodIdentifier(IMethod method) throws JavaModelException {
138147
StringBuilder sb = new StringBuilder();
139148
sb.append((method.getElementName()) + "(");

edu.cuny.hunter.streamrefactoring.eval/src/edu/cuny/hunter/streamrefactoring/eval/handlers/EvaluateConvertToParallelStreamRefactoringHandler.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public class EvaluateConvertToParallelStreamRefactoringHandler extends AbstractH
7676
private static final int LOGGING_LEVEL = IStatus.INFO;
7777
private static final boolean PERFORM_CHANGE_DEFAULT = false;
7878
private static final String PERFORM_CHANGE_PROPERTY_KEY = "edu.cuny.hunter.streamrefactoring.eval.performChange";
79+
private static final boolean FIND_IMPLICIT_ENTRYPOINTS_DEFAULT = true;
80+
private static final String FIND_IMPLICIT_ENTRYPOINTS_PROPERTY_KEY = "edu.cuny.hunter.streamrefactoring.eval.findImplicitEntrypoints";
7981

8082
private static String[] buildAttributeColumns(String attribute) {
8183
return new String[] { "subject", "stream", "start pos", "length", "method", "type FQN", attribute };
@@ -229,7 +231,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
229231

230232
resultsTimeCollector.start();
231233
processor = createConvertToParallelStreamRefactoringProcessor(new IJavaProject[] { javaProject },
232-
Optional.of(monitor));
234+
this.shouldFindImplicitEntrypoints(), Optional.of(monitor));
233235
resultsTimeCollector.stop();
234236
ConvertToParallelStreamRefactoringProcessor.setLoggingLevel(LOGGING_LEVEL);
235237

@@ -453,4 +455,13 @@ private boolean shouldPerformChange() {
453455
else
454456
return Boolean.valueOf(performChangePropertyValue);
455457
}
458+
459+
private boolean shouldFindImplicitEntrypoints() {
460+
String findImplicitEntrypoits = System.getenv(FIND_IMPLICIT_ENTRYPOINTS_PROPERTY_KEY);
461+
462+
if (findImplicitEntrypoits == null)
463+
return FIND_IMPLICIT_ENTRYPOINTS_DEFAULT;
464+
else
465+
return Boolean.valueOf(findImplicitEntrypoits);
466+
}
456467
}

0 commit comments

Comments
 (0)