diff options
Diffstat (limited to 'org.eclipse.cdt.codan.checkers.ui')
43 files changed, 276 insertions, 0 deletions
diff --git a/org.eclipse.cdt.codan.checkers.ui/.classpath b/org.eclipse.cdt.codan.checkers.ui/.classpath new file mode 100644 index 0000000..1fa3e68 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.cdt.codan.checkers.ui/.project b/org.eclipse.cdt.codan.checkers.ui/.project new file mode 100644 index 0000000..4c29868 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.cdt.codan.checkers.ui</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Entries new file mode 100644 index 0000000..2303ef8 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Entries @@ -0,0 +1 @@ +/org.eclipse.jdt.core.prefs/1.1/Sat Apr 18 02:11:07 2009// diff --git a/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Repository new file mode 100644 index 0000000..5684555 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/.settings diff --git a/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.cdt.codan.checkers.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..5edb6f2 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Fri Apr 17 21:55:42 EDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/org.eclipse.cdt.codan.checkers.ui/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/CVS/Entries new file mode 100644 index 0000000..47e41bc --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/CVS/Entries @@ -0,0 +1,7 @@ +/.classpath/1.1/Sat Apr 18 02:11:07 2009// +/.project/1.1/Sat Apr 18 02:11:07 2009// +D/.settings//// +D/META-INF//// +/build.properties/1.1/Sat Apr 18 02:11:07 2009// +/plugin.xml/1.1/Sat Apr 18 02:11:07 2009// +D/src//// diff --git a/org.eclipse.cdt.codan.checkers.ui/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/CVS/Repository new file mode 100644 index 0000000..c7e5368 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui diff --git a/org.eclipse.cdt.codan.checkers.ui/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Entries new file mode 100644 index 0000000..bb6a97a --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Entries @@ -0,0 +1 @@ +/MANIFEST.MF/1.1/Sat Apr 18 02:11:07 2009// diff --git a/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Repository new file mode 100644 index 0000000..36326a6 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/META-INF diff --git a/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF b/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF new file mode 100644 index 0000000..faffd30 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Checkers Ui +Bundle-SymbolicName: org.eclipse.cdt.codan.checkers.ui;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.cdt.codan.checkers.ui.CheckersUiActivator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.ui.ide;bundle-version="3.5.0", + org.eclipse.jface.text;bundle-version="3.5.0", + org.eclipse.ui.editors;bundle-version="3.5.0", + org.eclipse.core.resources;bundle-version="3.5.0", + org.eclipse.cdt.codan.checkers;bundle-version="1.0.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/org.eclipse.cdt.codan.checkers.ui/build.properties b/org.eclipse.cdt.codan.checkers.ui/build.properties new file mode 100644 index 0000000..34d2e4d --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/org.eclipse.cdt.codan.checkers.ui/plugin.xml b/org.eclipse.cdt.codan.checkers.ui/plugin.xml new file mode 100644 index 0000000..783ff1d --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/plugin.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.ide.markerResolution"> + <markerResolutionGenerator + class="org.eclipse.cdt.codan.checkers.ui.quickfix.CodanProblemMarkerResolutionGenerator" + markerType="org.eclipse.cdt.codan.core.codanProblem"> + </markerResolutionGenerator> + </extension> +</plugin> diff --git a/org.eclipse.cdt.codan.checkers.ui/src/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Entries new file mode 100644 index 0000000..381094d --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Entries @@ -0,0 +1 @@ +D/org//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Repository new file mode 100644 index 0000000..ccb7248 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src diff --git a/org.eclipse.cdt.codan.checkers.ui/src/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Entries new file mode 100644 index 0000000..0f148f8 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Entries @@ -0,0 +1 @@ +D/eclipse//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Repository new file mode 100644 index 0000000..30e0dd1 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Entries new file mode 100644 index 0000000..e524915 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Entries @@ -0,0 +1 @@ +D/cdt//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Repository new file mode 100644 index 0000000..f3c8514 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Entries new file mode 100644 index 0000000..8d969ba --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Entries @@ -0,0 +1 @@ +D/codan//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Repository new file mode 100644 index 0000000..1a7cf10 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Entries new file mode 100644 index 0000000..513604d --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Entries @@ -0,0 +1 @@ +D/checkers//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Repository new file mode 100644 index 0000000..dde7cb7 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Entries new file mode 100644 index 0000000..7f0205c --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Entries @@ -0,0 +1 @@ +D/ui//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Repository new file mode 100644 index 0000000..24fc549 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Entries new file mode 100644 index 0000000..fc31844 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Entries @@ -0,0 +1,2 @@ +/CheckersUiActivator.java/1.1/Sat Apr 18 02:11:07 2009// +D/quickfix//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Repository new file mode 100644 index 0000000..25cd7cf --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java new file mode 100644 index 0000000..1635684 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java @@ -0,0 +1,50 @@ +package org.eclipse.cdt.codan.checkers.ui; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class CheckersUiActivator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers.ui"; + + // The shared instance + private static CheckersUiActivator plugin; + + /** + * The constructor + */ + public CheckersUiActivator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static CheckersUiActivator getDefault() { + return plugin; + } + +} diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Entries new file mode 100644 index 0000000..641ef34 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Entries @@ -0,0 +1,2 @@ +/CodanProblemMarkerResolutionGenerator.java/1.2/Tue Apr 21 00:36:20 2009// +/QuickFixAssignmentInCondition.java/1.1/Sat Apr 18 02:11:07 2009// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Repository new file mode 100644 index 0000000..3bdd833 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@dev.eclipse.org:/cvsroot/tools diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CodanProblemMarkerResolutionGenerator.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CodanProblemMarkerResolutionGenerator.java new file mode 100644 index 0000000..1470e7f --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CodanProblemMarkerResolutionGenerator.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2009 Andrew Gvozdev + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.checkers.ui.quickfix; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.ui.IMarkerResolution; +import org.eclipse.ui.IMarkerResolutionGenerator; + +public class CodanProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator { + public IMarkerResolution[] getResolutions(IMarker marker) { + final Pattern patternBuildDependsAdd = Pattern.compile("Possible assignment in condition.*"); + String description = marker.getAttribute(IMarker.MESSAGE, "no message"); + Matcher matcherBuildDependsAdd = patternBuildDependsAdd.matcher(description); + if (matcherBuildDependsAdd.matches()) { + return new IMarkerResolution[] { new QuickFixAssignmentInCondition() }; + } + return new IMarkerResolution[0]; + } +}
\ No newline at end of file diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/QuickFixAssignmentInCondition.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/QuickFixAssignmentInCondition.java new file mode 100644 index 0000000..5c28d53 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/QuickFixAssignmentInCondition.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2009 Andrew Gvozdev + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.checkers.ui.quickfix; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.FindReplaceDocumentAdapter; +import org.eclipse.jface.text.IDocument; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IMarkerResolution; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.texteditor.ITextEditor; + +public class QuickFixAssignmentInCondition implements IMarkerResolution { + public String getLabel() { + return "Change to '=='"; + } + + public void run(IMarker marker) { + // See if there is an open editor on the file containing the marker + IWorkbenchWindow w = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + if (w == null) { + return; + } + IWorkbenchPage page = w.getActivePage(); + if (page == null) { + return; + } + IFileEditorInput input = new FileEditorInput((IFile) marker + .getResource()); + IEditorPart editorPart = page.findEditor(input); + if (editorPart == null) { + // open an editor + try { + editorPart = IDE.openEditor(page, (IFile) marker.getResource(), + true); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + if (editorPart == null) { + return; + } + if (editorPart instanceof ITextEditor) { + ITextEditor editor = (ITextEditor) editorPart; + IDocument doc = editor.getDocumentProvider().getDocument( + editor.getEditorInput()); + int line = marker.getAttribute(IMarker.LINE_NUMBER, -1) - 1; + FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(doc); + try { + dad.find(doc.getLineOffset(line), "=", /* forwardSearch */ + true, /* caseSensitive */false, + /* wholeWord */false, /* regExSearch */false); + dad.replace("==", /* regExReplace */false); + marker.delete(); + } catch (BadLocationException e) { + // TODO: log the error + e.printStackTrace(); + } catch (CoreException e) { + // TODO: log the error + e.printStackTrace(); + } + } + } +} |