@@ -35,19 +35,18 @@ public static void main(String[] args) throws Throwable {
35
35
final var aggregator = new AggregateSnippets (snippetsSrcRoot );
36
36
aggregator .computeContents ();
37
37
aggregator .saveContentsToFile (repoRoot .resolve ("SNIPPETS.md" ));
38
- aggregator .saveLineNumbersToCsv (repoRoot .resolve ("snippets_line_numbers.csv" ));
39
38
}
40
39
41
40
42
- public record CodeSnippetFile (
41
+ public record CodeSnippetFileInfo (
43
42
Path file ,
44
43
int mainStartIndex , int mainEndIndex ,
45
44
int clientStartIndex , int clientEndIndex
46
45
) { }
47
46
48
47
private StringBuilder sb ;
49
48
private final Path snippetsSrcRoot ;
50
- private Collection <CodeSnippetFile > snippetFiles ;
49
+ private Collection <CodeSnippetFileInfo > snippetFiles ;
51
50
52
51
public AggregateSnippets (Path snippetsSrcRoot ) {
53
52
this .snippetsSrcRoot = Objects .requireNonNull (snippetsSrcRoot );
@@ -59,7 +58,7 @@ private void checkComputed() {
59
58
}
60
59
}
61
60
62
- public Collection <CodeSnippetFile > getLineNumbers () {
61
+ public Collection <CodeSnippetFileInfo > getLineNumbers () {
63
62
checkComputed ();
64
63
return snippetFiles ;
65
64
}
@@ -77,13 +76,13 @@ public void saveLineNumbersToCsv(Path destPath) throws IOException {
77
76
checkComputed ();
78
77
try (var writer = Files .newBufferedWriter (destPath , StandardOpenOption .CREATE )) {
79
78
writer .write ("File,MainStart,MainEnd,ClientStart,ClientEnd\n " );
80
- for (var file : snippetFiles ) {
79
+ for (var metadata : snippetFiles ) {
81
80
writer .write (
82
- file .file .getFileName () + "," +
83
- file .mainStartIndex + "," +
84
- file .mainEndIndex + "," +
85
- file .clientStartIndex + "," +
86
- file .clientEndIndex + "\n "
81
+ metadata .file .getFileName () + "," +
82
+ metadata .mainStartIndex + "," +
83
+ metadata .mainEndIndex + "," +
84
+ metadata .clientStartIndex + "," +
85
+ metadata .clientEndIndex + "\n "
87
86
);
88
87
}
89
88
}
@@ -163,7 +162,7 @@ else if (level > 2 && path.getName().endsWith(".java")) {
163
162
sb .append ("\n ```java\n " ).append (nugget ).append ("\n ```\n " );
164
163
165
164
boolean standalone = clientInitEndIndex < 12 ;
166
- snippetFiles .add (new CodeSnippetFile (path .toPath (),
165
+ snippetFiles .add (new CodeSnippetFileInfo (path .toPath (),
167
166
lineNumberFromIndex (fileContent , startIndex ) + 1 ,
168
167
lineNumberFromIndex (fileContent , endIndex ),
169
168
standalone ? -1 : lineNumberFromIndex (fileContent , clientInitStartIndex ) + 1 ,
0 commit comments