1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-26 01:33:53 +02:00

Refactor CommandLauncherFactoryManager to CommandLauncherManager

Change-Id: I254abdb6a3e749050cb25f5ed68c672462506475
This commit is contained in:
Jeff Johnston 2017-04-26 15:25:52 -04:00
parent 00a7db1c4d
commit 9a262a6cd4
10 changed files with 37 additions and 27 deletions

View file

@ -18,7 +18,7 @@ import java.util.zip.ZipFile;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager; import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager;
@ -131,7 +131,7 @@ public class ProjectTools {
*/ */
public static boolean markExecutable(IProject project, String filePath) { public static boolean markExecutable(IProject project, String filePath) {
// Get a launcher for the config command // Get a launcher for the config command
ICommandLauncher launcher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(); ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher();
launcher.setProject(project); launcher.setProject(project);
OutputStream stdout = new ByteArrayOutputStream(); OutputStream stdout = new ByteArrayOutputStream();
OutputStream stderr = new ByteArrayOutputStream(); OutputStream stderr = new ByteArrayOutputStream();

View file

@ -23,7 +23,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.IConsoleParser;
@ -180,7 +180,7 @@ public class MakeBuilder extends ACBuilder {
console.start(project); console.start(project);
// Prepare launch parameters for BuildRunnerHelper // Prepare launch parameters for BuildRunnerHelper
ICommandLauncher launcher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(); ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher();
String[] targets = getTargets(kind, info); String[] targets = getTargets(kind, info);
if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget())) if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget()))

View file

@ -19,7 +19,7 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.IConsoleParser;
@ -120,7 +120,7 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
} }
console.start(project); console.start(project);
ICommandLauncher launcher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(); ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher();
launcher.setProject(project); launcher.setProject(project);
IPath program = getCommandToLaunch(); IPath program = getCommandToLaunch();

View file

@ -18,7 +18,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
@ -147,7 +147,7 @@ public class CommandBuilder implements IBuildModelBuilder {
} }
protected ICommandLauncher createLauncher() { protected ICommandLauncher createLauncher() {
return CommandLauncherFactoryManager.getInstance().getCommandLauncher(fProject); return CommandLauncherManager.getInstance().getCommandLauncher(fProject);
} }
public String getErrMsg() { public String getErrMsg() {

View file

@ -25,7 +25,7 @@ import java.util.SortedMap;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
@ -2858,7 +2858,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
return getSuperClass().getCommandLauncher(); return getSuperClass().getCommandLauncher();
else if(fCommandLauncher == null) // catch all for backwards compatibility else if(fCommandLauncher == null) // catch all for backwards compatibility
fCommandLauncher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(); fCommandLauncher = CommandLauncherManager.getInstance().getCommandLauncher();
return fCommandLauncher; return fCommandLauncher;
} }

View file

