1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 18:55:38 +02:00

Adjustments to Alex's contribution.

This commit is contained in:
Sergey Prigogin 2012-02-23 11:45:19 -08:00
parent d7f5c2bd7c
commit 934adecf48
35 changed files with 240 additions and 293 deletions

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui; package org.eclipse.cdt.codan.internal.checkers.ui;
@ -41,11 +41,13 @@ public class CppcheckChecker extends AbstractCxxExternalToolBasedChecker {
// key: severity (error, warning, etc.) - value : problem ID associated to severity // key: severity (error, warning, etc.) - value : problem ID associated to severity
private static final Map<String, String> PROBLEM_IDS = new HashMap<String, String>(); private static final Map<String, String> PROBLEM_IDS = new HashMap<String, String>();
static { static {
ERROR_PROBLEM_ID = addProblemId("error"); //$NON-NLS-1$ ERROR_PROBLEM_ID = addProblemId("error"); //$NON-NLS-1$
addProblemId("warning"); //$NON-NLS-1$ addProblemId("warning"); //$NON-NLS-1$
addProblemId("style"); //$NON-NLS-1$ addProblemId("style"); //$NON-NLS-1$
} }
private static String addProblemId(String severity) { private static String addProblemId(String severity) {
String problemId = "org.eclipse.cdt.codan.checkers.cppcheck." + severity; //$NON-NLS-1$ String problemId = "org.eclipse.cdt.codan.checkers.cppcheck." + severity; //$NON-NLS-1$
PROBLEM_IDS.put(severity, problemId); PROBLEM_IDS.put(severity, problemId);

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.externaltool; package org.eclipse.cdt.codan.internal.checkers.externaltool;
@ -78,5 +78,6 @@ public class CppcheckOutputParser extends AbstractOutputParser {
} }
@Override @Override
public void reset() {} public void reset() {
}
} }

View file

