mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
revert kotlin 1.1 usages because kotlin 1.1.0 doesn't support facets correctly
This commit is contained in:
@@ -1,18 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="2" platform="JVM 1.8" useProjectSettings="false">
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
<option name="languageVersion" value="1.1" />
|
||||
<option name="apiVersion" value="1.1" />
|
||||
<option name="coroutinesError" value="true" />
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
|
||||
@@ -432,7 +432,7 @@ private fun removeWorkspaceComponentConfiguration(defaultProject: Project, eleme
|
||||
}
|
||||
}
|
||||
|
||||
ServiceManagerImpl.processAllImplementationClasses(defaultProject as ProjectImpl) { aClass, _ ->
|
||||
ServiceManagerImpl.processAllImplementationClasses(defaultProject as ProjectImpl) { aClass, pluginDescriptor ->
|
||||
getNameIfWorkspaceStorage(aClass)?.let {
|
||||
workspaceComponentNames.add(it)
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ internal class AState : BaseState() {
|
||||
@get:Attribute("customName")
|
||||
var languageLevel by storedProperty<String?>()
|
||||
|
||||
var bar by string()
|
||||
|
||||
var property2 by storedProperty(0)
|
||||
|
||||
var floatProperty by storedProperty(0.3)
|
||||
@@ -39,10 +37,6 @@ class StoredPropertyStateTest {
|
||||
|
||||
assertThat(state).isNotEqualTo(AState())
|
||||
|
||||
val newEqualState = AState()
|
||||
newEqualState.languageLevel = String("foo".toCharArray())
|
||||
assertThat(state).isEqualTo(newEqualState)
|
||||
|
||||
assertThat(state.serialize()).isEqualTo("""<AState customName="foo" />""")
|
||||
assertThat(loadElement("""<AState customName="foo" />""").deserialize(AState::class.java).languageLevel).isEqualTo("foo")
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.intellij.configurationStore
|
||||
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class ResourceLoader(id: String) : ReadOnlyProperty<MyUI, String> {
|
||||
operator fun provideDelegate(thisRef: MyUI, prop: KProperty<*>): ReadOnlyProperty<MyUI, String> {
|
||||
checkProperty(thisRef, prop.name)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun getValue(thisRef: MyUI, property: KProperty<*>): String {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
private fun checkProperty(thisRef: MyUI, name: String) {}
|
||||
}
|
||||
|
||||
fun bindResource(id: String): ResourceLoader {
|
||||
return ResourceLoader(id)
|
||||
}
|
||||
|
||||
class MyUI {
|
||||
val image by bindResource("f")
|
||||
val text by bindResource("d")
|
||||
}
|
||||
|
||||
fun main(a: Array<String>) {
|
||||
MyUI()
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="2" platform="JVM 1.8" useProjectSettings="false">
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
<option name="languageVersion" value="1.1" />
|
||||
<option name="apiVersion" value="1.1" />
|
||||
<option name="coroutinesError" value="true" />
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.util.SmartList
|
||||
import com.intellij.util.xmlb.Accessor
|
||||
import com.intellij.util.xmlb.SerializationFilter
|
||||
import com.intellij.util.xmlb.annotations.Transient
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
abstract class BaseState : SerializationFilter, ModificationTracker {
|
||||
@@ -38,7 +39,16 @@ abstract class BaseState : SerializationFilter, ModificationTracker {
|
||||
modificationCount++
|
||||
}
|
||||
|
||||
fun <T> storedProperty(defaultValue: T? = null): StoredPropertyBase<T?> {
|
||||
override fun accepts(accessor: Accessor, bean: Any): Boolean {
|
||||
for (property in properties) {
|
||||
if (property.name == accessor.name) {
|
||||
return property.value != property.defaultValue
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun <T> storedProperty(defaultValue: T? = null): ReadWriteProperty<BaseState, T?> {
|
||||
val result = ObjectStoredProperty(defaultValue)
|
||||
properties.add(result)
|
||||
return result
|
||||
@@ -47,39 +57,30 @@ abstract class BaseState : SerializationFilter, ModificationTracker {
|
||||
/**
|
||||
* Empty string is always normalized to null.
|
||||
*/
|
||||
fun string(defaultValue: String? = null): StoredPropertyBase<String?> {
|
||||
val result = NormalizedStringStoredProperty(defaultValue)
|
||||
fun string(defaultValue: String? = null): ReadWriteProperty<BaseState, String?> {
|
||||
val result = StringStoredProperty(defaultValue)
|
||||
properties.add(result)
|
||||
return result
|
||||
}
|
||||
|
||||
fun storedProperty(defaultValue: Int = 0): StoredPropertyBase<Int> {
|
||||
fun storedProperty(defaultValue: Int = 0): ReadWriteProperty<BaseState, Int> {
|
||||
val result = IntStoredProperty(defaultValue)
|
||||
properties.add(result)
|
||||
return result
|
||||
}
|
||||
|
||||
fun storedProperty(defaultValue: Float = 0f): StoredPropertyBase<Float> {
|
||||
fun storedProperty(defaultValue: Float = 0f): ReadWriteProperty<BaseState, Float> {
|
||||
val result = FloatStoredProperty(defaultValue)
|
||||
properties.add(result)
|
||||
return result
|
||||
}
|
||||
|
||||
fun storedProperty(defaultValue: Boolean = false): StoredPropertyBase<Boolean> {
|
||||
fun storedProperty(defaultValue: Boolean = false): ReadWriteProperty<BaseState, Boolean> {
|
||||
val result = ObjectStoredProperty(defaultValue)
|
||||
properties.add(result)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun accepts(accessor: Accessor, bean: Any): Boolean {
|
||||
for (property in properties) {
|
||||
if (property.name == accessor.name) {
|
||||
return property.value != property.defaultValue
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@Transient
|
||||
override fun getModificationCount(): Long {
|
||||
var result = modificationCount
|
||||
@@ -113,19 +114,41 @@ abstract class BaseState : SerializationFilter, ModificationTracker {
|
||||
assert(state.properties.size == properties.size)
|
||||
for ((index, property) in properties.withIndex()) {
|
||||
val otherProperty = state.properties.get(index)
|
||||
assert(otherProperty.name == property.name)
|
||||
if (property.name != null) {
|
||||
if (otherProperty.name == null) {
|
||||
otherProperty.name = property.name
|
||||
}
|
||||
else {
|
||||
assert(otherProperty.name == property.name)
|
||||
}
|
||||
}
|
||||
property.setValue(otherProperty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ObjectStoredProperty<T>(override val defaultValue: T) : StoredPropertyBase<T>() {
|
||||
override var value = defaultValue
|
||||
internal interface StoredProperty {
|
||||
val defaultValue: Any?
|
||||
val value: Any?
|
||||
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>) = value
|
||||
var name: String?
|
||||
|
||||
fun setValue(other: StoredProperty)
|
||||
}
|
||||
|
||||
private class ObjectStoredProperty<T>(override val defaultValue: T) : ReadWriteProperty<BaseState, T>, StoredProperty {
|
||||
override var value = defaultValue
|
||||
override var name: String? = null
|
||||
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>): T {
|
||||
name = property.name
|
||||
return value
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun setValue(thisRef: BaseState, property: KProperty<*>, @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE") newValue: T) {
|
||||
name = property.name
|
||||
|
||||
if (value != newValue) {
|
||||
thisRef.modificationCount++
|
||||
|
||||
@@ -137,7 +160,7 @@ private class ObjectStoredProperty<T>(override val defaultValue: T) : StoredProp
|
||||
|
||||
override fun hashCode() = value?.hashCode() ?: 0
|
||||
|
||||
override fun toString() = if (value == defaultValue) "" else value?.toString() ?: super.toString()
|
||||
override fun toString() = if (value === defaultValue) "" else value?.toString() ?: super.toString()
|
||||
|
||||
override fun setValue(other: StoredProperty) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -145,13 +168,19 @@ private class ObjectStoredProperty<T>(override val defaultValue: T) : StoredProp
|
||||
}
|
||||
}
|
||||
|
||||
private class NormalizedStringStoredProperty(override val defaultValue: String?) : StoredPropertyBase<String?>() {
|
||||
private class StringStoredProperty(override val defaultValue: String?) : ReadWriteProperty<BaseState, String?>, StoredProperty {
|
||||
override var value = defaultValue
|
||||
override var name: String? = null
|
||||
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>) = value
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>): String? {
|
||||
name = property.name
|
||||
return value
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun setValue(thisRef: BaseState, property: KProperty<*>, @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE") _newValue: String?) {
|
||||
name = property.name
|
||||
|
||||
var newValue = _newValue
|
||||
if (newValue != null && newValue.isEmpty()) {
|
||||
newValue = null
|
||||
@@ -163,24 +192,30 @@ private class NormalizedStringStoredProperty(override val defaultValue: String?)
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?) = this === other || (other is NormalizedStringStoredProperty && value == other.value)
|
||||
override fun equals(other: Any?) = this === other || (other is ObjectStoredProperty<*> && value == other.value)
|
||||
|
||||
override fun hashCode() = value?.hashCode() ?: 0
|
||||
|
||||
override fun toString() = if (value == defaultValue) "" else value ?: super.toString()
|
||||
|
||||
override fun setValue(other: StoredProperty) {
|
||||
value = (other as NormalizedStringStoredProperty).value
|
||||
value = (other as StringStoredProperty).value
|
||||
}
|
||||
}
|
||||
|
||||
private class IntStoredProperty(override val defaultValue: Int) : StoredPropertyBase<Int>() {
|
||||
private class IntStoredProperty(override val defaultValue: Int) : ReadWriteProperty<BaseState, Int>, StoredProperty {
|
||||
override var value = defaultValue
|
||||
override var name: String? = null
|
||||
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>) = value
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>): Int {
|
||||
name = property.name
|
||||
return value
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun setValue(thisRef: BaseState, property: KProperty<*>, @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE") newValue: Int) {
|
||||
name = property.name
|
||||
|
||||
if (value != newValue) {
|
||||
thisRef.modificationCount++
|
||||
|
||||
@@ -199,13 +234,19 @@ private class IntStoredProperty(override val defaultValue: Int) : StoredProperty
|
||||
}
|
||||
}
|
||||
|
||||
private class FloatStoredProperty(override val defaultValue: Float) : StoredPropertyBase<Float>() {
|
||||
private class FloatStoredProperty(override val defaultValue: Float) : ReadWriteProperty<BaseState, Float>, StoredProperty {
|
||||
override var value = defaultValue
|
||||
override var name: String? = null
|
||||
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>) = value
|
||||
override operator fun getValue(thisRef: BaseState, property: KProperty<*>): Float {
|
||||
name = property.name
|
||||
return value
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun setValue(thisRef: BaseState, property: KProperty<*>, @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE") newValue: Float) {
|
||||
name = property.name
|
||||
|
||||
if (value != newValue) {
|
||||
thisRef.modificationCount++
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-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 com.intellij.openapi.components
|
||||
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
internal interface StoredProperty {
|
||||
val defaultValue: Any?
|
||||
val value: Any?
|
||||
|
||||
var name: String?
|
||||
|
||||
fun setValue(other: StoredProperty)
|
||||
}
|
||||
|
||||
// type must be exposed otherwise `provideDelegate` doesn't work
|
||||
abstract class StoredPropertyBase<T> : ReadWriteProperty<BaseState, T>, StoredProperty {
|
||||
override final var name: String? = null
|
||||
|
||||
operator fun provideDelegate(thisRef: Any, property: KProperty<*>): ReadWriteProperty<BaseState, T> {
|
||||
name = property.name
|
||||
return this
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="2" platform="JVM 1.8" useProjectSettings="false">
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
<option name="languageVersion" value="1.1" />
|
||||
<option name="apiVersion" value="1.1" />
|
||||
<option name="coroutinesError" value="true" />
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
|
||||
@@ -31,8 +31,8 @@ import java.net.URL
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
import kotlin.concurrent.read
|
||||
import kotlin.concurrent.write
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
import kotlin.reflect.primaryConstructor
|
||||
|
||||
@JvmOverloads
|
||||
fun <T : Any> T.serialize(filter: SerializationFilter? = SkipDefaultsSerializationFilter()): Element {
|
||||
|
||||
Reference in New Issue
Block a user