From 4e112eca7750a4f530c986be55c178c43c16d3ea Mon Sep 17 00:00:00 2001 From: Elliott Baron Date: Sat, 26 Jun 2010 22:27:34 -0400 Subject: Update codan plugins to CDT 7.0. * org.eclipse.cdt.codan.checkers.ui: Updated. * org.eclipse.cdt.codan.checkers: Updated. * org.eclipse.cdt.codan.core: Updated. * org.eclipse.cdt.codan.ui: Updated. * org.eclipse.cdt.codan.core.cxx: Added. * org.eclipse.cdt.codan.extension/META-INF/MANIFEST.MF: Import org.eclipse.cdt.codan.core.cxx.model. * org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/checkers/AbstractPropSimChecker.java: Superclass moved. --- .../src/org/eclipse/cdt/codan/internal/CVS/Entries | 1 + .../org/eclipse/cdt/codan/internal/CVS/Repository | 1 + .../src/org/eclipse/cdt/codan/internal/CVS/Root | 1 + .../src/org/eclipse/cdt/codan/internal/CVS/Tag | 1 + .../org/eclipse/cdt/codan/internal/CVS/Template | 0 .../cdt/codan/internal/checkers/CVS/Entries | 1 + .../cdt/codan/internal/checkers/CVS/Repository | 1 + .../eclipse/cdt/codan/internal/checkers/CVS/Root | 1 + .../eclipse/cdt/codan/internal/checkers/CVS/Tag | 1 + .../cdt/codan/internal/checkers/CVS/Template | 0 .../cdt/codan/internal/checkers/ui/CVS/Entries | 4 + .../cdt/codan/internal/checkers/ui/CVS/Repository | 1 + .../cdt/codan/internal/checkers/ui/CVS/Root | 1 + .../eclipse/cdt/codan/internal/checkers/ui/CVS/Tag | 1 + .../cdt/codan/internal/checkers/ui/CVS/Template | 0 .../internal/checkers/ui/CheckersUiActivator.java | 92 ++++++++++++++++++++++ .../cdt/codan/internal/checkers/ui/Messages.java | 30 +++++++ .../codan/internal/checkers/ui/messages.properties | 13 +++ .../internal/checkers/ui/quickfix/CVS/Entries | 3 + .../internal/checkers/ui/quickfix/CVS/Repository | 1 + .../codan/internal/checkers/ui/quickfix/CVS/Root | 1 + .../codan/internal/checkers/ui/quickfix/CVS/Tag | 1 + .../internal/checkers/ui/quickfix/CVS/Template | 0 .../ui/quickfix/CatchByReferenceQuickFix.java | 42 ++++++++++ .../ui/quickfix/QuickFixAssignmentInCondition.java | 45 +++++++++++ .../ui/quickfix/SuggestedParenthesisQuickFix.java | 47 +++++++++++ 26 files changed, 290 insertions(+) create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Entries create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Repository create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Root create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Template create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Template create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Entries create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Repository create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Root create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Tag create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Template create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/Messages.java create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/messages.properties create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Entries create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Repository create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Root create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Tag create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Template create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java create mode 100644 org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java (limited to 'org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal') diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Entries new file mode 100644 index 0000000..513604d --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Entries @@ -0,0 +1 @@ +D/checkers//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Repository new file mode 100644 index 0000000..65b8627 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/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/internal/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag new file mode 100644 index 0000000..3cd1ca4 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag @@ -0,0 +1 @@ +TCDT_7_0_0 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Template new file mode 100644 index 0000000..e69de29 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries new file mode 100644 index 0000000..7f0205c --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries @@ -0,0 +1 @@ +D/ui//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository new file mode 100644 index 0000000..f36ddb5 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root new file mode 100644 index 0000000..04efa23 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/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/internal/checkers/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag new file mode 100644 index 0000000..3cd1ca4 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag @@ -0,0 +1 @@ +TCDT_7_0_0 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Template new file mode 100644 index 0000000..e69de29 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Entries new file mode 100644 index 0000000..38f32cc --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Entries @@ -0,0 +1,4 @@ +/CheckersUiActivator.java/1.4/Sun Jun 27 01:30:39 2010//TCDT_7_0_0 +/Messages.java/1.2/Sun May 2 02:31:03 2010//TCDT_7_0_0 +/messages.properties/1.3/Thu Jun 3 17:01:30 2010//TCDT_7_0_0 +D/quickfix//// diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Repository new file mode 100644 index 0000000..afa2081 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/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/internal/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/internal/checkers/ui/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Tag new file mode 100644 index 0000000..49a449a --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Tag @@ -0,0 +1 @@ +NCDT_7_0_0 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Template new file mode 100644 index 0000000..e69de29 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java new file mode 100644 index 0000000..7a3d418 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2010 Alena Laskavaia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alena Laskavaia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.internal.checkers.ui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +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"; //$NON-NLS-1$ + + // 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; + } + + /** + * Logs the specified status with this plug-in's log. + * + * @param status + * status to log + */ + public static void log(IStatus status) { + getDefault().getLog().log(status); + } + + /** + * Logs an internal error with the specified throwable + * + * @param e + * the exception to be logged + */ + public static void log(Throwable e) { + log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$ + } + + /** + * Logs an internal error with the specified message. + * + * @param message + * the error message to log + */ + public static void log(String message) { + log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null)); + } + +} diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/Messages.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/Messages.java new file mode 100644 index 0000000..525de8a --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/Messages.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2009,2010 Alena Laskavaia + * 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: + * Alena Laskavaia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.internal.checkers.ui; + +import org.eclipse.osgi.util.NLS; + +/** + * TODO: add description + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.checkers.ui.messages"; //$NON-NLS-1$ + public static String CatchByReferenceQuickFix_Message; + public static String QuickFixAssignmentInCondition_Message; + public static String SuggestedParenthesisQuickFix_Message; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/messages.properties b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/messages.properties new file mode 100644 index 0000000..da262e0 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/messages.properties @@ -0,0 +1,13 @@ +############################################################################### +# Copyright (c) 2010 Alena Laskavaia and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Alena Laskavaia - initial API and implementation +############################################################################### +CatchByReferenceQuickFix_Message=Change to use '&' +QuickFixAssignmentInCondition_Message=Change to '==' +SuggestedParenthesisQuickFix_Message=Surround with '()' diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Entries new file mode 100644 index 0000000..e7497b1 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Entries @@ -0,0 +1,3 @@ +/CatchByReferenceQuickFix.java/1.2/Sun May 2 01:47:22 2010//TCDT_7_0_0 +/QuickFixAssignmentInCondition.java/1.5/Sun Jun 27 01:30:39 2010//TCDT_7_0_0 +/SuggestedParenthesisQuickFix.java/1.2/Thu Jun 3 17:01:30 2010//TCDT_7_0_0 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Repository new file mode 100644 index 0000000..f74bc94 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Repository @@ -0,0 +1 @@ +org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/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/internal/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/internal/checkers/ui/quickfix/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Tag new file mode 100644 index 0000000..49a449a --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Tag @@ -0,0 +1 @@ +NCDT_7_0_0 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Template new file mode 100644 index 0000000..e69de29 diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java new file mode 100644 index 0000000..68c3884 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2010 Alena Laskavaia + * 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: + * Alena Laskavaia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; + +import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator; +import org.eclipse.cdt.codan.internal.checkers.ui.Messages; +import org.eclipse.cdt.codan.ui.AbstarctCodanCMarkerResolution; +import org.eclipse.core.resources.IMarker; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.FindReplaceDocumentAdapter; +import org.eclipse.jface.text.IDocument; + +/** + * quick fix for catch by value + */ +public class CatchByReferenceQuickFix extends AbstarctCodanCMarkerResolution { + public String getLabel() { + return Messages.CatchByReferenceQuickFix_Message; + } + + public void apply(IMarker marker, IDocument document) { + FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter( + document); + try { + int pos = getOffset(marker, document); + dad.find(pos, " ", /* forwardSearch *///$NON-NLS-1$ + true, /* caseSensitive */false, + /* wholeWord */false, /* regExSearch */false); + dad.replace(" & ", /* regExReplace */false); //$NON-NLS-1$ + } catch (BadLocationException e) { + CheckersUiActivator.log(e); + } + } +} diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java new file mode 100644 index 0000000..4e64cd1 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010 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.internal.checkers.ui.quickfix; + +import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator; +import org.eclipse.cdt.codan.internal.checkers.ui.Messages; +import org.eclipse.cdt.codan.ui.AbstarctCodanCMarkerResolution; +import org.eclipse.core.resources.IMarker; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.FindReplaceDocumentAdapter; +import org.eclipse.jface.text.IDocument; + +/** + * quick fix for assignment in condition + */ +public class QuickFixAssignmentInCondition extends + AbstarctCodanCMarkerResolution { + public String getLabel() { + return Messages.QuickFixAssignmentInCondition_Message; + } + + + @Override + public void apply(IMarker marker, IDocument document) { + int pos = getOffset(marker, document); + try { + FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter( + document); + dad.find(pos, "=", /* forwardSearch *///$NON-NLS-1$ + true, /* caseSensitive */false, + /* wholeWord */false, /* regExSearch */false); + dad.replace("==", /* regExReplace */false); //$NON-NLS-1$ + } catch (BadLocationException e) { + CheckersUiActivator.log(e); + } + } +} diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java new file mode 100644 index 0000000..977d7a7 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2010 Alena Laskavaia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alena Laskavaia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; + +import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator; +import org.eclipse.cdt.codan.internal.checkers.ui.Messages; +import org.eclipse.cdt.codan.ui.AbstarctCodanCMarkerResolution; +import org.eclipse.core.resources.IMarker; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; + +public class SuggestedParenthesisQuickFix extends + AbstarctCodanCMarkerResolution { + public String getLabel() { + return Messages.SuggestedParenthesisQuickFix_Message; + } + + @Override + public boolean isApplicable(IMarker marker) { + int charEnd = marker.getAttribute(IMarker.CHAR_END, -1); + if (charEnd == -1) + return false; + return true; + } + + @Override + public void apply(IMarker marker, IDocument document) { + int charStart = marker.getAttribute(IMarker.CHAR_START, -1); + int charEnd = marker.getAttribute(IMarker.CHAR_END, -1); + if (charEnd == -1) + return; + try { + document.replace(charStart, 0, "("); //$NON-NLS-1$ + document.replace(charEnd+1, 0, ")"); //$NON-NLS-1$ + } catch (BadLocationException e) { + CheckersUiActivator.log(e); + } + } +} -- cgit