@ -30,10 +30,12 @@ import org.eclipse.cdt.codan.core.internal.checkers.StatementHasNoEffectCheckerT
import org.eclipse.cdt.codan.core.internal.checkers.SuggestedParenthesisCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.SuggestedParenthesisCheckerTest;
import org.eclipse.cdt.codan.core.internal.checkers.SuspiciousSemicolonCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.SuspiciousSemicolonCheckerTest;
import org.eclipse.cdt.codan.core.internal.checkers.UnusedSymbolInFileScopeCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.UnusedSymbolInFileScopeCheckerTest;
import org.eclipse.cdt.codan.internal.checkers.externaltool.CppcheckOutputParserTest;
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CaseBreakQuickFixTest; import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CaseBreakQuickFixTest;
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CatchByReferenceQuickFixTest; import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CatchByReferenceQuickFixTest;
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CreateLocalVariableQuickFixTest; import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CreateLocalVariableQuickFixTest;
import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.SuggestedParenthesisQuickFixTest; import org.eclipse.cdt.codan.internal.checkers.ui.quickfix.SuggestedParenthesisQuickFixTest;
import org.eclipse.cdt.codan.internal.core.externaltool.ExternalToolInvokerTest;
public class AutomatedIntegrationSuite extends TestSuite { public class AutomatedIntegrationSuite extends TestSuite {
public AutomatedIntegrationSuite() { public AutomatedIntegrationSuite() {
@ -69,6 +71,8 @@ public class AutomatedIntegrationSuite extends TestSuite {
suite.addTestSuite(SuggestedParenthesisCheckerTest.class); suite.addTestSuite(SuggestedParenthesisCheckerTest.class);
suite.addTestSuite(SuspiciousSemicolonCheckerTest.class); suite.addTestSuite(SuspiciousSemicolonCheckerTest.class);
suite.addTestSuite(UnusedSymbolInFileScopeCheckerTest.class); suite.addTestSuite(UnusedSymbolInFileScopeCheckerTest.class);
suite.addTestSuite(ExternalToolInvokerTest.class);
suite.addTestSuite(CppcheckOutputParserTest.class);
// framework // framework
suite.addTest(CodanFastTestSuite.suite()); suite.addTest(CodanFastTestSuite.suite());
// quick fixes // quick fixes

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.externaltool; package org.eclipse.cdt.codan.internal.checkers.externaltool;

View file

@ -1,25 +1,18 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.externaltool; package org.eclipse.cdt.codan.internal.core.externaltool;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
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;
@ -27,7 +20,7 @@ import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider; 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.cdt.codan.core.externaltool.SpaceDelimitedArgsSeparator; import org.eclipse.cdt.codan.core.externaltool.SpaceArgsSeparator;
import org.eclipse.cdt.codan.core.param.BasicProblemPreference; import org.eclipse.cdt.codan.core.param.BasicProblemPreference;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.param.MapProblemPreference; import org.eclipse.cdt.codan.core.param.MapProblemPreference;
@ -35,6 +28,13 @@ import org.eclipse.cdt.codan.core.test.CodanTestCase;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
/** /**
* Tests for <code>{@link ExternalToolInvoker}</code>. * Tests for <code>{@link ExternalToolInvoker}</code>.
* *
@ -73,7 +73,7 @@ public class ExternalToolInvokerTest extends CodanTestCase {
MapProblemPreference preferences = createPreferences(new File(externalToolPath), MapProblemPreference preferences = createPreferences(new File(externalToolPath),
"--include=all --debug=true", shouldDisplayOutput); "--include=all --debug=true", shouldDisplayOutput);
settings.updateValuesFrom(preferences); settings.updateValuesFrom(preferences);
argsSeparator = new SpaceDelimitedArgsSeparator(); argsSeparator = new SpaceArgsSeparator();
externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider, processInvoker); externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider, processInvoker);
} }
@ -83,7 +83,7 @@ public class ExternalToolInvokerTest extends CodanTestCase {
preferences.addChildDescriptor(createPreference(PathSetting.KEY, executablePath)); preferences.addChildDescriptor(createPreference(PathSetting.KEY, executablePath));
preferences.addChildDescriptor(createPreference(ArgsSetting.KEY, args)); preferences.addChildDescriptor(createPreference(ArgsSetting.KEY, args));
preferences.addChildDescriptor( preferences.addChildDescriptor(
createPreference(ShouldDisplayOutputSetting.KEY, shouldDisplayOutput)); createPreference(ConsoleOutputSetting.KEY, shouldDisplayOutput));
return preferences; return preferences;
} }

View file

@ -1,5 +1,9 @@
#Wed Feb 23 19:43:25 EST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@ -19,6 +23,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
@ -26,6 +31,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@ -38,11 +44,12 @@ org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
@ -53,20 +60,30 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
org.eclipse.jdt.core.compiler.problem.nullReference=error org.eclipse.jdt.core.compiler.problem.nullReference=error
org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore

View file

@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.cdt.codan.core, Export-Package: org.eclipse.cdt.codan.core,
org.eclipse.cdt.codan.core.externaltool, org.eclipse.cdt.codan.core.externaltool;x-friends:="org.eclipse.cdt.codan.ui,org.eclipse.cdt.codan.core.test",
org.eclipse.cdt.codan.core.model, org.eclipse.cdt.codan.core.model,
org.eclipse.cdt.codan.core.model.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.checkers", org.eclipse.cdt.codan.core.model.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.checkers",
org.eclipse.cdt.codan.core.param, org.eclipse.cdt.codan.core.param,
@ -20,5 +20,5 @@ Export-Package: org.eclipse.cdt.codan.core,
org.eclipse.cdt.codan.core.test, org.eclipse.cdt.codan.core.test,
org.eclipse.cdt.codan.ui", org.eclipse.cdt.codan.ui",
org.eclipse.cdt.codan.internal.core.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx", org.eclipse.cdt.codan.internal.core.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx",
org.eclipse.cdt.codan.internal.core.externaltool, org.eclipse.cdt.codan.internal.core.externaltool;x-friends:="org.eclipse.cdt.codan.core.test",
org.eclipse.cdt.codan.internal.core.model;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.core.test,org.eclipse.cdt.codan.ui" org.eclipse.cdt.codan.internal.core.model;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.core.test,org.eclipse.cdt.codan.ui"

View file

@ -1,20 +1,20 @@
// Copyright 2012 Google Inc. All Rights Reserved. /*******************************************************************************
* Copyright (c) 2012 Google, Inc and others.
package org.eclipse.cdt.codan.core.model; * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
import java.util.List; * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool;
import org.eclipse.cdt.codan.core.CodanCorePlugin; import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser; import org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences;
import org.eclipse.cdt.codan.core.externaltool.ConfigurationSettings; import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.externaltool.IArgsSeparator; import org.eclipse.cdt.codan.core.model.IProblemLocation;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider; import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.core.externaltool.IInvocationParametersProvider;
import org.eclipse.cdt.codan.core.externaltool.IProblemDisplay;
import org.eclipse.cdt.codan.core.externaltool.ISupportedResourceVerifier;
import org.eclipse.cdt.codan.core.externaltool.InvocationFailure;
import org.eclipse.cdt.codan.core.externaltool.InvocationParameters;
import org.eclipse.cdt.codan.core.externaltool.SingleConfigurationSetting;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.param.MapProblemPreference; import org.eclipse.cdt.codan.core.param.MapProblemPreference;
import org.eclipse.cdt.codan.core.param.RootProblemPreference; import org.eclipse.cdt.codan.core.param.RootProblemPreference;
@ -22,6 +22,8 @@ import org.eclipse.cdt.codan.core.param.SharedRootProblemPreference;
import org.eclipse.cdt.codan.internal.core.externaltool.ExternalToolInvoker; import org.eclipse.cdt.codan.internal.core.externaltool.ExternalToolInvoker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import java.util.List;
/** /**
* 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.
* <p> * <p>
@ -43,7 +45,6 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
private static final boolean DO_NOT_TRAVERSE_CHILDREN = false; private static final boolean DO_NOT_TRAVERSE_CHILDREN = false;
private final IInvocationParametersProvider parametersProvider; private final IInvocationParametersProvider parametersProvider;
private final ISupportedResourceVerifier supportedResourceVerifier;
private final IArgsSeparator argsSeparator; private final IArgsSeparator argsSeparator;
private final ConfigurationSettings settings; private final ConfigurationSettings settings;
private final ExternalToolInvoker externalToolInvoker; private final ExternalToolInvoker externalToolInvoker;
@ -52,8 +53,6 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
/** /**
* Constructor. * Constructor.
* @param parametersProvider provides the parameters to pass when invoking the external tool. * @param parametersProvider provides the parameters to pass when invoking the external tool.
* @param supportedResourceVerifier indicates whether a resource can be processed by the
* 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 consolePrinterProvider creates an Eclipse console that uses the name of an external * @param consolePrinterProvider creates an Eclipse console that uses the name of an external
@ -61,27 +60,15 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
* @param settings 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, IArgsSeparator argsSeparator, IConsolePrinterProvider consolePrinterProvider,
IConsolePrinterProvider consolePrinterProvider, ConfigurationSettings settings) { ConfigurationSettings settings) {
this.parametersProvider = parametersProvider; this.parametersProvider = parametersProvider;
this.supportedResourceVerifier = supportedResourceVerifier;
this.argsSeparator = argsSeparator; this.argsSeparator = argsSeparator;
this.settings = settings; this.settings = settings;
externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider); externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider);
preferences = new SharedRootProblemPreference(); preferences = new SharedRootProblemPreference();
} }
/**
* Indicates whether this checker can process the given resource. For more details, please
* see <code>{@link ISupportedResourceVerifier#isSupported(IResource)}</code>.
* @param resource the given resource.
* @return {@code true} if this checker can process the given resource, {@code false} otherwise.
*/
@Override
public boolean enabledInContext(IResource resource) {
return supportedResourceVerifier.isSupported(resource);
}
/** /**
* Indicates whether this checker is enabled to run while the user types. By default, this * Indicates whether this checker is enabled to run while the user types. By default, this
* method returns {@code false}. * method returns {@code false}.

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;

View file

@ -1,21 +1,21 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
import java.io.File;
import org.eclipse.cdt.codan.core.param.MapProblemPreference; import org.eclipse.cdt.codan.core.param.MapProblemPreference;
import org.eclipse.cdt.codan.internal.core.externaltool.ArgsSetting; import org.eclipse.cdt.codan.internal.core.externaltool.ArgsSetting;
import org.eclipse.cdt.codan.internal.core.externaltool.PathSetting; import org.eclipse.cdt.codan.internal.core.externaltool.PathSetting;
import org.eclipse.cdt.codan.internal.core.externaltool.ShouldDisplayOutputSetting; import org.eclipse.cdt.codan.internal.core.externaltool.ConsoleOutputSetting;
import java.io.File;
/** /**
* User-configurable external tool settings. * User-configurable external tool settings.
@ -27,7 +27,7 @@ import org.eclipse.cdt.codan.internal.core.externaltool.ShouldDisplayOutputSetti
public final class ConfigurationSettings { public final class ConfigurationSettings {
private final PathSetting path; private final PathSetting path;
private final ArgsSetting args; private final ArgsSetting args;
private final ShouldDisplayOutputSetting shouldDisplayOutput; private final ConsoleOutputSetting shouldDisplayOutput;
private final String externalToolName; private final String externalToolName;
/** /**
@ -43,7 +43,7 @@ public final class ConfigurationSettings {
this.externalToolName = externalToolName; this.externalToolName = externalToolName;
this.path = new PathSetting(externalToolName, defaultPath); this.path = new PathSetting(externalToolName, defaultPath);
this.args = new ArgsSetting(externalToolName, defaultArgs); this.args = new ArgsSetting(externalToolName, defaultArgs);
this.shouldDisplayOutput = new ShouldDisplayOutputSetting(defaultShouldDisplayOutput); this.shouldDisplayOutput = new ConsoleOutputSetting(defaultShouldDisplayOutput);
} }
/** /**

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
@ -22,8 +22,7 @@ public interface IArgsSeparator {
/** /**
* Parses a given {@code String} containing the arguments to pass to an external tool and * Parses a given {@code String} containing the arguments to pass to an external tool and
* separates them into individual values. * separates them into individual values.
* @param args contains the arguments to pass to the external tool * @param args contains the arguments to pass to the external tool executable.
* executable.
* @return the separated argument values. * @return the separated argument values.
*/ */
String[] separateArgs(String args); String[] separateArgs(String args);

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
@ -14,6 +14,9 @@ package org.eclipse.cdt.codan.core.externaltool;
* Prints the output of an external tool to an Eclipse console. It uses the name of the external * Prints the output of an external tool to an Eclipse console. It uses the name of the external
* tool as the console ID. * tool as the console ID.
* *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
* *
* @since 2.1 * @since 2.1
@ -22,21 +25,21 @@ public interface IConsolePrinter {
/** /**
* Clears the contents of the console. * Clears the contents of the console.
*/ */
void clear(); public void clear();
/** /**
* Prints the specified message to the console, followed by a line separator string. * Prints the specified message to the console, followed by a line separator string.
* @param message the message to print. * @param message the message to print.
*/ */
void println(String message); public void println(String message);
/** /**
* Prints a line separator to the console. * Prints a line separator to the console.
*/ */
void println(); public void println();
/** /**
* Closes the output stream of the console. * Closes the output stream of the console.
*/ */
void close(); public void close();
} }

View file

@ -1,18 +1,21 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
/** /**
* Creates or 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.
* *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
* *
* @since 2.1 * @since 2.1
@ -26,5 +29,5 @@ public interface IConsolePrinterProvider {
* tool in the console. * tool in the console.
* @return the created or found console. * @return the created or found console.
*/ */
IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput); public IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput);
} }

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
@ -15,6 +15,9 @@ import org.eclipse.cdt.codan.core.model.IProblemLocation;
/** /**
* Reports problems found in code, reported by an external tool. * Reports problems found in code, reported by an external tool.
* *
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
* *
* @since 2.1 * @since 2.1
@ -25,7 +28,7 @@ public interface IProblemDisplay {
* @param location the problem's location (e.g. file and line number.) * @param location the problem's location (e.g. file and line number.)
* @param description the description of the problem. * @param description the description of the problem.
*/ */
void reportProblem(IProblemLocation location, String description); public void reportProblem(IProblemLocation location, String description);
/** /**
* Reports a problem found by an external tool. * Reports a problem found by an external tool.
@ -33,5 +36,5 @@ public interface IProblemDisplay {
* @param description the description of the problem. * @param description the description of the problem.
* @param severity the problem's severity (e.g. "error", "warning", etc.) * @param severity the problem's severity (e.g. "error", "warning", etc.)
*/ */
void reportProblem(IProblemLocation location, String description, String severity); public void reportProblem(IProblemLocation location, String description, String severity);
} }

