Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBuildSupport extension point #1455

Merged
merged 4 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
import org.eclipse.lsp4j.WatchKind;

public class StandardProjectsManager extends ProjectsManager {
private static final String BUILD_SUPPORT_EXTENSION_POINT_ID = "buildSupport";
protected static final String BUILD_SUPPORT_EXTENSION_POINT_ID = "buildSupport";
private static final Set<String> watchers = new LinkedHashSet<>();
private PreferenceManager preferenceManager;
//@formatter:off
Expand Down Expand Up @@ -276,7 +276,7 @@ public Optional<IBuildSupport> getBuildSupport(IProject project) {
return buildSupports().filter(bs -> bs.applies(project)).findFirst();
}

private Stream<IBuildSupport> buildSupports() {
protected Stream<IBuildSupport> buildSupports() {
Map<Integer, IBuildSupport> supporters = new TreeMap<>();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IConstants.PLUGIN_ID, BUILD_SUPPORT_EXTENSION_POINT_ID);
IConfigurationElement[] configs = extensionPoint.getConfigurationElements();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2020 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal.managers;

import java.util.stream.Stream;

import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;

/**
* @author siarhei_leanavets1
*
*/
public class StandardProjectsManagerDummy extends StandardProjectsManager {
beginningineer marked this conversation as resolved.
Show resolved Hide resolved

/**
* @param preferenceManager
*/
public StandardProjectsManagerDummy(PreferenceManager preferenceManager) {
super(preferenceManager);
}

@Override
public Stream<IBuildSupport> buildSupports() {
return super.buildSupports();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2020 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal.managers;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;

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

import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
import org.eclipse.jdt.ls.core.internal.preferences.StandardPreferenceManager;
import org.junit.Test;

/**
* @author siarhei_leanavets1
*
*/
public class StandartProjectManagerTest {
beginningineer marked this conversation as resolved.
Show resolved Hide resolved

@Test
public void testCheckBuildSupportOrder() {
PreferenceManager preferenceManager = mock(StandardPreferenceManager.class);
StandardProjectsManagerDummy projectsManagerDummy = new StandardProjectsManagerDummy(preferenceManager);
List<IBuildSupport> expectedList = Arrays.asList(new GradleBuildSupport(), new MavenBuildSupport(), new InvisibleProjectBuildSupport(), new DefaultProjectBuildSupport(), new EclipseBuildSupport());
beginningineer marked this conversation as resolved.
Show resolved Hide resolved
List<IBuildSupport> actualList = projectsManagerDummy.buildSupports().collect(Collectors.toList());
for (int i = 0; i < expectedList.size(); i++) {
assertTrue(actualList.get(i).getClass().isInstance(expectedList.get(i)));
}
}

}