-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
946 changed files
with
160,800 additions
and
51,016 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<parent> | ||
<groupId>io.reactiverse</groupId> | ||
<artifactId>es4x-parent</artifactId> | ||
<version>0.6.0</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>es4x-codegen</artifactId> | ||
<version>0.6.0</version> | ||
|
||
<properties> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-core</artifactId> | ||
<version>${vertx.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-codegen</artifactId> | ||
<version>${vertx.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.amashchenko.maven.plugin</groupId> | ||
<artifactId>gitflow-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
45 changes: 45 additions & 0 deletions
45
codegen/src/main/java/io/reactiverse/es4x/codegen/ES4XGeneratorLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2018 Paulo Lopes. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* The Apache License v2.0 is available at | ||
* http://www.opensource.org/licenses/apache2.0.php | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
*/ | ||
package io.reactiverse.es4x.codegen; | ||
|
||
import io.reactiverse.es4x.codegen.generator.*; | ||
import io.vertx.codegen.Generator; | ||
import io.vertx.codegen.GeneratorLoader; | ||
|
||
import javax.annotation.processing.ProcessingEnvironment; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
public class ES4XGeneratorLoader implements GeneratorLoader { | ||
@Override | ||
public Stream<Generator<?>> loadGenerators(ProcessingEnvironment processingEnv) { | ||
|
||
final List<Generator<?>> generators = new LinkedList<>(); | ||
|
||
generators.add(new IndexJS()); | ||
generators.add(new IndexDTS()); | ||
generators.add(new OptionsJS()); | ||
generators.add(new OptionsDTS()); | ||
generators.add(new EnumJS()); | ||
generators.add(new EnumDTS()); | ||
generators.add(new ReadmeMD()); | ||
generators.add(new PackageJSON()); | ||
|
||
return generators.stream(); | ||
|
||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
codegen/src/main/java/io/reactiverse/es4x/codegen/generator/EnumDTS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2018 Paulo Lopes. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* The Apache License v2.0 is available at | ||
* http://www.opensource.org/licenses/apache2.0.php | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
*/ | ||
package io.reactiverse.es4x.codegen.generator; | ||
|
||
import io.vertx.codegen.EnumModel; | ||
import io.vertx.codegen.EnumValueInfo; | ||
import io.vertx.codegen.Generator; | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
|
||
public class EnumDTS extends Generator<EnumModel> { | ||
|
||
public EnumDTS() { | ||
incremental = true; | ||
|
||
kinds = new HashSet<>(); | ||
kinds.add("enum"); | ||
|
||
name = "es4x-generator (enum.d.ts)"; | ||
} | ||
|
||
@Override | ||
public String filename(EnumModel model) { | ||
return "npm/enums.d.ts"; | ||
} | ||
|
||
@Override | ||
public String render(EnumModel model, int index, int size, Map<String, Object> session) { | ||
|
||
StringWriter sw = new StringWriter(); | ||
PrintWriter writer = new PrintWriter(sw); | ||
|
||
if (index == 0) { | ||
Util.generateLicense(writer); | ||
} else { | ||
writer.print("\n"); | ||
} | ||
|
||
writer.printf("export enum %s {\n", model.getType().getRaw().getSimpleName()); | ||
for (int i = 0; i < model.getValues().size(); i++) { | ||
EnumValueInfo value = model.getValues().get(i); | ||
writer.printf(" %s", value.getIdentifier()); | ||
if (i != model.getValues().size() - 1) { | ||
writer.print(","); | ||
} | ||
writer.print("\n"); | ||
} | ||
writer.print("}\n"); | ||
|
||
return sw.toString(); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
codegen/src/main/java/io/reactiverse/es4x/codegen/generator/EnumJS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2018 Paulo Lopes. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* The Apache License v2.0 is available at | ||
* http://www.opensource.org/licenses/apache2.0.php | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
*/ | ||
package io.reactiverse.es4x.codegen.generator; | ||
|
||
import io.vertx.codegen.Generator; | ||
import io.vertx.codegen.EnumModel; | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
|
||
import static io.reactiverse.es4x.codegen.generator.Util.*; | ||
|
||
public class EnumJS extends Generator<EnumModel> { | ||
|
||
public EnumJS() { | ||
incremental = true; | ||
|
||
kinds = new HashSet<>(); | ||
kinds.add("enum"); | ||
|
||
name = "es4x-generator (enum.js)"; | ||
} | ||
|
||
@Override | ||
public String filename(EnumModel model) { | ||
return "npm/enums.js"; | ||
} | ||
|
||
@Override | ||
public String render(EnumModel model, int index, int size, Map<String, Object> session) { | ||
|
||
StringWriter sw = new StringWriter(); | ||
PrintWriter writer = new PrintWriter(sw); | ||
|
||
if (index == 0) { | ||
Util.generateLicense(writer); | ||
writer.printf("/// <reference types=\"%s/enums\" />\n", getNPMScope(model.getType().getRaw().getModule())); | ||
writer.print("module.exports = {\n"); | ||
} | ||
|
||
writer.printf(" %s: Java.type('%s')", model.getType().getRaw().getSimpleName(), model.getType().getName()); | ||
|
||
if (index != size - 1) { | ||
writer.print(','); | ||
} | ||
|
||
writer.print('\n'); | ||
|
||
if (index == size - 1) { | ||
writer.print("};\n"); | ||
} | ||
|
||
return sw.toString(); | ||
} | ||
} |
Oops, something went wrong.