Add multiline comments more sensibly...
This commit is contained in:
@@ -120,27 +120,17 @@ public class OmegaConfig {
|
|||||||
// Find areas we should insert comments into...
|
// Find areas we should insert comments into...
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
String at = lines.get(i);
|
String at = lines.get(i);
|
||||||
|
String startingWhitespace = getStartingWhitespace(at);
|
||||||
|
|
||||||
// Check if we should insert comment
|
|
||||||
for (Map.Entry<String, String> entry : keyToComments.entrySet()) {
|
for (Map.Entry<String, String> entry : keyToComments.entrySet()) {
|
||||||
String comment = entry.getValue();
|
String comment = entry.getValue();
|
||||||
|
// Check if we should insert comment
|
||||||
if (at.trim().startsWith(String.format("\"%s\"", entry.getKey()))) {
|
if (at.trim().startsWith(String.format("\"%s\"", entry.getKey()))) {
|
||||||
if (comment.contains("\n")) {
|
if (comment.contains("\n")) {
|
||||||
String[] comments = comment.split("\n");
|
comment = startingWhitespace + "//" + String.join(String.format("\n%s//", startingWhitespace), comment.split("\n"));
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
for (int j = 0; j < comments.length; j++) {
|
|
||||||
builder.append(String.format("%s//%s", getStartingWhitespace(at), comments[j]));
|
|
||||||
if (j != comments.length - 1) {
|
|
||||||
builder.append("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
comment = builder.toString();
|
|
||||||
} else {
|
} else {
|
||||||
comment = String.format("%s//%s", getStartingWhitespace(at), comment);
|
comment = String.format("%s//%s", startingWhitespace, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
insertions.put(i + insertions.size(), comment);
|
insertions.put(i + insertions.size(), comment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user