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

feat(format/yaml): Rebase onto latest upstream snakeyaml #441

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions vendor/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*]
indent_size = 2
34 changes: 33 additions & 1 deletion vendor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ project(":snakeyaml") {

spotless {
java {
targetExclude 'src/main/java9/**' // upstream doesn't format this for some reason
eclipse()
.configFile('../snakeyaml-upstream/src/etc/eclipse-java-google-style.xml')
}
Expand All @@ -72,6 +73,9 @@ project(":snakeyaml") {
tasks.withType(ProcessResources).configureEach {
dependsOn ':applyPatches'
}
spotlessJava {
dependsOn ':applyPatches'
}

tasks.named("test", Test) {
environment(
Expand All @@ -83,4 +87,32 @@ project(":snakeyaml") {
excludeTest("org.yaml.snakeyaml.issues.issue318.ContextClassLoaderTest", null)
}
}
}

// Set up multi-release jar
sourceSets {
java9 { SourceSet set ->
set.compileClasspath += main.compileClasspath
set.runtimeClasspath += main.runtimeClasspath
set.java.setSrcDirs(['src/main/java9'])
}
}

dependencies {
java9Implementation sourceSets.main.output
}

jar {
from(sourceSets.java9.output) {
into 'META-INF/versions/9/'
exclude 'module-info.class' // not used for our purposes
}
manifest {
attributes 'Multi-Release': 'true'
}
}

compileJava9Java {
options.release = 9
options.compilerArgs += "--patch-module=org.yaml.snakeyaml=${sourceSets.main.output.classesDirs.asPath}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ Subject: [PATCH] scanner: Initial implementation of tab acceptance


diff --git a/src/main/java/org/yaml/snakeyaml/LoaderOptions.java b/src/main/java/org/yaml/snakeyaml/LoaderOptions.java
index 432730bee858cfaa9e638b87272265826d6270a6..03bcf0d12e35768cee5cc6e179d7150cc5857dee 100644
index 12038cbbab7d0263739b8738a309412157be71c5..772c8819aab4b39d702d89d0508dc79d2126c13f 100644
--- a/src/main/java/org/yaml/snakeyaml/LoaderOptions.java
+++ b/src/main/java/org/yaml/snakeyaml/LoaderOptions.java
@@ -28,6 +28,7 @@ public class LoaderOptions {
// https://en.wikipedia.org/wiki/Billion_laughs_attack
private boolean allowRecursiveKeys = false;
@@ -32,6 +32,8 @@ public class LoaderOptions {

private boolean processComments = false;

+ private boolean acceptTabs = false;
+
private boolean enumCaseSensitive = true;

private int nestingDepthLimit = 50;
private int codePointLimit = 3 * 1024 * 1024; // 3 MB
@@ -148,6 +149,30 @@ public class LoaderOptions {
return processComments;
@@ -149,6 +151,30 @@ public class LoaderOptions {
return this;
}

+ /**
Expand Down Expand Up @@ -48,27 +49,25 @@ index 432730bee858cfaa9e638b87272265826d6270a6..03bcf0d12e35768cee5cc6e179d7150c
* getter
*
diff --git a/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java b/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
index c9ae314ce57c268e169b99b77d050ac02a143ce2..373e4c1845b0f739b2f805612887b8d84d057700 100644
index ca2343c2d223abee59c219aa58629efd46429fdf..e566816b2cf7719a14c601f2551aa7f6f0c13cd6 100644
--- a/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
+++ b/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
@@ -216,6 +216,8 @@ public final class ScannerImpl implements Scanner {
@@ -216,11 +216,14 @@ public final class ScannerImpl implements Scanner {
*/
private final Map<Integer, SimpleKey> possibleSimpleKeys;

+ private final boolean acceptTabs;
+
/**
* Create
*
@@ -232,6 +234,7 @@ public final class ScannerImpl implements Scanner {
public ScannerImpl(StreamReader reader, LoaderOptions options) {
if (options == null) {
throw new NullPointerException("LoaderOptions must be provided.");
}
this.parseComments = options.isProcessComments();
+ this.acceptTabs = options.isAcceptTabs();
this.reader = reader;
this.tokens = new ArrayList<Token>(100);
this.indents = new ArrayStack<Integer>(10);
@@ -1241,7 +1244,7 @@ public final class ScannerImpl implements Scanner {
@@ -1213,7 +1216,7 @@ public final class ScannerImpl implements Scanner {
int ff = 0;
// Peek ahead until we find the first non-space character, then
// move forward directly to that character.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sequences. It might be nice to capture the prettiness status of input
data, but that seems extremely error-prone and probably not worth doing.

diff --git a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
index 155e1f5775c20ae7efb6aa7f8a39c35480231452..81a0a14835931a6b0f201d102b5e9b66d9888bb5 100644
index 7ba1cd72dfe51ca80131b05d38fdba8e7f37e60c..1cdf6658139bb08939a830ce1dbf1d762d0f8fda 100644
--- a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
+++ b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
@@ -161,7 +161,14 @@ public final class Emitter implements Emitable {
Expand Down Expand Up @@ -104,7 +104,7 @@ index 155e1f5775c20ae7efb6aa7f8a39c35480231452..81a0a14835931a6b0f201d102b5e9b66
inlineCommentsCollector.collectEvents();
writeInlineComments();
state = states.pop();
@@ -1532,6 +1565,10 @@ public final class Emitter implements Emitable {
@@ -1545,6 +1578,10 @@ public final class Emitter implements Emitable {
if (!blockCommentsCollector.isEmpty()) {
writeIndent();
writeCommentLines(blockCommentsCollector.consume());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ first element of the sequence. I don't think there's anything we can
do about that though.... needs more thought i suppose

diff --git a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
index 81a0a14835931a6b0f201d102b5e9b66d9888bb5..c30d3fb69004d63e752d6207f2df376d079da172 100644
index 1cdf6658139bb08939a830ce1dbf1d762d0f8fda..b2f9e9486fd43570b831cf2409e1321aeedcb38b 100644
--- a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
+++ b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
@@ -753,6 +753,9 @@ public final class Emitter implements Emitable {
Expand Down
2 changes: 1 addition & 1 deletion vendor/snakeyaml-upstream
Submodule snakeyaml-upstream updated from fc1701 to a4df9e