compiler: cleanup 'public', property access syntax
This commit is contained in:
@@ -18,27 +18,26 @@ package org.jetbrains.kotlin.config
|
||||
|
||||
import java.util.HashMap
|
||||
|
||||
public class Services private constructor(private val map: Map<Class<*>, Any>) {
|
||||
class Services private constructor(private val map: Map<Class<*>, Any>) {
|
||||
companion object {
|
||||
@JvmField
|
||||
public val EMPTY: Services = Builder().build()
|
||||
@JvmField val EMPTY: Services = Builder().build()
|
||||
}
|
||||
|
||||
public fun <T> get(interfaceClass: Class<T>): T {
|
||||
fun <T> get(interfaceClass: Class<T>): T {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return map.get(interfaceClass) as T
|
||||
}
|
||||
|
||||
public class Builder {
|
||||
class Builder {
|
||||
|
||||
private val map = HashMap<Class<*>, Any>()
|
||||
|
||||
public fun <T : Any> register(interfaceClass: Class<T>, implementation: T): Builder {
|
||||
fun <T : Any> register(interfaceClass: Class<T>, implementation: T): Builder {
|
||||
map.put(interfaceClass, implementation)
|
||||
return this
|
||||
}
|
||||
|
||||
public fun build(): Services {
|
||||
fun build(): Services {
|
||||
return Services(map)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,20 @@
|
||||
|
||||
package org.jetbrains.kotlin.modules
|
||||
|
||||
public interface Module {
|
||||
public fun getModuleName(): String
|
||||
interface Module {
|
||||
fun getModuleName(): String
|
||||
|
||||
public fun getModuleType(): String
|
||||
fun getModuleType(): String
|
||||
|
||||
public fun getOutputDirectory(): String
|
||||
fun getOutputDirectory(): String
|
||||
|
||||
public fun getFriendPaths(): List<String>
|
||||
fun getFriendPaths(): List<String>
|
||||
|
||||
public fun getSourceFiles(): List<String>
|
||||
fun getSourceFiles(): List<String>
|
||||
|
||||
public fun getClasspathRoots(): List<String>
|
||||
fun getClasspathRoots(): List<String>
|
||||
|
||||
public fun getJavaSourceRoots(): List<JavaRootPath>
|
||||
fun getJavaSourceRoots(): List<JavaRootPath>
|
||||
}
|
||||
|
||||
data class JavaRootPath(val path: String, val packagePrefix: String? = null)
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.modules
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
public data class TargetId(public val name: String, public val type: String) : Serializable
|
||||
data class TargetId(val name: String, val type: String) : Serializable
|
||||
|
||||
public fun TargetId(module: Module): TargetId =
|
||||
fun TargetId(module: Module): TargetId =
|
||||
TargetId(module.getModuleName(), module.getModuleType())
|
||||
@@ -19,23 +19,21 @@ package org.jetbrains.kotlin.progress
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider
|
||||
|
||||
public class CompilationCanceledException : ProcessCanceledException()
|
||||
class CompilationCanceledException : ProcessCanceledException()
|
||||
|
||||
public interface CompilationCanceledStatus {
|
||||
interface CompilationCanceledStatus {
|
||||
fun checkCanceled(): Unit
|
||||
}
|
||||
|
||||
public object ProgressIndicatorAndCompilationCanceledStatus {
|
||||
object ProgressIndicatorAndCompilationCanceledStatus {
|
||||
private var canceledStatus: CompilationCanceledStatus? = null
|
||||
|
||||
@JvmStatic
|
||||
@Synchronized
|
||||
public fun setCompilationCanceledStatus(newCanceledStatus: CompilationCanceledStatus?): Unit {
|
||||
@Synchronized fun setCompilationCanceledStatus(newCanceledStatus: CompilationCanceledStatus?): Unit {
|
||||
canceledStatus = newCanceledStatus
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun checkCanceled(): Unit {
|
||||
@JvmStatic fun checkCanceled(): Unit {
|
||||
ProgressIndicatorProvider.checkCanceled()
|
||||
canceledStatus?.checkCanceled()
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.utils
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
public class CachedValueProperty<TValue : Any, TTimestamp : Any>(
|
||||
class CachedValueProperty<TValue : Any, TTimestamp : Any>(
|
||||
private val calculator: () -> TValue,
|
||||
private val timestampCalculator: () -> TTimestamp
|
||||
) {
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
public class KotlinFrontEndException(message: String, cause: Throwable) : RuntimeException(message, cause)
|
||||
class KotlinFrontEndException(message: String, cause: Throwable) : RuntimeException(message, cause)
|
||||
|
||||
@@ -20,14 +20,14 @@ import java.io.File
|
||||
import javax.xml.bind.DatatypeConverter.parseBase64Binary
|
||||
import javax.xml.bind.DatatypeConverter.printBase64Binary
|
||||
|
||||
public class KotlinJavascriptMetadata(public val abiVersion: Int, public val moduleName: String, public val body: ByteArray) {
|
||||
public val isAbiVersionCompatible: Boolean = KotlinJavascriptMetadataUtils.isAbiVersionCompatible(abiVersion)
|
||||
class KotlinJavascriptMetadata(val abiVersion: Int, val moduleName: String, val body: ByteArray) {
|
||||
val isAbiVersionCompatible: Boolean = KotlinJavascriptMetadataUtils.isAbiVersionCompatible(abiVersion)
|
||||
}
|
||||
|
||||
public object KotlinJavascriptMetadataUtils {
|
||||
public const val JS_EXT: String = ".js"
|
||||
public const val META_JS_SUFFIX: String = ".meta.js"
|
||||
public const val VFS_PROTOCOL: String = "kotlin-js-meta"
|
||||
object KotlinJavascriptMetadataUtils {
|
||||
const val JS_EXT: String = ".js"
|
||||
const val META_JS_SUFFIX: String = ".meta.js"
|
||||
const val VFS_PROTOCOL: String = "kotlin-js-meta"
|
||||
private val KOTLIN_JAVASCRIPT_METHOD_NAME = "kotlin_module_metadata"
|
||||
private val KOTLIN_JAVASCRIPT_METHOD_NAME_PATTERN = "\\.kotlin_module_metadata\\(".toPattern()
|
||||
/**
|
||||
@@ -35,19 +35,16 @@ public object KotlinJavascriptMetadataUtils {
|
||||
*/
|
||||
private val METADATA_PATTERN = "(?m)\\w+\\.$KOTLIN_JAVASCRIPT_METHOD_NAME\\((\\d+),\\s*(['\"])([^'\"]*)\\2,\\s*(['\"])([^'\"]*)\\4\\)".toPattern()
|
||||
|
||||
@JvmField
|
||||
public val ABI_VERSION: Int = 3
|
||||
@JvmField val ABI_VERSION: Int = 3
|
||||
|
||||
public fun replaceSuffix(filePath: String): String = filePath.substringBeforeLast(JS_EXT) + META_JS_SUFFIX
|
||||
fun replaceSuffix(filePath: String): String = filePath.substringBeforeLast(JS_EXT) + META_JS_SUFFIX
|
||||
|
||||
@JvmStatic
|
||||
public fun isAbiVersionCompatible(abiVersion: Int): Boolean = abiVersion == ABI_VERSION
|
||||
@JvmStatic fun isAbiVersionCompatible(abiVersion: Int): Boolean = abiVersion == ABI_VERSION
|
||||
|
||||
@JvmStatic
|
||||
public fun hasMetadata(text: String): Boolean =
|
||||
@JvmStatic fun hasMetadata(text: String): Boolean =
|
||||
KOTLIN_JAVASCRIPT_METHOD_NAME_PATTERN.matcher(text).find() && METADATA_PATTERN.matcher(text).find()
|
||||
|
||||
public fun hasMetadataWithIncompatibleAbiVersion(text: String): Boolean {
|
||||
fun hasMetadataWithIncompatibleAbiVersion(text: String): Boolean {
|
||||
val matcher = METADATA_PATTERN.matcher(text)
|
||||
while (matcher.find()) {
|
||||
var abiVersion = matcher.group(1).toInt()
|
||||
@@ -56,15 +53,14 @@ public object KotlinJavascriptMetadataUtils {
|
||||
return false
|
||||
}
|
||||
|
||||
public fun formatMetadataAsString(moduleName: String, content: ByteArray): String =
|
||||
fun formatMetadataAsString(moduleName: String, content: ByteArray): String =
|
||||
"// Kotlin.$KOTLIN_JAVASCRIPT_METHOD_NAME($ABI_VERSION, \"$moduleName\", \"${printBase64Binary(content)}\");\n"
|
||||
|
||||
@JvmStatic
|
||||
public fun loadMetadata(file: File): List<KotlinJavascriptMetadata> {
|
||||
@JvmStatic fun loadMetadata(file: File): List<KotlinJavascriptMetadata> {
|
||||
assert(file.exists()) { "Library " + file + " not found" }
|
||||
val metadataList = arrayListOf<KotlinJavascriptMetadata>()
|
||||
LibraryUtils.traverseJsLibrary(file) { content, relativePath ->
|
||||
var path = file.getPath()
|
||||
var path = file.path
|
||||
|
||||
if (relativePath.isNotBlank()) {
|
||||
path += "/$relativePath"
|
||||
@@ -76,11 +72,9 @@ public object KotlinJavascriptMetadataUtils {
|
||||
return metadataList
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun loadMetadata(path: String): List<KotlinJavascriptMetadata> = loadMetadata(File(path))
|
||||
@JvmStatic fun loadMetadata(path: String): List<KotlinJavascriptMetadata> = loadMetadata(File(path))
|
||||
|
||||
@JvmStatic
|
||||
public fun parseMetadata(text: String, metadataList: MutableList<KotlinJavascriptMetadata>) {
|
||||
@JvmStatic fun parseMetadata(text: String, metadataList: MutableList<KotlinJavascriptMetadata>) {
|
||||
// Check for literal pattern first in order to reduce time for large files without metadata
|
||||
if (!KOTLIN_JAVASCRIPT_METHOD_NAME_PATTERN.matcher(text).find()) return
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ import java.util.jar.JarFile
|
||||
import java.util.jar.Manifest
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
public object LibraryUtils {
|
||||
object LibraryUtils {
|
||||
private val LOG = Logger.getInstance(LibraryUtils::class.java)
|
||||
|
||||
public val KOTLIN_JS_MODULE_NAME: String = "Kotlin-JS-Module-Name"
|
||||
val KOTLIN_JS_MODULE_NAME: String = "Kotlin-JS-Module-Name"
|
||||
private var TITLE_KOTLIN_JAVASCRIPT_STDLIB: String
|
||||
private var TITLE_KOTLIN_JAVASCRIPT_LIB: String
|
||||
private val METAINF = "META-INF/"
|
||||
@@ -64,39 +64,32 @@ public object LibraryUtils {
|
||||
TITLE_KOTLIN_JAVASCRIPT_LIB = jsLib
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun getJarFile(classesRoots: List<VirtualFile>, jarName: String): VirtualFile? {
|
||||
@JvmStatic fun getJarFile(classesRoots: List<VirtualFile>, jarName: String): VirtualFile? {
|
||||
return classesRoots.firstOrNull { it.name == jarName }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun getKotlinJsModuleName(library: File): String? {
|
||||
@JvmStatic fun getKotlinJsModuleName(library: File): String? {
|
||||
return getManifestMainAttributesFromJarOrDirectory(library)?.getValue(KOTLIN_JS_MODULE_ATTRIBUTE_NAME)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun isOldKotlinJavascriptLibrary(library: File): Boolean =
|
||||
@JvmStatic fun isOldKotlinJavascriptLibrary(library: File): Boolean =
|
||||
checkAttributeValue(library, TITLE_KOTLIN_JAVASCRIPT_LIB, Attributes.Name.SPECIFICATION_TITLE) && getKotlinJsModuleName(library) != null
|
||||
|
||||
@JvmStatic
|
||||
public fun isKotlinJavascriptLibraryWithMetadata(library: File): Boolean = KotlinJavascriptMetadataUtils.loadMetadata(library).isNotEmpty()
|
||||
@JvmStatic fun isKotlinJavascriptLibraryWithMetadata(library: File): Boolean = KotlinJavascriptMetadataUtils.loadMetadata(library).isNotEmpty()
|
||||
|
||||
@JvmStatic
|
||||
public fun isKotlinJavascriptLibrary(library: File): Boolean =
|
||||
@JvmStatic fun isKotlinJavascriptLibrary(library: File): Boolean =
|
||||
isOldKotlinJavascriptLibrary(library) || isKotlinJavascriptLibraryWithMetadata(library)
|
||||
|
||||
@JvmStatic
|
||||
public fun isKotlinJavascriptStdLibrary(library: File): Boolean {
|
||||
@JvmStatic fun isKotlinJavascriptStdLibrary(library: File): Boolean {
|
||||
return checkAttributeValue(library, TITLE_KOTLIN_JAVASCRIPT_STDLIB, Attributes.Name.IMPLEMENTATION_TITLE)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun copyJsFilesFromLibraries(libraries: List<String>, outputLibraryJsPath: String) {
|
||||
@JvmStatic fun copyJsFilesFromLibraries(libraries: List<String>, outputLibraryJsPath: String) {
|
||||
for (library in libraries) {
|
||||
val file = File(library)
|
||||
assert(file.exists()) { "Library " + library + " not found" }
|
||||
|
||||
if (file.isDirectory()) {
|
||||
if (file.isDirectory) {
|
||||
copyJsFilesFromDirectory(file, outputLibraryJsPath)
|
||||
}
|
||||
else {
|
||||
@@ -105,17 +98,15 @@ public object LibraryUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun traverseJsLibraries(libs: List<File>, action: (content: String, path: String)->Unit) {
|
||||
@JvmStatic fun traverseJsLibraries(libs: List<File>, action: (content: String, path: String)->Unit) {
|
||||
libs.forEach { traverseJsLibrary(it, action) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun traverseJsLibrary(lib: File, action: (content: String, path: String)->Unit) {
|
||||
@JvmStatic fun traverseJsLibrary(lib: File, action: (content: String, path: String)->Unit) {
|
||||
when {
|
||||
lib.isDirectory() -> traverseDirectory(lib, action)
|
||||
lib.isDirectory -> traverseDirectory(lib, action)
|
||||
FileUtil.isJarOrZip(lib) -> traverseArchive(lib, action)
|
||||
lib.getName().endsWith(KotlinJavascriptMetadataUtils.JS_EXT) -> {
|
||||
lib.name.endsWith(KotlinJavascriptMetadataUtils.JS_EXT) -> {
|
||||
lib.runIfFileExists(action)
|
||||
val jsFile = lib.withReplacedExtensionOrNull(KotlinJavascriptMetadataUtils.META_JS_SUFFIX, KotlinJavascriptMetadataUtils.JS_EXT)
|
||||
jsFile?.runIfFileExists(action)
|
||||
@@ -126,7 +117,7 @@ public object LibraryUtils {
|
||||
}
|
||||
|
||||
private fun File.runIfFileExists(action: (content: String, path: String)->Unit) {
|
||||
if (isFile()) {
|
||||
if (isFile) {
|
||||
action(FileUtil.loadFile(this), "")
|
||||
}
|
||||
}
|
||||
@@ -141,7 +132,7 @@ public object LibraryUtils {
|
||||
FileUtil.processFilesRecursively(dir, object : Processor<File> {
|
||||
override fun process(file: File): Boolean {
|
||||
val relativePath = FileUtil.getRelativePath(dir, file) ?: throw IllegalArgumentException("relativePath should not be null " + dir + " " + file)
|
||||
if (file.isFile() && relativePath.endsWith(KotlinJavascriptMetadataUtils.JS_EXT)) {
|
||||
if (file.isFile && relativePath.endsWith(KotlinJavascriptMetadataUtils.JS_EXT)) {
|
||||
val suggestedRelativePath = getSuggestedPath(relativePath)
|
||||
if (suggestedRelativePath == null) return true
|
||||
|
||||
@@ -157,7 +148,7 @@ public object LibraryUtils {
|
||||
processDirectory(dir, action)
|
||||
}
|
||||
catch (ex: IOException) {
|
||||
LOG.error("Could not read files from directory ${dir.getName()}: ${ex.message}")
|
||||
LOG.error("Could not read files from directory ${dir.name}: ${ex.message}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +159,13 @@ public object LibraryUtils {
|
||||
}
|
||||
|
||||
fun traverseArchive(file: File, action: (content: String, relativePath: String) -> Unit) {
|
||||
val zipFile = ZipFile(file.getPath())
|
||||
val zipFile = ZipFile(file.path)
|
||||
try {
|
||||
val zipEntries = zipFile.entries()
|
||||
while (zipEntries.hasMoreElements()) {
|
||||
val entry = zipEntries.nextElement()
|
||||
val entryName = entry.getName()
|
||||
if (!entry.isDirectory() && entryName.endsWith(KotlinJavascriptMetadataUtils.JS_EXT)) {
|
||||
val entryName = entry.name
|
||||
if (!entry.isDirectory && entryName.endsWith(KotlinJavascriptMetadataUtils.JS_EXT)) {
|
||||
val relativePath = getSuggestedPath(entryName)
|
||||
if (relativePath == null) continue
|
||||
|
||||
@@ -185,7 +176,7 @@ public object LibraryUtils {
|
||||
}
|
||||
}
|
||||
catch (ex: IOException) {
|
||||
LOG.error("Could not extract files from archive ${file.getName()}: ${ex.message}")
|
||||
LOG.error("Could not extract files from archive ${file.name}: ${ex.message}")
|
||||
}
|
||||
finally {
|
||||
zipFile.close()
|
||||
@@ -210,7 +201,7 @@ public object LibraryUtils {
|
||||
try {
|
||||
val jarFile = JarFile(library)
|
||||
try {
|
||||
return jarFile.getManifest()
|
||||
return jarFile.manifest
|
||||
}
|
||||
finally {
|
||||
jarFile.close()
|
||||
@@ -222,7 +213,7 @@ public object LibraryUtils {
|
||||
}
|
||||
|
||||
private fun getManifestFromDirectory(library: File): Manifest? {
|
||||
if (!library.canRead() || !library.isDirectory()) return null
|
||||
if (!library.canRead() || !library.isDirectory) return null
|
||||
|
||||
val manifestFile = File(library, MANIFEST_PATH)
|
||||
if (!manifestFile.exists()) return null
|
||||
@@ -243,10 +234,10 @@ public object LibraryUtils {
|
||||
}
|
||||
|
||||
private fun getManifestFromJarOrDirectory(library: File): Manifest? =
|
||||
if (library.isDirectory()) getManifestFromDirectory(library) else getManifestFromJar(library)
|
||||
if (library.isDirectory) getManifestFromDirectory(library) else getManifestFromJar(library)
|
||||
|
||||
private fun getManifestMainAttributesFromJarOrDirectory(library: File): Attributes? =
|
||||
getManifestFromJarOrDirectory(library)?.getMainAttributes()
|
||||
getManifestFromJarOrDirectory(library)?.mainAttributes
|
||||
|
||||
private fun checkAttributeValue(library: File, expected: String, attributeName: Attributes.Name): Boolean {
|
||||
val attributes = getManifestMainAttributesFromJarOrDirectory(library)
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.utils.concurrent.block
|
||||
|
||||
public class LockedClearableLazyValue<T: Any>(val lock: Any, val init: () -> T) {
|
||||
class LockedClearableLazyValue<T: Any>(val lock: Any, val init: () -> T) {
|
||||
@Volatile private var value: T? = null
|
||||
|
||||
public fun get(): T {
|
||||
fun get(): T {
|
||||
val _v1 = value
|
||||
if (_v1 != null) {
|
||||
return _v1
|
||||
|
||||
@@ -20,11 +20,11 @@ import java.io.File
|
||||
|
||||
// TODO: move to stdlib as:
|
||||
// public fun File?.readTextOrEmpty(encoding: String = Charset.defaultCharset().name()): String = this?.readText(encoding) ?: ""
|
||||
public fun File?.readTextOrEmpty(): String = this?.readText() ?: ""
|
||||
fun File?.readTextOrEmpty(): String = this?.readText() ?: ""
|
||||
|
||||
public fun File.withReplacedExtensionOrNull(oldExt: String, newExt: String): File? {
|
||||
if (getName().endsWith(oldExt)) {
|
||||
val path = getPath()
|
||||
fun File.withReplacedExtensionOrNull(oldExt: String, newExt: String): File? {
|
||||
if (name.endsWith(oldExt)) {
|
||||
val path = path
|
||||
val pathWithoutExt = path.substring(0, path.length - oldExt.length)
|
||||
val pathWithNewExt = pathWithoutExt + newExt
|
||||
return File(pathWithNewExt)
|
||||
|
||||
@@ -18,6 +18,6 @@ package org.jetbrains.kotlin.utils.intellij
|
||||
|
||||
import com.intellij.openapi.util.Pair
|
||||
|
||||
public fun <A> Pair<A, *>.component1(): A = getFirst()
|
||||
fun <A> Pair<A, *>.component1(): A = getFirst()
|
||||
|
||||
public fun <B> Pair<*, B>.component2(): B = getSecond()
|
||||
fun <B> Pair<*, B>.component2(): B = getSecond()
|
||||
|
||||
@@ -22,7 +22,7 @@ private val CARET_MARKER = "<~!!~>"
|
||||
private val BEGIN_MARKER = "<~BEGIN~>"
|
||||
private val END_MARKER = "<~END~>"
|
||||
|
||||
public fun CharSequence.substringWithContext(beginIndex: Int, endIndex: Int, range: Int): String {
|
||||
fun CharSequence.substringWithContext(beginIndex: Int, endIndex: Int, range: Int): String {
|
||||
val start = Math.max(0, beginIndex - range)
|
||||
val end = Math.min(this.length, endIndex + range)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user