Skip to content

Commit

Permalink
@GWT3Export refactored, now it works on the method level for static a…
Browse files Browse the repository at this point in the history
…nd instance methods, fields support is drop for now, because it's not very stable
  • Loading branch information
treblereel committed May 26, 2022
1 parent aad2a5f commit b530d65
Show file tree
Hide file tree
Showing 28 changed files with 492 additions and 638 deletions.
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,28 @@ It contains the following features:
* *@GWT3Export* allows a resulted JavaScript file to be called from the pure JavaScript environment.

```java
@JsType
@GWT3Export
public class ExportTestClass {

@JsProperty
public static String staticProperty = "staticProperty";

@JsMethod
public static String test2(String s) {
@GWT3Export
public static String test(String s) {
return s;
}

@JsProperty
public String id = "qwerty";

@JsMethod
public String test1(String s) {
return s;
@GWT3Export
public Promise<String> promise() {
return Promise.resolve("Hello world!");
}
}
```
```javascript
var test = new org.treblereel.j2cl.exports.ExportTestClass();

expect(test.test1('INSTANCE METHOD CALL')).toBe('INSTANCE METHOD CALL');
expect(test.id).toBe('qwerty');
test.test('INSTANCE METHOD CALL');

expect(org.treblereel.j2cl.exports.ExportTestClass.test2('STATIC METHOD CALL')).toBe('STATIC METHOD CALL');
expect(org.treblereel.j2cl.exports.ExportTestClass.staticProperty).toBe('staticProperty');
test.promise().then(function(result) {

});

```

Take a look at tests for more details.
2 changes: 1 addition & 1 deletion annotations/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.3-SNAPSHOT</version>
<version>0.4-SNAPSHOT</version>
</parent>

<artifactId>annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@

/** GWT3Export */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Target({ElementType.METHOD})
public @interface GWT3Export {

String name() default "<auto>";

String namespace() default "<auto>";
}
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.3-SNAPSHOT</version>
<version>0.4-SNAPSHOT</version>
<packaging>pom</packaging>

<name>GWT3 processors parent</name>
Expand Down
2 changes: 1 addition & 1 deletion processor/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>org.treblereel.j2cl.processors</groupId>
<version>0.1-SNAPSHOT</version>
<version>0.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>processors</artifactId>
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.3-SNAPSHOT</version>
<version>0.4-SNAPSHOT</version>
</parent>

<artifactId>processors</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package org.treblereel.j2cl.processors.exception;

import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;

public class GenerationException extends RuntimeException {
private static final long serialVersionUID = 1L;

Expand All @@ -25,6 +28,16 @@ public GenerationException(String msg) {
super(msg);
}

public GenerationException(TypeElement element, String message) {
super(String.format("%s : %s", element.toString(), message));
}

public GenerationException(ExecutableElement element, String message) {
super(
String.format(
"%s.%s : %s", element.getEnclosingElement().toString(), element.toString(), message));
}

public GenerationException(Throwable t) {
super(t);
}
Expand Down
Loading

0 comments on commit b530d65

Please sign in to comment.