Author Topic: Clang Complete new try?  (Read 47716 times)

Offline koonschi

  • Multiple posting newcomer
  • *
  • Posts: 27
    • My personal project
Clang Complete new try?
« on: May 15, 2013, 10:58:54 am »
Hello,

I was thinking about the clang complete plugin, and I decided it was time to show that plugin some love. I guess I don't have to tell you how powerful libclang is and what great benefits codeblocks could have using clang for code completion, refactoring etc.

I know that there is already a Clang plugin and I was thinking of extending it at first, but then I looked at the code and it wasn't really easy to read and understand as there were next to no comments and the whole structure of the plugin wasn't very clear to me either.

Now, as it seems to be working (a little at least as I have seen from the original topic of the plugin (http://forums.codeblocks.org/index.php/topic,15521.0.html), I thought of reusing code of this PlugIn to create a new one or refactoring it and then extending it.
I'd like to create a cleaner, well commented version of this plugin that might be delivered with later releases of codeblocks.

On the long term, working on this would not only include code completion, but also a lot of refactoring options. I see huge potential in this.

Now, before I start, there are a few things I want to have clarified first:
Would this be appreciated?
Are there currently similar plans for code completion (i.e. would I do redundant work)?
I guess it could make codeblocks slower, but add a lot of features. What's the opinion on this of the rest of the community?
Would maybe anybody else be interested in taking a serious approach to this, too?

I will not be able to start working on this at once, as I have a lot of other things going on, too. But if the response to this proposal is good, I'd take some time to really dig into libclang and extend this plugin.

Let me know what you think.

Koonschi
"As a general rule, the compiler is smarter than you, and working in your best interest. Do not question it." - Terry Mahaffey

#define TRUE FALSE // happy debugging suckers

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Clang Complete new try?
« Reply #1 on: May 15, 2013, 11:19:21 am »
Would this be appreciated?
Yes, surely using clang code completion will give correct code suggestion list, as you may know, currently, our parser in CC does not handle code(c++ template code)very well.
Quote
Are there currently similar plans for code completion (i.e. would I do redundant work)?
The work in ClangComplete plugin is one year ago, currently I see no body was working on this plugin.
Quote
I guess it could make codeblocks slower, but add a lot of features. What's the opinion on this of the rest of the community?
Look at CodeLite IDE, it already have clang code completion.
Quote
Would maybe anybody else be interested in taking a serious approach to this, too?
I personally do not have much time on playing with clang, but I can be a tester if you go ahead. Thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Clang Complete new try?
« Reply #2 on: May 15, 2013, 12:00:01 pm »
Let me know what you think.
The first thing that should be done is improving the C::B's SDK in regard to CC.
Currently it is made with the CC plugin in mind and it is not generic. Writing the plugin probably is not that hard.
But changing the API is and this is what stops me from doing any work in this regard.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Clang Complete new try?
« Reply #3 on: May 15, 2013, 04:28:58 pm »
I will probably have time to help this summer.

Another thing to keep in mind, is that other tools can benefit from Clang's knowledge, for example semantic highlight.  An idea is to create a single parser module (Clang), and allow multiple plugins to communicate with it.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Clang Complete new try?
« Reply #4 on: May 15, 2013, 04:34:20 pm »
for example semantic highlight.
As you know semantic highlight improvement is limited more by the editor than the parser.

An idea is to create a single parser module (Clang), and allow multiple plugins to communicate with it.
This is why I'm saying we need changes to the SDK.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline golgepapaz

  • Multiple posting newcomer
  • *
  • Posts: 44
Re: Clang Complete new try?
« Reply #5 on: May 15, 2013, 09:54:45 pm »
Guys. I am working on it. Still  much to go though.

Symbol browser



Code completion. Shows the higher priority matches first.



Errors and stuffies


Memory usage. Seems to be the limiting factor (This is a memory usage for single translation unit)
« Last Edit: May 15, 2013, 10:01:28 pm by golgepapaz »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Clang Complete new try?
« Reply #6 on: May 15, 2013, 10:04:27 pm »
Great now we will have 3 symbol browsers  ::)

p.s. I doubt you'll be allowed to use M$ icons.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline golgepapaz

  • Multiple posting newcomer
  • *
  • Posts: 44
Re: Clang Complete new try?
« Reply #7 on: May 15, 2013, 10:32:30 pm »
Meh I've pilfered the icons from http://sourceforge.net/projects/symbol-browser/?source=dlp except the private and protected overlays which in turn
might have been copied from visual studio (They look alike but slightly different)
I won't deny VisualAssist is my inspiration though.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Clang Complete new try?
« Reply #8 on: May 16, 2013, 02:12:20 am »
Guys. I am working on it. Still  much to go though.
...
Great Job!!!
Can you show us the source link so that someone can build and test it? Thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline golgepapaz

  • Multiple posting newcomer
  • *
  • Posts: 44
Re: Clang Complete new try?
« Reply #9 on: May 16, 2013, 03:45:49 am »

Great Job!!!
Can you show us the source link so that someone can build and test it? Thanks.

Thanks . Unfortunately this is at its preliminary stages and not worthy of publishing yet.(lots of bugs ,frequent crashes)
Since I detest the c interface of libclang I am writing this against the officially unstable c++ libraries
and this stuff is huge and requires more work on my part.But I am getting there...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Clang Complete new try?
« Reply #10 on: May 16, 2013, 03:50:23 am »

Great Job!!!
Can you show us the source link so that someone can build and test it? Thanks.

Thanks . Unfortunately this is at its preliminary stages and not worthy of publishing yet.(lots of bugs ,frequent crashes)
Since I detest the c interface of libclang I am writing this against the officially unstable c++ libraries
and this stuff is huge and requires more work on my part.But I am getting there...

Ok, I see, When it's ready, I'd like to test it, thanks for the contribution!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Clang Complete new try?
« Reply #11 on: May 16, 2013, 09:30:26 am »
Since I detest the c interface of libclang I am writing this against the officially unstable c++ libraries
and this stuff is huge and requires more work on my part.
Why are you detesting it? Does it limit you? How?
If there is no other benefit other than you feeling happy of using c++ instead of c, then you're doing it wrong.

Because:
1. Use c interfaces are better because they are more stable - most of the time you can update the library without the need to recompile
2. You're not tempted to use modern c++11 stuff (your plugin should compile with gcc4.1 in order to be included in C::B!)
3. You're not tempted to use modern c++ template stuff (makes code slow to compile, produces tons of useless symbols)
4. Most of the times c interfaces are simpler to use and understand
5. If you're serious about your plugin then you'll use the stable interface, otherwise it is just an experiment and then we'll have the same topic started again in an year.

p.s. if you're not using local repo for your project you're also doing it wrong
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline koonschi

  • Multiple posting newcomer
  • *
  • Posts: 27
    • My personal project
Re: Clang Complete new try?
« Reply #12 on: May 16, 2013, 10:04:37 am »
Wow this looks amazing.
BTW That's exactly why I was asking if there was already someone working on it :D

The icons look very MS-ish though, they remember me of my VB 6.0 times.

If you need help, I'd be very happy to assist you.
"As a general rule, the compiler is smarter than you, and working in your best interest. Do not question it." - Terry Mahaffey

#define TRUE FALSE // happy debugging suckers

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Clang Complete new try?
« Reply #13 on: May 16, 2013, 05:11:03 pm »
I rather prefer Code::Blocks style icons, but that may just be me.

Offline golgepapaz

  • Multiple posting newcomer
  • *
  • Posts: 44
Re: Clang Complete new try?
« Reply #14 on: May 17, 2013, 12:06:35 am »

Why are you detesting it? Does it limit you? How?
If there is no other benefit other than you feeling happy of using c++ instead of c, then you're doing it wrong.

Because:
1. Use c interfaces are better because they are more stable - most of the time you can update the library without the need to recompile
2. You're not tempted to use modern c++11 stuff (your plugin should compile with gcc4.1 in order to be included in C::B!)
3. You're not tempted to use modern c++ template stuff (makes code slow to compile, produces tons of useless symbols)
4. Most of the times c interfaces are simpler to use and understand
5. If you're serious about your plugin then you'll use the stable interface, otherwise it is just an experiment and then we'll have the same topic started again in an year.

p.s. if you're not using local repo for your project you're also doing it wrong


1. Well it's just that c interface does not click with me with the necessary indirections and I've wanted
something more powerful than what libclang provides. Although I admit there are not much I cannot do with libclang
until now.
2. Yes I do use c++11 and new standard library features (although nothing major and can't do without boost).I am also
contemplating ditching wxWidgets 2.8.12 in favor of 2.9.5 (hopefully would be released soon) to be able to use CallAfter() (Tree Control double click issue,disconnecting a event
handler inside a handler etc.) and some other stuff. I did not know there was an requirement as such but again I don't expect it to work at every platform for now.
3. I assure you no kittens were harmed when I practice my insane template metaprogramming skills  ;). Seriously no fancy stuff other than provided by the boost itself.
   Those issues are not a great concern compared the other stuffies and thingies such as speed and memory footprint.
4. That's debatable and up the personal taste but I digress. The point one is the motivation here.
5. It's not that unstable. I would eventually need to delve in the class hierarchy for some stuff I am imagining doing.

p.s. I do have a Git repo set up but I am not using it extensively yet though.