diff --git a/.idea/runConfigurations/Js_backend_tests.xml b/.idea/runConfigurations/Js_backend_tests.xml
index 95f27eae686..92d546e1571 100644
--- a/.idea/runConfigurations/Js_backend_tests.xml
+++ b/.idea/runConfigurations/Js_backend_tests.xml
@@ -23,8 +23,12 @@
+
+
+
+
diff --git a/js/js.libraries/src/core/annotations.kt b/js/js.libraries/src/core/annotations.kt
index adafe8c4aa9..15e9185634a 100644
--- a/js/js.libraries/src/core/annotations.kt
+++ b/js/js.libraries/src/core/annotations.kt
@@ -1,6 +1,6 @@
package js;
native
-annotation class native(name : String = "") {}
+public annotation class native(name : String = "") {}
native
-annotation class library(name : String = "") {}
\ No newline at end of file
+public annotation class library(name : String = "") {}
\ No newline at end of file
diff --git a/js/js.libraries/src/core/core.kt b/js/js.libraries/src/core/core.kt
index da25142f48b..8555b1499ea 100644
--- a/js/js.libraries/src/core/core.kt
+++ b/js/js.libraries/src/core/core.kt
@@ -7,18 +7,18 @@ import java.lang.*;
native
-val noImpl : Nothing = throw Exception();
+public val noImpl : Nothing = throw Exception();
library("println")
-fun println() {}
+public fun println() {}
library("println")
-fun println(s : Any?) {}
+public fun println(s : Any?) {}
library("print")
-fun print(s : Any?) {}
+public fun print(s : Any?) {}
//TODO: consistent parseInt
library("parseInt")
-fun parseInt(s : String) : Int = js.noImpl
+public fun parseInt(s : String) : Int = js.noImpl
library
-fun safeParseInt(s : String) : Int? = js.noImpl
+public fun safeParseInt(s : String) : Int? = js.noImpl
library
-fun safeParseDouble(s : String) : Double? = js.noImpl
\ No newline at end of file
+public fun safeParseDouble(s : String) : Double? = js.noImpl
\ No newline at end of file
diff --git a/js/js.libraries/src/core/date.kt b/js/js.libraries/src/core/date.kt
index cf551097b6a..bf3cf339ad7 100644
--- a/js/js.libraries/src/core/date.kt
+++ b/js/js.libraries/src/core/date.kt
@@ -1,6 +1,6 @@
package js
native
-class Date() {
- fun getTime() : Int = js.noImpl
+public class Date() {
+ public fun getTime() : Int = js.noImpl
}
\ No newline at end of file
diff --git a/js/js.libraries/src/core/dom.kt b/js/js.libraries/src/core/dom.kt
index f20c5b076a0..6930eea617d 100644
--- a/js/js.libraries/src/core/dom.kt
+++ b/js/js.libraries/src/core/dom.kt
@@ -221,7 +221,7 @@ native public trait Node {
public fun lookupNamespaceURI(arg1: String?): String = js.noImpl
public fun isEqualNode(arg1: Node): Boolean = js.noImpl
- class object {
+ public class object {
public val ELEMENT_NODE: Short = 1
public val ATTRIBUTE_NODE: Short = 2
public val TEXT_NODE: Short = 3
diff --git a/js/js.libraries/src/core/javaio.kt b/js/js.libraries/src/core/javaio.kt
index c529fa0fa65..a5fd8ed741e 100644
--- a/js/js.libraries/src/core/javaio.kt
+++ b/js/js.libraries/src/core/javaio.kt
@@ -1,4 +1,4 @@
package java.io
library
-class IOException(message: String = "") : Exception() {}
+public class IOException(message: String = "") : Exception() {}
diff --git a/js/js.libraries/src/core/javalang.kt b/js/js.libraries/src/core/javalang.kt
index a2d8dadb7c8..506e980b36d 100644
--- a/js/js.libraries/src/core/javalang.kt
+++ b/js/js.libraries/src/core/javalang.kt
@@ -10,25 +10,25 @@ trait Iterable {
}
library
-open class Exception() : Throwable() {}
+open public class Exception() : Throwable() {}
library("splitString")
public fun String.split(regex : String) : Array = js.noImpl
library
-class IllegalArgumentException(message: String = "") : Exception() {}
+public class IllegalArgumentException(message: String = "") : Exception() {}
library
-class IllegalStateException(message: String = "") : Exception() {}
+public class IllegalStateException(message: String = "") : Exception() {}
library
-class IndexOutOfBoundsException(message: String = "") : Exception() {}
+public class IndexOutOfBoundsException(message: String = "") : Exception() {}
library
-class UnsupportedOperationException(message: String = "") : Exception() {}
+public class UnsupportedOperationException(message: String = "") : Exception() {}
library
-class NumberFormatException(message: String = "") : Exception() {}
+public class NumberFormatException(message: String = "") : Exception() {}
public trait Comparable {
fun compareTo(that: T): Int
diff --git a/js/js.libraries/src/core/javautil.kt b/js/js.libraries/src/core/javautil.kt
index 967a23e8064..65c60678e80 100644
--- a/js/js.libraries/src/core/javautil.kt
+++ b/js/js.libraries/src/core/javautil.kt
@@ -17,6 +17,7 @@ public trait Iterator {
open fun remove() : Unit = js.noImpl
}
+/*
val Collections = object {
library("collectionsMax")
public fun max(col : Collection, comp : Comparator) : T = js.noImpl
@@ -51,9 +52,7 @@ val Collections = object {
list[i2] = tmp
}
}
-
-
-}
+}*/
library
public open class ArrayList() : java.util.List {
@@ -79,19 +78,19 @@ public open class ArrayList() : java.util.List {
library
public trait Collection : java.lang.Iterable {
- open fun size() : Int
- open fun isEmpty() : Boolean
- open fun contains(o : Any?) : Boolean
- override fun iterator() : java.util.Iterator
- // open fun toArray() : Array
- // open fun toArray(a : Array) : Array
- open fun add(e : E) : Boolean
- open fun remove(o : Any?) : Boolean
- //open fun containsAll(c : java.util.Collection<*>) : Boolean
- open fun addAll(c : java.util.Collection) : Boolean
- //open fun removeAll(c : java.util.Collection<*>) : Boolean
- //open fun retainAll(c : java.util.Collection<*>) : Boolean
- open fun clear() : Unit
+ open public fun size() : Int
+ open public fun isEmpty() : Boolean
+ open public fun contains(o : Any?) : Boolean
+ override public fun iterator() : java.util.Iterator
+ // open public fun toArray() : Array
+ // open public fun toArray(a : Array) : Array
+ open public fun add(e : E) : Boolean
+ open public fun remove(o : Any?) : Boolean
+ //open public fun containsAll(c : java.util.Collection<*>) : Boolean
+ open public fun addAll(c : java.util.Collection) : Boolean
+ //open public fun removeAll(c : java.util.Collection<*>) : Boolean
+ //open public fun retainAll(c : java.util.Collection<*>) : Boolean
+ open public fun clear() : Unit
}
library
@@ -120,44 +119,44 @@ public abstract open class AbstractList() : AbstractCollection(), List
library
public trait List : Collection {
- override fun size() : Int
- override fun isEmpty() : Boolean
- override fun contains(o : Any?) : Boolean
- override fun iterator() : java.util.Iterator
- // override fun toArray() : Array
+ override public fun size() : Int
+ override public fun isEmpty() : Boolean
+ override public fun contains(o : Any?) : Boolean
+ override public fun iterator() : java.util.Iterator
+ // override public fun toArray() : Array
// Simulate Java's array covariance
- // override fun toArray(a : Array) : Array
- override fun add(e : E) : Boolean
- override fun remove(o : Any?) : Boolean
- // override fun containsAll(c : java.util.Collection<*>) : Boolean
- override fun addAll(c : java.util.Collection) : Boolean
- // open fun addAll(index : Int, c : java.util.Collection) : Boolean
- // override fun removeAll(c : java.util.Collection<*>) : Boolean
- // override fun retainAll(c : java.util.Collection<*>) : Boolean
- override fun clear() : Unit
- open fun get(index : Int) : E
- open fun set(index : Int, element : E) : E
- open fun add(index : Int, element : E) : Unit
- open fun remove(index : Int) : E
- // open fun indexOf(o : Any?) : Int
- // open fun lastIndexOf(o : Any?) : Int
+ // override public fun toArray(a : Array) : Array
+ override public fun add(e : E) : Boolean
+ override public fun remove(o : Any?) : Boolean
+ // override public fun containsAll(c : java.util.Collection<*>) : Boolean
+ override public fun addAll(c : java.util.Collection) : Boolean
+ // open public fun addAll(index : Int, c : java.util.Collection) : Boolean
+ // override public fun removeAll(c : java.util.Collection<*>) : Boolean
+ // override public fun retainAll(c : java.util.Collection<*>) : Boolean
+ override public fun clear() : Unit
+ open public fun get(index : Int) : E
+ open public fun set(index : Int, element : E) : E
+ open public fun add(index : Int, element : E) : Unit
+ open public fun remove(index : Int) : E
+ // open public fun indexOf(o : Any?) : Int
+ // open public fun lastIndexOf(o : Any?) : Int
}
library
public trait Set : Collection {
- override fun size() : Int
- override fun isEmpty() : Boolean
- override fun contains(o : Any?) : Boolean
- override fun iterator() : java.util.Iterator
- // override fun toArray() : Array
- // override fun toArray(a : Array) : Array
- override fun add(e : E) : Boolean
- override fun remove(o : Any?) : Boolean
- //override fun containsAll(c : java.util.Collection<*>) : Boolean
- override fun addAll(c : java.util.Collection) : Boolean
- //override fun retainAll(c : java.util.Collection<*>) : Boolean
- //override fun removeAll(c : java.util.Collection<*>) : Boolean
- override fun clear() : Unit
+ override public fun size() : Int
+ override public fun isEmpty() : Boolean
+ override public fun contains(o : Any?) : Boolean
+ override public fun iterator() : java.util.Iterator
+ // override public fun toArray() : Array
+ // override public fun toArray(a : Array) : Array
+ override public fun add(e : E) : Boolean
+ override public fun remove(o : Any?) : Boolean
+ //override public fun containsAll(c : java.util.Collection<*>) : Boolean
+ override public fun addAll(c : java.util.Collection) : Boolean
+ //override public fun retainAll(c : java.util.Collection<*>) : Boolean
+ //override public fun removeAll(c : java.util.Collection<*>) : Boolean
+ override public fun clear() : Unit
}
library
@@ -174,28 +173,28 @@ public open class HashSet() : java.util.Set {
library
public trait Map {
- open fun size() : Int
- open fun isEmpty() : Boolean
- open fun containsKey(key : Any?) : Boolean
- open fun containsValue(value : Any?) : Boolean
- open fun get(key : Any?) : V?
- open fun put(key : K, value : V) : V?
- open fun remove(key : Any?) : V?
- open fun putAll(m : java.util.Map) : Unit
- open fun clear() : Unit
- open fun keySet() : java.util.Set
- open fun values() : java.util.Collection
+ open public fun size() : Int
+ open public fun isEmpty() : Boolean
+ open public fun containsKey(key : Any?) : Boolean
+ open public fun containsValue(value : Any?) : Boolean
+ open public fun get(key : Any?) : V?
+ open public fun put(key : K, value : V) : V?
+ open public fun remove(key : Any?) : V?
+ open public fun putAll(m : java.util.Map) : Unit
+ open public fun clear() : Unit
+ open public fun keySet() : java.util.Set
+ open public fun values() : java.util.Collection
- open fun entrySet() : java.util.Set>
-// open fun equals(o : Any?) : Boolean
-// open fun hashCode() : Int
+ open public fun entrySet() : java.util.Set>
+// open public fun equals(o : Any?) : Boolean
+// open public fun hashCode() : Int
trait Entry {
- open fun getKey() : K
- open fun getValue() : V
- open fun setValue(value : V) : V
-// open fun equals(o : Any?) : Boolean
-// open fun hashCode() : Int
+ open public fun getKey() : K
+ open public fun getValue() : V
+ open public fun setValue(value : V) : V
+// open public fun equals(o : Any?) : Boolean
+// open public fun hashCode() : Int
}
}
@@ -244,4 +243,4 @@ public class StringBuilder() : Appendable {
}
library
-class NoSuchElementException() : Exception() {}
+public class NoSuchElementException() : Exception() {}
diff --git a/js/js.libraries/src/core/json.kt b/js/js.libraries/src/core/json.kt
index 4b6429da4ae..9a60614639c 100644
--- a/js/js.libraries/src/core/json.kt
+++ b/js/js.libraries/src/core/json.kt
@@ -4,21 +4,21 @@ import java.util.*;
import js.library
native
-class Json() {
+public class Json() {
}
library("jsonSet")
-fun Json.set(paramName : String, value : Any?) : Unit = js.noImpl
+public fun Json.set(paramName : String, value : Any?) : Unit = js.noImpl
library("jsonGet")
-fun Json.get(paramName : String) : Any? = js.noImpl
+public fun Json.get(paramName : String) : Any? = js.noImpl
library("jsonFromTuples")
-fun json(vararg pairs : Tuple2) : Json = js.noImpl
+public fun json(vararg pairs : Tuple2) : Json = js.noImpl
library("jsonFromTuples")
-fun json2(pairs : Array>) : Json = js.noImpl
+public fun json2(pairs : Array>) : Json = js.noImpl
library("jsonAddProperties")
-fun Json.add(other : Json) : Json = js.noImpl
\ No newline at end of file
+public fun Json.add(other : Json) : Json = js.noImpl
\ No newline at end of file
diff --git a/js/js.libraries/src/core/math.kt b/js/js.libraries/src/core/math.kt
index d1b8944c2ea..078f810057a 100644
--- a/js/js.libraries/src/core/math.kt
+++ b/js/js.libraries/src/core/math.kt
@@ -4,29 +4,29 @@ import js.native
//TODO: declare using number
native
-class MathClass() {
- val PI : Double = js.noImpl;
- fun random() : Double = js.noImpl;
- fun abs(value : Double) : Double = js.noImpl
- fun acos(value : Double) : Double = js.noImpl
- fun asin(value : Double) : Double = js.noImpl
- fun atan(value : Double) : Double = js.noImpl
- fun atan2(x : Double, y : Double) : Double = js.noImpl
- fun cos(value : Double) : Double = js.noImpl
- fun sin(value : Double) : Double = js.noImpl
- fun exp(value : Double) : Double = js.noImpl
- fun max(vararg values : Double) : Double = js.noImpl
- fun max(vararg values : Int) : Int = js.noImpl
- fun min(vararg values : Int) : Int = js.noImpl
- fun min(vararg values : Double) : Double = js.noImpl
- fun sqrt(value : Double) : Double = js.noImpl
- fun tan(value : Double) : Double = js.noImpl
- fun log(value : Double) : Double = js.noImpl
- fun pow(base : Double, exp : Double) : Double = js.noImpl
- fun round(value : Number) : Int = js.noImpl
- fun floor(value : Number) : Int = js.noImpl
- fun ceil(value : Number) : Int = js.noImpl
+public class MathClass() {
+ public val PI : Double = js.noImpl;
+ public fun random() : Double = js.noImpl;
+ public fun abs(value : Double) : Double = js.noImpl
+ public fun acos(value : Double) : Double = js.noImpl
+ public fun asin(value : Double) : Double = js.noImpl
+ public fun atan(value : Double) : Double = js.noImpl
+ public fun atan2(x : Double, y : Double) : Double = js.noImpl
+ public fun cos(value : Double) : Double = js.noImpl
+ public fun sin(value : Double) : Double = js.noImpl
+ public fun exp(value : Double) : Double = js.noImpl
+ public fun max(vararg values : Double) : Double = js.noImpl
+ public fun max(vararg values : Int) : Int = js.noImpl
+ public fun min(vararg values : Int) : Int = js.noImpl
+ public fun min(vararg values : Double) : Double = js.noImpl
+ public fun sqrt(value : Double) : Double = js.noImpl
+ public fun tan(value : Double) : Double = js.noImpl
+ public fun log(value : Double) : Double = js.noImpl
+ public fun pow(base : Double, exp : Double) : Double = js.noImpl
+ public fun round(value : Number) : Int = js.noImpl
+ public fun floor(value : Number) : Int = js.noImpl
+ public fun ceil(value : Number) : Int = js.noImpl
}
native
-val Math = MathClass();
\ No newline at end of file
+public val Math = MathClass();
\ No newline at end of file
diff --git a/js/js.libraries/src/dom/html/window.kt b/js/js.libraries/src/dom/html/window.kt
index 65546466fd1..6b9f0c90b63 100644
--- a/js/js.libraries/src/dom/html/window.kt
+++ b/js/js.libraries/src/dom/html/window.kt
@@ -3,4 +3,4 @@ package js.dom.html
import js.noImpl
native
-val window : Window = js.noImpl
\ No newline at end of file
+public val window : Window = js.noImpl
\ No newline at end of file
diff --git a/js/js.libraries/src/jquery/common.kt b/js/js.libraries/src/jquery/common.kt
index 962a8be81fb..1694a185181 100644
--- a/js/js.libraries/src/jquery/common.kt
+++ b/js/js.libraries/src/jquery/common.kt
@@ -3,70 +3,70 @@ package js.jquery;
import js.dom.core.Element
native
-class JQuery() {
- fun addClass(className : String) : JQuery = js.noImpl;
- fun addClass(f : Element.(Int, String)->String) = js.noImpl;
+public public class JQuery() {
+ public fun addClass(className : String) : JQuery = js.noImpl;
+ public fun addClass(f : Element.(Int, String)->String) = js.noImpl;
- fun attr(attrName : String) = "";
- fun attr(attrName : String, value : String) = this;
+ public fun attr(attrName : String) = "";
+ public fun attr(attrName : String, value : String) = this;
- fun html() : String = "";
- fun html(s : String) = this;
- fun html(f : Element.(Int, String)->String) = this;
+ public fun html() : String = "";
+ public fun html(s : String) = this;
+ public fun html(f : Element.(Int, String)->String) = this;
- fun hasClass(className : String) = true
- fun removeClass(className : String) = this
- fun height() = 0
- fun width() = 0
+ public fun hasClass(className : String) = true
+ public fun removeClass(className : String) = this
+ public fun height() = 0
+ public fun width() = 0
- fun click() = this;
+ public fun click() = this;
- fun mousedown(handler : Element.(MouseEvent)->Unit) = this;
- fun mouseup(handler : Element.(MouseEvent)->Unit) = this;
- fun mousemove(handler : Element.(MouseEvent)->Unit) = this;
+ public fun mousedown(handler : Element.(MouseEvent)->Unit) = this;
+ public fun mouseup(handler : Element.(MouseEvent)->Unit) = this;
+ public fun mousemove(handler : Element.(MouseEvent)->Unit) = this;
- fun dblclick(handler : Element.(MouseClickEvent)->Unit) = this;
- fun click(handler : Element.(MouseClickEvent)->Unit) = this;
+ public fun dblclick(handler : Element.(MouseClickEvent)->Unit) = this;
+ public fun click(handler : Element.(MouseClickEvent)->Unit) = this;
- fun load(handler : Element.()->Unit) = this;
- fun change(handler : Element.()->Unit) = this;
+ public fun load(handler : Element.()->Unit) = this;
+ public fun change(handler : Element.()->Unit) = this;
- fun append(str : String) = this;
- fun ready(handler : ()->Unit) = this;
- fun text(text : String) = this;
- fun slideUp() = this;
- fun hover(handlerInOut : Element.() -> Unit) = this;
- fun hover(handlerIn : Element.() -> Unit, handlerOut : Element.() -> Unit) = this;
- fun next() : JQuery = js.noImpl
- fun parent() : JQuery = js.noImpl
- fun `val`() : String? = js.noImpl
+ public fun append(str : String) = this;
+ public fun ready(handler : ()->Unit) = this;
+ public fun text(text : String) = this;
+ public fun slideUp() = this;
+ public fun hover(handlerInOut : Element.() -> Unit) = this;
+ public fun hover(handlerIn : Element.() -> Unit, handlerOut : Element.() -> Unit) = this;
+ public fun next() : JQuery = js.noImpl
+ public fun parent() : JQuery = js.noImpl
+ public fun `val`() : String? = js.noImpl
}
native
-open class MouseEvent() {
- val pageX : Double = 0.0;
- val pageY : Double = 0.0;
- fun preventDefault() {}
- fun isDefaultPrevented() : Boolean = true;
+open public class MouseEvent() {
+ public val pageX : Double = 0.0;
+ public val pageY : Double = 0.0;
+ public fun preventDefault() {}
+ public fun isDefaultPrevented() : Boolean = true;
}
native
-class MouseClickEvent() : MouseEvent() {
+public class MouseClickEvent() : MouseEvent() {
val which : Int = 0;
}
native("$")
-fun jq(selector : String) = JQuery();
+public fun jq(selector : String) = JQuery();
native("$")
-fun jq(selector : String, context : Element) = JQuery();
+public fun jq(selector : String, context : Element) = JQuery();
native("$")
-fun jq(callback : () -> Unit) = JQuery();
+public fun jq(callback : () -> Unit) = JQuery();
native("$")
-fun jq(obj : JQuery) = JQuery();
+public fun jq(obj : JQuery) = JQuery();
native("$")
-fun jq(el : Element) = JQuery();
+public fun jq(el : Element) = JQuery();
native("$")
-fun jq() = JQuery();
+public fun jq() = JQuery();
diff --git a/js/js.libraries/src/raphael/raphael.kt b/js/js.libraries/src/raphael/raphael.kt
deleted file mode 100644
index ef74659206b..00000000000
--- a/js/js.libraries/src/raphael/raphael.kt
+++ /dev/null
@@ -1,63 +0,0 @@
-package raphael
-
-import js.*;
-import js.*;
-
-native
-open class Element() {
-
- fun attr(name : String, value : Any?) : Element = this
- fun attr(nameToValue : Json) : Element = this
-
- fun click(handler : Element.()-> Unit) = this;
-
- fun mouseover(handler : Element.() -> Unit) = this
- fun mouseout(handler : Element.() -> Unit) = this
-
-
- fun getTotalLength() : Double = 0.0
- fun getPointAtLength(length : Double) : Point = js.noImpl
-
- fun animate(params : Json, ms : Int, callback : ()-> Unit) : Element = js.noImpl
- fun animate(params : Json, ms : Int, s : String) : Element = js.noImpl
- fun animate(params : Json, ms : Int) : Element = js.noImpl
- //fun mouse
-}
-
-native
-class Set() : Element() {
- fun push(el : Element) = js.noImpl
-}
-
-native
-class Paper() {
- fun path(pathString : String) : Element = Element();
- fun path() : Element = Element();
-
- fun ellipse(x : Int, y : Int, rx : Int, ry : Int) : Element = js.noImpl
- fun circle(x : Int, y : Int, r : Int) : Element = js.noImpl
- fun set() : Set = js.noImpl
-
- val customAttributes : Json = Json();
-}
-
-native("Raphael")
-fun Raphael(elementId : String, width : Int, height : Int) : Paper = Paper();
-native("Raphael")
-fun Raphael(elementId : String, width : Int, height : Int, initFun : Paper.() -> Unit) : Unit = js.noImpl
-
-native
-fun getColor() : Color = js.noImpl
-native
-fun resetColors() = js.noImpl
-
-native
-class Color() {
-}
-
-native
-class Point() {
- val x = 0
- val y = 0
- val alpha = 0
-}
diff --git a/js/js.libraries/src/stdlib/JUMaps.kt b/js/js.libraries/src/stdlib/JUMaps.kt
index 2958fb676b1..49f2639616c 100644
--- a/js/js.libraries/src/stdlib/JUMaps.kt
+++ b/js/js.libraries/src/stdlib/JUMaps.kt
@@ -2,4 +2,4 @@ package kotlin
import java.util.Map as JMap
/** Provides [] access to maps */
-fun JMap.set(key : K, value : V) = this.put(key, value)
+public fun JMap.set(key : K, value : V) = this.put(key, value)
diff --git a/js/js.libraries/src/stdlib/browser.kt b/js/js.libraries/src/stdlib/browser.kt
index c62023de748..872910a51b4 100644
--- a/js/js.libraries/src/stdlib/browser.kt
+++ b/js/js.libraries/src/stdlib/browser.kt
@@ -7,5 +7,5 @@ import org.w3c.dom.Document
/**
* Provides access to the current active browsers DOM for the currently visible page.
*/
-native("document") var document: Document = null!!
+native("document") public var document: Document = null!!
diff --git a/js/js.libraries/src/stdlib/dom.kt b/js/js.libraries/src/stdlib/dom.kt
index c2e55bf2e5c..991ddebc999 100644
--- a/js/js.libraries/src/stdlib/dom.kt
+++ b/js/js.libraries/src/stdlib/dom.kt
@@ -3,7 +3,7 @@ package kotlin.dom
import org.w3c.dom.Document
import org.w3c.dom.Node
-fun createDocument(): Document {
+public fun createDocument(): Document {
return browser.document.implementation.createDocument(null, null, null)
}
diff --git a/js/js.tests/test/org/jetbrains/k2js/test/config/TestConfig.java b/js/js.tests/test/org/jetbrains/k2js/test/config/TestConfig.java
index b71bfed31b9..f3832533022 100644
--- a/js/js.tests/test/org/jetbrains/k2js/test/config/TestConfig.java
+++ b/js/js.tests/test/org/jetbrains/k2js/test/config/TestConfig.java
@@ -17,64 +17,39 @@
package org.jetbrains.k2js.test.config;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetFile;
+import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.k2js.config.Config;
import org.jetbrains.k2js.config.EcmaVersion;
-import org.jetbrains.k2js.utils.JetFileUtils;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
import java.util.List;
/**
* @author Pavel Talanov
*/
-//TODO: review/refactor
-public final class TestConfig extends Config {
-
- @Nullable
- private /*var*/ List jsLibFiles = null;
-
- public TestConfig(@NotNull Project project, @NotNull EcmaVersion version) {
- super(project, version);
- }
+public class TestConfig extends Config {
@NotNull
- private static List initLibFiles(@NotNull Project project) {
- List libFiles = new ArrayList();
- for (String libFileName : LIB_FILE_NAMES) {
- JetFile file = null;
- try {
- @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
- InputStream stream = new FileInputStream(LIBRARIES_LOCATION + libFileName);
- try {
- String text = FileUtil.loadTextAndClose(stream);
- file = JetFileUtils.createPsiFile(libFileName, text, project);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- libFiles.add(file);
- }
- catch (Exception e) {
- //TODO: throw generic exception
- throw new IllegalStateException(e);
- }
- }
- return libFiles;
+ private final List jsLibFiles;
+ @NotNull
+ private final BindingContext libraryContext;
+
+ public TestConfig(@NotNull Project project, @NotNull EcmaVersion version,
+ @NotNull List files, @NotNull BindingContext context) {
+ super(project, version);
+ jsLibFiles = files;
+ libraryContext = context;
+ }
+
+ @Override
+ public BindingContext getLibraryBindingContext() {
+ return libraryContext;
}
@Override
@NotNull
public List generateLibFiles() {
- if (jsLibFiles == null) {
- jsLibFiles = initLibFiles(getProject());
- }
return jsLibFiles;
}
}
diff --git a/js/js.tests/test/org/jetbrains/k2js/test/utils/TranslationUtils.java b/js/js.tests/test/org/jetbrains/k2js/test/utils/TranslationUtils.java
index 0fb0a33aa0c..b7e2e5dec61 100644
--- a/js/js.tests/test/org/jetbrains/k2js/test/utils/TranslationUtils.java
+++ b/js/js.tests/test/org/jetbrains/k2js/test/utils/TranslationUtils.java
@@ -17,19 +17,27 @@
package org.jetbrains.k2js.test.utils;
import closurecompiler.internal.com.google.common.collect.Maps;
+import com.google.common.base.Predicates;
import com.google.dart.compiler.backend.js.ast.JsProgram;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.lang.psi.JetFile;
+import org.jetbrains.jet.lang.resolve.BindingContext;
+import org.jetbrains.k2js.analyze.AnalyzerFacadeForJS;
+import org.jetbrains.k2js.config.Config;
import org.jetbrains.k2js.config.EcmaVersion;
import org.jetbrains.k2js.facade.K2JSTranslator;
import org.jetbrains.k2js.facade.MainCallParameters;
import org.jetbrains.k2js.generate.CodeGenerator;
import org.jetbrains.k2js.test.config.TestConfig;
+import org.jetbrains.k2js.utils.JetFileUtils;
-import java.io.File;
-import java.io.FileWriter;
+import java.io.*;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -44,7 +52,33 @@ public final class TranslationUtils {
}
@NotNull
- private static final Map translators = Maps.newHashMap();
+ private static final Map testConfigs = Maps.newHashMap();
+
+ @Nullable
+ private static BindingContext libraryContext = null;
+
+ @NotNull
+ public static BindingContext getLibraryContext(@NotNull Project project, @NotNull List files) {
+ if (libraryContext == null) {
+ AnalyzeExhaust exhaust = AnalyzerFacadeForJS
+ .analyzeFiles(files, Predicates.alwaysFalse(),
+ Config.getEmptyConfig(project));
+ libraryContext = exhaust.getBindingContext();
+ AnalyzerFacadeForJS.checkForErrors(files, libraryContext);
+ }
+ return libraryContext;
+ }
+
+ @NotNull
+ public static Config getConfig(@NotNull Project project, @NotNull EcmaVersion version) {
+ List files = initLibFiles(project);
+ Config config = testConfigs.get(version);
+ if (config == null) {
+ config = new TestConfig(project, version, files, getLibraryContext(project, files));
+ testConfigs.put(version, config);
+ }
+ return config;
+ }
public static void translateFiles(@NotNull Project project, @NotNull List inputFiles,
@NotNull String outputFile,
@@ -64,11 +98,31 @@ public final class TranslationUtils {
@NotNull
private static K2JSTranslator getTranslator(@NotNull Project project, @NotNull EcmaVersion version) {
- K2JSTranslator translator = translators.get(version);
- if (translator == null) {
- translators.put(version, translator);
- translator = new K2JSTranslator(new TestConfig(project, version));
+ return new K2JSTranslator(getConfig(project, version));
+ }
+
+ @NotNull
+ public static List initLibFiles(@NotNull Project project) {
+ List libFiles = new ArrayList();
+ for (String libFileName : Config.LIB_FILE_NAMES) {
+ JetFile file = null;
+ try {
+ @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
+ InputStream stream = new FileInputStream(Config.LIBRARIES_LOCATION + libFileName);
+ try {
+ String text = FileUtil.loadTextAndClose(stream);
+ file = JetFileUtils.createPsiFile(libFileName, text, project);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ libFiles.add(file);
+ }
+ catch (Exception e) {
+ //TODO: throw generic exception
+ throw new IllegalStateException(e);
+ }
}
- return translator;
+ return libFiles;
}
}
diff --git a/js/js.translator/src/org/jetbrains/k2js/analyze/AnalyzerFacadeForJS.java b/js/js.translator/src/org/jetbrains/k2js/analyze/AnalyzerFacadeForJS.java
index 4477b83962c..3f956e7c2ec 100644
--- a/js/js.translator/src/org/jetbrains/k2js/analyze/AnalyzerFacadeForJS.java
+++ b/js/js.translator/src/org/jetbrains/k2js/analyze/AnalyzerFacadeForJS.java
@@ -34,7 +34,9 @@ import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetImportDirective;
import org.jetbrains.jet.lang.psi.JetPsiFactory;
import org.jetbrains.jet.lang.resolve.*;
+import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
+import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
import org.jetbrains.k2js.config.Config;
@@ -44,6 +46,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
+import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isRootNamespace;
+
/**
* @author Pavel Talanov
*/
@@ -75,13 +79,13 @@ public final class AnalyzerFacadeForJS {
return analyzeFiles(files, filesToAnalyzeCompletely, config, false);
}
+ //TODO: refactor
@NotNull
public static AnalyzeExhaust analyzeFiles(
@NotNull Collection files,
@NotNull Predicate filesToAnalyzeCompletely, @NotNull Config config,
boolean storeContextForBodiesResolve) {
Project project = config.getProject();
- BindingTraceContext bindingTraceContext = new BindingTraceContext();
final ModuleDescriptor owner = new ModuleDescriptor(Name.special(""));
@@ -90,15 +94,22 @@ public final class AnalyzerFacadeForJS {
TopDownAnalysisParameters topDownAnalysisParameters = new TopDownAnalysisParameters(
completely, false, false, Collections.emptyList());
+ BindingContext libraryBindingContext = config.getLibraryBindingContext();
+ BindingTrace trace = libraryBindingContext == null ?
+ new ObservableBindingTrace(new BindingTraceContext()) :
+ new DelegatingBindingTrace(libraryBindingContext);
InjectorForTopDownAnalyzerForJs injector = new InjectorForTopDownAnalyzerForJs(
- project, topDownAnalysisParameters, new ObservableBindingTrace(bindingTraceContext), owner,
- JsConfiguration.jsLibConfiguration(project));
+ project, topDownAnalysisParameters, trace, owner,
+ new JsConfiguration(project, libraryBindingContext));
try {
- injector.getTopDownAnalyzer().analyzeFiles(withJsLibAdded(files, config), Collections.emptyList());
+ Collection allFiles = libraryBindingContext != null ?
+ files :
+ withJsLibAdded(files, config);
+ injector.getTopDownAnalyzer().analyzeFiles(allFiles, Collections.emptyList());
BodiesResolveContext bodiesResolveContext = storeContextForBodiesResolve ?
new CachedBodiesResolveContext(injector.getTopDownAnalysisContext()) :
null;
- return AnalyzeExhaust.success(bindingTraceContext.getBindingContext(), bodiesResolveContext);
+ return AnalyzeExhaust.success(trace.getBindingContext(), bodiesResolveContext);
}
finally {
injector.destroy();
@@ -116,7 +127,7 @@ public final class AnalyzerFacadeForJS {
config.getProject(), Collections.emptyList(), completely, traceContext, bodiesResolveContext);
}
- private static void checkForErrors(@NotNull Collection allFiles, @NotNull BindingContext bindingContext) {
+ public static void checkForErrors(@NotNull Collection allFiles, @NotNull BindingContext bindingContext) {
AnalyzingUtils.throwExceptionOnErrors(bindingContext);
for (JetFile file : allFiles) {
AnalyzingUtils.checkForSyntacticErrors(file);
@@ -147,13 +158,12 @@ public final class AnalyzerFacadeForJS {
@NotNull
private final Project project;
+ @Nullable
+ private final BindingContext contextToBaseOn;
- public static JsConfiguration jsLibConfiguration(@NotNull Project project) {
- return new JsConfiguration(project);
- }
-
- private JsConfiguration(@NotNull Project project) {
+ private JsConfiguration(@NotNull Project project, @Nullable BindingContext contextToBaseOn) {
this.project = project;
+ this.contextToBaseOn = contextToBaseOn;
}
@Override
@@ -170,6 +180,16 @@ public final class AnalyzerFacadeForJS {
@NotNull WritableScope namespaceMemberScope) {
DefaultModuleConfiguration.createStandardConfiguration(project, true)
.extendNamespaceScope(trace, namespaceDescriptor, namespaceMemberScope);
+ if (contextToBaseOn == null) {
+ return;
+ }
+ if (!isRootNamespace(namespaceDescriptor)) {
+ return;
+ }
+ NamespaceDescriptor rootNamespaceScope = contextToBaseOn.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.ROOT);
+ assert rootNamespaceScope != null;
+ JetScope memberScope = rootNamespaceScope.getMemberScope();
+ namespaceMemberScope.importScope(memberScope);
}
}
}
diff --git a/js/js.translator/src/org/jetbrains/k2js/config/Config.java b/js/js.translator/src/org/jetbrains/k2js/config/Config.java
index 28a5f72b881..4edde1506d9 100644
--- a/js/js.translator/src/org/jetbrains/k2js/config/Config.java
+++ b/js/js.translator/src/org/jetbrains/k2js/config/Config.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetFile;
+import org.jetbrains.jet.lang.resolve.BindingContext;
import java.util.Arrays;
import java.util.Collections;
@@ -63,7 +64,6 @@ public abstract class Config {
"/core/core.kt",
"/core/math.kt",
"/core/json.kt",
- "/raphael/raphael.kt",
"/stdlib/JUMaps.kt",
"/stdlib/browser.kt",
"/core/dom.kt",
@@ -144,4 +144,9 @@ public abstract class Config {
}
return libFiles;
}
+
+ @Nullable
+ public BindingContext getLibraryBindingContext() {
+ return null;
+ }
}
diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java b/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java
index bf9cc18a2f6..cba33a8b40b 100644
--- a/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java
+++ b/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java
@@ -21,13 +21,17 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
-import org.jetbrains.jet.lang.psi.*;
+import org.jetbrains.jet.lang.psi.JetClass;
+import org.jetbrains.jet.lang.psi.JetDeclaration;
+import org.jetbrains.jet.lang.psi.JetFile;
+import org.jetbrains.jet.lang.psi.JetNamedFunction;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.types.JetType;
-import org.jetbrains.k2js.translate.utils.BindingUtils;
import java.util.List;
+import static org.jetbrains.k2js.translate.utils.BindingUtils.getNullableDescriptorForFunction;
+
/**
* Helps find functions which are annotated with a @Test annotation from junit
*/
@@ -36,17 +40,18 @@ public class JetTestFunctionDetector {
}
public static boolean isTest(@NotNull BindingContext bindingContext, @NotNull JetNamedFunction function) {
- FunctionDescriptor functionDescriptor = BindingUtils.getFunctionDescriptor(bindingContext, function);
- if (functionDescriptor != null) {
- List annotations = functionDescriptor.getAnnotations();
- if (annotations != null) {
- for (AnnotationDescriptor annotation : annotations) {
- // TODO ideally we should find the fully qualified name here...
- JetType type = annotation.getType();
- String name = type.toString();
- if (name.equals("Test")) {
- return true;
- }
+ FunctionDescriptor functionDescriptor = getNullableDescriptorForFunction(bindingContext, function);
+ if (functionDescriptor == null) {
+ return false;
+ }
+ List annotations = functionDescriptor.getAnnotations();
+ if (annotations != null) {
+ for (AnnotationDescriptor annotation : annotations) {
+ // TODO ideally we should find the fully qualified name here...
+ JetType type = annotation.getType();
+ String name = type.toString();
+ if (name.equals("Test")) {
+ return true;
}
}
}
@@ -70,13 +75,15 @@ public class JetTestFunctionDetector {
}
@Nullable
- private static List getTestFunctions(@NotNull BindingContext bindingContext, @NotNull List declarations) {
+ private static List getTestFunctions(@NotNull BindingContext bindingContext,
+ @NotNull List declarations) {
List answer = Lists.newArrayList();
for (JetDeclaration declaration : declarations) {
if (declaration instanceof JetClass) {
JetClass klass = (JetClass) declaration;
answer.addAll(getTestFunctions(bindingContext, klass.getDeclarations()));
- } else if (declaration instanceof JetNamedFunction) {
+ }
+ else if (declaration instanceof JetNamedFunction) {
JetNamedFunction candidateFunction = (JetNamedFunction) declaration;
if (isTest(bindingContext, candidateFunction)) {
answer.add(candidateFunction);
diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java b/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
index 063b8724b0c..10c0775ab09 100644
--- a/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
+++ b/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
@@ -358,4 +358,10 @@ public final class BindingUtils {
assert primaryConstructor != null : "Traits do not have initialize methods.";
return primaryConstructor;
}
+
+ @Nullable
+ public static SimpleFunctionDescriptor getNullableDescriptorForFunction(@NotNull BindingContext bindingContext,
+ @NotNull JetNamedFunction function) {
+ return bindingContext.get(BindingContext.FUNCTION, function);
+ }
}
diff --git a/js/js.translator/testFiles/range/cases/explicitRange.kt b/js/js.translator/testFiles/range/cases/explicitRange.kt
index 3c8595027e3..8002b6f6c5e 100644
--- a/js/js.translator/testFiles/range/cases/explicitRange.kt
+++ b/js/js.translator/testFiles/range/cases/explicitRange.kt
@@ -22,16 +22,9 @@ fun box() : Boolean {
for (i in oneToFive) {
sum += i;
}
- for (i in oneToFive) {
- print(i)
- }
if (sum != 10) return false;
return true;
}
-
-fun main() {
- box()
-}
\ No newline at end of file
diff --git a/js/js.translator/testFiles/range/cases/rangeSugarSyntax.kt b/js/js.translator/testFiles/range/cases/rangeSugarSyntax.kt
index d300924fe91..e9c9c0f5049 100644
--- a/js/js.translator/testFiles/range/cases/rangeSugarSyntax.kt
+++ b/js/js.translator/testFiles/range/cases/rangeSugarSyntax.kt
@@ -22,16 +22,9 @@ fun box() : Boolean {
for (i in oneToFive) {
sum += i;
}
- for (i in oneToFive) {
- print(i)
- }
if (sum != 15) return false;
return true;
}
-
-fun main() {
- box()
-}
\ No newline at end of file