From 36b891aa8a13d393dfd82ff2e3ec8f4534dec61f Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Wed, 29 Mar 2017 17:46:46 -0400 Subject: [PATCH 1/2] #40 - tests for accented characters in keys --- .../key-accented-chars-tests.yaml | 41 +++++++++++++++++++ .../key-accented-chars.yaml | 9 ++++ .../yedit/test/scanner/YAMLScannerTest.java | 3 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars-tests.yaml create mode 100644 org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars.yaml diff --git a/org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars-tests.yaml b/org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars-tests.yaml new file mode 100644 index 0000000..2509d27 --- /dev/null +++ b/org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars-tests.yaml @@ -0,0 +1,41 @@ +--- +name: Parsing keys with accented characters +contentFile: key-accented-chars.yaml +rangeLength: -1 +startOffset: 0 +expectedTokens: + + - type: DOCUMENT_START + + # Poèmes + - type: WHITESPACE + - type: KEY + + # Poème1 + - type: WHITESPACE + - type: KEY + + - type: WHITESPACE + - type: KEY + - type: WHITESPACE + - type: SCALAR + + - type: WHITESPACE + - type: KEY + - type: WHITESPACE + - type: SCALAR + + - type: WHITESPACE + - type: KEY + - type: WHITESPACE + - type: SCALAR + + # Prop2 + - type: WHITESPACE + - type: KEY + + - type: WHITESPACE + - type: KEY + - type: WHITESPACE + - type: SCALAR + diff --git a/org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars.yaml b/org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars.yaml new file mode 100644 index 0000000..6bfe47e --- /dev/null +++ b/org.dadacoalition.yedit.test/scanner-test-files/key-accented-chars.yaml @@ -0,0 +1,9 @@ +--- +Poèmes: + Poème1: + MaîtreCorbeau: value + SurUnArbrePerché: value + î: value + Prop2: + grünen: value + diff --git a/org.dadacoalition.yedit.test/src/org/dadacoalition/yedit/test/scanner/YAMLScannerTest.java b/org.dadacoalition.yedit.test/src/org/dadacoalition/yedit/test/scanner/YAMLScannerTest.java index 2786587..d546076 100644 --- a/org.dadacoalition.yedit.test/src/org/dadacoalition/yedit/test/scanner/YAMLScannerTest.java +++ b/org.dadacoalition.yedit.test/src/org/dadacoalition/yedit/test/scanner/YAMLScannerTest.java @@ -66,7 +66,8 @@ public static Collection readTests() { "comment-tests.yaml", "tag-tests.yaml", "scalar-test.yaml", - "key-tests.yaml" + "key-tests.yaml", + "key-accented-chars-tests.yaml" }; Collection testCases = new ArrayList(); From 1546a6c36b5fb45eefa4bc81d60f051d6d0e621a Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Wed, 29 Mar 2017 17:47:09 -0400 Subject: [PATCH 2/2] #40 - allow accented characters in the keys --- .../src/org/dadacoalition/yedit/editor/scanner/KeyRule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.dadacoalition.yedit/src/org/dadacoalition/yedit/editor/scanner/KeyRule.java b/org.dadacoalition.yedit/src/org/dadacoalition/yedit/editor/scanner/KeyRule.java index 34fa330..7acd961 100644 --- a/org.dadacoalition.yedit/src/org/dadacoalition/yedit/editor/scanner/KeyRule.java +++ b/org.dadacoalition.yedit/src/org/dadacoalition/yedit/editor/scanner/KeyRule.java @@ -23,12 +23,12 @@ */ public class KeyRule implements IRule { - private IToken token; + private IToken token; private Pattern keyPattern; public KeyRule( IToken token ){ this.token = token; - keyPattern = Pattern.compile( getKeyRegex(), Pattern.DOTALL | Pattern.COMMENTS ); + keyPattern = Pattern.compile( getKeyRegex(), Pattern.DOTALL | Pattern.COMMENTS | Pattern.UNICODE_CHARACTER_CLASS); } public IToken evaluate(ICharacterScanner scanner) {