Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Ruiz2012-02-23 16:17:23 -0500
committerSergey Prigogin2012-02-23 16:17:23 -0500
commitb25c644007819f436d503d7e329f81533ecdd7d6 (patch)
tree9c202476b3c646442a9880e7bee480f71778a652 /codan/org.eclipse.cdt.codan.ui
parenta631e47e437dfe02bf91f3c0afae98b5269eb05a (diff)
downloadorg.eclipse.cdt-b25c644007819f436d503d7e329f81533ecdd7d6.tar.gz
org.eclipse.cdt-b25c644007819f436d503d7e329f81533ecdd7d6.tar.xz
org.eclipse.cdt-b25c644007819f436d503d7e329f81533ecdd7d6.zip
* Enabled correct API baseline (3.7) and fixed related API-check errors.
* Moved classes that are not part of the API to "internal" packages. * Removed unnecessary classes. * Simplified creation of checkers by providing alternative super class and constructors.
Diffstat (limited to 'codan/org.eclipse.cdt.codan.ui')
-rw-r--r--codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF2
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java1
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/CommandLauncher.java (renamed from codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/CommandInvoker.java)32
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/ConsolePrinterFactory.java30
4 files changed, 48 insertions, 17 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
index f915a5f0dd..03165322a3 100644
--- a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
+++ b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true
-Bundle-Version: 2.0.1.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.codan.internal.ui.CodanUIActivator
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java
index 7cb3830985..016bcbc36e 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java
@@ -160,6 +160,7 @@ public class CodanEditorUtility {
/**
* Returns the active workbench page.
* @return the active workbench page, or {@code null} if none can be found.
+ * @since 2.1
*/
public static IWorkbenchPage getActivePage() {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/CommandInvoker.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/CommandLauncher.java
index 5140080c4b..cf371943b3 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/CommandInvoker.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/CommandLauncher.java
@@ -17,26 +17,28 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
-import org.eclipse.cdt.codan.core.externaltool.ICommandInvoker;
-import org.eclipse.cdt.codan.core.externaltool.IOutputParser;
+import org.eclipse.cdt.codan.core.externaltool.ICommandLauncher;
+import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser;
import org.eclipse.cdt.codan.core.externaltool.InvocationFailure;
-import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.ui.PartInitException;
/**
* Invokes an external tool command.
*
* @author alruiz@google.com (Alex Ruiz)
+ *
+ * @since 2.1
*/
-public class CommandInvoker implements ICommandInvoker {
+public class CommandLauncher implements ICommandLauncher {
private static final String[] ENVIRONMENT_VARIABLE_SETTINGS = {};
+ private ConsolePrinterFactory consolePrinterFactory = new ConsolePrinterFactory();
+
@Override
public void buildAndLaunchCommand(IProject project, String externalToolName,
IPath executablePath, String[] args, IPath workingDirectory, boolean shouldDisplayOutput,
- List<IOutputParser> parsers) throws InvocationFailure, Throwable {
+ List<AbstractOutputParser> parsers) throws InvocationFailure, Throwable {
ConsolePrinter consolePrinter = consolePrinter(externalToolName, shouldDisplayOutput);
String command = buildCommand(executablePath, args);
Process process = null;
@@ -60,14 +62,7 @@ public class CommandInvoker implements ICommandInvoker {
}
private ConsolePrinter consolePrinter(String externalToolName, boolean shouldDisplayOutput) {
- if (shouldDisplayOutput) {
- try {
- return ConsolePrinterImpl.createOrFindConsole(externalToolName);
- } catch (PartInitException e) {
- CodanUIActivator.log("Unable to create/find console", e); //$NON-NLS-1$
- }
- }
- return ConsolePrinter.NullImpl;
+ return consolePrinterFactory.createConsolePrinter(externalToolName, shouldDisplayOutput);
}
private String buildCommand(IPath executablePath, String[] args) {
@@ -87,7 +82,7 @@ public class CommandInvoker implements ICommandInvoker {
return runtime.exec(command, ENVIRONMENT_VARIABLE_SETTINGS, workingDirectory.toFile());
}
- private void processStream(InputStream inputStream, List<IOutputParser> parsers,
+ private void processStream(InputStream inputStream, List<AbstractOutputParser> parsers,
ConsolePrinter consolePrinter) throws IOException, InvocationFailure {
Reader reader = null;
try {
@@ -96,7 +91,7 @@ public class CommandInvoker implements ICommandInvoker {
String line = null;
while ((line = bufferedReader.readLine()) != null) {
consolePrinter.println(line);
- for (IOutputParser parser : parsers) {
+ for (AbstractOutputParser parser : parsers) {
if (parser.parse(line)) {
break;
}
@@ -110,4 +105,9 @@ public class CommandInvoker implements ICommandInvoker {
}
}
}
+
+ // Visible for testing.
+ void setConsolePrinterFactory(ConsolePrinterFactory newVal) {
+ this.consolePrinterFactory = newVal;
+ }
}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/ConsolePrinterFactory.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/ConsolePrinterFactory.java
new file mode 100644
index 0000000000..7a86efef31
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/externaltool/ConsolePrinterFactory.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Google, Inc.
+ * 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:
+ * Alex Ruiz - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.ui.externaltool;
+
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+class ConsolePrinterFactory {
+ ConsolePrinter createConsolePrinter(String externalToolName, boolean shouldDisplayOutput) {
+ if (shouldDisplayOutput) {
+ try {
+ return ConsolePrinterImpl.createOrFindConsole(externalToolName);
+ } catch (PartInitException e) {
+ CodanUIActivator.log("Unable to create/find console", e); //$NON-NLS-1$
+ }
+ }
+ return ConsolePrinter.NullImpl;
+ }
+}

Back to the top