Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Refactoring tool?
byo:
--- Quote from: Takeshi Miya on September 12, 2006, 12:13:51 pm ---What makes you think that such precise parser doesn't exists yet? :)
The ANTLR parser generator (C++ binary and C++ grammar) is the best - most correct I could find.
There are lot's of programs using it for C++ refactoring, code coverage, code analysis, etc.
This parser generator is so powerful that is being used for language translations (ie. from Java to C and viceversa).
If you wonder what parser the IntelliJ IDEA guys are using for one of the best existing refactoring tools, you guessed right, it's ANTLR too.
So yes, refactoring C++ is not only possible but doable without "taking years in company where everybody works 8 hours (or more) a day" :wink: That is, if you choose the right parser instead of creating your own (ANTLR took 15 years :D).
--- End quote ---
:shock: Seems quite optimistic (it looks like my knowledge is outdated in c++ parsing). But why we don't use ANTLR for CodeCompletion parser? There's whole C++ grammar available for free, few small modifications could make it really usefl in codecompletion case. Ive looked into forums but haven't found real explanation why it is not used yet in C::B
takeshimiya:
--- Quote from: byo on September 12, 2006, 07:37:09 pm ---
--- Quote from: Takeshi Miya on September 12, 2006, 12:13:51 pm ---What makes you think that such precise parser doesn't exists yet? :)
The ANTLR parser generator (C++ binary and C++ grammar) is the best - most correct I could find.
There are lot's of programs using it for C++ refactoring, code coverage, code analysis, etc.
This parser generator is so powerful that is being used for language translations (ie. from Java to C and viceversa).
If you wonder what parser the IntelliJ IDEA guys are using for one of the best existing refactoring tools, you guessed right, it's ANTLR too.
So yes, refactoring C++ is not only possible but doable without "taking years in company where everybody works 8 hours (or more) a day" :wink: That is, if you choose the right parser instead of creating your own (ANTLR took 15 years :D).
--- End quote ---
:shock: Seems quite optimistic (it looks like my knowledge is outdated in c++ parsing). But why we don't use ANTLR for CodeCompletion parser? There's whole C++ grammar available for free, few small modifications could make it really usefl in codecompletion case. Ive looked into forums but haven't found real explanation why it is not used yet in C::B
--- End quote ---
ddiego has modified ANTLR a little for easier usage in CodeCompletion, along with ucpp, ctags and sqlite, see here: http://vcfbuilder.org/?q=node/139
and he's making it a standard library for using in any IDE. The repository is here: https://svn.sourceforge.net/svnroot/classdom
On the other hand, eranif is doing something very similar with CodeLite: ctags and sqlite, with a little usage of flex.
See here: https://opensvn.csie.org/traccgi/CodeLite/wiki
Ctags is very fast, but not precise, so it's best usage is for codecompletion. A list of supported languages is here.
ANTLR is not fast, but it's very precise, so it's best usage is things that require this precision: refactoring tools, code translators, compilers, etc. A list of available grammars is here.
Of course a hybrid solution is possible (combining ctags & antlr), like what ddiego is doing with "ClassDOM".
The problem with ClassDOM is that its a pure iso c/c++ library, so no wxWidgets facilities.
CodeLite on the other hand is being made as a wxWidgets library. We plan to make it integrated as a C::B plugin (any hand is welcomed!) when this component' functionality is finished.
A list of current supported features is here: https://opensvn.csie.org/traccgi/CodeLite/wiki/Features
byo:
Sounds great. But I hope it won't break in expressions like:
--- Code: ---a::b<c,d>::e<f,g> (h<i,j>::k) = reinterpret_cast<o>(l(--m++).n ...
--- End code ---
;) (Yop, I'm really waiting for some unbreakable tool)
Is there any estimated time when we could find out how these libraries work ?
eranif:
--- Quote ---Sounds great. But I hope it won't break in expressions like:
Code:
a::b<c,d>::e<f,g> (h<i,j>::k) = reinterpret_cast<o>(l(--m++).n ...
Wink (Yop, I'm really waiting for some unbreakable tool)
Is there any estimated time when we could find out how these libraries work ?
--- End quote ---
You are more then welcome to download CodeLite and test it using the supplied demo.
I suggest using the sources from SVN rather the zip or the installation provided since the sources are far more updated.
The svn respository is located at:
https://opensvn.csie.org/CodeLite/
There are several ways of building it:
using makfile - for MinGW
using VC7.1 solution
makefile.linux - linux ...
and codeblock project supplied by Takeshi & tiwag
For the timeline:
I believe that CodeLite will be ready by the end of next week.
Eran
kai:
after reading these posts i did a little research on refactoring c++ code. i'm surprised that there are very few projects about it. anyway, let me share what i found.
cerp is a refactoring tool for eclipse/cdt. i don't know the development status, but it had a few releases and the latest is called 1.0.1
features:
CERP offers some refactorings for C++. these should'nt be too difficult to implement but they are already very useful.
* Declare Method -- method from .cpp to .h
* Extract Baseclass -- create abstract base class from existing class in new file
* Hide Method -- makes a method private
* Implement Method -- method from .h to .cpp
* Separate Class -- moves a class to an extra file
* Synchronize Method -- sync e.g. parameters of a function in header and source file
(german) homepage: http://ifs.hsr.ch/374
elsa seems to be a c++ parser that is worth a look:
http://www.cs.berkeley.edu/~smcpeak/elkhound/
and the harmonia project is very interesting. it provides lots of tools to analyse source code and applications that use this analysis. one application is programming with speech input for handicapped people. harmonia-mode can e.g. provide syntax highlighting of errors before compile time.
a few quotes from the page http://harmonia.cs.berkeley.edu/harmonia/projects/shorthand/index.html :
shorthand project: The key idea behind this work is to use a combination of language awareness and contextual analysis to interpret the commands. The interface can then be made intuitive and natural. For example, inside a Java class, the input “p s v main ( s [ argv” would be taken to designate “public static void main ( String [] argv ) {}”.
codelink project: Studies have repeatedly shown that the majority of computer programs contain a lot duplicated source code. Existing research into this issue has assumed that the problem is in poor programming -- that programmers should abstract their code more extensively with functions and macros. However, we claim that the tools of abstraction (functions and macros) are the problem. They inadequately support the ergonomic and cognitive needs of programmers in real-life situations. We have developed a new editor-assisted alternative to functions and macros. This tool maintains a persistent editor-level "link" between similar regions of code in order to support high-level visualization, editing, and navigation. Our hypothesis is that this tool enables programmers to work faster and with fewer errors, and that in turn they are likely to use the tool in situations where they wouldn't use a traditional abstraction.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version