Skip to content

Commit ce4d107

Browse files
committed
Extract entry point method.
1 parent e7c3e5d commit ce4d107

File tree

1 file changed

+12
-12
lines changed
  • edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,29 +176,29 @@ public static Set<Entrypoint> findBenchmarkEntryPoints(IClassHierarchy classHier
176176
TypeName annotationName = annotation.getType().getName();
177177

178178
if (isBenchmark(annotationName) || isSetup(annotationName)) {
179-
result.add(new DefaultEntrypoint(method, classHierarchy));
179+
addEntryPoint(result, method, classHierarchy);
180180
isBenchmarkClass = true;
181181
break;
182182
}
183183
}
184184
}
185-
if (isBenchmarkClass) {
186-
IMethod classInitializer = klass.getClassInitializer();
187-
188-
if (classInitializer != null)
189-
result.add(new DefaultEntrypoint(classInitializer, classHierarchy));
190-
191-
IMethod ctor = klass.getMethod(MethodReference.initSelector);
192-
193-
if (ctor != null)
194-
result.add(new DefaultEntrypoint(ctor, classHierarchy));
195185

186+
if (isBenchmarkClass) {
187+
addEntryPoint(result, klass.getClassInitializer(), classHierarchy);
188+
addEntryPoint(result, klass.getMethod(MethodReference.initSelector), classHierarchy);
196189
}
197190
}
198191

199192
return result;
200193
}
201194

195+
private static void addEntryPoint(Set<Entrypoint> result, final IMethod method, IClassHierarchy classHierarchy) {
196+
if (method != null) {
197+
Entrypoint entrypoint = new DefaultEntrypoint(method, classHierarchy);
198+
result.add(entrypoint);
199+
}
200+
}
201+
202202
private static MethodInvocation findCorrespondingMethodInvocation(CompilationUnit unit,
203203
SourcePosition sourcePosition, MethodReference method) {
204204
CorrespondingASTVisitor visitor = new CorrespondingASTVisitor(unit, sourcePosition, method);
@@ -225,7 +225,7 @@ public static Set<Entrypoint> findEntryPoints(IClassHierarchy classHierarchy) {
225225
try {
226226
for (Annotation annotation : ((ShrikeCTMethod) method).getAnnotations(true))
227227
if (isEntryPointClass(annotation.getType().getName())) {
228-
result.add(new DefaultEntrypoint(method, classHierarchy));
228+
addEntryPoint(result, method, classHierarchy);
229229
break;
230230
}
231231
} catch (InvalidClassFileException e) {

0 commit comments

Comments
 (0)