diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java index 0ea7e96130f7..55a72aa7dbb3 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java @@ -1,4 +1,6 @@ -// 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-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. + */ package com.intellij.debugger.settings; import com.intellij.debugger.impl.DebuggerUtilsEx; @@ -16,9 +18,9 @@ import com.intellij.util.EventDispatcher; import com.intellij.util.containers.hash.LinkedHashMap; import com.intellij.util.xmlb.SkipDefaultsSerializationFilter; import com.intellij.util.xmlb.XmlSerializer; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.Transient; +import com.intellij.util.xmlb.annotations.XCollection; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -201,7 +203,7 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent getCapturePoints() { return myCapturePoints; } diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java index a7e8fbe33d0e..4ef874f4fe55 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 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-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. */ package org.jetbrains.java.debugger.breakpoints.properties; @@ -19,9 +7,9 @@ import com.intellij.debugger.InstanceFilter; import com.intellij.openapi.util.Comparing; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.ArrayUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.OptionTag; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import com.intellij.xdebugger.breakpoints.XBreakpointProperties; import org.jetbrains.annotations.Nullable; @@ -40,7 +28,7 @@ public class JavaBreakpointProperties extend private InstanceFilter[] myInstanceFilters; @Tag("instance-filters") - @AbstractCollection(surroundWithTag = false) + @XCollection public InstanceFilter[] getInstanceFilters() { return myInstanceFilters != null ? myInstanceFilters : InstanceFilter.EMPTY_ARRAY; } @@ -62,7 +50,7 @@ public class JavaBreakpointProperties extend } @Tag("class-filters") - @AbstractCollection(surroundWithTag = false) + @XCollection public final ClassFilter[] getClassFilters() { return myClassFilters != null ? myClassFilters : ClassFilter.EMPTY_ARRAY; } @@ -81,7 +69,7 @@ public class JavaBreakpointProperties extend } @Tag("class-exclusion-filters") - @AbstractCollection(surroundWithTag = false) + @XCollection public ClassFilter[] getClassExclusionFilters() { return myClassExclusionFilters != null ? myClassExclusionFilters : ClassFilter.EMPTY_ARRAY; } diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java index 37e141bbcb97..92c756e288c9 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java @@ -1,25 +1,13 @@ /* - * Copyright 2000-2016 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-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. */ package org.jetbrains.java.debugger.breakpoints.properties; import com.intellij.ui.classFilter.ClassFilter; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.OptionTag; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.Nullable; /** @@ -79,7 +67,7 @@ public class JavaExceptionBreakpointProperties extends JavaBreakpointProperties< } @Tag("catch-class-filters") - @AbstractCollection(surroundWithTag = false) + @XCollection public final ClassFilter[] getCatchClassFilters() { return myCatchClassFilters != null ? myCatchClassFilters : ClassFilter.EMPTY_ARRAY; } @@ -91,7 +79,7 @@ public class JavaExceptionBreakpointProperties extends JavaBreakpointProperties< } @Tag("catch-class-exclusion-filters") - @AbstractCollection(surroundWithTag = false) + @XCollection public ClassFilter[] getCatchClassExclusionFilters() { return myCatchClassExclusionFilters != null ? myCatchClassExclusionFilters : ClassFilter.EMPTY_ARRAY; } diff --git a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java index fce7ad5a5240..29a1e8fa3153 100644 --- a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java +++ b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java @@ -1,4 +1,6 @@ -// 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-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. + */ package com.intellij.execution.applet; import com.intellij.application.options.ModulesComboBox; @@ -17,6 +19,8 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; import com.intellij.ui.components.JBLabel; import com.intellij.ui.table.TableView; +import com.intellij.util.SmartList; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.ListTableModel; import org.jetbrains.annotations.NonNls; @@ -29,7 +33,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class AppletConfigurable extends SettingsEditor implements CheckableRunConfigurationEditor, @@ -60,25 +63,25 @@ public class AppletConfigurable extends SettingsEditor impl private static final ColumnInfo[] PARAMETER_COLUMNS = new ColumnInfo[]{ new MyColumnInfo(ExecutionBundle.message("applet.configuration.parameter.name.column")) { - public String valueOf(final AppletConfiguration.AppletParameter appletParameter) { + public String valueOf(final AppletParameter appletParameter) { return appletParameter.getName(); } - public void setValue(final AppletConfiguration.AppletParameter appletParameter, final String name) { + public void setValue(final AppletParameter appletParameter, final String name) { appletParameter.setName(name); } }, new MyColumnInfo(ExecutionBundle.message("applet.configuration.parameter.value.column")) { - public String valueOf(final AppletConfiguration.AppletParameter appletParameter) { + public String valueOf(final AppletParameter appletParameter) { return appletParameter.getValue(); } - public void setValue(final AppletConfiguration.AppletParameter appletParameter, final String value) { + public void setValue(final AppletParameter appletParameter, final String value) { appletParameter.setValue(value); } } }; - private final ListTableModel myParameters; + private final ListTableModel myParameters; private final TableView myTable; @NonNls protected static final String HTTP_PREFIX = "http:/"; @@ -153,9 +156,9 @@ public class AppletConfigurable extends SettingsEditor impl } private void addParameter() { - final ArrayList newItems = + final ArrayList newItems = new ArrayList<>(myParameters.getItems()); - final AppletConfiguration.AppletParameter parameter = new AppletConfiguration.AppletParameter("newParameter", ""); + final AppletParameter parameter = new AppletParameter("newParameter", ""); newItems.add(parameter); myParameters.setItems(newItems); @@ -172,10 +175,10 @@ public class AppletConfigurable extends SettingsEditor impl return myPolicyFile.getComponent(); } - private static List cloneParameters(final List items) { - final List params = new ArrayList<>(); - for (AppletConfiguration.AppletParameter appletParameter : items) { - params.add(new AppletConfiguration.AppletParameter(appletParameter.getName(), appletParameter.getValue())); + private static List cloneParameters(@NotNull List items) { + List params = new SmartList<>(); + for (AppletParameter appletParameter : items) { + params.add(new AppletParameter(appletParameter.getName(), appletParameter.getValue())); } return params; } @@ -192,11 +195,6 @@ public class AppletConfigurable extends SettingsEditor impl return myHtmlFile; } - private static String toNull(String s) { - s = s.trim(); - return s.length() == 0 ? null : s; - } - private static String toSystemFormat(String s) { s = s.trim(); return s.length() == 0 ? null : s.replace(File.separatorChar, '/'); @@ -205,8 +203,7 @@ public class AppletConfigurable extends SettingsEditor impl public void applyEditorTo(@NotNull final AppletConfiguration configuration) { checkEditorData(configuration); myTable.stopEditing(); - final List params = cloneParameters(myParameters.getItems()); - configuration.setAppletParameters(params); + configuration.getOptions().setAppletParameters(ContainerUtil.nullize(cloneParameters(myParameters.getItems()))); } public void resetEditorFrom(@NotNull AppletConfiguration runConfiguration) { @@ -225,13 +222,9 @@ public class AppletConfigurable extends SettingsEditor impl (configuration.getHtmlUsed() ? myURL : myMainClass).setSelected(true); changePanel(); - final AppletConfiguration.AppletParameter[] appletParameters = runConfiguration.getAppletParameters(); - if (appletParameters != null) { - myParameters.setItems(cloneParameters(Arrays.asList(appletParameters))); - } + myParameters.setItems(cloneParameters(ContainerUtil.notNullize(configuration.getAppletParameters()))); myModuleSelector.reset(runConfiguration); - myJrePathEditor - .setPathOrName(configuration.getAlternativeJrePath(), configuration.getAlternativeJrePathEnabled()); + myJrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.getAlternativeJrePathEnabled()); } private RawCommandLineEditor getVMParametersComponent() { @@ -289,18 +282,18 @@ public class AppletConfigurable extends SettingsEditor impl myHtmlFileLabel.setAnchor(anchor); } - private static abstract class MyColumnInfo extends ColumnInfo { + private static abstract class MyColumnInfo extends ColumnInfo { public MyColumnInfo(final String name) { super(name); } - public TableCellEditor getEditor(final AppletConfiguration.AppletParameter item) { + public TableCellEditor getEditor(final AppletParameter item) { final JTextField textField = new JTextField(); textField.setBorder(BorderFactory.createLineBorder(Color.BLACK)); return new DefaultCellEditor(textField); } - public boolean isCellEditable(final AppletConfiguration.AppletParameter appletParameter) { + public boolean isCellEditable(final AppletParameter appletParameter) { return true; } } diff --git a/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java b/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java index a97b70a26078..ce2ba1f6e55f 100644 --- a/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java @@ -16,13 +16,12 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JdkUtil; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.refactoring.listeners.RefactoringElementListener; -import com.intellij.util.SmartList; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.Transient; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -34,22 +33,15 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.Collection; -import java.util.List; public class AppletConfiguration extends ModuleBasedConfiguration implements SingleClassConfiguration, RefactoringListenerProvider, PersistentStateComponent { - private static final String NAME_ATTR = "name"; - private static final String VALUE_ATTR = "value"; - private static final String PARAMETER_ELEMENT_NAME = "parameter"; - - private AppletParameter[] myAppletParameters; - public AppletConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory) { super(new JavaRunConfigurationModule(project, false), factory); } @Override - protected AppletConfigurationOptions getOptions() { + public AppletConfigurationOptions getOptions() { return (AppletConfigurationOptions)super.getOptions(); } @@ -129,42 +121,6 @@ public class AppletConfiguration extends ModuleBasedConfiguration getValidModules() { return JavaRunConfigurationModule.getModulesForClass(getProject(), getOptions().getMainClassName()); @@ -174,35 +130,9 @@ public class AppletConfiguration extends ModuleBasedConfiguration paramList = element.getChildren(PARAMETER_ELEMENT_NAME); - if (paramList.isEmpty()) { - myAppletParameters = null; - } - else { - List parameters = new SmartList<>(); - for (Element child : paramList) { - parameters.add(new AppletParameter(child.getAttributeValue(NAME_ATTR), child.getAttributeValue(VALUE_ATTR))); - } - myAppletParameters = parameters.toArray(new AppletParameter[parameters.size()]); - } - } - @Override public RefactoringElementListener getRefactoringElementListener(final PsiElement element) { if (getOptions().getHtmlUsed()) { @@ -256,19 +186,6 @@ public class AppletConfiguration extends ModuleBasedConfiguration parameters) { - setAppletParameters(parameters.toArray(new AppletParameter[parameters.size()])); - } - private AppletHtmlFile getHtmlURL() throws CantRunException { if (getOptions().getHtmlUsed()) { if (getOptions().getHtmlFileName() == null) { @@ -306,11 +223,8 @@ public class AppletConfiguration extends ModuleBasedConfiguration\n"); - final AppletParameter[] appletParameters = getAppletParameters(); - if (appletParameters != null) { - for (final AppletParameter parameter : appletParameters) { - writer.write("\n"); - } + for (AppletParameter parameter : ContainerUtil.notNullize(getOptions().getAppletParameters())) { + writer.write("\n"); } writer.write("\n\n\n"); } diff --git a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurationOptions.kt b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurationOptions.kt index ba08da39bd86..e9fed4b6c363 100644 --- a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurationOptions.kt +++ b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurationOptions.kt @@ -3,20 +3,43 @@ */ package com.intellij.execution.applet +import com.intellij.execution.ExternalizablePath import com.intellij.execution.configurations.ModuleBasedConfigurationOptions -import com.intellij.util.xmlb.annotations.OptionTag +import com.intellij.openapi.application.PathManager +import com.intellij.util.xmlb.annotations.* class AppletConfigurationOptions : ModuleBasedConfigurationOptions() { - @get:OptionTag("MAIN_CLASS_NAME") var mainClassName by string() - @get:OptionTag("HTML_FILE_NAME") var htmlFileName by string() - @get:OptionTag("HTML_USED") var htmlUsed by storedProperty(false) + @get:OptionTag("MAIN_CLASS_NAME") + var mainClassName by string() - @get:OptionTag("WIDTH") var width by storedProperty(400) - @get:OptionTag("HEIGHT") var height by storedProperty(300) + @get:OptionTag("HTML_FILE_NAME") + var htmlFileName by string() - @get:OptionTag("POLICY_FILE") var policyFile by string() - @get:OptionTag("VM_PARAMETERS") var vmParameters by string() + @get:OptionTag("HTML_USED") + var htmlUsed by storedProperty(false) - @get:OptionTag("ALTERNATIVE_JRE_PATH_ENABLED") var alternativeJrePathEnabled by storedProperty(false) - @get:OptionTag("ALTERNATIVE_JRE_PATH") var alternativeJrePath by string() -} \ No newline at end of file + @get:OptionTag("WIDTH") + var width by storedProperty(400) + + @get:OptionTag("HEIGHT") + var height by storedProperty(300) + + @get:OptionTag("POLICY_FILE") + var policyFile by string(ExternalizablePath.urlValue("${PathManager.getHomePath()}/bin/appletviewer.policy")) + + @get:OptionTag("VM_PARAMETERS") + var vmParameters by string() + + @get:OptionTag("ALTERNATIVE_JRE_PATH_ENABLED") + var alternativeJrePathEnabled by storedProperty(false) + + @get:OptionTag("ALTERNATIVE_JRE_PATH") + var alternativeJrePath by string() + + @get:Property(surroundWithTag = false) + @get:XCollection() + var appletParameters by storedProperty?>() +} + +@Tag("parameter") +data class AppletParameter(@get:Attribute("name") var name: String? = null, @get:Attribute("value") var value: String? = null) \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/internal/statistic/libraryJar/LibraryJarDescriptors.java b/java/java-impl/src/com/intellij/internal/statistic/libraryJar/LibraryJarDescriptors.java index f9234abdfcd2..57ffcddd110e 100644 --- a/java/java-impl/src/com/intellij/internal/statistic/libraryJar/LibraryJarDescriptors.java +++ b/java/java-impl/src/com/intellij/internal/statistic/libraryJar/LibraryJarDescriptors.java @@ -1,27 +1,14 @@ /* - * Copyright 2000-2016 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-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. */ package com.intellij.internal.statistic.libraryJar; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.XCollection; public class LibraryJarDescriptors { - @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public LibraryJarDescriptor[] myDescriptors; public LibraryJarDescriptor[] getDescriptors() { diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactManagerState.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactManagerState.java index a54ca9ba2496..4a29e65a2da3 100644 --- a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactManagerState.java +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactManagerState.java @@ -1,23 +1,11 @@ /* - * Copyright 2000-2012 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-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. */ package org.jetbrains.jps.model.serialization.artifact; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Property; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import java.util.ArrayList; import java.util.List; @@ -30,7 +18,7 @@ public class ArtifactManagerState { private List myArtifacts = new ArrayList<>(); @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List getArtifacts() { return myArtifacts; } diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactState.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactState.java index 4ec515c71f3c..4b9c6e604cbe 100644 --- a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactState.java +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/artifact/ArtifactState.java @@ -1,29 +1,17 @@ /* - * Copyright 2000-2012 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-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. */ package org.jetbrains.jps.model.serialization.artifact; import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.Property; -import com.intellij.util.xmlb.annotations.AbstractCollection; +import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jdom.Element; import org.jetbrains.annotations.NonNls; -import java.util.List; import java.util.ArrayList; +import java.util.List; /** * @author nik @@ -70,7 +58,7 @@ public class ArtifactState { } @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List getPropertiesList() { return myPropertiesList; } diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetManagerState.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetManagerState.java index 88b359f3c345..f6726fdf9f33 100644 --- a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetManagerState.java +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetManagerState.java @@ -1,26 +1,13 @@ /* - * Copyright 2000-2012 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-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. */ - package org.jetbrains.jps.model.serialization.facet; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.XCollection; -import java.util.List; import java.util.ArrayList; +import java.util.List; /** * @author nik @@ -29,7 +16,7 @@ public class FacetManagerState { private List myFacets = new ArrayList<>(); @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List getFacets() { return myFacets; } diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetState.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetState.java index 69d0f7aa50a7..bba0c6198020 100644 --- a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetState.java +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/facet/FacetState.java @@ -1,29 +1,17 @@ /* - * Copyright 2000-2012 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-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. */ package org.jetbrains.jps.model.serialization.facet; import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Tag; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jdom.Element; -import java.util.List; import java.util.ArrayList; +import java.util.List; /** * @author nik @@ -57,7 +45,7 @@ public class FacetState { } @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List getSubFacets() { return mySubFacets; } diff --git a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java index 76961b7e275a..1157ab5ab212 100644 --- a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java +++ b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java @@ -1,10 +1,16 @@ +/* + * 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. + */ package com.jetbrains.jsonSchema; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import com.jetbrains.jsonSchema.ide.JsonSchemaService; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,15 +20,7 @@ import java.util.Map; import java.util.Optional; import java.util.TreeMap; -/** - * @author Irina.Chernushina on 2/2/2016. - */ -@State( - name = "JsonSchemaMappingsProjectConfiguration", - storages = { - @Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/jsonSchemas.xml", scheme = StorageScheme.DIRECTORY_BASED) - } -) +@State(name = "JsonSchemaMappingsProjectConfiguration", storages = @Storage("jsonSchemas.xml")) public class JsonSchemaMappingsProjectConfiguration implements PersistentStateComponent { public volatile MyState myState = new MyState(); @@ -39,7 +37,6 @@ public class JsonSchemaMappingsProjectConfiguration implements PersistentStateCo return myState; } - public void schemaFileMoved(@NotNull final Project project, @NotNull final String oldRelativePath, @NotNull final String newRelativePath) { @@ -66,7 +63,7 @@ public class JsonSchemaMappingsProjectConfiguration implements PersistentStateCo } static class MyState { - @Tag("state") @AbstractCollection(surroundWithTag = false) + @Tag("state") @XCollection public Map myState = new TreeMap<>(); public MyState() { diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt index c3cbd591efbd..31c30c6b3220 100644 --- a/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt +++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt @@ -3,13 +3,19 @@ package com.intellij.configurationStore.xml import com.intellij.configurationStore.deserialize +import com.intellij.ide.plugins.PluginBean import com.intellij.openapi.util.JDOMExternalizableStringList +import com.intellij.openapi.util.JDOMUtil +import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.util.SmartList +import com.intellij.util.loadElement import com.intellij.util.xmlb.SkipDefaultsSerializationFilter import com.intellij.util.xmlb.XmlSerializationException +import com.intellij.util.xmlb.XmlSerializer import com.intellij.util.xmlb.annotations.AbstractCollection import com.intellij.util.xmlb.annotations.CollectionBean import com.intellij.util.xmlb.annotations.Tag +import com.intellij.util.xmlb.annotations.XCollection import org.assertj.core.api.Assertions.assertThatThrownBy import org.jdom.Element import org.junit.Test @@ -83,7 +89,7 @@ internal class XmlSerializerCollectionTest { val bean = BeanWithArrayWithoutTagName() assertThatThrownBy({ doSerializerTest( - "", + """""", bean) }).isInstanceOf(XmlSerializationException::class.java) } @@ -192,6 +198,101 @@ internal class XmlSerializerCollectionTest { "\n \n", bean) } + + @Test fun testPropertyAndNoSurround() { + val bean = XmlSerializer.deserialize(loadElement(""" + com.intellij.database.ide + DataGrip Customization + JetBrains + Database + + com.intellij.modules.datagrip + com.intellij.database + + + + + + + + + + + + + + + + + + com.intellij.database.ide.DataGripInitialConfigurator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + """), PluginBean::class.java) + + assertThat(bean.actions.joinToString("\n") { JDOMUtil.writeElement(it) }).isEqualTo(""" + + + + + + + + + + + + + + + + + + """.trimIndent()) + } } @Tag("b") @@ -207,6 +308,6 @@ private class Bean4 { } private class BeanWithArrayWithoutTagName { - @AbstractCollection(surroundWithTag = false) + @XCollection() var V = arrayOf("a") } \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java b/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java index a793f1fe3b08..8662877cc321 100644 --- a/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java +++ b/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java @@ -1,25 +1,10 @@ /* - * 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-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. */ package com.intellij.ide.plugins; import com.intellij.openapi.components.OldComponentConfig; -import com.intellij.util.xmlb.annotations.AbstractCollection; -import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Property; -import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.*; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -28,15 +13,15 @@ import java.util.List; public class PluginBean { @Tag(APPLICATION_COMPONENTS) - @AbstractCollection(surroundWithTag = false) + @XCollection public OldComponentConfig[] applicationComponents; @Tag(PROJECT_COMPONENTS) - @AbstractCollection(surroundWithTag = false) + @XCollection public OldComponentConfig[] projectComponents; @Tag(MODULE_COMPONENTS) - @AbstractCollection(surroundWithTag = false) + @XCollection public OldComponentConfig[] moduleComponents; @NonNls public static final String APPLICATION_COMPONENTS = "application-components"; @@ -77,11 +62,11 @@ public class PluginBean { public Element[] actions; @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public PluginDependency[] dependencies; @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public PluginHelpSet[] helpSets; @Tag("category") diff --git a/platform/core-api/src/com/intellij/psi/PsiReferenceProviderBean.java b/platform/core-api/src/com/intellij/psi/PsiReferenceProviderBean.java index f8bb0b9b2841..438b28801737 100644 --- a/platform/core-api/src/com/intellij/psi/PsiReferenceProviderBean.java +++ b/platform/core-api/src/com/intellij/psi/PsiReferenceProviderBean.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2014 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-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. */ package com.intellij.psi; @@ -27,10 +15,10 @@ import com.intellij.patterns.StandardPatterns; import com.intellij.util.KeyedLazyInstance; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Property; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,7 +42,7 @@ public class PsiReferenceProviderBean extends AbstractExtensionPointBean impleme public String description; @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public ElementPatternBean[] patterns; public String getDescription() { diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java index f434520cd872..a328b4192c7b 100644 --- a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 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-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. */ package com.intellij.dvcs.push; @@ -20,9 +8,9 @@ import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.components.StoragePathMacros; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +22,7 @@ public class PushSettings implements PersistentStateComponent FORCE_PUSH_TARGETS = ContainerUtil.newArrayList(); } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java index 9751c398cd5e..5d5581ac636b 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorage.java @@ -1,17 +1,5 @@ /* - * 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. + * 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. */ package com.intellij.openapi.externalSystem.service.project.manage; @@ -40,9 +28,9 @@ import com.intellij.util.Alarm; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.MapAnnotation; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -469,7 +457,7 @@ public class ExternalProjectsDataStorage implements SettingsSavingComponent, Per static class ModuleState { @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false, elementTag = "id") + @XCollection(elementName = "id") public final Set set = ContainerUtil.newConcurrentSet(); public ModuleState() { diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java index d89348568262..96a5ce6f5e64 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java @@ -1,22 +1,10 @@ /* - * Copyright 2000-2014 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-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. */ package com.intellij.openapi.externalSystem.service.project.manage; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -29,31 +17,31 @@ import java.util.List; @Tag("activation") public class TaskActivationState { @Tag("before_run") - @AbstractCollection(surroundWithTag = false, elementTag = "task", elementValueAttribute = "name") + @XCollection(elementName = "task", valueAttributeName = "name") public List beforeRunTasks = new ArrayList<>(); @Tag("before_sync") - @AbstractCollection(surroundWithTag = false, elementTag = "task", elementValueAttribute = "name") + @XCollection(elementName = "task", valueAttributeName = "name") public List beforeSyncTasks = new ArrayList<>(); @Tag("after_sync") - @AbstractCollection(surroundWithTag = false, elementTag = "task", elementValueAttribute = "name") + @XCollection(elementName = "task", valueAttributeName = "name") public List afterSyncTasks = new ArrayList<>(); @Tag("before_compile") - @AbstractCollection(surroundWithTag = false, elementTag = "task", elementValueAttribute = "name") + @XCollection(elementName = "task", valueAttributeName = "name") public List beforeCompileTasks = new ArrayList<>(); @Tag("after_compile") - @AbstractCollection(surroundWithTag = false, elementTag = "task", elementValueAttribute = "name") + @XCollection(elementName = "task", valueAttributeName = "name") public List afterCompileTasks = new ArrayList<>(); @Tag("after_rebuild") - @AbstractCollection(surroundWithTag = false, elementTag = "task", elementValueAttribute = "name") + @XCollection(elementName = "task", valueAttributeName = "name") public List afterRebuildTask = new ArrayList<>(); @Tag("before_rebuild") - @AbstractCollection(surroundWithTag = false, elementTag = "task", elementValueAttribute = "name") + @XCollection(elementName = "task", valueAttributeName = "name") public List beforeRebuildTask = new ArrayList<>(); public boolean isEmpty() { diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java index d397a1d9ff52..2bdcf838b65a 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java @@ -196,6 +196,10 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements public void customizeLogConsole(LogConsole console) { } + public void loadState(@NotNull Element element) { + readExternal(element); + } + @Override public void readExternal(@NotNull Element element) throws InvalidDataException { myLogFiles.clear(); diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifact.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifact.java index abf47adf0a95..15955396312b 100644 --- a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifact.java +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifact.java @@ -1,9 +1,12 @@ +/* + * 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. + */ package com.intellij.facet.frameworks.beans; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Property; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; /** * @deprecated this class will be removed from open API in IDEA 11. Use {@link com.intellij.util.download.DownloadableFileService} instead @@ -13,7 +16,7 @@ public class Artifact { public static final Artifact[] EMPTY_ARRAY = new Artifact[0]; @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public ArtifactItem[] myItems; @Attribute("version") diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/ArtifactItem.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/ArtifactItem.java index 9bd38e022940..bfa247745fbb 100644 --- a/platform/lang-api/src/com/intellij/facet/frameworks/beans/ArtifactItem.java +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/ArtifactItem.java @@ -1,36 +1,21 @@ /* - * Copyright 2000-2010 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-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. */ - package com.intellij.facet.frameworks.beans; import com.intellij.util.ArrayUtil; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Property; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import java.util.List; @Tag("item") public class ArtifactItem { - @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public RequiredClass[] myRequiredClasses; @Attribute("name") diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java index 9e5499de5b07..f7e8fd49b0ff 100644 --- a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java @@ -1,12 +1,15 @@ +/* + * 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. + */ package com.intellij.facet.frameworks.beans; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.XCollection; public class Artifacts { @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public Artifact[] myVersions; public Artifact[] getArtifacts() { diff --git a/platform/lang-impl/src/com/intellij/execution/ExternalizablePath.java b/platform/lang-impl/src/com/intellij/execution/ExternalizablePath.java index 93a483fb11d6..b9d6a1781c96 100644 --- a/platform/lang-impl/src/com/intellij/execution/ExternalizablePath.java +++ b/platform/lang-impl/src/com/intellij/execution/ExternalizablePath.java @@ -1,9 +1,10 @@ -// 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-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. + */ package com.intellij.execution; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -12,8 +13,6 @@ import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; -import java.io.File; - /** * @author dyoma */ @@ -31,7 +30,7 @@ public class ExternalizablePath implements JDOMExternalizable { } @Override - public void writeExternal(final Element element) throws WriteExternalException { + public void writeExternal(final Element element) { element.setAttribute(VALUE_ATTRIBUTE, myUrl); } @@ -40,7 +39,7 @@ public class ExternalizablePath implements JDOMExternalizable { } public static String urlValue(String localPath) { - return StringUtil.isEmptyOrSpaces(localPath) ? "" : VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, localPath.trim().replace(File.separatorChar, '/')); + return StringUtil.isEmptyOrSpaces(localPath) ? "" : VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, FileUtilRt.toSystemIndependentName(localPath.trim())); } public static String localPathValue(@Nullable String url) { diff --git a/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java b/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java index c4b347f4c8f9..7d0fd8de86b3 100644 --- a/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java +++ b/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java @@ -1,39 +1,24 @@ /* - * 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-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. */ package com.intellij.execution.startup; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.XmlSerializerUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.Transient; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; -/** - * @author Irina.Chernushina on 8/19/2015. - */ public class ProjectStartupConfigurationBase implements PersistentStateComponent { - @Tag("configurations") @AbstractCollection(surroundWithTag = false) + @Tag("configurations") + @XCollection private final List myList; protected ProjectStartupConfigurationBase() { diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/ExcludesConfigurationState.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/ExcludesConfigurationState.java index 9539cc625fd8..56fd3d271446 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/ExcludesConfigurationState.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/ExcludesConfigurationState.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2011 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-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. */ package com.intellij.framework.detection.impl.exclude; @@ -19,6 +7,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.XCollection; import java.util.ArrayList; import java.util.List; @@ -38,7 +27,7 @@ public class ExcludesConfigurationState { } @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List getFiles() { return myFiles; } diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java index a3613ca3c0f9..0510b5ab8af1 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2009 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-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. */ package com.intellij.framework.detection.impl.exclude.old; @@ -19,9 +7,9 @@ package com.intellij.framework.detection.impl.exclude.old; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.SortedList; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -62,7 +50,7 @@ public class DisabledAutodetectionByTypeElement { } @Tag("modules") - @AbstractCollection(surroundWithTag = false) + @XCollection public List getModuleElements() { return myModuleElements; } diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java index 9ce825838e49..c78a040e55c3 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java @@ -1,24 +1,12 @@ /* - * Copyright 2000-2009 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-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. */ package com.intellij.framework.detection.impl.exclude.old; import com.intellij.util.containers.SortedList; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,7 +19,7 @@ public class DisabledAutodetectionInfo { private List myElements = new SortedList<>(DisabledAutodetectionByTypeElement.COMPARATOR); @Tag("autodetection-disabled") - @AbstractCollection(surroundWithTag = false) + @XCollection public List getElements() { return myElements; } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java index 8641de73cec5..93e8980168ca 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java @@ -1,17 +1,5 @@ /* - * 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. + * 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. */ package com.intellij.ide.projectView.impl; @@ -24,9 +12,9 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.util.ModificationTracker; import com.intellij.util.containers.SortedList; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -109,7 +97,7 @@ public class ProjectViewFileNestingService implements PersistentStateComponent

