From 8f727d5d3f825f5988bea5a73b0b6a861b73d7fc Mon Sep 17 00:00:00 2001 From: angelozerr Date: Mon, 18 Sep 2017 18:40:23 +0200 Subject: [PATCH 1/2] Add EditorConfig for Eclipse (ec4e) Signed-off-by: angelozerr --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eede71489..793dee8d5 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Here are some projects that use tm4e: * [Eclipse aCute](https://github.com/eclipse/aCute) C# edition in Eclipse IDE. * [LiClipseText](http://www.liclipse.com/text/) enables Eclipse to be used as a general-purpose text editor, providing support for several languages out of the box. * [typescript.java](https://github.com/angelozerr/typescript.java) TypeScript IDE for Eclipse with JSDT & tsserver. + * [EditorConfig for Eclipse](https://github.com/angelozerr/ec4e) EditorConfig for Eclipse with GenericEditor. ## Get support and contribute From bcd0b1e242fbb14c63731b0973f8e855f18cd804 Mon Sep 17 00:00:00 2001 From: angelozerr Date: Tue, 19 Sep 2017 00:14:22 +0200 Subject: [PATCH 2/2] Use StandardCharsets.UTF_8 constants. --- .../eclipse/tm4e/core/internal/oniguruma/OnigRegExp.java | 9 ++------- .../eclipse/tm4e/core/internal/oniguruma/OnigString.java | 6 ++---- .../tm4e/core/internal/parser/json/JSONPListParser.java | 3 ++- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigRegExp.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigRegExp.java index 15664c64e..a527d214b 100644 --- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigRegExp.java +++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigRegExp.java @@ -18,7 +18,7 @@ package org.eclipse.tm4e.core.internal.oniguruma; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import org.jcodings.specific.UTF8Encoding; import org.joni.Matcher; @@ -44,12 +44,7 @@ public OnigRegExp(String source) { lastSearchStrUniqueId = null; lastSearchPosition = -1; lastSearchResult = null; - byte[] pattern; - try { - pattern = source.getBytes("utf-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } + byte[] pattern = source.getBytes(StandardCharsets.UTF_8); this.regex = new Regex(pattern, 0, pattern.length, Option.CAPTURE_GROUP, UTF8Encoding.INSTANCE, Syntax.DEFAULT, WarnCallback.DEFAULT); } diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigString.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigString.java index 448566144..233a8df53 100644 --- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigString.java +++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigString.java @@ -17,7 +17,7 @@ package org.eclipse.tm4e.core.internal.oniguruma; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * Oniguruma string. @@ -27,15 +27,13 @@ */ public class OnigString { - private static final String UTF_8 = "UTF-8"; - private final String str; private byte[] value; private Object uniqueId; public OnigString(String str) { this.str = str; - this.value = str.getBytes(Charset.forName(UTF_8)); + this.value = str.getBytes(StandardCharsets.UTF_8); this.uniqueId = new Object(); } diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/parser/json/JSONPListParser.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/parser/json/JSONPListParser.java index fa079df66..4878d65c4 100644 --- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/parser/json/JSONPListParser.java +++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/parser/json/JSONPListParser.java @@ -13,6 +13,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import org.eclipse.tm4e.core.internal.parser.PList; @@ -29,7 +30,7 @@ public JSONPListParser(boolean theme) { public T parse(InputStream contents) throws Exception { PList pList = new PList(theme); - JsonReader reader = new JsonReader(new InputStreamReader(contents, Charset.forName("UTF-8"))); + JsonReader reader = new JsonReader(new InputStreamReader(contents, StandardCharsets.UTF_8)); // reader.setLenient(true); boolean parsing = true; while (parsing) {