Skip to content

Commit

Permalink
Merge pull request #131 from theia-ide/jk/gh118_3
Browse files Browse the repository at this point in the history
GH-118 also consider XpathNameTest elements
  • Loading branch information
JanKoehnlein committed May 31, 2018
2 parents 83c4d08 + 1f7b404 commit 456e6dd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
}
}
}
Expand All @@ -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";
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions yang-lsp/io.typefox.yang/src/test/resources/xpath-serialize.yang
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
}
}
}

0 comments on commit 456e6dd

Please sign in to comment.