mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: Fixed assist++ issues
git-svn-id: svn://ultimatepp.org/upp/trunk@8952 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
5dd1b4936b
commit
9ff668bdd2
10 changed files with 71 additions and 23 deletions
|
|
@ -798,7 +798,7 @@ void Sort(I l, I h, const Less& less)
|
|||
++iih;
|
||||
if(pass > 5 || min(ii - l, h - iih) > (max(ii - l, h - iih) >> pass)) { // partition sizes ok or we have done max attempts
|
||||
if(ii - l < h - iih - 1) { // recurse on smaller partition, tail on larger
|
||||
Sort(l, ii, less);
|
||||
Sort(l, ii, less);
|
||||
l = iih + 1;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ void CppItem::Dump(Stream& s) const
|
|||
PUT(qptype);
|
||||
PUT(tname);
|
||||
PUT(ctname);
|
||||
PUT(using_namespaces);
|
||||
#undef PUT
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,6 +201,43 @@ void QualifyTypes(CppBase& base, const String& scope, CppItem& m)
|
|||
m.qptype = QualifyIds(nf, m.ptype, m.using_namespaces, true);
|
||||
}
|
||||
|
||||
void QualifyPass0(CppBase& base)
|
||||
{ // Move scopes - solve: namespace X { struct C { void Foo(); }; using namespace X; void C::Foo() {}
|
||||
Vector<int> remove_scope;
|
||||
for(int ni = 0; ni < base.GetCount(); ni++) {
|
||||
Array<CppItem>& n = base[ni];
|
||||
ScopeInfo nf(base);
|
||||
String scope = base.GetKey(ni);
|
||||
String usings;
|
||||
int toscopei = -1;
|
||||
Vector<int> remove_item;
|
||||
for(int i = 0; i < n.GetCount(); i++) {
|
||||
CppItem& m = n[i];
|
||||
if(m.qualify && m.impl) {
|
||||
if(usings != m.using_namespaces) {
|
||||
usings = m.using_namespaces;
|
||||
toscopei = -1;
|
||||
Vector<String> h = Split(m.using_namespaces, ';');
|
||||
for(int i = 0; i < h.GetCount(); i++) {
|
||||
String ns = h[i] + "::" + scope;
|
||||
toscopei = base.Find(ns);
|
||||
if(toscopei >= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(toscopei >= 0 && toscopei != ni) {
|
||||
base[toscopei].Add(m);
|
||||
remove_item.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
n.Remove(remove_item);
|
||||
if(scope.GetCount() && n.GetCount() == 0)
|
||||
remove_scope.Add(ni);
|
||||
}
|
||||
base.Remove(remove_scope);
|
||||
}
|
||||
|
||||
void QualifyPass1(CppBase& base)
|
||||
{ // Qualify types
|
||||
LTIMING("QualifyPass1");
|
||||
|
|
@ -267,6 +304,7 @@ void Qualify(CppBase& base)
|
|||
}
|
||||
}
|
||||
base.namespaces.Clear();
|
||||
QualifyPass0(base);
|
||||
QualifyPass1(base);
|
||||
QualifyPass2(base);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,17 +109,17 @@ const Vector<String>& ScopeInfo::GetScopes(const String& usings_)
|
|||
usings = usings_;
|
||||
nvalid = true;
|
||||
scopes.Clear();
|
||||
if(scopei < 0)
|
||||
return scopes;
|
||||
String nn = base.GetKey(scopei);
|
||||
while(nn.GetCount()) {
|
||||
if(nn[0] == ':' && nn.GetCount() == 2) {
|
||||
scopes.Add(nn);
|
||||
return scopes;
|
||||
if(scopei >= 0) {
|
||||
String nn = base.GetKey(scopei);
|
||||
while(nn.GetCount()) {
|
||||
if(nn[0] == ':' && nn.GetCount() == 2) {
|
||||
scopes.Add(nn);
|
||||
return scopes;
|
||||
}
|
||||
scopes.Add(nn + "::");
|
||||
int q = nn.ReverseFind(':');
|
||||
nn.Trim(max(0, q - 1));
|
||||
}
|
||||
scopes.Add(nn + "::");
|
||||
int q = nn.ReverseFind(':');
|
||||
nn.Trim(max(0, q - 1));
|
||||
}
|
||||
scopes.Add("");
|
||||
Vector<String> h = Split(usings, ';');
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ String CppMacro::Define(const char *s)
|
|||
try {
|
||||
if(!p.IsId())
|
||||
return Null;
|
||||
p.NoSkipSpaces().NoSkipComments(); // '#define TEST(x)' is difference form '#define TEST (x)' - later is parameterless
|
||||
p.NoSkipSpaces().NoSkipComments(); // '#define TEST(x)' is different form '#define TEST (x)' - later is parameterless
|
||||
id = p.ReadId();
|
||||
param.Clear();
|
||||
if(p.Char('(')) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ String GetStdDefs()
|
|||
h = Split(ignore, ';');
|
||||
for(int i = 0; i < h.GetCount(); i++)
|
||||
defs << "#define " << h[i] << "\n";
|
||||
defs << "#define NULL NULL";
|
||||
defs << "#define NULL NULL\n";
|
||||
defs << "#define DrawText DrawText\n"; // DrawTextA/DrawTextW fiasco...
|
||||
return defs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,9 +104,10 @@ PPMacro *FindPPMacro(const String& id, Index<int>& segment_id, int& segmenti)
|
|||
Index<int> undef;
|
||||
PPMacro *r;
|
||||
|
||||
int best;
|
||||
for(int pass = 0; pass < 2; pass++) {
|
||||
r = NULL;
|
||||
int best = segmenti;
|
||||
best = segmenti;
|
||||
int line = -1;
|
||||
int q = sAllMacros.Find(id);
|
||||
while(q >= 0) {
|
||||
|
|
@ -116,7 +117,7 @@ PPMacro *FindPPMacro(const String& id, Index<int>& segment_id, int& segmenti)
|
|||
undef.FindAdd(m.segment_id); // cancel out undefined macro...
|
||||
}
|
||||
else
|
||||
if(pass == 0 || undef.Find(m.undef_segment_id) < 0) {
|
||||
if(pass == 0 || m.segment_id == 0 || undef.Find(m.undef_segment_id) < 0) {
|
||||
int si = m.segment_id == 0 ? INT_MAX : segment_id.Find(m.segment_id); // defs macros always override
|
||||
if(si > best || si >= 0 && si == best && m.line > line) {
|
||||
best = si;
|
||||
|
|
@ -129,6 +130,7 @@ PPMacro *FindPPMacro(const String& id, Index<int>& segment_id, int& segmenti)
|
|||
if(undef.GetCount() == 0)
|
||||
break;
|
||||
}
|
||||
segmenti = best;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +196,7 @@ void PPFile::Parse(Stream& in)
|
|||
md5.Put("#", 1);
|
||||
md5.Put(id);
|
||||
md5.Put(0);
|
||||
md5.Put(m.macro.md5, 16);
|
||||
md5.Put(m.macro.md5, 16);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -206,7 +208,7 @@ void PPFile::Parse(Stream& in)
|
|||
md5.Put(1);
|
||||
int segmenti = -1;
|
||||
PPMacro *um = FindPPMacro(id, local_segments, segmenti);
|
||||
if(um) { // heuristic: only local undefs are allowed
|
||||
if(um && segmenti) { // heuristic: only local undefs are allowed
|
||||
PPItem& m = item.Add();
|
||||
m.type = PP_DEFINES;
|
||||
m.segment_id = ++sPPserial;
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ void Ide::ContextGoto0(int pos)
|
|||
|
||||
Vector<String> scope;
|
||||
Vector<bool> istype; // prefer type (e.g. struct Foo) over constructor (Foo::Foo())
|
||||
|
||||
for(int i = 0; i < type.GetCount(); i++) { // 'x.attr'
|
||||
Index<String> done;
|
||||
String r;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ void Navigator::GoToNavLine()
|
|||
|
||||
bool Navigator::NavLine::operator<(const NavLine& b) const
|
||||
{
|
||||
String p1 = GetSourceFilePath(file); //
|
||||
String p1 = GetSourceFilePath(file);
|
||||
String p2 = GetSourceFilePath(b.file);
|
||||
return CombineCompare/*(!impl, !b.impl)*/
|
||||
(GetFileExt(p2), GetFileExt(p1)) // .h > .c
|
||||
|
|
@ -538,6 +538,7 @@ void Navigator::Search()
|
|||
String usearch_name = ToUpper(search_name);
|
||||
ArrayMap<String, NavItem> imap;
|
||||
bool local = sorting && IsNull(s);
|
||||
VectorMap<String, int> nest_pass;
|
||||
for(int pass = -1; pass < 2; pass++) {
|
||||
for(int i = 0; i < b.GetCount(); i++) {
|
||||
String nest = b.GetKey(i);
|
||||
|
|
@ -558,7 +559,13 @@ void Navigator::Search()
|
|||
: m.name.StartsWith(search_name))
|
||||
|| both && foundnest) {
|
||||
String key = nest + '\1' + m.qitem;
|
||||
int q = imap.Find(key);
|
||||
int q = nest_pass.Find(nest);
|
||||
int p = pass;
|
||||
if(q < 0) // We do not want classes to be split based on pass
|
||||
nest_pass.Add(nest, pass);
|
||||
else
|
||||
p = nest_pass[q];
|
||||
q = imap.Find(key);
|
||||
if(q < 0) {
|
||||
NavItem& ni = imap.Add(key);
|
||||
ni.Set(m);
|
||||
|
|
@ -566,7 +573,7 @@ void Navigator::Search()
|
|||
ni.decl_line = ni.line;
|
||||
ni.decl_file = ni.file;
|
||||
ni.decl = !ni.impl;
|
||||
ni.pass = pass;
|
||||
ni.pass = p;
|
||||
NavLine& l = ni.linefo.Add();
|
||||
l.impl = m.impl;
|
||||
l.file = m.file;
|
||||
|
|
@ -574,13 +581,13 @@ void Navigator::Search()
|
|||
}
|
||||
else {
|
||||
NavItem& mm = imap[q];
|
||||
String n = mm.natural;
|
||||
if(!m.impl &&
|
||||
(!mm.decl
|
||||
|| CombineCompare(mm.decl_file, m.file)(mm.decl_line, m.line) < 0)) {
|
||||
mm.decl = true;
|
||||
mm.decl_line = m.line;
|
||||
mm.decl_file = m.file;
|
||||
mm.natural = m.natural;
|
||||
}
|
||||
NavLine& l = mm.linefo.Add();
|
||||
l.impl = m.impl;
|
||||
|
|
|
|||
|
|
@ -1090,7 +1090,7 @@ void AppMain___()
|
|||
if(!FileExists(ppdefs))
|
||||
#endif
|
||||
SaveFile(ppdefs, GetStdDefs());
|
||||
|
||||
|
||||
SetPPDefs(LoadFile(ppdefs));
|
||||
|
||||
ide.LoadLastMain();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue