Fix YAML structure for escaped keys
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|-)*)|(\\'(\\.|\\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
|
||||
|
||||
@@ -65,6 +65,39 @@ public class YamlStructureParserTest {
|
||||
|
||||
}
|
||||
|
||||
@Test public void escapedStringKey_2() 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"+
|
||||
" '[**/]':\n" +
|
||||
" name: jeff"
|
||||
);
|
||||
assertParseOneDoc(editor,
|
||||
"DOC(0): ",
|
||||
" KEY(0): my:",
|
||||
" KEY(2): map:",
|
||||
" KEY(4): '[**/]':",
|
||||
" KEY(6): name: jeff"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test public void ignoreLeadingYamlCruftBeforeLeadingDocumentSeparator() throws Exception {
|
||||
String[] stuffToIgnore = {
|
||||
"#comment",
|
||||
|
||||
@@ -2582,6 +2582,29 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
"monday : String", "tuesday : String", "wednesday : String", "thursday : String", "friday : String", "saturday : String", "sunday : String"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueCompletionsOnEscapedKey() throws Exception {
|
||||
useProject(createPredefinedMavenProject("enums-boot-1.3.2-app"));
|
||||
|
||||
data("foo.demo", "java.util.Map<java.lang.String,demo.Color>", null, "Map of any string to colors");
|
||||
|
||||
assertCompletions(
|
||||
"foo:\n" +
|
||||
" demo:\n" +
|
||||
" '[./**/]': <*>",
|
||||
//=>
|
||||
"foo:\n" +
|
||||
" demo:\n" +
|
||||
" '[./**/]': blue<*>",
|
||||
"foo:\n" +
|
||||
" demo:\n" +
|
||||
" '[./**/]': green<*>",
|
||||
"foo:\n" +
|
||||
" demo:\n" +
|
||||
" '[./**/]': red<*>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEnumMapKeyCompletion() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user