[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] CODAN-Auto checking after quickfix
|
Hi.
I noticed that whe I used a quickfix on my code, checkers were called
automatically to refresh errors and warnings. I'd like to know if
there is a way to do it without modifying my file or my AST (I am in
my justification thing again).
My second question concerns the fact that when I use a quickfix, a new
tab is opened in the editor, and sometimes eclipse asks me to save
something. Is it because I used "run as eclipse application" (and then
it will not be the case when I'll run it it production mode), or
because something is wrong in my installation?
Here is my code for sample:
/**
* Handles the quick fix
*/
@Override
public void apply(IMarker pMarker, IDocument pDocument) {
try {
/* We get the beginning and the ending of the problem */
int lStart=(Integer) pMarker.getAttribute(IMarker.CHAR_START);
int lEnd=(Integer) pMarker.getAttribute(IMarker.CHAR_END);
/* We get the AST of the program, so as to get its filename */
ITranslationUnit lUnit=getTranslationUnitViaEditor(pMarker);
IASTTranslationUnit lAst = lUnit.getAST();
String lFilename=lAst.getContainingFilename();
/* We get the id of the problem, so as to get its checker's id */
String lProblemID=getProblemId(pMarker);
/* If the problem is an error or a warning, it is not justified yet */
Integer lSeverity=(Integer)pMarker.getAttribute(IMarker.SEVERITY);
IASTNodeSelector lSelector=lAst.getNodeSelector(lFilename);
int lLength=lEnd-lStart;
IASTNode lNode=lSelector.findEnclosingNode(lStart, lLength);
String lExpression=lNode.getRawSignature();
if(lSeverity==IMarker.SEVERITY_ERROR ||
lSeverity==IMarker.SEVERITY_WARNING){
/* Ables to enter justification */
InputDialog lDialog = new InputDialog(null, "Justification",
"Please enter the justification", "Default", null);
lDialog.open();
String lReason = lDialog.getValue();
CodanCheckersActivator.getDefault().GDatabase.addJustification(lFilename,
lProblemID, lStart, lEnd, lExpression, lReason);
}
/* Else, if it is an info, it is already justified */
else{
CodanCheckersActivator.getDefault().GDatabase.removeJustification(lFilename, lProblemID, lStart, lEnd,
lExpression);
}
} catch (CoreException e) {
e.printStackTrace();}
}
Thank in advance.
Maxime