Skip to content

Commit

Permalink
Merge pull request #26 from treblereel/r_0_6_4
Browse files Browse the repository at this point in the history
R 0 6 4
  • Loading branch information
treblereel authored Jun 1, 2024
2 parents ef827b4 + 44f1eea commit 9d98314
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 42 deletions.
2 changes: 1 addition & 1 deletion annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.treblereel.j2cl.processors</groupId>
<artifactId>parent</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
</parent>

<artifactId>annotations</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.treblereel.j2cl.processors</groupId>
<artifactId>parent</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
</parent>

<artifactId>common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.treblereel.j2cl.processors</groupId>
<artifactId>parent</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>pom</packaging>

<name>GWT3 processors parent</name>
Expand Down
2 changes: 1 addition & 1 deletion processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.treblereel.j2cl.processors</groupId>
<artifactId>parent</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
</parent>

<artifactId>processors</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.stream.Collectors;
import javax.lang.model.element.Element;
Expand Down Expand Up @@ -112,13 +114,13 @@ public void generate(Set<Element> elements) {
exports.put(checkClazz(parent), new HashSet<>());
exports.get(parent).addAll(methods);

ElementFilter.methodsIn(parent.getEnclosedElements()).stream()
getAllMethodsIn(parent).stream()
.filter(elm -> !elm.getModifiers().contains(Modifier.PRIVATE))
.filter(elm -> !elm.getModifiers().contains(Modifier.NATIVE))
.filter(elm -> !elm.getModifiers().contains(Modifier.ABSTRACT))
.forEach(elm -> exportDTOs.get(parent).addMethod(getMethodDTO(parent, elm)));

ElementFilter.fieldsIn(parent.getEnclosedElements()).stream()
getAllFieldsIn(parent).stream()
.filter(elm -> !elm.getModifiers().contains(Modifier.PRIVATE))
.filter(elm -> !elm.getModifiers().contains(Modifier.NATIVE))
.filter(elm -> !elm.getModifiers().contains(Modifier.ABSTRACT))
Expand Down Expand Up @@ -287,9 +289,8 @@ private TypeElement checkClazz(TypeElement parent) {
+ ", mustn't be annotated with @ES6Module");
}
Set<ExecutableElement> constructors =
ElementFilter.constructorsIn(parent.getEnclosedElements()).stream()
.collect(Collectors.toSet());
if (!constructors.isEmpty()) {
new HashSet<>(ElementFilter.constructorsIn(parent.getEnclosedElements()));
if (parent.getAnnotation(JsType.class) == null && !constructors.isEmpty()) {
constructors.stream()
.filter(elm -> elm.getModifiers().contains(Modifier.PUBLIC))
.filter(elm -> elm.getParameters().isEmpty())
Expand All @@ -305,4 +306,34 @@ private TypeElement checkClazz(TypeElement parent) {

return parent;
}

private Set<ExecutableElement> getAllMethodsIn(TypeElement parent) {
Set<ExecutableElement> elements = new HashSet<>();
Queue<TypeElement> queue = new LinkedList<>();
queue.add(parent);
while (!queue.isEmpty()) {
TypeElement current = queue.poll();
elements.addAll(ElementFilter.methodsIn(current.getEnclosedElements()));
if (!current.getSuperclass().toString().equals("java.lang.Object")
&& MoreTypes.asElement(current.getSuperclass()).getKind().isClass()) {
queue.offer((TypeElement) MoreTypes.asElement(current.getSuperclass()));
}
}
return elements;
}

private Set<VariableElement> getAllFieldsIn(TypeElement parent) {
Set<VariableElement> elements = new HashSet<>();
Queue<TypeElement> queue = new LinkedList<>();
queue.add(parent);
while (!queue.isEmpty()) {
TypeElement current = queue.poll();
elements.addAll(ElementFilter.fieldsIn(current.getEnclosedElements()));
if (!current.getSuperclass().toString().equals("java.lang.Object")
&& MoreTypes.asElement(current.getSuperclass()).getKind().isClass()) {
queue.offer((TypeElement) MoreTypes.asElement(current.getSuperclass()));
}
}
return elements;
}
}
36 changes: 22 additions & 14 deletions processor/src/main/resources/templates/resources/export.ftlh
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
<#if !isNative>
/**
* @fileoverview
* @suppress {missingProperties}
*/
</#if>
goog.module('${module}$GWT3Export');

const EXPORT = goog.require('${target}');

<#if isNative>
goog.exportSymbol('${type}', EXPORT);
<#else>
const j_l_Object = goog.require('java.lang.Object$impl');
const $Util = goog.require('nativebootstrap.Util$impl');

class _EXPORT extends EXPORT {
constructor() {
EXPORT.$clinit();
super();
this.${ctor}();
<#list methods as method>
goog.exportSymbol('${type}.<#if !method.isStatic>prototype.</#if>${method.name}', EXPORT.<#if !method.isStatic>prototype.</#if>${method.mangleName});
</#list>
<#else>
const classProxy = new Proxy(EXPORT, {
construct(target, args) {
return EXPORT.$create__();
}
}

$Util.$setClassMetadata(_EXPORT, '${module}');
goog.exportSymbol('${type}', _EXPORT);
</#if>
});

EXPORT.$clinit();
goog.exportSymbol('${type}', classProxy);
<#list methods as method>
goog.exportSymbol('${type}.<#if !method.isStatic>prototype.</#if>${method.name}', EXPORT.<#if !method.isStatic>prototype.</#if>${method.mangleName});
<#if method.isStatic>
goog.exportProperty(EXPORT, '${method.name}', EXPORT.${method.mangleName});
<#else>
goog.exportSymbol('${type}.prototype.${method.name}', classProxy.prototype.${method.mangleName});
</#if>
</#list>
</#if>
4 changes: 2 additions & 2 deletions tests/commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>common-tests</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>

<name>Common test cases</name>
<description>Common test cases</description>
Expand Down Expand Up @@ -85,7 +85,7 @@
<dependency>
<groupId>org.treblereel.j2cl.processors</groupId>
<artifactId>common</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion tests/entrypoint/jstype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>entrypoint-jstype-tests</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>

<name>GWT3 Entry Point Tests for @JsType class</name>
<description>Test cases for the GWT3 Entry Point for @JsType class</description>
Expand Down
2 changes: 1 addition & 1 deletion tests/entrypoint/pojo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>entrypoint-pojo-tests</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>

<name>GWT3 Entry Point Tests for Pojo class</name>
<description>Test cases for the GWT3 Entry Point for Pojo class</description>
Expand Down
2 changes: 1 addition & 1 deletion tests/entrypoint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>entrypoint-tests</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>pom</packaging>

<name>GWT3 Entry Point Tests</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/es6shim/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<artifactId>es6shim-tests</artifactId>
<groupId>org.treblereel.j2cl</groupId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>ES6SHIM Tests</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/exports/javaenv/pom-advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>javaenv-advanced</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>GWTExports java env Tests ADVANCED mode</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/exports/javaenv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>javaenv</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>GWTExports java env Tests BUNDLE_JAR mode</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/exports/jsenv/bundle_jar_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>exports-bundle_jar</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>GWTExports Tests BUNDLE_JAR mode</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/exports/jsenv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>jsenv</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>GWTExports Tests ADVANCED mode</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/exports/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.treblereel.j2cl</groupId>
<artifactId>tests-parent</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
</parent>
<packaging>pom</packaging>

Expand Down
2 changes: 1 addition & 1 deletion tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>tests-parent</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>pom</packaging>

<name>GWT3 processors Tests</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.treblereel.j2cl</groupId>
<artifactId>tests-parent</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
</parent>

<artifactId>resources</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tests/translation/default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>translation-default</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>Translation Tests en</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/translation/fr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>translation-fr</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>Translation Tests fr</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/translation/fr_nr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>translation-fr-nr</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>jar</packaging>

<name>Translation Tests fr-nr</name>
Expand Down
2 changes: 1 addition & 1 deletion tests/translation/no_bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.treblereel.j2cl</groupId>
<artifactId>translation-tests</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
</parent>

<artifactId>translation-no_bundle</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tests/translation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.treblereel.j2cl</groupId>
<artifactId>translation-tests</artifactId>
<version>0.6.3</version>
<version>0.6.4</version>
<packaging>pom</packaging>

<name>GWT3 Entry Point Tests</name>
Expand Down
2 changes: 1 addition & 1 deletion utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>org.treblereel.j2cl.processors</groupId>
<version>0.6.3</version>
<version>0.6.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit 9d98314

Please sign in to comment.