Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#615 Removed deprecated FoldedFlowLines and FlowOnOneLine #616

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
#615 removed deprecated FoldedFlowLines and FlowOnOneLine
amihaiemil committed Apr 4, 2024
commit 6c3cdc4a0d2c93fae435c1efa90ff35a194f41c6
2 changes: 1 addition & 1 deletion src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
Original file line number Diff line number Diff line change
@@ -174,7 +174,7 @@ private YamlNode mappingSequenceOrPlainScalar(final YamlLine prev) {
} else if (matcher.group(4) != null) {
node = new ReadYamlMapping(prev.number(), prev, this);
}
} else if (this.original().size() == 1) {
} else if (this.lines.size() == 1) {
node = new ReadPlainScalar(this, first);
}
}
116 changes: 0 additions & 116 deletions src/main/java/com/amihaiemil/eoyaml/FlowOnOneLine.java

This file was deleted.

197 changes: 0 additions & 197 deletions src/main/java/com/amihaiemil/eoyaml/FoldedFlowLines.java

This file was deleted.

12 changes: 6 additions & 6 deletions src/main/java/com/amihaiemil/eoyaml/ReadFlowMapping.java
Original file line number Diff line number Diff line change
@@ -43,10 +43,8 @@
* @since 8.0.0
* @todo #601:30min Modify the yaml printing visitor, so it prints the flow
* nodes in Flow style instead of block.
* @todo #607:60min Refactor this class to not use FoldedFlowLines anymore.
* FoldedFlowLines is deprecated and the collapsing/folding logic is now
* implemented with {@link CollapsedFlowLines}. ReadFlowSequence needs the
* same refactoring after that.
* @todo #615:60min Implement the comment() method properly (at the moment
* it always assumes there is no comment).
*/
final class ReadFlowMapping extends BaseYamlMapping {

@@ -72,10 +70,11 @@ final class ReadFlowMapping extends BaseYamlMapping {
* Ctor.
* @param previous Line just before the start of this flow mapping.
* @param lines All lines of the YAML document.
* @checkstyle AvoidInlineConditionals (30 lines)
*/
ReadFlowMapping(final YamlLine previous, final AllYamlLines lines) {
this(
new FoldedFlowLines(
new CollapsedFlowLines(
new Skip(
lines,
line -> line.number() <= previous.number(),
@@ -87,7 +86,7 @@ final class ReadFlowMapping extends BaseYamlMapping {
),
'{',
'}'
).iterator().next()
).line(previous.number() < 0 ? 0 : previous.number() + 1)
);
}

@@ -98,6 +97,7 @@ final class ReadFlowMapping extends BaseYamlMapping {
*/
ReadFlowMapping(final YamlLine folded) {
this.entries = new StringEntries(folded);
System.out.println("FLOW LINE: " + folded.value());
this.folded = folded;
}

5 changes: 3 additions & 2 deletions src/main/java/com/amihaiemil/eoyaml/ReadFlowSequence.java
Original file line number Diff line number Diff line change
@@ -62,10 +62,11 @@ final class ReadFlowSequence extends BaseYamlSequence {
* Ctor.
* @param previous Line just before the start of this flow sequence.
* @param lines All lines of the YAML document.
* @checkstyle AvoidInlineConditionals (30 lines)
*/
ReadFlowSequence(final YamlLine previous, final AllYamlLines lines) {
this(
new FoldedFlowLines(
new CollapsedFlowLines(
new Skip(
lines,
line -> line.number() <= previous.number(),
@@ -77,7 +78,7 @@ final class ReadFlowSequence extends BaseYamlSequence {
),
'[',
']'
).iterator().next()
).line(previous.number() < 0 ? 0 : previous.number() + 1)
);
}

12 changes: 7 additions & 5 deletions src/main/java/com/amihaiemil/eoyaml/YamlLines.java
Original file line number Diff line number Diff line change
@@ -68,19 +68,21 @@ interface YamlLines extends Iterable<YamlLine> {
* @return YamlLine or throws {@link IndexOutOfBoundsException}.
*/
default YamlLine line(final int number) {
final Collection<YamlLine> lines = this.original();
if(number < 0 && lines.size() > 0) {
return lines.iterator().next();
int linesNr = 0;
final Iterator<YamlLine> iterator = this.iterator();
if(number < 0 && iterator.hasNext()) {
return iterator.next();
}
for(final YamlLine line : lines){
for(final YamlLine line : this){
if(line.number() == number) {
return line;
}
linesNr++;
}
throw new IllegalArgumentException(
"Couldn't find line " + number
+ ". Pay attention, there are "
+ this.original().size() + " lines!");
+ linesNr + " lines!");
}

}
156 changes: 0 additions & 156 deletions src/test/java/com/amihaiemil/eoyaml/FlowOnOneLineTestCase.java

This file was deleted.