Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] New Codan checker + questions about ASTRewrite

I'm going to adress the second question. You don't really need ASTRewrite for deleting preprocessor statements. All you need is to get locations of the statements within the file and create the corresponding DeleteEdits. Although preprocessor statements and are represented in AST, they are pretty independent from the rest of the AST. The complexity of ASTRewrite is an overkill for #ifdef and #endif statements.

-sergey

On Tue, Aug 16, 2011 at 3:01 PM, Mathias De Maré <mathias.demare+cdt@xxxxxxxxx> wrote:
Hello,

I made my first changes to Eclipse CDT, but I still have a few questions.

1. The FAQ said to nag if there were no responses on a contribution, so I was hoping someone could review my patch for bug 354087.
The checker detects external header guards of the form:
#ifndef SOMEHEADER_HH
#include "someheader.hh"
#endif

2. I am currently writing a quickfix that removes external header guards (when detected with the above mentioned checker). I bumped into an exception when removing the '#ifndef' and #endif' statements using ASTRewrite.
java.lang.IllegalArgumentException: Rewriting preprocessor statements is not yet supported at
org.eclipse.cdt.core.dom.rewrite.ASTRewrite.checkSupportedNode(ASTRewrite.java:233)


at org.eclipse.cdt.core.dom.rewrite.ASTRewrite.remove(ASTRewrite.java:124)
at org.eclipse.cdt.codan.internal.checkers.ui.quickfix.QuickFixUnneededHeaderguard.modifyAST(QuickFixUnneededHeaderguard.java:71)

If I remove the throwing of the exception, the quickfix seems to work just fine. However, I have a feeling the exception is there for a reason.
In addition, ASTRewrite seems to come with a fairly strong warning to ask for more information, so: could I remove the exception, in the case of a 'remove operation' on a preprocessor statement?

Greetings,
Mathias
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top