1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Fix some API issues caused by some recent CommandLauncher additions

- remove new exposed field from CommandLauncherManager and
  add correct @since tags
- create new ICommandLauncherFactory2 interface so that no
  additions are made to ICommandLauncherFactory
- add @since tag for ICBuildCommandLauncher interface
- make ContainerCommandLauncherFactory implement the new
  ICommandLauncherFactory2 as well as ICommandLauncherFactory

Change-Id: I7bbacb59e284b43e6d142accf59b6ab9df274438
This commit is contained in:
Jeff Johnston 2018-02-02 13:05:11 -05:00
parent 0e9460ec7b
commit 1ae547908b
5 changed files with 43 additions and 16 deletions

View file

@ -35,8 +35,6 @@ import org.eclipse.core.runtime.Platform;
*/ */
public class CommandLauncherManager { public class CommandLauncherManager {
public final static String CONTAINER_BUILD_ENABLED = "container.build.enabled"; //$NON-NLS-1$
private static CommandLauncherManager instance; private static CommandLauncherManager instance;
private List<ICommandLauncherFactory> factories = new ArrayList<>(); private List<ICommandLauncherFactory> factories = new ArrayList<>();
@ -195,6 +193,7 @@ public class CommandLauncherManager {
* *
* @param config - ICBuildConfiguration to determine launcher for. * @param config - ICBuildConfiguration to determine launcher for.
* @return an ICommandLauncher for running commands * @return an ICommandLauncher for running commands
* @since 6.5
*/ */
public ICommandLauncher getCommandLauncher(ICBuildConfiguration config) { public ICommandLauncher getCommandLauncher(ICBuildConfiguration config) {
// loop through list of factories and return launcher returned with // loop through list of factories and return launcher returned with
@ -202,10 +201,12 @@ public class CommandLauncherManager {
int highestPriority = -1; int highestPriority = -1;
ICommandLauncher bestLauncher = null; ICommandLauncher bestLauncher = null;
for (ICommandLauncherFactory factory : factories) { for (ICommandLauncherFactory factory : factories) {
ICommandLauncher launcher = factory.getCommandLauncher(config); if (factory instanceof ICommandLauncherFactory2) {
if (launcher != null) { ICommandLauncher launcher = ((ICommandLauncherFactory2)factory).getCommandLauncher(config);
if (priorityMapping.get(factory) > highestPriority) { if (launcher != null) {
bestLauncher = launcher; if (priorityMapping.get(factory) > highestPriority) {
bestLauncher = launcher;
}
} }
} }
} }

View file

@ -36,15 +36,6 @@ public interface ICommandLauncherFactory {
*/ */
public ICommandLauncher getCommandLauncher(ICConfigurationDescription cfgd); public ICommandLauncher getCommandLauncher(ICConfigurationDescription cfgd);
/**
* Get a Command Launcher for a build configuration descriptor
* @param cfg - ICBuildConfiguration to get command launcher for
* @return ICommandLauncher or null
*/
public default ICommandLauncher getCommandLauncher(ICBuildConfiguration cfg) {
return null;
}
/** /**
* Register language setting entries for a project * Register language setting entries for a project
* @param project - IProject used in obtaining language setting entries * @param project - IProject used in obtaining language setting entries

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2018 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 v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
/**
* @since 6.5
*/
public interface ICommandLauncherFactory2 {
public static final String CONTAINER_BUILD_ENABLED = "container.build.enabled"; //$NON-NLS-1$
/**
* Get a Command Launcher for a build configuration descriptor
* @param cfg - ICBuildConfiguration to get command launcher for
* @return ICommandLauncher or null
*/
public default ICommandLauncher getCommandLauncher(ICBuildConfiguration cfg) {
return null;
}
}

View file

@ -10,6 +10,9 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.build; package org.eclipse.cdt.core.build;
/**
* @since 6.5
*/
public interface ICBuildCommandLauncher { public interface ICBuildCommandLauncher {
/** /**

View file

@ -21,6 +21,7 @@ import java.util.Set;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.ICommandLauncherFactory; import org.eclipse.cdt.core.ICommandLauncherFactory;
import org.eclipse.cdt.core.ICommandLauncherFactory2;
import org.eclipse.cdt.core.build.ICBuildConfiguration; import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
@ -37,7 +38,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.linuxtools.docker.ui.launch.ContainerLauncher; import org.eclipse.linuxtools.docker.ui.launch.ContainerLauncher;
public class ContainerCommandLauncherFactory public class ContainerCommandLauncherFactory
implements ICommandLauncherFactory { implements ICommandLauncherFactory, ICommandLauncherFactory2 {
@Override @Override
public ICommandLauncher getCommandLauncher(IProject project) { public ICommandLauncher getCommandLauncher(IProject project) {