From 2c1c3d1f31c19758fea85a3d7e42745007f5b80a Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 27 Jan 2017 12:58:38 +0100 Subject: [PATCH] Workaround for compilation issue: don't use a Java shim to access token name, use toString() instead (for all relevant tokens, it will return the name, and for all others, the return value won't match the Java keyword filter regexp) --- .../stubs/ClassFileToSourceStubConverter.kt | 5 ++-- .../kotlin/kapt3/stubs/Kapt3StubUtils.java | 29 ------------------- 2 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/Kapt3StubUtils.java diff --git a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt index aa3f839c4ea..bfe72055e89 100644 --- a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt +++ b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.kapt3.* import org.jetbrains.kotlin.kapt3.javac.KaptTreeMaker import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject -import org.jetbrains.kotlin.kapt3.stubs.Kapt3StubUtils.* import org.jetbrains.kotlin.kapt3.util.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils @@ -75,8 +74,8 @@ class ClassFileToSourceStubConverter( private val JAVA_KEYWORD_FILTER_REGEX = "[a-z]+".toRegex() private val JAVA_KEYWORDS = Tokens.TokenKind.values() - .filter { JAVA_KEYWORD_FILTER_REGEX.matches(getTokenName(it)) } - .mapTo(hashSetOf(), ::getTokenName) + .filter { JAVA_KEYWORD_FILTER_REGEX.matches(it.toString().orEmpty()) } + .mapTo(hashSetOf(), Any::toString) } private val _bindings = mutableMapOf() diff --git a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/Kapt3StubUtils.java b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/Kapt3StubUtils.java deleted file mode 100644 index 52fc163e8dc..00000000000 --- a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/stubs/Kapt3StubUtils.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010-2017 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.kotlin.kapt3.stubs; - -import com.sun.tools.javac.parser.Tokens; -import org.jetbrains.annotations.NotNull; - -public class Kapt3StubUtils { - @NotNull - public static String getTokenName(@NotNull Tokens.TokenKind kind) { - // This is a work-around. `name` can't be called from Kotlin, as it clashes with the `name` enum property. - String name = kind.name; - return (name == null) ? "" : name; - } -}