From 78e92b352c6dc3c8173035c6d12456e82f213933 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 9 Jul 2010 19:38:44 +0400 Subject: [PATCH] eclipse: collapse src/srclink paths in .iml; compare ids by equals --- .../eclipse/config/EclipseModuleManager.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java index 1ac0649ba4ab..ac79c5a8ee3d 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java @@ -20,6 +20,7 @@ import com.intellij.openapi.components.*; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleServiceManager; import com.intellij.openapi.roots.impl.storage.ClasspathStorage; +import com.intellij.openapi.util.text.StringUtil; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -45,8 +46,9 @@ public class EclipseModuleManager implements PersistentStateComponent{ private final Set myEclipseUrls = new LinkedHashSet(); private final Set myUnknownCons = new LinkedHashSet(); private boolean myForceConfigureJDK = false; - private static final String SRC_PREFIX = "src:"; - private static final String SRC_LINK_PREFIX = "linksrc:"; + @NonNls private static final String SRC_PREFIX = "src:"; + @NonNls private static final String SRC_LINK_PREFIX = "linksrc:"; + @NonNls private static final String PREFIX_ATTR = "kind"; private final Module myModule; @NonNls private static final String LIBELEMENT = "libelement"; @@ -115,7 +117,7 @@ public class EclipseModuleManager implements PersistentStateComponent{ } public Element getState() { - if (ClasspathStorage.getStorageType(myModule) != EclipseClasspathStorageProvider.ID) { + if (!ClasspathStorage.getStorageType(myModule).equals(EclipseClasspathStorageProvider.ID)) { if (!myEclipseUrls.isEmpty() || !myEclipseVariablePaths.isEmpty() || myForceConfigureJDK || !myUnknownCons.isEmpty()) { Element root = new Element("EclipseModuleSettings"); for (String eclipseUrl : myEclipseUrls) { @@ -125,7 +127,15 @@ public class EclipseModuleManager implements PersistentStateComponent{ } for (String var : myEclipseVariablePaths.keySet()) { Element varElement = new Element(VARELEMENT); - varElement.setAttribute(VAR_ATTRIBUTE, var); + if (var.startsWith(SRC_PREFIX)) { + varElement.setAttribute(VAR_ATTRIBUTE, StringUtil.trimStart(var, SRC_PREFIX)); + varElement.setAttribute(PREFIX_ATTR, SRC_PREFIX); + } else if (var.startsWith(SRC_LINK_PREFIX)) { + varElement.setAttribute(VAR_ATTRIBUTE, StringUtil.trimStart(var, SRC_LINK_PREFIX)); + varElement.setAttribute(PREFIX_ATTR, SRC_LINK_PREFIX); + } else { + varElement.setAttribute(VAR_ATTRIBUTE, var); + } varElement.setAttribute(VALUE_ATTR, myEclipseVariablePaths.get(var)); root.addContent(varElement); } @@ -150,7 +160,8 @@ public class EclipseModuleManager implements PersistentStateComponent{ } for (Object o : state.getChildren(VARELEMENT)) { - myEclipseVariablePaths.put(((Element)o).getAttributeValue(VAR_ATTRIBUTE), ((Element)o).getAttributeValue(VALUE_ATTR)); + final String prefix = ((Element)o).getAttributeValue(PREFIX_ATTR); + myEclipseVariablePaths.put(((Element)o).getAttributeValue(VAR_ATTRIBUTE), (prefix != null ? prefix : "") + ((Element)o).getAttributeValue(VALUE_ATTR)); } for (Object o : state.getChildren(CONELEMENT)) {