From 65f8e162f81d04ca3aff7dd321c6e9698256cbb9 Mon Sep 17 00:00:00 2001 From: lingenj Date: Mon, 18 Nov 2024 10:30:54 +0100 Subject: [PATCH] Add more logging --- .../main/java/org/openrewrite/yaml/MergeYaml.java | 2 ++ .../org/openrewrite/yaml/MergeYamlVisitor.java | 14 ++++++++------ .../java/org/openrewrite/yaml/YamlVisitor.java | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYaml.java b/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYaml.java index 0e52c7737d5..168127c9e63 100644 --- a/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYaml.java +++ b/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYaml.java @@ -116,6 +116,8 @@ public Yaml.Document visitDocument(Yaml.Document document, ExecutionContext ctx) ); if (getCursor().getMessage("RemovePrefix", false)) { + System.out.println("|||| after visit document"); + System.out.println(System.identityHashCode(getCursor())); return d.withEnd(d.getEnd().withPrefix("")); } diff --git a/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYamlVisitor.java b/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYamlVisitor.java index b26b10ad218..9dc1d28ba60 100644 --- a/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYamlVisitor.java +++ b/rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYamlVisitor.java @@ -100,12 +100,13 @@ public Yaml visitSequence(Yaml.Sequence existingSeq, P p) { @Override public Yaml visitMapping(Yaml.Mapping existingMapping, P p) { - System.out.println("<<< visitMapping"); + //System.out.println("<<< visitMapping"); if (getCursor().toString().equals("Cursor{Mapping->Document->Documents->root}")) { - System.out.println("ja!!"); + System.out.println(System.identityHashCode(getCursor())); + System.out.println(getCursor()); + System.out.println((boolean) (getCursor().getMessage("RemovePrefix", false))); } - System.out.println(getCursor()); - System.out.println((boolean) (getCursor().getMessage("RemovePrefix", false))); + if (existing.isScope(existingMapping) && incoming instanceof Yaml.Mapping) { return mergeMapping(existingMapping, (Yaml.Mapping) incoming, p, getCursor()); } @@ -217,9 +218,10 @@ private Yaml.Mapping mergeMapping(Yaml.Mapping m1, Yaml.Mapping m2, P p, Cursor // int index2 = ((Yaml.Mapping) currCursor.getValue()).getEntries().size() -1; - System.out.println(">>>"); - System.out.println(c); + System.out.println(">>> RemovePrefix"); + System.out.println(System.identityHashCode(c)); c.putMessage("RemovePrefix", true); + System.out.println(c); } } diff --git a/rewrite-yaml/src/main/java/org/openrewrite/yaml/YamlVisitor.java b/rewrite-yaml/src/main/java/org/openrewrite/yaml/YamlVisitor.java index 63b5ecb5069..7434e66a542 100755 --- a/rewrite-yaml/src/main/java/org/openrewrite/yaml/YamlVisitor.java +++ b/rewrite-yaml/src/main/java/org/openrewrite/yaml/YamlVisitor.java @@ -66,11 +66,13 @@ public Y2 autoFormat(Y2 y, @Nullable Yaml stopAfter, P p, Curs } public Yaml visitDocuments(Yaml.Documents documents, P p) { + System.out.println("visitDocumentSSSSSS"); return documents.withDocuments(ListUtils.map(documents.getDocuments(), d -> visitAndCast(d, p))) .withMarkers(visitMarkers(documents.getMarkers(), p)); } public Yaml visitDocument(Yaml.Document document, P p) { + System.out.println("visitDocument"); return document.withBlock((Yaml.Block) visit(document.getBlock(), p)) .withMarkers(visitMarkers(document.getMarkers(), p)); }