-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathSubmittedSolution.java
More file actions
40 lines (32 loc) · 1.12 KB
/
SubmittedSolution.java
File metadata and controls
40 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package analyzer;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.utils.SourceRoot;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
/**
* This represents a solution submitted by a student.
* It parses all Java files in the source root of the input directory.
*/
class SubmittedSolution implements Solution {
private static final String SOURCE_ROOT_PATH = "src/main/java";
private final String slug;
private final List<CompilationUnit> compilationUnits;
SubmittedSolution(String slug, Path inputDirectory) throws IOException {
this.slug = slug;
this.compilationUnits = new ArrayList<>();
var sourceRoot = new SourceRoot(inputDirectory.resolve(SOURCE_ROOT_PATH));
for (var result : sourceRoot.tryToParse()) {
this.compilationUnits.add(result.getResult().get());
}
}
@Override
public String getSlug() {
return this.slug;
}
@Override
public List<CompilationUnit> getCompilationUnits() {
return List.copyOf(this.compilationUnits);
}
}