1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Leftover cleanup from previous commit.

This commit is contained in:
Alex Ruiz 2012-02-23 13:22:06 -08:00 committed by Sergey Prigogin
parent 88d576787e
commit fba2b5c3e4
6 changed files with 40 additions and 36 deletions

View file

@ -11,20 +11,20 @@
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
/** /**
* Finds an Eclipse console that uses the name of an external tool as its own. * Creates or finds an Eclipse console that uses the name of an external tool as its own.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
* *
* @since 2.1 * @since 2.1
*/ */
public interface IConsolePrinterFinder { public interface IConsolePrinterProvider {
/** /**
* Finds an Eclipse console that uses the name of an external tool as its own. * Creates an Eclipse console that uses the name of an external tool as its own.
* @param externalToolName the name of the external tool that will be used as the name of the * @param externalToolName the name of the external tool that will be used as the name of the
* console. * console.
* @param shouldDisplayOutput indicates whether the user wants to see the output of the external * @param shouldDisplayOutput indicates whether the user wants to see the output of the external
* tool in the console. * tool in the console.
* @return the created or found console. * @return the created or found console.
*/ */
IConsolePrinter findConsole(String externalToolName, boolean shouldDisplayOutput); IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput);
} }

View file

@ -8,7 +8,7 @@ import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser; import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser;
import org.eclipse.cdt.codan.core.externaltool.ConfigurationSettings; import org.eclipse.cdt.codan.core.externaltool.ConfigurationSettings;
import org.eclipse.cdt.codan.core.externaltool.IArgsSeparator; import org.eclipse.cdt.codan.core.externaltool.IArgsSeparator;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterFinder; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider;
import org.eclipse.cdt.codan.core.externaltool.IInvocationParametersProvider; import org.eclipse.cdt.codan.core.externaltool.IInvocationParametersProvider;
import org.eclipse.cdt.codan.core.externaltool.IProblemDisplay; import org.eclipse.cdt.codan.core.externaltool.IProblemDisplay;
import org.eclipse.cdt.codan.core.externaltool.ISupportedResourceVerifier; import org.eclipse.cdt.codan.core.externaltool.ISupportedResourceVerifier;
@ -45,7 +45,7 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
private final IInvocationParametersProvider parametersProvider; private final IInvocationParametersProvider parametersProvider;
private final ISupportedResourceVerifier supportedResourceVerifier; private final ISupportedResourceVerifier supportedResourceVerifier;
private final IArgsSeparator argsSeparator; private final IArgsSeparator argsSeparator;
private final ConfigurationSettings configurationSettings; private final ConfigurationSettings settings;
private final ExternalToolInvoker externalToolInvoker; private final ExternalToolInvoker externalToolInvoker;
private final RootProblemPreference preferences; private final RootProblemPreference preferences;
@ -56,18 +56,18 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
* external tool. * external tool.
* @param argsSeparator separates the arguments to pass to the external tool executable. These * @param argsSeparator separates the arguments to pass to the external tool executable. These
* arguments are stored in a single {@code String}. * arguments are stored in a single {@code String}.
* @param consolePrinterFinder finds an Eclipse console that uses the name of an external tool * @param consolePrinterProvider creates an Eclipse console that uses the name of an external
* as its own. * tool as its own.
* @param configurationSettings user-configurable external tool configuration settings. * @param settings user-configurable external tool configuration settings.
*/ */
public AbstractExternalToolBasedChecker(IInvocationParametersProvider parametersProvider, public AbstractExternalToolBasedChecker(IInvocationParametersProvider parametersProvider,
ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator, ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator,
IConsolePrinterFinder consolePrinterFinder, ConfigurationSettings configurationSettings) { IConsolePrinterProvider consolePrinterProvider, ConfigurationSettings settings) {
this.parametersProvider = parametersProvider; this.parametersProvider = parametersProvider;
this.supportedResourceVerifier = supportedResourceVerifier; this.supportedResourceVerifier = supportedResourceVerifier;
this.argsSeparator = argsSeparator; this.argsSeparator = argsSeparator;
this.configurationSettings = configurationSettings; this.settings = settings;
externalToolInvoker = new ExternalToolInvoker(consolePrinterFinder); externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider);
preferences = new SharedRootProblemPreference(); preferences = new SharedRootProblemPreference();
} }
@ -118,7 +118,7 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
updateConfigurationSettingsFromPreferences(parameters.getActualFile()); updateConfigurationSettingsFromPreferences(parameters.getActualFile());
List<AbstractOutputParser> parsers = createParsers(parameters); List<AbstractOutputParser> parsers = createParsers(parameters);
try { try {
externalToolInvoker.invoke(parameters, configurationSettings, argsSeparator, parsers); externalToolInvoker.invoke(parameters, settings, argsSeparator, parsers);
} catch (InvocationFailure error) { } catch (InvocationFailure error) {
handleInvocationFailure(error, parameters); handleInvocationFailure(error, parameters);
} }
@ -127,7 +127,7 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
private void updateConfigurationSettingsFromPreferences(IResource fileToProcess) { private void updateConfigurationSettingsFromPreferences(IResource fileToProcess) {
IProblem problem = getProblemById(getReferenceProblemId(), fileToProcess); IProblem problem = getProblemById(getReferenceProblemId(), fileToProcess);
MapProblemPreference preferences = (MapProblemPreference) problem.getPreference(); MapProblemPreference preferences = (MapProblemPreference) problem.getPreference();
configurationSettings.updateValuesFrom(preferences); settings.updateValuesFrom(preferences);
} }
/** /**
@ -180,9 +180,9 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
@Override @Override
public void initPreferences(IProblemWorkingCopy problem) { public void initPreferences(IProblemWorkingCopy problem) {
super.initPreferences(problem); super.initPreferences(problem);
addPreference(problem, configurationSettings.getPath()); addPreference(problem, settings.getPath());
addPreference(problem, configurationSettings.getArgs()); addPreference(problem, settings.getArgs());
addPreference(problem, configurationSettings.getShouldDisplayOutput()); addPreference(problem, settings.getShouldDisplayOutput());
} }
private void addPreference(IProblemWorkingCopy problem, SingleConfigurationSetting<?> setting) { private void addPreference(IProblemWorkingCopy problem, SingleConfigurationSetting<?> setting) {

View file

@ -19,7 +19,7 @@ import java.util.List;
import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser; import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterFinder; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider;
import org.eclipse.cdt.codan.core.externaltool.InvocationFailure; import org.eclipse.cdt.codan.core.externaltool.InvocationFailure;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -32,14 +32,15 @@ import org.eclipse.core.runtime.IPath;
*/ */
public class CommandLauncher { public class CommandLauncher {
private ProcessInvoker processInvoker = new ProcessInvoker(); private ProcessInvoker processInvoker = new ProcessInvoker();
private final IConsolePrinterFinder consolePrinterFinder; private final IConsolePrinterProvider consolePrinterProvider;
/** /**
* Constructor. * Constructor.
* @param consolePrinter prints the output of an external tool to an Eclipse Console. * @param consolePrinterProvider creates an Eclipse console that uses the name of an external
* tool as its own.
*/ */
public CommandLauncher(IConsolePrinterFinder consolePrinter) { public CommandLauncher(IConsolePrinterProvider consolePrinterProvider) {
this.consolePrinterFinder = consolePrinter; this.consolePrinterProvider = consolePrinterProvider;
} }
/** /**
@ -60,7 +61,7 @@ public class CommandLauncher {
String command = buildCommand(executablePath, args); String command = buildCommand(executablePath, args);
Process process = null; Process process = null;
IConsolePrinter console = IConsolePrinter console =
consolePrinterFinder.findConsole(externalToolName, shouldDisplayOutput); consolePrinterProvider.createConsole(externalToolName, shouldDisplayOutput);
try { try {
console.clear(); console.clear();
console.println(command); console.println(command);

View file

@ -16,7 +16,7 @@ import java.util.List;
import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser; import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser;
import org.eclipse.cdt.codan.core.externaltool.ConfigurationSettings; import org.eclipse.cdt.codan.core.externaltool.ConfigurationSettings;
import org.eclipse.cdt.codan.core.externaltool.IArgsSeparator; import org.eclipse.cdt.codan.core.externaltool.IArgsSeparator;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterFinder; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider;
import org.eclipse.cdt.codan.core.externaltool.InvocationFailure; import org.eclipse.cdt.codan.core.externaltool.InvocationFailure;
import org.eclipse.cdt.codan.core.externaltool.InvocationParameters; import org.eclipse.cdt.codan.core.externaltool.InvocationParameters;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -34,15 +34,18 @@ public class ExternalToolInvoker {
/** /**
* Constructor. * Constructor.
* @param consolePrinterFinder finds an Eclipse console that uses the name of an external tool * @param consolePrinterProvider creates an Eclipse console that uses the name of an external
* as its own. * tool as its own.
*/ */
public ExternalToolInvoker(IConsolePrinterFinder consolePrinterFinder) { public ExternalToolInvoker(IConsolePrinterProvider consolePrinterProvider) {
this(new CommandLauncher(consolePrinterFinder)); this(new CommandLauncher(consolePrinterProvider));
} }
// Visible for testing. /**
ExternalToolInvoker(CommandLauncher commandLauncher) { * Constructor.
* @param commandLauncher invokes an external tool command.
*/
public ExternalToolInvoker(CommandLauncher commandLauncher) {
this.commandLauncher = commandLauncher; this.commandLauncher = commandLauncher;
} }

View file

@ -18,7 +18,7 @@ import org.eclipse.cdt.codan.core.externaltool.InvocationParametersProvider;
import org.eclipse.cdt.codan.core.externaltool.SpaceDelimitedArgsSeparator; import org.eclipse.cdt.codan.core.externaltool.SpaceDelimitedArgsSeparator;
import org.eclipse.cdt.codan.core.model.AbstractExternalToolBasedChecker; import org.eclipse.cdt.codan.core.model.AbstractExternalToolBasedChecker;
import org.eclipse.cdt.codan.internal.ui.cxx.externaltool.CxxSupportedResourceVerifier; import org.eclipse.cdt.codan.internal.ui.cxx.externaltool.CxxSupportedResourceVerifier;
import org.eclipse.cdt.codan.ui.externaltool.ConsolePrinterFinder; import org.eclipse.cdt.codan.ui.externaltool.ConsolePrinterProvider;
/** /**
* Base class for checkers that invoke external command-line tools to perform code checking * Base class for checkers that invoke external command-line tools to perform code checking
@ -59,6 +59,6 @@ public abstract class AbstractCxxExternalToolBasedChecker extends AbstractExtern
ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator, ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator,
ConfigurationSettings configurationSettings) { ConfigurationSettings configurationSettings) {
super(parametersProvider, supportedResourceVerifier, argsSeparator, super(parametersProvider, supportedResourceVerifier, argsSeparator,
new ConsolePrinterFinder(), configurationSettings); new ConsolePrinterProvider(), configurationSettings);
} }
} }

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.codan.ui.externaltool;
import static org.eclipse.ui.console.IConsoleConstants.ID_CONSOLE_VIEW; import static org.eclipse.ui.console.IConsoleConstants.ID_CONSOLE_VIEW;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterFinder; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator; import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.cdt.codan.ui.CodanEditorUtility; import org.eclipse.cdt.codan.ui.CodanEditorUtility;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
@ -25,18 +25,18 @@ import org.eclipse.ui.console.IConsoleView;
import org.eclipse.ui.console.MessageConsole; import org.eclipse.ui.console.MessageConsole;
/** /**
* Default implementation of <code>{@link IConsolePrinterFinder}</code>. * Default implementation of <code>{@link IConsolePrinterProvider}</code>.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
* *
* @since 2.1 * @since 2.1
*/ */
public class ConsolePrinterFinder implements IConsolePrinterFinder { public class ConsolePrinterProvider implements IConsolePrinterProvider {
private static final NullConsolePrinter NULL_CONSOLE = new NullConsolePrinter(); private static final NullConsolePrinter NULL_CONSOLE = new NullConsolePrinter();
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public IConsolePrinter findConsole(String externalToolName, boolean shouldDisplayOutput) { public IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput) {
if (shouldDisplayOutput) { if (shouldDisplayOutput) {
try { try {
return createOrFindConsole(externalToolName); return createOrFindConsole(externalToolName);