ide: SwapS fixed new method issue #1280

git-svn-id: svn://ultimatepp.org/upp/trunk@8978 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-10-04 12:13:57 +00:00
parent ea54a51b3a
commit 963bddae63
3 changed files with 80 additions and 74 deletions

View file

@ -8,10 +8,12 @@
#define LDUMP(x) // DDUMP(x)
#ifdef _DEBUG
#define CLOG(x) // LOG(x)
// #define HAS_CLOG
#ifdef HAS_CLOG
#define CLOG(x) RLOG(x)
#else
#define CLOG(x) // RLOG(x)
#define CLOG(x)
#endif
#define CPP_CODEBASE_VERSION 314159
@ -247,7 +249,9 @@ bool CheckFile(SourceFileInfo& f, const String& path)
pp.Preprocess(npath, in, GetMasterFile(npath), true);
String md5 = pp.GetDependeciesMd5(GetPPFile(path).keywords);
bool r = f.dependencies_md5sum == md5 && tmok;
#ifdef HAS_CLOG
if(!r) CLOG(path << " " << f.dependencies_md5sum << " " << md5);
#endif
f.depends.Clear();
f.dependencies_md5sum = md5;
for(int i = 0; i < pp.visited.GetCount(); i++)
@ -281,9 +285,11 @@ void UpdateCodeBase2(Progress& pi)
Index<int> parse_file;
CLOG("Gathered files: " << GetAllSourceMasters());
const Index<String>& src = GetAllSources();
#ifdef HAS_CLOG
for(int i = 0; i < source_file.GetCount(); i++)
if(!source_file.IsUnlinked(i))
CLOG(i << " " << source_file.GetKey(i) << " " << source_file[i].dependencies_md5sum << " " << source_file[i].time);
#endif
pi.SetTotal(src.GetCount());
for(int i = 0; i < src.GetCount(); i++) {
pi.Step();

View file

@ -1,70 +1,70 @@
#include "ide.h"
#define LLOG(x) // DLOG(x)
void AssistEditor::SwapSContext(Parser& p)
{
int i = GetCursor();
if(Ch(i - 1) == ';')
i--;
else
for(;;) {
int c = Ch(i);
if(c == '{') {
i++;
break;
}
if(c == 0 || c == ';' || c == '}')
break;
i++;
}
Context(p, i);
}
bool Ide::SwapSIf(const char *cref)
{
if(designer || !editor.assist_active)
return false;
Parser p;
editor.SwapSContext(p);
int q = CodeBase().Find(p.current_scope);
LLOG("SwapS scope: " << p.current_scope << ", name " << p.current_name << ", key " << p.current_key);
if(q < 0)
return false;
const Array<CppItem>& nn = CodeBase()[q];
if(cref && MakeCodeRef(p.current_scope, p.current_key) != cref || IsNull(p.current_name))
return false;
Vector<const CppItem *> n;
bool destructor = p.current_key.Find('~') >= 0;
for(int i = 0; i < nn.GetCount(); i++) {
const CppItem& m = nn[i];
if(m.name == p.current_name && destructor == (m.kind == DESTRUCTOR) && !m.IsType())
n.Add(&m);
}
if(!cref && n.GetCount() < 2)
for(int i = 0; i < n.GetCount(); i++)
if(n[i]->IsType()) {
GotoCpp(*n[i]);
return false;
}
if(n.GetCount() == 0 || IsNull(editfile))
return false;
int file = GetSourceFileIndex(editfile);
int line = p.current.line;
LLOG("SwapS line: " << line);
int i;
for(i = 0; i < n.GetCount(); i++) {
LLOG("file: " << GetSourceFilePath(n[i]->file) << ", line: " << n[i]->line);
if(n[i]->file == file && n[i]->line == line) {
i++;
break;
}
}
GotoCpp(*n[i % n.GetCount()]);
return true;
}
void Ide::SwapS()
{
SwapSIf(NULL);
}
#include "ide.h"
#define LLOG(x) DLOG(x)
void AssistEditor::SwapSContext(Parser& p)
{
int i = GetCursor();
if(Ch(i - 1) == ';')
i--;
else
for(;;) {
int c = Ch(i);
if(c == '{') {
i++;
break;
}
if(c == 0 || c == ';' || c == '}')
break;
i++;
}
Context(p, i);
}
bool Ide::SwapSIf(const char *cref)
{
if(designer || !editor.assist_active)
return false;
Parser p;
editor.SwapSContext(p);
int q = CodeBase().Find(p.current_scope);
LLOG("SwapS scope: " << p.current_scope << ", name " << p.current_name << ", key " << p.current_key);
if(q < 0)
return false;
const Array<CppItem>& nn = CodeBase()[q];
if(cref && MakeCodeRef(p.current_scope, p.current_key) != cref || IsNull(p.current_name))
return false;
Vector<const CppItem *> n;
bool destructor = p.current_key.Find('~') >= 0;
for(int i = 0; i < nn.GetCount(); i++) {
const CppItem& m = nn[i];
if(m.name == p.current_name && destructor == (m.kind == DESTRUCTOR) && !m.IsType())
n.Add(&m);
}
if(!cref && n.GetCount() < 2)
for(int i = 0; i < nn.GetCount(); i++)
if(nn[i].IsType()) {
GotoCpp(nn[i]);
return false;
}
if(n.GetCount() == 0 || IsNull(editfile))
return false;
int file = GetSourceFileIndex(editfile);
int line = p.current.line;
LLOG("SwapS line: " << line);
int i;
for(i = 0; i < n.GetCount(); i++) {
LLOG("file: " << GetSourceFilePath(n[i]->file) << ", line: " << n[i]->line);
if(n[i]->file == file && n[i]->line == line) {
i++;
break;
}
}
GotoCpp(*n[i % n.GetCount()]);
return true;
}
void Ide::SwapS()
{
SwapSIf(NULL);
}

View file

@ -49,12 +49,12 @@ file
Assist.cpp,
DCopy.cpp,
ContextGoto.cpp,
Swaps.cpp,
ParamInfo.cpp,
Navigator.cpp,
Annotations.cpp,
Virtuals.cpp,
Thisbacks.cpp,
Goto.cpp,
Jump.cpp,
Setup.cpp,
Custom.cpp,