1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

- moved generic base class for ast rewrite quick fix to common plugins

This commit is contained in:
Alena Laskavaia 2011-03-19 18:15:57 +00:00
parent 899b6159ac
commit 9afbc979e6
5 changed files with 44 additions and 5 deletions

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
import org.eclipse.cdt.codan.ui.AbstractAstRewriteQuickFix;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
import org.eclipse.cdt.codan.ui.AbstractAstRewriteQuickFix;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;

View file

@ -15,6 +15,7 @@ import java.util.HashMap;
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils.NameFinderVisitor;
import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
import org.eclipse.cdt.codan.ui.AbstractAstRewriteQuickFix;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.cxx;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@ -60,4 +62,34 @@ public class Activator extends AbstractUIPlugin {
public static Activator 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));
}
}

View file

@ -8,10 +8,9 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
package org.eclipse.cdt.codan.ui;
import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
import org.eclipse.cdt.codan.internal.ui.cxx.Activator;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
@ -23,6 +22,11 @@ import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
/**
*
* Abstract class to simply ast rewrite quick fixers
* @since 2.0
*/
public abstract class AbstractAstRewriteQuickFix extends AbstractCodanCMarkerResolution {
private IDocument document;
@ -35,7 +39,7 @@ public abstract class AbstractAstRewriteQuickFix extends AbstractCodanCMarkerRes
try {
index = getIndexFromMarker(marker);
} catch (CoreException e) {
CheckersUiActivator.log(e);
Activator.log(e);
return;
}
// lock the index for read access
@ -50,7 +54,7 @@ public abstract class AbstractAstRewriteQuickFix extends AbstractCodanCMarkerRes
index.releaseReadLock();
}
} catch (Exception e) {
CheckersUiActivator.log(e);
Activator.log(e);
}
}