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

Include completion improved

(1/4) > >>

oBFusCATed:
Hello,
Here is a patch for the codecompletion plugin,
that tries to improve the include file completion.

Improvements:
1. Parse correctly:

--- Code: ---#    include "ala-bala"
    #   include "ala-bala"

--- End code ---

2. Use the project/active target include dirs to simplify the entries in the auto-complete list.
In my projects, I always put the source (*.h/*.cpp) files in subdirectory "src" and add it as an include path to the projects.
This let me use the headers without the "src/" prefix.
In the patch, the file path is modified, so it doesn't start with the include dir (the dir is stripped from the path).
So I can type the file path relative to the src directory and the completion list has the correct entries.
I've tested it only on linux and I need some help to handle paths in platform independent way (handle paths with \ instead of /)
Also I'm not sure how to handle ./ or ../ added to include dir. Any help here will be appreciated

--- Code: ---#include "file1.h"
#include "dir1/file2.h"

--- End code ---

3. Fixed a bug in the usage of the "caseSens" option

--- Code: ----        ed->GetControl()->AutoCompSetIgnoreCase(caseSens);
+        ed->GetControl()->AutoCompSetIgnoreCase(!caseSens);

--- End code ---

KNOWN PROBLEM:
The closing '"' or '>' is not added automatically and I couldn't find a way to implement it.
If anyone knows (and shares this info) if there is a message, that I can handle to add the one of the two characters, I'll be very thankful.

Best regards

p.s. the patch is attached
p.s.s. the patch is made against the 5617 wxaui branch


[attachment deleted by admin]

ollydbg:
Your message has much information, so, it will take me a lot of time to absorb. :D

Lets take the path related aspect, I found it was there: In Globals.cpp


--- Code: ---bool NormalizePath(wxFileName& f,const wxString& base)
{
    bool result = true;
//    if(!f.IsAbsolute())
    {
        f.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, base);
        result = f.IsOk();
    }
    return result;
}

--- End code ---


In Parser.cpp


--- Quote ---wxArrayString Parser::FindFileInIncludeDirs(const wxString& file,bool firstonly)
{
    wxArrayString FoundSet;
    for(size_t idxSearch = 0; idxSearch < m_IncludeDirs.GetCount(); ++idxSearch)
    {
        wxString base = m_IncludeDirs[idxSearch];
        wxFileName tmp = file;
        NormalizePath(tmp,base);
        wxString fullname = tmp.GetFullPath();
        if(wxFileExists(fullname))
        {
            FoundSet.Add(fullname);
            if(firstonly)
                break;
        }
    } // end for : idx : idxSearch
//    Manager::Get()->GetLogManager()->DebugLog(_T("Searching %s"), file.c_str());
//    Manager::Get()->GetLogManager()->DebugLog(_T("Found %d"), FoundSet.GetCount());
    return FoundSet;
} // end of FindFileInIncludeDirs


--- End quote ---

Also, I searched on Google, and this page will give a more details:

http://lists.wxwidgets.org/pipermail/wx-users/2007-January/096389.html


--- Quote ---> *bool* *Normalize*(*int */flags = wxPATH_NORM_ALL/, *const wxString&
> */cwd = wxEmptyString/, *wxPathFormat */format = wxPATH_NATIVE/)
>
> Normalize the path: with the default flags value, the path will be made
> absolute, without any ".." and "." and all environment variables will be
> expanded in it this may be done using another (than current) value of cwd


--- End quote ---

Maybe, it's helpful or not, I'm not sure. :)

killerbot:

--- Quote ---In my projects, I always put the source (*.h/*.cpp) files in subdirectory "src" and add it as an include path to the projects.
This let me use the headers without the "src/" prefix.
In the patch, the file path is modified, so it doesn't start with the include dir (the dir is stripped from the path).
So I can type the file path relative to the src directory and the completion list has the correct entries.
--- End quote ---

Is not already the case that CB offers both, like :
 "./src/MyHeader.h
 "MyHeader.h"  ??

Should recheck.

While you are at it, could you look at the following issue : I am trying out another patch that tries to put closing quotes/double quotes/braces/brackets/... when you type the opening one.
This has however a negative effect on the include completion since what happens is :

I type :

--- Code: ---#include "
--- End code ---

and I get :

--- Code: ---#include ""
--- End code ---
with the cursor between the 2 ". But that has killed the include completion.

oBFusCATed:
ollydbg, thanks I'll take a look at it tonight.


--- Quote from: killerbot on June 03, 2009, 07:36:12 am ---Is not already the case that CB offers both, like :
 "./src/MyHeader.h
 "MyHeader.h"  ??

Should recheck.

--- End quote ---
You talk about the case when you have both files, and the ./src is added to the include paths?


--- Quote from: ollydbg on June 03, 2009, 04:38:58 am ---While you are at it, could you look at the following issue : I am trying out another patch that tries to put closing quotes/double quotes/braces/brackets/... when you type the opening one.
This has however a negative effect on the include completion since what happens is :

I type :

--- Code: ---#include "
--- End code ---

and I get :

--- Code: ---#include ""
--- End code ---
with the cursor between the 2 ". But that has killed the include completion.


--- End quote ---
I suppose you talk about: http://forums.codeblocks.org/index.php/topic,10361.0.html
I've not tested it, because I don't like the feature. I'll give it a try.
I suppose the problem is something like that:
1. The user types a " or <
2. The list opens
3. The brace completion kicks in and places a character
4. The list closes because of the placed character

killerbot:
I guess something like that, or the character inserted event is no longer past on .. to investigate ;-)

Navigation

[0] Message Index

[#] Next page

Go to full version