js.annotations -> js
path independent jslib
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pavel Talanov
|
||||||
|
*/
|
||||||
|
public final class Dummy {
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package js.annotations;
|
package js;
|
||||||
|
|
||||||
annotation class native(name : String = "")
|
annotation class native(name : String = "") {}
|
||||||
annotation class library(name : String = "") {}
|
annotation class library(name : String = "") {}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package js;
|
package js;
|
||||||
|
|
||||||
import js.annotations.library
|
import js.library
|
||||||
import js.annotations.library
|
import js.native
|
||||||
import js.annotations.native
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
library("println")
|
library("println")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package java.lang
|
package java.lang
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import js.annotations.library
|
import js.library
|
||||||
|
|
||||||
library
|
library
|
||||||
trait Iterable<T> {
|
trait Iterable<T> {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package java.util
|
package java.util
|
||||||
|
|
||||||
import js.annotations.*;
|
import js.*;
|
||||||
|
|
||||||
|
|
||||||
library("collectionsMax")
|
library("collectionsMax")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package js
|
package js
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import js.annotations.library
|
import js.library
|
||||||
|
|
||||||
class Json() {
|
class Json() {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package js;
|
package js;
|
||||||
|
|
||||||
import js.annotations.native
|
import js.native
|
||||||
|
|
||||||
native
|
native
|
||||||
val Math = object {
|
val Math = object {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package html5
|
package html5
|
||||||
|
|
||||||
import js.annotations.native
|
import js.native
|
||||||
import js.DomElement
|
import js.DomElement
|
||||||
|
|
||||||
native
|
native
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package jquery;
|
package jquery;
|
||||||
|
|
||||||
import js.annotations.*;
|
import js.*;
|
||||||
import js.DomElement
|
import js.DomElement
|
||||||
|
|
||||||
native
|
native
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package raphael
|
package raphael
|
||||||
|
|
||||||
import js.annotations.*;
|
import js.*;
|
||||||
import js.*;
|
import js.*;
|
||||||
|
|
||||||
native
|
native
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package org.jetbrains.k2js.config;
|
|||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
import core.Dummy;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.k2js.utils.JetFileUtils;
|
import org.jetbrains.k2js.utils.JetFileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -26,15 +27,15 @@ public abstract class Config {
|
|||||||
//TODO: provide some generic way to get the files of the project
|
//TODO: provide some generic way to get the files of the project
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final List<String> LIB_FILE_NAMES = Arrays.asList(
|
private static final List<String> LIB_FILE_NAMES = Arrays.asList(
|
||||||
PATH_TO_JS_LIB_SRC + "\\core\\annotations.kt",
|
"/core/annotations.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\jquery\\common.kt",
|
"/jquery/common.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\core\\javautil.kt",
|
"/core/javautil.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\core\\javalang.kt",
|
"/core/javalang.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\core\\core.kt",
|
"/core/core.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\core\\math.kt",
|
"/core/math.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\core\\json.kt",
|
"/core/json.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\raphael\\raphael.kt",
|
"/raphael/raphael.kt",
|
||||||
PATH_TO_JS_LIB_SRC + "\\html5\\core.kt"
|
"/html5/core.kt"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ public abstract class Config {
|
|||||||
List<String> lines = Files.readLines(file, Charsets.UTF_8);
|
List<String> lines = Files.readLines(file, Charsets.UTF_8);
|
||||||
return lines.get(0);
|
return lines.get(0);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return "jslib\\src";
|
return "jslib/src";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +54,16 @@ public abstract class Config {
|
|||||||
private static List<JetFile> initLibFiles(@NotNull Project project) {
|
private static List<JetFile> initLibFiles(@NotNull Project project) {
|
||||||
List<JetFile> libFiles = new ArrayList<JetFile>();
|
List<JetFile> libFiles = new ArrayList<JetFile>();
|
||||||
for (String libFileName : LIB_FILE_NAMES) {
|
for (String libFileName : LIB_FILE_NAMES) {
|
||||||
libFiles.add(JetFileUtils.loadPsiFile(libFileName, project));
|
InputStream stream = Dummy.class.getResourceAsStream(libFileName);
|
||||||
|
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||||
|
JetFile file = null;
|
||||||
|
try {
|
||||||
|
String text = readString(stream);
|
||||||
|
file = JetFileUtils.createPsiFile(libFileName, text, project);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
libFiles.add(file);
|
||||||
}
|
}
|
||||||
return libFiles;
|
return libFiles;
|
||||||
}
|
}
|
||||||
@@ -73,4 +83,19 @@ public abstract class Config {
|
|||||||
|
|
||||||
return jsLibFiles;
|
return jsLibFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String readString(InputStream is) throws IOException {
|
||||||
|
char[] buf = new char[2048];
|
||||||
|
Reader r = new InputStreamReader(is, "UTF-8");
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
while (true) {
|
||||||
|
int n = r.read(buf);
|
||||||
|
if (n < 0)
|
||||||
|
break;
|
||||||
|
s.append(buf, 0, n);
|
||||||
|
}
|
||||||
|
return s.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getContainingCl
|
|||||||
public final class AnnotationsUtils {
|
public final class AnnotationsUtils {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static final String NATIVE_ANNOTATION_FQNAME = "js.annotations.native";
|
public static final String NATIVE_ANNOTATION_FQNAME = "js.native";
|
||||||
@NotNull
|
@NotNull
|
||||||
public static final String LIBRARY_ANNOTATION_FQNAME = "js.annotations.library";
|
public static final String LIBRARY_ANNOTATION_FQNAME = "js.library";
|
||||||
|
|
||||||
private AnnotationsUtils() {
|
private AnnotationsUtils() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
<orderEntry type="library" name="idea-full" level="application" />
|
<orderEntry type="library" name="idea-full" level="application" />
|
||||||
<orderEntry type="module" module-name="js" />
|
<orderEntry type="module" module-name="js" />
|
||||||
<orderEntry type="module" module-name="compiler-tests" />
|
<orderEntry type="module" module-name="compiler-tests" />
|
||||||
|
<orderEntry type="module" module-name="jslib" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user