plugins: cleanup 'public', property access syntax
This commit is contained in:
+10
-10
@@ -39,17 +39,17 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
|
||||
public object AndroidConfigurationKeys {
|
||||
public val VARIANT: CompilerConfigurationKey<List<String>> = CompilerConfigurationKey.create<List<String>>("Android build variant")
|
||||
public val PACKAGE: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("application package fq name")
|
||||
object AndroidConfigurationKeys {
|
||||
val VARIANT: CompilerConfigurationKey<List<String>> = CompilerConfigurationKey.create<List<String>>("Android build variant")
|
||||
val PACKAGE: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("application package fq name")
|
||||
}
|
||||
|
||||
public class AndroidCommandLineProcessor : CommandLineProcessor {
|
||||
class AndroidCommandLineProcessor : CommandLineProcessor {
|
||||
companion object {
|
||||
public val ANDROID_COMPILER_PLUGIN_ID: String = "org.jetbrains.kotlin.android"
|
||||
val ANDROID_COMPILER_PLUGIN_ID: String = "org.jetbrains.kotlin.android"
|
||||
|
||||
public val VARIANT_OPTION: CliOption = CliOption("variant", "<name;path>", "Android build variant", allowMultipleOccurrences = true)
|
||||
public val PACKAGE_OPTION: CliOption = CliOption("package", "<fq name>", "Application package")
|
||||
val VARIANT_OPTION: CliOption = CliOption("variant", "<name;path>", "Android build variant", allowMultipleOccurrences = true)
|
||||
val PACKAGE_OPTION: CliOption = CliOption("package", "<fq name>", "Application package")
|
||||
}
|
||||
|
||||
override val pluginId: String = ANDROID_COMPILER_PLUGIN_ID
|
||||
@@ -69,9 +69,9 @@ public class AndroidCommandLineProcessor : CommandLineProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
public class AndroidComponentRegistrar : ComponentRegistrar {
|
||||
class AndroidComponentRegistrar : ComponentRegistrar {
|
||||
|
||||
public override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
||||
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
||||
val applicationPackage = configuration.get(AndroidConfigurationKeys.PACKAGE)
|
||||
val variants = configuration.get(AndroidConfigurationKeys.VARIANT)?.map { parseVariant(it) }?.filterNotNull() ?: emptyList()
|
||||
|
||||
@@ -94,7 +94,7 @@ public class AndroidComponentRegistrar : ComponentRegistrar {
|
||||
}
|
||||
}
|
||||
|
||||
public class AndroidExtensionPropertiesComponentContainerContributor : StorageComponentContainerContributor {
|
||||
class AndroidExtensionPropertiesComponentContainerContributor : StorageComponentContainerContributor {
|
||||
override fun addDeclarations(container: StorageComponentContainer, platform: TargetPlatform) {
|
||||
if (platform is JvmPlatform) {
|
||||
container.useInstance(AndroidExtensionPropertiesCallChecker())
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.android.synthetic
|
||||
|
||||
|
||||
public object AndroidConst {
|
||||
object AndroidConst {
|
||||
val SYNTHETIC_PACKAGE: String = "kotlinx.android.synthetic"
|
||||
val SYNTHETIC_PACKAGE_PATH_LENGTH = SYNTHETIC_PACKAGE.count { it == '.' } + 1
|
||||
|
||||
@@ -55,7 +55,7 @@ public object AndroidConst {
|
||||
val FQNAME_RESOLVE_PACKAGES = listOf("android.widget", "android.webkit", "android.view")
|
||||
}
|
||||
|
||||
public fun androidIdToName(id: String): String? {
|
||||
fun androidIdToName(id: String): String? {
|
||||
for (prefix in AndroidConst.XML_ID_PREFIXES) {
|
||||
if (id.startsWith(prefix)) {
|
||||
return id.substring(prefix.length)
|
||||
@@ -64,7 +64,7 @@ public fun androidIdToName(id: String): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
public fun isWidgetTypeIgnored(xmlType: String): Boolean {
|
||||
fun isWidgetTypeIgnored(xmlType: String): Boolean {
|
||||
return (xmlType.isEmpty() || xmlType in AndroidConst.IGNORED_XML_WIDGET_TYPES)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ class AndroidXmlHandler(private val elementCallback: (String, String) -> Unit) :
|
||||
|
||||
}
|
||||
|
||||
public fun Attributes.toMap(): HashMap<String, String> {
|
||||
fun Attributes.toMap(): HashMap<String, String> {
|
||||
val res = HashMap<String, String>()
|
||||
for (index in 0..length - 1) {
|
||||
val attrName = getLocalName(index)!!
|
||||
|
||||
+5
-5
@@ -43,7 +43,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes.ACC_PUBLIC
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
public enum class AndroidClassType(className: String, val supportsCache: Boolean = false, val fragment: Boolean = false) {
|
||||
enum class AndroidClassType(className: String, val supportsCache: Boolean = false, val fragment: Boolean = false) {
|
||||
ACTIVITY(AndroidConst.ACTIVITY_FQNAME, supportsCache = true),
|
||||
FRAGMENT(AndroidConst.FRAGMENT_FQNAME, supportsCache = true, fragment = true),
|
||||
SUPPORT_FRAGMENT_ACTIVITY(AndroidConst.SUPPORT_FRAGMENT_ACTIVITY_FQNAME, supportsCache = true),
|
||||
@@ -51,10 +51,10 @@ public enum class AndroidClassType(className: String, val supportsCache: Boolean
|
||||
VIEW(AndroidConst.VIEW_FQNAME),
|
||||
UNKNOWN("");
|
||||
|
||||
public val internalClassName: String = className.replace('.', '/')
|
||||
val internalClassName: String = className.replace('.', '/')
|
||||
|
||||
public companion object {
|
||||
public fun getClassType(descriptor: ClassifierDescriptor): AndroidClassType {
|
||||
companion object {
|
||||
fun getClassType(descriptor: ClassifierDescriptor): AndroidClassType {
|
||||
fun getClassTypeInternal(name: String): AndroidClassType? = when (name) {
|
||||
AndroidConst.ACTIVITY_FQNAME -> AndroidClassType.ACTIVITY
|
||||
AndroidConst.FRAGMENT_FQNAME -> AndroidClassType.FRAGMENT
|
||||
@@ -86,7 +86,7 @@ public enum class AndroidClassType(className: String, val supportsCache: Boolean
|
||||
}
|
||||
}
|
||||
|
||||
public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension {
|
||||
class AndroidExpressionCodegenExtension : ExpressionCodegenExtension {
|
||||
companion object {
|
||||
private val PROPERTY_NAME = "_\$_findViewCache"
|
||||
private val CACHED_FIND_VIEW_BY_ID_METHOD_NAME = "_\$_findCachedViewById"
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
||||
import org.jetbrains.org.objectweb.asm.*
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
public class AndroidOnDestroyClassBuilderInterceptorExtension : ClassBuilderInterceptorExtension {
|
||||
class AndroidOnDestroyClassBuilderInterceptorExtension : ClassBuilderInterceptorExtension {
|
||||
|
||||
override fun interceptClassBuilderFactory(
|
||||
interceptedFactory: ClassBuilderFactory,
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.android.synthetic.res.AndroidSyntheticProperty
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
|
||||
public class AndroidExtensionPropertiesCallChecker : CallChecker {
|
||||
class AndroidExtensionPropertiesCallChecker : CallChecker {
|
||||
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
|
||||
val expression = context.call.calleeExpression ?: return
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
|
||||
|
||||
public class DefaultErrorMessagesAndroid : DefaultErrorMessages.Extension {
|
||||
class DefaultErrorMessagesAndroid : DefaultErrorMessages.Extension {
|
||||
|
||||
private companion object {
|
||||
val MAP = DiagnosticFactoryToRendererMap("Android")
|
||||
|
||||
+4
-4
@@ -39,16 +39,16 @@ class AndroidModuleData(val module: AndroidModule, private val variants: List<An
|
||||
|
||||
abstract class AndroidLayoutXmlFileManager(val project: Project) {
|
||||
|
||||
public abstract val androidModule: AndroidModule?
|
||||
abstract val androidModule: AndroidModule?
|
||||
|
||||
public open fun propertyToXmlAttributes(propertyDescriptor: PropertyDescriptor): List<PsiElement> = listOf()
|
||||
open fun propertyToXmlAttributes(propertyDescriptor: PropertyDescriptor): List<PsiElement> = listOf()
|
||||
|
||||
open fun getModuleData(): AndroidModuleData {
|
||||
val androidModule = androidModule ?: return AndroidModuleData.EMPTY
|
||||
return AndroidModuleData(androidModule, androidModule.variants.map { getVariantData(it) })
|
||||
}
|
||||
|
||||
public fun getVariantData(variant: AndroidVariant): AndroidVariantData {
|
||||
fun getVariantData(variant: AndroidVariant): AndroidVariantData {
|
||||
val psiManager = PsiManager.getInstance(project)
|
||||
val fileManager = VirtualFileManager.getInstance()
|
||||
|
||||
@@ -125,7 +125,7 @@ abstract class AndroidLayoutXmlFileManager(val project: Project) {
|
||||
|
||||
|
||||
companion object {
|
||||
public fun getInstance(module: Module): AndroidLayoutXmlFileManager? {
|
||||
fun getInstance(module: Module): AndroidLayoutXmlFileManager? {
|
||||
val service = ModuleServiceManager.getService(module, AndroidLayoutXmlFileManager::class.java)
|
||||
return service ?: module.getComponent(AndroidLayoutXmlFileManager::class.java)
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.io.ByteArrayInputStream
|
||||
import javax.xml.parsers.SAXParser
|
||||
import javax.xml.parsers.SAXParserFactory
|
||||
|
||||
public class CliAndroidLayoutXmlFileManager(
|
||||
class CliAndroidLayoutXmlFileManager(
|
||||
project: Project,
|
||||
private val applicationPackage: String,
|
||||
private val variants: List<AndroidVariant>
|
||||
|
||||
+4
-4
@@ -30,7 +30,7 @@ import java.util.Collections
|
||||
import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestFiles
|
||||
|
||||
public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
|
||||
private fun createAndroidAPIEnvironment(path: String) {
|
||||
return createEnvironmentForConfiguration(KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
|
||||
@@ -45,12 +45,12 @@ public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
myEnvironment = createAndroidTestEnvironment(configuration, layoutPaths)
|
||||
}
|
||||
|
||||
public fun doCompileAgainstAndroidSdkTest(path: String) {
|
||||
fun doCompileAgainstAndroidSdkTest(path: String) {
|
||||
createAndroidAPIEnvironment(path)
|
||||
doMultiFileTest(path)
|
||||
}
|
||||
|
||||
public fun doFakeInvocationTest(path: String) {
|
||||
fun doFakeInvocationTest(path: String) {
|
||||
if (needsInvocationTest(path)) {
|
||||
createFakeAndroidEnvironment(path)
|
||||
doMultiFileTest(path, getFakeFiles(path))
|
||||
@@ -73,7 +73,7 @@ public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
val files = ArrayList<String>(2)
|
||||
FileUtil.processFilesRecursively(File(path), object : Processor<File> {
|
||||
override fun process(file: File?): Boolean {
|
||||
when (file!!.getName()) {
|
||||
when (file!!.name) {
|
||||
"1.kt" -> {
|
||||
if (additionalFiles == null) files.add(relativePath(file))
|
||||
}
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
public abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTest() {
|
||||
abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTest() {
|
||||
|
||||
private fun createAndroidAPIEnvironment(path: String) {
|
||||
return createEnvironmentForConfiguration(KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
|
||||
@@ -34,7 +34,7 @@ public abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTes
|
||||
myEnvironment = createAndroidTestEnvironment(configuration, layoutPaths)
|
||||
}
|
||||
|
||||
public override fun doTest(path: String) {
|
||||
override fun doTest(path: String) {
|
||||
val fileName = path + getTestName(true) + ".kt"
|
||||
createAndroidAPIEnvironment(path)
|
||||
loadFileByFullPath(fileName)
|
||||
|
||||
+2
-2
@@ -30,9 +30,9 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import java.io.File
|
||||
|
||||
public abstract class AbstractAndroidSyntheticPropertyDescriptorTest : UsefulTestCase() {
|
||||
abstract class AbstractAndroidSyntheticPropertyDescriptorTest : UsefulTestCase() {
|
||||
|
||||
public fun doTest(path: String) {
|
||||
fun doTest(path: String) {
|
||||
val config = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API)
|
||||
val env = createAndroidTestEnvironment(config, getResPaths(path))
|
||||
val project = env.project
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
public class AndroidGotoDeclarationHandler : GotoDeclarationHandler {
|
||||
class AndroidGotoDeclarationHandler : GotoDeclarationHandler {
|
||||
|
||||
override fun getGotoDeclarationTargets(sourceElement: PsiElement?, offset: Int, editor: Editor?): Array<PsiElement>? {
|
||||
if (sourceElement is LeafPsiElement && sourceElement.parent is KtSimpleNameExpression) {
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import com.intellij.psi.xml.XmlFile
|
||||
import com.intellij.psi.xml.XmlToken
|
||||
import org.jetbrains.kotlin.android.synthetic.res.AndroidLayoutXmlFileManager
|
||||
|
||||
public class AndroidPsiTreeChangePreprocessor : PsiTreeChangePreprocessor, SimpleModificationTracker() {
|
||||
class AndroidPsiTreeChangePreprocessor : PsiTreeChangePreprocessor, SimpleModificationTracker() {
|
||||
|
||||
override fun treeChanged(event: PsiTreeChangeEventImpl) {
|
||||
if (event.code in HANDLED_EVENTS) {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
|
||||
public class IDEAndroidLayoutXmlFileManager(val module: Module) : AndroidLayoutXmlFileManager(module.project) {
|
||||
class IDEAndroidLayoutXmlFileManager(val module: Module) : AndroidLayoutXmlFileManager(module.project) {
|
||||
override val androidModule: AndroidModule?
|
||||
get() = module.androidFacet?.toAndroidModuleInfo()
|
||||
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ package org.jetbrains.kotlin.plugin.android
|
||||
import com.intellij.diagnostic.ITNReporter
|
||||
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
|
||||
|
||||
public class AndroidExtensionsReportSubmitter : ITNReporter() {
|
||||
class AndroidExtensionsReportSubmitter : ITNReporter() {
|
||||
override fun showErrorInRelease(event: IdeaLoggingEvent?) = true
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.completion.test.testCompletion
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
import java.io.File
|
||||
|
||||
public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
||||
abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
||||
private var codeCompletionOldValue: Boolean = false
|
||||
private var smartTypeCompletionOldValue: Boolean = false
|
||||
|
||||
|
||||
+2
-2
@@ -18,11 +18,11 @@ package org.jetbrains.kotlin.android
|
||||
|
||||
import com.intellij.codeInsight.TargetElementUtil
|
||||
|
||||
public abstract class AbstractAndroidFindUsagesTest : KotlinAndroidTestCase() {
|
||||
abstract class AbstractAndroidFindUsagesTest : KotlinAndroidTestCase() {
|
||||
|
||||
override fun getTestDataPath() = KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/findUsages/" + getTestName(true) + "/"
|
||||
|
||||
public fun doTest(path: String) {
|
||||
fun doTest(path: String) {
|
||||
if (true) return // Muted (actually works in IDEA)
|
||||
|
||||
val f = myFixture!!
|
||||
|
||||
+2
-2
@@ -29,13 +29,13 @@ import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
|
||||
public abstract class AbstractAndroidGotoTest : KotlinAndroidTestCase() {
|
||||
abstract class AbstractAndroidGotoTest : KotlinAndroidTestCase() {
|
||||
|
||||
override fun getTestDataPath(): String {
|
||||
return KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/goto/" + getTestName(true) + "/"
|
||||
}
|
||||
|
||||
public fun doTest(path: String) {
|
||||
fun doTest(path: String) {
|
||||
val f = myFixture!!
|
||||
getResourceDirs(path).forEach { myFixture.copyDirectoryToProject(it.name, it.name) }
|
||||
val virtualFile = f.copyFileToProject(path + getTestName(true) + ".kt", "src/" + getTestName(true) + ".kt");
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ import com.intellij.refactoring.rename.RenameProcessor
|
||||
import com.intellij.psi.impl.source.xml.XmlAttributeValueImpl
|
||||
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
||||
|
||||
public abstract class AbstractAndroidRenameTest : KotlinAndroidTestCase() {
|
||||
abstract class AbstractAndroidRenameTest : KotlinAndroidTestCase() {
|
||||
private val NEW_NAME = "NEWNAME"
|
||||
private val NEW_ID_NAME = "@+id/$NEW_NAME"
|
||||
|
||||
public fun doTest(path: String) {
|
||||
fun doTest(path: String) {
|
||||
val f = myFixture!!
|
||||
getResourceDirs(path).forEach { myFixture.copyDirectoryToProject(it.name, it.name) }
|
||||
val virtualFile = f.copyFileToProject(path + getTestName(true) + ".kt", "src/" + getTestName(true) + ".kt");
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.util.PathUtil
|
||||
import org.w3c.dom.Document
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
|
||||
public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
|
||||
class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
|
||||
override fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> {
|
||||
val module = moduleBuildTarget.module
|
||||
if (!hasAndroidJpsPlugin() || !isAndroidModuleWithoutGradle(module)) return emptyList()
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ import org.jetbrains.jps.model.impl.JpsSimpleElementImpl
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||
import java.io.File
|
||||
|
||||
public abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() {
|
||||
abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() {
|
||||
|
||||
private val SDK_NAME = "Android API 21 Platform"
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() {
|
||||
System.setProperty("kotlin.jps.tests", "true")
|
||||
}
|
||||
|
||||
public fun doTest(path: String) {
|
||||
fun doTest(path: String) {
|
||||
addJdkAndAndroidSdk()
|
||||
loadProject(path + getTestName(true) + ".ipr")
|
||||
rebuildAll()
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() {
|
||||
deleteDirectory(File(path + "/out"))
|
||||
}
|
||||
|
||||
public fun deleteDirectory(path: File): Boolean {
|
||||
fun deleteDirectory(path: File): Boolean {
|
||||
if (path.exists() && path.isDirectory) {
|
||||
val files = path.listFiles()
|
||||
for (i in files.indices) {
|
||||
|
||||
+4
-4
@@ -34,7 +34,7 @@ import java.util.regex.Pattern
|
||||
import java.util.regex.PatternSyntaxException
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
public abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnotations: Boolean) : ClassBuilderInterceptorExtension {
|
||||
abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnotations: Boolean) : ClassBuilderInterceptorExtension {
|
||||
|
||||
private object RecordTypes {
|
||||
val ANNOTATED_CLASS = "c"
|
||||
@@ -180,7 +180,7 @@ public abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnot
|
||||
}
|
||||
|
||||
private fun recordAnnotation(name: String?, type: String, annotationDesc: String) {
|
||||
val annotationFqName = Type.getType(annotationDesc).getClassName()
|
||||
val annotationFqName = Type.getType(annotationDesc).className
|
||||
if (!isAnnotationHandled(annotationFqName)) return
|
||||
|
||||
try {
|
||||
@@ -231,7 +231,7 @@ public abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnot
|
||||
}
|
||||
}
|
||||
|
||||
public class AnnotationCollectorExtension(
|
||||
class AnnotationCollectorExtension(
|
||||
override val annotationFilterList: List<String>? = null,
|
||||
val outputFilename: String? = null,
|
||||
supportInheritedAnnotations: Boolean
|
||||
@@ -246,7 +246,7 @@ public class AnnotationCollectorExtension(
|
||||
override fun getWriter(diagnostic: DiagnosticSink): Writer {
|
||||
return writerInternal ?: try {
|
||||
with (File(outputFilename)) {
|
||||
val parent = getParentFile()
|
||||
val parent = parentFile
|
||||
if (!parent.exists()) parent.mkdirs()
|
||||
writerInternal = bufferedWriter()
|
||||
writerInternal!!
|
||||
|
||||
+13
-13
@@ -44,31 +44,31 @@ import java.io.Writer
|
||||
import java.util.regex.Pattern
|
||||
import java.util.regex.PatternSyntaxException
|
||||
|
||||
public object AnnotationCollectorConfigurationKeys {
|
||||
public val ANNOTATION_FILTER_LIST: CompilerConfigurationKey<List<String>> =
|
||||
object AnnotationCollectorConfigurationKeys {
|
||||
val ANNOTATION_FILTER_LIST: CompilerConfigurationKey<List<String>> =
|
||||
CompilerConfigurationKey.create<List<String>>("annotation filter regular expressions")
|
||||
public val OUTPUT_FILENAME: CompilerConfigurationKey<String> =
|
||||
val OUTPUT_FILENAME: CompilerConfigurationKey<String> =
|
||||
CompilerConfigurationKey.create<String>("annotation file name")
|
||||
public val STUBS_PATH: CompilerConfigurationKey<String> =
|
||||
val STUBS_PATH: CompilerConfigurationKey<String> =
|
||||
CompilerConfigurationKey.create<String>("stubs output directory")
|
||||
public val INHERITED: CompilerConfigurationKey<String> =
|
||||
val INHERITED: CompilerConfigurationKey<String> =
|
||||
CompilerConfigurationKey.create<String>("support inherited annotations")
|
||||
}
|
||||
|
||||
public class AnnotationCollectorCommandLineProcessor : CommandLineProcessor {
|
||||
class AnnotationCollectorCommandLineProcessor : CommandLineProcessor {
|
||||
companion object {
|
||||
public val ANNOTATION_COLLECTOR_COMPILER_PLUGIN_ID: String = "org.jetbrains.kotlin.kapt"
|
||||
val ANNOTATION_COLLECTOR_COMPILER_PLUGIN_ID: String = "org.jetbrains.kotlin.kapt"
|
||||
|
||||
public val ANNOTATION_FILTER_LIST_OPTION: CliOption =
|
||||
val ANNOTATION_FILTER_LIST_OPTION: CliOption =
|
||||
CliOption("annotations", "<path>", "Annotation filter regular expressions, separated by commas", required = false)
|
||||
|
||||
public val OUTPUT_FILENAME_OPTION: CliOption =
|
||||
val OUTPUT_FILENAME_OPTION: CliOption =
|
||||
CliOption("output", "<path>", "File in which annotated declarations will be placed", required = false)
|
||||
|
||||
public val STUBS_PATH_OPTION: CliOption =
|
||||
val STUBS_PATH_OPTION: CliOption =
|
||||
CliOption("stubs", "<path>", "Output path for stubs", required = false)
|
||||
|
||||
public val INHERITED_ANNOTATIONS_OPTION: CliOption =
|
||||
val INHERITED_ANNOTATIONS_OPTION: CliOption =
|
||||
CliOption("inherited", "<true/false>",
|
||||
"True if collecting Kotlin class names for inherited annotations is needed", required = false)
|
||||
}
|
||||
@@ -92,8 +92,8 @@ public class AnnotationCollectorCommandLineProcessor : CommandLineProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
public class AnnotationCollectorComponentRegistrar : ComponentRegistrar {
|
||||
public override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
||||
class AnnotationCollectorComponentRegistrar : ComponentRegistrar {
|
||||
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
||||
val supportInheritedAnnotations = "true" == (configuration.get(AnnotationCollectorConfigurationKeys.INHERITED) ?: "true")
|
||||
|
||||
val annotationFilterList = configuration.get(AnnotationCollectorConfigurationKeys.ANNOTATION_FILTER_LIST)
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisCompletedHandlerExten
|
||||
import org.jetbrains.org.objectweb.asm.ClassWriter
|
||||
import java.io.File
|
||||
|
||||
public class StubProducerExtension(val stubsOutputDir: File) : AnalysisCompletedHandlerExtension {
|
||||
class StubProducerExtension(val stubsOutputDir: File) : AnalysisCompletedHandlerExtension {
|
||||
|
||||
override fun analysisCompleted(
|
||||
project: Project,
|
||||
@@ -67,7 +67,7 @@ private class StubClassBuilderFactory : ClassBuilderFactory {
|
||||
override fun asText(builder: ClassBuilder) = throw UnsupportedOperationException("BINARIES generator asked for text")
|
||||
|
||||
override fun asBytes(builder: ClassBuilder): ByteArray {
|
||||
val visitor = builder.getVisitor() as ClassWriter
|
||||
val visitor = builder.visitor as ClassWriter
|
||||
return visitor.toByteArray()
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -32,9 +32,9 @@ import java.io.StringWriter
|
||||
import java.io.Writer
|
||||
import org.junit.Assert.*
|
||||
|
||||
public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() {
|
||||
abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() {
|
||||
|
||||
public fun doTest(path: String) {
|
||||
fun doTest(path: String) {
|
||||
val testName = getTestName(true)
|
||||
val fileName = path + testName + ".kt"
|
||||
val supportInheritedAnnotations = testName.startsWith("inherited")
|
||||
@@ -55,7 +55,7 @@ public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() {
|
||||
|
||||
private fun createTestEnvironment(supportInheritedAnnotations: Boolean): AnnotationCollectorExtensionForTests {
|
||||
val configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
||||
val environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
val environment = KotlinCoreEnvironment.createForTests(testRootDisposable!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
val project = environment.project
|
||||
|
||||
val collectorExtension = AnnotationCollectorExtensionForTests(supportInheritedAnnotations)
|
||||
|
||||
Reference in New Issue
Block a user