contribute library roots without creating Library/OrderEntry instances to avoid ...
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Tue, 28 Jun 2016 09:46:56 +0000 (12:46 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Tue, 28 Jun 2016 09:47:41 +0000 (12:47 +0300)
platform/platform-resources/src/META-INF/LangExtensionPoints.xml
platform/projectModel-impl/src/com/intellij/openapi/roots/AdditionalLibraryRootsProvider.java [new file with mode: 0644]
platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java

index 55f48d5c372da23d6a2d45901f1aa2e6c2859db6..2b0d6129d33b4e7fdb27f4bea66befbd20560888 100644 (file)
     <extensionPoint name="orderEnumerationHandlerFactory" interface="com.intellij.openapi.roots.OrderEnumerationHandler$Factory"/>
     <extensionPoint name="directoryIndexExcludePolicy" interface="com.intellij.openapi.roots.impl.DirectoryIndexExcludePolicy"
                     area="IDEA_PROJECT"/>
+    <extensionPoint name="additionalLibraryRootsProvider" interface="com.intellij.openapi.roots.AdditionalLibraryRootsProvider"/>
     <extensionPoint name="librarySettingsProvider" interface="com.intellij.openapi.roots.ui.configuration.LibrarySettingsProvider"/>
 
     <extensionPoint name="smartPointer.anchorProvider" interface="com.intellij.psi.impl.smartPointers.SmartPointerAnchorProvider"/>
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/AdditionalLibraryRootsProvider.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/AdditionalLibraryRootsProvider.java
new file mode 100644 (file)
index 0000000..7155ba1
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2016 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;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+import java.util.Collections;
+
+public abstract class AdditionalLibraryRootsProvider {
+  public static final ExtensionPointName<AdditionalLibraryRootsProvider> EP_NAME = ExtensionPointName.create("com.intellij.additionalLibraryRootsProvider");
+
+  @NotNull
+  public Collection<VirtualFile> getAdditionalProjectLibrarySourceRoots(@NotNull Project project) {
+    return Collections.emptyList();
+  }
+}
index 8b0441dee432ee0f1f353165979b5fa7e9bb1b2c..c85cd283647988dac7cbbcf718aa98aff455017d 100644 (file)
@@ -154,6 +154,10 @@ public class RootIndex {
       }
     }
 
+    for (AdditionalLibraryRootsProvider provider : Extensions.getExtensions(AdditionalLibraryRootsProvider.EP_NAME)) {
+      Collection<VirtualFile> roots = provider.getAdditionalProjectLibrarySourceRoots(project);
+      info.libraryOrSdkSources.addAll(roots);
+    }
     for (DirectoryIndexExcludePolicy policy : Extensions.getExtensions(DirectoryIndexExcludePolicy.EP_NAME, project)) {
       Collections.addAll(info.excludedFromProject, policy.getExcludeRootsForProject());
     }