myRules = new SortedList<>(Comparator.comparing(o -> o.getParentFileSuffix())); public MyState() { diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt b/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt index fe6370303f4f..29bdd2c017d7 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt @@ -1,4 +1,6 @@ -// 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-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. + */ package com.intellij.openapi.module.impl import com.intellij.notification.Notification @@ -11,8 +13,8 @@ import com.intellij.openapi.module.ModuleDescription import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ui.configuration.ConfigureUnloadedModulesDialog -import com.intellij.util.xmlb.annotations.AbstractCollection import com.intellij.util.xmlb.annotations.Tag +import com.intellij.util.xmlb.annotations.XCollection import com.intellij.xml.util.XmlStringUtil /** @@ -153,7 +155,7 @@ class AutomaticModuleUnloader(private val project: Project) : PersistentStateCom class LoadedModulesListStorage { @Tag("loaded-modules") - @AbstractCollection(surroundWithTag = false, elementTag = "module", elementValueAttribute = "name") + @XCollection(elementName = "module", valueAttributeName = "name") var modules: MutableList = ArrayList() } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.java index eb67e9c8f318..ad27f11ae38e 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.java @@ -1,21 +1,8 @@ /* - * Copyright 2000-2016 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-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. */ package com.intellij.openapi.actionSystem.ex; - import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.extensions.PluginId; @@ -26,7 +13,6 @@ import javax.swing.*; import java.awt.event.InputEvent; import java.util.Comparator; - public abstract class ActionManagerEx extends ActionManager { public static ActionManagerEx getInstanceEx() { return (ActionManagerEx)getInstance(); diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java index 4146af6bb694..c62bd8264fe3 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java +++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java @@ -1,17 +1,5 @@ /* - * 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. + * 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. */ package com.intellij.openapi.options; @@ -23,10 +11,10 @@ import com.intellij.openapi.extensions.AbstractExtensionPointBean; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.AtomicNotNullLazyValue; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Property; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.picocontainer.PicoContainer; @@ -84,7 +72,7 @@ public class ConfigurableEP extends AbstractExten } @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public ConfigurableEP[] children; /** diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java index 319e35de425d..acf4772549ec 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java @@ -1,17 +1,5 @@ /* - * 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. + * 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. */ package com.intellij.openapi.ui; @@ -20,9 +8,9 @@ import com.intellij.openapi.components.*; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; import com.intellij.util.xmlb.XmlSerializer; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -90,7 +78,7 @@ public class MasterDetailsStateService implements PersistentStateComponent myStates = new ArrayList<>(); @Tag("states") - @AbstractCollection(surroundWithTag = false) + @XCollection public List getStates() { return myStates; } diff --git a/platform/platform-impl/src/com/intellij/externalDependencies/impl/ExternalDependenciesManagerImpl.java b/platform/platform-impl/src/com/intellij/externalDependencies/impl/ExternalDependenciesManagerImpl.java index 9e729aa6100e..f19543d98dea 100644 --- a/platform/platform-impl/src/com/intellij/externalDependencies/impl/ExternalDependenciesManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/externalDependencies/impl/ExternalDependenciesManagerImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 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-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. */ package com.intellij.externalDependencies.impl; @@ -26,8 +14,8 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.FilteringIterator; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -99,7 +87,7 @@ public class ExternalDependenciesManagerImpl extends ExternalDependenciesManager public static class ExternalDependenciesState { @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List myDependencies = new ArrayList<>(); } } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServersManagerState.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServersManagerState.java index fe27335e620b..dd007d8647e6 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServersManagerState.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServersManagerState.java @@ -1,7 +1,10 @@ +/* + * 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. + */ package com.intellij.remoteServer.impl.configuration; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.XCollection; import java.util.ArrayList; import java.util.List; @@ -11,6 +14,6 @@ import java.util.List; */ public class RemoteServersManagerState { @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List myServers = new ArrayList<>(); } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java index 55d908598370..233a25d2b271 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 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-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. */ package com.intellij.remoteServer.impl.runtime.clientLibrary; @@ -32,9 +20,7 @@ import com.intellij.remoteServer.runtime.clientLibrary.ClientLibraryManager; import com.intellij.util.EventDispatcher; import com.intellij.util.download.*; import com.intellij.util.xmlb.annotations.AbstractCollection; -import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Property; -import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -192,7 +178,7 @@ public class ClientLibraryManagerImpl extends ClientLibraryManager implements Pe public static class State { @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) + @XCollection public List myLibraries = new ArrayList<>(); } } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AbstractAutoTestManager.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AbstractAutoTestManager.java index ae160bca267b..cd0edbfcf16f 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AbstractAutoTestManager.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AbstractAutoTestManager.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 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-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. */ package com.intellij.execution.testframework.autotest; @@ -39,9 +27,9 @@ import com.intellij.openapi.util.Key; import com.intellij.ui.content.Content; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.xmlb.annotations.AbstractCollection; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -245,7 +233,7 @@ public abstract class AbstractAutoTestManager implements PersistentStateComponen public static class State { @Tag("enabled-run-configurations") - @AbstractCollection(surroundWithTag = false) + @XCollection List myEnabledRunConfigurations = ContainerUtil.newArrayList(); } diff --git a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java index 7456e5a3c647..5ba5473b3277 100644 --- a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java @@ -1,23 +1,13 @@ -// 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. +/* + * 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. + */ package com.intellij.util.xmlb; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.AbstractCollection; -import gnu.trove.THashMap; +import com.intellij.util.xmlb.annotations.XCollection; import org.jdom.Content; import org.jdom.Element; import org.jdom.Text; @@ -28,22 +18,31 @@ import java.lang.reflect.Type; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Map; abstract class AbstractCollectionBinding extends NotNullDeserializeBinding implements MultiNodeBinding { - private Map, Binding> itemBindings; + private List itemBindings; protected final Class itemType; @Nullable - protected final AbstractCollection annotation; + private final AbstractCollection annotation; + @Nullable + protected final XCollection newAnnotation; + @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized") private Serializer serializer; + private boolean isItemTypePrimitive; + public AbstractCollectionBinding(@NotNull Class elementType, @Nullable MutableAccessor accessor) { super(accessor); itemType = elementType; - annotation = accessor == null ? null : accessor.getAnnotation(AbstractCollection.class); + newAnnotation = accessor == null ? null : accessor.getAnnotation(XCollection.class); + annotation = newAnnotation == null ? (accessor == null ? null : accessor.getAnnotation(AbstractCollection.class)) : null; + } + + protected boolean isSortOrderedSet() { + return annotation == null || annotation.sortOrderedSet(); } @Override @@ -55,36 +54,43 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple public void init(@NotNull Type originalType, @NotNull Serializer serializer) { this.serializer = serializer; - if (annotation == null || annotation.surroundWithTag()) { + if (isSurroundWithTag()) { return; } - if (StringUtil.isEmpty(annotation.elementTag()) || - (annotation.elementTag().equals(Constants.OPTION) && serializer.getBinding(itemType) == null)) { + isItemTypePrimitive = XmlSerializerImpl.isPrimitive(itemType); + + //noinspection ConstantConditions + if (isItemTypePrimitive && (newAnnotation != null || StringUtil.isEmpty(getElementName()))) { throw new XmlSerializationException("If surround with tag is turned off, element tag must be specified for: " + myAccessor); } } + private boolean isSurroundWithTag() { + return newAnnotation == null && (annotation == null || annotation.surroundWithTag()); + } + @NotNull - private synchronized Map, Binding> getElementBindings() { + private synchronized List getElementBindings() { if (itemBindings == null) { Binding binding = serializer.getBinding(itemType); if (annotation == null || annotation.elementTypes().length == 0) { - itemBindings = binding == null ? Collections., Binding>emptyMap() : Collections., Binding>singletonMap(itemType, binding); + itemBindings = binding == null ? Collections.emptyList() : Collections.singletonList(binding); } else { - itemBindings = new THashMap, Binding>(); + itemBindings = new SmartList(); if (binding != null) { - itemBindings.put(itemType, binding); + itemBindings.add(binding); } + for (Class aClass : annotation.elementTypes()) { Binding b = serializer.getBinding(aClass); - if (b != null) { - itemBindings.put(aClass, b); + if (b != null && !itemBindings.contains(b)) { + itemBindings.add(b); } } if (itemBindings.isEmpty()) { - itemBindings = Collections.emptyMap(); + itemBindings = Collections.emptyList(); } } } @@ -93,7 +99,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple @Nullable private Binding getElementBinding(@NotNull Element element) { - for (Binding binding : getElementBindings().values()) { + for (Binding binding : getElementBindings()) { if (binding.isBoundTo(element)) { return binding; } @@ -173,8 +179,8 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple Binding binding = serializer.getBinding(value.getClass()); if (binding == null) { - Element serializedItem = new Element(annotation == null ? Constants.OPTION : annotation.elementTag()); - String attributeName = annotation == null ? Constants.VALUE : annotation.elementValueAttribute(); + Element serializedItem = new Element(getElementName()); + String attributeName = getValueAttributeName(); String serialized = XmlSerializerImpl.convertToString(value); if (attributeName.isEmpty()) { if (!serialized.isEmpty()) { @@ -194,7 +200,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple private Object deserializeItem(@NotNull Element node, @Nullable Object context) { Binding binding = getElementBinding(node); if (binding == null) { - String attributeName = annotation == null ? Constants.VALUE : annotation.elementValueAttribute(); + String attributeName = getValueAttributeName(); String value; if (attributeName.isEmpty()) { value = XmlSerializerImpl.getTextValue(node, ""); @@ -209,6 +215,22 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple } } + @NotNull + private String getElementName() { + if (newAnnotation != null) { + return newAnnotation.elementName(); + } + return annotation == null ? Constants.OPTION : annotation.elementTag(); + } + + @NotNull + private String getValueAttributeName() { + if (newAnnotation != null) { + return newAnnotation.valueAttributeName(); + } + return annotation == null ? Constants.VALUE : annotation.elementValueAttribute(); + } + @Override @NotNull public Object deserialize(@Nullable Object context, @NotNull Element element) { @@ -253,22 +275,21 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple @Override public boolean isBoundTo(@NotNull Element element) { String tagName = getTagName(element); - if (tagName == null) { - if (element.getName().equals(annotation == null ? Constants.OPTION : annotation.elementTag())) { - return true; - } - - if (getElementBinding(element) != null) { - return true; - } + if (tagName != null) { + return element.getName().equals(tagName); } - return element.getName().equals(tagName); + if (isItemTypePrimitive) { + return element.getName().equals(getElementName()); + } + else { + return getElementBinding(element) != null; + } } @Nullable private String getTagName(@Nullable Object target) { - return annotation == null || annotation.surroundWithTag() ? getCollectionTagName(target) : null; + return isSurroundWithTag() ? getCollectionTagName(target) : null; } protected abstract String getCollectionTagName(@Nullable Object target); diff --git a/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java b/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java index 50731245138e..6577012069d8 100644 --- a/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java +++ b/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java @@ -1,17 +1,5 @@ /* - * 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. + * 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. */ package com.intellij.util.xmlb; @@ -22,7 +10,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; class AccessorBindingWrapper extends Binding implements MultiNodeBinding { - private final Binding myBinding; + protected final Binding myBinding; private final boolean myFlat; diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java index 54d3294c14bf..9e42bc2e870e 100644 --- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java @@ -1,16 +1,6 @@ -// 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. +/* + * 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. + */ package com.intellij.util.xmlb; import com.intellij.openapi.util.Couple; @@ -369,6 +359,7 @@ public class BeanBinding extends NotNullDeserializeBinding { object.getAnnotation(Text.class) != null || object.getAnnotation(CollectionBean.class) != null || object.getAnnotation(MapAnnotation.class) != null || + object.getAnnotation(XCollection.class) != null || object.getAnnotation(AbstractCollection.class) != null; } diff --git a/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java index 84f004b78cbc..8df123b586f9 100644 --- a/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java @@ -1,17 +1,5 @@ /* - * 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. + * 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. */ package com.intellij.util.xmlb; @@ -46,7 +34,7 @@ class CollectionBinding extends AbstractCollectionBinding { @NotNull @Override Collection getIterable(@NotNull Object o) { - if (annotation != null && !annotation.sortOrderedSet() && o instanceof LinkedHashSet) { + if (isSortOrderedSet() && o instanceof LinkedHashSet) { return (Collection)o; } return o instanceof Set ? new TreeSet((Set)o) : (Collection)o; diff --git a/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java b/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java index 75ba35b8b09e..70aae6ef4a35 100644 --- a/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java +++ b/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java @@ -1,16 +1,6 @@ -// 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. +/* + * 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. + */ package com.intellij.util.xmlb; import com.intellij.openapi.util.JDOMExternalizableStringList; @@ -185,7 +175,7 @@ public final class XmlSerializerImpl { } } - private static boolean isPrimitive(@NotNull Class aClass) { + static boolean isPrimitive(@NotNull Class aClass) { return aClass.isPrimitive() || aClass == String.class || aClass == Integer.class || diff --git a/platform/util/src/com/intellij/util/xmlb/annotations/XCollection.java b/platform/util/src/com/intellij/util/xmlb/annotations/XCollection.java new file mode 100644 index 000000000000..c3f038dce9d9 --- /dev/null +++ b/platform/util/src/com/intellij/util/xmlb/annotations/XCollection.java @@ -0,0 +1,62 @@ +/* + * 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. + */ +package com.intellij.util.xmlb.annotations; + +import com.intellij.util.xmlb.Constants; +import org.jetbrains.annotations.ApiStatus; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Experimental. + * + * ```xml + *