Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] CODAN-Auto checking after quickfix

On Tue, Apr 12, 2011 at 10:08 AM,  <maximed@xxxxxxxxxxxxxxxxxxx> wrote:
> 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).

I don't understand the question

>
> 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?

It should not open tab. It will ask to save the file because it cannot
work on unsaved file for some reason.
Check the code of existing quick fixes to see what is different.


>
> 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
>
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>


Back to the top