mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
library detector and presentationProvider extension points merged
This commit is contained in:
+4
-7
@@ -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<Pair<LibraryKind, LibraryProperties>> computeKinds(List<VirtualFile> files) {
|
||||
final SmartList<Pair<LibraryKind, LibraryProperties>> result = new SmartList<Pair<LibraryKind, LibraryProperties>>();
|
||||
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;
|
||||
|
||||
@@ -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<P extends LibraryProperties> {
|
||||
public static final ExtensionPointName<LibraryDetector> EP_NAME = ExtensionPointName.create("com.intellij.library.detector");
|
||||
private final LibraryKind<P> myKind;
|
||||
|
||||
protected LibraryDetector(LibraryKind<P> kind) {
|
||||
myKind = kind;
|
||||
}
|
||||
|
||||
public final LibraryKind<P> getKind() {
|
||||
return myKind;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract P detect(@NotNull List<VirtualFile> classesRoots);
|
||||
}
|
||||
+6
-3
@@ -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<P extends LibraryProperties> {
|
||||
public String getDescription(@NotNull P properties) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract P detect(@NotNull List<VirtualFile> classesRoots);
|
||||
}
|
||||
@@ -276,7 +276,7 @@
|
||||
|
||||
<extensionPoint name="sdkType" interface="com.intellij.openapi.projectRoots.SdkType"/>
|
||||
|
||||
<extensionPoint name="library.detector" interface="com.intellij.openapi.roots.libraries.LibraryDetector"/>
|
||||
<extensionPoint name="library.presentationProvider" interface="com.intellij.openapi.roots.libraries.LibraryPresentationProvider"/>
|
||||
|
||||
<extensionPoint name="lang.implementationTextSelectioner"
|
||||
beanClass="com.intellij.lang.LanguageExtensionPoint"/>
|
||||
|
||||
@@ -103,7 +103,6 @@
|
||||
<projectConfigurable instance="org.jetbrains.plugins.groovy.gradle.GradleConfigurable"/>
|
||||
|
||||
<library.creator implementation="org.jetbrains.plugins.groovy.config.GroovyLibraryCreator"/>
|
||||
<library.detector implementation="org.jetbrains.plugins.groovy.config.GroovyLibraryDetector"/>
|
||||
<library.presentationProvider implementation="org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProvider"/>
|
||||
|
||||
<projectService serviceInterface="org.jetbrains.plugins.groovy.gant.GantSettings" serviceImplementation="org.jetbrains.plugins.groovy.gant.GantSettings"/>
|
||||
|
||||
@@ -46,7 +46,7 @@ public class GroovyLibraryCreator extends CustomLibraryCreator {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends LibraryKind<?>> getSuitableKinds() {
|
||||
return Collections.singletonList(GroovyLibraryDetector.GROOVY_KIND);
|
||||
return Collections.singletonList(GroovyLibraryPresentationProvider.GROOVY_KIND);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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<GroovyLibraryProperties> {
|
||||
public static final LibraryKind<GroovyLibraryProperties> GROOVY_KIND = LibraryKind.create("groovy");
|
||||
|
||||
public GroovyLibraryDetector() {
|
||||
super(GROOVY_KIND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroovyLibraryProperties detect(@NotNull List<VirtualFile> 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;
|
||||
}
|
||||
}
|
||||
+18
-2
@@ -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<GroovyLibraryProperties> {
|
||||
public static final LibraryKind<GroovyLibraryProperties> 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<VirtualFile> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@
|
||||
<extensionPoint name="OrderRootTypeUI"
|
||||
beanClass="com.intellij.openapi.extensions.KeyedFactoryEPBean"/>
|
||||
|
||||
<extensionPoint name="library.presentationProvider" interface="com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationProvider"/>
|
||||
<extensionPoint name="library.creator" interface="com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryCreator"/>
|
||||
|
||||
<extensionPoint name="allOverridingMethodsSearch" interface="com.intellij.util.QueryExecutor"/>
|
||||
|
||||
Reference in New Issue
Block a user