Skip to content

Commit

Permalink
yaml: Eclipse integration work
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Dec 19, 2021
1 parent cd37b65 commit 9d43596
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ buildSrc/build/
# gitpatcher local data
/vendor/snakeyaml/

# gitpatcher local data
/vendor/snakeyaml/

# IntelliJ project data
.idea
*.iml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,60 +23,61 @@ import org.yaml.snakeyaml.parser.ParserImpl
import org.yaml.snakeyaml.reader.StreamReader
import org.yaml.snakeyaml.scanner.ScannerImpl

import java.nio.charset.StandardCharsets
trait YamlTest {

interface YamlTest {

default CommentedConfigurationNode parseString(final String input) {
CommentedConfigurationNode parseString(final String input) {
// Print events
def scanner = new ScannerImpl(new StreamReader(input))
scanner.emitComments = true
scanner.parseComments = true
scanner.acceptTabs = true
def parser = new ParserImpl(scanner)
do {

while (true) {
println parser.getEvent()
} while (parser.peekEvent())
if (!parser.peekEvent()) break
}

final YamlParserComposer loader = new YamlParserComposer(new StreamReader(input), Yaml11Tags.REPOSITORY, true)
final CommentedConfigurationNode result = CommentedConfigurationNode.root()
loader.singleDocumentStream(result)
return result
}

default CommentedConfigurationNode parseResource(final URL url) {
CommentedConfigurationNode parseResource(final URL url) {
// Print events
url.openStream().withReader('UTF-8') {reader ->
def scanner = new ScannerImpl(new StreamReader(reader))
scanner.emitComments = true
scanner.parseComments = true
scanner.acceptTabs = true
def parser = new ParserImpl(scanner)
do {
while (true) {
println parser.getEvent()
} while (parser.peekEvent())
if (!parser.peekEvent()) break
}
}

assertNotNull(url, "Expected resource is missing")
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
url.openStream().withReader('UTF-8') { reader ->
final YamlParserComposer loader = new YamlParserComposer(new StreamReader(reader), Yaml11Tags.REPOSITORY, true)
final CommentedConfigurationNode result = CommentedConfigurationNode.root()
loader.singleDocumentStream(result)
return result
}
}

default String dump(final CommentedConfigurationNode input) {
String dump(final CommentedConfigurationNode input) {
return dump(input, null)
}

default String dump(final CommentedConfigurationNode input, final NodeStyle preferredStyle) {
String dump(final CommentedConfigurationNode input, final NodeStyle preferredStyle) {
return YamlConfigurationLoader.builder()
.nodeStyle(preferredStyle)
.indent(2)
.commentsEnabled(true)
.buildAndSaveString(input)
}

default String normalize(final String input) {
String normalize(final String input) {
return input.stripIndent(true)
}

Expand Down
4 changes: 2 additions & 2 deletions vendor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ project(":snakeyaml") {
val applyPatches = rootProject.tasks.named("applyPatches")
tasks.withType(JavaCompile::class) {
options.release.set(7)
dependsOn(applyPatches)
// dependsOn(applyPatches)
}
tasks.withType(ProcessResources::class) {
dependsOn(applyPatches)
// dependsOn(applyPatches)
}

tasks.named("test", Test::class) {
Expand Down

0 comments on commit 9d43596

Please sign in to comment.