[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-core-dev] RE: [Bug 75364] [plan item] Refactoring support
|
Text Search:
------------
I share the goal to run the parser on as few files as possible.
There are several ways to rule out text matches before actually
generating AST.
- I currently run a simple scanner to figure out whether the
match occurs within a preprocessor directive, comment or string
literal. Replacement there may or may not be appropriate depending
on the kind of refactoring and/or user's choice. Any way there
obviously is no need to generate AST to analyze matches within
comments and string-literals.
- The CDT-index may tell us about sections of code that are
not reachable due to the current scanner configuration. Those
matches have to be dealt with, but without generating AST.
- Finally, the CDT-index may rule out further matches within those
parts of the code that have been parsed sucessfully. This way I'd
use it in a defensive way.
AST creation:
-------------
I do not know much about what you have done within the parser, so
it's kind of dary to make any suggestion on that. Nevertheless you
may want to consider skipping blocks that are currently of no
interest. That works well for code completion, and you may be doing
this anyhow. It is kind of easy there, because the blocks of
interest are determined by the single point where the completion
shall take place. For refactoring we'd need to figure out a way to
tell the parser about the interesting blocks. In case of renaming
a global symbol it works similar to code completion.
Example:
when doing code completion within block 4 below,
block 1 and block 3 are of no interest.
// ---------- sample code ----------
void func1() { // block 1
..
}
void func2() { // block 2
int abc;
if (...) { // block 3
int abcd;
...
}
else { // block 4
}
}
// ---------- end of code ----------
Markus.
> -----Original Message-----
> From: cdt-core-dev-admin@xxxxxxxxxxx
> [mailto:cdt-core-dev-admin@xxxxxxxxxxx] On Behalf Of Douglas Schaefer
> Sent: Thursday, October 21, 2004 2:01 PM
> To: cdt-core-dev@xxxxxxxxxxx
> Cc: cdt-core-dev@xxxxxxxxxxx; cdt-core-dev-admin@xxxxxxxxxxx;
> Michael.Scharf@xxxxxxxxxxxxx
> Subject: Re: [cdt-core-dev] RE: [Bug 75364] [plan item]
> Refactoring support
>
> I guess my major concern with text-search is that there is a
> good potential for text search to return more results than
> you want. One thing we've learned in our work on the CDT
> parser is that parsing is slow and to avoid it where
> possible. By using CDT's index to find the files you are
> really interested in, you will greatly improve your
> performance, especially on large projects.
>
> We're getting off to a slow start with the AST because we
> want to do it right considering all of the clients that could
> use it and we are very concerned about scalability and
> performance of creating an AST (which is why we didn't do it
> originally). Any advice/help you guys can offer in that area
> would be hugely appreciated :-)
>
> Cheers,
> Doug Schaefer, IBM's Technical Lead, Eclipse CDT Ottawa Lab,
> IBM Canada, Rational Software Division
>