remove obsolete components after conversion

This commit is contained in:
Nikolay Chashnikov
2009-09-09 13:40:12 +04:00
parent 36d2fe7929
commit a0406dd550
5 changed files with 38 additions and 2 deletions
@@ -61,6 +61,7 @@ public class BuildJarProjectSettings implements PersistentStateComponent<Element
public boolean BUILD_JARS_ON_MAKE = false;
@NonNls private static final String MAIN_CLASS = Attributes.Name.MAIN_CLASS.toString();
@NonNls private static final String JAR_EXTENSION = ".jar";
@NonNls public static final String BUILD_JAR_PROJECT_SETTINGS_COMPONENT_NAME = "BuildJarProjectSettings";
private final Project myProject;
public static BuildJarProjectSettings getInstance(Project project) {
@@ -108,7 +109,7 @@ public class BuildJarProjectSettings implements PersistentStateComponent<Element
@NonNls @NotNull
public String getComponentName() {
return "BuildJarProjectSettings";
return BUILD_JAR_PROJECT_SETTINGS_COMPONENT_NAME;
}
public void initComponent() {
@@ -6,6 +6,8 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
/**
* @author nik
*/
@@ -19,4 +21,6 @@ public interface ComponentManagerSettings {
@NotNull
Document getDocument();
File getFile();
}
@@ -2,6 +2,7 @@ package com.intellij.conversion;
import com.intellij.openapi.components.StorageScheme;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Collection;
@@ -31,4 +32,7 @@ public interface ConversionContext {
String collapsePath(@NotNull String path);
Collection<File> getLibraryClassRoots(@NotNull String name, @NotNull String level);
@Nullable
ComponentManagerSettings getCompilerSettings();
}
@@ -13,7 +13,7 @@ import java.io.IOException;
/**
* @author nik
*/
public abstract class ComponentManagerSettingsImpl implements ComponentManagerSettings {
public class ComponentManagerSettingsImpl implements ComponentManagerSettings {
protected final SettingsXmlFile mySettingsFile;
protected final ConversionContextImpl myContext;
@@ -39,4 +39,8 @@ public abstract class ComponentManagerSettingsImpl implements ComponentManagerSe
public void save() throws IOException {
mySettingsFile.save();
}
public File getFile() {
return mySettingsFile.getFile();
}
}
@@ -18,6 +18,7 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.PathUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
@@ -32,6 +33,7 @@ import java.util.*;
* @author nik
*/
public class ConversionContextImpl implements ConversionContext {
private static final Logger LOG = Logger.getInstance("#com.intellij.conversion.impl.ConversionContextImpl");
private Map<File, SettingsXmlFile> mySettingsFiles = new HashMap<File, SettingsXmlFile>();
private StorageScheme myStorageScheme;
private File myProjectBaseDir;
@@ -44,6 +46,7 @@ public class ConversionContextImpl implements ConversionContext {
private Map<File, ModuleSettingsImpl> myModuleSettingsMap = new HashMap<File, ModuleSettingsImpl>();
private RunManagerSettingsImpl myRunManagerSettings;
private File mySettingsBaseDir;
private ComponentManagerSettings myCompilerManagerSettings;
public ConversionContextImpl(String projectPath) throws CannotConvertException {
myProjectFile = new File(projectPath);
@@ -147,6 +150,26 @@ public class ConversionContextImpl implements ConversionContext {
}
}
public ComponentManagerSettings getCompilerSettings() {
if (myCompilerManagerSettings == null) {
try {
File file;
if (myStorageScheme == StorageScheme.DEFAULT) {
file = myProjectFile;
}
else {
file = new File(mySettingsBaseDir, "compiler.xml");
}
myCompilerManagerSettings = new ComponentManagerSettingsImpl(file, this);
}
catch (CannotConvertException e) {
LOG.info(e);
return null;
}
}
return myCompilerManagerSettings;
}
@Nullable
private Element findGlobalLibraryElement(String name) throws CannotConvertException {
final File file = PathManager.getOptionsFile("applicationLibraries");