From 78f7be1bcd78b63b7e07dfeb2c0f82e8df006b9b Mon Sep 17 00:00:00 2001 From: Shaverdova Elena Date: Wed, 27 Apr 2016 20:35:07 +0300 Subject: [PATCH] remove effectively useless code, as now we work only with locally stored project templates --- .../templates/ArchivedTemplatesFactory.java | 83 +++---------------- 1 file changed, 12 insertions(+), 71 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java b/platform/lang-impl/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java index c749c1f939f0..502ff01d5ce1 100644 --- a/platform/lang-impl/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java +++ b/platform/lang-impl/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java @@ -20,15 +20,10 @@ import com.intellij.ide.fileTemplates.impl.UrlUtil; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.ClearableLazyValue; -import com.intellij.openapi.util.Pair; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; -import com.intellij.util.ArrayUtil; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.MultiMap; -import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,8 +33,6 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.List; -import java.util.Map; -import java.util.Set; /** * @author Dmitry Avdeev @@ -50,55 +43,6 @@ public class ArchivedTemplatesFactory extends ProjectTemplatesFactory { static final String ZIP = ".zip"; - private final ClearableLazyValue>> myGroups = new ClearableLazyValue>>() { - @NotNull - @Override - protected MultiMap> compute() { - MultiMap> map = MultiMap.createSmart(); - Map urls = new THashMap(); - //for (IdeaPluginDescriptor plugin : plugins) { - // if (!plugin.isEnabled()) continue; - // try { - // ClassLoader loader = plugin.getPluginClassLoader(); - // Enumeration resources = loader.getResources("resources/projectTemplates"); - // ArrayList list = Collections.list(resources); - // for (URL url : list) { - // urls.put(url, loader); - // } - // } - // catch (IOException e) { - // LOG.error(e); - // } - //} - - URL configURL = getCustomTemplatesURL(); - urls.put(configURL, ClassLoader.getSystemClassLoader()); - - for (Map.Entry url : urls.entrySet()) { - try { - List children = UrlUtil.getChildrenRelativePaths(url.getKey()); - if (configURL == url.getKey() && !children.isEmpty()) { - map.putValue(CUSTOM_GROUP, Pair.create(url.getKey(), url.getValue())); - continue; - } - - for (String child : children) { - int index = child.indexOf('/'); - if (index != -1) { - child = child.substring(0, index); - } - String name = child.replace('_', ' '); - map.putValue(name, Pair.create(new URL(url.getKey().toExternalForm() + "/" + child), url.getValue())); - } - } - catch (IOException e) { - LOG.error(e); - } - } - return map; - } - }; - @NotNull private static URL getCustomTemplatesURL() { try { @@ -121,34 +65,31 @@ public class ArchivedTemplatesFactory extends ProjectTemplatesFactory { @NotNull @Override public String[] getGroups() { - myGroups.drop(); - Set groups = myGroups.getValue().keySet(); - return ArrayUtil.toStringArray(groups); + return new String[]{CUSTOM_GROUP}; } @NotNull @Override public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) { // myGroups contains only not-null keys - if (group == null) { + if (!CUSTOM_GROUP.equals(group)) { return ProjectTemplate.EMPTY_ARRAY; } List templates = null; - for (Pair url : myGroups.getValue().get(group)) { - try { - for (String child : UrlUtil.getChildrenRelativePaths(url.first)) { - if (child.endsWith(ZIP)) { - if (templates == null) { - templates = new SmartList(); - } - templates.add(new LocalArchivedTemplate(new URL(url.first.toExternalForm() + '/' + child), url.second)); + URL url = getCustomTemplatesURL(); + try { + for (String child : UrlUtil.getChildrenRelativePaths(url)) { + if (child.endsWith(ZIP)) { + if (templates == null) { + templates = new SmartList(); } + templates.add(new LocalArchivedTemplate(new URL(url.toExternalForm() + '/' + child), ClassLoader.getSystemClassLoader())); } } - catch (IOException e) { - LOG.error(e); - } + } + catch (IOException e) { + LOG.error(e); } return ContainerUtil.isEmpty(templates) ? ProjectTemplate.EMPTY_ARRAY : templates.toArray(new ProjectTemplate[templates.size()]); }