Author Topic: ClangComplete plugin  (Read 74314 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: ClangComplete plugin
« Reply #15 on: November 12, 2011, 02:07:24 am »
I mean how clang can find the gcc's default search paths, different version of gcc has different paths, like:

Code
Caching GCC dir: E:\code\cb\gcc\mingw-static-4.4.5-all\lib\gcc\i686-mingw32\4.4.5\include\c++
Caching GCC dir: E:\code\cb\gcc\mingw-static-4.4.5-all\lib\gcc\i686-mingw32\4.4.5\include\c++\i686-mingw32
Caching GCC dir: E:\code\cb\gcc\mingw-static-4.4.5-all\lib\gcc\i686-mingw32\4.4.5\include\c++\backward
Caching GCC dir: E:\code\cb\gcc\mingw-static-4.4.5-all\include
Caching GCC dir: E:\code\cb\gcc\mingw-static-4.4.5-all\lib\gcc\i686-mingw32\4.4.5\include
Caching GCC dir: E:\code\cb\gcc\mingw-static-4.4.5-all\lib\gcc\i686-mingw32\4.4.5\include-fixed

Does clang has it's own include files so that we do not need mingw's ?
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 Lalaland

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: ClangComplete plugin
« Reply #16 on: November 12, 2011, 07:46:13 am »
No, you are right, it is using gcc's search directories.

It seems that it can search a limited number of hardcoded paths for the headers(there is a whole complex module for this, tons of switch statements and  "// FIXME: temporary hack: hard-coded paths.") , eg
Code
    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0");
    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0");
    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0");

which is why it seems to work, but I actually need to find the real paths to get it working when Mingw is not installed in the usual locations ...
« Last Edit: November 12, 2011, 07:55:38 am by Lalaland »

Offline Lalaland

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: ClangComplete plugin
« Reply #17 on: November 14, 2011, 07:57:54 am »
How does codeblocks filter results completions that are not related to a container(Ie, does not '->', '.' or '::')
With no container, you get hundreds of possible completions.

Should I filter and show only variables, only functions, ?
Showing all possible completions causes observable delays, and the resulting list is too large to use.

Also:
How useful is it to users to have the icon also show accesability(private, protected, etc)?
While it is possible with clang(the functions are there) it seems that I would have parse the file twice in order to get this kind of type information.
« Last Edit: November 14, 2011, 08:00:53 am by Lalaland »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: ClangComplete plugin
« Reply #18 on: November 14, 2011, 08:27:33 am »
How does codeblocks filter results completions that are not related to a container(Ie, does not '->', '.' or '::')
With no container, you get hundreds of possible completions.
You mean the current implementation in Codeblocks? As far as I know, it dose not filter any thing, but note that the "auto-completion" should be only triggered by:
1, after "->", "::" or "."
2, after user continuously entered four characters, so we do a prefix match of four chars, and only list the tokens which have the same prefix string. note: the value "four" can be configured to "two" or even "one", which means more Tokens will be listed, but we have a limit value (like 10000).
3, when the user continuously enter some more characters, we just use the result in the step 2.

Quote
Should I filter and show only variables, only functions, ?
Showing all possible completions causes observable delays, and the resulting list is too large to use.
The best way is show automatic variable firstly, and then class members, then global variables....So, I think the Tokens from clang should be sorted. :D

Quote
Also:
How useful is it to users to have the icon also show accesability(private, protected, etc)?
While it is possible with clang(the functions are there) it seems that I would have parse the file twice in order to get this kind of type information.
Yeah, this is much better!
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 Folco

  • Regular
  • ***
  • Posts: 343
    • Folco's blog (68k lover)
Re: ClangComplete plugin
« Reply #19 on: November 15, 2011, 09:15:43 pm »
My personal opinion : I don't use these pictures. The names I choose are explicit, and I never learned the meaning of these symbols.
Kernel Extremist - PedroM power ©

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: ClangComplete plugin
« Reply #20 on: November 16, 2011, 01:06:39 am »
My personal opinion : I don't use these pictures. The names I choose are explicit, and I never learned the meaning of these symbols.
You are answering to this question below?
Quote
How useful is it to users to have the icon also show accesability(private, protected, etc)?
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 Lalaland

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: ClangComplete plugin
« Reply #21 on: November 16, 2011, 08:11:05 am »
Regardless, I have added the icons for visibility.



The only issue is that I had to modify libclang slightly to do it.
I have submitted a patch request, but until then, I have attached the patch to this post.

Now the only main issue is to work on handling code completion with no context.

Offline Folco

  • Regular
  • ***
  • Posts: 343
    • Folco's blog (68k lover)
Re: ClangComplete plugin
« Reply #22 on: November 16, 2011, 05:55:11 pm »
My personal opinion : I don't use these pictures. The names I choose are explicit, and I never learned the meaning of these symbols.
You are answering to this question below?
Quote
How useful is it to users to have the icon also show accesability(private, protected, etc)?

Yes I do.

Could these pictures be optional ?
Kernel Extremist - PedroM power ©

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: ClangComplete plugin
« Reply #23 on: November 16, 2011, 10:57:36 pm »
Could these pictures be optional ?

Come on... Even if you don't use the pictures (which I do a lot), they are very unlikely to disturb anyone, right? ;-)

Anyway, even if "the names [you] choose are explicit", you still have do deal with code from others, like your beloved CodeBlocks API/SDK, for example, right? And then, the pictures really help me a lot!!!!

Just my 2 cents, though...

Offline Lalaland

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: ClangComplete plugin
« Reply #24 on: November 17, 2011, 01:00:43 am »
I am just going to keep the pictures in there.
Right now the major goal of this plugin is to mirror the experience but provide better functionality than the current plugin.
And, those pictures are a major part of the "experience".

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: ClangComplete plugin
« Reply #25 on: November 17, 2011, 01:58:45 pm »
It looks like the codelite IDE was changing its way to call clang, see its svn chang log:
Quote
Revision: 5276
Author: eranif
Date: 2011-11-17 15:12:47
Message:
added clang sdk for Windows
-------------------------------
A : /trunk/sdk/clang

A : /trunk/sdk/clang/include

A : /trunk/sdk/clang/include/clang-c

A : /trunk/sdk/clang/include/clang-c/Index.h

A : /trunk/sdk/clang/lib

A : /trunk/sdk/clang/lib/clang.dll


Now, it will depend on clang shared library.
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 Lalaland

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: ClangComplete plugin
« Reply #26 on: November 18, 2011, 06:54:17 am »
Clang allows you to see what is accessible.
Should I hide non-accessible results?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: ClangComplete plugin
« Reply #27 on: November 18, 2011, 06:58:29 am »
Clang allows you to see what is accessible.
Should I hide non-accessible results?
I think "non-accessible results" should be hide in the completion suggest list. :D

The other question is: (dependency question)
If some would like to distribute this clangcompletion plugin, which file should be included.
The clangcompletion dll
and the clang.dll
Or other files needed?
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 Lalaland

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: ClangComplete plugin
« Reply #28 on: November 18, 2011, 07:15:31 am »
Well I use the images from the real code completion plugin.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: ClangComplete plugin
« Reply #29 on: November 18, 2011, 07:41:57 am »
Remember:
One note: Please keep in mind that the plugin should derive from cbCodeCompletionPlugin, not cbPlugin to work properly in the end.
I would recommend you better do it before it's too late and requires massive re-factoring. In the end the interface of cbPlugin (wrong for a CC plugin) and cbCodeCompletionPlugin is different.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