Skip to content

Commit ee5ecbc

Browse files
committed
Look for eval properties recursively.
1 parent c467768 commit ee5ecbc

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ private static CSVPrinter createCSVPrinter(String fileName, String[] header) thr
112112
return new CSVPrinter(new FileWriter(fileName, true), CSVFormat.EXCEL.withHeader(header));
113113
}
114114

115+
private static File findEvaluationPropertiesFile(File directory) {
116+
if (directory == null)
117+
return null;
118+
119+
if (!directory.isDirectory())
120+
throw new IllegalArgumentException("Expecting directory: " + directory + ".");
121+
122+
File evaluationFile = directory.toPath().resolve(EVALUATION_PROPERTIES_FILE_NAME).toFile();
123+
124+
if (evaluationFile != null && evaluationFile.exists())
125+
return evaluationFile;
126+
else
127+
return findEvaluationPropertiesFile(directory.getParentFile());
128+
}
129+
130+
private static File findEvaluationPropertiesFile(IJavaProject project) throws JavaModelException {
131+
IPath location = project.getCorrespondingResource().getLocation();
132+
return findEvaluationPropertiesFile(location.toFile());
133+
}
134+
115135
private static IType[] getAllDeclaringTypeSubtypes(IMethod method) throws JavaModelException {
116136
IType declaringType = method.getDeclaringType();
117137
ITypeHierarchy typeHierarchy = declaringType.newTypeHierarchy(new NullProgressMonitor());
@@ -150,10 +170,9 @@ private static int getMethodLinesOfCode(IMethod method) {
150170

151171
private static int getNForStreams(IJavaProject project) throws IOException, JavaModelException {
152172
Properties properties = new Properties();
153-
IPath filePath = project.getCorrespondingResource().getLocation().append(EVALUATION_PROPERTIES_FILE_NAME);
154-
File file = filePath.toFile();
173+
File file = findEvaluationPropertiesFile(project);
155174

156-
if (file.exists())
175+
if (file != null && file.exists())
157176
try (Reader reader = new FileReader(file)) {
158177
properties.load(reader);
159178

0 commit comments

Comments
 (0)