Author Topic: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.  (Read 76685 times)

Offline polygon7

  • Multiple posting newcomer
  • *
  • Posts: 104
    • Home site
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #90 on: October 12, 2010, 11:14:19 am »
yes, this delay is already present for so time now, I can confirm ;-)
Hi, killerbot, Could you have a trying r6707.
And post the debug log in here?
Thanks!
Revision 6707 works really fast with #include's :D

// Edit:
include with "
Code: [Select]
Get include file count is 2, use time is 1
include with <
Code: [Select]
Get include file count is 31006, use time is 57
« Last Edit: October 12, 2010, 11:16:23 am by polygon7 »
best regards,
p7
 Free open source UML modeling tool: ArgoUML

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #91 on: October 12, 2010, 12:20:12 pm »
yes, this delay is already present for so time now, I can confirm ;-)
Hi, killerbot, Could you have a trying r6707.
And post the debug log in here?
Thanks!
Revision 6707 works really fast with #include's :D

// Edit:
include with "
Code: [Select]
Get include file count is 2, use time is 1
include with <
Code: [Select]
Get include file count is 31006, use time is 57

About the 2~6 sec delay: I think it is wxScintilla issue, not CC. :(

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5188
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #92 on: October 12, 2010, 02:34:48 pm »
#include " --> worked very fast, but several includes missing
#include <  --> still rather slow [and at the start I always have a lot of entries like this : /32/32/32/32/32/32/32....]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #93 on: October 12, 2010, 04:00:57 pm »
#include " --> worked very fast, but several includes missing
#include <  --> still rather slow [and at the start I always have a lot of entries like this : /32/32/32/32/32/32/32....]
All code in here:
Quote
// Do the code completion when we enter:
// #include "| or #include <|
void CodeCompletion::CodeCompleteIncludes()
{
    wxStopWatch sw;

    if (!IsAttached() || !m_InitDone)
        return;

    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if (!ed)
        return;

    const wxString curFile(ed->GetFilename());
    const wxString curPath(wxFileName(curFile).GetPath());
    wxArrayString buildTargets;

    cbProject* project = m_NativeParser.GetProjectByParser(&m_NativeParser.GetParser());
    ProjectFile* pf = project ? project->GetFileByFilename(curFile, false) : 0;
    if (pf)
        buildTargets = pf->buildTargets;

    FileType ft = FileTypeOf(ed->GetShortName());
    if ( ft != ftHeader && ft != ftSource) // only parse source/header files
        return;

    int pos = ed->GetControl()->GetCurrentPos();
    int lineStartPos = ed->GetControl()->PositionFromLine(ed->GetControl()->GetCurrentLine());
    wxString line = ed->GetControl()->GetLine(ed->GetControl()->GetCurrentLine());
    line.Trim();
    if (line.IsEmpty() || !TestIncludeLine(line))
        return;

    bool useSystemHeaders = false;
    int keyPos = line.Find(_T('"'));
    if (keyPos == wxNOT_FOUND)
    {
        useSystemHeaders = true;
        keyPos = line.Find(_T('<'));
    }
    if (keyPos == wxNOT_FOUND || keyPos > pos - lineStartPos)
        return;
    ++keyPos;

    // now, we are after the quote prompt
    wxString filename = line.SubString(keyPos, pos - lineStartPos - keyPos);
    filename.Replace(_T("\\"), _T("/"), true);

    // fill a list of matching files
    StringSet files;

    // #include <|
    if (m_CCSystemHeaderFiles && useSystemHeaders)
    {
        wxCriticalSectionLocker locker(s_HeadersCriticalSection);
        wxArrayString& incDirs = GetSystemIncludeDirs(&m_NativeParser.GetParser(),
                                                      project ? project->GetModified() : true);
        for (size_t i = 0; i < incDirs.GetCount(); ++i)
        {
            SystemHeadersMap::iterator it = m_SystemHeadersMap.find(incDirs);
            if (it != m_SystemHeadersMap.end())
            {
                const StringSet& headers = it->second;
                for (StringSet::iterator it = headers.begin(); it != headers.end(); ++it)
                    files.insert(*it);
            }
        }
    }

    // #include "|
    if (!useSystemHeaders && project)
    {
        const wxArrayString localIncludeDirs = GetLocalIncludeDirs(project, buildTargets);
        for (int i = 0; i < project->GetFilesCount(); ++i)
        {
            ProjectFile* pf = project->GetFile(i);
            if (pf && FileTypeOf(pf->relativeFilename) == ftHeader)
            {
                wxString file = pf->file.GetFullPath();
                if (file.Find(filename) != wxNOT_FOUND)
                {
                    wxString header;
                    for (size_t j = 0; j < localIncludeDirs.GetCount(); ++j)
                    {
                        const wxString& dir = localIncludeDirs[j];
                        if (file.StartsWith(dir))
                        {
                            header = file.Mid(dir.Len());
                            break;
                        }
                    }

                    if (header.IsEmpty())
                    {
                        if (pf->buildTargets != buildTargets)
                            continue;

                        wxFileName fn(file);
                        fn.MakeRelativeTo(curPath);
                        header = fn.GetFullPath();
                    }

                    header.Replace(_T("\\"), _T("/"), true);
                    files.insert(header);
                }
            }
        }
    }

    // popup the auto completion window
    if (!files.empty())
    {
        ed->GetControl()->ClearRegisteredImages();
        ed->GetControl()->AutoCompSetIgnoreCase(false);
        ed->GetControl()->AutoCompSetCancelAtStart(true);
        ed->GetControl()->AutoCompSetFillUps(m_CCFillupChars);
        ed->GetControl()->AutoCompSetChooseSingle(false);
        ed->GetControl()->AutoCompSetAutoHide(true);
        ed->GetControl()->AutoCompSetDropRestOfWord(m_IsAutoPopup ? false : true);
        wxString final;
        GetStringFromSet(final, files, _T(" "));
        final.RemoveLast(); // remove last space
        Manager::Get()->GetLogManager()->DebugLog(F(_T("Get include file count is %d, use time is %d"),
                                                    files.size(), sw.Time()));
        ed->GetControl()->AutoCompShow(pos - lineStartPos - keyPos, final);
    }
}
Almost all of the time is spent in the AutoCompShow call.
This is not a CC problem, but wxScintilla.

Offline polygon7

  • Multiple posting newcomer
  • *
  • Posts: 104
    • Home site
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #94 on: October 12, 2010, 04:17:13 pm »
#include " --> worked very fast, but several includes missing
#include <  --> still rather slow [and at the start I always have a lot of entries like this : /32/32/32/32/32/32/32....]
All code in here:
(...)
Almost all of the time is spent in the AutoCompShow call.
This is not a CC problem, but wxScintilla.

Maybe that includes popup should be visible only when user write similar number of letters like
in CC (Editor->CC->Automatically launch when typed # letters) after " or < character and
popup should contain only that items which have the same letters on start as written by user?

Eg.
Editor->CC->Automatically launch when typed # letters is set to 4
and with:
Code: [Select]
#include <cst|
no popup visible

Code: [Select]
#include <cstd
popup visible and should contain: "cstdio" (or if there is another file with cstd prefix then it should be in popup too).
best regards,
p7
 Free open source UML modeling tool: ArgoUML

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #95 on: October 12, 2010, 04:36:13 pm »
This problem does not occur in the Windows platform. :(

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5188
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #96 on: October 12, 2010, 04:56:06 pm »
one thing is for sure :
Code: [Select]
#include "

doesn't show any options any more from file present in the project's include paths (no idea with target's include paths)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12069
    • Travis build status
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #97 on: October 12, 2010, 05:05:01 pm »
This problem does not occur in the Windows platform. :(
Probably on windows you have far less header files. On linux many softwares install header files in /usr/include
(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 jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #98 on: October 12, 2010, 05:57:00 pm »
I just mesured it with wxStopWatch.

There are 22996, that are splitted in tokens by wxStringTokenizer in PlatWX.cpp ListBoxImpl::SetList (caled by ScintillaBase::AutoCompleteStart ), that needs the great amount of time.

Maybe we have to create our own listbox to show the includes ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12069
    • Travis build status
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #99 on: October 12, 2010, 07:03:59 pm »
Or limit the number to 500 and to put "To many includes found..." at the top of the list :)
(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 jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #100 on: October 12, 2010, 08:22:48 pm »
More tests:
The problem is not the wxStringTokenizer, but appending the string to the listcontrol.
So limiting the maximal amount, or better kicking in the autocomp-listbox after 2 or more characters (as default, configurable) might be the best solution.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #101 on: October 13, 2010, 03:07:56 am »
More tests:
The problem is not the wxStringTokenizer, but appending the string to the listcontrol.
So limiting the maximal amount, or better kicking in the autocomp-listbox after 2 or more characters (as default, configurable) might be the best solution.
Thanks a lot! :D

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #102 on: October 13, 2010, 05:36:29 am »
#include " --> worked very fast, but several includes missing
#include <  --> still rather slow [and at the start I always have a lot of entries like this : /32/32/32/32/32/32/32....]
Fixed in r6708. :D

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5188
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #103 on: October 13, 2010, 08:39:02 am »
I can confirm that
Code: [Select]
#include <
now works fast, and one first has to type a few first characters.

But the
Code: [Select]
#include "
fails for me.

My test project :
simple console project -> the .cbp and main.cpp are in the same directory. The project has some search/include directories added.
But not even one suggestion pops up, even if I start typing parts of the filename of the header to include.

For further testing purposes, I added 2 more files to the same directory where main.cpp is (and the .cbp) : foo.h and bar.h
Also these 2 don't show up in the suggestion list.

Next I added foo.h to the project, from that moment on the include list "foo.h" appears, but not bar.h [I even added the directory where main.cpp and foo/bar.h live as an include directory explicitly].

This is something that used to work, so I guess somewhere there's still a little glitch.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 25 september 2010 build (6634) CODECOMPLETION BRANCH version is out.
« Reply #104 on: October 13, 2010, 09:04:31 am »
Next I added foo.h to the project, from that moment on the include list "foo.h" appears, but not bar.h [I even added the directory where main.cpp and foo/bar.h live as an include directory explicitly].
#include "f // appear f****.h
#include "b // appear b****.h
That's right!