1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +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;
/**
* 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)
*
* @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
* console.
* @param shouldDisplayOutput indicates whether the user wants to see the output of the external
* tool in the 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.ConfigurationSettings;
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.IProblemDisplay;
import org.eclipse.cdt.codan.core.externaltool.ISupportedResourceVerifier;
@ -45,7 +45,7 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
private final IInvocationParametersProvider parametersProvider;
private final ISupportedResourceVerifier supportedResourceVerifier;
private final IArgsSeparator argsSeparator;
private final ConfigurationSettings configurationSettings;
private final ConfigurationSettings settings;
private final ExternalToolInvoker externalToolInvoker;
private final RootProblemPreference preferences;
@ -56,18 +56,18 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
* external tool.
* @param argsSeparator separates the arguments to pass to the external tool executable. These
* arguments are stored in a single {@code String}.
* @param consolePrinterFinder finds an Eclipse console that uses the name of an external tool
* as its own.
* @param configurationSettings user-configurable external tool configuration settings.
* @param consolePrinterProvider creates an Eclipse console that uses the name of an external
* tool as its own.
* @param settings user-configurable external tool configuration settings.
*/
public AbstractExternalToolBasedChecker(IInvocationParametersProvider parametersProvider,
ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator,
IConsolePrinterFinder consolePrinterFinder, ConfigurationSettings configurationSettings) {
IConsolePrinterProvider consolePrinterProvider, ConfigurationSettings settings) {
this.parametersProvider = parametersProvider;
this.supportedResourceVerifier = supportedResourceVerifier;
this.argsSeparator = argsSeparator;
this.configurationSettings = configurationSettings;
externalToolInvoker = new ExternalToolInvoker(consolePrinterFinder);
this.settings = settings;
externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider);
preferences = new SharedRootProblemPreference();
}
@ -118,7 +118,7 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
updateConfigurationSettingsFromPreferences(parameters.getActualFile());
List<AbstractOutputParser> parsers = createParsers(parameters);
try {
externalToolInvoker.invoke(parameters, configurationSettings, argsSeparator, parsers);
externalToolInvoker.invoke(parameters, settings, argsSeparator, parsers);
} catch (InvocationFailure error) {
handleInvocationFailure(error, parameters);
}
@ -127,7 +127,7 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
private void updateConfigurationSettingsFromPreferences(IResource fileToProcess) {
IProblem problem = getProblemById(getReferenceProblemId(), fileToProcess);
MapProblemPreference preferences = (MapProblemPreference) problem.getPreference();
configurationSettings.updateValuesFrom(preferences);
settings.updateValuesFrom(preferences);
}
/**
@ -180,9 +180,9 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
@Override
public void initPreferences(IProblemWorkingCopy problem) {
super.initPreferences(problem);
addPreference(problem, configurationSettings.getPath());
addPreference(problem, configurationSettings.getArgs());
addPreference(problem, configurationSettings.getShouldDisplayOutput());
addPreference(problem, settings.getPath());
addPreference(problem, settings.getArgs());
addPreference(problem, settings.getShouldDisplayOutput());
}
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.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.core.runtime.IPath;
@ -32,14 +32,15 @@ import org.eclipse.core.runtime.IPath;
*/
public class CommandLauncher {
private ProcessInvoker processInvoker = new ProcessInvoker();
private final IConsolePrinterFinder consolePrinterFinder;
private final IConsolePrinterProvider consolePrinterProvider;
/**
* 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) {
this.consolePrinterFinder = consolePrinter;
public CommandLauncher(IConsolePrinterProvider consolePrinterProvider) {
this.consolePrinterProvider = consolePrinterProvider;
}
/**
@ -60,7 +61,7 @@ public class CommandLauncher {
String command = buildCommand(executablePath, args);
Process process = null;
IConsolePrinter console =
consolePrinterFinder.findConsole(externalToolName, shouldDisplayOutput);
consolePrinterProvider.createConsole(externalToolName, shouldDisplayOutput);
try {
console.clear();
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.ConfigurationSettings;
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.InvocationParameters;
import org.eclipse.core.runtime.IPath;
@ -34,15 +34,18 @@ public class ExternalToolInvoker {
/**
* Constructor.
* @param consolePrinterFinder finds an Eclipse console that uses the name of an external tool
* as its own.
* @param consolePrinterProvider creates an Eclipse console that uses the name of an external
* tool as its own.
*/
public ExternalToolInvoker(IConsolePrinterFinder consolePrinterFinder) {
this(new CommandLauncher(consolePrinterFinder));
public ExternalToolInvoker(IConsolePrinterProvider consolePrinterProvider) {
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;
}

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.model.AbstractExternalToolBasedChecker;
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
@ -59,6 +59,6 @@ public abstract class AbstractCxxExternalToolBasedChecker extends AbstractExtern
ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator,
ConfigurationSettings configurationSettings) {
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 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.ui.CodanEditorUtility;
import org.eclipse.ui.IWorkbenchPage;
@ -25,18 +25,18 @@ import org.eclipse.ui.console.IConsoleView;
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)
*
* @since 2.1
*/
public class ConsolePrinterFinder implements IConsolePrinterFinder {
public class ConsolePrinterProvider implements IConsolePrinterProvider {
private static final NullConsolePrinter NULL_CONSOLE = new NullConsolePrinter();
/** {@inheritDoc} */
@Override
public IConsolePrinter findConsole(String externalToolName, boolean shouldDisplayOutput) {
public IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput) {
if (shouldDisplayOutput) {
try {
return createOrFindConsole(externalToolName);