Skip to content

Commit

Permalink
GH-2582: As a smith I want to migrate some Xtend files to Java (part …
Browse files Browse the repository at this point in the history
…7) (#2583)

* migrate some transpiler transformations

* migrate more

* migrate some

* migrate files

* migrate files

* migration of package es.transform complete

* fix migration issues

* another migration fix

* migrate file

* migrate remaining files in bundle transpiler.es

* remove xtend nature from bundle transpiler.es

* fix and migration

* migrate bundle transpiler

* remove xtend nature from bundle transpiler

* remove xtend nature from semver.ide and semver.model

* migrate files and remove xtend nature from regex.ide

* migrate files and remove xtend nature from regex

* migrate files and remove xtend nature from n4js.model

* clean-up obsolete xtend natures

* migrate files and remove xtend nature from n4js.json

* migrate files and remove xtend nature from n4js.jsdoc2spec

* migrate files and remove xtend nature from n4js.common.unicode

* cleanup obsolete xtend bundle natures

* migrate files and remove xtend nature from tests.helper

* two fixes

* adjust test expectations

* another fix

* test adjustments

* fixes

* fix

* fix
  • Loading branch information
mmews-n4 authored Dec 20, 2023
1 parent d7c8d06 commit 3403473
Show file tree
Hide file tree
Showing 182 changed files with 12,583 additions and 10,892 deletions.
4 changes: 0 additions & 4 deletions plugins/org.eclipse.n4js.cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ Contributors:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down
1 change: 0 additions & 1 deletion plugins/org.eclipse.n4js.common.unicode/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen">
<attributes>
Expand Down
3 changes: 1 addition & 2 deletions plugins/org.eclipse.n4js.common.unicode/build.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source.. = src/,\
src-gen/,\
grammar-gen/,\
xtend-gen/
grammar-gen/
bin.includes = META-INF/,\
.,\
about.html
6 changes: 0 additions & 6 deletions plugins/org.eclipse.n4js.common.unicode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ Contributors:
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>

</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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<Integer, Boolean> 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;
}
}
}

}
Loading

0 comments on commit 3403473

Please sign in to comment.