@ -26,7 +26,7 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.IConsoleParser;
@ -482,6 +482,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
return; return;
} }
System.out.println("in execute");
WorkspaceJob job = new WorkspaceJob(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobName")) { //$NON-NLS-1$ WorkspaceJob job = new WorkspaceJob(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobName")) { //$NON-NLS-1$
@Override @Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
@ -532,6 +534,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
* @return status of operation. * @return status of operation.
*/ */
protected IStatus runForEachLanguage(IProgressMonitor monitor) { protected IStatus runForEachLanguage(IProgressMonitor monitor) {
System.out.println("in runForEachLanguage");
MultiStatus status = new MultiStatus(ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.OK, "Problem running CDT Scanner Discovery provider " + getId(), null); //$NON-NLS-1$ MultiStatus status = new MultiStatus(ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.OK, "Problem running CDT Scanner Discovery provider " + getId(), null); //$NON-NLS-1$
if (monitor == null) { if (monitor == null) {
@ -638,6 +643,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
* has not been called yet. * has not been called yet.
*/ */
private void runForLanguage(IProgressMonitor monitor) throws CoreException { private void runForLanguage(IProgressMonitor monitor) throws CoreException {
System.out.println("run for language");
buildRunnerHelper = new BuildRunnerHelper(currentProject); buildRunnerHelper = new BuildRunnerHelper(currentProject);
if (monitor == null) { if (monitor == null) {
@ -656,7 +664,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
} }
console.start(currentProject); console.start(currentProject);
ICommandLauncher launcher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(); ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher();
launcher.setProject(currentProject); launcher.setProject(currentProject);
IPath program = new Path(""); //$NON-NLS-1$ IPath program = new Path(""); //$NON-NLS-1$
@ -756,6 +764,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
} }
protected int runProgramForLanguage(String languageId, String command, String[] envp, URI workingDirectoryURI, OutputStream consoleOut, OutputStream consoleErr, IProgressMonitor monitor) throws CoreException, IOException { protected int runProgramForLanguage(String languageId, String command, String[] envp, URI workingDirectoryURI, OutputStream consoleOut, OutputStream consoleErr, IProgressMonitor monitor) throws CoreException, IOException {
System.out.println("runProgramForLanguage");
return buildRunnerHelper.build(monitor); return buildRunnerHelper.build(monitor);
} }

View file

@ -18,7 +18,7 @@ import org.eclipse.cdt.codan.core.cxx.externaltool.ConfigurationSettings;
import org.eclipse.cdt.codan.core.cxx.externaltool.InvocationFailure; import org.eclipse.cdt.codan.core.cxx.externaltool.InvocationFailure;
import org.eclipse.cdt.codan.core.cxx.externaltool.InvocationParameters; import org.eclipse.cdt.codan.core.cxx.externaltool.InvocationParameters;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
@ -85,7 +85,7 @@ public class ExternalToolInvoker {
final OutputStream out = sniffer.getOutputStream(); final OutputStream out = sniffer.getOutputStream();
final OutputStream err = sniffer.getErrorStream(); final OutputStream err = sniffer.getErrorStream();
try { try {
ICommandLauncher launcher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(); ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher();
launcher.showCommand(true); launcher.showCommand(true);
launcher.setProject(project); launcher.setProject(project);
Process p = launcher.execute(commandPath, commandArgs, commandEnv, workingDirectory, new SubProgressMonitor(monitor, 50)); Process p = launcher.execute(commandPath, commandArgs, commandEnv, workingDirectory, new SubProgressMonitor(monitor, 50));

View file

@ -17,7 +17,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.XmlUtil;
@ -147,7 +147,7 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
List<? extends ICLanguageSettingEntry> entries) { List<? extends ICLanguageSettingEntry> entries) {
String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null; String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null;
fStorage.setSettingEntries(rcProjectPath, languageId, entries); fStorage.setSettingEntries(rcProjectPath, languageId, entries);
CommandLauncherFactoryManager.getInstance().setLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries); CommandLauncherManager.getInstance().setLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries);
} }
/** /**
@ -171,7 +171,7 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
} }
if (cfgDescription != null) { if (cfgDescription != null) {
entries = CommandLauncherFactoryManager.getInstance().getLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries); entries = CommandLauncherManager.getInstance().getLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries);
} }
return entries; return entries;

View file

@ -29,19 +29,19 @@ import org.eclipse.core.runtime.Platform;
/** /**
* @since 6.3 * @since 6.3
*/ */
public class CommandLauncherFactoryManager { public class CommandLauncherManager {
private static CommandLauncherFactoryManager instance; private static CommandLauncherManager instance;
private List<ICommandLauncherFactory> factories = new ArrayList<>(); private List<ICommandLauncherFactory> factories = new ArrayList<>();
private CommandLauncherFactoryManager() { private CommandLauncherManager() {
loadCommandLauncherFactoryExtensions(); loadCommandLauncherFactoryExtensions();
} }
public static synchronized CommandLauncherFactoryManager getInstance() { public static synchronized CommandLauncherManager getInstance() {
if (instance == null) { if (instance == null) {
instance = new CommandLauncherFactoryManager(); instance = new CommandLauncherManager();
} }
return instance; return instance;
} }
@ -57,9 +57,9 @@ public class CommandLauncherFactoryManager {
private IProject fProject; private IProject fProject;
private boolean fShowCommand; private boolean fShowCommand;
private String fErrorMessage; private String fErrorMessage;
private CommandLauncherFactoryManager manager; private CommandLauncherManager manager;
public CommandLauncherWrapper(CommandLauncherFactoryManager manager) { public CommandLauncherWrapper(CommandLauncherManager manager) {
this.manager = manager; this.manager = manager;
} }
@ -142,6 +142,7 @@ public class CommandLauncherFactoryManager {
return launcher.execute(commandPath, args, env, workingDirectory, monitor); return launcher.execute(commandPath, args, env, workingDirectory, monitor);
} }
@SuppressWarnings("deprecation")
@Override @Override
public int waitAndRead(OutputStream out, OutputStream err) { public int waitAndRead(OutputStream out, OutputStream err) {
if (launcher != null) { if (launcher != null) {

View file

@ -17,7 +17,7 @@ import java.net.URI;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.eclipse.cdt.core.CommandLauncherFactoryManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.remote.internal.core.Activator; import org.eclipse.cdt.remote.internal.core.Activator;
import org.eclipse.cdt.remote.internal.core.messages.Messages; import org.eclipse.cdt.remote.internal.core.messages.Messages;
@ -104,7 +104,7 @@ public class RemoteCommandLauncher implements ICommandLauncher {
return s; return s;
} }
private ICommandLauncher fLocalLauncher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(); private ICommandLauncher fLocalLauncher = CommandLauncherManager.getInstance().getCommandLauncher();
private boolean fShowCommand; private boolean fShowCommand;
private String[] fCommandArgs; private String[] fCommandArgs;
private IRemoteConnection fConnection; private IRemoteConnection fConnection;
@ -131,7 +131,7 @@ public class RemoteCommandLauncher implements ICommandLauncher {
@Override @Override
public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor)
throws CoreException { throws CoreException {
ICommandLauncher localLauncher = CommandLauncherFactoryManager.getInstance().getCommandLauncher(getProject()); ICommandLauncher localLauncher = CommandLauncherManager.getInstance().getCommandLauncher(getProject());
localLauncher.setProject(getProject()); localLauncher.setProject(getProject());
localLauncher.setErrorMessage(getErrorMessage()); localLauncher.setErrorMessage(getErrorMessage());
usingLocalLauncher = false; usingLocalLauncher = false;