mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
Merge branch 'master' of https://github.com/cincheo/jsweet.git
This commit is contained in:
commit
9db3920d9c
@ -78,7 +78,7 @@ More with the [live sandbox](http://www.jsweet.org/jsweet-live-sandbox/).
|
||||
- Extensive support of Java constructs and semantics added since [version 1.1.0](https://github.com/cincheo/jsweet/releases/tag/v1.1.0) (inner classes, anonymous classes, final fields, method overloading, instanceof operator, static initializers, ...).
|
||||
- *Over 1000 JavaScript libraries*, frameworks and plugins to write Web and Mobile HTML5 applications (JQuery, Underscore, Angular, Backbone, Cordova, Node.js, and much [more](http://www.jsweet.org/candies-snapshots/)).
|
||||
- A [Maven repository](http://repository.jsweet.org/artifactory) containing all the available libraries in Maven artifacts (a.k.a. candies).
|
||||
- Support for Java basic APIs as the [J4TS](https://github.com/cincheo/j4ts) candy (forked from the GWT's JRE emulation).
|
||||
- Support for Java basic APIs as the [J4TS](https://github.com/j4ts/j4ts) candy (forked from the GWT's JRE emulation).
|
||||
- An [Eclipse plugin](https://github.com/cincheo/jsweet-eclipse-plugin) for easy installation and use.
|
||||
- A [Maven plugin](https://github.com/lgrignon/jsweet-maven-plugin) to use JSweet from any other IDE or from the command line.
|
||||
- A debug mode to enable Java code debugging within your favorite browser.
|
||||
@ -132,7 +132,7 @@ This repository is organized in sub-projects. Each sub-project has its own build
|
||||
|
||||
* [JSweet transpiler](https://github.com/cincheo/jsweet/tree/master/transpiler): the Java to TypeScript/JavaScript compiler.
|
||||
* [JSweet core candy](https://github.com/cincheo/jsweet/tree/master/core-lib): the core APIs (JavaScript language, JavaScript DOM, and JSweet language utilities).
|
||||
* [JDK runtime](https://github.com/cincheo/jsweet/tree/master/j4ts): a fork from GWT's JRE emulation to implement main JDK APIs in JSweet/TypeScript/JavaScript.
|
||||
* [JDK runtime](https://github.com/j4ts/j4ts): a fork from GWT's JRE emulation to implement main JDK APIs in JSweet/TypeScript/JavaScript.
|
||||
* [JSweet candy generator](https://github.com/cincheo/jsweet/tree/master/candy-generator): a tool to generate Java APIs from TypeScript definition files, and package them as JSweet candies.
|
||||
* [JSweet documentation](https://github.com/cincheo/jsweet/tree/master/doc): JSweet documentation.
|
||||
|
||||
|
||||
@ -491,9 +491,10 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
|
||||
if (qualified.sym != null) {
|
||||
// regular import case (qualified.sym is a package)
|
||||
if (context.hasAnnotationType(qualified.sym, JSweetConfig.ANNOTATION_MODULE)) {
|
||||
String targetName = createImportAliasFromFieldAccess (qualified);
|
||||
String actualName = context.getAnnotationValue(qualified.sym,
|
||||
JSweetConfig.ANNOTATION_MODULE, String.class, null);
|
||||
useModule(true, null, importDecl, qualified.name.toString(), actualName,
|
||||
useModule(true, null, importDecl, targetName, actualName,
|
||||
((PackageSymbol) qualified.sym));
|
||||
}
|
||||
} else {
|
||||
@ -506,10 +507,11 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
|
||||
if (qualified.name.equals(importedMember.getSimpleName())) {
|
||||
if (context.hasAnnotationType(importedMember,
|
||||
JSweetConfig.ANNOTATION_MODULE)) {
|
||||
String targetName = createImportAliasFromSymbol (importedMember);
|
||||
String actualName = context.getAnnotationValue(importedMember,
|
||||
JSweetConfig.ANNOTATION_MODULE, String.class, null);
|
||||
useModule(true, null, importDecl,
|
||||
importedMember.getSimpleName().toString(), actualName,
|
||||
targetName, actualName,
|
||||
importedMember);
|
||||
break;
|
||||
}
|
||||
@ -746,8 +748,40 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
|
||||
|
||||
globalModule = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String createImportAliasFromFieldAccess (JCFieldAccess access) {
|
||||
String name = extractNameFromAnnotatedSymbol (access.sym);
|
||||
if (name != null) {
|
||||
return name;
|
||||
} else {
|
||||
return access.name.toString ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String createImportAliasFromSymbol (Symbol symbol) {
|
||||
String name = extractNameFromAnnotatedSymbol (symbol);
|
||||
if (name != null) {
|
||||
return name;
|
||||
} else {
|
||||
return symbol.getSimpleName ().toString ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String extractNameFromAnnotatedSymbol (Symbol symbol) {
|
||||
if (context.hasAnnotationType (symbol, JSweetConfig.ANNOTATION_NAME)) {
|
||||
return context.getAnnotationValue (
|
||||
symbol, JSweetConfig.ANNOTATION_NAME,
|
||||
String.class, null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void printDocComment(JCTree element, boolean indent) {
|
||||
if (compilationUnit != null && compilationUnit.docComments != null) {
|
||||
Comment comment = compilationUnit.docComments.getComment(element);
|
||||
|
||||
@ -261,7 +261,7 @@ public class Java2TypeScriptAdapter extends PrinterAdapter {
|
||||
case "java.lang.Math":
|
||||
return null;
|
||||
}
|
||||
String name = getPrinter().getRootRelativeName(fa.selected.type.tsym, context.useModules);
|
||||
String name = getPrinter().getRootRelativeName(fa.selected.type.tsym, false);
|
||||
String methodName = fa.name.toString();
|
||||
|
||||
// function is a top-level global function (no need to import)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user