diff --git a/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/formatting2/YangFormatter.xtend b/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/formatting2/YangFormatter.xtend index cf29b5dc..4659eeac 100644 --- a/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/formatting2/YangFormatter.xtend +++ b/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/formatting2/YangFormatter.xtend @@ -97,6 +97,7 @@ import org.eclipse.xtext.preferences.MapBasedPreferenceValues import static io.typefox.yang.formatting2.MultilineStringReplacer.Line.PartType.* import static extension com.google.common.base.Strings.* +import io.typefox.yang.yang.XpathNameTest class YangFormatter extends AbstractFormatter2 { @@ -544,7 +545,7 @@ class YangFormatter extends AbstractFormatter2 { nodeRegions.head.prepend[oneSpace] nodeRegions .tail - .filter[grammarElement == HIDDENRule && semanticElement instanceof XpathLocation] + .filter[grammarElement == HIDDENRule && (semanticElement instanceof XpathLocation || semanticElement instanceof XpathNameTest)] .forEach[prepend[noSpace]] val nextSemanticRegion = nodeRegions.last.nextSemanticRegion if (HIDDENRule == nextSemanticRegion.grammarElement) { diff --git a/yang-lsp/io.typefox.yang/src/test/java/io/typefox/yang/tests/serializer/ModuleSerializeTest.xtend b/yang-lsp/io.typefox.yang/src/test/java/io/typefox/yang/tests/serializer/ModuleSerializeTest.xtend index 55bb20dc..fd1cb965 100644 --- a/yang-lsp/io.typefox.yang/src/test/java/io/typefox/yang/tests/serializer/ModuleSerializeTest.xtend +++ b/yang-lsp/io.typefox.yang/src/test/java/io/typefox/yang/tests/serializer/ModuleSerializeTest.xtend @@ -80,6 +80,16 @@ class ModuleSerializeTest { path "/ytest:c1" + "/ytest:l1"; } } + leaf lfb3 { + type leafref { + path "/ytest:c1/" + "ytest:l1"; + } + } + leaf lfb4 { + type leafref { + path "/ytest:" + "c1/ytest" + ":l1"; + } + } } } } @@ -105,6 +115,16 @@ class ModuleSerializeTest { path "/ytest:c1" + "/ytest:l1"; } } + leaf lfb3 { + type leafref { + path "/ytest:c1/" + "ytest:l1"; + } + } + leaf lfb4 { + type leafref { + path "/ytest:" + "c1/ytest" + ":l1"; + } + } } } } diff --git a/yang-lsp/io.typefox.yang/src/test/resources/xpath-serialize.yang b/yang-lsp/io.typefox.yang/src/test/resources/xpath-serialize.yang index 8a2d1222..4e79e3c6 100644 --- a/yang-lsp/io.typefox.yang/src/test/resources/xpath-serialize.yang +++ b/yang-lsp/io.typefox.yang/src/test/resources/xpath-serialize.yang @@ -17,6 +17,16 @@ module xpath-serialize { path "/ytest:c1" + "/ytest:l1"; } } + leaf lfb3 { + type leafref { + path "/ytest:c1/" + "ytest:l1"; + } + } + leaf lfb4 { + type leafref { + path "/ytest:" + "c1/ytest" + ":l1"; + } + } } } } \ No newline at end of file