Skip to content

Commit

Permalink
C++ Code Completion: suggest code completion for C++11 lambda functio…
Browse files Browse the repository at this point in the history
…n arguments without clang enabled
  • Loading branch information
eranif committed Apr 8, 2015
1 parent d75e24d commit e313166
Show file tree
Hide file tree
Showing 8 changed files with 3,126 additions and 2,431 deletions.
2,551 changes: 1,427 additions & 1,124 deletions CodeLite/scope_optimizer.cpp

Large diffs are not rendered by default.

48 changes: 33 additions & 15 deletions Plugin/cl_editor_tip_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ EVT_PAINT(clEditorTipWindow::OnPaint)
EVT_ERASE_BACKGROUND(clEditorTipWindow::OnEraseBg)
END_EVENT_TABLE()

#define TIP_SPACER 4
#define TIP_SPACER 10

clEditorTipWindow::clEditorTipWindow(wxWindow* parent)
: wxPanel(parent)
, m_highlighIndex(0)
{
m_font = ColoursAndFontsManager::Get().GetLexer("c++")->GetFontForSyle(0); // default font
m_font = DrawingUtils::GetDefaultFixedFont();
Hide();
EventNotifier::Get()->Connect(
wxEVT_CMD_COLOURS_FONTS_UPDATED, clCommandEventHandler(clEditorTipWindow::OnEditoConfigChanged), NULL, this);
Expand All @@ -62,16 +62,21 @@ clEditorTipWindow::~clEditorTipWindow()
wxEVT_CMD_COLOURS_FONTS_UPDATED, clCommandEventHandler(clEditorTipWindow::OnEditoConfigChanged), NULL, this);
}

void clEditorTipWindow::OnEraseBg(wxEraseEvent& e) { wxUnusedVar(e); }
void clEditorTipWindow::OnEraseBg(wxEraseEvent& e)
{
wxUnusedVar(e);
}

void clEditorTipWindow::OnPaint(wxPaintEvent& e)
{
wxUnusedVar(e);
wxBufferedPaintDC dc(this);

wxGCDC gdc;
if(!DrawingUtils::GetGCDC(dc, gdc)) return;
if(m_args.IsEmpty()) return;
if(!DrawingUtils::GetGCDC(dc, gdc))
return;
if(m_args.IsEmpty())
return;

// Define the colours used by this tooltip window
clColourPalette colours = DrawingUtils::GetColourPalette();
Expand All @@ -97,7 +102,7 @@ void clEditorTipWindow::OnPaint(wxPaintEvent& e)
wxCoord y = 0;

if(!m_header.IsEmpty()) {
wxFont guiFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont guiFont = m_font;
gdc.SetFont(guiFont);
wxSize headerSize = gdc.GetTextExtent(m_header);
wxPoint headerPt;
Expand Down Expand Up @@ -133,12 +138,12 @@ void clEditorTipWindow::OnPaint(wxPaintEvent& e)
if(!m_footer.IsEmpty()) {
gdc.SetPen(penColour);
gdc.DrawLine(0, y, rr.GetWidth(), y);

// Draw the extra line ("1 OF N")
m_footer.Clear();
m_footer << (GetTip()->GetCurr() + 1) << " OF " << GetTip()->Count();

wxFont guiFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont guiFont = m_font;
gdc.SetFont(guiFont);
wxSize extraLineSize = gdc.GetTextExtent(m_footer);

Expand Down Expand Up @@ -167,12 +172,16 @@ void clEditorTipWindow::AddCallTip(clCallTipPtr tip)

clCallTipPtr clEditorTipWindow::GetTip()
{
if(m_tips.empty()) return NULL;
if(m_tips.empty())
return NULL;

return m_tips.at(m_tips.size() - 1).tip;
}

bool clEditorTipWindow::IsEmpty() { return m_tips.empty(); }
bool clEditorTipWindow::IsEmpty()
{
return m_tips.empty();
}

void clEditorTipWindow::Remove()
{
Expand All @@ -184,7 +193,8 @@ void clEditorTipWindow::Remove()
}
}

if(m_tips.empty()) Deactivate();
if(m_tips.empty())
Deactivate();
}

void clEditorTipWindow::Clear()
Expand All @@ -197,7 +207,10 @@ void clEditorTipWindow::Clear()
m_lineHeight = 0;
}

bool clEditorTipWindow::IsActive() { return IsShown(); }
bool clEditorTipWindow::IsActive()
{
return IsShown();
}

