From 7fb88e70dff92e27b1cbee5be6a56e7f3c4dfa78 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 22 Sep 2010 12:41:16 +0400 Subject: [PATCH] library detector and presentationProvider extension points merged --- .../LibraryDetectionManagerImpl.java | 11 ++--- .../roots/libraries/LibraryDetector.java | 42 ------------------ .../LibraryPresentationProvider.java | 9 ++-- .../src/META-INF/LangExtensionPoints.xml | 2 +- plugins/groovy/src/META-INF/plugin.xml | 1 - .../groovy/config/GroovyLibraryCreator.java | 2 +- .../groovy/config/GroovyLibraryDetector.java | 44 ------------------- .../GroovyLibraryPresentationProvider.java | 20 ++++++++- resources/src/META-INF/IdeaPlugin.xml | 1 - 9 files changed, 30 insertions(+), 102 deletions(-) delete mode 100644 platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetector.java rename {java/idea-ui/src/com/intellij/openapi/roots/ui/configuration => platform/lang-impl/src/com/intellij/openapi/roots}/libraries/LibraryPresentationProvider.java (87%) delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDetector.java diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java index ab0db3c70104..abce2c12a9a3 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryDetectionManagerImpl.java @@ -15,10 +15,7 @@ */ package com.intellij.openapi.roots.impl.libraries; -import com.intellij.openapi.roots.libraries.LibraryDetectionManager; -import com.intellij.openapi.roots.libraries.LibraryDetector; -import com.intellij.openapi.roots.libraries.LibraryKind; -import com.intellij.openapi.roots.libraries.LibraryProperties; +import com.intellij.openapi.roots.libraries.*; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.SmartList; @@ -56,10 +53,10 @@ public class LibraryDetectionManagerImpl extends LibraryDetectionManager { private static List> computeKinds(List files) { final SmartList> result = new SmartList>(); - for (LibraryDetector detector : LibraryDetector.EP_NAME.getExtensions()) { - final LibraryProperties properties = detector.detect(files); + for (LibraryPresentationProvider provider : LibraryPresentationProvider.EP_NAME.getExtensions()) { + final LibraryProperties properties = provider.detect(files); if (properties != null) { - result.add(Pair.create(detector.getKind(), properties)); + result.add(Pair.create(provider.getKind(), properties)); } } return result; diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetector.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetector.java deleted file mode 100644 index d92eb26e4b4f..000000000000 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetector.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ -package com.intellij.openapi.roots.libraries; - -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * @author nik - */ -public abstract class LibraryDetector

{ - public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.library.detector"); - private final LibraryKind

myKind; - - protected LibraryDetector(LibraryKind

kind) { - myKind = kind; - } - - public final LibraryKind

getKind() { - return myKind; - } - - @Nullable - public abstract P detect(@NotNull List classesRoots); -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationProvider.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryPresentationProvider.java similarity index 87% rename from java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationProvider.java rename to platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryPresentationProvider.java index 99014a0d3853..548509224844 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryPresentationProvider.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.roots.ui.configuration.libraries; +package com.intellij.openapi.roots.libraries; import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.roots.libraries.LibraryKind; -import com.intellij.openapi.roots.libraries.LibraryProperties; +import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.List; /** * @author nik @@ -45,4 +45,7 @@ public abstract class LibraryPresentationProvider

{ public String getDescription(@NotNull P properties) { return null; } + + @Nullable + public abstract P detect(@NotNull List classesRoots); } diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 390944d9dc96..97e8e7b73236 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -276,7 +276,7 @@ - + diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index ca5971cd336b..1f6918d8110b 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -103,7 +103,6 @@ - diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java index 8dd7682cf7f6..6488ad28df53 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java @@ -46,7 +46,7 @@ public class GroovyLibraryCreator extends CustomLibraryCreator { @NotNull @Override public List> getSuitableKinds() { - return Collections.singletonList(GroovyLibraryDetector.GROOVY_KIND); + return Collections.singletonList(GroovyLibraryPresentationProvider.GROOVY_KIND); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDetector.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDetector.java deleted file mode 100644 index f36d448a2c58..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDetector.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ -package org.jetbrains.plugins.groovy.config; - -import com.intellij.openapi.roots.libraries.LibraryDetector; -import com.intellij.openapi.roots.libraries.LibraryKind; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * @author nik - */ -public class GroovyLibraryDetector extends LibraryDetector { - public static final LibraryKind GROOVY_KIND = LibraryKind.create("groovy"); - - public GroovyLibraryDetector() { - super(GROOVY_KIND); - } - - @Override - public GroovyLibraryProperties detect(@NotNull List classesRoots) { - final VirtualFile[] libraryFiles = classesRoots.toArray(new VirtualFile[classesRoots.size()]); - final LibraryManager manager = LibraryManager.findManagerFor(AbstractGroovyLibraryManager.EP_NAME.getExtensions(), libraryFiles); - if (manager != null) { - return new GroovyLibraryProperties(manager); - } - return null; - } -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java index 0633031a4a1b..64b9cb4aa8cb 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java @@ -15,20 +15,36 @@ */ package org.jetbrains.plugins.groovy.config; -import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationProvider; +import com.intellij.openapi.roots.libraries.LibraryKind; +import com.intellij.openapi.roots.libraries.LibraryPresentationProvider; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.util.List; /** * @author nik */ public class GroovyLibraryPresentationProvider extends LibraryPresentationProvider { + public static final LibraryKind GROOVY_KIND = LibraryKind.create("groovy"); + public GroovyLibraryPresentationProvider() { - super(GroovyLibraryDetector.GROOVY_KIND); + super(GROOVY_KIND); } @Override public Icon getIcon(GroovyLibraryProperties properties) { return properties.getManager().getIcon(); } + + @Override + public GroovyLibraryProperties detect(@NotNull List classesRoots) { + final VirtualFile[] libraryFiles = classesRoots.toArray(new VirtualFile[classesRoots.size()]); + final LibraryManager manager = LibraryManager.findManagerFor(AbstractGroovyLibraryManager.EP_NAME.getExtensions(), libraryFiles); + if (manager != null) { + return new GroovyLibraryProperties(manager); + } + return null; + } } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 0eea9414eed9..765b0bc3f67f 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -90,7 +90,6 @@ -