Skip to content

Commit

Permalink
Re-implemented the info-message when Clang is still parsing for AutoC…
Browse files Browse the repository at this point in the history
…ompletion.

Signed-off-by: Yves De Muyter <[email protected]>
  • Loading branch information
yvesdm3000 committed Dec 7, 2015
1 parent ca66fbb commit 98c4a39
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
24 changes: 14 additions & 10 deletions clangcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <cbstyledtextctrl.h>
#include <editor_hooks.h>
#include <cbcolourmanager.h>
#include <infowindow.h>

//#ifndef CB_PRECOMP
#include <cbeditor.h>
Expand All @@ -16,6 +17,7 @@
#include <projectmanager.h>

#include <algorithm>
#include <vector>
#include <wx/dir.h>
#include <wx/tokenzr.h>
#include <wx/choice.h>
Expand All @@ -40,7 +42,6 @@ ClangCodeCompletion::ClangCodeCompletion() :
m_CCOutstanding(0),
m_CCOutstandingLastMessageTime(0),
m_CCOutstandingPos(-1)

{

}
Expand Down Expand Up @@ -89,9 +90,12 @@ void ClangCodeCompletion::OnEditorActivate(CodeBlocksEvent& event)

ClTranslUnitId id = m_pClangPlugin->GetTranslationUnitId(fn);
m_TranslUnitId = id;
m_CCOutstandingLastMessageTime = 0;
#ifndef __WXMSW__
cbStyledTextCtrl* stc = ed->GetControl();
stc->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( ClangCodeCompletion::OnKeyDown ) );
stc->Connect( wxID_ANY, wxEVT_KEY_DOWN, wxKeyEventHandler( ClangCodeCompletion::OnKeyDown ), (wxObject*)NULL, this );
#endif
}
}

Expand Down Expand Up @@ -266,15 +270,20 @@ std::vector<cbCodeCompletionPlugin::CCToken> ClangCodeCompletion::GetAutocompLis
}
}

ClTranslUnitId translUnitId = m_TranslUnitId;
if( translUnitId != GetCurrentTranslationUnitId() )
return tokens;
ClTranslUnitId translUnitId = GetCurrentTranslationUnitId();
if (translUnitId == wxNOT_FOUND)
{
Manager::Get()->GetLogManager()->LogWarning(wxT("ClangLib: m_TranslUnitId == wxNOT_FOUND, "
Manager::Get()->GetLogManager()->LogWarning(wxT("ClangLib: translUnitId == wxNOT_FOUND, "
"cannot complete in file ") + ed->GetFilename());
if (wxGetLocalTime() + 10 > m_CCOutstandingLastMessageTime)
{
InfoWindow::Display(_("Code completion"), _("Busy parsing the document"), 1000);
m_CCOutstandingLastMessageTime = wxGetLocalTime();
}
return tokens;
}
if( translUnitId != m_TranslUnitId )
return tokens;

const wxChar curChar = stc->GetCharAt(tknEnd - 1);
if (isAuto) // filter illogical cases of auto-launch
Expand Down Expand Up @@ -346,11 +355,6 @@ std::vector<cbCodeCompletionPlugin::CCToken> ClangCodeCompletion::GetAutocompLis
}
if( wxCOND_TIMEOUT == m_pClangPlugin->GetCodeCompletionAt(translUnitId, ed->GetFilename(), loc, timeout, tknResults))
{
if (wxGetLocalTime() - m_CCOutstandingLastMessageTime > 10)
{
//InfoWindow::Display(_("Code completion"), _("Busy parsing the document"), 1000);
m_CCOutstandingLastMessageTime = wxGetLocalTime();
}
//std::cout<<"Timeout waiting for code completion"<<std::endl;
m_CCOutstanding++;
m_CCOutstandingPos = ed->GetControl()->GetCurrentPos();
Expand Down
4 changes: 1 addition & 3 deletions clangdiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void ClangDiagnostics::OnGotoNextDiagnostic( wxCommandEvent& WXUNUSED(event) )
cbEditor* ed = edMgr->GetBuiltinActiveEditor();
if (!ed)
{
std::cout<<"No editor..."<<std::endl;
return;
}

Expand All @@ -109,7 +108,6 @@ void ClangDiagnostics::OnGotoPrevDiagnostic( wxCommandEvent& WXUNUSED(event) )
cbEditor* ed = edMgr->GetBuiltinActiveEditor();
if (!ed)
{
std::cout<<"No editor..."<<std::endl;
return;
}

Expand Down Expand Up @@ -159,7 +157,7 @@ void ClangDiagnostics::OnDiagnostics( ClangEvent& event )
cbEditor* ed = edMgr->GetBuiltinActiveEditor();
if (!ed)
{
std::cout<<"No editor..."<<std::endl;

return;
}
if( event.GetTranslationUnitId() != GetCurrentTranslationUnitId() )
Expand Down
3 changes: 2 additions & 1 deletion translationunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ ClTranslationUnit::ClTranslationUnit(ClTranslationUnit&& other) :
other.m_ClTranslUnit = nullptr;
}

ClTranslationUnit::ClTranslationUnit(const ClTranslationUnit& WXUNUSED(other))
ClTranslationUnit::ClTranslationUnit(const ClTranslationUnit& WXUNUSED(other)) :
m_LastPos(-1, -1)
{
fprintf(stdout,"%s\n", __PRETTY_FUNCTION__);
cbThrow(wxT("Illegal copy attempted of TranslationUnit object."));
Expand Down

0 comments on commit 98c4a39

Please sign in to comment.