Skip to content

Commit cf18708

Browse files
add #Entrypoints in csv file
1 parent 59c62ee commit cf18708

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ private static void addImplicitEntryPoints(Collection<Entrypoint> target, Iterab
5353
private boolean findImplicitTestEntryPoints;
5454

5555
private Set<Stream> streamSet = new HashSet<>();
56+
57+
private Set<Entrypoint> entryPoints = new HashSet<>();
5658

5759
public StreamAnalyzer() {
5860
this(false);
@@ -194,6 +196,8 @@ protected void buildCallGraph(EclipseProjectAnalysisEngine<InstanceKey> engine)
194196
// TODO: Can I slice the graph so that only nodes relevant to the
195197
// instance in question are present?
196198
this.enginesWithBuiltCallGraphs.add(engine);
199+
200+
setEntryPoints(entryPoints);
197201
}
198202
}
199203

@@ -248,4 +252,13 @@ public boolean visit(MethodInvocation node) {
248252

249253
return super.visit(node);
250254
}
255+
256+
protected void setEntryPoints(Set<Entrypoint> entryPoints) {
257+
this.entryPoints = entryPoints;
258+
}
259+
260+
public Set<Entrypoint> getEntryPoints() {
261+
return this.entryPoints;
262+
}
263+
251264
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.text.MessageFormat;
77
import java.util.HashMap;
8+
import java.util.HashSet;
89
import java.util.Map;
910
import java.util.Optional;
1011
import java.util.Set;
@@ -49,6 +50,8 @@
4950
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
5051
import org.osgi.framework.FrameworkUtil;
5152

53+
import com.ibm.wala.ipa.callgraph.Entrypoint;
54+
5255
import edu.cuny.hunter.streamrefactoring.core.analysis.PreconditionFailure;
5356
import edu.cuny.hunter.streamrefactoring.core.analysis.Stream;
5457
import edu.cuny.hunter.streamrefactoring.core.analysis.StreamAnalyzer;
@@ -129,6 +132,8 @@ public static void setLoggingLevel(int level) {
129132
private IJavaProject[] javaProjects;
130133

131134
private Set<Stream> streamSet;
135+
136+
private Set<Entrypoint> entryPoints = new HashSet<>();
132137

133138
private boolean useImplicitEntrypoints = true;
134139

@@ -208,6 +213,9 @@ public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, fi
208213
RefactoringStatus collectedStatus = getStreamSet().stream().map(Stream::getStatus)
209214
.collect(() -> new RefactoringStatus(), (a, b) -> a.merge(b), (a, b) -> a.merge(b));
210215
status.merge(collectedStatus);
216+
217+
// set entry points
218+
setEntryPoints(analyzer.getEntryPoints());
211219

212220
// if there are no fatal errors.
213221
if (!status.hasFatalError()) {
@@ -232,6 +240,14 @@ public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, fi
232240
}
233241
}
234242

243+
private void setEntryPoints(Set<Entrypoint> entryPoints) {
244+
this.entryPoints = entryPoints;
245+
}
246+
247+
public Set<Entrypoint> getEntryPoints() {
248+
return this.entryPoints;
249+
}
250+
235251
private boolean getUseImplicitEntrypoints() {
236252
return this.useImplicitEntrypoints;
237253
}

edu.cuny.hunter.streamrefactoring.eval/META-INF/MANIFEST.MF

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Export-Package: edu.cuny.hunter.streamrefactoring.eval.handlers,
2222
edu.cuny.hunter.streamrefactoring.eval.utils,
2323
edu.cuny.hunter.streamrefactoring.ui.plugins
2424
Import-Package: com.google.common.io,
25+
com.ibm.wala.classLoader,
26+
com.ibm.wala.ipa.callgraph,
2527
edu.cuny.hunter.streamrefactoring.core.analysis,
2628
edu.cuny.hunter.streamrefactoring.core.refactorings,
2729
edu.cuny.hunter.streamrefactoring.core.utils,

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
import com.google.common.collect.Sets;
5353
import com.google.common.collect.Sets.SetView;
54+
import com.ibm.wala.ipa.callgraph.Entrypoint;
5455

5556
import edu.cuny.hunter.streamrefactoring.core.analysis.PreconditionFailure;
5657
import edu.cuny.hunter.streamrefactoring.core.analysis.PreconditionSuccess;
@@ -162,6 +163,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
162163
CSVPrinter streamActionsPrinter = null;
163164
CSVPrinter streamExecutionModePrinter = null;
164165
CSVPrinter streamOrderingPrinter = null;
166+
CSVPrinter entryPointsPrinter = null;
165167

166168
ConvertToParallelStreamRefactoringProcessor processor = null;
167169

@@ -175,8 +177,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
175177

176178
IJavaProject[] javaProjects = Util.getSelectedJavaProjectsFromEvent(event);
177179

178-
List<String> resultsHeader = new ArrayList<>(Arrays.asList("subject", "SLOC", "#streams",
179-
"#optimization available streams", "#optimizable streams", "#failed preconditions"));
180+
List<String> resultsHeader = new ArrayList<>(
181+
Arrays.asList("subject", "SLOC", "#entrypoints", "#streams", "#optimization available streams",
182+
"#optimizable streams", "#failed preconditions"));
180183

181184
for (Refactoring refactoring : Refactoring.values())
182185
resultsHeader.add(refactoring.toString());
@@ -216,6 +219,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
216219

217220
streamOrderingPrinter = createCSVPrinter("stream_orderings.csv", buildAttributeColumns("ordering"));
218221

222+
entryPointsPrinter = createCSVPrinter("entry_points.csv",
223+
new String[] { "subject", "method", "type FQN" });
224+
219225
for (IJavaProject javaProject : javaProjects) {
220226
if (!javaProject.isStructureKnown())
221227
throw new IllegalStateException(
@@ -240,6 +246,15 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
240246
RefactoringStatus status = new ProcessorBasedRefactoring(processor)
241247
.checkAllConditions(new NullProgressMonitor());
242248
resultsTimeCollector.stop();
249+
250+
// print entry points
251+
Set<Entrypoint> entryPoints = processor.getEntryPoints();
252+
resultsPrinter.print(entryPoints.size());
253+
254+
for (Entrypoint entryPoint : entryPoints) {
255+
entryPointsPrinter.printRecord(javaProject.getElementName(),
256+
entryPoint.getMethod().getSignature(), "! not implement now");
257+
}
243258

244259
// #streams.
245260
resultsPrinter.print(processor.getStreamSet().size());
@@ -414,6 +429,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
414429
streamExecutionModePrinter.close();
415430
if (streamOrderingPrinter != null)
416431
streamOrderingPrinter.close();
432+
if (entryPointsPrinter != null)
433+
entryPointsPrinter.close();
417434

418435
// clear cache.
419436
if (processor != null)

0 commit comments

Comments
 (0)