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 12:41 PM,  <maximed@xxxxxxxxxxxxxxxxxxx> wrote:
>
> Alena Laskavaia <elaskavaia.cdt@xxxxxxxxx> a écrit :
>
>> 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
>
>     When a codan problem is reproted on CDT IDE, and when I use the
> suggested quick fix (such as create local variable for example), the
> error/warning disappears, which is the expected comportment. Indeed, in the
> existing quickfixes, the source file is modified, so I think the warning
> disappears because of the modification (as I am in run as you type mode).
> The quickfix I developed does'nt modify the source to change the problem, it
> only flags it in an other way. My problem is that I need to add/suppress a
> character (in run as you type mode), or launch a manual checking to make
> this modification visible (ie re-call checking on the file). So I wanted to
> know what was the way (the class/method) to explicitly call checking of all
> my checkers on the displayed file.

Check where code removes the error for quick fix, contribute the API
extension which would allow to suppress it

>
>
>>
>>>
>>> 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.
>>
>
> The fact is that my code is based on a copy/paste of what was done on
> previous quickfixes (I don't pretend being smart enough to guess what API
> does without an example =) ). Even with an empty apply method, the problem
> is present. Maybe it comes from my build, as I had to manually copy a class
> from cdt.core into codan.checkers.ui, since I wasn't able to find it in the
> cdt.core.jar which was in my eclipse/plugin directory (don't remember at the
> moment the name of the class). The weird thing is that it asks to save the
> file, saves it indeed, but the result file is empty...

Sorry I don't know how this works really. Mine does not open another tab...

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


Back to the top