├── com.googlecode.cppcheclipse.core ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.pde.api.tools.prefs ├── cppcheck.png ├── about.ini ├── about.properties ├── build.properties ├── plugin.xml ├── src │ └── com │ │ └── googlecode │ │ └── cppcheclipse │ │ └── core │ │ ├── TableModel.java │ │ ├── command │ │ ├── EmptyPathException.java │ │ ├── IncompatibleVersionException.java │ │ ├── VersionCommand.java │ │ ├── ProcessExecutionException.java │ │ ├── UpdateCheckCommand.java │ │ ├── ErrorListCommand.java │ │ └── Version.java │ │ ├── utils │ │ ├── IHttpClientService.java │ │ ├── FileUtils.java │ │ ├── SerializeHelper.java │ │ ├── PathMacroReplacer.java │ │ ├── PatternSearch.java │ │ ├── LineFilterOutputStream.java │ │ └── HttpClientService.java │ │ ├── IToolchainSettings.java │ │ ├── IProgressReporter.java │ │ ├── IConsole.java │ │ ├── IProblemReporter.java │ │ ├── ProblemSeverity.java │ │ ├── Appendages.java │ │ ├── Symbol.java │ │ ├── PreferenceInitializer.java │ │ ├── IPreferenceConstants.java │ │ ├── Suppression.java │ │ ├── Symbols.java │ │ ├── SuppressionProfile.java │ │ ├── Checker.java │ │ └── Problem.java ├── .classpath ├── OSGI-INF │ └── HttpClient.xml ├── pom.xml ├── META-INF │ └── MANIFEST.MF └── .project ├── com.googlecode.cppcheclipse.ui ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.pde.api.tools.prefs ├── build.properties ├── .classpath ├── src │ └── com │ │ └── googlecode │ │ └── cppcheclipse │ │ └── ui │ │ ├── Utils.java │ │ ├── marker │ │ ├── ResolutionGenerator.java │ │ ├── ReportBugResolution.java │ │ ├── CheckDescriptionResolution.java │ │ ├── SuppressProblemResolution.java │ │ ├── SuppressProblemInLineResolution.java │ │ ├── SuppressFileResolution.java │ │ ├── SuppressResolution.java │ │ └── ProblemReporter.java │ │ ├── preferences │ │ ├── AppendagePropertyPage.java │ │ ├── SuppressionsPropertyPage.java │ │ ├── AdvancedSettingsPropertyPage.java │ │ ├── ProblemsPreferencePage.java │ │ ├── BuildPropertyPage.java │ │ ├── DependentBooleanFieldEditor.java │ │ ├── AppendageTable.java │ │ ├── SymbolsPropertyPage.java │ │ ├── SymbolsTable.java │ │ ├── SuppressionsTable.java │ │ └── SymbolEditDialog.java │ │ ├── ProgressReporter.java │ │ ├── Activator.java │ │ ├── commands │ │ ├── ClearMarkers.java │ │ ├── RunCodeAnalysis.java │ │ ├── ResourceSelectionJob.java │ │ └── AbstractResourceSelectionJobCommand.java │ │ ├── Nature.java │ │ ├── Console.java │ │ └── Messages.java ├── pom.xml ├── META-INF │ └── MANIFEST.MF └── .project ├── com.googlecode.cppcheclipse.core.tests ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.jdt.core.prefs ├── build.properties ├── src │ └── com │ │ └── googlecode │ │ └── cppcheclipse │ │ ├── tests │ │ ├── MockPreferenceStore.java │ │ └── Activator.java │ │ └── core │ │ ├── utils │ │ ├── TestFileUtils.java │ │ ├── TestSerializeHelper.java │ │ └── TestLineFilterOutputStream.java │ │ ├── command │ │ ├── TestVersion.java │ │ └── TestCppcheckCommand.java │ │ └── SuppressionProfileTest.java ├── .classpath ├── META-INF │ └── MANIFEST.MF ├── pom.xml └── .project ├── com.googlecode.cppcheclipse.feature ├── .gitignore ├── build.properties ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.m2e.core.prefs ├── create_dropin.xml ├── compile.com.googlecode.cppcheclipse.feature.xml ├── .project └── pom.xml ├── com.googlecode.cppcheclipse.repository ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.m2e.core.prefs ├── category.xml ├── .project ├── removeFromBintray.sh ├── packaging-p2composite.ant └── pom.xml ├── com.googlecode.cppcheclipse.ui.tests ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.jdt.core.prefs ├── build.properties ├── src │ └── com │ │ └── googlecode │ │ └── cppcheclipse │ │ └── ui │ │ └── EmptyTest.java ├── .classpath ├── META-INF │ └── MANIFEST.MF ├── pom.xml └── .project ├── com.googlecode.cppcheclipse.parent ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.m2e.core.prefs ├── .project ├── release.txt └── pom.xml ├── com.googlecode.cppcheclipse.target ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.m2e.core.prefs ├── .project ├── eclipse3.7cdtp2.target ├── eclipse3.6cdtp2.target ├── eclipse3.8cdtp2.target ├── eclipse4.2cdtp2.target ├── eclipse4.3cdtp2.target └── pom.xml ├── .travis.yml ├── .project ├── .github └── workflows │ └── maven-ci.yml └── README.md /com.googlecode.cppcheclipse.core/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml 2 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/cppcheck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kwin/cppcheclipse/HEAD/com.googlecode.cppcheclipse.core/cppcheck.png -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.parent/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: java 3 | jdk: openjdk8 4 | sudo: false 5 | script: cd com.googlecode.cppcheclipse.parent && mvn clean verify 6 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/about.ini: -------------------------------------------------------------------------------- 1 | # language dependent entries, are defined in about.properties 2 | aboutText=%blurb 3 | 4 | featureImage=cppcheck.png -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.parent/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | plugin.xml 6 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/about.properties: -------------------------------------------------------------------------------- 1 | blurb=cppcheclipse \n\ 2 | \n\ 3 | (c) Trademark and Copyright 2009-2011 by Konrad Windszus. Licensed under the EPL.\n\ 4 | http://eclipselabs.org/p/cppcheclipse/\n\ 5 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cppcheclipse 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/src/com/googlecode/cppcheclipse/ui/EmptyTest.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui; 2 | 3 | import org.junit.Test; 4 | 5 | public class EmptyTest { 6 | 7 | @Test 8 | public void testAlwaysSucceeding() { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/tests/MockPreferenceStore.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.tests; 2 | 3 | import org.eclipse.jface.preference.PreferenceStore; 4 | 5 | public class MockPreferenceStore extends PreferenceStore { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/build.properties: -------------------------------------------------------------------------------- 1 | output.. = target/classes/ 2 | bin.includes = META-INF/,\ 3 | plugin.xml,\ 4 | .,\ 5 | cppcheck.png,\ 6 | about.properties,\ 7 | about.ini,\ 8 | OSGI-INF/ 9 | source.. = src/ 10 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/TableModel.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.IOException; 4 | 5 | public interface TableModel extends Iterable { 6 | void remove(Element element); 7 | void removeAll(); 8 | Element[] toArray(); 9 | 10 | void save() throws IOException; 11 | } 12 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/category.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/create_dropin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.github/workflows/maven-ci.yml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Set up JDK 1.8 13 | uses: actions/setup-java@v1 14 | with: 15 | java-version: 1.8 16 | - name: Build with Maven 17 | run: mvn -B package --file com.googlecode.cppcheclipse.parent/pom.xml 18 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/EmptyPathException.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | public class EmptyPathException extends ProcessExecutionException { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = 6032180437996210576L; 9 | 10 | public EmptyPathException(String message) { 11 | super(message); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.compliance=1.6 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.6 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/IHttpClientService.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.net.URISyntaxException; 6 | import java.net.URL; 7 | 8 | public interface IHttpClientService { 9 | 10 | public abstract InputStream executeGetRequest(URL url) 11 | throws URISyntaxException, IOException; 12 | 13 | } -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: cppcheclipse UI Tests 4 | Bundle-SymbolicName: com.googlecode.cppcheclipse.ui.tests 5 | Bundle-Version: 1.1.2.qualifier 6 | Bundle-Vendor: Konrad Windszus 7 | Fragment-Host: com.googlecode.cppcheclipse.ui;bundle-version="0.9.8" 8 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7 9 | Require-Bundle: org.junit4;bundle-version="4.8.1" 10 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: cppcheclipse Core Tests 4 | Bundle-SymbolicName: com.googlecode.cppcheclipse.core.tests 5 | Bundle-Version: 1.1.2.qualifier 6 | Bundle-Vendor: Konrad Windszus 7 | Fragment-Host: com.googlecode.cppcheclipse.core;bundle-version="0.9.8" 8 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6 9 | Require-Bundle: org.junit4;bundle-version="4.5.0" 10 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/IToolchainSettings.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.File; 4 | import java.util.Collection; 5 | 6 | 7 | public interface IToolchainSettings { 8 | 9 | public Collection getUserIncludes(); 10 | 11 | public Collection getSystemIncludes(); 12 | 13 | public Collection getUserSymbols(); 14 | 15 | public Collection getSystemSymbols(); 16 | } -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.parent/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.parent-git 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.target-git 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/compile.com.googlecode.cppcheclipse.feature.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/IncompatibleVersionException.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | public class IncompatibleVersionException extends ProcessExecutionException { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = 6032181437996210576L; 9 | 10 | public IncompatibleVersionException(Version version) { 11 | super("You must have at least version " + Version.MIN_VERSION.toString() + " of cppcheck. But you only have version "+ version.toString() +"!"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/IProgressReporter.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | public interface IProgressReporter { 4 | /** 5 | * Reports progress in checking file 6 | * @param currentlyCheckedFilename filename of the currently checked file (may be null to indicate nothing has changed since last report) 7 | * @param numFilesChecked number of files which are already checked (may be null to indicate nothing has changed since last report) 8 | */ 9 | void reportProgress(String currentlyCheckedFilename, Integer numFilesChecked); 10 | } 11 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/Utils.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui; 2 | 3 | import java.net.MalformedURLException; 4 | import java.net.URL; 5 | 6 | import org.eclipse.ui.PartInitException; 7 | import org.eclipse.ui.PlatformUI; 8 | 9 | public class Utils { 10 | 11 | private Utils() { 12 | // only has static methods 13 | } 14 | 15 | public static void openUrl(String url) throws PartInitException, MalformedURLException { 16 | PlatformUI.getWorkbench().getBrowserSupport() 17 | .getExternalBrowser().openURL( 18 | new URL(url)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/OSGI-INF/HttpClient.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/IConsole.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | public interface IConsole { 7 | 8 | public abstract OutputStream getConsoleOutputStream(boolean isError); 9 | 10 | public abstract void print(String line) throws IOException; 11 | 12 | public abstract void println(String line) throws IOException; 13 | 14 | /** 15 | * Shows the console view (in an async way, this method may be called from non UI-thread) 16 | */ 17 | public abstract void show(); 18 | 19 | } -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.feature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.pde.FeatureNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.repository 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.UpdateSiteBuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.pde.UpdateSiteNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.parent/release.txt: -------------------------------------------------------------------------------- 1 | To release version x do the following steps: 2 | 3 | make sure there are no uncommitted changes 4 | mvn -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion= 5 | refresh category.xml (to point to feature in right version) 6 | mvn clean verify -Prelease-composite (see also http://www.lorenzobettini.it/2016/02/publish-an-eclipse-p2-composite-repository-on-bintray/) 7 | tag (from local workspace) 8 | mvn -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=-SNAPSHOT 9 | afterwards the category.xml has to be updated manually, due to the changed version of the referenced feature 10 | commit -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import java.io.File; 4 | import java.net.URI; 5 | import java.net.URISyntaxException; 6 | 7 | public class FileUtils { 8 | 9 | static public File relativizeFile(File parent, File file) throws URISyntaxException { 10 | // use Uri.relativize 11 | // regard the bugs in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6226081 12 | URI fileUri = file.toURI(); 13 | URI parentUri = parent.toURI(); 14 | // constructor of File only allows absolute uris, therefore convert from string 15 | return new File(parentUri.relativize(fileUri).getPath()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.googlecode.cppcheclipse.parent 8 | com.googlecode.cppcheclipse 9 | 1.1.2-SNAPSHOT 10 | ../com.googlecode.cppcheclipse.parent/pom.xml 11 | 12 | com.googlecode.cppcheclipse.ui 13 | eclipse-plugin 14 | 15 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.googlecode.cppcheclipse.parent 8 | com.googlecode.cppcheclipse 9 | 1.1.2-SNAPSHOT 10 | ../com.googlecode.cppcheclipse.parent/pom.xml 11 | 12 | com.googlecode.cppcheclipse.core 13 | eclipse-plugin 14 | 15 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.googlecode.cppcheclipse.parent 8 | com.googlecode.cppcheclipse 9 | 1.1.2-SNAPSHOT 10 | ../com.googlecode.cppcheclipse.parent/pom.xml 11 | 12 | com.googlecode.cppcheclipse.core.tests 13 | eclipse-test-plugin 14 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.feature/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.googlecode.cppcheclipse.parent 8 | com.googlecode.cppcheclipse 9 | 1.1.2-SNAPSHOT 10 | ../com.googlecode.cppcheclipse.parent/pom.xml 11 | 12 | com.googlecode.cppcheclipse.feature 13 | eclipse-feature 14 | 15 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.googlecode.cppcheclipse.parent 8 | com.googlecode.cppcheclipse 9 | 1.1.2-SNAPSHOT 10 | ../com.googlecode.cppcheclipse.parent/pom.xml 11 | 12 | com.googlecode.cppcheclipse.ui.tests 13 | eclipse-test-plugin 14 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/ResolutionGenerator.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import org.eclipse.core.resources.IMarker; 4 | import org.eclipse.ui.IMarkerResolution; 5 | import org.eclipse.ui.IMarkerResolutionGenerator; 6 | 7 | 8 | public class ResolutionGenerator implements IMarkerResolutionGenerator { 9 | public ResolutionGenerator() { 10 | 11 | } 12 | 13 | public IMarkerResolution[] getResolutions(IMarker marker) { 14 | return new IMarkerResolution[] { 15 | new SuppressProblemInLineResolution(), 16 | new SuppressProblemResolution(), 17 | new SuppressFileResolution(), 18 | new ReportBugResolution(), 19 | new CheckDescriptionResolution() 20 | }; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/core/utils/TestFileUtils.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import java.io.File; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import static org.junit.Assert.assertEquals; 9 | 10 | public class TestFileUtils { 11 | @Before 12 | public void setUp() throws Exception { 13 | } 14 | 15 | @After 16 | public void tearDown() throws Exception { 17 | } 18 | 19 | @Test 20 | public void testRelativize() throws Exception { 21 | File file1 = new File("/abc/def/e f"); 22 | File file2 = new File("/abc/def/e f/g/h i"); 23 | File result = FileUtils.relativizeFile(file1, file2); 24 | assertEquals("g/h i", result.toString()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/core/utils/TestSerializeHelper.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.File; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | public class TestSerializeHelper { 12 | 13 | @Before 14 | public void setUp() throws Exception { 15 | } 16 | 17 | @After 18 | public void tearDown() throws Exception { 19 | } 20 | 21 | @Test 22 | public void testSerializeHelper() throws Exception { 23 | File file1 = new File("/tmp/var/test"); 24 | String serialized = SerializeHelper.toString(file1); 25 | File file2 = (File) SerializeHelper.fromString(serialized); 26 | assertEquals(file1, file2); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/ReportBugResolution.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import org.eclipse.core.resources.IMarker; 4 | import org.eclipse.ui.IMarkerResolution; 5 | 6 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 7 | import com.googlecode.cppcheclipse.ui.Messages; 8 | import com.googlecode.cppcheclipse.ui.Utils; 9 | 10 | public class ReportBugResolution implements IMarkerResolution { 11 | 12 | private static final String REPORT_URL = "http://trac.cppcheck.net/report"; //$NON-NLS-1$ 13 | public String getLabel() { 14 | return Messages.ReportBug_Label; 15 | } 16 | 17 | public void run(IMarker marker) { 18 | try { 19 | Utils.openUrl(REPORT_URL); 20 | } catch (Exception e) { 21 | CppcheclipsePlugin.logError("Could not open bug report page", e); 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/VersionCommand.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | import java.io.IOException; 4 | 5 | import org.eclipse.core.runtime.IProgressMonitor; 6 | 7 | import com.googlecode.cppcheclipse.core.IConsole; 8 | 9 | public class VersionCommand extends AbstractCppcheckCommand { 10 | private static final String[] DEFAULT_ARGUMENTS = {"--version"}; 11 | private static final int TIMEOUT_MS = 5000; 12 | 13 | public VersionCommand(IConsole console, String binaryPath) { 14 | super(console, DEFAULT_ARGUMENTS, TIMEOUT_MS, binaryPath); 15 | } 16 | 17 | public Version run(IProgressMonitor monitor) throws IOException, InterruptedException, ProcessExecutionException { 18 | CppcheckProcessResultHandler resultHandler = runInternal(); 19 | waitForExit(resultHandler, monitor); 20 | return new Version(getOutput()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/AppendagePropertyPage.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.ui.IWorkbenchPropertyPage; 4 | 5 | import com.googlecode.cppcheclipse.core.IPreferenceConstants; 6 | import com.googlecode.cppcheclipse.ui.Messages; 7 | 8 | public class AppendagePropertyPage extends FieldEditorOverlayPage 9 | implements IWorkbenchPropertyPage { 10 | public AppendagePropertyPage() { 11 | super(FLAT, false); 12 | setDescription(Messages.AppendagePropertyPage_Description); 13 | } 14 | 15 | @Override 16 | protected void createFieldEditors() { 17 | AppendageTable list = new AppendageTable(IPreferenceConstants.P_APPENDAGES, Messages.AppendagePropertyPage_AppendageLabel, getFieldEditorParent(), getProject()); 18 | addField(list); 19 | } 20 | 21 | @Override 22 | protected String getPageId() { 23 | return null; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/IProblemReporter.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import org.eclipse.core.resources.IResource; 4 | import org.eclipse.core.runtime.CoreException; 5 | 6 | 7 | public interface IProblemReporter { 8 | 9 | 10 | 11 | /** 12 | * Reports problem in problem view. 13 | * @param problem the problem to report 14 | * @throws CoreException 15 | */ 16 | public abstract void reportProblem(Problem problem) throws CoreException; 17 | 18 | /** 19 | * Deletes all cppcheck markers in the given resource. 20 | * @param resource 21 | * @throws CoreException 22 | */ 23 | public abstract void deleteMarkers(IResource resource, boolean isRecursive) throws CoreException; 24 | 25 | /** 26 | * Deletes all cppcheck markers from the whole workspace 27 | * @throws CoreException 28 | */ 29 | public abstract void deleteAllMarkers() throws CoreException; 30 | 31 | } -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/CheckDescriptionResolution.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import org.eclipse.core.resources.IMarker; 4 | import org.eclipse.ui.IMarkerResolution; 5 | 6 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 7 | import com.googlecode.cppcheclipse.ui.Messages; 8 | import com.googlecode.cppcheclipse.ui.Utils; 9 | 10 | public class CheckDescriptionResolution implements IMarkerResolution { 11 | 12 | private static final String CHECK_DESCRIPTION_URL = "https://sourceforge.net/p/cppcheck/wiki/Home/#checks"; //$NON-NLS-1$ 13 | public String getLabel() { 14 | return Messages.CheckDescriptionResolution_Label; 15 | } 16 | 17 | public void run(IMarker marker) { 18 | try { 19 | Utils.openUrl(CHECK_DESCRIPTION_URL); 20 | } catch (Exception e) { 21 | CppcheclipsePlugin.logError("Could not open check description page", e); 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/SuppressionsPropertyPage.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.ui.IWorkbenchPropertyPage; 4 | 5 | import com.googlecode.cppcheclipse.core.IPreferenceConstants; 6 | import com.googlecode.cppcheclipse.ui.Messages; 7 | 8 | public class SuppressionsPropertyPage extends FieldEditorOverlayPage 9 | implements IWorkbenchPropertyPage { 10 | public SuppressionsPropertyPage() { 11 | super(FLAT, false); 12 | setDescription(Messages.SuppressionsPropertyPage_Description); 13 | } 14 | 15 | @Override 16 | protected void createFieldEditors() { 17 | SuppressionsTable list = new SuppressionsTable(IPreferenceConstants.P_SUPPRESSIONS, Messages.SuppressionsPropertyPage_SuppressionsLabel, getFieldEditorParent(), getProject()); 18 | addField(list); 19 | } 20 | 21 | @Override 22 | protected String getPageId() { 23 | return null; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/ProcessExecutionException.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | public class ProcessExecutionException extends Exception { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = 7085940287202256905L; 9 | 10 | public static ProcessExecutionException newException(String cmdLine, Throwable cause) { 11 | StringBuffer errorMsg = new StringBuffer(); 12 | errorMsg.append("Error executing '").append(cmdLine).append("' due to error: ").append(cause.getLocalizedMessage()); 13 | errorMsg.append(" Maybe more information is available in the console view."); 14 | return new ProcessExecutionException(errorMsg.toString(), cause); 15 | } 16 | 17 | public ProcessExecutionException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | public ProcessExecutionException(String message) { 22 | super(message); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.core.tests-git 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.m2e.core.maven2Nature 31 | org.eclipse.pde.PluginNature 32 | org.eclipse.jdt.core.javanature 33 | 34 | 35 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui.tests/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.ui.tests-git 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.m2e.core.maven2Nature 31 | org.eclipse.pde.PluginNature 32 | org.eclipse.jdt.core.javanature 33 | 34 | 35 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: cppcheclipse UI 4 | Bundle-SymbolicName: com.googlecode.cppcheclipse.ui;singleton:=true 5 | Bundle-Version: 1.1.2.qualifier 6 | Bundle-Activator: com.googlecode.cppcheclipse.ui.Activator 7 | Bundle-Vendor: Konrad Windszus 8 | Require-Bundle: org.eclipse.ui;bundle-version="3.4.0", 9 | org.eclipse.core.runtime;bundle-version="3.4.0", 10 | com.googlecode.cppcheclipse.core;bundle-version="1.0.0", 11 | org.eclipse.core.resources;bundle-version="3.4.0", 12 | org.eclipse.cdt.core;bundle-version="5.0.0", 13 | org.eclipse.ui.editors;bundle-version="3.4.0", 14 | org.eclipse.jface.text;bundle-version="3.4.0", 15 | org.eclipse.cdt.make.core;bundle-version="5.0.0", 16 | org.eclipse.debug.ui 17 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7 18 | Bundle-ActivationPolicy: lazy 19 | Import-Package: org.eclipse.cdt.core.model, 20 | org.eclipse.cdt.core.settings.model, 21 | org.eclipse.core.resources, 22 | org.eclipse.ui, 23 | org.eclipse.ui.console 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: cppcheclipse Core 4 | Bundle-SymbolicName: com.googlecode.cppcheclipse.core;singleton:=true 5 | Bundle-Version: 1.1.2.qualifier 6 | Bundle-Activator: com.googlecode.cppcheclipse.core.CppcheclipsePlugin 7 | Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0", 8 | org.eclipse.ui;bundle-version="3.5.0", 9 | org.eclipse.core.resources;bundle-version="3.5.0", 10 | org.eclipse.core.net;bundle-version="1.2.0", 11 | com.google.guava;bundle-version="12.0.0", 12 | org.apache.commons.codec;bundle-version="1.4.0", 13 | org.apache.commons.io;bundle-version="2.0.1", 14 | org.apache.commons.exec;bundle-version="1.1.0", 15 | org.eclipse.core.variables 16 | Bundle-ActivationPolicy: lazy 17 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7 18 | Export-Package: com.googlecode.cppcheclipse.core, 19 | com.googlecode.cppcheclipse.core.command, 20 | com.googlecode.cppcheclipse.core.utils 21 | Bundle-Vendor: Konrad Windszus 22 | Service-Component: OSGI-INF/HttpClient.xml 23 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/AdvancedSettingsPropertyPage.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.jface.preference.StringFieldEditor; 4 | import org.eclipse.ui.IWorkbenchPropertyPage; 5 | 6 | import com.googlecode.cppcheclipse.core.IPreferenceConstants; 7 | import com.googlecode.cppcheclipse.ui.Messages; 8 | 9 | public class AdvancedSettingsPropertyPage extends FieldEditorOverlayPage 10 | implements IWorkbenchPropertyPage { 11 | 12 | public AdvancedSettingsPropertyPage() { 13 | super(FLAT, false); 14 | setDescription(Messages.AdvancedSettingsPropertyPage_Description); 15 | } 16 | 17 | @Override 18 | protected void createFieldEditors() { 19 | StringFieldEditor advancedArguments = new StringFieldEditor(IPreferenceConstants.P_ADVANCED_ARGUMENTS, Messages.AdvancedSettingsPropertyPage_AdvancedArguments, getFieldEditorParent()); 20 | addField(advancedArguments); 21 | } 22 | 23 | @Override 24 | /** 25 | * not necessary for pure property pages 26 | */ 27 | protected String getPageId() { 28 | return null; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/SuppressProblemResolution.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import java.io.File; 4 | 5 | import org.eclipse.core.resources.IResource; 6 | import org.eclipse.core.runtime.CoreException; 7 | 8 | import com.googlecode.cppcheclipse.core.SuppressionProfile; 9 | import com.googlecode.cppcheclipse.ui.Messages; 10 | 11 | public class SuppressProblemResolution extends SuppressResolution { 12 | 13 | /* 14 | * (non-Javadoc) 15 | * @see com.googlecode.cppcheclipse.ui.marker.SuppressResolution#getLabel() 16 | */ 17 | @Override 18 | public String getLabel() { 19 | return Messages.SuppressProblemResolution_Label; 20 | } 21 | 22 | /* 23 | * (non-Javadoc) 24 | * @see com.googlecode.cppcheclipse.ui.marker.SuppressResolution#suppress(com.googlecode.cppcheclipse.core.SuppressionProfile, org.eclipse.core.resources.IFile, java.lang.String, int) 25 | */ 26 | @Override 27 | protected void suppress(SuppressionProfile profile, IResource resource, File file, 28 | String problemId, int line) throws CoreException { 29 | profile.addProblemSuppression(file, problemId); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/SuppressProblemInLineResolution.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import java.io.File; 4 | 5 | import org.eclipse.core.resources.IResource; 6 | import org.eclipse.core.runtime.CoreException; 7 | 8 | import com.googlecode.cppcheclipse.core.SuppressionProfile; 9 | import com.googlecode.cppcheclipse.ui.Messages; 10 | 11 | public class SuppressProblemInLineResolution extends SuppressResolution { 12 | 13 | /* 14 | * (non-Javadoc) 15 | * @see com.googlecode.cppcheclipse.ui.marker.SuppressResolution#getLabel() 16 | */ 17 | @Override 18 | public String getLabel() { 19 | return Messages.SuppressProblemInLineResolution_Label; 20 | } 21 | 22 | /* 23 | * (non-Javadoc) 24 | * @see com.googlecode.cppcheclipse.ui.marker.SuppressResolution#suppress(com.googlecode.cppcheclipse.core.SuppressionProfile, org.eclipse.core.resources.IFile, java.lang.String, int) 25 | */ 26 | @Override 27 | protected void suppress(SuppressionProfile profile, IResource resource, File file, 28 | String problemId, int line) throws CoreException { 29 | profile.addProblemInLineSuppression(file, problemId, line); 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.ui 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.api.tools.apiAnalysisBuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.m2e.core.maven2Builder 30 | 31 | 32 | 33 | 34 | 35 | org.eclipse.m2e.core.maven2Nature 36 | org.eclipse.pde.PluginNature 37 | org.eclipse.jdt.core.javanature 38 | org.eclipse.pde.api.tools.apiAnalysisNature 39 | 40 | 41 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/SuppressFileResolution.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import java.io.File; 4 | 5 | import org.eclipse.core.resources.IResource; 6 | import org.eclipse.core.runtime.CoreException; 7 | 8 | import com.googlecode.cppcheclipse.core.SuppressionProfile; 9 | import com.googlecode.cppcheclipse.ui.Messages; 10 | 11 | public class SuppressFileResolution extends SuppressResolution { 12 | 13 | /* 14 | * (non-Javadoc) 15 | * @see com.googlecode.cppcheclipse.ui.marker.SuppressResolution#getLabel() 16 | */ 17 | @Override 18 | public String getLabel() { 19 | return Messages.SuppressFileResolution_Label; 20 | } 21 | 22 | /* 23 | * (non-Javadoc) 24 | * @see com.googlecode.cppcheclipse.ui.marker.SuppressResolution#suppress(com.googlecode.cppcheclipse.core.SuppressionProfile, org.eclipse.core.resources.IFile, java.lang.String, int) 25 | */ 26 | @Override 27 | protected void suppress(SuppressionProfile profile, IResource resource, File file, 28 | String problemId, int line) throws CoreException { 29 | new ProblemReporter().deleteMarkers(resource, true); 30 | profile.addFileSuppression(file); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.googlecode.cppcheclipse.core 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.api.tools.apiAnalysisBuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.m2e.core.maven2Builder 30 | 31 | 32 | 33 | 34 | 35 | org.eclipse.m2e.core.maven2Nature 36 | org.eclipse.pde.PluginNature 37 | org.eclipse.jdt.core.javanature 38 | org.eclipse.pde.api.tools.apiAnalysisNature 39 | 40 | 41 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ProgressReporter.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui; 2 | 3 | import org.eclipse.core.runtime.IProgressMonitor; 4 | 5 | import com.googlecode.cppcheclipse.core.IProgressReporter; 6 | 7 | public class ProgressReporter implements IProgressReporter { 8 | 9 | private final IProgressMonitor monitor; 10 | private int reportedProgress; 11 | 12 | public ProgressReporter(IProgressMonitor monitor) { 13 | super(); 14 | this.monitor = monitor; 15 | reportedProgress = 0; 16 | } 17 | 18 | /* 19 | * (non-Javadoc) 20 | * 21 | * @see 22 | * com.googlecode.cppcheclipse.core.IProgressReporter#reportProgress(java 23 | * .lang.String, java.lang.Integer) 24 | */ 25 | public void reportProgress(String currentlyCheckedFilename, 26 | Integer numFilesChecked) { 27 | if (currentlyCheckedFilename != null) { 28 | monitor.subTask(Messages.bind(Messages.ProgressReporter_TaskName, 29 | currentlyCheckedFilename)); 30 | } 31 | if (numFilesChecked != null) { 32 | int workUnits = numFilesChecked - reportedProgress; 33 | if (workUnits > 0) { 34 | monitor.worked(workUnits); 35 | reportedProgress = numFilesChecked; 36 | } 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/core/command/TestVersion.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class TestVersion { 8 | 9 | // compare with issue 47 10 | @Test 11 | public void testDevelopmentVersion() { 12 | String versionString = "cppcheck 1.55 dev"; 13 | Version version = new Version(versionString); 14 | assertEquals(1, version.getMajorVersion()); 15 | assertEquals(55, version.getMinorVersion()); 16 | } 17 | 18 | @Test(expected=IllegalArgumentException.class) 19 | public void testInvalidVersion() { 20 | new Version("1.2.3"); 21 | } 22 | 23 | @Test 24 | public void testReleaseVersion() { 25 | String versionString = "cppcheck 1.55"; 26 | Version version = new Version(versionString); 27 | assertEquals(1, version.getMajorVersion()); 28 | assertEquals(55, version.getMinorVersion()); 29 | } 30 | 31 | @Test 32 | public void testReleaseVersionWithRevision() { 33 | String versionString = "cppcheck 1.2.3"; 34 | Version version = new Version(versionString); 35 | assertEquals(1, version.getMajorVersion()); 36 | assertEquals(2, version.getMinorVersion()); 37 | assertEquals(3, version.getRevision()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/tests/Activator.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.tests; 2 | 3 | import org.eclipse.ui.plugin.AbstractUIPlugin; 4 | import org.osgi.framework.BundleContext; 5 | 6 | /** 7 | * The activator class controls the plug-in life cycle 8 | */ 9 | public class Activator extends AbstractUIPlugin { 10 | 11 | // The plug-in ID 12 | public static final String PLUGIN_ID = "com.googlecode.cppcheclipse.tests"; 13 | 14 | // The shared instance 15 | private static Activator plugin; 16 | 17 | /** 18 | * The constructor 19 | */ 20 | public Activator() { 21 | } 22 | 23 | /* 24 | * (non-Javadoc) 25 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) 26 | */ 27 | public void start(BundleContext context) throws Exception { 28 | super.start(context); 29 | plugin = this; 30 | } 31 | 32 | /* 33 | * (non-Javadoc) 34 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) 35 | */ 36 | public void stop(BundleContext context) throws Exception { 37 | plugin = null; 38 | super.stop(context); 39 | } 40 | 41 | /** 42 | * Returns the shared instance 43 | * 44 | * @return the shared instance 45 | */ 46 | public static Activator getDefault() { 47 | return plugin; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/Activator.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui; 2 | 3 | import org.eclipse.ui.plugin.AbstractUIPlugin; 4 | import org.osgi.framework.BundleContext; 5 | 6 | /** 7 | * The activator class controls the plug-in life cycle 8 | */ 9 | public class Activator extends AbstractUIPlugin { 10 | 11 | // The plug-in ID 12 | public static final String PLUGIN_ID = "com.googlecode.cppcheclipse.ui"; //$NON-NLS-1$ 13 | 14 | // The shared instance 15 | private static Activator plugin; 16 | 17 | /** 18 | * The constructor 19 | */ 20 | public Activator() { 21 | } 22 | 23 | /* 24 | * (non-Javadoc) 25 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) 26 | */ 27 | public void start(BundleContext context) throws Exception { 28 | super.start(context); 29 | plugin = this; 30 | } 31 | 32 | /* 33 | * (non-Javadoc) 34 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) 35 | */ 36 | public void stop(BundleContext context) throws Exception { 37 | plugin = null; 38 | super.stop(context); 39 | } 40 | 41 | /** 42 | * Returns the shared instance 43 | * 44 | * @return the shared instance 45 | */ 46 | public static Activator getDefault() { 47 | return plugin; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/SerializeHelper.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.io.ObjectInputStream; 7 | import java.io.ObjectOutputStream; 8 | import java.io.Serializable; 9 | import org.apache.commons.codec.binary.Base64; 10 | 11 | public class SerializeHelper { 12 | 13 | /** Read the object from Base64 string. 14 | * @throws ClassNotFoundException */ 15 | public static Object fromString(String s) throws IOException, ClassNotFoundException { 16 | byte [] data = new Base64().decode(s); 17 | ObjectInputStream ois = new ObjectInputStream( 18 | new ByteArrayInputStream( data ) ); 19 | Object o = ois.readObject(); 20 | ois.close(); 21 | return o; 22 | } 23 | /** Write the object to a Base64 string. */ 24 | public static String toString(Serializable o) throws IOException { 25 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 26 | ObjectOutputStream oos = new ObjectOutputStream( baos ); 27 | oos.writeObject( o ); 28 | oos.close(); 29 | return new String( Base64.encodeBase64(baos.toByteArray())); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/commands/ClearMarkers.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.commands; 2 | 3 | import org.eclipse.core.resources.IResource; 4 | import org.eclipse.core.runtime.CoreException; 5 | import org.eclipse.core.runtime.IProgressMonitor; 6 | 7 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 8 | import com.googlecode.cppcheclipse.ui.Messages; 9 | import com.googlecode.cppcheclipse.ui.marker.ProblemReporter; 10 | 11 | public class ClearMarkers extends AbstractResourceSelectionJobCommand { 12 | 13 | 14 | private static class ClearMarkersJob extends ResourceSelectionJob { 15 | 16 | private final ProblemReporter reporter; 17 | public ClearMarkersJob(String name) { 18 | super(name); 19 | reporter = new ProblemReporter(); 20 | } 21 | 22 | @Override 23 | protected void runResource(IResource resource, 24 | IProgressMonitor monitor) { 25 | monitor.beginTask("", 1); //$NON-NLS-1$ 26 | try { 27 | reporter.deleteMarkers(resource, true); 28 | } catch (CoreException e) { 29 | CppcheclipsePlugin.showError(Messages.bind( 30 | Messages.ClearMarkers_Error, resource.getName()), 31 | e); 32 | } 33 | monitor.worked(1); 34 | } 35 | 36 | } 37 | 38 | 39 | @Override 40 | ResourceSelectionJob getJob() { 41 | return new ClearMarkersJob(Messages.ClearMarkers_JobName); 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Java CI](https://github.com/kwin/cppcheclipse/workflows/Java%20CI/badge.svg) 2 | 3 | **IMPORTANT:** 4 | This is the original cppcheclipse repository. It is not actively maintained in this repository anymore. 5 | You now find the cppcheclipse source code [here](https://github.com/cppchecksolutions/cppcheclipse). Please report issues and provide pull requests in that repository instead. 6 | 7 | cppcheclipse is an Eclipse plugin which integrates [cppcheck](http://sourceforge.net/projects/cppcheck/) with the [CDT project](https://eclipse.org/cdt/). You can run/configure cppcheck from the Eclipse UI. 8 | 9 | To build the project on the command line it requires maven, Run the following commands: 10 | ```bash 11 | cd com.googlecode.cppcheclipse.parent 12 | mvn clean verify 13 | ``` 14 | It will not increment the version number nor deploy/publish/release the artifact. You can find the built p2 repository now in ../com.googlecode.cppcheclipse.repository/target in zip format. 15 | 16 | **NOTES:** 17 | 18 | * Under Windows the `mvn clean verify` will fail because the unit test paths in unix format. As workaround skip the tests `mvn clean package` should build successfully, but it will not create. 19 | * Maven build will fail if Java 9 is used, while it will work under Java 8. 20 | 21 | 22 | Further information on how to use and install cppcheclipse can be found in the [wiki](https://github.com/kwin/cppcheclipse/wiki). 23 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/PathMacroReplacer.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import org.eclipse.core.runtime.CoreException; 4 | import org.eclipse.core.variables.IStringVariableManager; 5 | import org.eclipse.core.variables.VariablesPlugin; 6 | 7 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 8 | 9 | /** 10 | * This util class is helping replace path containing macros into real path. 11 | * 12 | * Following macros will resolve to: 13 | * ${eclipse_home} to a Eclipse's installation folder. 14 | * ${project_loc} to the folder of a active project. 15 | * ${workspace_loc} to the current open workspace. 16 | * 17 | * https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcpathvars.htm 18 | * 19 | * @author Anton Krug 20 | * 21 | */ 22 | 23 | public class PathMacroReplacer { 24 | 25 | public static String performMacroSubstitution(String input) { 26 | String ret = input; 27 | 28 | IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); 29 | try { 30 | ret = manager.performStringSubstitution(ret, false); 31 | } catch (CoreException e) { 32 | // in case of a issue, keep the path as it is and log error 33 | CppcheclipsePlugin.logError("Path macro subsitution failed", e); //$NON-NLS-1$ 34 | } 35 | 36 | return ret; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/commands/RunCodeAnalysis.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.commands; 2 | 3 | import org.eclipse.core.resources.IResource; 4 | import org.eclipse.core.runtime.CoreException; 5 | import org.eclipse.core.runtime.IProgressMonitor; 6 | 7 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 8 | import com.googlecode.cppcheclipse.ui.Builder; 9 | import com.googlecode.cppcheclipse.ui.Console; 10 | import com.googlecode.cppcheclipse.ui.Messages; 11 | 12 | public class RunCodeAnalysis extends AbstractResourceSelectionJobCommand { 13 | 14 | private static class RunCodeAnalysisJob extends ResourceSelectionJob { 15 | 16 | private final Builder builder; 17 | public RunCodeAnalysisJob(String name) { 18 | super(name); 19 | builder = new Builder(); 20 | } 21 | 22 | @Override 23 | protected void runResource(IResource resource, 24 | IProgressMonitor monitor) { 25 | try { 26 | builder.processResource(resource, monitor); 27 | } catch (CoreException e1) { 28 | CppcheclipsePlugin.showError(Messages.bind( 29 | Messages.RunCodeAnalysis_Error, resource.getName()), 30 | e1); 31 | // show console in case of exceptions 32 | Console.getInstance().show(); 33 | } 34 | } 35 | } 36 | 37 | 38 | @Override 39 | ResourceSelectionJob getJob() { 40 | return new RunCodeAnalysisJob(Messages.RunCodeAnalysis_JobName); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/ProblemsPreferencePage.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.ui.IWorkbench; 4 | import org.eclipse.ui.IWorkbenchPreferencePage; 5 | 6 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 7 | import com.googlecode.cppcheclipse.core.IPreferenceConstants; 8 | import com.googlecode.cppcheclipse.ui.Messages; 9 | 10 | /** 11 | * This class is used for WorkspacePreference as well as for ProjectProperties 12 | * @author Konrad Windszus 13 | * 14 | */ 15 | public class ProblemsPreferencePage extends FieldEditorOverlayPage implements 16 | IWorkbenchPreferencePage { 17 | 18 | 19 | public ProblemsPreferencePage() { 20 | super(GRID, true); 21 | // this is overridden in case of project properties 22 | setPreferenceStore(CppcheclipsePlugin.getWorkspacePreferenceStore()); 23 | setDescription(Messages.ProblemsPreferencePage_Description); 24 | } 25 | 26 | @Override 27 | protected void createFieldEditors() { 28 | 29 | ProblemsTreeEditor problemsTreeEditor = new ProblemsTreeEditor( 30 | getFieldEditorParent()); 31 | addField(problemsTreeEditor); 32 | } 33 | 34 | public void init(IWorkbench workbench) { 35 | } 36 | 37 | /* 38 | * (non-Javadoc) 39 | * @see com.googlecode.cppcheclipse.ui.FieldEditorOverlayPage#getPageId() 40 | */ 41 | @Override 42 | protected String getPageId() { 43 | return IPreferenceConstants.PROBLEMS_PAGE_ID; 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/eclipse3.7cdtp2.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/BuildPropertyPage.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.jface.preference.BooleanFieldEditor; 4 | import org.eclipse.ui.IWorkbenchPropertyPage; 5 | 6 | import com.googlecode.cppcheclipse.core.IPreferenceConstants; 7 | import com.googlecode.cppcheclipse.ui.Messages; 8 | import com.googlecode.cppcheclipse.ui.Nature; 9 | 10 | public class BuildPropertyPage extends FieldEditorOverlayPage implements 11 | IWorkbenchPropertyPage { 12 | private BooleanFieldEditor runOnBuild; 13 | 14 | public BuildPropertyPage() { 15 | super(FLAT, false); 16 | // must set preference store later 17 | runOnBuild = null; 18 | setDescription(Messages.BuildPropertyPage_Description); 19 | } 20 | 21 | /* 22 | * (non-Javadoc) 23 | * 24 | * @see 25 | * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors 26 | * () 27 | */ 28 | @Override 29 | protected void createFieldEditors() { 30 | runOnBuild = new BooleanFieldEditor(IPreferenceConstants.P_RUN_ON_BUILD, 31 | Messages.BuildPropertyPage_RunOnBuild, getFieldEditorParent()); 32 | addField(runOnBuild); 33 | } 34 | 35 | @Override 36 | public boolean performOk() { 37 | boolean result = super.performOk(); 38 | if (result) { 39 | if (runOnBuild != null) { 40 | Nature.toggleNature(getProject(), runOnBuild.getBooleanValue()); 41 | } 42 | } 43 | return result; 44 | } 45 | 46 | @Override 47 | protected String getPageId() { 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/DependentBooleanFieldEditor.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.jface.preference.BooleanFieldEditor; 4 | import org.eclipse.swt.widgets.Composite; 5 | 6 | public class DependentBooleanFieldEditor extends BooleanFieldEditor { 7 | 8 | private final BooleanFieldEditor dependencyFieldEditor; 9 | 10 | public DependentBooleanFieldEditor(BooleanFieldEditor dependencyFieldEditor) { 11 | super(); 12 | this.dependencyFieldEditor = dependencyFieldEditor; 13 | } 14 | 15 | public DependentBooleanFieldEditor(BooleanFieldEditor dependencyFieldEditor, String name, String label, 16 | Composite parent) { 17 | super(name, label, parent); 18 | this.dependencyFieldEditor = dependencyFieldEditor; 19 | } 20 | 21 | public DependentBooleanFieldEditor(BooleanFieldEditor dependencyFieldEditor, String name, String labelText, 22 | int style, Composite parent) { 23 | super(name, labelText, style, parent); 24 | this.dependencyFieldEditor = dependencyFieldEditor; 25 | } 26 | 27 | @Override 28 | public void setEnabled(boolean enabled, Composite parent) { 29 | // only enable this field if dependency field editor is not enabled 30 | if (enabled) { 31 | // although the getBooleanValue is not necessary set for initialization (depends on order) 32 | // this is necessary for switching from workspace settings to project settings 33 | enabled = !dependencyFieldEditor.getBooleanValue(); 34 | } 35 | super.setEnabled(enabled, parent); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/eclipse3.6cdtp2.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/eclipse3.8cdtp2.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/eclipse4.2cdtp2.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/eclipse4.3cdtp2.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.target/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | com.googlecode.cppcheclipse.parent 7 | com.googlecode.cppcheclipse 8 | 1.1.2-SNAPSHOT 9 | ../com.googlecode.cppcheclipse.parent/pom.xml 10 | 11 | 12 | com.googlecode.cppcheclipse.target 13 | pom 14 | 15 | 16 | 17 | 18 | org.codehaus.mojo 19 | build-helper-maven-plugin 20 | 1.3 21 | 22 | 23 | attach-artifacts 24 | package 25 | 26 | attach-artifact 27 | 28 | 29 | 30 | 31 | eclipse3.6cdtp2.target 32 | target 33 | eclipse3.6cdtp2 34 | 35 | 36 | eclipse4.3cdtp2.target 37 | target 38 | eclipse4.3cdtp2 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/SuppressResolution.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import java.io.File; 4 | 5 | import org.eclipse.core.resources.IMarker; 6 | import org.eclipse.core.resources.IProject; 7 | import org.eclipse.core.resources.IResource; 8 | import org.eclipse.core.runtime.CoreException; 9 | import org.eclipse.ui.IMarkerResolution; 10 | 11 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 12 | import com.googlecode.cppcheclipse.core.SuppressionProfile; 13 | 14 | public abstract class SuppressResolution implements IMarkerResolution { 15 | 16 | public abstract String getLabel(); 17 | 18 | public void run(IMarker marker) { 19 | try { 20 | IResource resource = (IResource)marker.getResource(); 21 | IProject project = resource.getProject(); 22 | String problemId = marker.getAttribute(ProblemReporter.ATTRIBUTE_ID, ""); //$NON-NLS-1$ 23 | int line = marker.getAttribute(ProblemReporter.ATTRIBUTE_ORIGINAL_LINE_NUMBER, 0); 24 | File file = new File(marker.getAttribute(ProblemReporter.ATTRIBUTE_FILE, "")); //$NON-NLS-1$ 25 | marker.delete(); 26 | SuppressionProfile profile = new SuppressionProfile(CppcheclipsePlugin.getProjectPreferenceStore(project), project); 27 | suppress(profile, resource, file, problemId, line); 28 | profile.save(); 29 | } 30 | catch (Exception e) { 31 | CppcheclipsePlugin.logError("Could not save suppression", e); 32 | } 33 | } 34 | 35 | protected abstract void suppress(SuppressionProfile profile, IResource resource, File file, String problemId, int line) throws CoreException; 36 | } 37 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/ProblemSeverity.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import org.eclipse.core.resources.IMarker; 4 | 5 | public enum ProblemSeverity { 6 | Info(IMarker.SEVERITY_INFO), Warning(IMarker.SEVERITY_WARNING), Error( 7 | IMarker.SEVERITY_ERROR); 8 | private int value; 9 | 10 | private ProblemSeverity(int value) { 11 | this.value = value; 12 | } 13 | 14 | public int intValue() { 15 | return value; 16 | } 17 | 18 | public static String[] stringValues() { 19 | ProblemSeverity[] values = values(); 20 | String[] svalues = new String[values.length]; 21 | for (int i = 0; i < values.length; i++) { 22 | ProblemSeverity sev = values[i]; 23 | svalues[i] = sev.toString(); 24 | } 25 | return svalues; 26 | } 27 | 28 | // creates default problem severity from cppcheck severity (here called category) 29 | public static ProblemSeverity fromCategory(String category) { 30 | ProblemSeverity severity = ProblemSeverity.Error; 31 | if ("error".equals(category)) { 32 | severity = ProblemSeverity.Error; 33 | } else if ("style".equals(category)) { 34 | severity = ProblemSeverity.Warning; 35 | } else if ("warning".equals(category)) { 36 | severity = ProblemSeverity.Warning; 37 | } else if ("information".equals(category)) { 38 | severity = ProblemSeverity.Info; 39 | } else if ("performance".equals(category)) { 40 | severity = ProblemSeverity.Info; 41 | } else if ("portability".equals(category)) { 42 | severity = ProblemSeverity.Info; 43 | } 44 | else { 45 | CppcheclipsePlugin.logInfo("Unknown severity detected: " + category); 46 | } 47 | return severity; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/removeFromBintray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # remove p2 metadata artifacts from bintray remote path 3 | #Sample Usage: removeFromBintray.sh apikey remotePath 4 | API=https://api.bintray.com 5 | 6 | BINTRAY_API_KEY=$1 7 | PATH_TO_REPOSITORY=$2 8 | 9 | BINTRAY_USER=kwin 10 | BINTRAY_REPO=p2 11 | BINTRAY_ORGANISATION=cppcheclipse 12 | 13 | function main() { 14 | remove_p2_metadata 15 | } 16 | 17 | function remove_p2_metadata() { 18 | echo "${BINTRAY_USER}" 19 | echo "${BINTRAY_API_KEY}" 20 | echo "${BINTRAY_REPO}" 21 | echo "${PCK_NAME}" 22 | echo "${PCK_VERSION}" 23 | echo "${PATH_TO_REPOSITORY}" 24 | 25 | 26 | echo "Removing metadata content.jar..." 27 | curl -X DELETE -u${BINTRAY_USER}:${BINTRAY_API_KEY} "https://api.bintray.com/content/${BINTRAY_ORGANISATION}/${BINTRAY_REPO}/${PATH_TO_REPOSITORY}/content.jar" 28 | echo "" 29 | echo "Removing metadata artifacts.jar..." 30 | curl -X DELETE -u${BINTRAY_USER}:${BINTRAY_API_KEY} "https://api.bintray.com/content/${BINTRAY_ORGANISATION}/${BINTRAY_REPO}/${PATH_TO_REPOSITORY}/artifacts.jar" 31 | echo "" 32 | echo "Removing metadata compositeContent.xml..." 33 | curl -X DELETE -u${BINTRAY_USER}:${BINTRAY_API_KEY} "https://api.bintray.com/content/${BINTRAY_ORGANISATION}/${BINTRAY_REPO}/${PATH_TO_REPOSITORY}/compositeContent.xml" 34 | echo "" 35 | echo "Removing metadata compositeArtifacts.xml..." 36 | curl -X DELETE -u${BINTRAY_USER}:${BINTRAY_API_KEY} "https://api.bintray.com/content/${BINTRAY_ORGANISATION}/${BINTRAY_REPO}/${PATH_TO_REPOSITORY}/compositeArtifacts.xml" 37 | echo "" 38 | echo "Removing metadata p2.index..." 39 | curl -X DELETE -u${BINTRAY_USER}:${BINTRAY_API_KEY} "https://api.bintray.com/content/${BINTRAY_ORGANISATION}/${BINTRAY_REPO}/${PATH_TO_REPOSITORY}/p2.index" 40 | echo "" 41 | 42 | } 43 | 44 | 45 | 46 | main "$@" -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/core/SuppressionProfileTest.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.File; 6 | 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import com.googlecode.cppcheclipse.tests.MockPreferenceStore; 11 | 12 | public class SuppressionProfileTest { 13 | 14 | private SuppressionProfile profile; 15 | 16 | @Before 17 | public void setup() { 18 | profile = new SuppressionProfile(new MockPreferenceStore(), null); 19 | } 20 | 21 | @Test 22 | public void testFileSuppression() { 23 | File file = new File("/test/testfile"); 24 | profile.addFileSuppression(file); 25 | assertTrue(profile.isFileSuppressed(file)); 26 | } 27 | 28 | @Test 29 | public void testFolderSuppression() { 30 | File file = new File("/test/testfolder"); 31 | profile.addFileSuppression(file); 32 | assertTrue(profile.isFileSuppressed(new File("/test/testfolder/testfile"))); 33 | profile.addFileSuppression(file); 34 | assertFalse(profile.isFileSuppressed(new File("/test/testfolder2/testfile"))); 35 | } 36 | 37 | @Test 38 | public void testLineSuppression() { 39 | File file = new File("/test/testfile"); 40 | profile.addProblemInLineSuppression(file, "id1", 12); 41 | assertTrue(profile.isProblemInLineSuppressed(file, "id1", 12)); 42 | } 43 | 44 | @Test 45 | public void testProblemSuppression() { 46 | File file = new File("/test/testfile"); 47 | profile.addProblemSuppression(file, "id1"); 48 | assertTrue(profile.isProblemInLineSuppressed(file, "id1", 12)); 49 | } 50 | 51 | @Test 52 | public void testProblemSuppressionForSuppressedFile() { 53 | File file = new File("/test/testfolder"); 54 | profile.addFileSuppression(file); 55 | assertTrue(profile.isProblemInLineSuppressed(new File("/test/testfolder"), "id1", 12)); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/commands/ResourceSelectionJob.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.commands; 2 | 3 | import java.util.Iterator; 4 | 5 | import org.eclipse.core.resources.IResource; 6 | import org.eclipse.core.runtime.IAdaptable; 7 | import org.eclipse.core.runtime.IProgressMonitor; 8 | import org.eclipse.core.runtime.IStatus; 9 | import org.eclipse.core.runtime.Status; 10 | import org.eclipse.core.runtime.SubProgressMonitor; 11 | import org.eclipse.core.runtime.jobs.Job; 12 | import org.eclipse.jface.viewers.IStructuredSelection; 13 | 14 | public abstract class ResourceSelectionJob extends Job { 15 | 16 | public ResourceSelectionJob(String name) { 17 | super(name); 18 | } 19 | 20 | static IResource getIResource(Object element) { 21 | // Adapt the first element to a file. 22 | if (!(element instanceof IAdaptable)) 23 | return null; 24 | IResource res = (IResource) ((IAdaptable) element) 25 | .getAdapter(IResource.class); 26 | return res; 27 | } 28 | 29 | @Override 30 | protected IStatus run(IProgressMonitor monitor) { 31 | IStructuredSelection selection = (IStructuredSelection) getProperty(AbstractResourceSelectionJobCommand.SELECTION_PROPERTY); 32 | 33 | // progress monitor has as many steps as selected files 34 | int count = selection.size(); 35 | monitor.beginTask(getName(), count); 36 | if (monitor.isCanceled()) 37 | return Status.CANCEL_STATUS; 38 | 39 | for (Iterator iterator = selection.iterator(); iterator.hasNext();) { 40 | IResource res = getIResource(iterator.next()); 41 | if (res == null) 42 | continue; 43 | 44 | runResource(res, new SubProgressMonitor(monitor, 1)); 45 | 46 | if (monitor.isCanceled()) 47 | return Status.CANCEL_STATUS; 48 | 49 | } 50 | return Status.OK_STATUS; 51 | } 52 | 53 | abstract protected void runResource(IResource resource, IProgressMonitor monitor); 54 | } 55 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/core/utils/TestLineFilterOutputStream.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | 4 | import java.io.ByteArrayInputStream; 5 | import java.io.ByteArrayOutputStream; 6 | 7 | import org.apache.commons.io.IOUtils; 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import static org.junit.Assert.assertEquals; 12 | 13 | public class TestLineFilterOutputStream { 14 | 15 | @Before 16 | public void setUp() throws Exception { 17 | } 18 | 19 | @After 20 | public void tearDown() throws Exception { 21 | } 22 | 23 | @Test 24 | public void testLineFilterOutputStream() throws Exception { 25 | String lines = "Line1\n"; 26 | lines += "Line2"; 27 | ByteArrayInputStream input = new ByteArrayInputStream(lines.getBytes("ASCII")); 28 | ByteArrayOutputStream output = new ByteArrayOutputStream(); 29 | LineFilterOutputStream lfOutput = new LineFilterOutputStream(output, "ASCII"); 30 | IOUtils.copy(input, lfOutput); 31 | 32 | assertEquals("Line1\n", output.toString("ASCII")); 33 | lfOutput.close(); 34 | 35 | assertEquals(lines, output.toString("ASCII")); 36 | } 37 | 38 | /** 39 | * Make sure that even unwanted line do not lead to invalid XML (due to bugs in the XML) 40 | * @throws Exception 41 | */ 42 | @Test 43 | public void testLineFilterOutputStreamWithBlacklist() throws Exception { 44 | String lines = "Line1\n"; 45 | lines += "Line2\n"; 46 | lines += "cppcheck: No C or C++ source files found.\n"; 47 | ByteArrayInputStream input = new ByteArrayInputStream(lines.getBytes("ASCII")); 48 | ByteArrayOutputStream output = new ByteArrayOutputStream(); 49 | LineFilterOutputStream lfOutput = new LineFilterOutputStream(output, "ASCII"); 50 | lfOutput.addBlacklistPattern("^Line2.*\\s*"); 51 | lfOutput.addBlacklistPattern("^cppcheck: No C or C\\+\\+ source files found\\..*\\s*"); 52 | IOUtils.copy(input, lfOutput); 53 | lfOutput.close(); 54 | assertEquals("Line1\n", output.toString("ASCII")); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/UpdateCheckCommand.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.net.URISyntaxException; 8 | import java.net.URL; 9 | 10 | import org.eclipse.core.runtime.IProgressMonitor; 11 | 12 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 13 | import com.googlecode.cppcheclipse.core.IConsole; 14 | import com.googlecode.cppcheclipse.core.utils.IHttpClientService; 15 | 16 | public class UpdateCheckCommand { 17 | 18 | private static final String UPDATE_URL = "http://cppcheck.sourceforge.net/version.txt"; 19 | 20 | public UpdateCheckCommand() { 21 | 22 | } 23 | 24 | private Version getNewVersion() throws IOException, URISyntaxException { 25 | IHttpClientService client = CppcheclipsePlugin.getHttpClientService(); 26 | InputStream is = client.executeGetRequest(new URL(UPDATE_URL)); 27 | BufferedReader rd = new BufferedReader(new InputStreamReader(is)); 28 | String line = rd.readLine(); 29 | rd.close(); 30 | if (line == null) { 31 | throw new IOException("Empty response"); 32 | } 33 | return new Version(line); 34 | } 35 | 36 | private Version getCurrentVersion(IProgressMonitor monitor, IConsole console, String binaryPath) throws IOException, InterruptedException, ProcessExecutionException { 37 | VersionCommand command = new VersionCommand(console, binaryPath); 38 | return command.run(monitor); 39 | } 40 | 41 | /** 42 | * 43 | * @return version data of the new available version or null if no newer version available 44 | * @throws IOException 45 | * @throws InterruptedException 46 | * @throws ProcessExecutionException 47 | * @throws URISyntaxException 48 | */ 49 | public Version run(IProgressMonitor monitor, IConsole console, String binaryPath) throws IOException, InterruptedException, ProcessExecutionException, URISyntaxException { 50 | Version newVersion = getNewVersion(); 51 | Version currentVersion = getCurrentVersion(monitor, console, binaryPath); 52 | if (newVersion.isGreaterThan(currentVersion)) 53 | return newVersion; 54 | return null; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Appendages.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.Iterator; 6 | import java.util.LinkedList; 7 | import java.util.List; 8 | 9 | import org.eclipse.jface.preference.IPreferenceStore; 10 | 11 | import com.google.common.base.Joiner; 12 | import com.google.common.base.Splitter; 13 | import com.googlecode.cppcheclipse.core.utils.SerializeHelper; 14 | 15 | public class Appendages implements TableModel { 16 | private final IPreferenceStore preferenceStore; 17 | private static final String DELIMITER = ";"; // something which does not 18 | // occur within base64 19 | // encoding 20 | private final List files; 21 | 22 | public Appendages(IPreferenceStore preferenceStore) { 23 | this.preferenceStore = preferenceStore; 24 | files = new LinkedList(); 25 | load(); 26 | } 27 | 28 | private void load() { 29 | Iterable values = Splitter 30 | .on(DELIMITER) 31 | .omitEmptyStrings() 32 | .split(preferenceStore 33 | .getString(IPreferenceConstants.P_APPENDAGES)); 34 | for (String file : values) { 35 | try { 36 | files.add((File) SerializeHelper.fromString(file)); 37 | } catch (Exception e) { 38 | CppcheclipsePlugin.logWarning( 39 | "Error reading filename of appendages. Stored appendage file '" 40 | + file + "'", e); 41 | } 42 | } 43 | } 44 | 45 | public void save() throws IOException { 46 | List values = new LinkedList(); 47 | // serialize files 48 | for (File file : files) { 49 | values.add(SerializeHelper.toString(file)); 50 | } 51 | preferenceStore.setValue(IPreferenceConstants.P_APPENDAGES, 52 | Joiner.on(DELIMITER).join(values)); 53 | } 54 | 55 | public void removeAll() { 56 | files.clear(); 57 | } 58 | 59 | public void add(File file) { 60 | files.add(file); 61 | } 62 | 63 | public void remove(File file) { 64 | files.remove(file); 65 | } 66 | 67 | public Iterator iterator() { 68 | return files.iterator(); 69 | } 70 | 71 | public boolean isEmpty() { 72 | return files.isEmpty(); 73 | } 74 | 75 | public File[] toArray() { 76 | return files.toArray(new File[files.size()]); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Symbol.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.IOException; 4 | import java.util.StringTokenizer; 5 | 6 | public class Symbol { 7 | 8 | private final static String DELIMITER = "="; 9 | 10 | private String name; 11 | private String value; 12 | private final boolean isCDTDefined; 13 | private final boolean isSystemDefined; 14 | 15 | public Symbol(String name, String value, boolean isCDTDefined, 16 | boolean isSystemDefined) { 17 | super(); 18 | this.name = name; 19 | this.value = value; 20 | this.isCDTDefined = isCDTDefined; 21 | this.isSystemDefined = isSystemDefined; 22 | } 23 | 24 | public Symbol(String name, String value) { 25 | this(name, value, false, false); 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public void setValue(String value) { 41 | this.value = value; 42 | } 43 | 44 | /** 45 | * returns the symbol in the form "-D{= 0) { 52 | result.append("=").append(value); 53 | } 54 | return result.toString(); 55 | } 56 | 57 | public boolean isCDTDefined() { 58 | return isCDTDefined; 59 | } 60 | 61 | public boolean isSystemDefined() { 62 | return isSystemDefined; 63 | } 64 | 65 | public String serialize() throws IOException { 66 | // only serialize non system defined symbols 67 | if (isCDTDefined) { 68 | throw new IOException("CDT-defined symbols can't be serialized"); 69 | } 70 | 71 | StringBuffer serialization = new StringBuffer(); 72 | // serialize in a platform-portable way 73 | serialization.append(name).append(DELIMITER).append(value); 74 | return serialization.toString(); 75 | } 76 | 77 | public static Symbol deserialize(String serialization) throws IOException, 78 | ClassNotFoundException { 79 | StringTokenizer tokenizer = new StringTokenizer(serialization, 80 | DELIMITER); 81 | String name = tokenizer.nextToken(); 82 | String value = tokenizer.nextToken(); 83 | return new Symbol(name, value); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/PatternSearch.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | /** 4 | * Search the data byte array for the first occurrence 5 | * of the byte array pattern (Knuth-Morris-Pratt Pattern) 6 | */ 7 | public class PatternSearch { 8 | private static final byte[] LINEBREAK_PATTERN = { '\n'}; 9 | 10 | private final int[] failure; 11 | private final byte[] pattern; 12 | 13 | public static PatternSearch getLinebreakPatternSearch() { 14 | return new PatternSearch(LINEBREAK_PATTERN); 15 | } 16 | 17 | public PatternSearch(byte[] pattern) { 18 | this.pattern = pattern; 19 | failure = computeFailure(pattern); 20 | } 21 | 22 | public int indexAfter(byte[] data) { 23 | return indexAfter(data, 0); 24 | } 25 | 26 | public int indexAfter(byte[] data, int startPosition) { 27 | int result = indexOf(data, startPosition); 28 | if (result == -1) { 29 | return result; 30 | } 31 | return result + pattern.length; 32 | } 33 | 34 | public int indexOf(byte[] data) { 35 | return indexOf(data, 0); 36 | } 37 | 38 | /** 39 | * Search the data byte array for the first occurrence 40 | * of the byte array pattern 41 | */ 42 | public int indexOf(byte[] data, int startPosition) { 43 | int j = 0; 44 | 45 | for (int i = startPosition; i < data.length; i++) { 46 | while (j > 0 && pattern[j] != data[i]) { 47 | j = failure[j - 1]; 48 | } 49 | if (pattern[j] == data[i]) { 50 | j++; 51 | } 52 | if (j == pattern.length) { 53 | return i - pattern.length + 1; 54 | } 55 | } 56 | return -1; 57 | } 58 | 59 | /** 60 | * Computes the failure function using a boot-strapping process, 61 | * where the pattern is matched against itself. 62 | */ 63 | private static int[] computeFailure(byte[] pattern) { 64 | int[] failure = new int[pattern.length]; 65 | 66 | int j = 0; 67 | for (int i = 1; i < pattern.length; i++) { 68 | while (j>0 && pattern[j] != pattern[i]) { 69 | j = failure[j - 1]; 70 | } 71 | if (pattern[j] == pattern[i]) { 72 | j++; 73 | } 74 | failure[i] = j; 75 | } 76 | 77 | return failure; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/PreferenceInitializer.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 4 | import org.eclipse.jface.preference.IPreferenceStore; 5 | 6 | 7 | /** 8 | * Class used to initialize default preference values. 9 | */ 10 | public class PreferenceInitializer extends AbstractPreferenceInitializer { 11 | 12 | /* 13 | * (non-Javadoc) 14 | * 15 | * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() 16 | */ 17 | public void initializeDefaultPreferences() { 18 | // only initialize workspace preferences (project preferences will get that too, since they inherit the values) 19 | IPreferenceStore store = CppcheclipsePlugin.getWorkspacePreferenceStore(); 20 | initializeBinaryPathPreferencesDefault(CppcheclipsePlugin.getConfigurationPreferenceStore()); 21 | initializeSettingsDefault(store); 22 | initializeProblemsDefault(store); 23 | } 24 | 25 | private static void initializeSettingsDefault(IPreferenceStore store) { 26 | store.setDefault(IPreferenceConstants.P_CHECK_ALL, false); 27 | store.setDefault(IPreferenceConstants.P_CHECK_STYLE, false); 28 | store.setDefault(IPreferenceConstants.P_CHECK_VERBOSE, false); 29 | store.setDefault(IPreferenceConstants.P_CHECK_FORCE, false); 30 | store.setDefault(IPreferenceConstants.P_CHECK_DEBUG, false); 31 | store.setDefault(IPreferenceConstants.P_USE_INLINE_SUPPRESSIONS, false); 32 | store.setDefault(IPreferenceConstants.P_CHECK_FORCE, false); 33 | store.setDefault(IPreferenceConstants.P_CHECK_UNUSED_FUNCTIONS, false); 34 | store.setDefault(IPreferenceConstants.P_FOLLOW_SYSTEM_INCLUDES, false); 35 | store.setDefault(IPreferenceConstants.P_FOLLOW_USER_INCLUDES, false); 36 | store.setDefault(IPreferenceConstants.P_NUMBER_OF_THREADS, 1); 37 | } 38 | 39 | private static void initializeProblemsDefault(IPreferenceStore store) { 40 | 41 | } 42 | 43 | public static void initializePropertiesDefault(IPreferenceStore store) { 44 | store.setDefault(IPreferenceConstants.P_ADVANCED_ARGUMENTS, ""); 45 | store.setDefault(IPreferenceConstants.P_RUN_ON_BUILD, false); 46 | store.setDefault(IPreferenceConstants.PROBLEMS_PAGE_ID + IPreferenceConstants.P_USE_PARENT_SUFFIX, true); 47 | store.setDefault(IPreferenceConstants.SETTINGS_PAGE_ID + IPreferenceConstants.P_USE_PARENT_SUFFIX, true); 48 | 49 | initializeSettingsDefault(store); 50 | initializeProblemsDefault(store); 51 | } 52 | 53 | private static void initializeBinaryPathPreferencesDefault(IPreferenceStore store) { 54 | store.setDefault(IPreferenceConstants.P_AUTOMATIC_UPDATE_CHECK_INTERVAL, "weekly"); 55 | store.setDefault(IPreferenceConstants.P_USE_AUTOMATIC_UPDATE_CHECK, true); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/commands/AbstractResourceSelectionJobCommand.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.commands; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import org.eclipse.core.commands.AbstractHandler; 7 | import org.eclipse.core.commands.ExecutionEvent; 8 | import org.eclipse.core.commands.ExecutionException; 9 | import org.eclipse.core.resources.IFile; 10 | import org.eclipse.core.runtime.QualifiedName; 11 | import org.eclipse.jface.viewers.ISelection; 12 | import org.eclipse.jface.viewers.IStructuredSelection; 13 | import org.eclipse.jface.viewers.StructuredSelection; 14 | import org.eclipse.ui.IEditorInput; 15 | import org.eclipse.ui.IEditorPart; 16 | import org.eclipse.ui.IFileEditorInput; 17 | import org.eclipse.ui.handlers.HandlerUtil; 18 | 19 | public abstract class AbstractResourceSelectionJobCommand extends AbstractHandler { 20 | 21 | static final QualifiedName SELECTION_PROPERTY = new QualifiedName( 22 | "com.googlecode.cppcheclipse", "JobSelection"); //$NON-NLS-1$ //$NON-NLS-2$ 23 | 24 | private IStructuredSelection getEditorFileSelection(IEditorPart editor) { 25 | if (editor == null) { 26 | return null; 27 | } 28 | IEditorInput input = editor.getEditorInput(); 29 | if (input == null) { 30 | return null; 31 | } 32 | 33 | IFileEditorInput fileInput = (IFileEditorInput) input 34 | .getAdapter(IFileEditorInput.class); 35 | if (fileInput == null) { 36 | return null; 37 | } 38 | List fileList = new LinkedList(); 39 | fileList.add(fileInput.getFile()); 40 | return new StructuredSelection(fileList); 41 | } 42 | 43 | /* 44 | * (non-Javadoc) 45 | * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) 46 | */ 47 | public Object execute(ExecutionEvent event) throws ExecutionException { 48 | // get selection 49 | ISelection selection = HandlerUtil.getCurrentSelection(event); 50 | IStructuredSelection structuredSelection; 51 | if (!(selection instanceof IStructuredSelection)) { 52 | structuredSelection = getEditorFileSelection(HandlerUtil 53 | .getActiveEditor(event)); 54 | 55 | } else { 56 | // maybe this is a structured selection which does not adapt to an 57 | // IResorce 58 | structuredSelection = (IStructuredSelection) selection; 59 | Object firstElement = structuredSelection.getFirstElement(); 60 | // in that case, try to get the file via the current editor 61 | if (ResourceSelectionJob.getIResource(firstElement) == null) { 62 | structuredSelection = getEditorFileSelection(HandlerUtil.getActiveEditor(event)); 63 | } 64 | } 65 | 66 | if (structuredSelection == null) { 67 | return null; 68 | } 69 | 70 | ResourceSelectionJob job = getJob(); 71 | job.setProperty(SELECTION_PROPERTY, structuredSelection); 72 | job.setUser(true); 73 | job.schedule(); 74 | 75 | return null; 76 | } 77 | 78 | abstract ResourceSelectionJob getJob(); 79 | } 80 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core.tests/src/com/googlecode/cppcheclipse/core/command/TestCppcheckCommand.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.File; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import com.googlecode.cppcheclipse.core.Problem; 12 | 13 | public class TestCppcheckCommand { 14 | 15 | @Before 16 | public void setUp() throws Exception { 17 | } 18 | 19 | @After 20 | public void tearDown() throws Exception { 21 | } 22 | 23 | @Test 24 | public void testParseResultLines() throws Exception { 25 | /** 26 | * line should have the following format 27 | * ;;;; 28 | */ 29 | 30 | // we must use absolute file names here, otherwise NPE due to project = null 31 | String line1 = "/var/tmp/file1.cpp;112;error;08;This is a test message; with a semicolon"; 32 | String line2 = "/var/tmp/file2.cpp;7;error;112;Error message2"; 33 | Problem problem1 = CppcheckCommand.parseResult(line1, null); 34 | 35 | assertProblem(problem1, new File("/var/tmp/file1.cpp"), 112, "error", "08", "This is a test message; with a semicolon" ); 36 | 37 | Problem problem2 = CppcheckCommand.parseResult(line2, null); 38 | assertProblem(problem2, new File("/var/tmp/file2.cpp"), 7, "error", "112", "Error message2"); 39 | 40 | String line3 = ";;information;missingInclude;Cppcheck cannot find all the include files (use --check-config for details)"; 41 | Problem problem3 = CppcheckCommand.parseResult(line3, null); 42 | assertProblem(problem3, null, -1, "information", "missingInclude", "Cppcheck cannot find all the include files (use --check-config for details)"); 43 | 44 | String line4="nofile;0;information;missingInclude;Cppcheck cannot find all the include files (use --check-config for details)"; 45 | Problem problem4 = CppcheckCommand.parseResult(line4, null); 46 | assertProblem(problem4, null, -1, "information", "missingInclude", "Cppcheck cannot find all the include files (use --check-config for details)"); 47 | } 48 | 49 | private void assertProblem(Problem problem, File file, int line, String category, String id, String message) { 50 | assertEquals(id, problem.getId()); 51 | assertEquals(file, problem.getFile()); 52 | assertEquals(line, problem.getLineNumber()); 53 | assertEquals(category, problem.getCategory()); 54 | assertEquals(id, problem.getId()); 55 | assertEquals(message, problem.getMessage()); 56 | } 57 | 58 | @Test 59 | public void testParseFilename() throws Exception { 60 | String line = "Checking src/bug 10.cpp..."; 61 | String filename = CppcheckCommand.parseFilename(line); 62 | 63 | assertEquals("src/bug 10.cpp", filename); 64 | } 65 | 66 | @Test 67 | public void testParseProgress() throws Exception { 68 | String line = "4/120 files checked 100% done"; 69 | Integer fileNumber = CppcheckCommand.parseProgress(line); 70 | 71 | assertEquals(new Integer(4), fileNumber); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/IPreferenceConstants.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | /** 4 | * Constant definitions for plug-in preferences 5 | */ 6 | public interface IPreferenceConstants { 7 | public static final String P_RUN_ON_BUILD = "runOnBuild"; 8 | public static final String P_PROBLEMS = "problems"; 9 | public static final String P_USE_PARENT_SUFFIX = "_useParentScope"; 10 | public static final String P_BINARY_PATH = "binaryPath"; 11 | public static final String P_CHECK_STYLE = "checkStyle"; 12 | public static final String P_CHECK_ALL = "checkAllIssues"; 13 | public static final String P_CHECK_PERFORMANCE = "checkPerformance"; 14 | public static final String P_CHECK_PORTABILITY = "checkPortability"; 15 | public static final String P_CHECK_INFORMATION = "checkInformation"; 16 | public static final String P_CHECK_MISSING_INCLUDE = "checkMissingInclude"; 17 | public static final String P_CHECK_VERBOSE = "checkVerbose"; 18 | public static final String P_CHECK_INCONCLUSIVE = "checkInconclusive"; 19 | public static final String P_CHECK_FORCE = "checkForce"; 20 | public static final String P_CHECK_DEBUG = "checkDebug"; 21 | public static final String P_USE_INLINE_SUPPRESSIONS = "useInlineSuppressions"; 22 | public static final String P_CHECK_UNUSED_FUNCTIONS = "checkUnusedFunctions"; 23 | public static final String P_FOLLOW_SYSTEM_INCLUDES = "followSystemIncludes"; 24 | public static final String P_FOLLOW_USER_INCLUDES = "followUserIncludes"; 25 | public static final String P_NUMBER_OF_THREADS = "numberOfThreads"; 26 | public static final String P_AUTOMATIC_UPDATE_CHECK_INTERVAL = "automaticUpdateCheckInterval"; 27 | public static final String P_USE_AUTOMATIC_UPDATE_CHECK = "automaticUpdateCheck"; 28 | public static final String P_LAST_UPDATE_CHECK = "lastUpdateCheck"; 29 | public static final String P_SUPPRESSIONS = "suppressions"; 30 | public static final String P_APPENDAGES = "appendages"; 31 | public static final String P_ADVANCED_ARGUMENTS = "advancedArgument"; 32 | public static final String P_SYMBOLS = "symbols"; 33 | public static final String P_RESTRICT_CONFIGURATION_CHECK = "restrictConfigurations"; 34 | public static final String P_INCLUDE_CDT_SYSTEM_SYMBOLS = "includeCDTSystemSymbols"; 35 | public static final String P_INCLUDE_CDT_USER_SYMBOLS = "includeCDTUserSymbols"; 36 | 37 | // these are the page id's of the preferences but also the prefixes for the use parent properties 38 | public static final String PROBLEMS_PAGE_ID = "com.googlecode.cppcheclipse.ui.ProblemsPreferencePage"; 39 | public static final String SETTINGS_PAGE_ID = "com.googlecode.cppcheclipse.ui.SettingsPreferencePage"; 40 | public static final String P_LANGUAGE_STANDARD = "languageStandard"; 41 | public static final String P_TARGET_PLATFORM = "targetPlatform"; 42 | public static final String P_LANGUAGE_STANDARD_POSIX = "languageStandardPosix"; 43 | public static final String P_LANGUAGE_STANDARD_C = "languageStandardC"; 44 | public static final String P_LANGUAGE_STANDARD_CPP = "languageStandardCpp"; 45 | } 46 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/LineFilterOutputStream.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.FilterOutputStream; 5 | import java.io.IOException; 6 | import java.io.OutputStream; 7 | import java.io.UnsupportedEncodingException; 8 | import java.util.Collection; 9 | import java.util.LinkedList; 10 | import java.util.regex.Pattern; 11 | 12 | public class LineFilterOutputStream extends FilterOutputStream { 13 | 14 | private final ByteArrayOutputStream lineBuffer; 15 | private final PatternSearch linebreakPatternSearch; 16 | private final String charset; 17 | private final Collection blacklistPatterns; 18 | 19 | public LineFilterOutputStream(OutputStream out, String charset) { 20 | super(out); 21 | lineBuffer = new ByteArrayOutputStream(); 22 | linebreakPatternSearch = PatternSearch.getLinebreakPatternSearch(); 23 | this.charset = charset; 24 | blacklistPatterns = new LinkedList(); 25 | } 26 | 27 | public void addBlacklistPattern(String regex) { 28 | blacklistPatterns.add(Pattern.compile(regex)); 29 | } 30 | 31 | @Override 32 | public void write(byte[] b, int off, int len) throws IOException { 33 | lineBuffer.write(b, off, len); 34 | flushBuffer(); 35 | } 36 | 37 | private boolean runFilters(byte[] buffer, int offset, int length) throws UnsupportedEncodingException { 38 | boolean skipLine = false; 39 | if (!blacklistPatterns.isEmpty()) { 40 | String line = new String(buffer, offset, length, charset); 41 | for (Pattern blacklistPattern : blacklistPatterns) { 42 | if (blacklistPattern.matcher(line).matches()) { 43 | skipLine = true; 44 | break; 45 | } 46 | } 47 | } 48 | return skipLine; 49 | } 50 | 51 | private void flushLine(byte[] buffer) throws IOException { 52 | flushLine(buffer, 0, buffer.length); 53 | } 54 | 55 | private void flushLine(byte[] buffer, int offset, int length) throws IOException { 56 | if (!runFilters(buffer, offset, length)) { 57 | out.write(buffer, offset, length); 58 | } 59 | } 60 | 61 | /** 62 | * Give out every complete line to underlying outputstream 63 | * 64 | * @return 65 | * @throws IOException 66 | */ 67 | private boolean flushBuffer() throws IOException { 68 | byte[] buffer = lineBuffer.toByteArray(); 69 | int startPos = 0; 70 | int pos; 71 | boolean foundLineBreak = false; 72 | while ((pos = linebreakPatternSearch.indexAfter(buffer, startPos)) >= 0) { 73 | flushLine(buffer, startPos, pos - startPos); 74 | startPos = pos; 75 | foundLineBreak = true; 76 | } 77 | if (foundLineBreak) { 78 | lineBuffer.reset(); 79 | lineBuffer.write(buffer, startPos, buffer.length - startPos); 80 | } 81 | 82 | return false; 83 | } 84 | 85 | @Override 86 | public void write(int b) throws IOException { 87 | lineBuffer.write(b); 88 | flushBuffer(); 89 | } 90 | 91 | @Override 92 | public void close() throws IOException { 93 | flushLine(lineBuffer.toByteArray()); 94 | super.close(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/ErrorListCommand.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.Collection; 6 | import java.util.LinkedList; 7 | 8 | import javax.xml.parsers.DocumentBuilder; 9 | import javax.xml.parsers.DocumentBuilderFactory; 10 | import javax.xml.parsers.ParserConfigurationException; 11 | import javax.xml.xpath.XPath; 12 | import javax.xml.xpath.XPathConstants; 13 | import javax.xml.xpath.XPathExpressionException; 14 | import javax.xml.xpath.XPathFactory; 15 | 16 | import org.eclipse.core.resources.IFile; 17 | import org.eclipse.core.runtime.NullProgressMonitor; 18 | import org.w3c.dom.Document; 19 | import org.w3c.dom.Node; 20 | import org.w3c.dom.NodeList; 21 | import org.xml.sax.SAXException; 22 | 23 | import com.googlecode.cppcheclipse.core.IConsole; 24 | import com.googlecode.cppcheclipse.core.Problem; 25 | 26 | public class ErrorListCommand extends AbstractCppcheckCommand { 27 | 28 | private static final String[] DEFAULT_ARGUMENTS = {"--xml-version=2", "--errorlist"}; 29 | private static final int TIMEOUT_MS = 5000; 30 | 31 | public ErrorListCommand(IConsole console, String binaryPath) { 32 | super(console, DEFAULT_ARGUMENTS, TIMEOUT_MS, binaryPath); 33 | } 34 | 35 | public Collection run() throws IOException, InterruptedException, 36 | XPathExpressionException, ParserConfigurationException, 37 | SAXException, ProcessExecutionException { 38 | CppcheckProcessResultHandler resultHandler = runInternal(); 39 | waitForExit(resultHandler, new NullProgressMonitor()); 40 | Collection problems = parseXMLStream(getOutputStream(), null); 41 | return problems; 42 | } 43 | 44 | /** 45 | * Can handle both formats (--errorlist as well as file checking). Format: 46 | * <results> <error id="autoVariables" severity="error" msg= 47 | * "Wrong assignement of an auto-variable to an effective parameter of a function" 48 | * /> </result> 49 | * 50 | * or 51 | * 52 | * <results> <error file="a.cpp" line="4" id="arrayIndexOutOfBounds" 53 | * severity="all" msg="Array index out of bounds"/> </results> 54 | * 55 | * @param stream 56 | * @return Collection of Problems 57 | * @throws ParserConfigurationException 58 | * @throws XPathExpressionException 59 | * @throws SAXException 60 | * @throws IOException 61 | */ 62 | public static Collection parseXMLStream(InputStream stream, 63 | IFile file) throws ParserConfigurationException, 64 | XPathExpressionException, SAXException, IOException { 65 | DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory 66 | .newInstance(); 67 | documentBuilderFactory.setNamespaceAware(true); // never forget this! 68 | DocumentBuilder documentBuilder = documentBuilderFactory 69 | .newDocumentBuilder(); 70 | Document doc = documentBuilder.parse(stream); 71 | 72 | XPathFactory xpathFactory = XPathFactory.newInstance(); 73 | XPath xpath = xpathFactory.newXPath(); 74 | 75 | NodeList errors = (NodeList) xpath.evaluate("//error", doc, 76 | XPathConstants.NODESET); 77 | Collection problems = new LinkedList(); 78 | // can't use iterator here 79 | for (int i = 0; i < errors.getLength(); i++) { 80 | Node error = errors.item(i); 81 | String id = (String) xpath.evaluate("@id", error, 82 | XPathConstants.STRING); 83 | String msg = (String) xpath.evaluate("@msg", error, 84 | XPathConstants.STRING); 85 | String severity = (String) xpath.evaluate("@severity", error, 86 | XPathConstants.STRING); 87 | 88 | // TODO: what to do with verbose 89 | 90 | problems.add(new Problem(id, msg, severity)); 91 | } 92 | return problems; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Suppression.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.StringTokenizer; 6 | 7 | import org.eclipse.core.resources.IProject; 8 | 9 | import com.googlecode.cppcheclipse.core.utils.SerializeHelper; 10 | 11 | public class Suppression { 12 | private final File file; 13 | private final String problemId; 14 | private final int line; 15 | 16 | private final static String PROBLEM_ID_ALL = "allProblems"; 17 | private final static int LINE_ALL = Integer.MAX_VALUE; 18 | 19 | private final static String DELIMITER = ";"; 20 | public Suppression(File file, IProject project) { 21 | this(file, PROBLEM_ID_ALL); 22 | } 23 | 24 | public Suppression(File file, String problemId) { 25 | this(file, problemId, LINE_ALL); 26 | } 27 | 28 | public Suppression(File file, String problemId, int line) { 29 | super(); 30 | this.file = file; 31 | this.problemId = problemId; 32 | this.line = line; 33 | } 34 | 35 | /** 36 | * 37 | * @return the absolute file of this suppression 38 | */ 39 | public File getFile(IProject project) { 40 | return getFile(true, project); 41 | } 42 | 43 | /** 44 | * @param absolute if true, returns an absolute path, otherwise it might be relative 45 | * @return the file of this suppression 46 | */ 47 | public File getFile(boolean absolute, IProject project) { 48 | final File file; 49 | if (absolute && !this.file.isAbsolute()) { 50 | file = new File(project.getLocation().toFile(), this.file.toString()); 51 | } else { 52 | file = this.file; 53 | } 54 | return file; 55 | } 56 | 57 | public String getProblemId() { 58 | return problemId; 59 | } 60 | 61 | public int getLine() { 62 | return line; 63 | } 64 | 65 | public boolean isFileSuppression() { 66 | return problemId.equals(PROBLEM_ID_ALL); 67 | } 68 | 69 | public boolean isSuppression(File absoluteFile, IProject project) { 70 | return isSuppression(absoluteFile, PROBLEM_ID_ALL, LINE_ALL, project); 71 | } 72 | 73 | public boolean isAllLines() { 74 | return line == LINE_ALL; 75 | } 76 | 77 | /** 78 | * 79 | * @param file (must be absolute) 80 | * @param problemId 81 | * @param line 82 | * @return true if the given problem should be suppressed 83 | */ 84 | public boolean isSuppression(File file, String problemId, int line, IProject project) { 85 | if (!file.equals(getFile(project)) && !file.toString().startsWith(getFile(project).toString() + File.separator)) 86 | return false; 87 | 88 | if (isFileSuppression()) 89 | return true; 90 | 91 | if (getProblemId().equals(problemId)) { 92 | if (getLine() == LINE_ALL) 93 | return true; 94 | 95 | // check line 96 | if (getLine() == line) 97 | return true; 98 | } 99 | return false; 100 | } 101 | 102 | public String serialize() throws IOException { 103 | StringBuffer serialization = new StringBuffer(); 104 | // serialize in a platform-portable way 105 | String path = SerializeHelper.toString(file); 106 | serialization.append(path).append(DELIMITER); 107 | serialization.append(problemId).append(DELIMITER); 108 | serialization.append(line); 109 | return serialization.toString(); 110 | } 111 | 112 | public static Suppression deserialize(String serialization) throws IOException, ClassNotFoundException { 113 | StringTokenizer tokenizer = new StringTokenizer(serialization, DELIMITER); 114 | File file = (File) SerializeHelper.fromString(tokenizer.nextToken()); 115 | String problemId = tokenizer.nextToken(); 116 | int line = Integer.parseInt(tokenizer.nextToken()); 117 | return new Suppression(file, problemId, line); 118 | } 119 | } -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/packaging-p2composite.ant: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | version=1 75 | metadata.repository.factory.order=compositeContent.xml,\! 76 | artifact.repository.factory.order=compositeArtifacts.xml,\! 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/AppendageTable.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import java.io.File; 4 | 5 | import org.eclipse.core.resources.IProject; 6 | import org.eclipse.core.resources.IResource; 7 | import org.eclipse.jface.viewers.ILabelProviderListener; 8 | import org.eclipse.jface.viewers.ITableLabelProvider; 9 | import org.eclipse.swt.SWT; 10 | import org.eclipse.swt.events.SelectionAdapter; 11 | import org.eclipse.swt.events.SelectionEvent; 12 | import org.eclipse.swt.graphics.Image; 13 | import org.eclipse.swt.widgets.Composite; 14 | 15 | import com.googlecode.cppcheclipse.core.Appendages; 16 | import com.googlecode.cppcheclipse.ui.Messages; 17 | 18 | public class AppendageTable extends TableEditor { 19 | 20 | private final IProject project; 21 | 22 | static enum TableColumn { 23 | Filename 24 | }; 25 | 26 | public AppendageTable(String name, String labelText, Composite parent, 27 | IProject project) { 28 | super(name, labelText, parent); 29 | 30 | getTableViewer(parent).getTable().setHeaderVisible(true); 31 | getTableViewer(parent).getTable().setLinesVisible(true); 32 | addColumn(new ExtendedTableColumn(Messages.AppendageTable_ColumnFile, SWT.LEFT, 150)); 33 | 34 | getTableViewer(parent).setLabelProvider(new LabelProvider()); 35 | this.project = project; 36 | } 37 | 38 | private static class LabelProvider implements ITableLabelProvider { 39 | 40 | public Image getColumnImage(Object element, int columnIndex) { 41 | return null; 42 | } 43 | 44 | public String getColumnText(Object element, int columnIndex) { 45 | String text = ""; //$NON-NLS-1$ 46 | TableColumn column = TableColumn.values()[columnIndex]; 47 | switch (column) { 48 | case Filename: 49 | text = ((File) element).toString(); 50 | break; 51 | } 52 | return text; 53 | } 54 | 55 | public void addListener(ILabelProviderListener listener) { 56 | } 57 | 58 | public void dispose() { 59 | } 60 | 61 | public boolean isLabelProperty(Object element, String property) { 62 | return false; 63 | } 64 | 65 | public void removeListener(ILabelProviderListener listener) { 66 | } 67 | 68 | } 69 | 70 | @Override 71 | protected void createButtons(Composite box) { 72 | createPushButton(box, Messages.TableEditor_Add, new SelectionAdapter() { 73 | @Override 74 | public void widgetSelected(SelectionEvent e) { 75 | addPressed(); 76 | } 77 | }); 78 | createPushButton(box, Messages.TableEditor_AddExternal, 79 | new SelectionAdapter() { 80 | @Override 81 | public void widgetSelected(SelectionEvent e) { 82 | addExternalPressed(); 83 | } 84 | }); 85 | createPushButton(box, Messages.TableEditor_Remove, 86 | new SelectionAdapter() { 87 | @Override 88 | public void widgetSelected(SelectionEvent e) { 89 | removePressed(); 90 | } 91 | }); 92 | createPushButton(box, Messages.TableEditor_RemoveAll, 93 | new SelectionAdapter() { 94 | @Override 95 | public void widgetSelected(SelectionEvent e) { 96 | removeAllPressed(); 97 | } 98 | }); 99 | } 100 | 101 | protected void addPressed() { 102 | IResource resource = openProjectFile(Messages.AppendageTable_FileSelection, Messages.AppendageTable_FileSelectionMessage, project, false); 103 | if (resource != null) { 104 | File file = resource.getProjectRelativePath().toFile(); 105 | getModel().add(file); 106 | getTableViewer().add(file); 107 | } 108 | } 109 | 110 | protected void addExternalPressed() { 111 | File file = openExternalFile(Messages.AppendageTable_FileSelection); 112 | if (file != null) { 113 | getModel().add(file); 114 | getTableViewer().add(file); 115 | } 116 | } 117 | 118 | @Override 119 | protected Appendages createModel() { 120 | return new Appendages(getPreferenceStore()); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Symbols.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.IOException; 4 | import java.util.Collection; 5 | import java.util.Iterator; 6 | import java.util.LinkedList; 7 | import java.util.StringTokenizer; 8 | 9 | import org.eclipse.jface.preference.IPersistentPreferenceStore; 10 | import org.eclipse.jface.preference.IPreferenceStore; 11 | 12 | /** 13 | * 14 | * @author Konrad Windszus 15 | * Model class for symbols (also called configurations or macros) 16 | */ 17 | public class Symbols implements TableModel { 18 | private Collection symbols; // key and value 19 | 20 | private static final String DELIMITER = "\n"; 21 | private final IPreferenceStore projectPreferences; 22 | 23 | /* 24 | * Creates empty list of symbols 25 | */ 26 | public Symbols() { 27 | symbols = new LinkedList(); 28 | projectPreferences = null; 29 | } 30 | 31 | public Symbols(IPreferenceStore projectPreferences, IToolchainSettings toolchainSettings) { 32 | this.projectPreferences = projectPreferences; 33 | this.symbols = new LinkedList(); 34 | 35 | // load from project preferences 36 | load(toolchainSettings); 37 | } 38 | 39 | private void load(IToolchainSettings toolchainSettings) { 40 | if (projectPreferences.getBoolean(IPreferenceConstants.P_INCLUDE_CDT_USER_SYMBOLS)) { 41 | this.symbols.addAll(toolchainSettings.getUserSymbols()); 42 | } 43 | 44 | if (projectPreferences.getBoolean(IPreferenceConstants.P_INCLUDE_CDT_SYSTEM_SYMBOLS)) { 45 | this.symbols.addAll(toolchainSettings.getSystemSymbols()); 46 | } 47 | String symbols = projectPreferences 48 | .getString(IPreferenceConstants.P_SYMBOLS); 49 | StringTokenizer tokenizer = new StringTokenizer(symbols, DELIMITER); 50 | while (tokenizer.hasMoreTokens()) { 51 | try { 52 | Symbol symbol = Symbol.deserialize(tokenizer 53 | .nextToken()); 54 | addSymbol(symbol); 55 | } catch (Exception e) { 56 | CppcheclipsePlugin.logWarning("Could not load defined symbols", e); 57 | } 58 | } 59 | } 60 | 61 | /* 62 | * (non-Javadoc) 63 | * @see com.googlecode.cppcheclipse.core.TableModel#save() 64 | */ 65 | public void save() throws IOException { 66 | StringBuffer symbolsSerialization = new StringBuffer(); 67 | for (Symbol symbol : symbols) { 68 | // only serialize user-defined symbols 69 | if (!symbol.isCDTDefined()) 70 | symbolsSerialization.append(symbol.serialize()).append(DELIMITER); 71 | } 72 | 73 | projectPreferences.setValue(IPreferenceConstants.P_SYMBOLS, 74 | symbolsSerialization.toString()); 75 | 76 | if (projectPreferences instanceof IPersistentPreferenceStore) { 77 | ((IPersistentPreferenceStore) projectPreferences).save(); 78 | } 79 | } 80 | 81 | public void addSymbol(Symbol symbol) { 82 | symbols.add(symbol); 83 | } 84 | 85 | public void addSymbols(Collection symbols) { 86 | this.symbols.addAll(symbols); 87 | } 88 | 89 | public void remove(Symbol symbol) { 90 | symbols.remove(symbol); 91 | } 92 | 93 | public void removeAll() { 94 | symbols.clear(); 95 | } 96 | 97 | public void removeCDTSystemSymbols() { 98 | Iterator iterator = symbols.iterator(); 99 | while (iterator.hasNext()) { 100 | Symbol symbol = iterator.next(); 101 | if (symbol.isCDTDefined() && symbol.isSystemDefined()) { 102 | iterator.remove(); 103 | } 104 | } 105 | } 106 | 107 | public void removeUserSymbols() { 108 | Iterator iterator = symbols.iterator(); 109 | while (iterator.hasNext()) { 110 | Symbol symbol = iterator.next(); 111 | if (!symbol.isCDTDefined()) { 112 | iterator.remove(); 113 | } 114 | } 115 | } 116 | 117 | public void removeCDTUserSymbols() { 118 | Iterator iterator = symbols.iterator(); 119 | while (iterator.hasNext()) { 120 | Symbol symbol = iterator.next(); 121 | if (symbol.isCDTDefined() && !symbol.isSystemDefined()) { 122 | iterator.remove(); 123 | } 124 | } 125 | } 126 | 127 | public Iterator iterator() { 128 | return symbols.iterator(); 129 | } 130 | 131 | public Symbol[] toArray() { 132 | return symbols.toArray(new Symbol[0]); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/Nature.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui; 2 | 3 | import org.eclipse.core.resources.ICommand; 4 | import org.eclipse.core.resources.IProject; 5 | import org.eclipse.core.resources.IProjectDescription; 6 | import org.eclipse.core.resources.IProjectNature; 7 | import org.eclipse.core.runtime.CoreException; 8 | 9 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 10 | 11 | public class Nature implements IProjectNature { 12 | /** 13 | * ID of this project nature 14 | */ 15 | public static final String NATURE_ID = "com.googlecode.cppcheclipse.Nature"; //$NON-NLS-1$ 16 | private IProject project; 17 | 18 | /* 19 | * (non-Javadoc) 20 | * 21 | * @see org.eclipse.core.resources.IProjectNature#configure() 22 | */ 23 | public void configure() throws CoreException { 24 | // add builder to list of proect builders 25 | IProjectDescription desc = project.getDescription(); 26 | ICommand[] commands = desc.getBuildSpec(); 27 | for (int i = 0; i < commands.length; ++i) { 28 | if (commands[i].getBuilderName().equals(Builder.BUILDER_ID)) { 29 | return; 30 | } 31 | } 32 | ICommand[] newCommands = new ICommand[commands.length + 1]; 33 | System.arraycopy(commands, 0, newCommands, 0, commands.length); 34 | ICommand command = desc.newCommand(); 35 | command.setBuilderName(Builder.BUILDER_ID); 36 | newCommands[newCommands.length - 1] = command; 37 | desc.setBuildSpec(newCommands); 38 | project.setDescription(desc, null); 39 | } 40 | 41 | /* 42 | * (non-Javadoc) 43 | * 44 | * @see org.eclipse.core.resources.IProjectNature#deconfigure() 45 | */ 46 | public void deconfigure() throws CoreException { 47 | // remove builder from the list of builders 48 | IProjectDescription description = getProject().getDescription(); 49 | ICommand[] commands = description.getBuildSpec(); 50 | for (int i = 0; i < commands.length; ++i) { 51 | if (commands[i].getBuilderName().equals(Builder.BUILDER_ID)) { 52 | ICommand[] newCommands = new ICommand[commands.length - 1]; 53 | System.arraycopy(commands, 0, newCommands, 0, i); 54 | System.arraycopy(commands, i + 1, newCommands, i, 55 | commands.length - i - 1); 56 | description.setBuildSpec(newCommands); 57 | project.setDescription(description, null); 58 | return; 59 | } 60 | } 61 | } 62 | 63 | /* 64 | * (non-Javadoc) 65 | * 66 | * @see org.eclipse.core.resources.IProjectNature#getProject() 67 | */ 68 | public IProject getProject() { 69 | return project; 70 | } 71 | 72 | /* 73 | * (non-Javadoc) 74 | * 75 | * @see 76 | * org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core 77 | * .resources.IProject) 78 | */ 79 | public void setProject(IProject project) { 80 | this.project = project; 81 | } 82 | 83 | /** 84 | * Toggles sample nature on a project 85 | * 86 | * @param project 87 | * to have sample nature added or removed 88 | */ 89 | public static void toggleNature(IProject project, boolean add) { 90 | try { 91 | IProjectDescription description = project.getDescription(); 92 | String[] natures = description.getNatureIds(); 93 | for (int i = 0; i < natures.length; ++i) { 94 | if (NATURE_ID.equals(natures[i])) { 95 | if (add == false) { 96 | // Remove the nature 97 | String[] newNatures = new String[natures.length - 1]; 98 | System.arraycopy(natures, 0, newNatures, 0, i); 99 | System.arraycopy(natures, i + 1, newNatures, i, 100 | natures.length - i - 1); 101 | description.setNatureIds(newNatures); 102 | project.setDescription(description, null); 103 | return; 104 | } else { 105 | // already there no need to add 106 | add = false; 107 | break; 108 | } 109 | } 110 | } 111 | if (add) { 112 | // Add the nature 113 | String[] newNatures = new String[natures.length + 1]; 114 | System.arraycopy(natures, 0, newNatures, 0, natures.length); 115 | newNatures[natures.length] = NATURE_ID; 116 | description.setNatureIds(newNatures); 117 | project.setDescription(description, null); 118 | } 119 | } catch (CoreException e) { 120 | CppcheclipsePlugin.logError("Could not toggle nature", e); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/SuppressionProfile.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.Collection; 6 | import java.util.Iterator; 7 | import java.util.LinkedList; 8 | import java.util.List; 9 | import java.util.StringTokenizer; 10 | 11 | import org.eclipse.core.resources.IProject; 12 | import org.eclipse.jface.preference.IPersistentPreferenceStore; 13 | import org.eclipse.jface.preference.IPreferenceStore; 14 | 15 | public class SuppressionProfile implements TableModel { 16 | private static final String DELIMITER = "!"; 17 | 18 | // contains the suppressions per file 19 | private final List suppressionList; 20 | private final IPreferenceStore projectPreferences; 21 | private final IProject project; 22 | 23 | public SuppressionProfile(IPreferenceStore projectPreferences, 24 | IProject project) { 25 | this.projectPreferences = projectPreferences; 26 | this.suppressionList = new LinkedList(); 27 | this.project = project; 28 | load(); 29 | } 30 | 31 | private void load() { 32 | String suppressions = projectPreferences 33 | .getString(IPreferenceConstants.P_SUPPRESSIONS); 34 | StringTokenizer tokenizer = new StringTokenizer(suppressions, DELIMITER); 35 | while (tokenizer.hasMoreTokens()) { 36 | try { 37 | Suppression suppression = Suppression.deserialize(tokenizer 38 | .nextToken()); 39 | addSuppression(suppression); 40 | } catch (Exception e) { 41 | CppcheclipsePlugin.logWarning("Could not load preferences", e); 42 | } 43 | } 44 | } 45 | 46 | public void save() throws IOException { 47 | StringBuffer suppressions = new StringBuffer(); 48 | for (Suppression suppression : suppressionList) { 49 | suppressions.append(suppression.serialize()).append(DELIMITER); 50 | } 51 | 52 | projectPreferences.setValue(IPreferenceConstants.P_SUPPRESSIONS, 53 | suppressions.toString()); 54 | 55 | if (projectPreferences instanceof IPersistentPreferenceStore) { 56 | ((IPersistentPreferenceStore) projectPreferences).save(); 57 | } 58 | } 59 | 60 | private void addSuppression(Suppression suppression) { 61 | suppressionList.add(suppression); 62 | } 63 | 64 | public Suppression addFileSuppression(File file) { 65 | Suppression suppression = new Suppression(file, project); 66 | addSuppression(suppression); 67 | return suppression; 68 | } 69 | 70 | public void addProblemSuppression(File file, String problemId) { 71 | addSuppression(new Suppression(file, problemId)); 72 | } 73 | 74 | public void addProblemInLineSuppression(File file, String problemId, 75 | int line) { 76 | addSuppression(new Suppression(file, problemId, line)); 77 | } 78 | 79 | public void remove(Suppression suppression) { 80 | suppressionList.remove(suppression); 81 | } 82 | 83 | public void removeAll() { 84 | suppressionList.clear(); 85 | } 86 | 87 | private File makeAbsoluteFile(File file) { 88 | if (file.isAbsolute()) { 89 | return file; 90 | } 91 | return new File(project.getLocation().toFile(), file.toString()); 92 | } 93 | 94 | public boolean isFileSuppressed(File file) { 95 | File absoluteFile = makeAbsoluteFile(file); 96 | for (Suppression suppression : suppressionList) { 97 | if (suppression.isSuppression(absoluteFile, project)) { 98 | return true; 99 | } 100 | } 101 | return false; 102 | } 103 | 104 | public boolean isProblemInLineSuppressed(File file, String problemId, 105 | int line) { 106 | // not possible to suppress problems with no file attached 107 | if (file == null) { 108 | return false; 109 | } 110 | File absoluteFile = makeAbsoluteFile(file); 111 | for (Suppression suppression : suppressionList) { 112 | if (suppression.isSuppression(absoluteFile, problemId, line, 113 | project)) { 114 | return true; 115 | } 116 | } 117 | return false; 118 | } 119 | 120 | public final Collection getSuppressions() { 121 | return suppressionList; 122 | } 123 | 124 | public Iterator iterator() { 125 | return suppressionList.iterator(); 126 | } 127 | 128 | public Suppression[] toArray() { 129 | return (Suppression[]) suppressionList.toArray(new Suppression[0]); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/Version.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.command; 2 | 3 | import java.util.NoSuchElementException; 4 | import java.util.StringTokenizer; 5 | 6 | public class Version { 7 | 8 | private static final String VERSION_PREFIX = "cppcheck"; 9 | private static final String DELIMITER = "."; 10 | private final int majorVersion; 11 | private final int minorVersion; 12 | private final int revision; 13 | 14 | public static final Version MIN_VERSION = new Version (1, 56, 0); 15 | 16 | private Version(int majorVersion, int minorVersion, int revision) { 17 | this.majorVersion = majorVersion; 18 | this.minorVersion = minorVersion; 19 | this.revision = revision; 20 | } 21 | 22 | /** version string must have the format 23 | * "cppcheck .[.]" 24 | * 25 | * @param version 26 | */ 27 | public Version(String version) { 28 | version = version.toLowerCase(); 29 | 30 | if (!version.startsWith(VERSION_PREFIX)) { 31 | throw new IllegalArgumentException("Version must start with " + VERSION_PREFIX + ", but is " + version); 32 | } 33 | 34 | version = version.substring(VERSION_PREFIX.length()); 35 | version = version.trim(); 36 | 37 | // extract the version with the delimiter from the string 38 | version = version.replaceAll("[^0-9" + DELIMITER + "]",""); 39 | 40 | try { 41 | StringTokenizer tokenizer = new StringTokenizer(version, DELIMITER); 42 | String versionPart = tokenizer.nextToken(); 43 | majorVersion = Integer.parseInt(versionPart); 44 | versionPart = tokenizer.nextToken(); 45 | minorVersion = Integer.parseInt(versionPart); 46 | 47 | if (tokenizer.hasMoreTokens()) { 48 | versionPart = tokenizer.nextToken(); 49 | revision = Integer.parseInt(versionPart); 50 | } else { 51 | revision = 0; 52 | } 53 | } catch (NoSuchElementException e) { 54 | throw new IllegalArgumentException("Version must consist of at least two integers, separated by " + DELIMITER); 55 | } 56 | } 57 | 58 | 59 | 60 | public int getMajorVersion() { 61 | return majorVersion; 62 | } 63 | 64 | public int getMinorVersion() { 65 | return minorVersion; 66 | } 67 | 68 | public int getRevision() { 69 | return revision; 70 | } 71 | 72 | /** 73 | * 74 | * @param version 75 | * @return true if the given version is greater than the current version 76 | */ 77 | public boolean isGreaterThan(Version version) { 78 | if (majorVersion > version.majorVersion) 79 | return true; 80 | else if (majorVersion == version.majorVersion) { 81 | if (minorVersion > version.minorVersion) 82 | return true; 83 | else if (minorVersion == version.minorVersion) { 84 | if (revision > version.revision) 85 | return true; 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | public boolean isGreaterOrEqual(Version version) { 92 | boolean result = isGreaterThan(version); 93 | if (!result) { 94 | // check for equality 95 | if (equals(version)) { 96 | return true; 97 | } 98 | } 99 | return result; 100 | } 101 | 102 | /** 103 | * minimum required version check 104 | * @return true, if current version is greater or equal to the minimum required version. 105 | */ 106 | public boolean isCompatible() { 107 | return isGreaterOrEqual(MIN_VERSION); 108 | } 109 | 110 | 111 | @Override 112 | public String toString() { 113 | StringBuffer version = new StringBuffer(); 114 | version.append(majorVersion).append(".").append(minorVersion); 115 | if (revision != 0) { 116 | version.append(".").append(revision); 117 | } 118 | return version.toString(); 119 | } 120 | 121 | @Override 122 | public int hashCode() { 123 | final int prime = 31; 124 | int result = 1; 125 | result = prime * result + majorVersion; 126 | result = prime * result + minorVersion; 127 | result = prime * result + revision; 128 | return result; 129 | } 130 | 131 | @Override 132 | public boolean equals(Object obj) { 133 | if (this == obj) 134 | return true; 135 | if (obj == null) 136 | return false; 137 | if (getClass() != obj.getClass()) 138 | return false; 139 | Version other = (Version) obj; 140 | if (majorVersion != other.majorVersion) 141 | return false; 142 | if (minorVersion != other.minorVersion) 143 | return false; 144 | if (revision != other.revision) 145 | return false; 146 | return true; 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/.settings/org.eclipse.pde.api.tools.prefs: -------------------------------------------------------------------------------- 1 | ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error 2 | ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 3 | ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error 4 | ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error 5 | ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 6 | API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error 7 | API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error 8 | API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error 9 | API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error 10 | CLASS_ELEMENT_TYPE_ADDED_METHOD=Error 11 | CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error 12 | CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 13 | CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error 14 | CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 15 | CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error 16 | CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error 17 | CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 18 | CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error 19 | CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error 20 | CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error 21 | CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error 22 | CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 23 | CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 24 | CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 25 | CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 26 | CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error 27 | CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 28 | ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error 29 | ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 30 | ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error 31 | ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error 32 | ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error 33 | ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 34 | FIELD_ELEMENT_TYPE_ADDED_VALUE=Error 35 | FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 36 | FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error 37 | FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error 38 | FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error 39 | FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error 40 | FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error 41 | FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error 42 | FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error 43 | FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error 44 | ILLEGAL_EXTEND=Warning 45 | ILLEGAL_IMPLEMENT=Warning 46 | ILLEGAL_INSTANTIATE=Warning 47 | ILLEGAL_OVERRIDE=Warning 48 | ILLEGAL_REFERENCE=Warning 49 | INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error 50 | INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error 51 | INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error 52 | INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error 53 | INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 54 | INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error 55 | INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 56 | INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error 57 | INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error 58 | INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 59 | INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 60 | INVALID_JAVADOC_TAG=Error 61 | INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Error 62 | LEAK_EXTEND=Warning 63 | LEAK_FIELD_DECL=Warning 64 | LEAK_IMPLEMENT=Warning 65 | LEAK_METHOD_PARAM=Warning 66 | LEAK_METHOD_RETURN_TYPE=Warning 67 | METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error 68 | METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 69 | METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 70 | METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error 71 | METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error 72 | METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error 73 | METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error 74 | METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error 75 | METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error 76 | METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 77 | TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error 78 | TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error 79 | TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error 80 | TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error 81 | TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error 82 | TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error 83 | UNUSED_PROBLEM_FILTERS=Warning 84 | automatically_removed_unused_problem_filters=false 85 | eclipse.preferences.version=1 86 | incompatible_api_component_version=Error 87 | incompatible_api_component_version_include_major_without_breaking_change=Disabled 88 | incompatible_api_component_version_include_minor_without_api_change=Disabled 89 | invalid_since_tag_version=Error 90 | malformed_since_tag=Error 91 | missing_since_tag=Error 92 | report_api_breakage_when_major_version_incremented=Disabled 93 | report_resolution_errors_api_component=Warning 94 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/.settings/org.eclipse.pde.api.tools.prefs: -------------------------------------------------------------------------------- 1 | ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error 2 | ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 3 | ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error 4 | ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error 5 | ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 6 | API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error 7 | API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error 8 | API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error 9 | API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error 10 | CLASS_ELEMENT_TYPE_ADDED_METHOD=Error 11 | CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error 12 | CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 13 | CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error 14 | CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 15 | CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error 16 | CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error 17 | CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 18 | CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error 19 | CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error 20 | CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error 21 | CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error 22 | CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 23 | CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 24 | CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 25 | CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 26 | CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error 27 | CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 28 | ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error 29 | ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 30 | ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error 31 | ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error 32 | ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error 33 | ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 34 | FIELD_ELEMENT_TYPE_ADDED_VALUE=Error 35 | FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 36 | FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error 37 | FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error 38 | FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error 39 | FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error 40 | FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error 41 | FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error 42 | FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error 43 | FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error 44 | ILLEGAL_EXTEND=Warning 45 | ILLEGAL_IMPLEMENT=Warning 46 | ILLEGAL_INSTANTIATE=Warning 47 | ILLEGAL_OVERRIDE=Warning 48 | ILLEGAL_REFERENCE=Warning 49 | INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error 50 | INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error 51 | INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error 52 | INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error 53 | INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 54 | INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error 55 | INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error 56 | INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error 57 | INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error 58 | INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error 59 | INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 60 | INVALID_JAVADOC_TAG=Warning 61 | INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Error 62 | LEAK_EXTEND=Warning 63 | LEAK_FIELD_DECL=Warning 64 | LEAK_IMPLEMENT=Warning 65 | LEAK_METHOD_PARAM=Warning 66 | LEAK_METHOD_RETURN_TYPE=Warning 67 | METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error 68 | METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error 69 | METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error 70 | METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error 71 | METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error 72 | METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error 73 | METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error 74 | METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error 75 | METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error 76 | METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error 77 | TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error 78 | TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error 79 | TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error 80 | TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error 81 | TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error 82 | TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error 83 | UNUSED_PROBLEM_FILTERS=Warning 84 | automatically_removed_unused_problem_filters=false 85 | eclipse.preferences.version=1 86 | incompatible_api_component_version=Error 87 | incompatible_api_component_version_include_major_without_breaking_change=Disabled 88 | incompatible_api_component_version_include_minor_without_api_change=Disabled 89 | invalid_since_tag_version=Error 90 | malformed_since_tag=Error 91 | missing_since_tag=Error 92 | report_api_breakage_when_major_version_incremented=Disabled 93 | report_resolution_errors_api_component=Warning 94 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/Console.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | import org.eclipse.swt.SWT; 7 | import org.eclipse.swt.widgets.Display; 8 | import org.eclipse.ui.IWorkbenchPage; 9 | import org.eclipse.ui.IWorkbenchWindow; 10 | import org.eclipse.ui.PartInitException; 11 | import org.eclipse.ui.PlatformUI; 12 | import org.eclipse.ui.console.ConsolePlugin; 13 | import org.eclipse.ui.console.IConsole; 14 | import org.eclipse.ui.console.IConsoleConstants; 15 | import org.eclipse.ui.console.IConsoleManager; 16 | import org.eclipse.ui.console.IConsoleView; 17 | import org.eclipse.ui.console.MessageConsole; 18 | import org.eclipse.ui.console.MessageConsoleStream; 19 | 20 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 21 | 22 | /** 23 | * Wrapper around a console window, which can output an existing InputSteam. 24 | * 25 | * @author Konrad Windszus 26 | * 27 | */ 28 | public class Console implements com.googlecode.cppcheclipse.core.IConsole { 29 | 30 | private static final String NAME = Messages.Console_Title; 31 | private final MessageConsole messageConsole; 32 | private static Console INSTANCE = null; 33 | 34 | public synchronized static Console getInstance() { 35 | if (INSTANCE == null) { 36 | INSTANCE = new Console(); 37 | } 38 | return INSTANCE; 39 | } 40 | 41 | private Console() { 42 | messageConsole = findMessageConsole(NAME); 43 | } 44 | 45 | 46 | 47 | private static MessageConsole findMessageConsole(String name) { 48 | ConsolePlugin plugin = ConsolePlugin.getDefault(); 49 | IConsoleManager conMan = plugin.getConsoleManager(); 50 | IConsole[] existing = conMan.getConsoles(); 51 | for (int i = 0; i < existing.length; i++) 52 | if (name.equals(existing[i].getName())) 53 | return (MessageConsole) existing[i]; 54 | // no console found, so create a new one 55 | MessageConsole myConsole = new MessageConsole(name, null); 56 | conMan.addConsoles(new IConsole[] { myConsole }); 57 | return myConsole; 58 | } 59 | 60 | 61 | /* 62 | * (non-Javadoc) 63 | * @see com.googlecode.cppcheclipse.core.IConsole#getConsoleOutputStream(boolean) 64 | */ 65 | public OutputStream getConsoleOutputStream(boolean isError) { 66 | final MessageConsoleStream output = messageConsole.newMessageStream(); 67 | output.setActivateOnWrite(false); 68 | 69 | final int colorId; 70 | if (!isError) { 71 | colorId = SWT.COLOR_BLACK; 72 | } else { 73 | colorId = SWT.COLOR_RED; 74 | } 75 | 76 | /* we must set the color in the UI thread */ 77 | Runnable runnable = new Runnable() { 78 | public void run() { 79 | org.eclipse.swt.graphics.Color color = Display.getCurrent() 80 | .getSystemColor(colorId); 81 | output.setColor(color); 82 | } 83 | }; 84 | Display.getDefault().syncExec(runnable); 85 | 86 | return output; 87 | } 88 | 89 | /* 90 | * (non-Javadoc) 91 | * 92 | * @see com.googlecode.cppcheclipse.command.IConsole#print(java.lang.String) 93 | */ 94 | public void print(String line) throws IOException { 95 | final MessageConsoleStream output = messageConsole.newMessageStream(); 96 | output.print(line); 97 | output.close(); 98 | } 99 | 100 | /* 101 | * (non-Javadoc) 102 | * 103 | * @see 104 | * com.googlecode.cppcheclipse.command.IConsole#println(java.lang.String) 105 | */ 106 | public void println(String line) throws IOException { 107 | final MessageConsoleStream output = messageConsole.newMessageStream(); 108 | output.println(line); 109 | output.close(); 110 | } 111 | 112 | /* 113 | * (non-Javadoc) 114 | * 115 | * @see com.googlecode.cppcheclipse.command.IConsole#show() 116 | */ 117 | public void show() { 118 | 119 | Runnable runnable = new Runnable() { 120 | public void run() { 121 | // this should only be called from GUI thread 122 | IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); 123 | if (window == null) { 124 | CppcheclipsePlugin.logError("Could not show console because there is no active workbench window"); 125 | return; 126 | } 127 | IWorkbenchPage page = window.getActivePage(); 128 | if (page == null) { 129 | CppcheclipsePlugin.logError("Could not show console because there is no active page"); 130 | return; 131 | } 132 | try { 133 | IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW); 134 | view.display(messageConsole); 135 | } catch (PartInitException e) { 136 | CppcheclipsePlugin.logError("Could not show console", e); 137 | } 138 | 139 | } 140 | }; 141 | Display.getDefault().asyncExec(runnable); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/SymbolsPropertyPage.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import java.util.Collection; 4 | import java.util.LinkedList; 5 | 6 | import org.eclipse.jface.preference.BooleanFieldEditor; 7 | import org.eclipse.jface.preference.FieldEditor; 8 | import org.eclipse.swt.SWT; 9 | import org.eclipse.swt.widgets.Composite; 10 | import org.eclipse.swt.widgets.Control; 11 | import org.eclipse.swt.widgets.Group; 12 | import org.eclipse.ui.IWorkbenchPropertyPage; 13 | 14 | import com.googlecode.cppcheclipse.core.IPreferenceConstants; 15 | import com.googlecode.cppcheclipse.ui.ToolchainSettings; 16 | import com.googlecode.cppcheclipse.ui.Messages; 17 | 18 | public class SymbolsPropertyPage extends FieldEditorOverlayPage implements 19 | IWorkbenchPropertyPage { 20 | private Collection restrictedSymbolEditors; 21 | private Group group; 22 | private SymbolsTable table; 23 | private ToolchainSettings settings; 24 | private BooleanFieldEditor restrictConfigurations; 25 | 26 | public SymbolsPropertyPage() { 27 | super(GRID, false); 28 | setDescription(Messages.SymbolsPropertyPage_Description); 29 | restrictedSymbolEditors = new LinkedList(); 30 | } 31 | 32 | @Override 33 | protected void createFieldEditors() { 34 | settings = new ToolchainSettings(getProject()); 35 | 36 | restrictConfigurations = new BooleanFieldEditor(IPreferenceConstants.P_RESTRICT_CONFIGURATION_CHECK, "Restrict checked configurations", getFieldEditorParent()) { 37 | @Override 38 | protected void valueChanged(boolean oldValue, boolean newValue) { 39 | super.valueChanged(oldValue, newValue); 40 | 41 | for (FieldEditor restrictedSymbolEditor : restrictedSymbolEditors) { 42 | restrictedSymbolEditor.setEnabled(newValue, 43 | group); 44 | } 45 | } 46 | }; 47 | addField(restrictConfigurations); 48 | 49 | // available checks 50 | final Composite parent = getFieldEditorParent(); 51 | group = new Group(parent, SWT.NONE); 52 | group.setText(Messages.SettingsPreferencePage_ChecksLabel); 53 | 54 | BooleanFieldEditor includeCDTSystemSymbols = new BooleanFieldEditor(IPreferenceConstants.P_INCLUDE_CDT_SYSTEM_SYMBOLS, 55 | "Include CDT System-Defined Symbols", group) { 56 | 57 | @Override 58 | protected void valueChanged(boolean oldValue, 59 | boolean newValue) { 60 | if (oldValue == newValue) { 61 | return; 62 | } 63 | if (newValue == false) { 64 | table.getModel().removeCDTSystemSymbols(); 65 | } else { 66 | table.getModel().addSymbols(settings.getSystemSymbols()); 67 | } 68 | table.getTableViewer().refresh(); 69 | super.valueChanged(oldValue, newValue); 70 | } 71 | 72 | }; 73 | restrictedSymbolEditors.add(includeCDTSystemSymbols); 74 | addField(includeCDTSystemSymbols, group); 75 | 76 | BooleanFieldEditor includeCDTUserSymbols = new BooleanFieldEditor(IPreferenceConstants.P_INCLUDE_CDT_USER_SYMBOLS, 77 | "Include CDT User-Defined Symbols", group) { 78 | 79 | @Override 80 | protected void valueChanged(boolean oldValue, 81 | boolean newValue) { 82 | if (oldValue == newValue) { 83 | return; 84 | } 85 | if (newValue == false) { 86 | table.getModel().removeCDTUserSymbols(); 87 | } else { 88 | table.getModel().addSymbols(settings.getUserSymbols()); 89 | } 90 | table.getTableViewer().refresh(); 91 | super.valueChanged(oldValue, newValue); 92 | } 93 | 94 | }; 95 | restrictedSymbolEditors.add(includeCDTUserSymbols); 96 | addField(includeCDTUserSymbols, group); 97 | 98 | table = new SymbolsTable( 99 | IPreferenceConstants.P_SYMBOLS, 100 | Messages.AppendagePropertyPage_AppendageLabel, 101 | group, settings); 102 | restrictedSymbolEditors.add(table); 103 | addField(table, group); 104 | 105 | // reset layout manager here, since every field editor reset the parent's layout manager in FieldEditor::createControl 106 | setCompositeLayout(group); 107 | } 108 | 109 | @Override 110 | protected String getPageId() { 111 | return null; 112 | } 113 | 114 | @Override 115 | protected Control createContents(Composite parent) { 116 | Control control = super.createContents(parent); 117 | refresh(); 118 | // after that all controls are initialized 119 | return control; 120 | } 121 | 122 | @Override 123 | protected void performDefaults() { 124 | super.performDefaults(); 125 | refresh(); 126 | } 127 | 128 | private void refresh() { 129 | for (FieldEditor restrictedSymbolEditor : restrictedSymbolEditors) { 130 | restrictedSymbolEditor.setEnabled(restrictConfigurations.getBooleanValue(), 131 | group); 132 | } 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.parent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.googlecode.cppcheclipse 7 | com.googlecode.cppcheclipse.parent 8 | 1.1.2-SNAPSHOT 9 | pom 10 | 11 | 12 | 13 | 3.0 14 | 15 | 16 | 17 | 0.24.0 18 | UTF-8 19 | 1.7 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.eclipse.tycho 27 | tycho-maven-plugin 28 | ${tycho-version} 29 | true 30 | 31 | 32 | org.eclipse.tycho 33 | target-platform-configuration 34 | ${tycho-version} 35 | 36 | p2 37 | 38 | 39 | com.googlecode.cppcheclipse.target 40 | com.googlecode.cppcheclipse 41 | ${project.version} 42 | eclipse3.6cdtp2 43 | 44 | 45 | true 46 | 47 | 48 | linux 49 | gtk 50 | x86 51 | 52 | 53 | linux 54 | gtk 55 | x86_64 56 | 57 | 58 | win32 59 | win32 60 | x86 61 | 62 | 63 | win32 64 | win32 65 | x86_64 66 | 67 | 68 | macosx 69 | cocoa 70 | x86_64 71 | 72 | 73 | 74 | 75 | 76 | 77 | org.eclipse.tycho 78 | tycho-source-plugin 79 | ${tycho-version} 80 | 81 | 82 | plugin-source 83 | 84 | plugin-source 85 | 86 | 87 | 88 | 89 | 104 | 105 | org.eclipse.tycho 106 | tycho-p2-plugin 107 | ${tycho-version} 108 | 109 | 110 | attach-p2-metadata 111 | package 112 | 113 | p2-metadata 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | org.eclipse.tycho 122 | tycho-packaging-plugin 123 | ${tycho-version} 124 | 125 | 'v'yyyyMMdd'-'HHmm 126 | 127 | 128 | 129 | 130 | org.eclipse.tycho 131 | tycho-versions-plugin 132 | ${tycho-version} 133 | 134 | 135 | 136 | 137 | 138 | ../com.googlecode.cppcheclipse.target 139 | ../com.googlecode.cppcheclipse.core 140 | ../com.googlecode.cppcheclipse.core.tests 141 | ../com.googlecode.cppcheclipse.ui 142 | ../com.googlecode.cppcheclipse.ui.tests 143 | ../com.googlecode.cppcheclipse.feature 144 | ../com.googlecode.cppcheclipse.repository 145 | 146 | 147 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/HttpClientService.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core.utils; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.net.Authenticator; 6 | import java.net.HttpURLConnection; 7 | import java.net.InetAddress; 8 | import java.net.InetSocketAddress; 9 | import java.net.PasswordAuthentication; 10 | import java.net.Proxy; 11 | import java.net.Proxy.Type; 12 | import java.net.URI; 13 | import java.net.URISyntaxException; 14 | import java.net.URL; 15 | import java.net.UnknownHostException; 16 | 17 | import org.eclipse.core.net.proxy.IProxyData; 18 | import org.eclipse.core.net.proxy.IProxyService; 19 | 20 | import com.google.common.base.Strings; 21 | 22 | public class HttpClientService implements IHttpClientService { 23 | 24 | private IProxyService proxyService; 25 | 26 | private static class ProxyAuthenticator extends Authenticator { 27 | 28 | private String user, password; 29 | 30 | public ProxyAuthenticator(String user, String password) { 31 | this.user = user; 32 | this.password = password; 33 | } 34 | 35 | protected PasswordAuthentication getPasswordAuthentication() { 36 | return new PasswordAuthentication(user, password.toCharArray()); 37 | } 38 | } 39 | 40 | 41 | private Proxy getProxy(URI uri) throws UnknownHostException { 42 | IProxyData proxyData = getProxyData(uri); 43 | if (proxyData == null) { 44 | if (!isProxiesEnabled()) { 45 | return Proxy.NO_PROXY; 46 | } 47 | return null; 48 | } 49 | 50 | return getProxyFromProxyData(proxyData); 51 | 52 | } 53 | 54 | private Proxy getProxyFromProxyData(IProxyData proxyData) throws UnknownHostException { 55 | 56 | Type proxyType; 57 | if (IProxyData.HTTP_PROXY_TYPE.equals(proxyData.getType())) { 58 | proxyType = Type.HTTP; 59 | } else if (IProxyData.SOCKS_PROXY_TYPE.equals(proxyData.getType())) { 60 | proxyType = Type.SOCKS; 61 | } else if (IProxyData.HTTPS_PROXY_TYPE.equals(proxyData.getType())) { 62 | proxyType = Type.HTTP; 63 | } else { 64 | throw new IllegalArgumentException("Invalid proxy type " + proxyData.getType()); 65 | } 66 | 67 | InetSocketAddress sockAddr = new InetSocketAddress(InetAddress.getByName(proxyData.getHost()), proxyData.getPort()); 68 | Proxy proxy = new Proxy(proxyType, sockAddr); 69 | if (!Strings.isNullOrEmpty(proxyData.getUserId())) { 70 | Authenticator.setDefault(new ProxyAuthenticator(proxyData.getUserId(), proxyData.getPassword())); 71 | } 72 | return proxy; 73 | } 74 | 75 | private IProxyData getProxyData(URI uri) { 76 | IProxyService proxyService = getProxyService(); 77 | if (proxyService != null && proxyService.isProxiesEnabled()) { 78 | if (!proxyService.isSystemProxiesEnabled()) { 79 | IProxyData[] proxies = proxyService.select(uri); 80 | if (proxies.length > 0) { 81 | return proxies[0]; 82 | } 83 | } 84 | } 85 | return null; 86 | } 87 | 88 | private boolean isProxiesEnabled() { 89 | IProxyService proxyService = getProxyService(); 90 | if (proxyService != null && proxyService.isProxiesEnabled()) 91 | return true; 92 | return false; 93 | } 94 | 95 | /* (non-Javadoc) 96 | * @see com.googlecode.cppcheclipse.core.utils.IHttpClient#executeGetRequest(java.net.URL) 97 | */ 98 | public InputStream executeGetRequest(URL url) throws URISyntaxException, IOException { 99 | Proxy proxy = getProxy(url.toURI()); 100 | 101 | HttpURLConnection connection; 102 | if (proxy != null) 103 | connection = (HttpURLConnection) url.openConnection(proxy); 104 | else 105 | connection = (HttpURLConnection) url.openConnection(); 106 | connection.setRequestMethod("GET"); 107 | connection.setDoOutput(true); 108 | connection.setReadTimeout(10000); 109 | if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { 110 | throw new IOException("Wrong response code: " 111 | + connection.getResponseMessage()); 112 | } 113 | return connection.getInputStream(); 114 | } 115 | 116 | /** 117 | * Binds the {@link IProxyService} service reference. 118 | * 119 | * @param proxyService the {@link IProxyService} service reference to bind 120 | */ 121 | protected void bindProxyService(IProxyService proxyService) { 122 | this.proxyService = proxyService; 123 | } 124 | 125 | /** 126 | * Unbinds the {@link IProxyService} service reference. 127 | * 128 | * @param proxyService 129 | * the {@link IProxyService} service reference to unbind 130 | */ 131 | protected void unbindProxyService(IProxyService proxyService) { 132 | this.proxyService = null; 133 | } 134 | 135 | /** 136 | * Gets the {@link IProxyService} instance. 137 | * 138 | * @return the {@link IProxyService} instance 139 | */ 140 | protected IProxyService getProxyService() { 141 | return proxyService; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Checker.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.IOException; 4 | import java.net.URISyntaxException; 5 | import java.util.LinkedList; 6 | import java.util.List; 7 | 8 | import javax.xml.parsers.ParserConfigurationException; 9 | import javax.xml.xpath.XPathExpressionException; 10 | 11 | import org.eclipse.core.resources.IFile; 12 | import org.eclipse.core.resources.IProject; 13 | import org.eclipse.core.runtime.CoreException; 14 | import org.eclipse.core.runtime.IProgressMonitor; 15 | import org.eclipse.jface.preference.IPreferenceStore; 16 | import org.xml.sax.SAXException; 17 | 18 | import com.googlecode.cppcheclipse.core.command.CppcheckCommand; 19 | import com.googlecode.cppcheclipse.core.command.ProcessExecutionException; 20 | import com.googlecode.cppcheclipse.core.utils.PathMacroReplacer; 21 | 22 | /** 23 | * This class should abstract from the eclipse concepts for easier testability. 24 | * 25 | * @author kwindszus 26 | * 27 | */ 28 | public class Checker { 29 | 30 | private final ProblemProfile profile; 31 | private final CppcheckCommand command; 32 | private final IProblemReporter problemReporter; 33 | private final SuppressionProfile suppressionProfile; 34 | private final IProject project; 35 | private List files; 36 | 37 | public Checker(IConsole console, IPreferenceStore projectPreferences, 38 | IPreferenceStore workspacePreferences, IProject project, 39 | IToolchainSettings toolchainSettings, 40 | IProblemReporter problemReporter) throws XPathExpressionException, 41 | IOException, InterruptedException, ParserConfigurationException, 42 | SAXException, CloneNotSupportedException, ProcessExecutionException { 43 | 44 | // check if we should use project or workspace preferences (for 45 | // problems) 46 | IPreferenceStore problemPreferences = projectPreferences; 47 | boolean useWorkspacePreferences = projectPreferences 48 | .getBoolean(IPreferenceConstants.PROBLEMS_PAGE_ID 49 | + IPreferenceConstants.P_USE_PARENT_SUFFIX); 50 | 51 | if (useWorkspacePreferences) { 52 | problemPreferences = workspacePreferences; 53 | } 54 | 55 | profile = CppcheclipsePlugin.getNewProblemProfile(console, 56 | problemPreferences); 57 | 58 | // check if we should use project or workspace preferences (for 59 | // settings) 60 | IPreferenceStore settingsPreferences = projectPreferences; 61 | useWorkspacePreferences = projectPreferences 62 | .getBoolean(IPreferenceConstants.SETTINGS_PAGE_ID 63 | + IPreferenceConstants.P_USE_PARENT_SUFFIX); 64 | 65 | if (useWorkspacePreferences) { 66 | settingsPreferences = workspacePreferences; 67 | } 68 | 69 | Symbols symbols; 70 | // restrict configurations to the given macros 71 | if (projectPreferences.getBoolean(IPreferenceConstants.P_RESTRICT_CONFIGURATION_CHECK)) { 72 | symbols = new Symbols(projectPreferences, toolchainSettings); 73 | } else { 74 | symbols = new Symbols(); 75 | } 76 | 77 | String binaryPath = PathMacroReplacer.performMacroSubstitution(CppcheclipsePlugin.getConfigurationPreferenceStore() 78 | .getString(IPreferenceConstants.P_BINARY_PATH)); 79 | 80 | command = new CppcheckCommand(console, binaryPath, settingsPreferences, 81 | projectPreferences, toolchainSettings.getUserIncludes(), toolchainSettings.getSystemIncludes(), symbols); 82 | this.problemReporter = problemReporter; 83 | suppressionProfile = new SuppressionProfile(projectPreferences, project); 84 | 85 | files = new LinkedList(); 86 | this.project = project; 87 | } 88 | 89 | public void addFile(IFile file) throws CoreException { 90 | if (suppressionProfile.isFileSuppressed(file.getLocation().toFile())) 91 | return; 92 | if (file.getProject() != project) { 93 | throw new IllegalArgumentException( 94 | "Only files within the project are valid"); 95 | } 96 | problemReporter.deleteMarkers(file, true); 97 | files.add(file); 98 | } 99 | 100 | public void run(IProgressMonitor monitor, IProgressReporter progressReporter) throws XPathExpressionException, 101 | ParserConfigurationException, SAXException, IOException, 102 | InterruptedException, ProcessExecutionException, CoreException, URISyntaxException { 103 | if (files.isEmpty()) { 104 | return; 105 | } 106 | 107 | // TODO: always reset external resource markers (since we have no way of identifying why this external resource was checked so far) 108 | problemReporter.deleteMarkers(project, false); 109 | command.run(this, progressReporter, project, files, monitor); 110 | } 111 | 112 | /** 113 | * Callback, called from CppcheckCommand 114 | * 115 | * @param problems 116 | * @throws CoreException 117 | */ 118 | public void reportProblems(List problems) throws CoreException { 119 | // display each problem 120 | profile.reportProblems(problems, problemReporter, suppressionProfile); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/ProblemReporter.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.marker; 2 | 3 | import java.io.File; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.eclipse.core.resources.IMarker; 8 | import org.eclipse.core.resources.IResource; 9 | import org.eclipse.core.resources.ResourcesPlugin; 10 | import org.eclipse.core.runtime.CoreException; 11 | import org.eclipse.ui.texteditor.MarkerUtilities; 12 | 13 | import com.googlecode.cppcheclipse.core.IProblemReporter; 14 | import com.googlecode.cppcheclipse.core.Problem; 15 | import com.googlecode.cppcheclipse.ui.Messages; 16 | 17 | public class ProblemReporter implements IProblemReporter { 18 | 19 | private static final String CHECKER_MARKER_TYPE = "com.googlecode.cppcheclipse.Problem"; //$NON-NLS-1$ 20 | 21 | // some additional attributes (which must be specified in plugin.xml as 22 | // well) 23 | public static final String ATTRIBUTE_ID = "problemId"; //$NON-NLS-1$ 24 | public static final String ATTRIBUTE_ORIGINAL_LINE_NUMBER = "originalLineNumber"; //$NON-NLS-1$ 25 | public static final String ATTRIBUTE_FILE = "file"; //$NON-NLS-1$ 26 | 27 | public ProblemReporter() { 28 | } 29 | 30 | /* 31 | * (non-Javadoc) 32 | * 33 | * @see 34 | * com.googlecode.cppcheclipse.ui.marker.IProblemReporter#reportProblem( 35 | * com.googlecode.cppcheclipse.core.Problem) 36 | */ 37 | public void reportProblem(Problem problem) throws CoreException { 38 | final StringBuffer message = new StringBuffer(); 39 | final int lineNumber; 40 | if (problem.isExternalFile()) { 41 | message.append(Messages.bind( 42 | Messages.ProblemReporter_ProblemInExternalFile, 43 | problem.getFile(), problem.getLineNumber())); 44 | lineNumber = 0; 45 | } else { 46 | lineNumber = problem.getLineNumber(); 47 | } 48 | message.append(problem.getMessage()); 49 | final String completeMessage = Messages.bind( 50 | Messages.ProblemReporter_Message, problem.getCategory(), 51 | message); 52 | for (IResource resource : problem.getResources()) { 53 | // for each resource 54 | reportProblem(resource, completeMessage, problem 55 | .getSeverity().intValue(), lineNumber, problem.getId(), 56 | problem.getFile(), problem.getLineNumber()); 57 | } 58 | } 59 | 60 | private void reportProblem(IResource resource, String message, 61 | int severity, int lineNumber, String id, File file, 62 | int originalLineNumber) throws CoreException { 63 | // TODO: open external file, see 64 | // https://bugs.eclipse.org/bugs/show_bug.cgi?id=151005 on how to 65 | // generate markers for external files 66 | 67 | // Do not put in duplicates 68 | IMarker[] cur = resource.findMarkers(CHECKER_MARKER_TYPE, false, 69 | IResource.DEPTH_ZERO); 70 | if (cur != null) { 71 | for (IMarker element : cur) { 72 | int oldLineNumber = element 73 | .getAttribute(IMarker.LINE_NUMBER, 0); 74 | if (lineNumber == oldLineNumber) { 75 | String oldMessage = element.getAttribute(IMarker.MESSAGE, 76 | ""); //$NON-NLS-1$ 77 | int oldSeverity = element.getAttribute(IMarker.SEVERITY, 78 | 100); 79 | if (severity == oldSeverity && message.equals(oldMessage)) 80 | return; 81 | } 82 | } 83 | } 84 | 85 | // see 86 | // http://wiki.eclipse.org/FAQ_Why_don%27t_my_markers_appear_in_the_editor%27s_vertical_ruler%3F 87 | Map attributes = new HashMap(); 88 | if (lineNumber != 0) { 89 | MarkerUtilities.setLineNumber(attributes, lineNumber); 90 | } 91 | MarkerUtilities.setMessage(attributes, message); 92 | attributes.put(IMarker.SEVERITY, severity); 93 | // the following attributes are only used for the quick fixes 94 | attributes.put(ATTRIBUTE_ID, id); 95 | if (file != null) { 96 | attributes.put(ATTRIBUTE_FILE, file.toString()); 97 | } 98 | attributes.put(ATTRIBUTE_ORIGINAL_LINE_NUMBER, originalLineNumber); 99 | MarkerUtilities.createMarker(resource, attributes, CHECKER_MARKER_TYPE); 100 | } 101 | 102 | /* 103 | * (non-Javadoc) 104 | * 105 | * @see 106 | * com.googlecode.cppcheclipse.ui.marker.IProblemReporter#deleteMarkers( 107 | * org.eclipse.core.resources.IResource) 108 | */ 109 | public void deleteMarkers(IResource file, boolean isRecursive) 110 | throws CoreException { 111 | final int depth; 112 | if (isRecursive) { 113 | depth = IResource.DEPTH_INFINITE; 114 | } else { 115 | depth = IResource.DEPTH_ZERO; 116 | } 117 | file.deleteMarkers(CHECKER_MARKER_TYPE, true, depth); 118 | } 119 | 120 | /* 121 | * (non-Javadoc) 122 | * 123 | * @see 124 | * com.googlecode.cppcheclipse.ui.marker.IProblemReporter#deleteAllMarkers() 125 | */ 126 | public void deleteAllMarkers() throws CoreException { 127 | ResourcesPlugin 128 | .getWorkspace() 129 | .getRoot() 130 | .deleteMarkers(CHECKER_MARKER_TYPE, true, 131 | IResource.DEPTH_INFINITE); 132 | 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/SymbolsTable.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.jface.dialogs.Dialog; 4 | import org.eclipse.jface.viewers.ILabelProviderListener; 5 | import org.eclipse.jface.viewers.ITableLabelProvider; 6 | import org.eclipse.swt.SWT; 7 | import org.eclipse.swt.events.SelectionAdapter; 8 | import org.eclipse.swt.events.SelectionEvent; 9 | import org.eclipse.swt.graphics.Image; 10 | import org.eclipse.swt.widgets.Button; 11 | import org.eclipse.swt.widgets.Composite; 12 | 13 | import com.googlecode.cppcheclipse.core.Symbol; 14 | import com.googlecode.cppcheclipse.core.Symbols; 15 | import com.googlecode.cppcheclipse.ui.ToolchainSettings; 16 | 17 | public class SymbolsTable extends TableEditor { 18 | 19 | private final ToolchainSettings settings; 20 | private Button removeButton, removeAllButton, editButton; 21 | 22 | static enum TableColumn { 23 | Name, Value, CDTDefined, SystemDefined; 24 | } 25 | 26 | public SymbolsTable(String name, String labelText, Composite parent, 27 | ToolchainSettings settings) { 28 | super(name, labelText, parent); 29 | 30 | getTableViewer(parent).getTable().setHeaderVisible(true); 31 | getTableViewer(parent).getTable().setLinesVisible(true); 32 | 33 | // in the same order as the enum TableColumn 34 | addColumn(new ExtendedTableColumn("Name", SWT.LEFT, 150)); 35 | addColumn(new ExtendedTableColumn("Value", SWT.LEFT, 350)); 36 | addColumn(new ExtendedTableColumn("CDT", SWT.LEFT, 40)); 37 | addColumn(new ExtendedTableColumn("System", SWT.LEFT, 40)); 38 | 39 | getTableViewer(parent).setLabelProvider(new LabelProvider()); 40 | this.settings = settings; 41 | } 42 | 43 | private class LabelProvider implements ITableLabelProvider { 44 | 45 | public Image getColumnImage(Object element, int columnIndex) { 46 | return null; 47 | } 48 | 49 | public String getColumnText(Object element, int columnIndex) { 50 | String text = ""; //$NON-NLS-1$ 51 | Symbol symbol = (Symbol) element; 52 | TableColumn column = TableColumn.values()[columnIndex]; 53 | switch (column) { 54 | case Name: 55 | text = symbol.getName(); 56 | break; 57 | case Value: 58 | text = symbol.getValue(); 59 | break; 60 | case CDTDefined: 61 | if (symbol.isCDTDefined()) { 62 | text = "yes"; 63 | } else { 64 | text = "no"; 65 | } 66 | break; 67 | case SystemDefined: 68 | if (symbol.isSystemDefined()) { 69 | text = "yes"; 70 | } else { 71 | text = "no"; 72 | } 73 | } 74 | return text; 75 | } 76 | 77 | public void addListener(ILabelProviderListener listener) { 78 | } 79 | 80 | public void dispose() { 81 | } 82 | 83 | public boolean isLabelProperty(Object element, String property) { 84 | return false; 85 | } 86 | 87 | public void removeListener(ILabelProviderListener listener) { 88 | } 89 | } 90 | 91 | @Override 92 | protected Symbols createModel() { 93 | // get predefined symbols 94 | Symbols symbols = new Symbols(getPreferenceStore(), settings); 95 | /* 96 | * if (includeCDTSystemSymbols.getBooleanValue()) { 97 | * symbols.addSymbols(settings.getSymbols(true)); } if 98 | * (includeCDTUserSymbols.getBooleanValue()) { 99 | * symbols.addSymbols(settings.getSymbols(false)); } 100 | */ 101 | return symbols; 102 | } 103 | 104 | @Override 105 | protected void createButtons(Composite box) { 106 | // add symbol 107 | createPushButton(box, "Add", new SelectionAdapter() { 108 | @Override 109 | public void widgetSelected(SelectionEvent e) { 110 | addPressed(); 111 | } 112 | }); 113 | 114 | // remove symbol 115 | editButton = createPushButton(box, "Edit", new SelectionAdapter() { 116 | @Override 117 | public void widgetSelected(SelectionEvent e) { 118 | editPressed(); 119 | } 120 | }); 121 | 122 | // remove symbol 123 | removeButton = createPushButton(box, "Remove", new SelectionAdapter() { 124 | @Override 125 | public void widgetSelected(SelectionEvent e) { 126 | removePressed(); 127 | } 128 | }); 129 | 130 | // remove all 131 | removeAllButton = createPushButton(box, "Remove All", 132 | new SelectionAdapter() { 133 | @Override 134 | public void widgetSelected(SelectionEvent e) { 135 | removeAllPressed(); 136 | } 137 | }); 138 | } 139 | 140 | protected void removeAllPressed() { 141 | getModel().removeUserSymbols(); 142 | getTableViewer().refresh(); 143 | } 144 | 145 | private void addPressed() { 146 | // open new dialog 147 | SymbolEditDialog dialog = new SymbolEditDialog(getPage().getShell(), 148 | "Add new symbol"); 149 | if (dialog.open() == Dialog.OK) { 150 | 151 | getModel().addSymbol( 152 | new Symbol(dialog.getName(), dialog.getValue())); 153 | getTableViewer().refresh(); 154 | } 155 | } 156 | 157 | private void editPressed() { 158 | // open new dialog 159 | SymbolEditDialog dialog = new SymbolEditDialog(getPage().getShell(), 160 | "Edit symbol"); 161 | Symbol symbol = (Symbol) getSelection().getSelection() 162 | .getFirstElement(); 163 | if (symbol != null) { 164 | dialog.setName(symbol.getName()); 165 | dialog.setValue(symbol.getValue()); 166 | if (dialog.open() == Dialog.OK) { 167 | symbol.setName(dialog.getName()); 168 | symbol.setValue(dialog.getValue()); 169 | getTableViewer().refresh(); 170 | } 171 | } 172 | } 173 | 174 | protected void selectionChanged(IterableStructuredSelection selection) { 175 | // check all elements 176 | // if some is CDT defined disable 177 | for (Symbol symbol : selection) { 178 | if (symbol.isCDTDefined()) { 179 | removeAllButton.setEnabled(false); 180 | removeButton.setEnabled(false); 181 | editButton.setEnabled(false); 182 | return; 183 | } 184 | removeAllButton.setEnabled(true); 185 | removeButton.setEnabled(true); 186 | editButton.setEnabled(true); 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/SuppressionsTable.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import java.io.File; 4 | 5 | import org.eclipse.core.resources.IProject; 6 | import org.eclipse.core.resources.IResource; 7 | import org.eclipse.core.runtime.CoreException; 8 | import org.eclipse.jface.viewers.ILabelProviderListener; 9 | import org.eclipse.jface.viewers.ITableLabelProvider; 10 | import org.eclipse.swt.SWT; 11 | import org.eclipse.swt.events.SelectionAdapter; 12 | import org.eclipse.swt.events.SelectionEvent; 13 | import org.eclipse.swt.graphics.Image; 14 | import org.eclipse.swt.widgets.Composite; 15 | 16 | import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; 17 | import com.googlecode.cppcheclipse.core.ProblemProfile; 18 | import com.googlecode.cppcheclipse.core.Suppression; 19 | import com.googlecode.cppcheclipse.core.SuppressionProfile; 20 | import com.googlecode.cppcheclipse.ui.Console; 21 | import com.googlecode.cppcheclipse.ui.Messages; 22 | import com.googlecode.cppcheclipse.ui.marker.ProblemReporter; 23 | 24 | public class SuppressionsTable extends 25 | TableEditor { 26 | 27 | private ProblemProfile problemProfile; 28 | private final IProject project; 29 | 30 | static enum TableColumn { 31 | Filename, Problem, Line; 32 | } 33 | 34 | public SuppressionsTable(String name, String labelText, Composite parent, 35 | IProject project) { 36 | super(name, labelText, parent); 37 | 38 | getTableViewer(parent).getTable().setHeaderVisible(true); 39 | getTableViewer(parent).getTable().setLinesVisible(true); 40 | // in the same order as the enum TableColumn 41 | addColumn(new ExtendedTableColumn( 42 | Messages.SuppressionsTable_ColumnFilename, SWT.LEFT, 150)); 43 | addColumn(new ExtendedTableColumn( 44 | Messages.SuppressionsTable_ColumnProblem, SWT.LEFT, 400)); 45 | addColumn(new ExtendedTableColumn( 46 | Messages.SuppressionsTable_ColumnLine, SWT.LEFT, 50)); 47 | 48 | getTableViewer(parent).setLabelProvider(new LabelProvider()); 49 | this.project = project; 50 | } 51 | 52 | private class LabelProvider implements ITableLabelProvider { 53 | 54 | public Image getColumnImage(Object element, int columnIndex) { 55 | return null; 56 | } 57 | 58 | public String getColumnText(Object element, int columnIndex) { 59 | String text = ""; //$NON-NLS-1$ 60 | Suppression suppression = (Suppression) element; 61 | TableColumn column = TableColumn.values()[columnIndex]; 62 | switch (column) { 63 | case Filename: 64 | text = suppression.getFile(false, project).toString(); 65 | break; 66 | case Problem: 67 | if (suppression.isFileSuppression()) { 68 | text = Messages.SuppressionsTable_AllProblems; 69 | } else { 70 | text = problemProfile.getProblemMessage(suppression 71 | .getProblemId()); 72 | } 73 | break; 74 | case Line: 75 | if (suppression.isAllLines()) { 76 | text = Messages.SuppressionsTable_AllLines; 77 | } else { 78 | text = String.valueOf(suppression.getLine()); 79 | } 80 | } 81 | return text; 82 | } 83 | 84 | public void addListener(ILabelProviderListener listener) { 85 | } 86 | 87 | public void dispose() { 88 | } 89 | 90 | public boolean isLabelProperty(Object element, String property) { 91 | return false; 92 | } 93 | 94 | public void removeListener(ILabelProviderListener listener) { 95 | } 96 | 97 | } 98 | 99 | @Override 100 | protected void createButtons(Composite box) { 101 | createPushButton(box, Messages.TableEditor_Add, new SelectionAdapter() { 102 | @Override 103 | public void widgetSelected(SelectionEvent e) { 104 | addPressed(); 105 | } 106 | }); 107 | createPushButton(box, Messages.TableEditor_AddExternal, 108 | new SelectionAdapter() { 109 | @Override 110 | public void widgetSelected(SelectionEvent e) { 111 | addExternalPressed(); 112 | } 113 | }); 114 | createPushButton(box, Messages.TableEditor_Remove, 115 | new SelectionAdapter() { 116 | @Override 117 | public void widgetSelected(SelectionEvent e) { 118 | removePressed(); 119 | } 120 | }); 121 | createPushButton(box, Messages.TableEditor_RemoveAll, 122 | new SelectionAdapter() { 123 | @Override 124 | public void widgetSelected(SelectionEvent e) { 125 | removeAllPressed(); 126 | } 127 | }); 128 | } 129 | 130 | protected void addPressed() { 131 | IResource file = openProjectFile(Messages.SuppressionsTable_FileSelection, 132 | Messages.SuppressionsTable_FileSelectionMessage, project, true); 133 | if (file != null) { 134 | SuppressionProfile profile = getModel(); 135 | Suppression suppression = profile.addFileSuppression(file 136 | .getProjectRelativePath().toFile()); 137 | try { 138 | new ProblemReporter().deleteMarkers(file, true); 139 | } catch (CoreException e) { 140 | CppcheclipsePlugin.logError("Could not delete error markers", e); 141 | } 142 | getTableViewer().add(suppression); 143 | } 144 | } 145 | 146 | protected void addExternalPressed() { 147 | File file = openExternalFile(Messages.SuppressionsTable_FileSelection); 148 | if (file != null) { 149 | SuppressionProfile profile = getModel(); 150 | Suppression suppression = profile.addFileSuppression(file); 151 | try { 152 | new ProblemReporter().deleteMarkers(project, false); 153 | } catch (CoreException e) { 154 | CppcheclipsePlugin.logError("Could not delete problem markers", e); 155 | } 156 | getTableViewer().add(suppression); 157 | } 158 | } 159 | 160 | @Override 161 | protected SuppressionProfile createModel() { 162 | SuppressionProfile profile = new SuppressionProfile( 163 | getPreferenceStore(), project); 164 | try { 165 | problemProfile = CppcheclipsePlugin.getNewProblemProfile( 166 | Console.getInstance(), getPreferenceStore()); 167 | } catch (Exception e) { 168 | CppcheclipsePlugin.logError("Could not load problem profile", e); 169 | } 170 | return profile; 171 | } 172 | 173 | } 174 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/Messages.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui; 2 | 3 | import org.eclipse.osgi.util.NLS; 4 | 5 | public class Messages extends NLS { 6 | private static final String BUNDLE_NAME = "com.googlecode.cppcheclipse.ui.messages"; //$NON-NLS-1$ 7 | 8 | public static String AppendagePropertyPage_AppendageLabel; 9 | public static String AppendagePropertyPage_Description; 10 | public static String AppendageTable_ColumnFile; 11 | public static String AppendageTable_FileSelection; 12 | public static String AppendageTable_FileSelectionMessage; 13 | public static String UpdateCheck_Daily, UpdateCheck_JobName, 14 | UpdateCheck_Monthly, UpdateCheck_NoUpdateMessage, 15 | UpdateCheck_NoUpdateTitle, 16 | UpdateCheck_UpdateMessage, UpdateCheck_UpdateTitle, 17 | UpdateCheck_Weekly; 18 | public static String OverlayPage_UseWorkspaceSettings, 19 | OverlayPage_UseProjectSettings, 20 | OverlayPage_ConfigureWorkspaceSettings; 21 | public static String BinaryPathPreferencePage_AskBeforeLeaveMessage; 22 | public static String BinaryPathPreferencePage_AskBeforeLeaveTitle; 23 | public static String BinaryPathPreferencePage_AutomaticUpdateCheck; 24 | public static String BinaryPathPreferencePage_ButtonDiscard; 25 | public static String BinaryPathPreferencePage_ButtonSave; 26 | public static String BinaryPathPreferencePage_CheckForUpdate; 27 | public static String BinaryPathPreferencePage_Description; 28 | public static String BinaryPathPreferencePage_FileDialogButton; 29 | public static String BinaryPathPreferencePage_FileDialogTitle; 30 | public static String BinaryPathPreferencePage_NoValidPath; 31 | public static String BinaryPathPreferencePage_PathToBinary; 32 | public static String BinaryPathPreferencePage_UnknownVersion; 33 | public static String BinaryPathPreferencePage_UpdateCheckNever; 34 | public static String BinaryPathPreferencePage_UpdateCheckNotice; 35 | public static String BinaryPathPreferencePage_UpdateInterval; 36 | public static String BinaryPathPreferencePage_VariablesButton; 37 | 38 | public static String BinaryPathPreferencePage_VersionTooOld; 39 | public static String BinaryPathPreferencePage_LinkToCppcheck; 40 | public static String Builder_IncrementalBuilderTask; 41 | public static String Builder_PathEmptyMessage; 42 | public static String Builder_PathEmptyTitle; 43 | public static String Builder_ResouceVisitorTask; 44 | public static String BuildPropertyPage_Description; 45 | public static String BuildPropertyPage_RunOnBuild; 46 | public static String Console_Title; 47 | public static String ProblemReporter_ProblemInExternalFile; 48 | public static String ProblemReporter_Message; 49 | public static String ProblemsPreferencePage_Description; 50 | public static String ProblemsTreeEditor_Name; 51 | public static String ProblemsTreeEditor_Problems; 52 | public static String ProblemsTreeEditor_Severity; 53 | public static String ProgressReporter_TaskName; 54 | public static String ReportBug_Label; 55 | public static String RunCodeAnalysis_Error; 56 | public static String RunCodeAnalysis_JobName; 57 | 58 | public static String ClearMarkers_Error; 59 | public static String ClearMarkers_JobName; 60 | 61 | public static String SettingsPreferencePage_CheckAll; 62 | public static String SettingsPreferencePage_CheckPerformance; 63 | public static String SettingsPreferencePage_CheckPortability; 64 | public static String SettingsPreferencePage_CheckInformation; 65 | public static String SettingsPreferencePage_CheckMissingInclude; 66 | public static String SettingsPreferencePage_CheckStyle; 67 | public static String SettingsPreferencePage_Description; 68 | public static String SettingsPreferencePage_FollowUserIncludes; 69 | public static String SettingsPreferencePage_FollowSystemIncludes; 70 | public static String SettingsPreferencePage_Force; 71 | public static String SettingsPreferencePage_NumberOfThreads; 72 | public static String SettingsPreferencePage_UnusedFunctions; 73 | public static String SettingsPreferencePage_Verbose; 74 | public static String SuppressFileResolution_Label; 75 | public static String CheckDescriptionResolution_Label; 76 | public static String SuppressionsPropertyPage_Description; 77 | public static String SuppressionsPropertyPage_SuppressionsLabel; 78 | public static String SuppressionsTable_AllLines; 79 | public static String SuppressionsTable_AllProblems; 80 | public static String SuppressionsTable_ColumnFilename; 81 | public static String SuppressionsTable_ColumnLine; 82 | public static String SuppressionsTable_ColumnProblem; 83 | public static String SuppressionsTable_FileSelection; 84 | public static String TableEditor_FileSelectionErrorExactlyOne; 85 | public static String TableEditor_FileSelectionErrorFile; 86 | public static String TableEditor_FileSelectionErrorFileFolder; 87 | public static String SuppressionsTable_FileSelectionMessage; 88 | public static String SuppressProblemInLineResolution_Label; 89 | public static String SuppressProblemResolution_Label; 90 | public static String TableEditor_Add; 91 | public static String TableEditor_Remove; 92 | public static String TableEditor_RemoveAll; 93 | public static String TableEditor_AddExternal; 94 | public static String UpdateCheck_NeverCheckAgain; 95 | 96 | public static String AdvancedSettingsPropertyPage_AdvancedArguments; 97 | public static String AdvancedSettingsPropertyPage_Description; 98 | public static String SettingsPreferencePage_Debug; 99 | public static String SettingsPreferencePage_ChecksLabel; 100 | public static String SettingsPreferencePage_InlineSuppressions; 101 | 102 | public static String SymbolsPropertyPage_Description; 103 | 104 | public static String SettingsPreferencePage_Inconclusive; 105 | 106 | public static String SettingsPreferencePage_TargetPlatform; 107 | 108 | public static String SettingsPreferencePage_LanguageStandard_Posix; 109 | 110 | public static String SettingsPreferencePage_LanguageStandard_C99; 111 | 112 | public static String SettingsPreferencePage_LanguageStandardsLabel; 113 | 114 | static { 115 | // initialize resource bundle 116 | NLS.initializeMessages(BUNDLE_NAME, Messages.class); 117 | } 118 | 119 | private Messages() { 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Problem.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.core; 2 | 3 | import java.io.File; 4 | import java.net.URI; 5 | import java.util.Arrays; 6 | import java.util.Collection; 7 | import java.util.LinkedList; 8 | import java.util.NoSuchElementException; 9 | import java.util.StringTokenizer; 10 | 11 | import org.eclipse.core.resources.IFile; 12 | import org.eclipse.core.resources.IMarker; 13 | import org.eclipse.core.resources.IProject; 14 | import org.eclipse.core.resources.IResource; 15 | import org.eclipse.core.resources.IWorkspaceRoot; 16 | import org.eclipse.core.resources.ResourcesPlugin; 17 | 18 | public class Problem implements Cloneable { 19 | private static final String DELIMITER = ";"; 20 | 21 | private final String id, message, category; 22 | private final int lineNumber; 23 | private final File file; // either absolute or relative filename (to 24 | // project), maybe null for problem profiles or 25 | // project related problems 26 | private boolean isEnabled; 27 | private ProblemSeverity severity; // a severity which can be used as 28 | // severity in IMarker 29 | private final IProject project; 30 | private Collection resources; 31 | 32 | /** 33 | * Constructor is called for default problems (in problem profiles). 34 | */ 35 | public Problem(String id, String message, String category) { 36 | this(id, message, category, null, null, -1); 37 | } 38 | 39 | /** 40 | * Constructor is called for specific problems in files. 41 | * 42 | * @param id 43 | * @param message 44 | * @param category 45 | * @param filename 46 | * (might be null for non file-specific problems) 47 | * @param project 48 | * @param line 49 | * (might be 0 for non line-specific problems) 50 | */ 51 | public Problem(String id, String message, String category, File file, 52 | IProject project, int line) { 53 | this.id = id; 54 | this.message = message; 55 | this.category = category; 56 | this.lineNumber = line; 57 | this.file = file; 58 | this.project = project; 59 | setToDefault(); 60 | } 61 | 62 | public void setToDefault() { 63 | // standard values for non-final fields 64 | this.isEnabled = true; 65 | this.severity = ProblemSeverity.fromCategory(category); 66 | } 67 | 68 | public String getId() { 69 | return id; 70 | } 71 | 72 | public String getMessage() { 73 | return message; 74 | } 75 | 76 | public String getCategory() { 77 | return category; 78 | } 79 | 80 | public ProblemSeverity getSeverity() { 81 | return severity; 82 | } 83 | 84 | public void setSeverity(ProblemSeverity severity) { 85 | this.severity = severity; 86 | } 87 | 88 | /** 89 | * 90 | * @return a collection of resources which are associated with this problem. 91 | * The collection might be empty. 92 | */ 93 | public Collection getResources() { 94 | if (resources == null) { 95 | resources = new LinkedList(); 96 | if (file != null) { 97 | URI fileUri; 98 | if (!file.isAbsolute()) { 99 | // make file absolute and convert to URI (does not work the 100 | // other way round, because File.toURI always returns an 101 | // absolute URI 102 | fileUri = new File(new File(project.getLocationURI() 103 | .getPath()), file.toString()).toURI(); 104 | } else { 105 | fileUri = file.toURI(); 106 | } 107 | 108 | // find file in workspace (absolute path) 109 | IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 110 | 111 | // consider linked paths also 112 | IFile[] file = root.findFilesForLocationURI(fileUri); 113 | resources.addAll(Arrays.asList(file)); 114 | } 115 | if (resources.isEmpty()) { 116 | // if no resource could be resolved take project 117 | resources.add(project); 118 | } 119 | } 120 | return resources; 121 | } 122 | 123 | public File getFile() { 124 | return file; 125 | } 126 | 127 | /** 128 | * 129 | * @return a positive line number or 0 if there is no linenumber associated 130 | * with this problem 131 | */ 132 | public int getLineNumber() { 133 | return lineNumber; 134 | } 135 | 136 | public boolean isExternalFile() { 137 | // TODO: check 138 | return false; 139 | } 140 | 141 | public boolean isEnabled() { 142 | return isEnabled; 143 | } 144 | 145 | public void setEnabled(boolean isEnabled) { 146 | this.isEnabled = isEnabled; 147 | } 148 | 149 | @Override 150 | protected Object clone() throws CloneNotSupportedException { 151 | return super.clone(); 152 | } 153 | 154 | @Override 155 | public int hashCode() { 156 | final int prime = 31; 157 | int result = 1; 158 | result = prime * result + ((id == null) ? 0 : id.hashCode()); 159 | return result; 160 | } 161 | 162 | @Override 163 | public boolean equals(Object obj) { 164 | if (this == obj) 165 | return true; 166 | if (obj == null) 167 | return false; 168 | if (getClass() != obj.getClass()) 169 | return false; 170 | Problem other = (Problem) obj; 171 | if (id == null) { 172 | if (other.id != null) 173 | return false; 174 | } else if (!id.equals(other.id)) 175 | return false; 176 | return true; 177 | } 178 | 179 | public String serializeNonFinalFields() { 180 | StringBuffer serialization = new StringBuffer(); 181 | serialization.append(isEnabled).append(DELIMITER); 182 | serialization.append(severity.ordinal()).append(DELIMITER); 183 | return serialization.toString(); 184 | } 185 | 186 | public void deserializeNonFinalFields(String serialization) 187 | throws NoSuchElementException, IllegalArgumentException { 188 | StringTokenizer tokenizer = new StringTokenizer(serialization, 189 | DELIMITER); 190 | String token = tokenizer.nextToken(); 191 | boolean isEnabled = Boolean.parseBoolean(token); 192 | token = tokenizer.nextToken(); 193 | int severity = Integer.parseInt(token); 194 | // range check for severity 195 | if (severity < IMarker.SEVERITY_INFO 196 | || severity > IMarker.SEVERITY_ERROR) { 197 | throw new IllegalArgumentException( 198 | "Found invalid severity value of " 199 | + String.valueOf(severity)); 200 | } 201 | this.isEnabled = isEnabled; 202 | this.severity = ProblemSeverity.values()[severity]; 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/preferences/SymbolEditDialog.java: -------------------------------------------------------------------------------- 1 | package com.googlecode.cppcheclipse.ui.preferences; 2 | 3 | import org.eclipse.jface.dialogs.Dialog; 4 | import org.eclipse.jface.dialogs.IDialogConstants; 5 | import org.eclipse.swt.SWT; 6 | import org.eclipse.swt.events.ModifyEvent; 7 | import org.eclipse.swt.events.ModifyListener; 8 | import org.eclipse.swt.layout.GridData; 9 | import org.eclipse.swt.layout.GridLayout; 10 | import org.eclipse.swt.widgets.Composite; 11 | import org.eclipse.swt.widgets.Control; 12 | import org.eclipse.swt.widgets.Label; 13 | import org.eclipse.swt.widgets.Shell; 14 | import org.eclipse.swt.widgets.Text; 15 | 16 | /** 17 | * Edit dialog for symbols with two text fields 18 | * name and value. 19 | * Derived from InputDialog which only provides one input text field 20 | */ 21 | public class SymbolEditDialog extends Dialog { 22 | 23 | private final String title; 24 | private Text nameControl, valueControl; 25 | private String name, value; 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public void setValue(String value) { 32 | this.value = value; 33 | } 34 | 35 | public SymbolEditDialog(Shell parentShell, String title) { 36 | super(parentShell); 37 | this.title = title; 38 | this.name = ""; // default values 39 | this.value = ""; 40 | } 41 | 42 | protected Control createDialogArea(Composite parent) { 43 | // create new parent 44 | parent = (Composite)super.createDialogArea(parent); 45 | 46 | // create a composite with 2 column layout 47 | Composite composite = new Composite(parent, SWT.NONE); 48 | GridLayout layout = new GridLayout(2, false); 49 | composite.setLayout(layout); 50 | composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); 51 | 52 | // create new label and name fields 53 | Label label = new Label(composite, SWT.WRAP); 54 | label.setText("Name"); 55 | GridData data = new GridData(GridData.GRAB_HORIZONTAL 56 | | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL 57 | | GridData.VERTICAL_ALIGN_CENTER); 58 | //data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); 59 | label.setLayoutData(data); 60 | label.setFont(parent.getFont()); 61 | 62 | nameControl = new Text(composite, SWT.SINGLE | SWT.BORDER); 63 | nameControl.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL 64 | | GridData.HORIZONTAL_ALIGN_FILL)); 65 | nameControl.setText(name); 66 | nameControl.addModifyListener(new ModifyListener() { 67 | public void modifyText(ModifyEvent e) { 68 | validateInput(); 69 | } 70 | }); 71 | 72 | 73 | label = new Label(composite, SWT.WRAP); 74 | label.setText("Value"); 75 | data = new GridData(GridData.GRAB_HORIZONTAL 76 | | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL 77 | | GridData.VERTICAL_ALIGN_CENTER); 78 | //data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); 79 | label.setLayoutData(data); 80 | label.setFont(parent.getFont()); 81 | 82 | valueControl = new Text(composite, SWT.SINGLE | SWT.BORDER); 83 | valueControl.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL 84 | | GridData.HORIZONTAL_ALIGN_FILL)); 85 | valueControl.setText(value); 86 | valueControl.addModifyListener(new ModifyListener() { 87 | public void modifyText(ModifyEvent e) { 88 | //validateInput(); 89 | } 90 | }); 91 | 92 | // TODO: create new label and value fields 93 | return parent; 94 | } 95 | 96 | private void validateInput() { 97 | 98 | } 99 | 100 | @Override 101 | protected void configureShell(Shell shell) { 102 | super.configureShell(shell); 103 | if (title != null) { 104 | shell.setText(title); 105 | } 106 | } 107 | 108 | public String getName() { 109 | return name; 110 | } 111 | 112 | 113 | public String getValue() { 114 | return value; 115 | } 116 | 117 | 118 | /* 119 | * (non-Javadoc) Method declared on Dialog. 120 | */ 121 | protected void buttonPressed(int buttonId) { 122 | // need to persist the values, since they are inaccessible after the dialog is destroyed 123 | if (buttonId == IDialogConstants.OK_ID) { 124 | name = nameControl.getText(); 125 | value = valueControl.getText(); 126 | } else { 127 | name = null; 128 | value = null; 129 | } 130 | super.buttonPressed(buttonId); 131 | } 132 | 133 | /*@Override 134 | protected Control createDialogArea(Composite parent) { 135 | // create composite 136 | Composite composite = (Composite) super.createDialogArea(parent); 137 | // create message 138 | if (message != null) { 139 | Label label = new Label(composite, SWT.WRAP); 140 | label.setText(message); 141 | GridData data = new GridData(GridData.GRAB_HORIZONTAL 142 | | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL 143 | | GridData.VERTICAL_ALIGN_CENTER); 144 | data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); 145 | label.setLayoutData(data); 146 | label.setFont(parent.getFont()); 147 | } 148 | text = new Text(composite, getInputTextStyle()); 149 | text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL 150 | | GridData.HORIZONTAL_ALIGN_FILL)); 151 | text.addModifyListener(new ModifyListener() { 152 | public void modifyText(ModifyEvent e) { 153 | validateInput(); 154 | } 155 | }); 156 | errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP); 157 | errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL 158 | | GridData.HORIZONTAL_ALIGN_FILL)); 159 | errorMessageText.setBackground(errorMessageText.getDisplay() 160 | .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); 161 | // Set the error message text 162 | // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292 163 | setErrorMessage(errorMessage); 164 | 165 | applyDialogFont(composite); 166 | }*/ 167 | 168 | 169 | 170 | } 171 | -------------------------------------------------------------------------------- /com.googlecode.cppcheclipse.repository/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.googlecode.cppcheclipse.parent 8 | com.googlecode.cppcheclipse 9 | 1.1.2-SNAPSHOT 10 | ../com.googlecode.cppcheclipse.parent/pom.xml 11 | 12 | com.googlecode.cppcheclipse.repository 13 | eclipse-repository 14 | 15 | 16 | 17 | 18 | p2 19 | 20 | releases 21 | 22 | Composite Site for cppcheclipse 23 | 24 | 26 | cppcheclipse 27 | 29 | 30 | 31 | releases 32 | updates 33 | zipped 34 | 36 | ../../releases/ 37 | 38 | 39 | 40 | 41 | 44 | 45 | org.eclipse.tycho 46 | tycho-p2-repository-plugin 47 | ${tycho-version} 48 | 49 | ${project.artifactId}-${qualifiedVersion} 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | release-composite 59 | 60 | false 61 | 62 | 63 | 64 | 65 | 66 | maven-antrun-plugin 67 | ${maven-antrun-plugin.version} 68 | 69 | 70 | 71 | update-local-repository 72 | prepare-package 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | run 81 | 82 | 83 | 84 | 85 | 86 | deploy-repository 87 | verify 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | run 96 | 97 | 98 | 99 | 100 | 101 | 102 | org.eclipse.tycho.extras 103 | tycho-eclipserun-plugin 104 | ${tycho-version} 105 | 106 | 107 | 108 | -application org.eclipse.ant.core.antRunner -buildfile packaging-p2composite.ant p2.composite.add -Dsite.label="${site.label}" -Dproject.build.directory=${project.build.directory} -DunqualifiedVersion=${unqualifiedVersion} -DbuildQualifier=${buildQualifier} -Dchild.repository.path.prefix="${child.repository.path.prefix}" 109 | 110 | 111 | mars 112 | p2 113 | http://download.eclipse.org/releases/mars 114 | 115 | 116 | 117 | 118 | org.eclipse.ant.core 119 | eclipse-plugin 120 | 121 | 122 | org.apache.ant 123 | eclipse-plugin 124 | 125 | 126 | org.eclipse.equinox.p2.repository.tools 127 | eclipse-plugin 128 | 129 | 130 | org.eclipse.equinox.p2.core.feature 131 | eclipse-feature 132 | 133 | 134 | org.eclipse.equinox.p2.extras.feature 135 | eclipse-feature 136 | 137 | 138 | org.eclipse.equinox.ds 139 | eclipse-plugin 140 | 141 | 142 | 143 | 144 | 145 | add-p2-composite-repository 146 | package 147 | 148 | eclipse-run 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | --------------------------------------------------------------------------------