Somewhat better handling of escaped '[...]' keys in yaml
This commit is contained in:
@@ -76,7 +76,7 @@ public class YamlStructureParser {
|
||||
* Pattern that matches a line starting with a 'simple key'
|
||||
*/
|
||||
public static final Pattern SIMPLE_KEY_LINE = Pattern.compile(
|
||||
"^(\\w(\\.|\\w|-)*):( .*|$)");
|
||||
"^((\\w(\\.|\\w|-)*)|(\\'(\\.|\\w|-|\\[|\\])*\\')):( .*|$)");
|
||||
//TODO: the parrern above is too selective (e.g. in real yaml one can have
|
||||
//spaces in simple keys and lots of other characters that this pattern does not
|
||||
//allow. For now it is good enough because we are only interested in spring property
|
||||
|
||||
@@ -33,6 +33,39 @@ import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser
|
||||
|
||||
public class YamlStructureParserTest {
|
||||
|
||||
@Test public void escapedStringKey() throws Exception {
|
||||
MockYamlEditor editor;
|
||||
|
||||
editor = new MockYamlEditor(
|
||||
"my:\n" +
|
||||
" map:\n"+
|
||||
" foobar:\n" +
|
||||
" name: jeff"
|
||||
);
|
||||
assertParseOneDoc(editor,
|
||||
"DOC(0): ",
|
||||
" KEY(0): my:",
|
||||
" KEY(2): map:",
|
||||
" KEY(4): foobar:",
|
||||
" KEY(6): name: jeff"
|
||||
);
|
||||
|
||||
editor = new MockYamlEditor(
|
||||
"my:\n" +
|
||||
" map:\n"+
|
||||
" '[foo.bar]':\n" +
|
||||
" name: jeff"
|
||||
);
|
||||
assertParseOneDoc(editor,
|
||||
"DOC(0): ",
|
||||
" KEY(0): my:",
|
||||
" KEY(2): map:",
|
||||
" KEY(4): '[foo.bar]':",
|
||||
" KEY(6): name: jeff"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test public void ignoreLeadingYamlCruftBeforeLeadingDocumentSeparator() throws Exception {
|
||||
String[] stuffToIgnore = {
|
||||
"#comment",
|
||||
|
||||
Reference in New Issue
Block a user