Skip to content

Commit

Permalink
Refactored ExtensionsExtractor
Browse files Browse the repository at this point in the history
Signed-off-by: Siarhei Leanavets [email protected]
  • Loading branch information
LeonovecSergey committed Mar 28, 2021
1 parent af6f884 commit 78e02c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;

import org.eclipse.core.runtime.IConfigurationElement;
Expand All @@ -26,12 +27,18 @@
*
*/
public class ExtensionsExtractor {
public static <T> List<T> extractExtensions(final String namespace, final String extensionPointName) {
public static <T> List<T> extractOrderedExtensions(final String namespace, final String extensionPointName) {

final var extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(namespace, extensionPointName);
final var configs = extensionPoint.getConfigurationElements();

return Arrays.stream(configs).map(ExtensionsExtractor::<T>makeExtension).collect(Collectors.toUnmodifiableList());
Map<Integer, T> extensionMap = new TreeMap<>();

for (int i = 0; i < configs.length; i++) {
Integer order = Integer.valueOf(configs[i].getAttribute("order"));
extensionMap.put(order, makeExtension(configs[i]));
}
return extensionMap.values().stream().collect(Collectors.toUnmodifiableList());
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private BuildSupportManager() {}

public static List<IBuildSupport> obtainBuildSupports() {
if (instance.lazyLoadedBuildSupportList == null) {
instance.lazyLoadedBuildSupportList = ExtensionsExtractor.extractExtensions(IConstants.PLUGIN_ID, "buildSupport");
instance.lazyLoadedBuildSupportList = ExtensionsExtractor.extractOrderedExtensions(IConstants.PLUGIN_ID, "buildSupport");
}

return instance.lazyLoadedBuildSupportList;
Expand Down

0 comments on commit 78e02c5

Please sign in to comment.