mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
IDEA-185495 Custom plugin repository URL is lost on IDE restart
This commit is contained in:
@@ -4,6 +4,7 @@ import com.intellij.openapi.components.BaseState
|
||||
import com.intellij.testFramework.assertions.Assertions.assertThat
|
||||
import com.intellij.util.loadElement
|
||||
import com.intellij.util.xmlb.annotations.Attribute
|
||||
import com.intellij.util.xmlb.annotations.CollectionBean
|
||||
import org.junit.Test
|
||||
|
||||
internal class AState(languageLevel: String? = null, nestedComplex: NestedState? = null) : BaseState() {
|
||||
@@ -97,4 +98,29 @@ class StoredPropertyStateTest {
|
||||
assertThat(state.languageLevel as String?).isEqualTo("foo")
|
||||
assertThat(state.modificationCount).isEqualTo(5)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listModificationCount() {
|
||||
class UpdateOptions : BaseState() {
|
||||
@get:CollectionBean
|
||||
val pluginHosts by list<String>()
|
||||
}
|
||||
|
||||
val state = UpdateOptions()
|
||||
val oldModificationCount = state.modificationCount
|
||||
|
||||
val list = state.pluginHosts
|
||||
list.clear()
|
||||
list.addAll(listOf("foo"))
|
||||
assertThat(state.modificationCount).isNotEqualTo(oldModificationCount)
|
||||
assertThat(state.isEqualToDefault()).isFalse()
|
||||
|
||||
val element = state.serialize()
|
||||
assertThat(element).isEqualTo("""
|
||||
<UpdateOptions>
|
||||
<pluginHosts>
|
||||
<item value="foo" />
|
||||
</pluginHosts>
|
||||
</UpdateOptions>""")
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -66,10 +52,9 @@ public class PluginHostsConfigurable extends BaseConfigurable implements Configu
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
UpdateSettings settings = UpdateSettings.getInstance();
|
||||
|
||||
settings.getStoredPluginHosts().clear();
|
||||
settings.getStoredPluginHosts().addAll(myUpdatesSettingsPanel.getPluginsHosts());
|
||||
List<String> list = UpdateSettings.getInstance().getStoredPluginHosts();
|
||||
list.clear();
|
||||
list.addAll(myUpdatesSettingsPanel.getPluginsHosts());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.components
|
||||
|
||||
import com.intellij.configurationStore.properties.*
|
||||
@@ -169,7 +167,7 @@ abstract class BaseState : SerializationFilter, ModificationTracker {
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun isEqualToDefault() = properties.all { it.isEqualToDefault() }
|
||||
fun isEqualToDefault() = properties.all { it.isEqualToDefault() }
|
||||
|
||||
@Transient
|
||||
override fun getModificationCount(): Long {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.testFramework.assertions
|
||||
|
||||
import com.intellij.configurationStore.deserialize
|
||||
@@ -55,7 +53,7 @@ class JdomAssert(actual: Element?) : AbstractAssert<JdomAssert, Element?>(actual
|
||||
return this
|
||||
}
|
||||
|
||||
fun isEqualTo(expected: String): JdomAssert {
|
||||
fun isEqualTo(@Language("xml") expected: String): JdomAssert {
|
||||
isNotNull
|
||||
|
||||
Objects.instance().assertEqual(
|
||||
|
||||
@@ -348,13 +348,11 @@ public class BeanBinding extends NotNullDeserializeBinding {
|
||||
|
||||
for (Iterator<Map.Entry<String, Couple<Method>>> iterator = candidates.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Map.Entry<String, Couple<Method>> candidate = iterator.next();
|
||||
// (getter,setter)
|
||||
Couple<Method> methods = candidate.getValue();
|
||||
if (methods.first != null && methods.second != null &&
|
||||
methods.first.getReturnType().equals(methods.second.getParameterTypes()[0]) &&
|
||||
methods.first.getAnnotation(Transient.class) == null &&
|
||||
methods.second.getAnnotation(Transient.class) == null) {
|
||||
accessors.add(new PropertyAccessor(candidate.getKey(), methods.first.getReturnType(), methods.first, methods.second));
|
||||
Method getter = methods.first;
|
||||
Method setter = methods.second;
|
||||
if (isAcceptableProperty(getter, setter)) {
|
||||
accessors.add(new PropertyAccessor(candidate.getKey(), getter.getReturnType(), getter, setter));
|
||||
}
|
||||
else {
|
||||
iterator.remove();
|
||||
@@ -363,6 +361,23 @@ public class BeanBinding extends NotNullDeserializeBinding {
|
||||
return candidates;
|
||||
}
|
||||
|
||||
private static boolean isAcceptableProperty(@Nullable Method getter, @Nullable Method setter) {
|
||||
if (getter == null || getter.getAnnotation(Transient.class) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (setter == null) {
|
||||
// check hasStoreAnnotations to ensure that this addition will not lead to regression (since there is a chance that there is some existing not-annotated list getters without setter)
|
||||
return (List.class.isAssignableFrom(getter.getReturnType()) || Map.class.isAssignableFrom(getter.getReturnType())) && hasStoreAnnotations(getter);
|
||||
}
|
||||
|
||||
if (setter.getAnnotation(Transient.class) != null || !getter.getReturnType().equals(setter.getParameterTypes()[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean hasStoreAnnotations(@NotNull AccessibleObject object) {
|
||||
//noinspection deprecation
|
||||
return object.getAnnotation(OptionTag.class) != null ||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.xmlb;
|
||||
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
@@ -27,7 +25,7 @@ public class PropertyAccessor implements MutableAccessor {
|
||||
this(descriptor.getName(), descriptor.getPropertyType(), descriptor.getReadMethod(), descriptor.getWriteMethod());
|
||||
}
|
||||
|
||||
public PropertyAccessor(String name, Class<?> type, @NotNull Method readMethod, @NotNull Method writeMethod) {
|
||||
public PropertyAccessor(String name, Class<?> type, @NotNull Method readMethod, @Nullable Method writeMethod) {
|
||||
myName = name;
|
||||
myType = type;
|
||||
myReadMethod = readMethod;
|
||||
@@ -36,7 +34,9 @@ public class PropertyAccessor implements MutableAccessor {
|
||||
|
||||
try {
|
||||
myReadMethod.setAccessible(true);
|
||||
myWriteMethod.setAccessible(true);
|
||||
if (myWriteMethod != null) {
|
||||
myWriteMethod.setAccessible(true);
|
||||
}
|
||||
}
|
||||
catch (SecurityException ignored) { }
|
||||
}
|
||||
@@ -126,7 +126,9 @@ public class PropertyAccessor implements MutableAccessor {
|
||||
@Override
|
||||
public <T extends Annotation> T getAnnotation(@NotNull Class<T> annotationClass) {
|
||||
T annotation = myReadMethod.getAnnotation(annotationClass);
|
||||
if (annotation == null) annotation = myWriteMethod.getAnnotation(annotationClass);
|
||||
if (annotation == null && myWriteMethod != null) {
|
||||
annotation = myWriteMethod.getAnnotation(annotationClass);
|
||||
}
|
||||
return annotation;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user