View file

@ -1,42 +0,0 @@
/*******************************************************************************
* 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.core.externaltool;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
/**
* Verifies that a <code>{@link IResource}</code> can be processed by an external tool.
*
* @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/
public interface ISupportedResourceVerifier {
/**
* Indicates whether the external tool is capable of processing the given
* <code>{@link IResource}</code>.
* <p>
* The minimum requirements that the given {@code IResource} should satisfy
* are:
* <ul>
* <li>should be an <code>{@link IFile}</code></li>
* <li>should be displayed in the current active editor</li>
* <li>should not have any unsaved changes</li>
* </ul>
* </p>
*
* @param resource the given {@code IResource}.
* @return {@code true} if the external tool is capable of processing the
* given file, {@code false} otherwise.
*/
boolean isSupported(IResource resource);
}

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
@ -18,7 +18,7 @@ package org.eclipse.cdt.codan.core.externaltool;
* @since 2.1 * @since 2.1
*/ */
public class InvocationFailure extends Exception { public class InvocationFailure extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 6727101323050538885L;
/** /**
* Constructor. * Constructor.
@ -31,8 +31,8 @@ public class InvocationFailure extends Exception {
/** /**
* Constructor. * Constructor.
* @param message the detail message. * @param message the detail message.
* @param cause the cause (which is saved for later retrieval by the * @param cause the cause (which is saved for later retrieval by
* <code>{@link #getCause()}</code> method.) * the <code>{@link #getCause()}</code> method.)
*/ */
public InvocationFailure(String message, Throwable cause) { public InvocationFailure(String message, Throwable cause) {
super(message, cause); super(message, cause);

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
@ -45,8 +45,8 @@ public final class InvocationParameters {
} }
/** /**
* Returns the original file to process. This is the file that triggered execution of a * Returns the original file to process. This is the file that triggered execution of
* command-line tool when saved. * a command-line tool when saved.
* @return the original file to process. * @return the original file to process.
*/ */
public IResource getOriginalFile() { public IResource getOriginalFile() {
@ -55,11 +55,11 @@ public final class InvocationParameters {
/** /**
* Returns the actual file to process. It may not be the same as * Returns the actual file to process. It may not be the same as
* <code>{@link #getActualFile()}</code>, depending on how the external tool works. * <code>{@link #getOriginalFile()}</code>, depending on how the external tool works.
* <p> * <p>
* A good example is an external tool that can only process C++ files but header files. If the * A good example is an external tool that can only process C++ source files but not header
* <em>original</em> file is a header file, the checker could potentially find a C++ file that * files. If the <em>original</em> file is a header file, the checker could potentially find
* includes such header and use it as the <em>actual</em> file to process. * a C++ file that includes such header and use it as the <em>actual</em> file to process.
* </p> * </p>
* <p> * <p>
* We still need to keep a reference to the <em>actual</em> file, in order to add markers to * We still need to keep a reference to the <em>actual</em> file, in order to add markers to

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.externaltool; package org.eclipse.cdt.codan.core.externaltool;
@ -20,13 +20,10 @@ import java.util.regex.Pattern;
* *
* @since 2.1 * @since 2.1
*/ */
public final class SpaceDelimitedArgsSeparator implements IArgsSeparator { public final class SpaceArgsSeparator implements IArgsSeparator {
private static final String[] NO_ARGS = new String[0]; private static final String[] NO_ARGS = {};
private static final Pattern EMPTY_SPACE_PATTERN = Pattern.compile("\\s+"); //$NON-NLS-1$ private static final Pattern EMPTY_SPACE_PATTERN = Pattern.compile("\\s+"); //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override @Override
public String[] separateArgs(String args) { public String[] separateArgs(String args) {
if (args == null || args.isEmpty()) { if (args == null || args.isEmpty()) {

View file

@ -11,15 +11,15 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.codan.core.CodanRuntime; import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.internal.core.CheckersRegistry; import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.OperationCanceledException;
import java.util.ArrayList;
import java.util.List;
/** /**
* Convenience implementation of IChecker interface. Has a default * Convenience implementation of IChecker interface. Has a default
* implementation for common methods. * implementation for common methods.
@ -43,7 +43,7 @@ public abstract class AbstractChecker implements IChecker {
*/ */
@Override @Override
public boolean enabledInContext(IResource res) { public boolean enabledInContext(IResource res) {
return res instanceof IFile; return res.getType() == IResource.FILE;
} }
/** /**

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.externaltool; package org.eclipse.cdt.codan.internal.core.externaltool;
@ -22,8 +22,6 @@ import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor;
* The arguments are stored in a single {@code String}. * The arguments are stored in a single {@code String}.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
public class ArgsSetting extends SingleConfigurationSetting<String> { public class ArgsSetting extends SingleConfigurationSetting<String> {
static final String KEY = "externalToolArgs"; //$NON-NLS-1$ static final String KEY = "externalToolArgs"; //$NON-NLS-1$

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.externaltool; package org.eclipse.cdt.codan.internal.core.externaltool;
@ -22,17 +22,15 @@ import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor;
* displayed in an Eclipse console. * displayed in an Eclipse console.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
public class ShouldDisplayOutputSetting extends SingleConfigurationSetting<Boolean> { public class ConsoleOutputSetting extends SingleConfigurationSetting<Boolean> {
static final String KEY = "externalToolShouldDisplayOutput"; //$NON-NLS-1$ static final String KEY = "externalToolShouldDisplayOutput"; //$NON-NLS-1$
/** /**
* Constructor. * Constructor.
* @param defaultValue the default value of the setting. * @param defaultValue the default value of the setting.
*/ */
public ShouldDisplayOutputSetting(boolean defaultValue) { public ConsoleOutputSetting(boolean defaultValue) {
super(newPreferenceDescriptor(), defaultValue, Boolean.class); super(newPreferenceDescriptor(), defaultValue, Boolean.class);
} }

View file

@ -1,15 +1,25 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.externaltool; package org.eclipse.cdt.codan.internal.core.externaltool;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider;
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.InvocationFailure;
import org.eclipse.cdt.codan.core.externaltool.InvocationParameters;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -18,22 +28,10 @@ import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.util.List; 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.IConsolePrinter;
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;
import org.eclipse.core.runtime.Path;
/** /**
* Invokes an external tool to perform checks on a single file. * Invokes an external tool to perform checks on a single file.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
public class ExternalToolInvoker { public class ExternalToolInvoker {
private final IConsolePrinterProvider consolePrinterProvider; private final IConsolePrinterProvider consolePrinterProvider;
@ -164,7 +162,8 @@ public class ExternalToolInvoker {
if (reader != null) { if (reader != null) {
try { try {
reader.close(); reader.close();
} catch (IOException ignored) {} } catch (IOException ignored) {
}
} }
} }
} }

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.externaltool; package org.eclipse.cdt.codan.internal.core.externaltool;
@ -14,19 +14,16 @@ import org.eclipse.osgi.util.NLS;
/** /**
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
@SuppressWarnings("javadoc")
public class Messages extends NLS { public class Messages extends NLS {
public static String ConfigurationSettings_args_format; public static String ConfigurationSettings_args_format;
public static String ConfigurationSettings_path_format; public static String ConfigurationSettings_path_format;
public static String ConfigurationSettings_should_display_output; public static String ConfigurationSettings_should_display_output;
static { static {
Class<Messages> clazz = Messages.class; NLS.initializeMessages(Messages.class.getName(), Messages.class);
NLS.initializeMessages(clazz.getName(), clazz);
} }
private Messages() {} private Messages() {
}
} }

View file

@ -1,3 +1,13 @@
###############################################################################
# Copyright (c) 2012 Google, 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:
# Alex Ruiz (Google) - initial API and implementation
###############################################################################
ConfigurationSettings_args_format=%s Args: ConfigurationSettings_args_format=%s Args:
ConfigurationSettings_path_format=%s Path: ConfigurationSettings_path_format=%s Path:
ConfigurationSettings_should_display_output=Display Output in Console ConfigurationSettings_should_display_output=Display Output in Console

View file

@ -1,30 +1,28 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.externaltool; package org.eclipse.cdt.codan.internal.core.externaltool;
import static org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType.TYPE_FILE; import static org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType.TYPE_FILE;
import static org.eclipse.cdt.codan.internal.core.externaltool.Messages.ConfigurationSettings_path_format; import static org.eclipse.cdt.codan.internal.core.externaltool.Messages.ConfigurationSettings_path_format;
import java.io.File;
import org.eclipse.cdt.codan.core.externaltool.SingleConfigurationSetting; import org.eclipse.cdt.codan.core.externaltool.SingleConfigurationSetting;
import org.eclipse.cdt.codan.core.param.BasicProblemPreference; import org.eclipse.cdt.codan.core.param.BasicProblemPreference;
import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor; import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor;
import java.io.File;
/** /**
* User-configurable setting that specifies the path and name of an external tool's executable. * User-configurable setting that specifies the path and name of an external tool's executable.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
public class PathSetting extends SingleConfigurationSetting<File> { public class PathSetting extends SingleConfigurationSetting<File> {
static final String KEY = "externalToolPath"; //$NON-NLS-1$ static final String KEY = "externalToolPath"; //$NON-NLS-1$

View file

@ -1,26 +1,24 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.externaltool; package org.eclipse.cdt.codan.internal.core.externaltool;
import java.io.IOException;
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;
import java.io.IOException;
/** /**
* Executes a command in a separate process. * Executes a command in a separate process.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
public class ProcessInvoker { public class ProcessInvoker {
private static final String[] ENVIRONMENT_VARIABLE_SETTINGS = {}; private static final String[] ENVIRONMENT_VARIABLE_SETTINGS = {};

View file

@ -1,59 +0,0 @@
/*******************************************************************************
* 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.internal.ui.cxx.externaltool;
import static org.eclipse.cdt.codan.core.cxx.util.FileTypes.isCppFile;
import static org.eclipse.cdt.codan.core.cxx.util.FileTypes.isHeaderFile;
import static org.eclipse.cdt.codan.ui.CodanEditorUtility.isResourceOpenInEditor;
import static org.eclipse.cdt.codan.ui.cxx.util.CEditors.activeCEditor;
import org.eclipse.cdt.codan.core.externaltool.ISupportedResourceVerifier;
import org.eclipse.core.resources.IResource;
import org.eclipse.ui.editors.text.TextEditor;
/**
* Implementation of <code>{@link ISupportedResourceVerifier}</code> for C/C++ files.
*
* @author alruiz@google.com (Alex Ruiz)
*/
public class CxxSupportedResourceVerifier implements ISupportedResourceVerifier {
/**
* Indicates whether the external tool is capable of processing the given
* <code>{@link IResource}</code>.
* <p>
* The minimum requirements that the given {@code IResource} should satisfy are:
* <ul>
* <li>should be C/C++ file</li>
* <li>should be displayed in the current active {@code CEditor}</li>
* <li>should not have any unsaved changes</li>
* </ul>
* </p>
* @param resource the given {@code IResource}.
* @return {@code true} if the external tool is capable of processing the given file,
* {@code false} otherwise.
*/
@Override
public boolean isSupported(IResource resource) {
return isFileOfSupportedType(resource) && isOpenInActiveCEditor(resource);
}
private boolean isFileOfSupportedType(IResource resource) {
return isCppFile(resource) || isHeaderFile(resource);
}
private boolean isOpenInActiveCEditor(IResource resource) {
TextEditor activeCEditor = activeCEditor();
if (activeCEditor == null) {
return false;
}
return !activeCEditor.isDirty() && isResourceOpenInEditor(resource, activeCEditor);
}
}

View file

@ -1,24 +1,27 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.ui.cxx.externaltool; package org.eclipse.cdt.codan.ui.cxx.externaltool;
import org.eclipse.cdt.codan.core.cxx.util.FileTypes;
import org.eclipse.cdt.codan.core.externaltool.AbstractExternalToolBasedChecker;
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.IInvocationParametersProvider; import org.eclipse.cdt.codan.core.externaltool.IInvocationParametersProvider;
import org.eclipse.cdt.codan.core.externaltool.ISupportedResourceVerifier;
import org.eclipse.cdt.codan.core.externaltool.InvocationParametersProvider; import org.eclipse.cdt.codan.core.externaltool.InvocationParametersProvider;
import org.eclipse.cdt.codan.core.externaltool.SpaceDelimitedArgsSeparator; import org.eclipse.cdt.codan.core.externaltool.SpaceArgsSeparator;
import org.eclipse.cdt.codan.core.model.AbstractExternalToolBasedChecker; import org.eclipse.cdt.codan.internal.ui.externaltool.ConsolePrinterProvider;
import org.eclipse.cdt.codan.internal.ui.cxx.externaltool.CxxSupportedResourceVerifier; import org.eclipse.cdt.codan.ui.CodanEditorUtility;
import org.eclipse.cdt.codan.ui.externaltool.ConsolePrinterProvider; import org.eclipse.cdt.codan.ui.cxx.util.CEditors;
import org.eclipse.core.resources.IResource;
import org.eclipse.ui.editors.text.TextEditor;
/** /**
* 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
@ -42,23 +45,51 @@ public abstract class AbstractCxxExternalToolBasedChecker extends AbstractExtern
* @param configurationSettings user-configurable external tool configuration settings. * @param configurationSettings user-configurable external tool configuration settings.
*/ */
public AbstractCxxExternalToolBasedChecker(ConfigurationSettings configurationSettings) { public AbstractCxxExternalToolBasedChecker(ConfigurationSettings configurationSettings) {
this(new InvocationParametersProvider(), new CxxSupportedResourceVerifier(), this(new InvocationParametersProvider(), new SpaceArgsSeparator(), configurationSettings);
new SpaceDelimitedArgsSeparator(), configurationSettings);
} }
/** /**
* Constructor. * Constructor.
* @param parametersProvider provides the parameters to pass when invoking the external tool. * @param parametersProvider provides the parameters to pass when invoking the external tool.
* @param supportedResourceVerifier indicates whether a resource can be processed by the
* 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 configurationSettings user-configurable external tool configuration settings. * @param configurationSettings user-configurable external tool configuration settings.
*/ */
public AbstractCxxExternalToolBasedChecker(IInvocationParametersProvider parametersProvider, public AbstractCxxExternalToolBasedChecker(IInvocationParametersProvider parametersProvider,
ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator, IArgsSeparator argsSeparator, ConfigurationSettings configurationSettings) {
ConfigurationSettings configurationSettings) { super(parametersProvider, argsSeparator, new ConsolePrinterProvider(),
super(parametersProvider, supportedResourceVerifier, argsSeparator, configurationSettings);
new ConsolePrinterProvider(), configurationSettings); }
/**
* Indicates whether the external tool is capable of processing the given
* <code>{@link IResource}</code>.
* <p>
* The minimum requirements that the given {@code IResource} should satisfy are:
* <ul>
* <li>should be C/C++ file</li>
* <li>should be displayed in the current active {@code CEditor}</li>
* <li>should not have any unsaved changes</li>
* </ul>
* </p>
* @param resource the given {@code IResource}.
* @return {@code true} if the external tool is capable of processing the given file,
* {@code false} otherwise.
*/
@Override
public boolean enabledInContext(IResource resource) {
return isFileOfSupportedType(resource) && isOpenInActiveCleanEditor(resource);
}
private boolean isFileOfSupportedType(IResource resource) {
return FileTypes.isCppFile(resource) || FileTypes.isHeaderFile(resource);
}
private boolean isOpenInActiveCleanEditor(IResource resource) {
TextEditor editor = CEditors.activeCEditor();
if (editor == null) {
return false;
}
return !editor.isDirty() && CodanEditorUtility.isResourceOpenInEditor(resource, editor);
} }
} }

View file

@ -20,10 +20,10 @@ Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx", Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx",
org.eclipse.cdt.codan.internal.ui.actions;x-friends:="org.eclipse.cdt.codan.ui.cxx", org.eclipse.cdt.codan.internal.ui.actions;x-friends:="org.eclipse.cdt.codan.ui.cxx",
org.eclipse.cdt.codan.internal.ui.dialogs;x-friends:="org.eclipse.cdt.codan.ui.cxx", org.eclipse.cdt.codan.internal.ui.dialogs;x-friends:="org.eclipse.cdt.codan.ui.cxx",
org.eclipse.cdt.codan.internal.ui.externaltool;x-friends:="org.eclipse.cdt.codan.ui.cxx",
org.eclipse.cdt.codan.internal.ui.preferences;x-friends:="org.eclipse.cdt.codan.ui.cxx", org.eclipse.cdt.codan.internal.ui.preferences;x-friends:="org.eclipse.cdt.codan.ui.cxx",
org.eclipse.cdt.codan.internal.ui.views;x-internal:=true, org.eclipse.cdt.codan.internal.ui.views;x-internal:=true,
org.eclipse.cdt.codan.internal.ui.widgets;x-internal:=true, org.eclipse.cdt.codan.internal.ui.widgets;x-internal:=true,
org.eclipse.cdt.codan.ui, org.eclipse.cdt.codan.ui,
org.eclipse.cdt.codan.ui.externaltool,
org.eclipse.cdt.codan.ui.handlers org.eclipse.cdt.codan.ui.handlers

View file

@ -1,27 +1,25 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.ui.externaltool; package org.eclipse.cdt.codan.internal.ui.externaltool;
import java.io.IOException;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
import org.eclipse.ui.console.MessageConsole; import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream; import org.eclipse.ui.console.MessageConsoleStream;
import java.io.IOException;
/** /**
* Default implementation of <code>{@link IConsolePrinter}</code>. * Default implementation of <code>{@link IConsolePrinter}</code>.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
class ConsolePrinter implements IConsolePrinter { class ConsolePrinter implements IConsolePrinter {
private final MessageConsole console; private final MessageConsole console;
@ -32,18 +30,22 @@ class ConsolePrinter implements IConsolePrinter {
out = console.newMessageStream(); out = console.newMessageStream();
} }
@Override
public void clear() { public void clear() {
console.clearConsole(); console.clearConsole();
} }
@Override
public void println(String s) { public void println(String s) {
out.println(s); out.println(s);
} }
@Override
public void println() { public void println() {
out.println(); out.println();
} }
@Override
public void close() { public void close() {
try { try {
out.close(); out.close();

View file

@ -1,14 +1,14 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.ui.externaltool; package org.eclipse.cdt.codan.internal.ui.externaltool;
import static org.eclipse.ui.console.IConsoleConstants.ID_CONSOLE_VIEW; import static org.eclipse.ui.console.IConsoleConstants.ID_CONSOLE_VIEW;
@ -28,13 +28,10 @@ import org.eclipse.ui.console.MessageConsole;
* Default implementation of <code>{@link IConsolePrinterProvider}</code>. * Default implementation of <code>{@link IConsolePrinterProvider}</code>.
* *
* @author alruiz@google.com (Alex Ruiz) * @author alruiz@google.com (Alex Ruiz)
*
* @since 2.1
*/ */
public class ConsolePrinterProvider implements IConsolePrinterProvider { public class ConsolePrinterProvider implements IConsolePrinterProvider {
private static final NullConsolePrinter NULL_CONSOLE = new NullConsolePrinter(); private static final NullConsolePrinter NULL_CONSOLE = new NullConsolePrinter();
/** {@inheritDoc} */
@Override @Override
public IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput) { public IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput) {
if (shouldDisplayOutput) { if (shouldDisplayOutput) {

View file

@ -1,14 +1,14 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc. * Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Alex Ruiz - initial API and implementation * Alex Ruiz (Google) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.ui.externaltool; package org.eclipse.cdt.codan.internal.ui.externaltool;
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter; import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
@ -19,14 +19,18 @@ import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
*/ */
class NullConsolePrinter implements IConsolePrinter { class NullConsolePrinter implements IConsolePrinter {
@Override @Override
public void clear() {} public void clear() {
}
@Override @Override
public void println(String message) {} public void println(String message) {
}
@Override @Override
public void println() {} public void println() {
}
@Override @Override
public void close() {} public void close() {
}
} }