diff --git a/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentEntry.java b/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentEntry.java new file mode 100644 index 0000000..3ebf63f --- /dev/null +++ b/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentEntry.java @@ -0,0 +1,34 @@ +package de.jcup.hijson.document; + +public class CommentEntry { + + private String comment; + + private int line; + private int column; + + public int getLine() { + return line; + } + + public void setLine(int line) { + this.line = line; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setComment(String comment) { + this.comment=comment; + } + + public String getComment() { + return comment; + } + +} diff --git a/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentHistory.java b/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentHistory.java new file mode 100644 index 0000000..2d2e8d7 --- /dev/null +++ b/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentHistory.java @@ -0,0 +1,18 @@ +package de.jcup.hijson.document; + +import java.util.ArrayList; +import java.util.List; + +public class CommentHistory { + + + List list = new ArrayList<>(); + + public void addComment(int line, int column, String comment) { + CommentEntry entry = new CommentEntry(); + entry.setComment(comment); + entry.setLine(line); + entry.setColumn(column); + } + +} diff --git a/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentHistorySupport.java b/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentHistorySupport.java new file mode 100644 index 0000000..38bd173 --- /dev/null +++ b/highspeed-json-editor-plugin/src/main/java/de/jcup/hijson/document/CommentHistorySupport.java @@ -0,0 +1,37 @@ +package de.jcup.hijson.document; + +public class CommentHistorySupport { + + private SimpleJsonFormatter simpleFormatter = new SimpleJsonFormatter(); + + public CommentHistory ceateCommentHistory(String json) { + CommentHistory history = new CommentHistory(); + /* FIXME de-jcup , 2023: handle comments hwich are in own line special: must be removed for line handling + * means simple formatter must have two ways of formatting... first the new line comments are contained, + * afterwards remove those as well to get the target line numbers... */ + String jsonWithoutEmptyNewLines= simpleFormatter.formatJson(json); + String[] lines = jsonWithoutEmptyNewLines.split("\n"); + + for (int lineNumber=0;lineNumber