void clEditorTipWindow::Highlight(int argIdxToHilight)
{
Expand Down Expand Up @@ -245,7 +258,8 @@ wxString clEditorTipWindow::GetText()

void clEditorTipWindow::Activate(wxPoint pt, int lineHeight, wxColour parentBgColour)
{
if(m_tips.empty()) return;
if(m_tips.empty())
return;

m_point = pt;
m_lineHeight = lineHeight;
Expand All @@ -260,7 +274,8 @@ void clEditorTipWindow::Activate(wxPoint pt, int lineHeight, wxColour parentBgCo
void clEditorTipWindow::Deactivate()
{
Clear();
if(IsShown()) Hide();
if(IsShown())
Hide();
}

wxSize clEditorTipWindow::DoGetTipSize()
Expand Down Expand Up @@ -293,6 +308,8 @@ wxSize clEditorTipWindow::DoGetTipSize()
wxSize headerSize = dc->GetTextExtent(m_header);
minLineWidth = headerSize.x > minLineWidth ? headerSize.x : minLineWidth;
}

minLineWidth += (2 * TIP_SPACER);
wxString tipContent = wxJoin(m_args, '\n');
tipContent.Trim().Trim(false);

Expand Down Expand Up @@ -341,7 +358,8 @@ void clEditorTipWindow::DoAdjustPosition()
// our tip can not fit into the screen, shift it left
pt.x -= ((pt.x + sz.x) - parentSize.width);

if(pt.x < 0) pt.x = 0;
if(pt.x < 0)
pt.x = 0;
}
Move(pt);
}
Expand Down
4 changes: 2 additions & 2 deletions Plugin/drawingutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@

#ifdef __WXMSW__
#define DEFAULT_FACE_NAME "Consolas"
#define DEFAULT_FONT_SIZE 9
#define DEFAULT_FONT_SIZE 11
#elif defined(__WXMAC__)
#define DEFAULT_FACE_NAME "monaco"
#define DEFAULT_FONT_SIZE 11
#define DEFAULT_FONT_SIZE 12
#else // GTK, FreeBSD etc
#define DEFAULT_FACE_NAME "monospace"
#define DEFAULT_FONT_SIZE 11
Expand Down
79 changes: 39 additions & 40 deletions ScopeOptimizer/ScopeOptimizer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,52 @@
#include <errno.h>
#include <string.h>


#include "scope_optimizer.h"
char *loadFile(const char *fileName);
char* loadFile(const char* fileName);

int main(int argc, char **argv)
int main(int argc, char** argv)
{
std::string output, localsScope;
char *input = loadFile("../test.h");

::OptimizeScope(input, output, 41, localsScope);
printf("Locals: %s\n", localsScope.c_str());
printf("All : %s\n", output.c_str());
return 0;
std::string output, localsScope;
char* input = loadFile("../test.h");

::OptimizeScope(input, output, 41, localsScope);

printf("Locals: %s\n", localsScope.c_str());
printf("All : %s\n", output.c_str());
return 0;
}

//-------------------------------------------------------
// Help function
//-------------------------------------------------------
char *loadFile(const char *fileName)
char* loadFile(const char* fileName)
{
FILE *fp;
long len;
char *buf = NULL;

fp = fopen(fileName, "rb");
if (!fp) {
printf("failed to open file 'test.h': %s\n", strerror(errno));
return NULL;
}

//read the whole file
fseek(fp, 0, SEEK_END); //go to end
len = ftell(fp); //get position at end (length)
fseek(fp, 0, SEEK_SET); //go to begining
buf = (char *)malloc(len+1); //malloc buffer

//read into buffer
long bytes = fread(buf, sizeof(char), len, fp);
printf("read: %ld\n", bytes);
if (bytes != len) {
fclose(fp);
printf("failed to read from file 'test.h': %s\n", strerror(errno));
return NULL;
}

buf[len] = 0; // make it null terminated string
fclose(fp);
return buf;
FILE* fp;
long len;
char* buf = NULL;

fp = fopen(fileName, "rb");
if(!fp) {
printf("failed to open file 'test.h': %s\n", strerror(errno));
return NULL;
}

// read the whole file
fseek(fp, 0, SEEK_END); // go to end
len = ftell(fp); // get position at end (length)
fseek(fp, 0, SEEK_SET); // go to begining
buf = (char*)malloc(len + 1); // malloc buffer

// read into buffer
long bytes = fread(buf, sizeof(char), len, fp);
printf("read: %ld\n", bytes);
if(bytes != len) {
fclose(fp);
printf("failed to read from file 'test.h': %s\n", strerror(errno));
return NULL;
}

buf[len] = 0; // make it null terminated string
fclose(fp);
return buf;
}
Loading

0 comments on commit e313166

Please sign in to comment.