Merge remote-tracking branch 'origin/master'
Conflicts: js/js.translator/src/org/jetbrains/k2js/translate/intrinsic/functions/factories/RangesFIF.java js/js.translator/src/org/jetbrains/k2js/translate/intrinsic/functions/patterns/NamePredicate.java
This commit is contained in:
@@ -4,7 +4,7 @@ package org.w3c.dom
|
||||
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GeneratedJavaScriptStubs.kt
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateJavaScriptStubs.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
@@ -28,11 +28,11 @@ native public trait CDATASection: Text {
|
||||
native public trait CharacterData: Node {
|
||||
public var data: String
|
||||
public val length: Int
|
||||
public fun appendData(arg1: String?): Unit = js.noImpl
|
||||
public fun deleteData(arg1: Int, arg2: Int): Unit = js.noImpl
|
||||
public fun insertData(arg1: Int, arg2: String?): Unit = js.noImpl
|
||||
public fun replaceData(arg1: Int, arg2: Int, arg3: String?): Unit = js.noImpl
|
||||
public fun substringData(arg1: Int, arg2: Int): String = js.noImpl
|
||||
public fun appendData(arg1: String?): Unit = js.noImpl
|
||||
public fun insertData(arg1: Int, arg2: String?): Unit = js.noImpl
|
||||
public fun deleteData(arg1: Int, arg2: Int): Unit = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Comment: CharacterData {
|
||||
@@ -49,21 +49,21 @@ native public trait Document: Node {
|
||||
public val xmlEncoding: String
|
||||
public var xmlStandalone: Boolean
|
||||
public var xmlVersion: String
|
||||
public fun createElement(arg1: String?): Element = js.noImpl
|
||||
public fun adoptNode(arg1: Node): Node = js.noImpl
|
||||
public fun createAttribute(arg1: String?): Attr = js.noImpl
|
||||
public fun createAttributeNS(arg1: String?, arg2: String?): Attr = js.noImpl
|
||||
public fun createCDATASection(arg1: String?): CDATASection = js.noImpl
|
||||
public fun createComment(arg1: String?): Comment = js.noImpl
|
||||
public fun createDocumentFragment(): DocumentFragment = js.noImpl
|
||||
public fun createTextNode(arg1: String?): Text = js.noImpl
|
||||
public fun createCDATASection(arg1: String?): CDATASection = js.noImpl
|
||||
public fun createProcessingInstruction(arg1: String?, arg2: String?): ProcessingInstruction = js.noImpl
|
||||
public fun createAttribute(arg1: String?): Attr = js.noImpl
|
||||
public fun createEntityReference(arg1: String?): EntityReference = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String?): NodeList = js.noImpl
|
||||
public fun importNode(arg1: Node, arg2: Boolean): Node = js.noImpl
|
||||
public fun createElement(arg1: String?): Element = js.noImpl
|
||||
public fun createElementNS(arg1: String?, arg2: String?): Element = js.noImpl
|
||||
public fun createAttributeNS(arg1: String?, arg2: String?): Attr = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String?, arg2: String?): NodeList = js.noImpl
|
||||
public fun createEntityReference(arg1: String?): EntityReference = js.noImpl
|
||||
public fun createProcessingInstruction(arg1: String?, arg2: String?): ProcessingInstruction = js.noImpl
|
||||
public fun createTextNode(arg1: String?): Text = js.noImpl
|
||||
public fun getElementById(arg1: String?): Element = js.noImpl
|
||||
public fun adoptNode(arg1: Node): Node = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String?): NodeList = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String?, arg2: String?): NodeList = js.noImpl
|
||||
public fun importNode(arg1: Node, arg2: Boolean): Node = js.noImpl
|
||||
public fun normalizeDocument(): Unit = js.noImpl
|
||||
public fun renameNode(arg1: Node, arg2: String?, arg3: String?): Node = js.noImpl
|
||||
}
|
||||
@@ -82,9 +82,9 @@ native public trait DocumentType: Node {
|
||||
|
||||
native public trait DOMConfiguration {
|
||||
public val parameterNames: DOMStringList
|
||||
public fun setParameter(arg1: String?, arg2: Any): Unit = js.noImpl
|
||||
public fun getParameter(arg1: String?): Any = js.noImpl
|
||||
public fun canSetParameter(arg1: String?, arg2: Any): Boolean = js.noImpl
|
||||
public fun getParameter(arg1: String?): Any = js.noImpl
|
||||
public fun setParameter(arg1: String?, arg2: Any): Unit = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMError {
|
||||
@@ -108,9 +108,9 @@ native public trait DOMErrorHandler {
|
||||
|
||||
native public trait DOMImplementation {
|
||||
public fun getFeature(arg1: String?, arg2: String?): Any = js.noImpl
|
||||
public fun hasFeature(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
public fun createDocumentType(arg1: String?, arg2: String?, arg3: String?): DocumentType = js.noImpl
|
||||
public fun createDocument(arg1: String?, arg2: String?, arg3: DocumentType?): Document = js.noImpl
|
||||
public fun createDocumentType(arg1: String?, arg2: String?, arg3: String?): DocumentType = js.noImpl
|
||||
public fun hasFeature(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMImplementationList {
|
||||
@@ -137,18 +137,18 @@ native public trait Element: Node {
|
||||
public val schemaTypeInfo: TypeInfo
|
||||
public val tagName: String
|
||||
public fun getAttribute(arg1: String?): String = js.noImpl
|
||||
public fun setAttribute(arg1: String?, arg2: String?): Unit = js.noImpl
|
||||
public fun removeAttribute(arg1: String?): Unit = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String?): NodeList = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String?, arg2: String?): NodeList = js.noImpl
|
||||
public fun getAttributeNode(arg1: String?): Attr = js.noImpl
|
||||
public fun removeAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
public fun getAttributeNS(arg1: String?, arg2: String?): String = js.noImpl
|
||||
public fun setAttributeNS(arg1: String?, arg2: String?, arg3: String?): Unit = js.noImpl
|
||||
public fun removeAttributeNS(arg1: String?, arg2: String?): Unit = js.noImpl
|
||||
public fun getAttributeNode(arg1: String?): Attr = js.noImpl
|
||||
public fun getAttributeNodeNS(arg1: String?, arg2: String?): Attr = js.noImpl
|
||||
public fun hasAttribute(arg1: String?): Boolean = js.noImpl
|
||||
public fun hasAttributeNS(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
public fun removeAttribute(arg1: String?): Unit = js.noImpl
|
||||
public fun removeAttributeNS(arg1: String?, arg2: String?): Unit = js.noImpl
|
||||
public fun removeAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
public fun setAttribute(arg1: String?, arg2: String?): Unit = js.noImpl
|
||||
public fun setAttributeNS(arg1: String?, arg2: String?, arg3: String?): Unit = js.noImpl
|
||||
public fun setIdAttribute(arg1: String?, arg2: Boolean): Unit = js.noImpl
|
||||
public fun setIdAttributeNS(arg1: String?, arg2: String?, arg3: Boolean): Unit = js.noImpl
|
||||
public fun setIdAttributeNode(arg1: Attr, arg2: Boolean): Unit = js.noImpl
|
||||
@@ -180,8 +180,8 @@ native public trait NamedNodeMap {
|
||||
public val length: Int
|
||||
public fun item(arg1: Int): Node = js.noImpl
|
||||
public fun getNamedItem(arg1: String?): Node = js.noImpl
|
||||
public fun removeNamedItem(arg1: String?): Node = js.noImpl
|
||||
public fun getNamedItemNS(arg1: String?, arg2: String?): Node = js.noImpl
|
||||
public fun removeNamedItem(arg1: String?): Node = js.noImpl
|
||||
public fun removeNamedItemNS(arg1: String?, arg2: String?): Node = js.noImpl
|
||||
public fun setNamedItem(arg1: Node): Node = js.noImpl
|
||||
public fun setNamedItemNS(arg1: Node): Node = js.noImpl
|
||||
@@ -204,24 +204,24 @@ native public trait Node {
|
||||
public var prefix: String
|
||||
public val previousSibling: Node
|
||||
public var textContent: String
|
||||
public fun normalize(): Unit = js.noImpl
|
||||
public fun isSupported(arg1: String?, arg2: String?): Boolean = js.noImpl
|
||||
public fun getUserData(arg1: String?): Any = js.noImpl
|
||||
public fun setUserData(arg1: String?, arg2: Any, arg3: UserDataHandler): Any = js.noImpl
|
||||
public fun getFeature(arg1: String?, arg2: String?): Any = js.noImpl
|
||||
public fun hasAttributes(): Boolean = js.noImpl
|
||||
public fun removeChild(arg1: Node): Node = js.noImpl
|
||||
public fun replaceChild(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun insertBefore(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun normalize(): Unit = js.noImpl
|
||||
public fun appendChild(arg1: Node): Node = js.noImpl
|
||||
public fun hasChildNodes(): Boolean = js.noImpl
|
||||
public fun cloneNode(arg1: Boolean): Node = js.noImpl
|
||||
public fun compareDocumentPosition(arg1: Node): Short = js.noImpl
|
||||
public fun isSameNode(arg1: Node): Boolean = js.noImpl
|
||||
public fun lookupPrefix(arg1: String?): String = js.noImpl
|
||||
public fun getFeature(arg1: String?, arg2: String?): Any = js.noImpl
|
||||
public fun getUserData(arg1: String?): Any = js.noImpl
|
||||
public fun hasAttributes(): Boolean = js.noImpl
|
||||
public fun hasChildNodes(): Boolean = js.noImpl
|
||||
public fun insertBefore(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun isDefaultNamespace(arg1: String?): Boolean = js.noImpl
|
||||
public fun lookupNamespaceURI(arg1: String?): String = js.noImpl
|
||||
public fun isEqualNode(arg1: Node): Boolean = js.noImpl
|
||||
public fun isSameNode(arg1: Node): Boolean = js.noImpl
|
||||
public fun lookupNamespaceURI(arg1: String?): String = js.noImpl
|
||||
public fun lookupPrefix(arg1: String?): String = js.noImpl
|
||||
public fun removeChild(arg1: Node): Node = js.noImpl
|
||||
public fun replaceChild(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun setUserData(arg1: String?, arg2: Any, arg3: UserDataHandler): Any = js.noImpl
|
||||
|
||||
public class object {
|
||||
public val ELEMENT_NODE: Short = 1
|
||||
@@ -262,9 +262,9 @@ native public trait ProcessingInstruction: Node {
|
||||
|
||||
native public trait Text: CharacterData {
|
||||
public val wholeText: String
|
||||
public fun splitText(arg1: Int): Text = js.noImpl
|
||||
public fun isElementContentWhitespace(): Boolean = js.noImpl
|
||||
public fun replaceWholeText(arg1: String?): Text = js.noImpl
|
||||
public fun splitText(arg1: Int): Text = js.noImpl
|
||||
}
|
||||
|
||||
native public trait TypeInfo {
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.w3c.dom.views.*
|
||||
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GeneratedJavaScriptStubs.kt
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateJavaScriptStubs.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
@@ -27,9 +27,9 @@ native public trait Event {
|
||||
public val eventPhase: Short
|
||||
public val target: EventTarget
|
||||
public val timeStamp: Long
|
||||
public fun stopPropagation(): Unit = js.noImpl
|
||||
public fun preventDefault(): Unit = js.noImpl
|
||||
public fun initEvent(arg1: String?, arg2: Boolean, arg3: Boolean): Unit = js.noImpl
|
||||
public fun preventDefault(): Unit = js.noImpl
|
||||
public fun stopPropagation(): Unit = js.noImpl
|
||||
|
||||
public class object {
|
||||
public val CAPTURING_PHASE: Short = 1
|
||||
@@ -39,8 +39,8 @@ native public trait Event {
|
||||
}
|
||||
|
||||
native public trait EventTarget {
|
||||
public fun dispatchEvent(arg1: Event?): Boolean = js.noImpl
|
||||
public fun addEventListener(arg1: String?, arg2: EventListener, arg3: Boolean): Unit = js.noImpl
|
||||
public fun dispatchEvent(arg1: Event?): Boolean = js.noImpl
|
||||
public fun removeEventListener(arg1: String?, arg2: EventListener, arg3: Boolean): Unit = js.noImpl
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public object Collections {
|
||||
library
|
||||
public fun <T> reverse(list: List<T>): Unit {
|
||||
val size = list.size()
|
||||
for (i in 0.upto(size / 2)) {
|
||||
for (i in 0.rangeTo(size / 2)) {
|
||||
val i2 = size - i
|
||||
val tmp = list[i]
|
||||
list[i] = list[i2]
|
||||
|
||||
@@ -10,7 +10,7 @@ public inline fun <T> java.util.List<T>.equals(that: List<T>): Boolean {
|
||||
val s1 = this.size()
|
||||
val s2 = that.size()
|
||||
if (s1 == s2) {
|
||||
for (i in 0.upto(s1)) {
|
||||
for (i in 0.rangeTo(s1)) {
|
||||
val elem1 = this.get(i)
|
||||
val elem2 = that.get(i)
|
||||
if (elem1 != elem2) {
|
||||
|
||||
@@ -49,11 +49,7 @@ public final class RangeTest extends SingleFileTranslationTest {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testIntDownTo() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testUpToDownToDoNotIterate() throws Exception {
|
||||
public void testRangeToDoesNotIterate() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -50,7 +50,6 @@ public final class FunctionIntrinsics {
|
||||
register(ArrayFIF.INSTANCE);
|
||||
register(TopLevelFIF.INSTANCE);
|
||||
register(NumberConversionFIF.INSTANCE);
|
||||
register(RangesFIF.INSTANCE);
|
||||
}
|
||||
|
||||
private void register(@NotNull FunctionIntrinsicFactory instance) {
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.k2js.translate.intrinsic.functions.factories;
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.JsNameRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.k2js.translate.intrinsic.functions.basic.CallStandardMethodIntrinsic;
|
||||
|
||||
import static org.jetbrains.k2js.translate.intrinsic.functions.patterns.PatternBuilder.pattern;
|
||||
|
||||
/**
|
||||
* @author Pavel Talanov
|
||||
*/
|
||||
public final class RangesFIF extends CompositeFIF {
|
||||
|
||||
@NotNull
|
||||
public static final FunctionIntrinsicFactory INSTANCE = new RangesFIF();
|
||||
|
||||
private RangesFIF() {
|
||||
add(pattern("Int.upto"), new CallStandardMethodIntrinsic(new JsNameRef("intUpto", "Kotlin"), true, 1));
|
||||
add(pattern("Int.downto"), new CallStandardMethodIntrinsic(new JsNameRef("intDownto", "Kotlin"), true, 1));
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -18,9 +18,12 @@ package org.jetbrains.k2js.translate.intrinsic.functions.patterns;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -32,7 +35,13 @@ import java.util.List;
|
||||
public final class NamePredicate implements Predicate<Name> {
|
||||
|
||||
@NotNull
|
||||
public static final NamePredicate PRIMITIVE_NUMBERS = new NamePredicate("Int", "Double", "Float", "Long", "Short", "Byte");
|
||||
public static final NamePredicate PRIMITIVE_NUMBERS = new NamePredicate(
|
||||
ContainerUtil.map(PrimitiveType.NUMBER_TYPES, new Function<PrimitiveType, String>() {
|
||||
@Override
|
||||
public String fun(PrimitiveType type) {
|
||||
return type.getTypeName().getName();
|
||||
}
|
||||
}));
|
||||
|
||||
@NotNull
|
||||
private final List<Name> validNames = Lists.newArrayList();
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package foo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box() : Boolean {
|
||||
var elems = ArrayList<Int>()
|
||||
for (i in 4 downto 0) {
|
||||
elems.add(i)
|
||||
}
|
||||
return elems[0] == 4 && elems[1] == 3 && elems[2] == 2 && elems[3] == 1 && elems[4] == 0
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import java.util.ArrayList
|
||||
|
||||
fun box() : Boolean {
|
||||
var elems = ArrayList<Int>()
|
||||
for (i in 0 upto 5) {
|
||||
for (i in 0 rangeTo 5) {
|
||||
elems.add(i)
|
||||
}
|
||||
return elems[0] == 0 && elems[1] == 1 && elems[2] == 2 && elems[3] == 3 && elems[4] == 4 && elems[5] == 5
|
||||
|
||||
+1
-4
@@ -3,10 +3,7 @@ package foo
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box() : Boolean {
|
||||
for (i in 0 upto -1) {
|
||||
return false
|
||||
}
|
||||
for (i in 0 downto 1) {
|
||||
for (i in 0 rangeTo -1) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
Reference in New Issue
Block a user