Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Suggestion: Using ctags & sqlite for code completion

<< < (3/16) > >>

eranif:
Hi Morten,

For the VC7.1, I dont have other editors here (unless VC8 is good for you ... ), I dont have C:B cause I am too lazy to build it from scratch  - I am patiently waiting for the official release so I can install it using setup  :D

What I can do, is to pack everything in setup.exe and will upload it to my site

EDIT:

here is the link for the setup.exe installation for the sample - it will install missing dlls & ctags for you (uninstall is also provided)
www.eistware.com/wxes/codeparser/CodeParserSample.exe

While I am writing here, I will report my progress so far  :):

First of all, I want to make a point that I am making this is a wxWidget library and not C::B plugin. So it means that once it is completed, it  is up to the developers here to decide whether they choose to use it or not (an integrate it into C::B), but I will be more then happy to answer/fix anything required from my side.

About the current status:

I actually made a nice progress with it:

- What now is working nicely is the class tree + class tree updating during editing
- Tomorrow I will focus my work on WordCompletion (when you type Ctrl+Space - a list of suitable words will appear or if only one word is available, it will be completed automatically) - this part is including local scope and workspace scope, should be completed by friday I think.

Next step is the code completion - I am familiar with couple of cases that will cause problems:
1. Casting - 'C' style casting is a pain in the a**. - I can parse a simple casting and get the method, however there will be cases that it will fail. the simple cases, such as ((Box*)rect)-> will give the correct results for code completion

2. Inhertiance members are not taking into considerations - but this one is easy to implement - so I dont expect any problems here

After code completion, comes symbol searches ( find function declaration Ctrl + . will jump you to function / member implementation or declaration )

I really hope that by the end of next week everything will be completed for testing ( I do expect bugs, but i want it to be stable )

Eran


eranif:
Hi,

I have updated the sample program on my website, it is now demonstrates the following:

1. Building up a GUI tree (AKA Symbol tree) using ctags & sqlite
2. GUI tree is updated upon saving the file. If you will change file content the tree will be updated once you save it, this is done since ctags accepts files as input, so updating the tree per interval is too much overhead (creating temporary file, passing it to ctags and then delete it - too much)
3. Saving the tree into database for later reloading
4. word completion is now completed - what is word completion you may ask, well, word completion is step one of the CodeCompletion, it completes words using Ctrl + Space, the completion is considering the local scope and the entire workspace.
HOw does it works? first it scans local scope for members that qualifies with the partial name under the cursor, and then scan the database and adds other matches (if we are inside class, it will add its members / functions) such as GLOBAL variables + function + class struct etc

if only single match exist, it will automatically insert it under the cursor, else it will print out to the debug window the matches it found. scope depth is taking into consideration as well, for example:

--- Code: ---void foo()
{
    int number =0;
    if(number == 0)
    {
           wxString name;
           break;
    }
    n<------ Here you type Ctrl + Space
--- End code ---
only number will be available from local scope since name is in depth=2 while number is depth=1 same as n.

If you would like to check out the sample (I named the libe CodeLite & the sample program LiteEditor  :wink::
http://www.eistware.com/wxes/codeparser/liteeditor.exe

If you want the source files, drop me a message here or in private and I will upload them or email them (to package them I need to close my editor and close all windows so I can tar it ^^)

Eran

grunerite:

--- Quote from: eranif on August 27, 2006, 12:52:54 am ---If you would like to check out the sample (I named the libe CodeLite & the sample program LiteEditor  :wink::
http://www.eistware.com/wxes/codeparser/liteeditor.exe

--- End quote ---

Hi Eran,

Pretty cool. I think this is meant to be an example to show that it works, but this example app could be made a valuable tool if you add 1 more feature: the ability to open more than 1 source file at a time. In the file open dialog, I can select many files at once, but it only opens 1 file (last clicked?).

I commonly download some library code, and don't want to load it up in an IDE to browse classes, etc. With this app, I could just load up a bunch of source at once and browse through it to learn the library faster.

Very nice.

eranif:
Hi,


--- Quote from: grunerite on August 27, 2006, 03:27:51 pm ---
Pretty cool. I think this is meant to be an example to show that it works, but this example app could be made a valuable tool if you add 1 more feature: the ability to open more than 1 source file at a time. In the file open dialog, I can select many files at once, but it only opens 1 file (last clicked?).


--- End quote ---

Well, my intention was to demonstrate that the library itself works well before I will hand it over to some of the developers here to integrate it into C::B.

The reason that you cant open more than one file is that the current API of the library TagsManager::SourceToTags support single file only, I still need to add some kind of batch operation API, but this is very straightforward to do.

About enhancing it, once the library is completed I will publish it along with the source code of the editor (the sample program) to the public domain

I published it as setup.exe becuase one of the developers here said that he cant open the source file using VC7.1 - my working enviornment, so I created an install shield using InnoSetup for it.

I really hope I will complete the CodeCompletion by the end of this week.

A question for users / developers here:

I am considering that the library itself will popup a AutoCompletion box - my own implementation, and a find symbol dialog (for example, find a function declaration/definition)
what do you guys think?

Eran

eranif:
Hi,

I think that the code completion is pretty much ready for integration - if you guys want it.

I will start by listing what I have accomplished so far:

- As described in previous posts - tree view & tree updates using the library thread which works in the background
- WordCompletion - attempts to complete a word under the cursor when hot key is pressed ( in the demo it is Ctrl+Space ), if single match is found, the word is inserted automatically no list box is poped, other wise, user selection box pops up (scintilla built in)
- CodeCompletion - typing an operator . or -> will attempt to parse the expression and to evaluate its return value, this is done with no limit of how complex the sentence is. for example: GetClassBox().GetBox().GetName(), a popup box will be shown for every operator (if a match will be found).
- Partial casting is supported (currently, only 'C' style casting is supported)
- All files were build and tested using g++ 3.4.5 MinGW, makefile is provided, you may need to alter it a bit, but the hard part of converting to code to compile under g++ is behind me (pheww, MSVC warning level 4 didnt do the job i got hundreds of errors when attempted to build with g++, especially with templates)
- Batch API was added to allow adding multiple files at a time to the database (in the demo you can select File->Add source file -> and select multiple files)
- Smart file parsing, if for example you have only the implementation of a function :
 
--- Code: ---int Rectange::GetTopRight() {}
--- End code ---
and the class Rectangle is declared in another file, which you did not add to the database, the library will automatically identifies that something is missing (in our case Rectange) and will 'fill' the space with 'dummy' entry to the tree view and the database. Once the real entry is added it will replace the dummy one.

Need to be added with minimum effort:
- Scope operator ( :: )
- this pointer & *this
- C++ casting (static_cast, dynamice, const_cast, reintepret_cast) style
- Identify whether an indentifier is a pointer or reference (or object), currently it responds for both regardless the type (e.g. Box *b; b. <-- will open a popup box)

I think that the code is well documented and can be easily read and followed.

The source files can be retrieved at:
http://www.eistware.com/wxes/codelite/CodeLite_sources.zip

to build the demo, you will need the following:
wxscintilla, wxsqlite3 and wxcontrols (already provided, under sdk/gcc_lib)

Setup for the demo:
http://www.eistware.com/wxes/codelite/LiteEditor.exe

Eran

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version