Skip to content

Commit

Permalink
Prevent new header from being deleted
Browse files Browse the repository at this point in the history
Now any previous file header is deleted before the new one is included
  • Loading branch information
alfonsodelavega committed Aug 1, 2023
1 parent a621c3c commit 23dd4d7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions sjpp/src/main/java/sjpp/JavaFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ public class JavaFile {
public JavaFile(Context context, Path path) throws IOException {
this.path = path;
this.context = context;

lines = new ArrayList<>();
if (context.getHeader() != null) {
lines.addAll(context.getHeader().getLines());
}
lines.addAll(Files.readAllLines(path));
this.lines = Files.readAllLines(path);

for (String s : lines) {
if (s.startsWith("package ")) {
Expand Down Expand Up @@ -67,6 +62,10 @@ public void process() {
if (context.getMode() == ContextMode.REGULAR)
removeFirstHeader();

if (context.getHeader() != null) {
lines.addAll(0, context.getHeader().getLines());
}

ProcessMode mode = ProcessMode.NORMAL;

for (ListIterator<String> it = lines.listIterator(); it.hasNext();) {
Expand Down

0 comments on commit 23dd4d7

Please sign in to comment.