diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt b/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt
index f4050eae22e9..3bedb89aa443 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt
@@ -63,8 +63,10 @@ internal class ProjectInspectionManagerTest {
projectInspectionProfileManager.setRootProfile(null)
val doNotUseProjectProfileState = """
-
-
+
+
+
+
""".trimIndent()
assertThat(projectInspectionProfileManager.state).isEqualTo(doNotUseProjectProfileState)
@@ -74,8 +76,10 @@ internal class ProjectInspectionManagerTest {
assertThat(file).exists()
val doNotUseProjectProfileData = """
-
-
+
+
+
+
""".trimIndent()
assertThat(file.readText()).isEqualTo(doNotUseProjectProfileData)
diff --git a/java/jdkAnnotations/org/jdom/annotations.xml b/java/jdkAnnotations/org/jdom/annotations.xml
index 5db66944529c..02739c14c0c0 100644
--- a/java/jdkAnnotations/org/jdom/annotations.xml
+++ b/java/jdkAnnotations/org/jdom/annotations.xml
@@ -51,6 +51,9 @@
-
+ -
+
+
-
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
index fe0bcc8466d7..63b654e97a81 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
@@ -134,7 +134,7 @@ public class SeverityRegistrar implements Comparator {
}
- public void readExternal(Element element) {
+ public void readExternal(@NotNull Element element) {
myMap.clear();
myRendererColors.clear();
for (Element infoElement : element.getChildren(INFO_TAG)) {
@@ -150,8 +150,9 @@ public class SeverityRegistrar implements Comparator {
final List knownSeverities = getDefaultOrder();
for (String name : myReadOrder) {
HighlightSeverity severity = getSeverity(name);
- if (severity == null || !knownSeverities.contains(severity)) continue;
- read.add(severity);
+ if (severity != null && knownSeverities.contains(severity)) {
+ read.add(severity);
+ }
}
OrderMap orderMap = fromList(read);
if (orderMap.isEmpty()) {
@@ -292,7 +293,6 @@ public class SeverityRegistrar implements Comparator {
return o1 - o2;
}
-
@NotNull
private OrderMap getOrderMap() {
OrderMap orderMap;
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
index 9b4ca37db9ad..fe0f5d045664 100644
--- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
@@ -832,16 +832,15 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
myDescription = description;
}
- @Override
public void convert(@NotNull Element element, @NotNull Project project) {
- initInspectionTools(project);
- final Element scopes = element.getChild(ProjectInspectionProfileManagerImplKt.SCOPES);
+ final Element scopes = element.getChild("scopes");
if (scopes == null) {
return;
}
- final List children = scopes.getChildren(SCOPE);
- for (Object s : children) {
- Element scopeElement = (Element)s;
+
+ initInspectionTools(project);
+
+ for (Element scopeElement : scopes.getChildren(SCOPE)) {
final String profile = scopeElement.getAttributeValue(ProjectInspectionProfileManagerImplKt.PROFILE);
if (profile != null) {
final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)getProfileManager().getProfile(profile);
diff --git a/platform/analysis-impl/src/com/intellij/profile/ProfileEx.java b/platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
index 608ee714e6e0..e6029fa3ab5a 100644
--- a/platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
+++ b/platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
@@ -15,7 +15,6 @@
*/
package com.intellij.profile;
-import com.intellij.openapi.project.Project;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImplKt;
import com.intellij.util.xmlb.SmartSerializer;
import com.intellij.util.xmlb.annotations.OptionTag;
@@ -120,9 +119,6 @@ public abstract class ProfileEx implements Profile {
return 0;
}
- public void convert(@NotNull Element element, @NotNull Project project) {
- }
-
@Override
public final void copyFrom(@NotNull Profile profile) {
readExternal(serializeProfile(profile));
diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManagerImpl.kt b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManagerImpl.kt
index 9897718a0082..3c666942c98a 100644
--- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManagerImpl.kt
+++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManagerImpl.kt
@@ -31,6 +31,7 @@ import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ProjectManagerListener
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.util.Disposer
+import com.intellij.openapi.util.JDOMUtil
import com.intellij.openapi.util.text.StringUtil
import com.intellij.packageDependencies.DependencyValidationManager
import com.intellij.profile.Profile
@@ -40,12 +41,10 @@ import com.intellij.util.ui.UIUtil
import com.intellij.util.xmlb.Accessor
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters
import com.intellij.util.xmlb.XmlSerializer
-import gnu.trove.THashSet
import org.jdom.Element
import java.util.function.Function
const val PROFILE = "profile"
-const val SCOPES = "scopes"
private const val VERSION = "1.0"
private const val SCOPE = "scope"
@@ -178,24 +177,29 @@ class ProjectInspectionProfileManagerImpl(val project: Project,
}
@Synchronized override fun loadState(state: Element) {
- try {
- severityRegistrar.readExternal(state)
- }
- catch (e: Throwable) {
- LOG.error(e)
+ val data = state.getChild("settings")
+
+ val newState = State()
+
+ data?.let {
+ try {
+ severityRegistrar.readExternal(it)
+ }
+ catch (e: Throwable) {
+ LOG.error(e)
+ }
+
+ XmlSerializer.deserializeInto(newState, it)
}
- val profileKeys = THashSet()
- profileKeys.addAll(schemeManager.allSchemeNames)
- val newState = State()
- XmlSerializer.deserializeInto(newState, state)
this.state = newState
- if (state.getChild("version")?.getAttributeValue("value") != VERSION) {
- for (o in state.getChildren("option")) {
+
+ if (data != null && data.getChild("version")?.getAttributeValue("value") != VERSION) {
+ for (o in data.getChildren("option")) {
if (o.getAttributeValue("name") == "USE_PROJECT_LEVEL_SETTINGS") {
if (o.getAttributeValue("value").toBoolean()) {
if (newState.projectProfile != null) {
- currentProfile.convert(state, project)
+ currentProfile.convert(data, project)
}
}
break
@@ -205,14 +209,20 @@ class ProjectInspectionProfileManagerImpl(val project: Project,
}
@Synchronized override fun getState(): Element? {
- val result = Element("state")
+ val result = Element("settings")
XmlSerializer.serializeInto(this.state, result, skipDefaultsSerializationFilter)
if (!result.children.isEmpty()) {
result.addContent(Element("version").setAttribute("value", VERSION))
}
severityRegistrar.writeExternal(result)
- return result
+ if (JDOMUtil.isEmpty(result)) {
+ result.name = "state"
+ return result
+ }
+ else {
+ return Element("state").addContent(result)
+ }
}
override fun getScopesManager() = scopeManager