Code::Blocks Forums
Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on December 05, 2010, 02:59:33 pm
-
Hei, guys, I found another codecompletion tool, this is much like the Clang's codecompletion model. But it is based on GCC
http://cx4a.org/software/gccsense/index.html
screen shot here:
(http://cx4a.org/software/gccsense/gccsense-vim.png)
http://cx4a.org/software/gccsense/manual.html
http://gcc.gnu.org/ml/gcc/2010-04/msg00433.html
:D :D
hope some brave guys can help cc to improve it's precise suggestion list.
-
this might be very interesting, since now and for sure in the future we will need the compilers information (for example the auto keyword, where the compiler will determine the actual type of the variable).
MSVC also uses its compiler for the intellisense.
-
The proble I see is, that it uses it's on gcc-derivate (if I see it correctly) and that it is not (yet) available for windows.
-
The problems with this one is that it is a 'proof of concept' project and lots of works should be done before it is usable in production...
-
The problems with this one is that it is a 'proof of concept' project and lots of works should be done before it is usable in production...
after I just review the patch here:http://gcc.gnu.org/ml/gcc/2010-04/msg00433.html
I totally agree oBF's comment. :D
currently, Clang is still the best candidate. but ... too complex and hard for me.
-
here is another source I found which Can be really usefull to support our codecompletion plugin.
http://codesynthesis.com/~boris/blog/2010/05/10/parsing-cxx-with-gcc-plugin-part-2/
GCC's plugin system is really quite nice place to retrieve the full AST.
Edit
it seems the plugin framework does not work under windows by default, see:
http://gcc.gnu.org/ml/gcc/2010-07/msg00003.html
-
We discussed this a few years ago, I think, when there was first talk about GCC running as server some day in the future (is this still planned?). The ability of dumping the intermediate language tree existed as something between an experimental patch and an idea in the form of xml-gcc then.
I'd very much like to see a code completion based on the compiler, since it is really the only thing that makes sense. However, it should not need to launch the compiler a thousand times, for performance reasons. And, before spending weeks/months on writing a tree-dump-parser, one should be sure that the gcc guys have frozen the format (which may take years).
-
We discussed this a few years ago, I think, when there was first talk about GCC running as server some day in the future (is this still planned?). The ability of dumping the intermediate language tree existed as something between an experimental patch and an idea in the form of xml-gcc then.
I have read those topics about using gcc, I also notices that TDM has doing some testing, but he said it take several seconds to parse the stl header. so he said this was not satisfied.
currently, gcc-xml project was not active, see:
http://www.gccxml.org/pipermail/gccxml/2010-November/001435.html
the author suggest using clang instead.
I'd very much like to see a code completion based on the compiler, since it is really the only thing that makes sense. However, it should not need to launch the compiler a thousand times, for performance reasons. And, before spending weeks/months on writing a tree-dump-parser, one should be sure that the gcc guys have frozen the format (which may take years).
If we can use a PCH(or dynamically create a PCH), the speed of codecompletion can be quite nice. I have review the gccsense's patch against the gcc's parser. it does very simple thing.
The parser will normally skip any function body, but when the parser find a function body which embrace the current caret position, it will rollback to parse the current function body again.
But I think the AST tree structure can not help to do the codecompletion. then information need to do the completion is "the scope" information of the current caret position. I don't think the dumped AST has these information.
-
The proble I see is, that it uses it's on gcc-derivate (if I see it correctly) and that it is not (yet) available for windows.
I just create gccsense under windows, it works fine.
I create patches so it can apply on vanilla gcc 4.5.2 source.
See the attachment for more details. (includes patches and Howto) :D
-
FYI:
here:
http://blogs.msdn.com/b/vcblog/archive/2010/01/26/precompiled-header-files-in-visual-studio-2010.aspx
but "reparse" the source file is quite tricky
In order for the intellisense compiler to provide this information, the intellisense engine must initially parse the TU like the command-line compiler, recursively parsing all #include files listed at the top of the source file before parsing the rest of the source file. Thanks to C++ scoping rules, we know that we can skip all method bodies except the one you might currently be in, but, other than this optimization, the rest of the translation unit must be parsed to give an accurate answer. We refer to this as the “pre-parse.”
Pre-parses are not always required, as users spend much of their time writing code inside of a local scope. Through careful tracking of user edits, we can say whether or not the user has changed information which requires a new pre-parse. When this happens, we throw away our old pre-parse and start again.
it seems that code completion result can be reused if we don't change the "scope". :D, but we maybe need to track the "}".