├── .gitignore
├── .mvn
└── extensions.xml
├── .project
├── .travis.yml
├── LICENSE
├── bundles
├── org.codechecker.eclipse.plugin
│ ├── .checkstyle
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ │ ├── org.eclipse.core.resources.prefs
│ │ ├── org.eclipse.jdt.core.prefs
│ │ └── org.eclipse.m2e.core.prefs
│ ├── META-INF
│ │ └── MANIFEST.MF
│ ├── build.properties
│ ├── contexts.xml
│ ├── icons
│ │ ├── analyze.png
│ │ ├── arrow_down.png
│ │ ├── arrow_left.png
│ │ ├── arrow_right.png
│ │ ├── arrow_up.png
│ │ ├── double_down.png
│ │ ├── double_left.png
│ │ ├── double_right.png
│ │ ├── double_up.png
│ │ ├── filter.png
│ │ └── sample.gif
│ ├── log4j.properties
│ ├── plugin.xml
│ └── src
│ │ └── org
│ │ └── codechecker
│ │ └── eclipse
│ │ └── plugin
│ │ ├── Activator.java
│ │ ├── CodeCheckerNature.java
│ │ ├── ExternalLogger.java
│ │ ├── Logger.java
│ │ ├── codechecker
│ │ ├── CodeChecker.java
│ │ ├── CodeCheckerFactory.java
│ │ ├── ICodeChecker.java
│ │ ├── ICodeCheckerFactory.java
│ │ ├── locator
│ │ │ ├── CodeCheckerLocatorFactory.java
│ │ │ ├── CodeCheckerLocatorService.java
│ │ │ ├── EnvCodeCheckerLocatorService.java
│ │ │ ├── InvalidCodeCheckerException.java
│ │ │ ├── PreBuiltCodeCheckerLocatorService.java
│ │ │ ├── ResolutionMethodTypes.java
│ │ │ └── package-info.java
│ │ └── package-info.java
│ │ ├── command
│ │ └── AddProjectNature.java
│ │ ├── config
│ │ ├── .CodeCheckerContext.java.swn
│ │ ├── CcConfiguration.java
│ │ ├── CcConfigurationBase.java
│ │ ├── CodeCheckerContext.java
│ │ ├── CommonGui.java
│ │ ├── Config.java
│ │ ├── EnvironmentVariables.java
│ │ ├── filter
│ │ │ ├── Filter.java
│ │ │ ├── FilterConfiguration.java
│ │ │ └── store
│ │ │ │ └── FilterStore.java
│ │ ├── global
│ │ │ ├── CcGlobalConfiguration.java
│ │ │ ├── CcGlobalProperties.java
│ │ │ └── package-info.java
│ │ ├── package-info.java
│ │ └── project
│ │ │ ├── CcProjectProperties.java
│ │ │ ├── CodeCheckerProject.java
│ │ │ └── package-info.java
│ │ ├── init
│ │ ├── EditorPartListener.java
│ │ ├── ProjectExplorerSelectionListener.java
│ │ └── StartupJob.java
│ │ ├── perspective
│ │ └── CodeCheckerPerspectiveFactory.java
│ │ ├── report
│ │ ├── BugPathItem.java
│ │ ├── FileInfo.java
│ │ ├── Listener.java
│ │ ├── PlistParser.java
│ │ ├── ProblemInfo.java
│ │ ├── ReportInfo.java
│ │ ├── ReportParser.java
│ │ ├── ResultCount.java
│ │ ├── ResultFilter.java
│ │ ├── ResultList.java
│ │ ├── RunInfo.java
│ │ ├── SearchList.java
│ │ ├── SearchListener.java
│ │ ├── Severity.java
│ │ ├── job
│ │ │ ├── AnalyzeJob.java
│ │ │ ├── JobDoneChangeListener.java
│ │ │ ├── PlistParseJob.java
│ │ │ └── package-info.java
│ │ └── package-info.java
│ │ ├── runtime
│ │ ├── IShellExecutorHelperFactory.java
│ │ ├── LogI.java
│ │ ├── OnCheckCallback.java
│ │ ├── SLogger.java
│ │ ├── ShellExecutorHelper.java
│ │ ├── ShellExecutorHelperFactory.java
│ │ └── package-info.java
│ │ └── views
│ │ ├── config
│ │ └── filter
│ │ │ ├── FilterConfigurationDialog.java
│ │ │ └── ListContentProvider.java
│ │ ├── console
│ │ └── ConsoleFactory.java
│ │ └── report
│ │ └── list
│ │ ├── ReportListView.java
│ │ ├── ReportListViewCustom.java
│ │ ├── ReportListViewListener.java
│ │ ├── ReportListViewProject.java
│ │ ├── action
│ │ ├── NewInstanceAction.java
│ │ ├── ShowFilterConfigurationDialog.java
│ │ ├── rerun
│ │ │ ├── RefreshAction.java
│ │ │ ├── RerunAllAction.java
│ │ │ └── RerunSelectedAction.java
│ │ └── showas
│ │ │ ├── CheckerGroupAction.java
│ │ │ ├── CheckerTreeAction.java
│ │ │ └── TreeAwareAction.java
│ │ └── provider
│ │ ├── content
│ │ ├── CheckerGroupContentProvider.java
│ │ └── TreeCheckerContentProvider.java
│ │ └── label
│ │ ├── BasicViewLabelProvider.java
│ │ └── LastPartLabelProvider.java
└── pom.xml
├── checkstyle.xml
├── docs
├── allperspective.png
├── checkershow.png
├── checkstyle.md
├── config.png
├── developer.md
├── example.png
├── img
│ └── checkstyle
│ │ ├── ide_config.png
│ │ └── ide_proj_conf.png
└── nature.png
├── features
├── org.codechecker.eclipse.feature
│ ├── .project
│ ├── build.properties
│ └── feature.xml
└── pom.xml
├── mavendeps
└── pom.xml
├── pom.xml
├── readme.md
├── releng
├── org.codechecker.eclipse.configuration
│ ├── .project
│ └── pom.xml
├── org.codechecker.eclipse.target
│ ├── .project
│ ├── org.codechecker.eclipse.target.target
│ └── pom.xml
├── org.codechecker.eclipse.update
│ ├── .project
│ ├── category.xml
│ └── pom.xml
└── pom.xml
└── tests
├── org.codechecker.eclipse.rcp.it.tests
├── .checkstyle
├── .classpath
├── .gitignore
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── META-INF
│ └── MANIFEST.MF
├── build.properties
├── fragment.xml
├── pom.xml
├── resources
│ ├── .gitkeep
│ └── cppTest
│ │ ├── .cproject
│ │ ├── .project
│ │ ├── .settings
│ │ └── language.settings.xml
│ │ └── src
│ │ └── cppTest.cpp
└── src
│ └── org
│ └── codechecker
│ └── eclipse
│ └── plugin
│ ├── AllTests.java
│ ├── AnalysisTest.java
│ ├── ConfigurationTest.java
│ ├── IndicatorTest.java
│ ├── ParameterPassThroughTest.java
│ ├── PluginTest.java
│ ├── package-info.java
│ └── utils
│ ├── CompilationLogHelper.java
│ ├── GuiUtils.java
│ ├── ProjectImporter.java
│ └── package-info.java
├── org.codechecker.eclipse.rcp.shared
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── META-INF
│ └── MANIFEST.MF
├── build.properties
├── resources
│ └── CodeChecker
│ │ └── bin
│ │ ├── CodeChecker
│ │ └── plists
│ │ ├── cppTest.cpp_1.plist
│ │ └── cppTest.cpp_2.plist
└── src
│ └── org
│ └── codechecker
│ └── eclipse
│ └── rcp
│ └── shared
│ └── utils
│ ├── Utils.java
│ └── package-info.java
├── org.codechecker.eclipse.rcp.unit.tests
├── .checkstyle
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── META-INF
│ └── MANIFEST.MF
├── build.properties
├── pom.xml
├── resources
│ └── plists
│ │ ├── test_plist_1.plist
│ │ └── test_plist_2.plist
└── src
│ └── org
│ └── codechecker
│ └── eclipse
│ └── plugin
│ ├── codechecker
│ ├── CodeCheckerTest.java
│ ├── locator
│ │ ├── CodeCheckerLocatorTest.java
│ │ └── package-info.java
│ └── package-info.java
│ ├── report
│ └── PlistParserTest.java
│ └── runtime
│ ├── ShellExecutorHelperTest.java
│ └── package-info.java
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # vim
4 | *.swp
5 | *.swo
6 |
7 | # Eclipse
8 | bin/
9 | .idea
10 | *.iml
11 | target/
12 | logs/
13 |
14 | # Package Files #
15 | *.jar
16 | *.war
17 | *.ear
18 |
19 | # maven
20 | pom.xml.tag
21 | pom.xml.releaseBackup
22 | pom.xml.versionsBackup
23 | pom.xml.next
24 | release.properties
25 | dependency-reduced-pom.xml
26 |
--------------------------------------------------------------------------------
/.mvn/extensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.eclipse.tycho.extras
4 | tycho-pomless
5 | 1.3.0
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.codechecker.eclipse
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: trusty
2 | install: true
3 | language: java
4 | jdk:
5 | - oraclejdk8
6 | - oraclejdk9
7 | - oraclejdk11
8 | - openjdk8
9 |
10 | env: DISPLAY=:99.0
11 |
12 | matrix:
13 | include:
14 | - jdk: openjdk10
15 | before_install:
16 | - rm "${JAVA_HOME}/lib/security/cacerts"
17 | - ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts"
18 | - jdk: openjdk11
19 | before_install:
20 | - rm "${JAVA_HOME}/lib/security/cacerts"
21 | - ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts"
22 |
23 | before_install:
24 | - sudo apt-get install at-spi2-core
25 |
26 | before_script:
27 | - sh -e /etc/init.d/xvfb start
28 | - sleep 10 # give xvfb some time to start
29 |
30 | script: mvn -f mavendeps/pom.xml p2:site && mvn clean verify
31 |
32 | after_failure:
33 | - cat $TRAVIS_BUILD_DIR/tests/org.codechecker.eclipse.rcp.it.tests/target/work/data/.metadata/.log
34 | - cat $TRAVIS_BUILD_DIR/tests/org.codechecker.eclipse.rcp.it.tests/target/surefire-reports/*
35 | - cat $TRAVIS_BUILD_DIR/tests/org.codechecker.eclipse.rcp.unit.tests/target/work/configuration/*.log
36 | - cat $TRAVIS_BUILD_DIR/tests/org.codechecker.eclipse.rcp.unit.tests/target/surefire-reports/*
37 |
38 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/.checkstyle:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.codechecker.eclipse.plugin
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 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/.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.methodParameters=do not generate
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6 | org.eclipse.jdt.core.compiler.compliance=1.8
7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.source=1.8
13 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: org.codechecker.eclipse
4 | Bundle-SymbolicName: org.codechecker.eclipse.plugin;singleton:=true
5 | Bundle-Version: 0.0.6.qualifier
6 | Require-Bundle: org.eclipse.ui,
7 | org.eclipse.ui.ide,
8 | org.eclipse.core.runtime,
9 | org.eclipse.core.resources;bundle-version="3.9.1",
10 | org.eclipse.ui.forms;bundle-version="3.6.100",
11 | org.eclipse.core.databinding,
12 | org.eclipse.core.databinding.beans,
13 | org.eclipse.core.databinding.observable,
14 | org.eclipse.core.databinding.property,
15 | org.eclipse.jface.databinding,
16 | org.eclipse.swt,
17 | org.eclipse.cdt.core,
18 | org.eclipse.ui.console,
19 | com.googlecode.plist.dd-plist;bundle-version="1.21.0",
20 | com.google.guava;bundle-version="26.0.0",
21 | org.apache.commons.lang;bundle-version="3.0.0",
22 | org.apache.commons.exec;bundle-version="1.3.0",
23 | joda-time;bundle-version="2.10.1",
24 | com.google.gson;bundle-version="2.3.1",
25 | log4j;bundle-version="1.2.17",
26 | org.eclipse.jdt.annotation;bundle-version="2.1.100"
27 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8
28 | Export-Package: org.codechecker.eclipse.plugin,
29 | org.codechecker.eclipse.plugin.runtime
30 | Import-Package: com.google.gson
31 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/build.properties:
--------------------------------------------------------------------------------
1 | source..=src/
2 | output..=target/classes/
3 | bin.includes = plugin.xml,\
4 | META-INF/,\
5 | .,\
6 | icons/,\
7 | contexts.xml,\
8 | log4j.properties
9 |
10 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/contexts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | This is the context help for the sample view with a tree viewer. It was
5 | generated by a PDE template.
6 |
7 |
9 |
10 |
11 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/analyze.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/analyze.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/arrow_down.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/arrow_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/arrow_left.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/arrow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/arrow_right.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/arrow_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/arrow_up.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/double_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/double_down.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/double_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/double_left.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/double_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/double_right.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/double_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/double_up.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/filter.png
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/icons/sample.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/icons/sample.gif
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=DEBUG, log, console
2 |
3 | log4j.appender.log=org.apache.log4j.DailyRollingFileAppender
4 | log4j.appender.log.datePattern='.'yyyy-MM-dd
5 | log4j.appender.log.Append=true
6 | log4j.appender.log.File=logs/codechecker_plugin.log
7 | log4j.appender.log.encoding=UTF-8
8 | log4j.appender.log.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.log.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %t %x %-5p %c{1}:%L - %m%n
10 |
11 | # You can specify the log level here
12 | # log levels
13 | # TRACE,
14 | # DEBUG,
15 | # INFO,
16 | # WARN,
17 | # ERROR,
18 | # FATAL
19 | log4j.appender.log.threshold=ERROR
20 |
21 | log4j.appender.console=org.apache.log4j.ConsoleAppender
22 | log4j.appender.console.target=System.err
23 | log4j.appender.console.threshold=ERROR
24 | log4j.appender.console.layout = org.apache.log4j.PatternLayout
25 | log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %t %x %-5p %c{1}:%L - %m%n
26 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/Activator.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin;
2 |
3 | import org.eclipse.cdt.utils.Platform;
4 | import org.eclipse.core.runtime.FileLocator;
5 | import org.eclipse.core.runtime.IPath;
6 | import org.eclipse.core.runtime.Path;
7 | import org.eclipse.core.runtime.jobs.Job;
8 | import org.eclipse.jface.resource.ImageDescriptor;
9 | import org.eclipse.ui.IStartup;
10 | import org.eclipse.ui.plugin.AbstractUIPlugin;
11 | import org.osgi.framework.Bundle;
12 | import org.osgi.framework.BundleContext;
13 |
14 | import org.codechecker.eclipse.plugin.init.StartupJob;
15 | import org.codechecker.eclipse.plugin.views.console.ConsoleFactory;
16 |
17 | import java.net.URL;
18 |
19 | import org.apache.log4j.PropertyConfigurator;
20 |
21 | /**
22 | * The activator class controls the plug-in life cycle
23 | */
24 | public class Activator extends AbstractUIPlugin implements IStartup {
25 |
26 | // The plug-in ID
27 | public static final String PLUGIN_ID = "org.codechecker.eclipse.plugin"; //$NON-NLS-1$
28 |
29 | // The shared instance
30 | private static Activator plugin;
31 |
32 | private static IPath preferencesPath;
33 |
34 | /**
35 | * The constructor
36 | */
37 | public Activator() {
38 | Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
39 | final URL fullPathString = FileLocator.find(bundle, new Path("log4j.properties"), null);
40 | PropertyConfigurator.configure(fullPathString);
41 | }
42 |
43 | public static IPath getPreferencesPath() {
44 | return preferencesPath;
45 | }
46 |
47 | /**
48 | * Returns the shared instance
49 | *
50 | * @return the shared instance
51 | */
52 | public static Activator getDefault() {
53 | return plugin;
54 | }
55 |
56 | /**
57 | * Returns an image descriptor for the image file at the given plug-in relative path
58 | *
59 | * @param path the path
60 | * @return the image descriptor
61 | */
62 | public static ImageDescriptor getImageDescriptor(String path) {
63 | return imageDescriptorFromPlugin(PLUGIN_ID, path);
64 | }
65 |
66 | /*
67 | * (non-Javadoc)
68 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
69 | */
70 | public void start(BundleContext context) throws Exception {
71 | ConsoleFactory.consoleWrite("CodeChecker Plugin Started");
72 | super.start(context);
73 |
74 | //earlyStartup();
75 | }
76 |
77 | /*
78 | * (non-Javadoc)
79 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
80 | */
81 | public void stop(BundleContext context) throws Exception {
82 | plugin = null;
83 | ConsoleFactory.consoleWrite("CodeChecker Plugin Stopped");
84 | super.stop(context);
85 | }
86 |
87 | @Override
88 | public void earlyStartup() {
89 | plugin = this;
90 |
91 | preferencesPath = getStateLocation();
92 |
93 | Job j = new StartupJob();
94 | j.setPriority(Job.INTERACTIVE);
95 | j.schedule();
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/CodeCheckerNature.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin;
2 |
3 | import org.eclipse.core.resources.IProject;
4 | import org.eclipse.core.resources.IProjectNature;
5 | import org.eclipse.core.runtime.CoreException;
6 |
7 | import org.codechecker.eclipse.plugin.config.CodeCheckerContext;
8 | import org.codechecker.eclipse.plugin.config.project.CodeCheckerProject;
9 |
10 | /**
11 | * Eclipse uses natures as project feature indicators.
12 | * This class adds CodeChecker related nature.
13 | *
14 | */
15 | public class CodeCheckerNature implements IProjectNature {
16 |
17 | public static final String NATURE_ID = "org.codechecker.eclipse.plugin.CodeCheckerNature";
18 | IProject project;
19 |
20 | @Override
21 | public void configure() throws CoreException {
22 | CodeCheckerProject cCProject = new CodeCheckerProject(project);
23 | cCProject.modifyProjectEnvironmentVariables();
24 | CodeCheckerContext.getInstance().addCodeCheckerProject(cCProject);
25 | }
26 |
27 | @Override
28 | public void deconfigure() throws CoreException {}
29 |
30 | @Override
31 | public IProject getProject() {
32 | return project;
33 | }
34 |
35 | @Override
36 | public void setProject(IProject project) {
37 | this.project = project;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/ExternalLogger.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin;
2 |
3 | import org.codechecker.eclipse.plugin.runtime.LogI;
4 | import org.codechecker.eclipse.plugin.views.console.ConsoleFactory;;
5 |
6 | //logger service for non plugin internal
7 | //components (such as the codechecker service)
8 | public class ExternalLogger implements LogI{
9 | public void log(int severity,String message){
10 | Logger.extLog(severity, message);
11 | }
12 | //logs to CodeChecker console
13 | public void consoleLog(String message){
14 | ConsoleFactory.consoleWrite(message);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/Logger.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin;
2 |
3 | import java.io.PrintWriter;
4 | import java.io.StringWriter;
5 |
6 | import org.eclipse.core.runtime.ILog;
7 | import org.eclipse.core.runtime.Status;
8 |
9 | import org.codechecker.eclipse.plugin.views.console.ConsoleFactory;
10 |
11 |
12 | public class Logger {
13 | private static ILog logger = Activator.getDefault().getLog();
14 | public static void log(int level,String message){
15 | StackTraceElement s[] = Thread.currentThread().getStackTrace();
16 | if (s.length>2){
17 | StackTraceElement caller=s[2];
18 | String place=caller.getFileName()+":"+caller.getLineNumber()+" "+caller.getMethodName()+"(): ";
19 | logger.log(new Status(level,Activator.PLUGIN_ID,place+message));
20 | }
21 | }
22 | public static void extLog(int level,String message){
23 | StackTraceElement s[] = Thread.currentThread().getStackTrace();
24 | if (s.length>4){//we do not want to show the ExternalLogger.log function in the trace
25 | StackTraceElement caller=s[4];
26 | String place=caller.getFileName()+":"+caller.getLineNumber()+" "+caller.getMethodName()+"(): ";
27 | logger.log(new Status(level,Activator.PLUGIN_ID,place+message));
28 | }
29 | }
30 | //logs to CodeChecker console
31 | public static void consoleLog(String message){
32 | ConsoleFactory.consoleWrite(message);
33 | }
34 |
35 | /**
36 | * Returns Stack Trace as String.
37 | * @param throwable The exception in question.
38 | * @return The Stack Trace as String.
39 | */
40 | public static String getStackTrace(final Throwable throwable) {
41 | final StringWriter sw = new StringWriter();
42 | final PrintWriter pw = new PrintWriter(sw, true);
43 | throwable.printStackTrace(pw);
44 | return sw.getBuffer().toString();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/CodeCheckerFactory.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker;
2 |
3 | import java.nio.file.Path;
4 |
5 | import org.codechecker.eclipse.plugin.codechecker.locator.InvalidCodeCheckerException;
6 | import org.codechecker.eclipse.plugin.runtime.ShellExecutorHelper;
7 |
8 | /**
9 | * Implementation of the {@link ICodeCheckerFactory} interface.
10 | */
11 | public class CodeCheckerFactory implements ICodeCheckerFactory {
12 | @Override
13 | public ICodeChecker createCodeChecker(Path pathToBin, ShellExecutorHelper she)
14 | throws InvalidCodeCheckerException {
15 | return new CodeChecker(pathToBin, she);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/ICodeChecker.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker;
2 |
3 | import java.nio.file.Path;
4 |
5 | import org.codechecker.eclipse.plugin.codechecker.locator.InvalidCodeCheckerException;
6 | import org.codechecker.eclipse.plugin.config.CcConfigurationBase;
7 | import org.eclipse.core.runtime.IProgressMonitor;
8 | import org.eclipse.jdt.annotation.NonNull;
9 | import org.eclipse.jdt.annotation.Nullable;
10 |
11 | /**
12 | * Interface representing a CodeChecker package.
13 | */
14 | public interface ICodeChecker {
15 | /**
16 | * Returns the unformatted output of the CodeChecker checkers command.
17 | *
18 | * @return The checker list.
19 | */
20 | @NonNull
21 | public String getCheckers();
22 |
23 | /**
24 | * Returns the full and complete version string of the CodeChecker package. The
25 | * returned String will never be empty.
26 | *
27 | * @return The version String.
28 | * @throws InvalidCodeCheckerException
29 | * Thrown when no version string can be returned.
30 | */
31 | @NonNull
32 | public String getVersion() throws InvalidCodeCheckerException;
33 |
34 | /**
35 | * To get the location of the CodeChecker binary. The returned String will never
36 | * be empty.
37 | *
38 | * @return The path.
39 | */
40 | public Path getLocation();
41 |
42 | /**
43 | * Returns the analyze command to be run, without extra parameters.
44 | *
45 | * @param logFile
46 | * A Path to the build log in the following format:
47 | * http://clang.llvm.org/docs/JSONCompilationDatabase.html .
48 | * @param config
49 | * The configuration being used.
50 | * @param skipFile
51 | * Skipfile to be used.
52 | * @return The analyze command as String.
53 | */
54 | public String getAnalyzeString(CcConfigurationBase config, @Nullable Path logFile, @Nullable Path skipFile);
55 |
56 | /**
57 | * Executes CodeChecker check command on the build log received in the logFile
58 | * parameter.
59 | *
60 | * @param logFile
61 | * A Path to the build log in the following format:
62 | * http://clang.llvm.org/docs/JSONCompilationDatabase.html .
63 | * @param logToConsole
64 | * Flag for indicating console logging.
65 | * @param monitor
66 | * ProgressMonitor for to be able to increment progress bar.
67 | * @param taskCount
68 | * How many analyze step to be taken.
69 | * @param config
70 | * The configuration being used.
71 | * @param FileToBeAnalyzed Filesystem path of the analysis target.
72 | * @return CodeChecker The full analyze command output.
73 | */
74 | public String analyze(Path logFile, boolean logToConsole, IProgressMonitor monitor, int taskCount,
75 | CcConfigurationBase config, Path FileToBeAnalyzed);
76 |
77 | public void cancelAnalyze();
78 | }
79 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/ICodeCheckerFactory.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker;
2 |
3 | import java.nio.file.Path;
4 |
5 | import org.codechecker.eclipse.plugin.codechecker.locator.InvalidCodeCheckerException;
6 | import org.codechecker.eclipse.plugin.runtime.ShellExecutorHelper;
7 |
8 | /**
9 | * Interface for CodeChecker factory.
10 | */
11 | public interface ICodeCheckerFactory {
12 | /**
13 | * Method for creating CodeChecker instances.
14 | *
15 | * @param pathToBin
16 | * Path to the CodeChecker binary. (Not to root!)
17 | * @param she
18 | * The shell executor helper that will be used.
19 | * @return A newly created {@link ICodeChecker} ICodeChecker instance.
20 | * @throws InvalidCodeCheckerException
21 | * Thrown when a new instance couldn't be created.
22 | */
23 | public ICodeChecker createCodeChecker(Path pathToBin, ShellExecutorHelper she)
24 | throws InvalidCodeCheckerException;
25 | }
26 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/locator/CodeCheckerLocatorFactory.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker.locator;
2 |
3 | /**
4 | * Class responsible to create {@link CodeCheckerLocatorService} instances.
5 | */
6 | public class CodeCheckerLocatorFactory {
7 | /**
8 | * Returns a {@link CodeCheckerLocatorService} depending on a the input
9 | * parameter.
10 | *
11 | * @param t
12 | * Any of the {@link ResolutionMethodTypes} enum values.
13 | * @return A {@link CodeCheckerLocatorService} instance.
14 | */
15 | public CodeCheckerLocatorService create(ResolutionMethodTypes t) {
16 | switch (t) {
17 | case PATH:
18 | return new EnvCodeCheckerLocatorService();
19 | case PRE:
20 | return new PreBuiltCodeCheckerLocatorService();
21 | default:
22 | return null;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/locator/CodeCheckerLocatorService.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker.locator;
2 |
3 | import java.nio.file.Path;
4 |
5 | import org.codechecker.eclipse.plugin.codechecker.ICodeChecker;
6 | import org.codechecker.eclipse.plugin.codechecker.ICodeCheckerFactory;
7 | import org.codechecker.eclipse.plugin.runtime.IShellExecutorHelperFactory;
8 |
9 | /**
10 | * Implementations of this interface should return the location of the
11 | * CodeChecker package.
12 | */
13 | public abstract class CodeCheckerLocatorService {
14 | /**
15 | * @param pathToBin
16 | * Path to CodeChecker package root.
17 | * @param ccfactory
18 | * An {@link ICodeCheckerFactory} that will create the CodeChecker.
19 | * @param sheFactory
20 | * A {@link IShellExecutorHelperFactory} to be used.
21 | * @return A CodeChecker Instance.
22 | * @throws InvalidCodeCheckerException
23 | * Thrown when the {@link ICodeChecker} instantiation fails.
24 | */
25 | public abstract ICodeChecker findCodeChecker(Path pathToBin, ICodeCheckerFactory ccfactory, IShellExecutorHelperFactory sheFactory)
26 | throws InvalidCodeCheckerException;
27 | }
28 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/locator/EnvCodeCheckerLocatorService.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker.locator;
2 |
3 | import java.nio.file.Path;
4 | import java.nio.file.Paths;
5 |
6 | import org.codechecker.eclipse.plugin.codechecker.ICodeChecker;
7 | import org.codechecker.eclipse.plugin.codechecker.ICodeCheckerFactory;
8 | import org.codechecker.eclipse.plugin.runtime.IShellExecutorHelperFactory;
9 | import org.codechecker.eclipse.plugin.runtime.ShellExecutorHelper;
10 |
11 | /**
12 | * Provides a CodeChecker instance tied to a CodeChecker package resulting of
13 | * "which CodeChecker".
14 | */
15 | public class EnvCodeCheckerLocatorService extends CodeCheckerLocatorService {
16 | public static final String CC_NOT_FOUND = "CodeChecker wasn't found in PATH environment variable!";
17 |
18 | @Override
19 | public ICodeChecker findCodeChecker(Path path, ICodeCheckerFactory ccFactory,
20 | IShellExecutorHelperFactory sheFactory) throws InvalidCodeCheckerException {
21 |
22 | ShellExecutorHelper she = sheFactory.createShellExecutorHelper(System.getenv());
23 | String location = she.quickReturnFirstLine("which CodeChecker", null).or("");
24 | try {
25 | return ccFactory.createCodeChecker(Paths.get(location), she);
26 | } catch (InvalidCodeCheckerException e) {
27 | throw new InvalidCodeCheckerException(CC_NOT_FOUND);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/locator/InvalidCodeCheckerException.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker.locator;
2 |
3 | /**
4 | * Custom exception indicating a failed CodeChecker instance creation.
5 | */
6 | @SuppressWarnings("serial")
7 | public class InvalidCodeCheckerException extends Exception {
8 | /**
9 | * Ctor.
10 | *
11 | * @param errorMessage
12 | * Error message.
13 | */
14 | public InvalidCodeCheckerException(String errorMessage) {
15 | super(errorMessage);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/locator/PreBuiltCodeCheckerLocatorService.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker.locator;
2 |
3 | import java.nio.file.Path;
4 |
5 | import org.codechecker.eclipse.plugin.codechecker.ICodeChecker;
6 | import org.codechecker.eclipse.plugin.codechecker.ICodeCheckerFactory;
7 | import org.codechecker.eclipse.plugin.runtime.IShellExecutorHelperFactory;
8 |
9 | /**
10 | * Provides a CodeChecker instance which is tied to a pre-built CodeChecker
11 | * package.
12 | */
13 | public class PreBuiltCodeCheckerLocatorService extends CodeCheckerLocatorService {
14 | public static final String CC_INVALID = "The path to the CodeChecker binary is not valid";
15 | public static final String CC_NOT_FOUND = "Couldn't find CodeChecker at the given destination!";
16 |
17 | @Override
18 | public ICodeChecker findCodeChecker(Path pathToBin, ICodeCheckerFactory ccfactory,
19 | IShellExecutorHelperFactory sheFactory) throws InvalidCodeCheckerException {
20 | if (pathToBin == null)
21 | throw new IllegalArgumentException(CC_INVALID);
22 | try {
23 | return ccfactory.createCodeChecker(pathToBin, sheFactory.createShellExecutorHelper(System.getenv()));
24 | } catch (InvalidCodeCheckerException e) {
25 | throw new InvalidCodeCheckerException(CC_NOT_FOUND);
26 | }
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/locator/ResolutionMethodTypes.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.codechecker.locator;
2 |
3 | /**
4 | * This enum represents the available types of CodeChecker resolution methods.
5 | */
6 | public enum ResolutionMethodTypes {
7 | PATH, PRE;
8 | }
9 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/locator/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * CodeChecker locator related classes.
3 | */
4 | package org.codechecker.eclipse.plugin.codechecker.locator;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/codechecker/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * CodeChecker related classes.
3 | */
4 | package org.codechecker.eclipse.plugin.codechecker;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/command/AddProjectNature.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.command;
2 |
3 | import org.eclipse.core.commands.AbstractHandler;
4 | import org.eclipse.core.commands.ExecutionEvent;
5 | import org.eclipse.core.commands.ExecutionException;
6 | import org.eclipse.ui.IWorkbenchWindow;
7 | import org.eclipse.core.resources.IProject;
8 | import org.eclipse.core.resources.IProjectDescription;
9 | import org.eclipse.core.runtime.CoreException;
10 | import org.eclipse.core.runtime.IAdaptable;
11 | import org.eclipse.core.runtime.IPath;
12 | import org.eclipse.core.runtime.IProgressMonitor;
13 | import org.eclipse.jface.viewers.IStructuredSelection;
14 | import org.eclipse.ui.PlatformUI;
15 |
16 | import org.codechecker.eclipse.plugin.CodeCheckerNature;
17 | import org.codechecker.eclipse.plugin.views.console.ConsoleFactory;
18 |
19 |
20 | import org.codechecker.eclipse.plugin.Logger;
21 | import org.eclipse.core.runtime.IStatus;
22 |
23 | public class AddProjectNature extends AbstractHandler {
24 |
25 | @Override
26 | public Object execute(ExecutionEvent event) throws ExecutionException {
27 | // TODO Auto-generated method stub
28 |
29 | IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
30 | if (window != null) {
31 | IStructuredSelection selection = (IStructuredSelection) window.getSelectionService()
32 | .getSelection();
33 | Object firstElement = selection.getFirstElement();
34 | if (firstElement instanceof IAdaptable) {
35 | IProject project = (IProject) ((IAdaptable) firstElement).getAdapter(IProject
36 | .class);
37 | if (project == null) {
38 | Logger.log(IStatus.INFO, "Not a project.");
39 | return null;
40 | }
41 | IPath path = project.getFullPath();
42 | Logger.log(IStatus.INFO, "" + path);
43 |
44 | try {
45 | if (project.hasNature(CodeCheckerNature.NATURE_ID)) {
46 | return null;
47 | }
48 |
49 | IProjectDescription description = project.getDescription();
50 | String[] prevNatures = description.getNatureIds();
51 | String[] newNatures = new String[prevNatures.length + 1];
52 | System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
53 | newNatures[prevNatures.length] = CodeCheckerNature.NATURE_ID;
54 | description.setNatureIds(newNatures);
55 |
56 | IProgressMonitor monitor = null;
57 | project.setDescription(description, monitor);
58 | ConsoleFactory.consoleWrite(project.getName() + ": Sucessfully added CodeChecker Nature");
59 | Logger.log(IStatus.INFO, "Project nature added!");
60 |
61 | } catch (CoreException e) {
62 | // TODO Auto-generated catch block
63 | Logger.log(IStatus.ERROR, e.toString());
64 | Logger.log(IStatus.INFO, e.getStackTrace().toString());
65 | }
66 |
67 | }
68 | }
69 |
70 | return null;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/.CodeCheckerContext.java.swn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ericsson/CodeCheckerEclipsePlugin/bd79c2631d81cf077864ddfac6068dd062c3aa91/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/.CodeCheckerContext.java.swn
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CcConfigurationBase.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config;
2 |
3 | import java.util.HashSet;
4 | import java.util.Map;
5 | import java.util.Set;
6 |
7 | import org.codechecker.eclipse.plugin.codechecker.ICodeChecker;
8 | import org.codechecker.eclipse.plugin.config.Config.ConfigTypes;
9 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
10 |
11 | /**
12 | * Interface for CodeChecker configuration.
13 | */
14 | public abstract class CcConfigurationBase {
15 |
16 | protected static final String STR_EMPTY = "";
17 |
18 | protected Map config;
19 | protected IEclipsePreferences preferences;
20 | protected ICodeChecker codeChecker;
21 |
22 | private final Set listeners = new HashSet<>();
23 |
24 | /**
25 | * Base Constructor.
26 | */
27 | public CcConfigurationBase() {}
28 |
29 | /**
30 | * For Updates the configuration.
31 | * @param config The new configuration.
32 | */
33 | public abstract void update(Map config);
34 |
35 | /**
36 | * For initializing the internal configuration.
37 | */
38 | public abstract void load();
39 |
40 | /**
41 | * For checking that the loaded configuration is valid.
42 | */
43 | protected abstract void validate();
44 |
45 | /**
46 | * @return The CodeChecker being used.
47 | */
48 | public ICodeChecker getCodeChecker() {
49 | return codeChecker;
50 | }
51 |
52 | /**
53 | * Sets the currently used CodeChecker.
54 | *
55 | * @param codeChecker
56 | * The CodeChecker that will be stored.
57 | */
58 | public void setCodeChecker(ICodeChecker codeChecker) {
59 | this.codeChecker = codeChecker;
60 | }
61 |
62 | /**
63 | * @return the internal configuration.
64 | */
65 | public Map get() {
66 | return config;
67 | }
68 |
69 | /**
70 | * @param type The key of the value that we are interested in.
71 | * @return The value.
72 | */
73 | public String get(ConfigTypes type) {
74 | return config.get(type);
75 | }
76 |
77 | /**
78 | * Returns the default configuration for the plug-in.
79 | * @return An Unmodifiable view of the default configuration Map.
80 | */
81 | public Map getDefaultConfig() {
82 | return ConfigTypes.getCommonDefault();
83 | }
84 |
85 | /**
86 | * @param listener The listener to be added.
87 | */
88 | public void registerChangeListener(ConfigurationChangedListener listener) {
89 | listeners.add(listener);
90 | }
91 |
92 | /**
93 | * @param listener The listener to be removed.
94 | */
95 | public void deRegisterChangeListener(ConfigurationChangedListener listener) {
96 | if (listener != null)
97 | listeners.remove(listener);
98 | }
99 |
100 | /**
101 | * Notifies registered listeners that the configuration had been changed.
102 | * @param config the new configuration.
103 | */
104 | public void notifyListeners(Map config) {
105 | for (ConfigurationChangedListener configurationChangedListener : listeners) {
106 | configurationChangedListener.configUpdated(config);
107 | }
108 | }
109 |
110 | /**
111 | * Implement this interface and use {@link registerChangeListener} to get
112 | * notifications about configuration changes.
113 | */
114 | public interface ConfigurationChangedListener{
115 | /**
116 | * {@link notifyListenersn} will call this method when the configuration changes.
117 | * @param config The new configuration.
118 | */
119 | public void configUpdated(Map config);
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/Config.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config;
2 |
3 | import java.util.EnumSet;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import java.util.Set;
7 |
8 | import org.codechecker.eclipse.plugin.Logger;
9 | import org.eclipse.core.runtime.IStatus;
10 |
11 | /**
12 | * Classes for handling actual configuration entries, and logging.
13 | *
14 | */
15 | public class Config {
16 | /**
17 | * Represents all available configuraton values.
18 | * Watch form marking comments, because specialized sets (Common, Project)
19 | * are returned using enumset range,
20 | *
21 | */
22 | public enum ConfigTypes {
23 | // Common configuration values
24 | CHECKER_PATH("codechecker_path"),
25 | RES_METHOD("PATH"),
26 | COMPILERS("gcc:g++:clang:clang++:c++:cc"),
27 | ANAL_THREADS("4"),
28 | ANAL_OPTIONS(""),
29 | // Project configuration values
30 | IS_GLOBAL("true"),
31 | CHECKER_WORKSPACE("codechecker_workdir");
32 |
33 | public static Set COMMON_TYPE = EnumSet.range(CHECKER_PATH, ANAL_OPTIONS);
34 | public static Set PROJECT_TYPE = EnumSet.range(IS_GLOBAL, CHECKER_WORKSPACE);
35 | private String defaultValue;
36 |
37 | /**
38 | *
39 | * @param def utility method for setting the default value.
40 | */
41 | private ConfigTypes(String def) {
42 | this.defaultValue = def;
43 | }
44 |
45 | /**
46 | *
47 | * @return Returns the default value associated with the enum.
48 | */
49 | public String getDefaultValue() {
50 | return defaultValue;
51 | }
52 |
53 | /**
54 | *
55 | * @param s The query string.
56 | * @return The matching ConfigType if exists null otherwise.
57 | */
58 | public static ConfigTypes getFromString(String s) {
59 | for (ConfigTypes c :ConfigTypes.values()) {
60 | if (s.equals(c.toString()))
61 | return c;
62 | }
63 | return null;
64 | }
65 |
66 | /**
67 | *
68 | * @return Returns the default configuration values to the common configuration keys.
69 | */
70 | public static Map getCommonDefault() {
71 | Map map = new HashMap();
72 | for (ConfigTypes ct : ConfigTypes.COMMON_TYPE)
73 | map.put(ct, ct.defaultValue);
74 | return map;
75 | }
76 | }
77 |
78 | /**
79 | * Utility class for easier config logging.
80 | *
81 | */
82 | public static class ConfigLogger {
83 |
84 | public static final String SEP = "=";
85 |
86 | private String header;
87 | private StringBuilder messageBuilder;
88 |
89 | /**
90 | * Initializes the header with a message.
91 | * @param header This will be the headline of the log.
92 | */
93 | public ConfigLogger(String header) {
94 | this(header, IStatus.INFO);
95 | }
96 |
97 | /**
98 | * Initializes the header with a message to be logged with, and
99 | * a log level if something other is desired than ISTATUS.INFO.
100 | * @param header This will be the headline of the log.
101 | * @param info The log level thats used for logging.
102 | */
103 | public ConfigLogger(String header, int info) {
104 | this.header = header + System.lineSeparator();
105 | }
106 |
107 | /**
108 | * Called on first append for flagging log need.
109 | */
110 | public void init() { if (messageBuilder == null) messageBuilder = new StringBuilder(); }
111 |
112 | /**
113 | * Appends a String to the message.
114 | * @param message Custom String.
115 | */
116 | public void append(String message){
117 | init();
118 | messageBuilder.append(message + System.lineSeparator());
119 | }
120 |
121 | /**
122 | * Appends a stringified entry to the message.
123 | * @param entry A {@link ConfigTypes} String pair.
124 | */
125 | public void append(Map.Entry entry) {
126 | init();
127 | messageBuilder.append(entry.getKey() + SEP + entry.getValue() + System.lineSeparator());
128 | }
129 |
130 | /**
131 | * Only logs when there is a message added.
132 | */
133 | public void log(){
134 | if (messageBuilder != null)
135 | Logger.log(IStatus.WARNING, header + messageBuilder.toString());
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/EnvironmentVariables.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config;
2 |
3 | import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
4 |
5 | /**
6 | * Environment variables to added to the C/C++ project environment variables.
7 | */
8 | public enum EnvironmentVariables {
9 | LD_LIBRARY_PATH("/ld_logger/lib", IEnvironmentVariable.ENVVAR_REPLACE),
10 | _("/bin/CodeChecker", IEnvironmentVariable.ENVVAR_REPLACE),
11 | CC_LOGGER_GCC_LIKE("clang", IEnvironmentVariable.ENVVAR_REPLACE),
12 | LD_PRELOAD("ldlogger.so", IEnvironmentVariable.ENVVAR_REPLACE),
13 | CC_LOGGER_FILE("logfile", IEnvironmentVariable.ENVVAR_REPLACE),
14 | CC_LOGGER_BIN("/bin/ldlogger", IEnvironmentVariable.ENVVAR_REPLACE);
15 |
16 | private String defaultValue;
17 | private int method;
18 |
19 | /**
20 | *
21 | * @param def
22 | * utility method for setting the default value.
23 | * @param method
24 | * default addition method.
25 | */
26 | EnvironmentVariables(String def, int method) {
27 | this.defaultValue = def;
28 | this.method = method;
29 | }
30 |
31 | /**
32 | *
33 | * @return Returns the default value associated with the enum.
34 | */
35 | public String getDefaultValue() {
36 | return defaultValue;
37 | }
38 |
39 | /**
40 | *
41 | * @return Returns Environment variable addition method associated with the key.
42 | */
43 | public int getMethod( ) {
44 | return method;
45 | }
46 |
47 | /**
48 | *
49 | * @param s The query string.
50 | * @return The matching ConfigType if exists null otherwise.
51 | */
52 | public static EnvironmentVariables getFromString(String s) {
53 | for (EnvironmentVariables ev :EnvironmentVariables.values()) {
54 | if (s.equals(ev.toString()))
55 | return ev;
56 | }
57 | return null;
58 | }
59 | }
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/filter/Filter.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config.filter;
2 |
3 | import org.codechecker.eclipse.plugin.Logger;
4 | import org.codechecker.eclipse.plugin.report.Severity;
5 |
6 | import org.eclipse.core.runtime.IStatus;
7 |
8 | public class Filter {
9 |
10 | private String filepath = "";
11 | private String checkerMsg = "";
12 | private Severity severity = Severity.ANY;
13 | private String checkerId = "";
14 | private String buildTarget = "";
15 | private boolean showSuppressedErrors = false;
16 |
17 | public Filter() {
18 | }
19 |
20 | public Filter(String filepath, String checkerMsg, Severity severity, String checkerId, String
21 | buildTarget, boolean showSuppressedErrors) {
22 | super();
23 | this.filepath = filepath;
24 | this.checkerMsg = checkerMsg;
25 | this.severity = severity;
26 | this.checkerId = checkerId;
27 | this.buildTarget = buildTarget;
28 | this.showSuppressedErrors = showSuppressedErrors;
29 | }
30 |
31 | public Filter dup() {
32 | return new Filter(filepath, checkerMsg, severity, checkerId, buildTarget,
33 | showSuppressedErrors);
34 | }
35 |
36 | public String getFilepath() {
37 | return filepath;
38 | }
39 |
40 | public void setFilepath(String filepath) {
41 | this.filepath = filepath;
42 | }
43 |
44 | public String getCheckerMsg() {
45 | return checkerMsg;
46 | }
47 |
48 | public void setCheckerMsg(String checkerMsg) {
49 | this.checkerMsg = checkerMsg;
50 | }
51 |
52 | public Severity getSeverity() {
53 | return severity;
54 | }
55 |
56 | public void setSeverity(Severity severity) {
57 | this.severity = severity;
58 | }
59 |
60 | public String getCheckerId() {
61 | return checkerId;
62 | }
63 |
64 | public void setCheckerId(String checkerId) {
65 | this.checkerId = checkerId;
66 | }
67 |
68 | public String getBuildTarget() {
69 | return buildTarget;
70 | }
71 |
72 | public void setBuildTarget(String buildTarget) {
73 | this.buildTarget = buildTarget;
74 | }
75 |
76 | public boolean isShowSuppressedErrors() {
77 | return showSuppressedErrors;
78 | }
79 |
80 | public void setShowSuppressedErrors(boolean showSuppressedErrors) {
81 | this.showSuppressedErrors = showSuppressedErrors;
82 | }
83 |
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/filter/FilterConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config.filter;
2 |
3 | import java.util.LinkedList;
4 |
5 | import org.codechecker.eclipse.plugin.report.ResultFilter;
6 | import org.codechecker.eclipse.plugin.report.Severity;
7 |
8 | import com.google.common.base.Optional;
9 | import com.google.common.collect.ImmutableList;
10 |
11 | public class FilterConfiguration {
12 |
13 | private String name = "";
14 |
15 | private boolean linkToCurrentEditorByDefalt = true;
16 |
17 | private boolean globallySaved = false;
18 |
19 | private LinkedList filters = new LinkedList();
20 |
21 | public FilterConfiguration() {
22 | }
23 |
24 | public FilterConfiguration(String name, boolean linkToCurrentEditorByDefalt,
25 | LinkedList filters) {
26 | super();
27 | this.name = name;
28 | this.linkToCurrentEditorByDefalt = linkToCurrentEditorByDefalt;
29 | this.filters = new LinkedList<>();
30 | for (Filter f : filters) {
31 | this.filters.add(f.dup());
32 | }
33 | }
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 |
43 | public boolean isGloballySaved() {
44 | return globallySaved;
45 | }
46 |
47 | public void setGloballySaved(boolean globallySaved) {
48 | this.globallySaved = globallySaved;
49 | }
50 |
51 | public boolean isLinkToCurrentEditorByDefalt() {
52 | return linkToCurrentEditorByDefalt;
53 | }
54 |
55 | public void setLinkToCurrentEditorByDefalt(boolean linkToCurrentEditorByDefalt) {
56 | this.linkToCurrentEditorByDefalt = linkToCurrentEditorByDefalt;
57 | }
58 |
59 | public LinkedList getFilters() {
60 | return filters;
61 | }
62 |
63 | public void setFilters(LinkedList filters) {
64 | this.filters = filters;
65 | }
66 |
67 | public FilterConfiguration dup() {
68 | return new FilterConfiguration(name, linkToCurrentEditorByDefalt, filters);
69 | }
70 |
71 | public ImmutableList convertToResultList() {
72 | ImmutableList.Builder builder = new ImmutableList.Builder<>();
73 |
74 | for (Filter f : filters) {
75 | builder.add(new ResultFilter(f.getFilepath().equals("") ? Optional.absent() :
76 | Optional.of(f.getFilepath()), f.getCheckerMsg().equals("") ? Optional
77 | .absent() : Optional.of(f.getCheckerMsg()), f.getSeverity(), f
78 | .getCheckerId().equals("") ? Optional.absent() : Optional.of(f
79 | .getCheckerId()), f.getBuildTarget().equals("") ? Optional.absent() :
80 | Optional.of(f.getBuildTarget()), f.isShowSuppressedErrors()));
81 | }
82 |
83 | return builder.build();
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/filter/store/FilterStore.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config.filter.store;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileOutputStream;
7 | import java.io.InputStreamReader;
8 | import java.lang.reflect.Type;
9 | import java.util.LinkedList;
10 |
11 | import org.eclipse.core.runtime.IPath;
12 |
13 | import com.google.gson.Gson;
14 | import com.google.gson.reflect.TypeToken;
15 |
16 | import org.codechecker.eclipse.plugin.Activator;
17 | import org.codechecker.eclipse.plugin.config.filter.FilterConfiguration;
18 | import org.codechecker.eclipse.plugin.Logger;
19 | import org.eclipse.core.runtime.IStatus;
20 |
21 | public class FilterStore {
22 |
23 | private final String projectName;
24 |
25 | private LinkedList filterList;
26 |
27 | public FilterStore(String projectName) {
28 | super();
29 | this.projectName = projectName;
30 | this.filterList = new LinkedList<>();
31 | load();
32 | }
33 |
34 | public void addFilterConfiguration(FilterConfiguration n) {
35 | if (filterList.contains(n)) {
36 | return; //rename or other change
37 | }
38 | filterList.add(n);
39 | save();
40 | }
41 |
42 | public void removeFilterConfiguration(FilterConfiguration n) {
43 | filterList.remove(n);
44 | save();
45 | }
46 |
47 | public LinkedList getFilterList() {
48 | return filterList;
49 | }
50 |
51 | private void save() {
52 | //saveFile("global", true); -- TODO!
53 | saveFile(projectName, false);
54 | }
55 |
56 | private void load() {
57 | // loadFile("global", true); -- TODO! handle global configuration
58 | loadFile(projectName, false);
59 | }
60 |
61 | public String[] getNames() {
62 | LinkedList names = new LinkedList<>();
63 |
64 | for (FilterConfiguration fc : filterList) {
65 | names.add(fc.getName());
66 | }
67 |
68 | return names.toArray(new String[]{});
69 | }
70 |
71 | private void loadFile(String name, boolean isGlobal) {
72 | IPath p = Activator.getPreferencesPath();
73 | p = p.append("filters-" + name + ".json");
74 | Gson gson = new Gson();
75 | File f = p.toFile();
76 |
77 | if (!f.exists()) {
78 | saveFile(name, isGlobal);
79 | }
80 |
81 | FileInputStream fis;
82 | try {
83 | fis = new FileInputStream(f);
84 | InputStreamReader isr = new InputStreamReader(fis);
85 | BufferedReader bufferedReader = new BufferedReader(isr);
86 | StringBuilder sb = new StringBuilder();
87 | String line;
88 | while ((line = bufferedReader.readLine()) != null) {
89 | sb.append(line);
90 | }
91 |
92 | String json = sb.toString();
93 | LinkedList subList;
94 |
95 | Type listType = new TypeToken>() {
96 | }.getType();
97 |
98 | subList = gson.fromJson(json, listType);
99 |
100 | for (FilterConfiguration fc : subList) {
101 | filterList.add(fc);
102 | }
103 |
104 | } catch (Exception e) {
105 | Logger.log(IStatus.ERROR, " " + e);
106 | Logger.log(IStatus.ERROR, " " + e.getStackTrace());
107 | }
108 |
109 | }
110 |
111 | private void saveFile(String name, boolean isGlobal) {
112 | LinkedList subList = new LinkedList<>();
113 |
114 | for (FilterConfiguration fc : filterList) {
115 | if (fc.isGloballySaved() == isGlobal) {
116 | subList.add(fc);
117 | }
118 | }
119 |
120 | IPath p = Activator.getPreferencesPath();
121 | p = p.append("filters-" + name + ".json");
122 | Gson gson = new Gson();
123 | File f = p.toFile();
124 | try {
125 | FileOutputStream outputStream = new FileOutputStream(f);
126 | outputStream.write(gson.toJson(subList).getBytes());
127 | outputStream.close();
128 | } catch (Exception e) {
129 | Logger.log(IStatus.ERROR, " " + e);
130 | Logger.log(IStatus.INFO, " " + e.getStackTrace());
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/global/CcGlobalProperties.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config.global;
2 |
3 | import org.eclipse.jface.preference.PreferencePage;
4 | import org.eclipse.swt.widgets.Control;
5 | import org.eclipse.swt.widgets.Composite;
6 | import org.eclipse.ui.IWorkbench;
7 | import org.eclipse.ui.IWorkbenchPreferencePage;
8 | import org.codechecker.eclipse.plugin.config.CommonGui;
9 |
10 | import org.codechecker.eclipse.plugin.Logger;
11 | import org.eclipse.core.runtime.IStatus;
12 |
13 | public class CcGlobalProperties extends PreferencePage implements IWorkbenchPreferencePage {
14 |
15 | private static CommonGui commonGUI;
16 |
17 | public CcGlobalProperties(){
18 | super();
19 |
20 | commonGUI=new CommonGui();
21 | }
22 | @Override
23 | protected Control createContents(final Composite parent) {
24 |
25 | return commonGUI.createContents(parent);
26 | }
27 |
28 | @Override
29 | public void performDefaults() {
30 |
31 | commonGUI.performDefaults();
32 | super.performDefaults();
33 |
34 | }
35 |
36 | @Override
37 | public boolean isValid() {
38 |
39 | return true;
40 | }
41 |
42 | @Override
43 | public boolean performOk() {
44 |
45 | commonGUI.performOk();
46 | return super.performOk();
47 | }
48 |
49 | @Override
50 | public void init(IWorkbench workbench) {
51 | Logger.log(IStatus.INFO, "init called");
52 | // TODO Auto-generated method stub
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/global/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Global configuration related package.
3 | */
4 | package org.codechecker.eclipse.plugin.config.global;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Configuration related package for the plugin.
3 | */
4 | package org.codechecker.eclipse.plugin.config;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/project/CcProjectProperties.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.config.project;
2 | import org.eclipse.core.resources.IProject;
3 | import org.eclipse.swt.widgets.Composite;
4 | import org.eclipse.swt.widgets.Control;
5 |
6 | import org.eclipse.ui.IWorkbenchPropertyPage;
7 | import org.eclipse.ui.dialogs.PropertyPage;
8 | import org.codechecker.eclipse.plugin.config.CommonGui;
9 |
10 | import org.codechecker.eclipse.plugin.Logger;
11 | import org.eclipse.core.runtime.IStatus;
12 |
13 | public class CcProjectProperties extends PropertyPage implements IWorkbenchPropertyPage {
14 |
15 | private CommonGui commonGUI;
16 |
17 | public CcProjectProperties(){
18 | super();
19 | }
20 |
21 | @Override
22 | protected Control createContents(Composite parent) {
23 | IProject project = (IProject) this.getElement().getAdapter(IProject.class);
24 | commonGUI=new CommonGui(project);
25 | return commonGUI.createContents(parent);
26 | }
27 |
28 |
29 | @Override
30 | public void performDefaults() {
31 | if (commonGUI!=null)
32 | commonGUI.performDefaults();
33 | super.performDefaults();
34 | }
35 |
36 | @Override
37 | public boolean isValid() {
38 | return true;
39 | }
40 |
41 | @Override
42 | public boolean performOk() {
43 | if (commonGUI!=null)
44 | commonGUI.performOk();
45 | return super.performOk();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/project/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Project level configuration related package.
3 | */
4 | package org.codechecker.eclipse.plugin.config.project;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/init/EditorPartListener.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.init;
2 |
3 | import org.codechecker.eclipse.plugin.Logger;
4 | import org.codechecker.eclipse.plugin.config.CodeCheckerContext;
5 | import org.codechecker.eclipse.plugin.report.job.AnalyzeJob;
6 | import org.codechecker.eclipse.plugin.report.job.JobDoneChangeListener;
7 | import org.codechecker.eclipse.plugin.report.job.PlistParseJob;
8 | import org.eclipse.core.resources.IFile;
9 | import org.eclipse.core.resources.IProject;
10 | import org.eclipse.core.runtime.IStatus;
11 | import org.eclipse.core.runtime.jobs.IJobChangeEvent;
12 | import org.eclipse.ui.IEditorPart;
13 | import org.eclipse.ui.IFileEditorInput;
14 | import org.eclipse.ui.IPartListener;
15 | import org.eclipse.ui.IWorkbenchPart;
16 |
17 | public class EditorPartListener implements IPartListener {
18 |
19 | @Override
20 | public void partActivated(IWorkbenchPart partRef) {
21 | if (!(partRef instanceof IEditorPart)) {
22 | return;
23 | }
24 | Logger.log(IStatus.INFO, "Editor changed : " + partRef.getClass().getName());
25 | CodeCheckerContext.getInstance().refreshChangeEditorPart((IEditorPart) partRef);
26 | }
27 |
28 | @Override
29 | public void partBroughtToTop(IWorkbenchPart part) {
30 | }
31 |
32 | @Override
33 | public void partClosed(IWorkbenchPart part) {
34 | }
35 |
36 | @Override
37 | public void partDeactivated(IWorkbenchPart part) {
38 | }
39 |
40 | @Override
41 | public void partOpened(IWorkbenchPart part) {
42 | Logger.log(IStatus.INFO, "Editor Opened : " + part.getClass().getName());
43 | // if an editor is opened parse the reports if there is any.
44 | IFile file;
45 | try {
46 | file = ((IFileEditorInput) ((IEditorPart) part).getEditorInput()).getFile();
47 | } catch (ClassCastException e) {
48 | Logger.log(IStatus.WARNING, "Not a File Editor,early returning");
49 | return;
50 | }
51 |
52 | IProject project = file.getProject();
53 | if (CodeCheckerContext.getInstance().getCcProject(project) == null)
54 | return;
55 |
56 | AnalyzeJob analyzeJob = new AnalyzeJob(project, file.getLocation().toFile().toPath());
57 | PlistParseJob plistParseJob = new PlistParseJob(project);
58 | analyzeJob.setRule(project);
59 | plistParseJob.setRule(project);
60 | plistParseJob.addJobChangeListener(new JobDoneChangeListener() {
61 | @Override
62 | public void done(IJobChangeEvent event) {
63 | CodeCheckerContext.getInstance().refresAsync(project);
64 | }
65 | });
66 | analyzeJob.schedule();
67 | plistParseJob.schedule();
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/init/ProjectExplorerSelectionListener.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.init;
2 |
3 | import org.codechecker.eclipse.plugin.config.CodeCheckerContext;
4 | import org.eclipse.core.resources.IProject;
5 | import org.eclipse.core.resources.IResource;
6 | import org.eclipse.core.runtime.IAdaptable;
7 | import org.eclipse.jface.viewers.ISelection;
8 | import org.eclipse.jface.viewers.IStructuredSelection;
9 | import org.eclipse.ui.ISelectionListener;
10 | import org.eclipse.ui.IWorkbenchPart;
11 |
12 | public class ProjectExplorerSelectionListener implements ISelectionListener {
13 |
14 | @Override
15 | public void selectionChanged(IWorkbenchPart part, ISelection selection) {
16 | if (selection instanceof IStructuredSelection) {
17 | Object element = ((IStructuredSelection) selection).getFirstElement();
18 | if (element instanceof IAdaptable) {
19 | IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
20 | if (resource != null) {
21 | final IProject project = resource.getProject();
22 | if (project != null)
23 | CodeCheckerContext.getInstance().refreshChangeProject(project);
24 |
25 | }
26 | }
27 | }
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/perspective/CodeCheckerPerspectiveFactory.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.perspective;
2 |
3 | import org.eclipse.ui.IFolderLayout;
4 | import org.eclipse.ui.IPageLayout;
5 | import org.eclipse.ui.IPerspectiveFactory;
6 | import org.eclipse.ui.console.IConsoleConstants;
7 |
8 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
9 | import org.codechecker.eclipse.plugin.views.report.list.ReportListViewProject;
10 |
11 | public class CodeCheckerPerspectiveFactory implements IPerspectiveFactory {
12 |
13 | @Override
14 | public void createInitialLayout(IPageLayout layout) {
15 | defineActions(layout);
16 | defineLayout(layout);
17 | }
18 |
19 | private void defineLayout(IPageLayout layout) {
20 | // TODO Auto-generated method stub
21 |
22 | }
23 |
24 | private void defineActions(IPageLayout layout) {
25 | String editorArea = layout.getEditorArea();
26 |
27 | IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, (float) 0.26,
28 | editorArea);
29 | left.addView(IPageLayout.ID_PROJECT_EXPLORER);
30 |
31 | IFolderLayout middleLeft = layout.createFolder("middleLeft", IPageLayout.BOTTOM, (float)
32 | 0.33, "left");
33 | middleLeft.addView(ReportListView.ID);
34 | middleLeft.addView(ReportListViewProject.ID);
35 |
36 | IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, (float) 0.8,
37 | editorArea);
38 | right.addView(IConsoleConstants.ID_CONSOLE_VIEW);
39 | right.addView(IPageLayout.ID_OUTLINE);
40 | right.addView(IPageLayout.ID_TASK_LIST);
41 |
42 | IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, (float) 0.8,
43 | editorArea);
44 | bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/BugPathItem.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import com.google.common.base.MoreObjects;
4 | import com.google.common.collect.ComparisonChain;
5 |
6 | import java.util.Objects;
7 |
8 | public class BugPathItem implements Comparable {
9 |
10 | private final Position startPosition;
11 | private final Position endPosition;
12 | private final String message;
13 | private final String file;
14 |
15 | public BugPathItem(Position startPosition, Position endPosition, String message, String file) {
16 | this.startPosition = startPosition;
17 | this.endPosition = endPosition;
18 | this.message = message;
19 | this.file = file;
20 | }
21 |
22 | @Override
23 | public int compareTo(BugPathItem o) {
24 | return ComparisonChain.start().compare(file, o.file).compare(startPosition, o
25 | .startPosition).compare(endPosition, o.endPosition).compare(message, o.message)
26 | .result();
27 | }
28 |
29 | public Position getStartPosition() {
30 | return startPosition;
31 | }
32 |
33 | public Position getEndPosition() {
34 | return endPosition;
35 | }
36 |
37 | public String getMessage() {
38 | return message;
39 | }
40 |
41 | public String getFile() {
42 | return file;
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | return MoreObjects.toStringHelper(this).add("file", file).add("start", startPosition).add
48 | ("end", endPosition).add("message", message).toString();
49 | }
50 |
51 | @Override
52 | public int hashCode() {
53 | return Objects.hash(startPosition, endPosition, message, file);
54 | }
55 |
56 | public boolean equalPosition(Object obj) {
57 | if (obj instanceof BugPathItem) {
58 | BugPathItem oth = (BugPathItem) obj;
59 |
60 | return Objects.equals(startPosition, oth.startPosition) && Objects.equals
61 | (endPosition, oth.endPosition) && Objects.equals(file, oth.file);
62 | }
63 |
64 | return false;
65 | }
66 |
67 | @Override
68 | public boolean equals(Object obj) {
69 | if (obj instanceof BugPathItem) {
70 | BugPathItem oth = (BugPathItem) obj;
71 |
72 | return Objects.equals(startPosition, oth.startPosition) && Objects.equals
73 | (endPosition, oth.endPosition) && Objects.equals(message, oth.message) &&
74 | Objects.equals(file, oth.file);
75 | }
76 |
77 | return false;
78 | }
79 |
80 | public static class Position implements Comparable {
81 | private final long line;
82 | private final long column;
83 |
84 | public Position(long line, long column) {
85 | this.line = line;
86 | this.column = column;
87 | }
88 |
89 | public long getLine() {
90 | return line;
91 | }
92 |
93 | public long getColumn() {
94 | return column;
95 | }
96 |
97 | @Override
98 | public String toString() {
99 | return MoreObjects.toStringHelper(this).add("l", line).add("c", column).toString();
100 | }
101 |
102 | @Override
103 | public int hashCode() {
104 | return Objects.hash(line, column);
105 | }
106 |
107 | @Override
108 | public boolean equals(Object obj) {
109 | if (obj instanceof Position) {
110 | Position oth = (Position) obj;
111 |
112 | return Objects.equals(line, oth.line) && Objects.equals(column, oth.column);
113 | }
114 |
115 | return false;
116 | }
117 |
118 | @Override
119 | public int compareTo(Position o) {
120 | return ComparisonChain.start().compare(line, o.line).compare(column, o.column).result();
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/FileInfo.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import com.google.common.base.MoreObjects;
4 |
5 | import java.util.Objects;
6 |
7 | public class FileInfo {
8 |
9 | private final long fileId;
10 | private final String filePath;
11 | private final String fileContent;
12 |
13 | public FileInfo(long fileId, String filePath, String fileContent) {
14 | this.fileId = fileId;
15 | this.filePath = filePath;
16 | this.fileContent = fileContent;
17 | }
18 |
19 | public long getFileId() {
20 | return fileId;
21 | }
22 |
23 | public String getFilePath() {
24 | return filePath;
25 | }
26 |
27 | public String getFileContent() {
28 | return fileContent;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return MoreObjects.toStringHelper(this).add("fileId", fileContent).add("filePath",
34 | filePath).toString();
35 | }
36 |
37 | @Override
38 | public int hashCode() {
39 | return Objects.hash(fileId);
40 | }
41 |
42 | @Override
43 | public boolean equals(Object obj) {
44 | if (obj instanceof FileInfo) {
45 | FileInfo oth = (FileInfo) obj;
46 |
47 | return Objects.equals(fileId, oth.fileId);
48 | }
49 |
50 | return false;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/Listener.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | /**
4 | * Basic listener for job events.
5 | */
6 | public interface Listener {
7 |
8 | /**
9 | * Called when the job is started.
10 | *
11 | * Always called, unless an internal error happens during initialization.
12 | */
13 | void onStart(Object obj);
14 |
15 | /**
16 | * Called after the job is finished (no actions remain, every processing is done)
17 | */
18 | void onComplete();
19 |
20 | /**
21 | * Called after the job stops with a timeout.
22 | *
23 | * More result may come in after this, because timeout only means it won't start new ones.
24 | */
25 | void onTimeout();
26 |
27 | /**
28 | * Called when an internal error happens.
29 | *
30 | * Might be called before (without) start.
31 | */
32 | void onJobInternalError(RuntimeException e);
33 |
34 | }
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/PlistParser.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import java.io.File;
4 | import java.io.FilenameFilter;
5 | import java.io.IOException;
6 | import java.text.ParseException;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | import javax.xml.parsers.ParserConfigurationException;
11 |
12 | import org.codechecker.eclipse.plugin.Logger;
13 |
14 | import org.eclipse.core.resources.IProject;
15 | import org.eclipse.core.resources.ResourcesPlugin;
16 | import org.eclipse.core.runtime.IStatus;
17 | import org.xml.sax.SAXException;
18 |
19 | import com.dd.plist.NSArray;
20 | import com.dd.plist.NSDictionary;
21 | import com.dd.plist.NSNumber;
22 | import com.dd.plist.NSObject;
23 | import com.dd.plist.NSString;
24 | import com.dd.plist.PropertyListFormatException;
25 | import com.dd.plist.PropertyListParser;
26 | import com.google.common.base.Optional;
27 | import com.google.common.collect.ImmutableList;
28 | import com.google.common.collect.Iterables;
29 |
30 | import org.codechecker.eclipse.plugin.report.BugPathItem.Position;
31 |
32 | /**
33 | * Class for parsing the analysis result plist files.
34 | */
35 | public class PlistParser {
36 | IProject project;
37 |
38 | public PlistParser(IProject project) {
39 | this.project = project;
40 | }
41 |
42 | /**
43 | * Parses exactly one .plist file.
44 | * @param pathToFile The file to be parsed.
45 | */
46 | public SearchList parsePlist(File file, SearchList sl) {
47 | List riList = new ArrayList<>();
48 |
49 | NSDictionary dict;
50 | try {
51 | dict = (NSDictionary) PropertyListParser.parse(file);
52 | NSObject[] sourceFiles = ((NSArray) dict.objectForKey("files")).getArray();
53 | NSObject[] diagnostics = ((NSArray) dict.objectForKey("diagnostics")).getArray();
54 |
55 | for (NSObject diagnostic : diagnostics) {
56 | NSDictionary diag = (NSDictionary) diagnostic;
57 | String checkerName = ((NSString) diag.get("check_name")).getContent();
58 | String description = ((NSString) diag.get("description")).getContent();
59 |
60 | NSObject[] path = ((NSArray) diag.objectForKey("path")).getArray();
61 |
62 | List bugPathItemList = new ArrayList<>();
63 |
64 | for (NSObject bp : path) {
65 | NSDictionary bugPath = (NSDictionary) bp;
66 |
67 | // We are only interested in bug events
68 | if (((NSString) bugPath.get("kind")).getContent().equals("event")) {
69 | String message = ((NSString) bugPath.get("message")).getContent();
70 | NSDictionary location = (NSDictionary) bugPath.get("location");
71 | Integer fileIndex = ((NSNumber) location.get("file")).intValue();
72 | Integer line = ((NSNumber) location.get("line")).intValue();
73 | Integer col = ((NSNumber) location.get("col")).intValue();
74 | String filePath = ((NSString) sourceFiles[fileIndex]).getContent();
75 |
76 | BugPathItem bItem = new BugPathItem(new Position(line, col), new Position(line, col), message,
77 | filePath);
78 | bugPathItemList.add(bItem);
79 | }
80 | }
81 |
82 | ProblemInfo pInfo = new ProblemInfo(ImmutableList.copyOf(bugPathItemList));
83 |
84 | riList.add(new ReportInfo(checkerName, "testHash", Iterables.getLast(bugPathItemList).getFile(),
85 | description, 1, false, "testFile", Iterables.getLast(bugPathItemList), Optional.of(pInfo)));
86 | }
87 |
88 | ImmutableList uriList = ImmutableList.copyOf(riList);
89 | sl.addReports(uriList);
90 |
91 | } catch (ParserConfigurationException | ParseException | SAXException | PropertyListFormatException
92 | | IOException e) {
93 | // TODO Auto-generated catch block
94 | Logger.log(IStatus.ERROR, "Cannot Parse File :" + e.getMessage() + " in file: " + file.getName());
95 | //e.printStackTrace();
96 | }
97 |
98 | return sl;
99 | }
100 |
101 | // TODO javadoc!, and return parse results for storing them
102 | public SearchList processResultsForProject() {
103 | // TODO Get This
104 | String ws = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + "/.codechecker/"
105 | + project.getName() + "/results";
106 | Logger.log(IStatus.INFO, "Parsing plists in :" + ws);
107 | File file = new File(ws);
108 | SearchList sl = new SearchList();
109 | if (file.exists()) {
110 | for (File f : file.listFiles(new FilenameFilter() {
111 |
112 | @Override
113 | public boolean accept(File dir, String name) {
114 | if (name.toLowerCase().endsWith(".plist"))
115 | return true;
116 | return false;
117 | }
118 | })) {
119 | //Logger.log(IStatus.INFO, "Parsing plist :" + f);
120 | parsePlist(f, sl);
121 | }
122 | }
123 | return sl;
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/ProblemInfo.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import com.google.common.base.MoreObjects;
4 | import com.google.common.collect.ImmutableList;
5 |
6 | import java.util.Objects;
7 |
8 | //TODO Refactor this to be called BugPathList.
9 | /**
10 | * Contains a list of BugPathItems.
11 | */
12 | public class ProblemInfo {
13 |
14 | private final ImmutableList items;
15 |
16 | public ProblemInfo(ImmutableList items) {
17 | this.items = items;
18 | }
19 |
20 | public ImmutableList getItems() {
21 | return items;
22 | }
23 |
24 | @Override
25 | public String toString() {
26 | return MoreObjects.toStringHelper(this).add("items", items).toString();
27 | }
28 |
29 | @Override
30 | public int hashCode() {
31 | return Objects.hash(items);
32 | }
33 |
34 | @Override
35 | public boolean equals(Object obj) {
36 | if (obj instanceof ProblemInfo) {
37 | ProblemInfo oth = (ProblemInfo) obj;
38 |
39 | return Objects.equals(items, oth.items);
40 | }
41 |
42 | return false;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/ReportInfo.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import com.google.common.base.MoreObjects;
4 | import com.google.common.base.Optional;
5 | import com.google.common.collect.ComparisonChain;
6 |
7 | import java.util.Objects;
8 |
9 | /**
10 | * Responsible for storing all informaiton of a report.
11 | * Created by Zsolt on 2015.02.25..
12 | */
13 | public class ReportInfo implements Comparable {
14 |
15 | private final String checkerId;
16 | private final String bugHash;
17 | private final String checkedFile;
18 | private final String checkerMsg;
19 | private final long reportId;
20 | private final boolean suppressed;
21 | private final String file;
22 | private final BugPathItem lastBugPathItem;
23 | private final Optional bugPath;
24 |
25 | /**
26 | * Set every member at instantiation, there are no setter for the members.
27 | * @param checkerId The Checker that generated the report.
28 | * @param bugHash The hash associated with the repprt.
29 | * @param checkedFile TODO whats this the plist or the plist file section???
30 | * @param checkerMsg The detailed message of the checker
31 | * @param reportId ID
32 | * @param suppressed TODO DEPRECATED in this form?
33 | * @param file TODO meh
34 | * @param getLastBugPathItem TODO why do we need this
35 | * @param bugPath TODO when we have this?
36 | */
37 | public ReportInfo(String checkerId, String bugHash, String checkedFile, String checkerMsg,
38 | long reportId, boolean suppressed, String file, BugPathItem lastBugPathItem,
39 | Optional bugPath) {
40 | this.checkerId = checkerId;
41 | this.bugHash = bugHash;
42 | this.checkedFile = checkedFile;
43 | this.checkerMsg = checkerMsg;
44 | this.reportId = reportId;
45 | this.suppressed = suppressed;
46 | this.file = file;
47 | this.lastBugPathItem = lastBugPathItem;
48 | this.bugPath = bugPath;
49 | }
50 |
51 | public Optional getChildren() {
52 | return this.bugPath;
53 | }
54 |
55 | public String getCheckerId() {
56 | return checkerId;
57 | }
58 |
59 | public String getBugHash() {
60 | return bugHash;
61 | }
62 |
63 | public String getCheckedFile() {
64 | return checkedFile;
65 | }
66 |
67 | public String getCheckerMsg() {
68 | return checkerMsg;
69 | }
70 |
71 | public long getReportId() {
72 | return reportId;
73 | }
74 |
75 | public boolean isSuppressed() {
76 | return suppressed;
77 | }
78 |
79 | public String getFile() {
80 | return file;
81 | }
82 |
83 | public BugPathItem getLastBugPathItem() {
84 | return lastBugPathItem;
85 | }
86 |
87 | @Override
88 | public String toString() {
89 | return MoreObjects.toStringHelper(this).add("checkerId", checkerId).add("checkedFile",
90 | checkedFile).add("checkerMsg", checkerMsg).add("reportId", reportId).add
91 | ("suppressed", suppressed).add("file", file).add("lastBugPathItem",
92 | lastBugPathItem).toString();
93 | }
94 |
95 | @Override
96 | public int hashCode() {
97 | return Objects.hash(checkerId, checkedFile, checkerMsg, reportId, suppressed, file,
98 | lastBugPathItem);
99 | }
100 |
101 | @Override
102 | public boolean equals(Object obj) {
103 | if (obj instanceof ReportInfo) {
104 | ReportInfo oth = (ReportInfo) obj;
105 | return Objects.equals(checkerId, oth.checkerId) && Objects.equals(checkedFile, oth
106 | .checkedFile) && Objects.equals(checkerMsg, oth.checkerMsg) && Objects.equals
107 | (reportId, oth.reportId) && Objects.equals(suppressed, oth.suppressed) &&
108 | Objects.equals(file, oth.file) && Objects.equals(lastBugPathItem, oth
109 | .lastBugPathItem);
110 | }
111 |
112 | return false;
113 | }
114 |
115 | @Override
116 | public int compareTo(ReportInfo o) {
117 | return ComparisonChain.start().compare(file, o.file).compare(suppressed, o.suppressed)
118 | .compare(checkerMsg, o.checkerMsg).compare(lastBugPathItem.getStartPosition(), o
119 | .lastBugPathItem.getStartPosition()).compare(reportId, o.reportId).result();
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/ReportParser.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.eclipse.jdt.annotation.Nullable;
7 |
8 | import com.google.common.collect.ImmutableList;
9 |
10 | /**
11 | * This class is for filtering the reports in memory.
12 | *
13 | */
14 | public class ReportParser implements Runnable {
15 | private List listeners = new ArrayList();
16 | private SearchList reports;
17 | private String currentFileName;
18 |
19 | /**
20 | *
21 | * @param reports The in memory representation of the reports.
22 | * @param currentFileName The filename {@link @Nullable}. If null there will be no filtering.
23 | */
24 | public ReportParser(SearchList reports, @Nullable String currentFileName) {
25 | this.reports = reports;
26 | this.currentFileName = currentFileName;
27 | }
28 |
29 | /**
30 | * Processes reports for displaying. If filename is null no report gets filtered.
31 | */
32 | public void processReports(){
33 | //Parse The reports given the current filename
34 | if (reports == null ) return;
35 | if (currentFileName.isEmpty() || currentFileName == null)
36 | for (SearchListener listener : listeners){
37 | listener.onTotalCountAvailable(reports, 1);
38 | }
39 | else {
40 | //TODO really needs a test for ensuring that all reports get coped over
41 | SearchList filteredReoports = new SearchList();
42 | for (String checker : reports.getCheckers())
43 | for (ReportInfo rep : reports.getReportsFor(checker))
44 | for (BugPathItem bp : rep.getChildren().orNull().getItems())
45 | if (bp.getFile().equals(currentFileName)) {
46 | filteredReoports.addReports(ImmutableList.of(rep));
47 | for (SearchListener listener : listeners) {
48 | listener.onPartsArrived(filteredReoports);
49 | }
50 | }
51 | for (SearchListener listener : listeners){
52 | listener.onTotalCountAvailable(filteredReoports, 1);
53 | }
54 | }
55 | }
56 |
57 | /**
58 | * Adds a {@link SearchListener} listener to this instance.
59 | * @param listener The listener to be added.
60 | */
61 | public void addListener(SearchListener listener){
62 | listeners.add(listener);
63 | }
64 |
65 | @Override
66 | public void run() {
67 | processReports();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/ResultCount.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import com.google.common.base.MoreObjects;
4 |
5 | import java.util.Objects;
6 |
7 | public class ResultCount {
8 |
9 | private final long count;
10 |
11 | public ResultCount(long count) {
12 | this.count = count;
13 | }
14 |
15 | public long getCount() {
16 | return count;
17 | }
18 |
19 | @Override
20 | public String toString() {
21 | return MoreObjects.toStringHelper(this).add("count", count).toString();
22 | }
23 |
24 | @Override
25 | public int hashCode() {
26 | return Objects.hash(count);
27 | }
28 |
29 | @Override
30 | public boolean equals(Object obj) {
31 | if (obj instanceof ResultCount) {
32 | ResultCount oth = (ResultCount) obj;
33 | return Objects.equals(count, oth.count);
34 | }
35 |
36 | return false;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/ResultFilter.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import org.codechecker.eclipse.plugin.report.Severity;
4 |
5 | import com.google.common.base.MoreObjects;
6 | import com.google.common.base.Optional;
7 |
8 | import java.util.Objects;
9 |
10 | public class ResultFilter {
11 | private final Optional filepath;
12 | private final Optional checkerMsg;
13 | private final Severity severity;
14 | private final Optional checkerId;
15 | private final Optional buildTarget;
16 | private final boolean showSuppressedErrors;
17 |
18 | public ResultFilter(Optional filepath, Optional checkerMsg,
19 | Severity severity, Optional checkerId, Optional buildTarget, boolean
20 | showSuppressedErrors) {
21 | this.filepath = filepath;
22 | this.checkerMsg = checkerMsg;
23 | this.severity = severity;
24 | this.checkerId = checkerId;
25 | this.buildTarget = buildTarget;
26 | this.showSuppressedErrors = showSuppressedErrors;
27 | }
28 |
29 | public Optional getFilepath() {
30 | return filepath;
31 | }
32 |
33 | public Optional getCheckerMsg() {
34 | return checkerMsg;
35 | }
36 |
37 | public org.codechecker.eclipse.plugin.report.Severity getSeverity() {
38 | return severity;
39 | }
40 |
41 | public Optional getCheckerId() {
42 | return checkerId;
43 | }
44 |
45 | public Optional getBuildTarget() {
46 | return buildTarget;
47 | }
48 |
49 | public boolean isShowSuppressedErrors() {
50 | return showSuppressedErrors;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return MoreObjects.toStringHelper(this).add("filepath", filepath).add("checkerMsg",
56 | checkerMsg).add("severity", severity).add("checkerID", checkerId).add
57 | ("buildTarget", buildTarget).add("suppressed", showSuppressedErrors).toString();
58 | }
59 |
60 | @Override
61 | public int hashCode() {
62 | return Objects.hash(filepath, checkerMsg, severity, checkerId, buildTarget,
63 | showSuppressedErrors);
64 | }
65 |
66 | @Override
67 | public boolean equals(Object obj) {
68 | if (obj instanceof ResultFilter) {
69 | ResultFilter oth = (ResultFilter) obj;
70 |
71 | return Objects.equals(filepath, oth.filepath) && Objects.equals(checkerMsg, oth
72 | .checkerMsg) && Objects.equals(severity, oth.severity) && Objects.equals
73 | (checkerId, oth.checkerId) && Objects.equals(buildTarget, oth.buildTarget) &&
74 | Objects.equals(showSuppressedErrors, oth.showSuppressedErrors);
75 | }
76 | return false;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/ResultList.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import com.google.common.base.MoreObjects;
4 | import com.google.common.collect.ImmutableList;
5 |
6 | import java.util.Objects;
7 |
8 | public class ResultList {
9 |
10 | private final ImmutableList runResultList;
11 |
12 | public ResultList(ImmutableList runResultList) {
13 | this.runResultList = runResultList;
14 | }
15 |
16 | public ImmutableList getRunResultList() {
17 | return runResultList;
18 | }
19 |
20 | @Override
21 | public String toString() {
22 | return MoreObjects.toStringHelper(this).add("result", runResultList).toString();
23 | }
24 |
25 | @Override
26 | public int hashCode() {
27 | return Objects.hash(runResultList);
28 | }
29 |
30 | @Override
31 | public boolean equals(Object obj) {
32 | if (obj instanceof ResultList) {
33 | ResultList oth = (ResultList) obj;
34 | return Objects.equals(runResultList, oth.runResultList);
35 | }
36 |
37 | return false;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/RunInfo.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import com.google.common.base.MoreObjects;
4 |
5 | import org.joda.time.DateTime;
6 |
7 | import java.util.Objects;
8 |
9 | public class RunInfo {
10 | private final long runId;
11 | private final DateTime runDate;
12 | private final String name;
13 | private final long duration;
14 | private final long resultCount;
15 |
16 | public RunInfo(long runId, DateTime runDate, String name, long duration, long resultCount) {
17 | this.runId = runId;
18 | this.runDate = runDate;
19 | this.name = name;
20 | this.duration = duration;
21 | this.resultCount = resultCount;
22 | }
23 |
24 | public long getRunId() {
25 | return runId;
26 | }
27 |
28 | public DateTime getRunDate() {
29 | return runDate;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | public long getDuration() {
37 | return duration;
38 | }
39 |
40 | public long getResultCount() {
41 | return resultCount;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return MoreObjects.toStringHelper(this).add("runID", runId).add("runDate", runDate).add
47 | ("name", name).add("duration", duration).add("count", resultCount).toString();
48 | }
49 |
50 | @Override
51 | public int hashCode() {
52 | return Objects.hash(runId, runDate, name, duration, resultCount);
53 | }
54 |
55 | @Override
56 | public boolean equals(Object obj) {
57 | if (obj instanceof RunInfo) {
58 | RunInfo oth = (RunInfo) obj;
59 |
60 | return Objects.equals(runId, oth.runId) && Objects.equals(runDate, oth.runDate) &&
61 | Objects.equals(name, oth.name) && Objects.equals(duration, oth.duration) &&
62 | Objects.equals(resultCount, oth.resultCount);
63 | }
64 |
65 | return false;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/SearchList.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 |
4 | import org.codechecker.eclipse.plugin.report.ReportInfo;
5 | import org.codechecker.eclipse.plugin.runtime.LogI;
6 | import org.codechecker.eclipse.plugin.runtime.SLogger;
7 |
8 | import com.google.common.base.Optional;
9 | import com.google.common.collect.ImmutableList;
10 | import com.google.common.collect.Multimap;
11 | import com.google.common.collect.TreeMultimap;
12 |
13 |
14 | import java.util.Collection;
15 | import java.util.Set;
16 |
17 | /**
18 | * Stores all report information for a project.
19 | *
20 | */
21 | public class SearchList {
22 |
23 | private final Multimap reports;
24 |
25 | private Optional totalReportCount;
26 |
27 | public SearchList() {
28 | this.reports = TreeMultimap.create();
29 | totalReportCount = Optional.absent();
30 | }
31 |
32 | public void addReports(ImmutableList reports) {
33 | for (ReportInfo report : reports) {
34 | if (this.reports.containsValue(report)) {
35 | //SLogger.log(LogI.WARNING, "Duplicate report in the result list: " + report);
36 | }
37 | this.reports.put(report.getCheckerId(), report);
38 | }
39 | }
40 |
41 | public Optional getTotalReportCount() {
42 | return totalReportCount;
43 | }
44 |
45 | public void setTotalReportCount(Integer totalReportCount) {
46 | this.totalReportCount = Optional.of(totalReportCount);
47 | }
48 |
49 | public Integer getRecordCount() {
50 | return reports.size();
51 | }
52 |
53 | public Set getCheckers() {
54 | return reports.keySet();
55 | }
56 |
57 | public Collection getReportsFor(String checker) {
58 | return reports.get(checker);
59 | }
60 |
61 | /*public ProblemInfoJob getBugPathJobFor(ReportInfo report, int priority, Optional
62 | deadline) {
63 | return new ProblemInfoJob(new ProblemInfoRequest(this.request.getServer(), report
64 | .getReportId()), priority, deadline);
65 | }*/
66 | }
67 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/SearchListener.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | import org.codechecker.eclipse.plugin.report.ReportInfo;
4 |
5 | import com.google.common.collect.ImmutableList;
6 |
7 | public interface SearchListener extends Listener {
8 | //TODO Refactor without jobs
9 | // void onTotalCountAvailable(SearchJob searchJob, SearchList result, int count);
10 | void onTotalCountAvailable(SearchList result, int count);
11 |
12 | // void onPartsArrived(SearchJob searchJob, SearchList result, ImmutableList runResultList);
13 | void onPartsArrived(SearchList result);
14 | }
15 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/Severity.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report;
2 |
3 | public enum Severity {
4 | STYLE(0), LOW(1), MEDIUM(2), HIGH(3), CRITICAL(4), ANY(5);
5 |
6 | private final int value;
7 |
8 | private Severity(int value) {
9 | this.value = value;
10 | }
11 |
12 | public int getValue() {
13 | return value;
14 | }
15 | }
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/job/JobDoneChangeListener.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report.job;
2 |
3 | import org.eclipse.core.runtime.jobs.IJobChangeEvent;
4 | import org.eclipse.core.runtime.jobs.IJobChangeListener;
5 |
6 | /**
7 | * Reducer Class for JobChangeListener interface.
8 | *
9 | */
10 | public abstract class JobDoneChangeListener implements IJobChangeListener {
11 |
12 | @Override
13 | public abstract void done(IJobChangeEvent event);
14 |
15 | @Override
16 | public void aboutToRun(IJobChangeEvent arg0) {}
17 |
18 | @Override
19 | public void awake(IJobChangeEvent arg0) {}
20 |
21 | @Override
22 | public void running(IJobChangeEvent arg0) {}
23 |
24 | @Override
25 | public void scheduled(IJobChangeEvent arg0) {}
26 |
27 | @Override
28 | public void sleeping(IJobChangeEvent arg0) {}
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/job/PlistParseJob.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.report.job;
2 |
3 | import org.eclipse.core.resources.IProject;
4 | import org.eclipse.core.runtime.IProgressMonitor;
5 | import org.eclipse.core.runtime.IStatus;
6 | import org.eclipse.core.runtime.Status;
7 | import org.eclipse.core.runtime.jobs.Job;
8 |
9 | import org.codechecker.eclipse.plugin.Logger;
10 | import org.codechecker.eclipse.plugin.config.CodeCheckerContext;
11 | import org.codechecker.eclipse.plugin.report.PlistParser;
12 | import org.codechecker.eclipse.plugin.report.SearchList;
13 |
14 | /**
15 | * This {@link Job} manages the parsing of the CodeChecker Analysis results.
16 | * Should be scheduled when:
17 | * - A project is opened.
18 | * - A project is being built, after an {@link AnalyzeJob}.
19 | *
20 | */
21 | public class PlistParseJob extends Job{
22 |
23 | private IProject project;
24 |
25 | /**
26 | * Hidden default ctor to avoid incorrect usage, project is always needed.
27 | * @param name NOT USED
28 | */
29 | private PlistParseJob(String name) {
30 | super(name);
31 | }
32 |
33 | /**
34 | * Use this ctor to create a PlistParseJob with a valid project.
35 | * @param project The project that's being processed.
36 | */
37 | public PlistParseJob(IProject project) {
38 | super("PlistParseJob");
39 | this.project = project;
40 | }
41 |
42 | @Override
43 | protected IStatus run(IProgressMonitor arg0) {
44 | Logger.log(IStatus.INFO, "Parsing analysis results.");
45 | parsePlistForProject(project);
46 | return Status.OK_STATUS;
47 | }
48 |
49 | /**
50 | * Method for parsing every plist result generated by the analyzer.
51 | * @param project the project that's results is needed to be parsed.
52 | */
53 | public void parsePlistForProject(final IProject project) {
54 | Logger.log(IStatus.INFO,
55 | "Started Plist Parsing for project: "+project.getName());
56 | final PlistParser parser = new PlistParser(project);
57 | SearchList sl;
58 | sl = parser.processResultsForProject();
59 | CodeCheckerContext.getInstance().setReportForProject(project, sl);
60 | Logger.log(IStatus.INFO,
61 | "Finished Plist Parsing for project: "+project.getName());
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/job/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Report related job and job utility classes.
3 | */
4 | package org.codechecker.eclipse.plugin.report.job;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/report/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Report related classes.
3 | */
4 | package org.codechecker.eclipse.plugin.report;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/IShellExecutorHelperFactory.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.runtime;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Interface for {@link ShellExecutorHelper} factory.
7 | */
8 | public interface IShellExecutorHelperFactory {
9 | /**
10 | * Method for creating {@link ShellExecutorHelper}.
11 | *
12 | * @param env
13 | * An environment to be used with the ShellExecutorHelper.
14 | * @return A {@link ShellExecutorHelper} instance.
15 | */
16 | public ShellExecutorHelper createShellExecutorHelper(Map env);
17 | }
18 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/LogI.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.runtime;
2 |
3 | public interface LogI {
4 | //IStatus severities
5 | static int CANCEL=8;
6 | static int ERROR=4;
7 | static int INFO=1;
8 | static int OK=0;
9 | static int WARNING=2;
10 | public void log(int severity,String message);
11 | public void consoleLog(String message);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/OnCheckCallback.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.runtime;
2 |
3 | public interface OnCheckCallback {
4 | void analysisStarted(String command);//called when the analysis starts
5 | void analysisFinished(String result);//called when analysis finished
6 | }
7 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/SLogger.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.runtime;
2 |
3 |
4 | public class SLogger {
5 | private static LogI logger = null;
6 | public static void setLogger(LogI l){
7 | logger=l;
8 | }
9 | public static void log(int level,String message){
10 | if (logger!=null){
11 | logger.log(level,message);
12 | }
13 | }
14 | public static void consoleLog(String message){
15 | if (logger!=null){
16 | logger.consoleLog(message);
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/ShellExecutorHelperFactory.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.runtime;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Implementation of {@link IShellExecutorHelperFactory}.
7 | */
8 | public class ShellExecutorHelperFactory implements IShellExecutorHelperFactory {
9 |
10 | @Override
11 | public ShellExecutorHelper createShellExecutorHelper(Map env) {
12 | return new ShellExecutorHelper(env);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Command line related package.
3 | */
4 | package org.codechecker.eclipse.plugin.runtime;
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/config/filter/ListContentProvider.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.config.filter;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.commons.lang3.ArrayUtils;
6 | import org.eclipse.jface.viewers.IContentProvider;
7 | import org.eclipse.jface.viewers.IStructuredContentProvider;
8 | import org.eclipse.jface.viewers.Viewer;
9 |
10 | import org.codechecker.eclipse.plugin.Logger;
11 | import org.eclipse.core.runtime.IStatus;
12 |
13 | public class ListContentProvider implements IContentProvider, IStructuredContentProvider {
14 |
15 | @Override
16 | public Object[] getElements(Object inputElement) {
17 | if (inputElement instanceof List) {
18 | Logger.log(IStatus.INFO, "SERVER_GUI_MSG >> Displaying list");
19 | return ((List) inputElement).toArray();
20 | }
21 | return ArrayUtils.toArray();
22 | }
23 |
24 | @Override
25 | public void dispose() {
26 | }
27 |
28 | @Override
29 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/console/ConsoleFactory.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.console;
2 |
3 | import org.eclipse.ui.IWorkbenchPage;
4 | import org.eclipse.ui.PartInitException;
5 | import org.eclipse.ui.PlatformUI;
6 | import org.eclipse.ui.console.ConsolePlugin;
7 | import org.eclipse.ui.console.IConsole;
8 | import org.eclipse.ui.console.IConsoleFactory;
9 | import org.eclipse.ui.console.IConsoleManager;
10 | import org.eclipse.ui.console.MessageConsole;
11 | import org.eclipse.ui.console.MessageConsoleStream;
12 |
13 | public class ConsoleFactory implements IConsoleFactory{
14 |
15 | private static MessageConsole console;
16 |
17 | private static MessageConsole getConsole() {
18 | if(console == null) {
19 | console = new MessageConsole("CodeChecker Console", null);
20 | }
21 | return console;
22 | }
23 |
24 | public static void consoleWrite(String msg) {
25 | console = getConsole();
26 | MessageConsoleStream out = console.newMessageStream();
27 | out.println(msg);
28 | }
29 |
30 | public static void setActiveConsole() {
31 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
32 | try {
33 | page.showView(console.getName());
34 | } catch (PartInitException e) {}
35 | }
36 |
37 | @Override
38 | public void openConsole() {
39 | console = getConsole();
40 | if (console != null) {
41 | IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
42 | IConsole[] existing = manager.getConsoles();
43 | boolean exists = false;
44 | for (int i = 0; i < existing.length; i++) {
45 | if(console == existing[i])
46 | exists = true;
47 | }
48 | if(!exists)
49 | manager.addConsoles(new IConsole[] {console});
50 | manager.showConsoleView(console);
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/ReportListViewCustom.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list;
2 |
3 | import java.util.LinkedList;
4 |
5 | import org.eclipse.core.resources.IProject;
6 |
7 | import org.codechecker.eclipse.plugin.config.filter.Filter;
8 | import org.codechecker.eclipse.plugin.config.filter.FilterConfiguration;
9 |
10 | public class ReportListViewCustom extends ReportListView {
11 |
12 | public static final String ID = "org.codechecker.eclipse.plugin.views.ReportListViewCustom";
13 |
14 | public void onEditorChanged(IProject project) {
15 | super.onEditorChanged(project, "");
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/ReportListViewListener.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list;
2 |
3 | import java.util.List;
4 | import java.util.ArrayList;
5 | import java.util.Collections;
6 |
7 | import org.eclipse.swt.widgets.Display;
8 |
9 | import com.google.common.base.Optional;
10 | import com.google.common.collect.ImmutableList;
11 |
12 | import org.codechecker.eclipse.plugin.report.BugPathItem;
13 | import org.codechecker.eclipse.plugin.report.BugPathItem.Position;
14 | import org.codechecker.eclipse.plugin.report.ProblemInfo;
15 | import org.codechecker.eclipse.plugin.report.ReportInfo;
16 | import org.codechecker.eclipse.plugin.report.SearchList;
17 | import org.codechecker.eclipse.plugin.report.SearchListener;
18 |
19 | public class ReportListViewListener implements SearchListener {
20 |
21 |
22 | private final ReportListView target;
23 |
24 | public ReportListViewListener(ReportListView target) {
25 | this.target = target;
26 | }
27 |
28 | @Override
29 | public void onComplete() {
30 | }
31 |
32 | @Override
33 | public void onJobInternalError(RuntimeException arg1) {
34 | }
35 |
36 | @Override
37 | public void onStart(final Object job) {
38 | Display.getDefault().syncExec(new Runnable() {
39 | @Override
40 | public void run() {
41 | // Invalidate target.
42 | //target.changeModel(job.getResult());
43 | }
44 | });
45 | }
46 |
47 | @Override
48 | public void onTimeout() {}
49 |
50 | //TODO UPLIFT use arguments in function.
51 | @Override
52 | public void onPartsArrived(SearchList sl) {
53 | // append insted of replace model?
54 | target.changeModel(sl);
55 | Display.getDefault().syncExec(new Runnable() {
56 | @Override
57 | public void run() {
58 | target.refresh(null);
59 | }
60 | });
61 | }
62 |
63 | @Override
64 | public void onTotalCountAvailable(SearchList sl, int arg2) {
65 | target.changeModel(sl);
66 | Display.getDefault().syncExec(new Runnable() {
67 | @Override
68 | public void run() {
69 | target.refresh(null);
70 | }
71 | });
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/ReportListViewProject.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list;
2 |
3 | import org.eclipse.core.resources.IProject;
4 |
5 | public class ReportListViewProject extends ReportListView {
6 |
7 | public static final String ID = "org.codechecker.eclipse.plugin.views.ReportListProject";
8 |
9 | public void onEditorChanged(IProject project) {
10 | super.onEditorChanged(project, "");
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/NewInstanceAction.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action;
2 |
3 | import org.eclipse.jface.action.IAction;
4 | import org.eclipse.ui.ISharedImages;
5 | import org.eclipse.ui.IWorkbenchPage;
6 | import org.eclipse.ui.PartInitException;
7 | import org.eclipse.ui.PlatformUI;
8 |
9 | import org.codechecker.eclipse.plugin.config.CodeCheckerContext;
10 | import org.codechecker.eclipse.plugin.views.report.list.ReportListViewCustom;
11 | import org.codechecker.eclipse.plugin.views.report.list.action.showas.TreeAwareAction;
12 | import org.codechecker.eclipse.plugin.Logger;
13 | import org.eclipse.core.runtime.IStatus;
14 |
15 | public class NewInstanceAction extends TreeAwareAction {
16 |
17 |
18 | public NewInstanceAction(ReportListViewCustom listView) {
19 | super(listView, "Create new ReportList", IAction.AS_PUSH_BUTTON);
20 | setToolTipText("Create new ReportList");
21 | setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor
22 | (ISharedImages.IMG_OBJ_ADD));
23 | }
24 |
25 | @Override
26 | public void run() {
27 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
28 |
29 | try {
30 | String secondaryId = "ReportList" + Math.ceil(Math.random() * 100);
31 | page.showView(ReportListViewCustom.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
32 | CodeCheckerContext.getInstance().refreshAddCustomReportListView(secondaryId);
33 | } catch (PartInitException e) {
34 | // TODO Auto-generated catch block
35 | Logger.log(IStatus.ERROR, " " + e);
36 | Logger.log(IStatus.INFO, " " + e.getStackTrace());
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/ShowFilterConfigurationDialog.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action;
2 |
3 | import org.eclipse.cdt.utils.Platform;
4 | import org.eclipse.core.runtime.FileLocator;
5 | import org.eclipse.core.runtime.Path;
6 | import org.eclipse.jface.action.IAction;
7 | import org.eclipse.jface.resource.ImageDescriptor;
8 | import org.eclipse.swt.widgets.Shell;
9 | import org.eclipse.ui.PlatformUI;
10 | import org.osgi.framework.Bundle;
11 |
12 | import org.codechecker.eclipse.plugin.Activator;
13 | import org.codechecker.eclipse.plugin.views.config.filter.FilterConfigurationDialog;
14 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
15 | import org.codechecker.eclipse.plugin.views.report.list.action.showas.TreeAwareAction;
16 |
17 |
18 | import java.net.URL;
19 |
20 | public class ShowFilterConfigurationDialog extends TreeAwareAction {
21 |
22 |
23 | public ShowFilterConfigurationDialog(ReportListView listView) {
24 | super(listView, "Show Filter Configurators", IAction.AS_PUSH_BUTTON);
25 | setToolTipText("Show Filter Configurators");
26 | Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
27 | final URL fullPathString = FileLocator.find(bundle, new Path("icons/filter.png"), null);
28 | setImageDescriptor(ImageDescriptor.createFromURL(fullPathString));
29 | }
30 |
31 | @Override
32 | public void run() {
33 | Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
34 |
35 | FilterConfigurationDialog dialog = new FilterConfigurationDialog(activeShell, listView
36 | .getActiveConfiguration().dup(), listView.getCurrentProject().getName());
37 |
38 | int result = dialog.open();
39 |
40 | if (result == 0) {
41 | listView.setActiveConfiguration(dialog.getCurrentConfiguration());
42 | }
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/rerun/RefreshAction.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action.rerun;
2 |
3 | import org.eclipse.jface.action.IAction;
4 |
5 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
6 | import org.codechecker.eclipse.plugin.views.report.list.action.showas.TreeAwareAction;
7 |
8 | public class RefreshAction extends TreeAwareAction {
9 |
10 | public RefreshAction(ReportListView listView) {
11 | super(listView, "Refresh reports", IAction.AS_PUSH_BUTTON);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/rerun/RerunAllAction.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action.rerun;
2 |
3 | import org.eclipse.jface.action.IAction;
4 |
5 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
6 | import org.codechecker.eclipse.plugin.views.report.list.action.showas.TreeAwareAction;
7 |
8 | public class RerunAllAction extends TreeAwareAction {
9 |
10 | public RerunAllAction(ReportListView listView) {
11 | super(listView, "Rerun everything", IAction.AS_PUSH_BUTTON);
12 | setEnabled(false);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/rerun/RerunSelectedAction.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action.rerun;
2 |
3 | import org.eclipse.jface.action.IAction;
4 |
5 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
6 | import org.codechecker.eclipse.plugin.views.report.list.action.showas.TreeAwareAction;
7 |
8 | public class RerunSelectedAction extends TreeAwareAction {
9 |
10 | public RerunSelectedAction(ReportListView listView) {
11 | super(listView, "Rerun selected reports", IAction.AS_PUSH_BUTTON);
12 | setEnabled(false);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/showas/CheckerGroupAction.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action.showas;
2 |
3 | import org.eclipse.jface.action.IAction;
4 |
5 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
6 | import org.codechecker.eclipse.plugin.views.report.list.provider.content.CheckerGroupContentProvider;
7 | import org.codechecker.eclipse.plugin.views.report.list.provider.label.BasicViewLabelProvider;
8 |
9 | public class CheckerGroupAction extends TreeAwareAction {
10 |
11 | public CheckerGroupAction(ReportListView listView, boolean checked) {
12 | super(listView, "Group by checkers", IAction.AS_RADIO_BUTTON, checked);
13 | }
14 |
15 | @Override
16 | public void run() {
17 | if (isChecked()) {
18 | listView.setProviders(new BasicViewLabelProvider(listView), new
19 | CheckerGroupContentProvider(listView));
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/showas/CheckerTreeAction.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action.showas;
2 |
3 | import org.eclipse.jface.action.IAction;
4 |
5 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
6 | import org.codechecker.eclipse.plugin.views.report.list.provider.content.TreeCheckerContentProvider;
7 | import org.codechecker.eclipse.plugin.views.report.list.provider.label.LastPartLabelProvider;
8 |
9 | public class CheckerTreeAction extends TreeAwareAction {
10 |
11 | public CheckerTreeAction(ReportListView listView, boolean checked) {
12 | super(listView, "Group by hierarchical checkers", IAction.AS_RADIO_BUTTON, checked);
13 | }
14 |
15 | @Override
16 | public void run() {
17 | if (isChecked()) {
18 | listView.setProviders(new LastPartLabelProvider(listView), new
19 | TreeCheckerContentProvider(listView));
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/action/showas/TreeAwareAction.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.action.showas;
2 |
3 | import org.eclipse.jface.action.Action;
4 |
5 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
6 |
7 | public class TreeAwareAction extends Action {
8 |
9 | protected final ReportListView listView;
10 |
11 | public TreeAwareAction(ReportListView listView, String name, int type) {
12 | super(name, type);
13 | this.listView = listView;
14 | }
15 |
16 | public TreeAwareAction(ReportListView listView, String name, int type, boolean checked) {
17 | super(name, type);
18 | this.listView = listView;
19 | setChecked(checked);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/provider/content/CheckerGroupContentProvider.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.provider.content;
2 |
3 | import java.util.ArrayList;
4 |
5 | import org.apache.commons.lang3.ArrayUtils;
6 | import org.eclipse.jface.viewers.ITreeContentProvider;
7 | import org.eclipse.jface.viewers.Viewer;
8 |
9 | import com.google.common.base.Optional;
10 | import com.google.common.base.Predicate;
11 | import com.google.common.collect.Iterables;
12 |
13 | import org.codechecker.eclipse.plugin.report.BugPathItem;
14 | import org.codechecker.eclipse.plugin.report.ProblemInfo;
15 | import org.codechecker.eclipse.plugin.report.ReportInfo;
16 | import org.codechecker.eclipse.plugin.report.SearchList;
17 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
18 |
19 | public class CheckerGroupContentProvider implements ITreeContentProvider {
20 |
21 | private final ReportListView reportListView;
22 |
23 | public CheckerGroupContentProvider(ReportListView reportListView) {
24 | this.reportListView = reportListView;
25 | }
26 |
27 | @Override
28 | public Object getParent(Object child) {
29 | if (child instanceof String) {
30 | return this.reportListView.getReportList().orNull();
31 | }
32 |
33 | if (child instanceof ReportInfo) {
34 | return ((ReportInfo) child).getCheckerId();
35 | }
36 |
37 | return null;
38 | }
39 |
40 | @Override
41 | public void dispose() {
42 | // nop
43 | }
44 |
45 | @Override
46 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
47 | // nop
48 | }
49 |
50 | @Override
51 | public Object[] getElements(Object inputElement) {
52 | return getChildren(inputElement);
53 | }
54 |
55 | @Override
56 | public Object[] getChildren(Object parentElement) {
57 |
58 | if (parentElement instanceof SearchList) {
59 | return this.reportListView.getReportList().get().getCheckers().toArray();
60 | }
61 |
62 | if (parentElement instanceof String) {
63 | return this.reportListView.getReportList().get().getReportsFor((String)
64 | parentElement).toArray();
65 | }
66 |
67 | if (parentElement instanceof ReportInfo) {
68 | ReportInfo ri = (ReportInfo) parentElement;
69 | Optional bp = ri.getChildren();
70 | if (bp != null && bp.isPresent()) {
71 | ArrayList result = new ArrayList<>(bp.get().getItems());
72 | Iterables.removeIf(result, new Predicate() {
73 | @Override
74 | public boolean apply(BugPathItem pi) {
75 | return "".equals(pi.getMessage());
76 | }
77 | });
78 | return result.toArray();
79 | }
80 | }
81 |
82 | return ArrayUtils.toArray();
83 | }
84 |
85 | @Override
86 | public boolean hasChildren(Object element) {
87 | if(element instanceof ReportInfo || element instanceof SearchList || element instanceof String) {
88 | return true;
89 | }
90 | return false;
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/views/report/list/provider/content/TreeCheckerContentProvider.java:
--------------------------------------------------------------------------------
1 | package org.codechecker.eclipse.plugin.views.report.list.provider.content;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashSet;
5 | import java.util.Set;
6 |
7 | import org.apache.commons.lang3.ArrayUtils;
8 | import org.codechecker.eclipse.plugin.report.BugPathItem;
9 | import org.codechecker.eclipse.plugin.report.ProblemInfo;
10 | import org.codechecker.eclipse.plugin.report.ReportInfo;
11 | import org.codechecker.eclipse.plugin.report.SearchList;
12 | import org.codechecker.eclipse.plugin.views.report.list.ReportListView;
13 | import org.eclipse.jface.viewers.ITreeContentProvider;
14 | import org.eclipse.jface.viewers.Viewer;
15 |
16 | import com.google.common.base.Optional;
17 | import com.google.common.base.Predicate;
18 | import com.google.common.collect.Iterables;
19 |
20 | public class TreeCheckerContentProvider implements ITreeContentProvider {
21 |
22 | private final ReportListView reportListView;
23 |
24 | public TreeCheckerContentProvider(ReportListView reportListView) {
25 | this.reportListView = reportListView;
26 | }
27 |
28 | @Override
29 | public Object getParent(Object child) {
30 | if (child instanceof String) {
31 | String checker = (String) child;
32 | for (String s : this.reportListView.getReportList().get().getCheckers()) {
33 | if (checker.startsWith(s + ".")) {
34 | return s;
35 | }
36 | }
37 | return this.reportListView.getReportList().orNull();
38 | }
39 |
40 | if (child instanceof ReportInfo) {
41 | return ((ReportInfo) child).getCheckerId();
42 | }
43 |
44 | return null;
45 | }
46 |
47 | @Override
48 | public void dispose() {
49 | // nop
50 | }
51 |
52 | @Override
53 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
54 | // nop
55 | }
56 |
57 | @Override
58 | public Object[] getElements(Object inputElement) {
59 | return getChildren(inputElement);
60 | }
61 |
62 | @Override
63 | public Object[] getChildren(Object parentElement) {
64 |
65 | if (parentElement instanceof SearchList) {
66 | Set tops = new HashSet<>();
67 | for (String s : this.reportListView.getReportList().get().getCheckers()) {
68 | tops.add(s.split("\\.")[0]);
69 | }
70 | return tops.toArray();
71 | }
72 |
73 | if (parentElement instanceof String) {
74 |
75 | String parent = (String) parentElement;
76 | String[] splittedParent = parent.split("\\.");
77 | int parentLevel = splittedParent.length;
78 | Set