mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +02:00
Adjustments to Alex's contribution.
This commit is contained in:
parent
d7f5c2bd7c
commit
934adecf48
35 changed files with 240 additions and 293 deletions
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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
|
||||
private static final Map<String, String> PROBLEM_IDS = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
ERROR_PROBLEM_ID = addProblemId("error"); //$NON-NLS-1$
|
||||
addProblemId("warning"); //$NON-NLS-1$
|
||||
addProblemId("style"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static String addProblemId(String severity) {
|
||||
String problemId = "org.eclipse.cdt.codan.checkers.cppcheck." + severity; //$NON-NLS-1$
|
||||
PROBLEM_IDS.put(severity, problemId);
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.checkers.externaltool;
|
||||
|
||||
|
@ -78,5 +78,6 @@ public class CppcheckOutputParser extends AbstractOutputParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reset() {}
|
||||
public void reset() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.SuspiciousSemicolonCheckerTest;
|
||||
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.CatchByReferenceQuickFixTest;
|
||||
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.core.externaltool.ExternalToolInvokerTest;
|
||||
|
||||
public class AutomatedIntegrationSuite extends TestSuite {
|
||||
public AutomatedIntegrationSuite() {
|
||||
|
@ -69,6 +71,8 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
|||
suite.addTestSuite(SuggestedParenthesisCheckerTest.class);
|
||||
suite.addTestSuite(SuspiciousSemicolonCheckerTest.class);
|
||||
suite.addTestSuite(UnusedSymbolInFileScopeCheckerTest.class);
|
||||
suite.addTestSuite(ExternalToolInvokerTest.class);
|
||||
suite.addTestSuite(CppcheckOutputParserTest.class);
|
||||
// framework
|
||||
suite.addTest(CodanFastTestSuite.suite());
|
||||
// quick fixes
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.checkers.externaltool;
|
||||
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.core.externaltool;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
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.ConfigurationSettings;
|
||||
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.InvocationFailure;
|
||||
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.IProblemPreference;
|
||||
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.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>.
|
||||
*
|
||||
|
@ -73,7 +73,7 @@ public class ExternalToolInvokerTest extends CodanTestCase {
|
|||
MapProblemPreference preferences = createPreferences(new File(externalToolPath),
|
||||
"--include=all --debug=true", shouldDisplayOutput);
|
||||
settings.updateValuesFrom(preferences);
|
||||
argsSeparator = new SpaceDelimitedArgsSeparator();
|
||||
argsSeparator = new SpaceArgsSeparator();
|
||||
externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider, processInvoker);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class ExternalToolInvokerTest extends CodanTestCase {
|
|||
preferences.addChildDescriptor(createPreference(PathSetting.KEY, executablePath));
|
||||
preferences.addChildDescriptor(createPreference(ArgsSetting.KEY, args));
|
||||
preferences.addChildDescriptor(
|
||||
createPreference(ShouldDisplayOutputSetting.KEY, shouldDisplayOutput));
|
||||
createPreference(ConsoleOutputSetting.KEY, shouldDisplayOutput));
|
||||
return preferences;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#Wed Feb 23 19:43:25 EST 2011
|
||||
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.targetPlatform=1.6
|
||||
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.emptyStatement=warning
|
||||
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.fatalOptionalError=enabled
|
||||
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.forbiddenReference=error
|
||||
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.incompleteEnumSwitch=warning
|
||||
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.missingDeprecatedAnnotation=ignore
|
||||
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.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
|
||||
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.missingJavadocTagsVisibility=public
|
||||
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.nonExternalizedStringLiteral=warning
|
||||
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.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
|
||||
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.redundantNullAnnotation=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.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
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.unclosedCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
|
|
|
@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
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.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.checkers",
|
||||
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.ui",
|
||||
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"
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
|
||||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
import java.util.List;
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||
import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser;
|
||||
import org.eclipse.cdt.codan.core.externaltool.ConfigurationSettings;
|
||||
import org.eclipse.cdt.codan.core.externaltool.IArgsSeparator;
|
||||
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinterProvider;
|
||||
import org.eclipse.cdt.codan.core.externaltool.IInvocationParametersProvider;
|
||||
import org.eclipse.cdt.codan.core.externaltool.IProblemDisplay;
|
||||
import org.eclipse.cdt.codan.core.externaltool.ISupportedResourceVerifier;
|
||||
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.model.AbstractCheckerWithProblemPreferences;
|
||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemLocation;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||
import org.eclipse.cdt.codan.core.param.IProblemPreference;
|
||||
import org.eclipse.cdt.codan.core.param.MapProblemPreference;
|
||||
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.core.resources.IResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Base class for checkers that invoke external command-line tools to perform code checking.
|
||||
* <p>
|
||||
|
@ -43,7 +45,6 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
|
|||
private static final boolean DO_NOT_TRAVERSE_CHILDREN = false;
|
||||
|
||||
private final IInvocationParametersProvider parametersProvider;
|
||||
private final ISupportedResourceVerifier supportedResourceVerifier;
|
||||
private final IArgsSeparator argsSeparator;
|
||||
private final ConfigurationSettings settings;
|
||||
private final ExternalToolInvoker externalToolInvoker;
|
||||
|
@ -52,8 +53,6 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
|
|||
/**
|
||||
* Constructor.
|
||||
* @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
|
||||
* arguments are stored in a single {@code String}.
|
||||
* @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.
|
||||
*/
|
||||
public AbstractExternalToolBasedChecker(IInvocationParametersProvider parametersProvider,
|
||||
ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator,
|
||||
IConsolePrinterProvider consolePrinterProvider, ConfigurationSettings settings) {
|
||||
IArgsSeparator argsSeparator, IConsolePrinterProvider consolePrinterProvider,
|
||||
ConfigurationSettings settings) {
|
||||
this.parametersProvider = parametersProvider;
|
||||
this.supportedResourceVerifier = supportedResourceVerifier;
|
||||
this.argsSeparator = argsSeparator;
|
||||
this.settings = settings;
|
||||
externalToolInvoker = new ExternalToolInvoker(consolePrinterProvider);
|
||||
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
|
||||
* method returns {@code false}.
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
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.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.
|
||||
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.codan.internal.core.externaltool.ShouldDisplayOutputSetti
|
|||
public final class ConfigurationSettings {
|
||||
private final PathSetting path;
|
||||
private final ArgsSetting args;
|
||||
private final ShouldDisplayOutputSetting shouldDisplayOutput;
|
||||
private final ConsoleOutputSetting shouldDisplayOutput;
|
||||
private final String externalToolName;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ public final class ConfigurationSettings {
|
|||
this.externalToolName = externalToolName;
|
||||
this.path = new PathSetting(externalToolName, defaultPath);
|
||||
this.args = new ArgsSetting(externalToolName, defaultArgs);
|
||||
this.shouldDisplayOutput = new ShouldDisplayOutputSetting(defaultShouldDisplayOutput);
|
||||
this.shouldDisplayOutput = new ConsoleOutputSetting(defaultShouldDisplayOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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
|
||||
* separates them into individual values.
|
||||
* @param args contains the arguments to pass to the external tool
|
||||
* executable.
|
||||
* @param args contains the arguments to pass to the external tool executable.
|
||||
* @return the separated argument values.
|
||||
*/
|
||||
String[] separateArgs(String args);
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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
|
||||
* 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)
|
||||
*
|
||||
* @since 2.1
|
||||
|
@ -22,21 +25,21 @@ public interface IConsolePrinter {
|
|||
/**
|
||||
* Clears the contents of the console.
|
||||
*/
|
||||
void clear();
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Prints the specified message to the console, followed by a line separator string.
|
||||
* @param message the message to print.
|
||||
*/
|
||||
void println(String message);
|
||||
public void println(String message);
|
||||
|
||||
/**
|
||||
* Prints a line separator to the console.
|
||||
*/
|
||||
void println();
|
||||
public void println();
|
||||
|
||||
/**
|
||||
* Closes the output stream of the console.
|
||||
*/
|
||||
void close();
|
||||
public void close();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*
|
||||
* @since 2.1
|
||||
|
@ -26,5 +29,5 @@ public interface IConsolePrinterProvider {
|
|||
* tool in the console.
|
||||
* @return the created or found console.
|
||||
*/
|
||||
IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput);
|
||||
public IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput);
|
||||
}
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.
|
||||
*
|
||||
* @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)
|
||||
*
|
||||
* @since 2.1
|
||||
|
@ -25,7 +28,7 @@ public interface IProblemDisplay {
|
|||
* @param location the problem's location (e.g. file and line number.)
|
||||
* @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.
|
||||
|
@ -33,5 +36,5 @@ public interface IProblemDisplay {
|
|||
* @param description the description of the problem.
|
||||
* @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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
|
@ -18,7 +18,7 @@ package org.eclipse.cdt.codan.core.externaltool;
|
|||
* @since 2.1
|
||||
*/
|
||||
public class InvocationFailure extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 6727101323050538885L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -31,8 +31,8 @@ public class InvocationFailure extends Exception {
|
|||
/**
|
||||
* Constructor.
|
||||
* @param message the detail message.
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* <code>{@link #getCause()}</code> method.)
|
||||
* @param cause the cause (which is saved for later retrieval by
|
||||
* the <code>{@link #getCause()}</code> method.)
|
||||
*/
|
||||
public InvocationFailure(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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
|
||||
* command-line tool when saved.
|
||||
* Returns the original file to process. This is the file that triggered execution of
|
||||
* a command-line tool when saved.
|
||||
* @return the original file to process.
|
||||
*/
|
||||
public IResource getOriginalFile() {
|
||||
|
@ -55,11 +55,11 @@ public final class InvocationParameters {
|
|||
|
||||
/**
|
||||
* 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>
|
||||
* A good example is an external tool that can only process C++ files but header files. If the
|
||||
* <em>original</em> file is a header file, the checker could potentially find a C++ file that
|
||||
* includes such header and use it as the <em>actual</em> file to process.
|
||||
* A good example is an external tool that can only process C++ source files but not header
|
||||
* files. If the <em>original</em> file is a header file, the checker could potentially find
|
||||
* a C++ file that includes such header and use it as the <em>actual</em> file to process.
|
||||
* </p>
|
||||
* <p>
|
||||
* We still need to keep a reference to the <em>actual</em> file, in order to add markers to
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.externaltool;
|
||||
|
||||
|
@ -20,13 +20,10 @@ import java.util.regex.Pattern;
|
|||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public final class SpaceDelimitedArgsSeparator implements IArgsSeparator {
|
||||
private static final String[] NO_ARGS = new String[0];
|
||||
public final class SpaceArgsSeparator implements IArgsSeparator {
|
||||
private static final String[] NO_ARGS = {};
|
||||
private static final Pattern EMPTY_SPACE_PATTERN = Pattern.compile("\\s+"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String[] separateArgs(String args) {
|
||||
if (args == null || args.isEmpty()) {
|
|
@ -11,15 +11,15 @@
|
|||
*******************************************************************************/
|
||||
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.internal.core.CheckersRegistry;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Convenience implementation of IChecker interface. Has a default
|
||||
* implementation for common methods.
|
||||
|
@ -43,7 +43,7 @@ public abstract class AbstractChecker implements IChecker {
|
|||
*/
|
||||
@Override
|
||||
public boolean enabledInContext(IResource res) {
|
||||
return res instanceof IFile;
|
||||
return res.getType() == IResource.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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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}.
|
||||
*
|
||||
* @author alruiz@google.com (Alex Ruiz)
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ArgsSetting extends SingleConfigurationSetting<String> {
|
||||
static final String KEY = "externalToolArgs"; //$NON-NLS-1$
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.
|
||||
*
|
||||
* @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$
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param defaultValue the default value of the setting.
|
||||
*/
|
||||
public ShouldDisplayOutputSetting(boolean defaultValue) {
|
||||
public ConsoleOutputSetting(boolean defaultValue) {
|
||||
super(newPreferenceDescriptor(), defaultValue, Boolean.class);
|
||||
}
|
||||
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.File;
|
||||
import java.io.IOException;
|
||||
|
@ -18,22 +28,10 @@ import java.io.InputStreamReader;
|
|||
import java.io.Reader;
|
||||
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.
|
||||
*
|
||||
* @author alruiz@google.com (Alex Ruiz)
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ExternalToolInvoker {
|
||||
private final IConsolePrinterProvider consolePrinterProvider;
|
||||
|
@ -164,7 +162,8 @@ public class ExternalToolInvoker {
|
|||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ignored) {}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.core.externaltool;
|
||||
|
||||
|
@ -14,19 +14,16 @@ import org.eclipse.osgi.util.NLS;
|
|||
|
||||
/**
|
||||
* @author alruiz@google.com (Alex Ruiz)
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages extends NLS {
|
||||
public static String ConfigurationSettings_args_format;
|
||||
public static String ConfigurationSettings_path_format;
|
||||
public static String ConfigurationSettings_should_display_output;
|
||||
|
||||
static {
|
||||
Class<Messages> clazz = Messages.class;
|
||||
NLS.initializeMessages(clazz.getName(), clazz);
|
||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
||||
}
|
||||
|
||||
private Messages() {}
|
||||
private Messages() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_path_format=%s Path:
|
||||
ConfigurationSettings_should_display_output=Display Output in Console
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.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.param.BasicProblemPreference;
|
||||
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.
|
||||
*
|
||||
* @author alruiz@google.com (Alex Ruiz)
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class PathSetting extends SingleConfigurationSetting<File> {
|
||||
static final String KEY = "externalToolPath"; //$NON-NLS-1$
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.core.externaltool;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.codan.core.externaltool.InvocationFailure;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Executes a command in a separate process.
|
||||
*
|
||||
* @author alruiz@google.com (Alex Ruiz)
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ProcessInvoker {
|
||||
private static final String[] ENVIRONMENT_VARIABLE_SETTINGS = {};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.IArgsSeparator;
|
||||
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.SpaceDelimitedArgsSeparator;
|
||||
import org.eclipse.cdt.codan.core.model.AbstractExternalToolBasedChecker;
|
||||
import org.eclipse.cdt.codan.internal.ui.cxx.externaltool.CxxSupportedResourceVerifier;
|
||||
import org.eclipse.cdt.codan.ui.externaltool.ConsolePrinterProvider;
|
||||
import org.eclipse.cdt.codan.core.externaltool.SpaceArgsSeparator;
|
||||
import org.eclipse.cdt.codan.internal.ui.externaltool.ConsolePrinterProvider;
|
||||
import org.eclipse.cdt.codan.ui.CodanEditorUtility;
|
||||
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
|
||||
|
@ -42,23 +45,51 @@ public abstract class AbstractCxxExternalToolBasedChecker extends AbstractExtern
|
|||
* @param configurationSettings user-configurable external tool configuration settings.
|
||||
*/
|
||||
public AbstractCxxExternalToolBasedChecker(ConfigurationSettings configurationSettings) {
|
||||
this(new InvocationParametersProvider(), new CxxSupportedResourceVerifier(),
|
||||
new SpaceDelimitedArgsSeparator(), configurationSettings);
|
||||
this(new InvocationParametersProvider(), new SpaceArgsSeparator(), configurationSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @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
|
||||
* arguments are stored in a single {@code String}.
|
||||
* @param configurationSettings user-configurable external tool configuration settings.
|
||||
*/
|
||||
public AbstractCxxExternalToolBasedChecker(IInvocationParametersProvider parametersProvider,
|
||||
ISupportedResourceVerifier supportedResourceVerifier, IArgsSeparator argsSeparator,
|
||||
ConfigurationSettings configurationSettings) {
|
||||
super(parametersProvider, supportedResourceVerifier, argsSeparator,
|
||||
new ConsolePrinterProvider(), configurationSettings);
|
||||
IArgsSeparator argsSeparator, ConfigurationSettings configurationSettings) {
|
||||
super(parametersProvider, argsSeparator, 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ Bundle-ActivationPolicy: lazy
|
|||
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.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.views;x-internal:=true,
|
||||
org.eclipse.cdt.codan.internal.ui.widgets;x-internal:=true,
|
||||
org.eclipse.cdt.codan.ui,
|
||||
org.eclipse.cdt.codan.ui.externaltool,
|
||||
org.eclipse.cdt.codan.ui.handlers
|
||||
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* Alex Ruiz (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.ui.externaltool;
|
||||
|
||||
import java.io.IOException;
|
||||
package org.eclipse.cdt.codan.internal.ui.externaltool;
|
||||
|
||||
import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
|
||||
import org.eclipse.ui.console.MessageConsole;
|
||||
import org.eclipse.ui.console.MessageConsoleStream;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Default implementation of <code>{@link IConsolePrinter}</code>.
|
||||
*
|
||||
* @author alruiz@google.com (Alex Ruiz)
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
class ConsolePrinter implements IConsolePrinter {
|
||||
private final MessageConsole console;
|
||||
|
@ -32,18 +30,22 @@ class ConsolePrinter implements IConsolePrinter {
|
|||
out = console.newMessageStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
console.clearConsole();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String s) {
|
||||
out.println(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println() {
|
||||
out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
out.close();
|
|
@ -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
|
||||
* 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
|
||||
* 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;
|
||||
|
||||
|
@ -28,13 +28,10 @@ import org.eclipse.ui.console.MessageConsole;
|
|||
* Default implementation of <code>{@link IConsolePrinterProvider}</code>.
|
||||
*
|
||||
* @author alruiz@google.com (Alex Ruiz)
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ConsolePrinterProvider implements IConsolePrinterProvider {
|
||||
private static final NullConsolePrinter NULL_CONSOLE = new NullConsolePrinter();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public IConsolePrinter createConsole(String externalToolName, boolean shouldDisplayOutput) {
|
||||
if (shouldDisplayOutput) {
|
|
@ -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
|
||||
* 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
|
||||
* 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;
|
||||
|
||||
|
@ -19,14 +19,18 @@ import org.eclipse.cdt.codan.core.externaltool.IConsolePrinter;
|
|||
*/
|
||||
class NullConsolePrinter implements IConsolePrinter {
|
||||
@Override
|
||||
public void clear() {}
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String message) {}
|
||||
public void println(String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println() {}
|
||||
public void println() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
public void close() {
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue