From 19c5c0c48e4c16bd7c82ca09007e96597b62ab56 Mon Sep 17 00:00:00 2001 From: mmews Date: Fri, 15 Dec 2023 11:49:07 +0100 Subject: [PATCH] migrate files and remove xtend nature from n4js.common.unicode --- ...Module.xtend => UnicodeRuntimeModule.java} | 6 +- ...etup.xtend => UnicodeStandaloneSetup.java} | 10 +- .../generator/UnicodeGrammarGenerator.java | 179 ++++++++++++++++++ .../generator/UnicodeGrammarGenerator.xtend | 174 ----------------- plugins/org.eclipse.n4js.dts/pom.xml | 6 +- 5 files changed, 188 insertions(+), 187 deletions(-) rename plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/{UnicodeRuntimeModule.xtend => UnicodeRuntimeModule.java} (79%) rename plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/{UnicodeStandaloneSetup.xtend => UnicodeStandaloneSetup.java} (76%) create mode 100644 plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.java delete mode 100644 plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.xtend diff --git a/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeRuntimeModule.xtend b/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeRuntimeModule.java similarity index 79% rename from plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeRuntimeModule.xtend rename to plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeRuntimeModule.java index f244e94392..9f7264bea1 100644 --- a/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeRuntimeModule.xtend +++ b/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeRuntimeModule.java @@ -8,11 +8,11 @@ * Contributors: * NumberFour AG - Initial API and implementation */ -package org.eclipse.n4js.common.unicode - +package org.eclipse.n4js.common.unicode; /** * Use this class to register components to be used at runtime / without the Equinox extension registry. */ -class UnicodeRuntimeModule extends AbstractUnicodeRuntimeModule { +public class UnicodeRuntimeModule extends AbstractUnicodeRuntimeModule { + // empty } diff --git a/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeStandaloneSetup.xtend b/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeStandaloneSetup.java similarity index 76% rename from plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeStandaloneSetup.xtend rename to plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeStandaloneSetup.java index 5438dc513d..461932a613 100644 --- a/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeStandaloneSetup.xtend +++ b/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/UnicodeStandaloneSetup.java @@ -8,15 +8,15 @@ * Contributors: * NumberFour AG - Initial API and implementation */ -package org.eclipse.n4js.common.unicode - +package org.eclipse.n4js.common.unicode; /** * Initialization support for running Xtext languages without Equinox extension registry. */ -class UnicodeStandaloneSetup extends UnicodeStandaloneSetupGenerated { +public class UnicodeStandaloneSetup extends UnicodeStandaloneSetupGenerated { - def static void doSetup() { - new UnicodeStandaloneSetup().createInjectorAndDoEMFRegistration() + /***/ + static public void doSetup() { + new UnicodeStandaloneSetup().createInjectorAndDoEMFRegistration(); } } diff --git a/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.java b/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.java new file mode 100644 index 0000000000..69d5c253df --- /dev/null +++ b/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.java @@ -0,0 +1,179 @@ +/** + * Copyright (c) 2016 NumberFour AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * NumberFour AG - Initial API and implementation + */ +package org.eclipse.n4js.common.unicode.generator; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.function.Function; + +import com.google.common.base.Charsets; +import com.google.common.base.Strings; +import com.google.common.io.Files; + +/***/ +public class UnicodeGrammarGenerator { + + /** + * This generator isn't called by the GenerateUnicode.mwe2, this have to be done manually + */ + @SuppressWarnings("unused") + static void main(String[] args) throws IOException { + // if (args.head == '-file') + new UnicodeGrammarGenerator(); + // else + // println(generateUnicodeRules) + } + + /** + * The write-on-instantiation allows to use this generator in mwe2 as #bean + */ + UnicodeGrammarGenerator() throws IOException { + Files.asCharSink(new File("grammar-gen/org/eclipse/n4js/common/unicode/Unicode.xtext"), Charsets.UTF_8) + .write(generateUnicodeRules()); + } + + static String generateUnicodeRules() { + return """ + /** + * Copyright (c) 2016 NumberFour AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * NumberFour AG - Initial API and implementation + */ + + // Important note: + // This grammar is auto generated by the + // org.eclipse.n4js.common.unicode.generator.UnicodeGrammarGenerator + // + // Rather than editing this manually, update the generator instead! + + grammar org.eclipse.n4js.common.unicode.Unicode + + import "http://www.eclipse.org/emf/2002/Ecore" as ecore + + terminal fragment HEX_DIGIT: + (DECIMAL_DIGIT_FRAGMENT|'a'..'f'|'A'..'F') + ; + terminal fragment DECIMAL_INTEGER_LITERAL_FRAGMENT: + '0' + | '1'..'9' DECIMAL_DIGIT_FRAGMENT* + ; + terminal fragment DECIMAL_DIGIT_FRAGMENT: + '0'..'9' + ; + terminal fragment ZWJ: + '\u200D' + ; + terminal fragment ZWNJ: + '\u200C' + ; + terminal fragment BOM: + '\uFEFF' + ; + terminal fragment WHITESPACE_FRAGMENT: + '\u0009' | '\u000B' | '\u000C' | '\u0020' | '\u00A0' | BOM | UNICODE_SPACE_SEPARATOR_FRAGMENT + ; + terminal fragment LINE_TERMINATOR_FRAGMENT: + '\u000A' | '\u000D' | '\u2028' | '\u2029' + ; + terminal fragment LINE_TERMINATOR_SEQUENCE_FRAGMENT: + '\u000A' | '\u000D' '\u000A'? | '\u2028' | '\u2029' + ; + terminal fragment SL_COMMENT_FRAGMENT: + '//' (!LINE_TERMINATOR_FRAGMENT)* + ; + terminal fragment ML_COMMENT_FRAGMENT: + '/*' -> '*/' + ; + + terminal fragment UNICODE_COMBINING_MARK_FRAGMENT: + // any character in the Unicode categories + // ―Non-spacing mark (Mn) + // ―Combining spacing mark (Mc) + «generateUnicodeRules [ isCombiningMark ]» + ; + terminal fragment UNICODE_DIGIT_FRAGMENT: + // any character in the Unicode categories + // ―Decimal number (Nd) + «generateUnicodeRules [ isDigit ]» + ; + terminal fragment UNICODE_CONNECTOR_PUNCTUATION_FRAGMENT: + // any character in the Unicode categories + // ―Connector punctuation (Pc) + «generateUnicodeRules [ isConnectorPunctuation ]» + ; + terminal fragment UNICODE_LETTER_FRAGMENT: + // any character in the Unicode categories + // ―Uppercase letter (Lu) + // ―Lowercase letter (Ll) + // ―Titlecase letter (Lt) + // ―Modifier letter (Lm) + // ―Other letter (Lo) + // ―Letter number (Nl) + «generateUnicodeRules [ isLetter ]» + ; + terminal fragment UNICODE_SPACE_SEPARATOR_FRAGMENT: + // any character in the Unicode categories + // ―space separator (Zs) + «generateUnicodeRules [ isSpaceSeparator ]» + ; + terminal fragment ANY_OTHER: + . + ; + """; + } + + static StringWriter generateUnicodeRules(Function guard) { + Character prev = null; + boolean run = false; + boolean first = true; + char c = Character.MIN_VALUE; + StringWriter result = new StringWriter(); + PrintWriter printer = new PrintWriter(result, true); + while (true) { + if (guard.apply((int) c)) { + if (!run) { + prev = c; + run = true; + } + } else { + if (run && prev != null) { + if (!first) { + printer.print("| "); + } else { + printer.print(" "); + first = false; + } + printer.print("'\\u" + Strings.padStart(Integer.toHexString(prev).toUpperCase(), 4, '0') + "'"); + if (prev.charValue() == c - 1) { + printer.println(); + } else { + printer.println( + "..'\\u" + Strings.padStart(Integer.toHexString(c - 1).toUpperCase(), 4, '0') + "'"); + } + prev = null; + run = false; + } + } + c = (char) (c + 1); + if (c == Character.MAX_VALUE) { + return result; + } + } + } + +} diff --git a/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.xtend b/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.xtend deleted file mode 100644 index aaf742462e..0000000000 --- a/plugins/org.eclipse.n4js.common.unicode/src/org/eclipse/n4js/common/unicode/generator/UnicodeGrammarGenerator.xtend +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Copyright (c) 2016 NumberFour AG. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * NumberFour AG - Initial API and implementation - */ -package org.eclipse.n4js.common.unicode.generator - -import com.google.common.base.Charsets -import com.google.common.base.Strings -import com.google.common.io.Files -import java.io.File -import java.io.PrintWriter -import java.io.StringWriter - -import static extension org.eclipse.n4js.common.unicode.CharTypes.* -import java.io.IOException - -class UnicodeGrammarGenerator { - - /** - * This generator isn't called by the GenerateUnicode.mwe2, this have to be done manually - */ - def static void main(String[] args) throws IOException { -// if (args.head == '-file') - new UnicodeGrammarGenerator -// else -// println(generateUnicodeRules) - } - - /** - * The write-on-instantiation allows to use this generator in mwe2 as #bean - */ - new() throws IOException { - Files.asCharSink(new File('grammar-gen/org/eclipse/n4js/common/unicode/Unicode.xtext'), Charsets.UTF_8).write(generateUnicodeRules); - } - - def static generateUnicodeRules() ''' - /** - * Copyright (c) 2016 NumberFour AG. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * NumberFour AG - Initial API and implementation - */ - - // Important note: - // This grammar is auto generated by the - // org.eclipse.n4js.common.unicode.generator.UnicodeGrammarGenerator - // - // Rather than editing this manually, update the generator instead! - - grammar org.eclipse.n4js.common.unicode.Unicode - - import "http://www.eclipse.org/emf/2002/Ecore" as ecore - - terminal fragment HEX_DIGIT: - (DECIMAL_DIGIT_FRAGMENT|'a'..'f'|'A'..'F') - ; - terminal fragment DECIMAL_INTEGER_LITERAL_FRAGMENT: - '0' - | '1'..'9' DECIMAL_DIGIT_FRAGMENT* - ; - terminal fragment DECIMAL_DIGIT_FRAGMENT: - '0'..'9' - ; - terminal fragment ZWJ: - '\u200D' - ; - terminal fragment ZWNJ: - '\u200C' - ; - terminal fragment BOM: - '\uFEFF' - ; - terminal fragment WHITESPACE_FRAGMENT: - '\u0009' | '\u000B' | '\u000C' | '\u0020' | '\u00A0' | BOM | UNICODE_SPACE_SEPARATOR_FRAGMENT - ; - terminal fragment LINE_TERMINATOR_FRAGMENT: - '\u000A' | '\u000D' | '\u2028' | '\u2029' - ; - terminal fragment LINE_TERMINATOR_SEQUENCE_FRAGMENT: - '\u000A' | '\u000D' '\u000A'? | '\u2028' | '\u2029' - ; - terminal fragment SL_COMMENT_FRAGMENT: - '//' (!LINE_TERMINATOR_FRAGMENT)* - ; - terminal fragment ML_COMMENT_FRAGMENT: - '/*' -> '*/' - ; - - terminal fragment UNICODE_COMBINING_MARK_FRAGMENT: - // any character in the Unicode categories - // ―Non-spacing mark (Mn) - // ―Combining spacing mark (Mc) - «generateUnicodeRules [ isCombiningMark ]» - ; - terminal fragment UNICODE_DIGIT_FRAGMENT: - // any character in the Unicode categories - // ―Decimal number (Nd) - «generateUnicodeRules [ isDigit ]» - ; - terminal fragment UNICODE_CONNECTOR_PUNCTUATION_FRAGMENT: - // any character in the Unicode categories - // ―Connector punctuation (Pc) - «generateUnicodeRules [ isConnectorPunctuation ]» - ; - terminal fragment UNICODE_LETTER_FRAGMENT: - // any character in the Unicode categories - // ―Uppercase letter (Lu) - // ―Lowercase letter (Ll) - // ―Titlecase letter (Lt) - // ―Modifier letter (Lm) - // ―Other letter (Lo) - // ―Letter number (Nl) - «generateUnicodeRules [ isLetter ]» - ; - terminal fragment UNICODE_SPACE_SEPARATOR_FRAGMENT: - // any character in the Unicode categories - // ―space separator (Zs) - «generateUnicodeRules [ isSpaceSeparator ]» - ; - terminal fragment ANY_OTHER: - . - ; - ''' - def static generateUnicodeRules((int)=>boolean guard) { - var Character prev = null; - var run = false; - var first = true; - var char c = Character.MIN_VALUE - val result = new StringWriter - val printer = new PrintWriter(result, true) - while(true) { - if (guard.apply(c as int)) { - if (!run) { - prev = c; - run = true; - } - } else { - if (run) { - if (!first) { - printer.print("| "); - } else { - printer.print(" "); - first = false; - } - printer.print("'\\u" + Strings.padStart(Integer.toHexString(prev).toUpperCase(), 4, '0') + "'"); - if (prev.charValue() == c - 1) { - printer.println(); - } else { - printer.println("..'\\u" + Strings.padStart(Integer.toHexString(c - 1).toUpperCase(), 4, '0') + "'"); - } - prev = null; - run = false; - } - } - c = (c + 1) as char - if (c == Character.MAX_VALUE) { - return result; - } - } - - } - - -} diff --git a/plugins/org.eclipse.n4js.dts/pom.xml b/plugins/org.eclipse.n4js.dts/pom.xml index 0b20fe0301..b9645b1212 100644 --- a/plugins/org.eclipse.n4js.dts/pom.xml +++ b/plugins/org.eclipse.n4js.dts/pom.xml @@ -37,11 +37,7 @@ Contributors: org.apache.maven.plugins maven-clean-plugin - - - org.eclipse.xtend - xtend-maven-plugin - + org.apache.maven.plugins maven-dependency-plugin