Skip to content

Commit

Permalink
Fix reading comment
Browse files Browse the repository at this point in the history
  • Loading branch information
hevav committed Aug 30, 2023
1 parent c1f64d0 commit 1f5cc18
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ public Long readLong(@Nullable Field owner) throws NumberFormatException {

@SuppressFBWarnings("SA_FIELD_SELF_COMPARISON")
private List<Object> readListByMarker(@Nullable Field owner, Type type, char marker) {
if (this.skipComments(owner, marker, false)) {
marker = AbstractReader.NEW_LINE;
}

List<Object> result = new ArrayList<>();
switch (marker) {
case '[': {
Expand Down Expand Up @@ -412,6 +416,9 @@ private List<Object> readListByMarker(@Nullable Field owner, Type type, char mar
result.add(this.readByType0(null, type));
this.unsetTempRestoreNewLine();
nextMarker = this.readRawIgnoreEmptyAndNewLines();
if (this.skipComments(owner, nextMarker, false)) {
nextMarker = this.readRawIgnoreEmptyAndNewLines();
}
}

this.setReuseBuffer();
Expand All @@ -432,6 +439,10 @@ private List<Object> readListByMarker(@Nullable Field owner, Type type, char mar
@SuppressFBWarnings("SA_FIELD_SELF_COMPARISON")
private Map<Object, Object> readMapByMarker(@Nullable Field owner, Type keyType, Type valueType, char marker) {
Map<Object, Object> result = new LinkedHashMap<>();
if (this.skipComments(owner, marker, false)) {
marker = AbstractReader.NEW_LINE;
}

char nextMarker;
if (this.tempRestoreNewLine) {
nextMarker = marker;
Expand All @@ -458,6 +469,9 @@ private Map<Object, Object> readMapByMarker(@Nullable Field owner, Type keyType,
while (nextMarker != '\0' && correctIndent == this.currentIndent) {
this.readMapEntry(owner, keyType, valueType, this.readNodeNameByMarker(null, nextMarker), result);
nextMarker = this.readRawIgnoreEmptyAndNewLines();
if (this.skipComments(owner, nextMarker, false)) {
nextMarker = this.readRawIgnoreEmptyAndNewLines();
}
}

this.setReuseBuffer();
Expand Down Expand Up @@ -666,6 +680,10 @@ public void skipList(@Nullable Field owner) {

@SuppressFBWarnings("SA_FIELD_SELF_COMPARISON")
private void skipListByMarker(@Nullable Field owner, char marker) {
if (this.skipComments(owner, marker, false)) {
marker = AbstractReader.NEW_LINE;
}

switch (marker) {
case '[': {
char nextMarker = this.readRawIgnoreEmptyAndNewLines();
Expand All @@ -692,6 +710,9 @@ private void skipListByMarker(@Nullable Field owner, char marker) {
this.skipGuessingType(owner);
this.unsetTempRestoreNewLine();
nextMarker = this.readRawIgnoreEmptyAndNewLines();
if (this.skipComments(owner, nextMarker, false)) {
nextMarker = this.readRawIgnoreEmptyAndNewLines();
}
}

this.setReuseBuffer();
Expand Down Expand Up @@ -720,6 +741,10 @@ public void skipMap(@Nullable Field owner) {

@SuppressFBWarnings("SA_FIELD_SELF_COMPARISON")
private void skipMapByMarker(@Nullable Field owner, char marker) {
if (this.skipComments(owner, marker, false)) {
marker = AbstractReader.NEW_LINE;
}

char nextMarker = this.readRawIgnoreEmptyAndNewLines();
switch (marker) {
case '{' -> {
Expand All @@ -735,6 +760,9 @@ private void skipMapByMarker(@Nullable Field owner, char marker) {
this.skipStringFromMarker(owner, nextMarker, true);
this.skipGuessingType(owner);
nextMarker = this.readRawIgnoreEmptyAndNewLines();
if (this.skipComments(owner, nextMarker, false)) {
nextMarker = this.readRawIgnoreEmptyAndNewLines();
}
}

this.setReuseBuffer();
Expand Down

0 comments on commit 1f5cc18

Please sign in to comment.