JS frontend: allow to omit body for native functions and initializer for native properties. Additionally suppress UNUSED_PARAM for new nativeX annotations too.
This commit is contained in:
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.kotlin.nativeDeclarations
|
|||||||
import org.jetbrains.jet.lang.resolve.diagnostics.DiagnosticsWithSuppression
|
import org.jetbrains.jet.lang.resolve.diagnostics.DiagnosticsWithSuppression
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||||
import org.jetbrains.jet.lang.diagnostics.Errors
|
|
||||||
import org.jetbrains.jet.lang.resolve.AnnotationChecker
|
import org.jetbrains.jet.lang.resolve.AnnotationChecker
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||||
@@ -30,6 +29,8 @@ import org.jetbrains.jet.lang.descriptors.Modality
|
|||||||
import org.jetbrains.jet.lang.resolve.java.diagnostics.ErrorsJvm
|
import org.jetbrains.jet.lang.resolve.java.diagnostics.ErrorsJvm
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
||||||
import org.jetbrains.jet.lang.resolve.annotations.hasInlineAnnotation
|
import org.jetbrains.jet.lang.resolve.annotations.hasInlineAnnotation
|
||||||
|
import org.jetbrains.jet.lang.resolve.diagnostics.SuppressDiagnosticsByAnnotations
|
||||||
|
import org.jetbrains.jet.lang.resolve.diagnostics.FUNCTION_NO_BODY_ERRORS
|
||||||
|
|
||||||
private val NATIVE_ANNOTATION_CLASS_NAME = FqName("kotlin.jvm.native")
|
private val NATIVE_ANNOTATION_CLASS_NAME = FqName("kotlin.jvm.native")
|
||||||
|
|
||||||
@@ -37,20 +38,7 @@ public fun DeclarationDescriptor.hasNativeAnnotation(): Boolean {
|
|||||||
return getAnnotations().findAnnotation(NATIVE_ANNOTATION_CLASS_NAME) != null
|
return getAnnotations().findAnnotation(NATIVE_ANNOTATION_CLASS_NAME) != null
|
||||||
}
|
}
|
||||||
|
|
||||||
class SuppressNoBodyErrorsForNativeDeclarations : DiagnosticsWithSuppression.SuppressStringProvider {
|
public class SuppressNoBodyErrorsForNativeDeclarations : SuppressDiagnosticsByAnnotations(FUNCTION_NO_BODY_ERRORS, NATIVE_ANNOTATION_CLASS_NAME)
|
||||||
override fun get(annotationDescriptor: AnnotationDescriptor): List<String> {
|
|
||||||
val descriptor = DescriptorUtils.getClassDescriptorForType(annotationDescriptor.getType())
|
|
||||||
if (NATIVE_ANNOTATION_CLASS_NAME.asString() == DescriptorUtils.getFqName(descriptor).asString()) {
|
|
||||||
return listOf(
|
|
||||||
Errors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY.getName().toLowerCase(),
|
|
||||||
Errors.NON_MEMBER_FUNCTION_NO_BODY.getName().toLowerCase(),
|
|
||||||
Errors.FINAL_FUNCTION_WITH_NO_BODY.getName().toLowerCase()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return listOf()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NativeFunChecker : AnnotationChecker {
|
public class NativeFunChecker : AnnotationChecker {
|
||||||
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
|
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
|
||||||
|
|||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.jet.lang.resolve.diagnostics
|
||||||
|
|
||||||
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.Errors
|
||||||
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.Diagnostic
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||||
|
import org.jetbrains.jet.lang.psi.JetFunction
|
||||||
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory1
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory0
|
||||||
|
|
||||||
|
public val FUNCTION_NO_BODY_ERRORS: List<DiagnosticFactory1<JetFunction, SimpleFunctionDescriptor>> =
|
||||||
|
listOf(Errors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY, Errors.NON_MEMBER_FUNCTION_NO_BODY, Errors.FINAL_FUNCTION_WITH_NO_BODY)
|
||||||
|
|
||||||
|
public val PROPERTY_NOT_INITIALIZED_ERRORS: List<DiagnosticFactory0<JetProperty>> =
|
||||||
|
listOf(Errors.MUST_BE_INITIALIZED, Errors.MUST_BE_INITIALIZED_OR_BE_ABSTRACT)
|
||||||
|
|
||||||
|
public abstract class SuppressDiagnosticsByAnnotations(
|
||||||
|
diagnosticsToSuppress: List<DiagnosticFactory<out Diagnostic>>,
|
||||||
|
vararg annotationsFqName: FqName
|
||||||
|
) : DiagnosticsWithSuppression.SuppressStringProvider {
|
||||||
|
|
||||||
|
private val annotationsFqName = annotationsFqName
|
||||||
|
private val stringsToSuppress = diagnosticsToSuppress.map { it.getName().toLowerCase() }
|
||||||
|
private val expectedFqNames = annotationsFqName.map { it.toString() }
|
||||||
|
|
||||||
|
override fun get(annotationDescriptor: AnnotationDescriptor): List<String> {
|
||||||
|
val descriptor = DescriptorUtils.getClassDescriptorForType(annotationDescriptor.getType())
|
||||||
|
val actualFqName = DescriptorUtils.getFqName(descriptor).asString()
|
||||||
|
|
||||||
|
if (expectedFqNames.any { it == actualFqName }) return stringsToSuppress
|
||||||
|
|
||||||
|
return listOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
$TESTDATA_DIR$/nativeDeclarations.kt
|
|
||||||
-output
|
|
||||||
$TEMP_DIR$/out.js
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
native
|
||||||
|
val baz: Int
|
||||||
|
native
|
||||||
|
val boo: Int = noImpl
|
||||||
|
|
||||||
|
native
|
||||||
|
val Int.baz: Int
|
||||||
|
|
||||||
|
native
|
||||||
|
fun foo()
|
||||||
|
native
|
||||||
|
fun bar() {}
|
||||||
|
|
||||||
|
native
|
||||||
|
fun String.foo(): Int
|
||||||
|
native
|
||||||
|
fun String.bar(): Int = noImpl
|
||||||
|
|
||||||
|
native
|
||||||
|
trait T {
|
||||||
|
val baz: Int
|
||||||
|
|
||||||
|
fun foo()
|
||||||
|
fun bar() {}
|
||||||
|
|
||||||
|
class object {
|
||||||
|
val baz: Int
|
||||||
|
val boo: Int = noImpl
|
||||||
|
|
||||||
|
fun foo()
|
||||||
|
fun bar(): String = noImpl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
native
|
||||||
|
class C {
|
||||||
|
val baz: Int
|
||||||
|
val boo: Int = noImpl
|
||||||
|
|
||||||
|
fun foo()
|
||||||
|
fun bar() {}
|
||||||
|
|
||||||
|
class object {
|
||||||
|
val baz: Int
|
||||||
|
val boo: Int = noImpl
|
||||||
|
|
||||||
|
fun foo()
|
||||||
|
fun bar(): String = noImpl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
native
|
||||||
|
object O {
|
||||||
|
val baz: Int
|
||||||
|
val boo: Int = noImpl
|
||||||
|
|
||||||
|
fun foo(s: String): String
|
||||||
|
fun bar(s: String): String = noImpl
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
[native]
|
||||||
|
class Local {
|
||||||
|
val baz: Int
|
||||||
|
val boo: Int = noImpl
|
||||||
|
|
||||||
|
fun foo()
|
||||||
|
fun bar() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.native() internal val baz: kotlin.Int
|
||||||
|
kotlin.js.native() internal val boo: kotlin.Int
|
||||||
|
kotlin.js.native() internal val kotlin.Int.baz: kotlin.Int
|
||||||
|
kotlin.js.native() internal fun bar(): kotlin.Unit
|
||||||
|
kotlin.js.native() internal fun foo(): kotlin.Unit
|
||||||
|
internal fun test(): kotlin.Unit
|
||||||
|
kotlin.js.native() internal fun kotlin.String.bar(): kotlin.Int
|
||||||
|
kotlin.js.native() internal fun kotlin.String.foo(): kotlin.Int
|
||||||
|
|
||||||
|
kotlin.js.native() internal final class C {
|
||||||
|
public constructor C()
|
||||||
|
internal final val baz: kotlin.Int
|
||||||
|
internal final val boo: kotlin.Int
|
||||||
|
internal final fun bar(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal final fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
internal class object <class-object-for-C> {
|
||||||
|
private constructor <class-object-for-C>()
|
||||||
|
internal final val baz: kotlin.Int
|
||||||
|
internal final val boo: kotlin.Int
|
||||||
|
internal final fun bar(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal final fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin.js.native() internal object O {
|
||||||
|
private constructor O()
|
||||||
|
internal final val baz: kotlin.Int
|
||||||
|
internal final val boo: kotlin.Int
|
||||||
|
internal final fun bar(/*0*/ s: kotlin.String): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal final fun foo(/*0*/ s: kotlin.String): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-O> : O {
|
||||||
|
private constructor <class-object-for-O>()
|
||||||
|
internal final override /*1*/ /*fake_override*/ val baz: kotlin.Int
|
||||||
|
internal final override /*1*/ /*fake_override*/ val boo: kotlin.Int
|
||||||
|
internal final override /*1*/ /*fake_override*/ fun bar(/*0*/ s: kotlin.String): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal final override /*1*/ /*fake_override*/ fun foo(/*0*/ s: kotlin.String): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin.js.native() internal trait T {
|
||||||
|
internal abstract val baz: kotlin.Int
|
||||||
|
internal open fun bar(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal abstract fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
internal class object <class-object-for-T> {
|
||||||
|
private constructor <class-object-for-T>()
|
||||||
|
internal final val baz: kotlin.Int
|
||||||
|
internal final val boo: kotlin.Int
|
||||||
|
internal final fun bar(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal final fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
nativeGetter
|
||||||
|
fun String.foo(n: Int): Int?
|
||||||
|
nativeGetter
|
||||||
|
fun String.bar(n: Int): Int? = noImpl
|
||||||
|
|
||||||
|
|
||||||
|
native
|
||||||
|
trait T {
|
||||||
|
nativeGetter
|
||||||
|
fun foo(d: Double): String?
|
||||||
|
nativeGetter
|
||||||
|
fun bar(d: Double): String? = noImpl
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.nativeGetter() internal fun kotlin.String.bar(/*0*/ n: kotlin.Int): kotlin.Int?
|
||||||
|
kotlin.js.nativeGetter() internal fun kotlin.String.foo(/*0*/ n: kotlin.Int): kotlin.Int?
|
||||||
|
|
||||||
|
kotlin.js.native() internal trait T {
|
||||||
|
kotlin.js.nativeGetter() internal open fun bar(/*0*/ d: kotlin.Double): kotlin.String?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
kotlin.js.nativeGetter() internal abstract fun foo(/*0*/ d: kotlin.Double): kotlin.String?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
nativeInvoke
|
||||||
|
fun String.foo(): Int
|
||||||
|
nativeInvoke
|
||||||
|
fun String.bar(): Int = noImpl
|
||||||
|
|
||||||
|
|
||||||
|
native
|
||||||
|
object O {
|
||||||
|
nativeInvoke
|
||||||
|
fun foo()
|
||||||
|
nativeInvoke
|
||||||
|
fun bar() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.nativeInvoke() internal fun kotlin.String.bar(): kotlin.Int
|
||||||
|
kotlin.js.nativeInvoke() internal fun kotlin.String.foo(): kotlin.Int
|
||||||
|
|
||||||
|
kotlin.js.native() internal object O {
|
||||||
|
private constructor O()
|
||||||
|
kotlin.js.nativeInvoke() internal final fun bar(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
kotlin.js.nativeInvoke() internal final fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-O> : O {
|
||||||
|
private constructor <class-object-for-O>()
|
||||||
|
kotlin.js.nativeInvoke() internal final override /*1*/ /*fake_override*/ fun bar(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
kotlin.js.nativeInvoke() internal final override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
nativeSetter
|
||||||
|
fun String.foo(n: Int, v: Any)
|
||||||
|
nativeSetter
|
||||||
|
fun String.bar(n: Int, v: Any) {}
|
||||||
|
|
||||||
|
|
||||||
|
native
|
||||||
|
class C {
|
||||||
|
nativeSetter
|
||||||
|
fun foo(d: Double, v: Any): String?
|
||||||
|
nativeSetter
|
||||||
|
fun bar(d: Double, v: Any): String? = noImpl
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.nativeSetter() internal fun kotlin.String.bar(/*0*/ n: kotlin.Int, /*1*/ v: kotlin.Any): kotlin.Unit
|
||||||
|
kotlin.js.nativeSetter() internal fun kotlin.String.foo(/*0*/ n: kotlin.Int, /*1*/ v: kotlin.Any): kotlin.Unit
|
||||||
|
|
||||||
|
kotlin.js.native() internal final class C {
|
||||||
|
public constructor C()
|
||||||
|
kotlin.js.nativeSetter() internal final fun bar(/*0*/ d: kotlin.Double, /*1*/ v: kotlin.Any): kotlin.String?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
kotlin.js.nativeSetter() internal final fun foo(/*0*/ d: kotlin.Double, /*1*/ v: kotlin.Any): kotlin.String?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
native
|
native
|
||||||
fun foo(a: String): Int = noImpl
|
fun foo(a: String): Int = noImpl
|
||||||
|
|
||||||
|
native
|
||||||
|
fun Int.foo(a: String): Int = noImpl
|
||||||
|
|
||||||
native
|
native
|
||||||
class Bar(b: Int, c: Char) {
|
class Bar(b: Int, c: Char) {
|
||||||
fun baz(d: Int) {}
|
fun baz(d: Int) {}
|
||||||
@@ -12,4 +15,4 @@ object Obj {
|
|||||||
object Nested {
|
object Nested {
|
||||||
fun test2(g: Int) {}
|
fun test2(g: Int) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.native() internal fun foo(/*0*/ a: kotlin.String): kotlin.Int
|
||||||
|
kotlin.js.native() internal fun kotlin.Int.foo(/*0*/ a: kotlin.String): kotlin.Int
|
||||||
|
|
||||||
|
kotlin.js.native() internal final class Bar {
|
||||||
|
public constructor Bar(/*0*/ b: kotlin.Int, /*1*/ c: kotlin.Char)
|
||||||
|
internal final fun baz(/*0*/ d: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin.js.native() internal object Obj {
|
||||||
|
private constructor Obj()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
internal final fun test1(/*0*/ e: kotlin.String): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Obj> : Obj {
|
||||||
|
private constructor <class-object-for-Obj>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
internal final override /*1*/ /*fake_override*/ fun test1(/*0*/ e: kotlin.String): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal object Nested {
|
||||||
|
private constructor Nested()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
internal final fun test2(/*0*/ g: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Nested> : Obj.Nested {
|
||||||
|
private constructor <class-object-for-Nested>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
internal final override /*1*/ /*fake_override*/ fun test2(/*0*/ g: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
nativeGetter
|
||||||
|
fun Int.foo(a: String): Int? = noImpl
|
||||||
|
|
||||||
|
native
|
||||||
|
class Bar(b: Int, c: Char) {
|
||||||
|
nativeGetter
|
||||||
|
fun baz(d: Int): Any? = noImpl
|
||||||
|
}
|
||||||
|
|
||||||
|
native
|
||||||
|
object Obj {
|
||||||
|
nativeGetter
|
||||||
|
fun test1(e: String): String? = noImpl
|
||||||
|
|
||||||
|
object Nested {
|
||||||
|
nativeGetter
|
||||||
|
fun test2(g: Int): Any? = noImpl
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.nativeGetter() internal fun kotlin.Int.foo(/*0*/ a: kotlin.String): kotlin.Int?
|
||||||
|
|
||||||
|
kotlin.js.native() internal final class Bar {
|
||||||
|
public constructor Bar(/*0*/ b: kotlin.Int, /*1*/ c: kotlin.Char)
|
||||||
|
kotlin.js.nativeGetter() internal final fun baz(/*0*/ d: kotlin.Int): kotlin.Any?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin.js.native() internal object Obj {
|
||||||
|
private constructor Obj()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeGetter() internal final fun test1(/*0*/ e: kotlin.String): kotlin.String?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Obj> : Obj {
|
||||||
|
private constructor <class-object-for-Obj>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeGetter() internal final override /*1*/ /*fake_override*/ fun test1(/*0*/ e: kotlin.String): kotlin.String?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal object Nested {
|
||||||
|
private constructor Nested()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeGetter() internal final fun test2(/*0*/ g: kotlin.Int): kotlin.Any?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Nested> : Obj.Nested {
|
||||||
|
private constructor <class-object-for-Nested>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeGetter() internal final override /*1*/ /*fake_override*/ fun test2(/*0*/ g: kotlin.Int): kotlin.Any?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
nativeInvoke
|
||||||
|
fun Int.foo(a: String): Int = noImpl
|
||||||
|
|
||||||
|
native
|
||||||
|
class Bar(b: Int, c: Char) {
|
||||||
|
nativeInvoke
|
||||||
|
fun baz(d: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
native
|
||||||
|
object Obj {
|
||||||
|
nativeInvoke
|
||||||
|
fun test1(e: String) {}
|
||||||
|
|
||||||
|
object Nested {
|
||||||
|
nativeInvoke
|
||||||
|
fun test2(g: Int) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.nativeInvoke() internal fun kotlin.Int.foo(/*0*/ a: kotlin.String): kotlin.Int
|
||||||
|
|
||||||
|
kotlin.js.native() internal final class Bar {
|
||||||
|
public constructor Bar(/*0*/ b: kotlin.Int, /*1*/ c: kotlin.Char)
|
||||||
|
kotlin.js.nativeInvoke() internal final fun baz(/*0*/ d: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin.js.native() internal object Obj {
|
||||||
|
private constructor Obj()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeInvoke() internal final fun test1(/*0*/ e: kotlin.String): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Obj> : Obj {
|
||||||
|
private constructor <class-object-for-Obj>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeInvoke() internal final override /*1*/ /*fake_override*/ fun test1(/*0*/ e: kotlin.String): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal object Nested {
|
||||||
|
private constructor Nested()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeInvoke() internal final fun test2(/*0*/ g: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Nested> : Obj.Nested {
|
||||||
|
private constructor <class-object-for-Nested>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeInvoke() internal final override /*1*/ /*fake_override*/ fun test2(/*0*/ g: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
nativeSetter
|
||||||
|
fun Int.foo(a: String, v: Int): Int = noImpl
|
||||||
|
|
||||||
|
native
|
||||||
|
class Bar(b: Int, c: Char) {
|
||||||
|
nativeSetter
|
||||||
|
fun baz(d: Int, v: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
native
|
||||||
|
object Obj {
|
||||||
|
nativeSetter
|
||||||
|
fun test1(e: String, v: Any) {}
|
||||||
|
|
||||||
|
object Nested {
|
||||||
|
nativeSetter
|
||||||
|
fun test2(g: Int, v: Any) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
kotlin.js.nativeSetter() internal fun kotlin.Int.foo(/*0*/ a: kotlin.String, /*1*/ v: kotlin.Int): kotlin.Int
|
||||||
|
|
||||||
|
kotlin.js.native() internal final class Bar {
|
||||||
|
public constructor Bar(/*0*/ b: kotlin.Int, /*1*/ c: kotlin.Char)
|
||||||
|
kotlin.js.nativeSetter() internal final fun baz(/*0*/ d: kotlin.Int, /*1*/ v: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin.js.native() internal object Obj {
|
||||||
|
private constructor Obj()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeSetter() internal final fun test1(/*0*/ e: kotlin.String, /*1*/ v: kotlin.Any): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Obj> : Obj {
|
||||||
|
private constructor <class-object-for-Obj>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeSetter() internal final override /*1*/ /*fake_override*/ fun test1(/*0*/ e: kotlin.String, /*1*/ v: kotlin.Any): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal object Nested {
|
||||||
|
private constructor Nested()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeSetter() internal final fun test2(/*0*/ g: kotlin.Int, /*1*/ v: kotlin.Any): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public class object <class-object-for-Nested> : Obj.Nested {
|
||||||
|
private constructor <class-object-for-Nested>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
kotlin.js.nativeSetter() internal final override /*1*/ /*fake_override*/ fun test2(/*0*/ g: kotlin.Int, /*1*/ v: kotlin.Any): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+67
-1
@@ -228,7 +228,7 @@ public class JetDiagnosticsTestWithJsStdLibGenerated extends AbstractJetDiagnost
|
|||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native")
|
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@InnerTestClasses({Native.NativeGetter.class, Native.NativeInvoke.class, Native.NativeSetter.class})
|
@InnerTestClasses({Native.NativeGetter.class, Native.NativeInvoke.class, Native.NativeSetter.class, Native.OptionlBody.class, Native.UnusedParam.class})
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class Native extends AbstractJetDiagnosticsTestWithJsStdLib {
|
public static class Native extends AbstractJetDiagnosticsTestWithJsStdLib {
|
||||||
public void testAllFilesPresentInNative() throws Exception {
|
public void testAllFilesPresentInNative() throws Exception {
|
||||||
@@ -441,5 +441,71 @@ public class JetDiagnosticsTestWithJsStdLibGenerated extends AbstractJetDiagnost
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/optionlBody")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class OptionlBody extends AbstractJetDiagnosticsTestWithJsStdLib {
|
||||||
|
public void testAllFilesPresentInOptionlBody() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/native/optionlBody"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("native.kt")
|
||||||
|
public void testNative() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/optionlBody/native.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeGetter.kt")
|
||||||
|
public void testNativeGetter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/optionlBody/nativeGetter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeInvoke.kt")
|
||||||
|
public void testNativeInvoke() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/optionlBody/nativeInvoke.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeSetter.kt")
|
||||||
|
public void testNativeSetter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/optionlBody/nativeSetter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/unusedParam")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class UnusedParam extends AbstractJetDiagnosticsTestWithJsStdLib {
|
||||||
|
public void testAllFilesPresentInUnusedParam() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/native/unusedParam"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("native.kt")
|
||||||
|
public void testNative() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/unusedParam/native.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeGetter.kt")
|
||||||
|
public void testNativeGetter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/unusedParam/nativeGetter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeInvoke.kt")
|
||||||
|
public void testNativeInvoke() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/unusedParam/nativeInvoke.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeSetter.kt")
|
||||||
|
public void testNativeSetter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/unusedParam/nativeSetter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,12 +192,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
|||||||
doJsTest(fileName);
|
doJsTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("nativeDeclarations.args")
|
|
||||||
public void testNativeDeclarations() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/nativeDeclarations.args");
|
|
||||||
doJsTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("notValidLibraryDir.args")
|
@TestMetadata("notValidLibraryDir.args")
|
||||||
public void testNotValidLibraryDir() throws Exception {
|
public void testNotValidLibraryDir() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/notValidLibraryDir.args");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/notValidLibraryDir.args");
|
||||||
|
|||||||
@@ -56,13 +56,6 @@ public class K2JsCliTest extends CliBaseTest {
|
|||||||
executeCompilerCompareOutputJS();
|
executeCompilerCompareOutputJS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void nativeDeclarations() throws Exception {
|
|
||||||
executeCompilerCompareOutputJS();
|
|
||||||
|
|
||||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), "out.js").isFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withLib() throws Exception {
|
public void withLib() throws Exception {
|
||||||
executeCompilerCompareOutputJS();
|
executeCompilerCompareOutputJS();
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||||
<defaultErrorMessages implementation="org.jetbrains.k2js.resolve.diagnostics.DefaultErrorMessagesJs"/>
|
<defaultErrorMessages implementation="org.jetbrains.k2js.resolve.diagnostics.DefaultErrorMessagesJs"/>
|
||||||
<suppressStringProvider implementation="org.jetbrains.k2js.analyze.SuppressUnusedParameterForJsNative"/>
|
<suppressStringProvider implementation="org.jetbrains.k2js.analyze.SuppressUnusedParameterForJsNative"/>
|
||||||
|
<suppressStringProvider implementation="org.jetbrains.k2js.analyze.SuppressNoBodyErrorsForNativeDeclarations"/>
|
||||||
|
<diagnosticSuppressor implementation="org.jetbrains.k2js.analyze.SuppressUninitializedErrorsForNativeDeclarations"/>
|
||||||
<diagnosticSuppressor implementation="org.jetbrains.k2js.analyze.SuppressWarningsFromExternalModules"/>
|
<diagnosticSuppressor implementation="org.jetbrains.k2js.analyze.SuppressWarningsFromExternalModules"/>
|
||||||
</extensions>
|
</extensions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|||||||
@@ -20,24 +20,40 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
|||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||||
import org.jetbrains.jet.lang.diagnostics.Errors
|
import org.jetbrains.jet.lang.diagnostics.Errors
|
||||||
import org.jetbrains.jet.lang.resolve.diagnostics.DiagnosticsWithSuppression
|
import org.jetbrains.jet.lang.resolve.diagnostics.DiagnosticsWithSuppression
|
||||||
import org.jetbrains.k2js.PredefinedAnnotation
|
import org.jetbrains.k2js.PredefinedAnnotation.*
|
||||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic
|
import org.jetbrains.jet.lang.diagnostics.Diagnostic
|
||||||
import org.jetbrains.jet.lang.diagnostics.Severity
|
import org.jetbrains.jet.lang.diagnostics.Severity
|
||||||
import org.jetbrains.jet.lang.psi.JetFile
|
import org.jetbrains.jet.lang.psi.JetFile
|
||||||
import org.jetbrains.k2js.config.LibrarySourcesConfig
|
import org.jetbrains.k2js.config.LibrarySourcesConfig
|
||||||
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters1
|
||||||
|
import org.jetbrains.k2js.translate.utils.AnnotationsUtils
|
||||||
|
import org.jetbrains.jet.lang.resolve.diagnostics.DiagnosticsWithSuppression
|
||||||
|
import org.jetbrains.jet.lang.resolve.diagnostics.SuppressDiagnosticsByAnnotations
|
||||||
|
import org.jetbrains.jet.lang.resolve.diagnostics.FUNCTION_NO_BODY_ERRORS
|
||||||
|
import org.jetbrains.jet.lang.resolve.diagnostics.PROPERTY_NOT_INITIALIZED_ERRORS
|
||||||
|
|
||||||
class SuppressUnusedParameterForJsNative : DiagnosticsWithSuppression.SuppressStringProvider {
|
private val NATIVE_ANNOTATIONS = array(NATIVE.fqName, NATIVE_INVOKE.fqName, NATIVE_GETTER.fqName, NATIVE_SETTER.fqName)
|
||||||
override fun get(annotationDescriptor: AnnotationDescriptor): List<String> {
|
|
||||||
val descriptor = DescriptorUtils.getClassDescriptorForType(annotationDescriptor.getType())
|
|
||||||
if (PredefinedAnnotation.NATIVE.fqName.asString() == DescriptorUtils.getFqName(descriptor).asString()) {
|
|
||||||
return listOf(Errors.UNUSED_PARAMETER.getName().toLowerCase())
|
|
||||||
}
|
|
||||||
|
|
||||||
return listOf()
|
public class SuppressUnusedParameterForJsNative : SuppressDiagnosticsByAnnotations(listOf(Errors.UNUSED_PARAMETER), *NATIVE_ANNOTATIONS)
|
||||||
|
|
||||||
|
public class SuppressNoBodyErrorsForNativeDeclarations : SuppressDiagnosticsByAnnotations(FUNCTION_NO_BODY_ERRORS + PROPERTY_NOT_INITIALIZED_ERRORS, *NATIVE_ANNOTATIONS)
|
||||||
|
|
||||||
|
public class SuppressUninitializedErrorsForNativeDeclarations : DiagnosticsWithSuppression.DiagnosticSuppressor {
|
||||||
|
override fun isSuppressed(diagnostic: Diagnostic): Boolean {
|
||||||
|
if (diagnostic.getFactory() != Errors.UNINITIALIZED_VARIABLE) return false
|
||||||
|
|
||||||
|
[suppress("UNCHECKED_CAST")]
|
||||||
|
val diagnosticWithParameters = diagnostic as DiagnosticWithParameters1<JetSimpleNameExpression, VariableDescriptor>
|
||||||
|
|
||||||
|
val variableDescriptor = diagnosticWithParameters.getA()
|
||||||
|
|
||||||
|
return AnnotationsUtils.isNativeObject(variableDescriptor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SuppressWarningsFromExternalModules : DiagnosticsWithSuppression.DiagnosticSuppressor {
|
public class SuppressWarningsFromExternalModules : DiagnosticsWithSuppression.DiagnosticSuppressor {
|
||||||
override fun isSuppressed(diagnostic: Diagnostic): Boolean {
|
override fun isSuppressed(diagnostic: Diagnostic): Boolean {
|
||||||
val file = diagnostic.getPsiFile()
|
val file = diagnostic.getPsiFile()
|
||||||
return diagnostic.getSeverity() == Severity.WARNING &&
|
return diagnostic.getSeverity() == Severity.WARNING &&
|
||||||
|
|||||||
Reference in New Issue
Block a user