More A++ fixes, A++ now supports THISBACK

git-svn-id: svn://ultimatepp.org/upp/trunk@515 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2008-10-10 20:39:22 +00:00
parent b1769a1d8d
commit d55256f013
4 changed files with 48 additions and 32 deletions

View file

@ -286,17 +286,25 @@ void AssistEditor::Assist()
Context(parser, GetCursor());
int q = GetCursor();
assist_cursor = q;
while(iscid(Ch(q - 1)))
q--;
assist_type.Clear();
assist_item.Clear();
Index<String> in_types;
while(iscid(Ch(q - 1)))
q--;
SkipSpcBack(q);
if(Ch(q - 1) == '(') {
--q;
String id = IdBack(q);
if(id == "THISBACK")
GatherItems(parser.current_scope, false, in_types, false, true);
}
else
if(Ch(q - 1) == ':') {
while(Ch(q - 1) == ':')
q--;
Vector<String> tparam;
GatherItems(ParseTemplatedType(Qualify(parser.current_scope, CompleteIdBack(q)), tparam),
true, in_types, true);
String scope = ParseTemplatedType(Qualify(parser.current_scope, CompleteIdBack(q)), tparam);
GatherItems(scope, false, in_types, true, false);
}
else {
String tp;
@ -305,12 +313,12 @@ void AssistEditor::Assist()
Index<String> typeset = ExpressionType(parser, xp);
for(int i = 0; i < typeset.GetCount(); i++)
if(typeset[i].GetCount())
GatherItems(typeset[i], xp.GetCount() == 0, in_types, xp.GetCount() == 0);
GatherItems(typeset[i], xp.GetCount(), in_types, xp.GetCount() == 0, false);
}
else {
GatherItems(parser.current_scope, true, in_types, true);
GatherItems(parser.current_scope, true, in_types, true, false);
Index<String> in_types2;
GatherItems("", true, in_types2, true);
GatherItems("", false, in_types2, true, false);
}
}
if(assist_item.GetCount() == 0)
@ -381,6 +389,7 @@ void AssistEditor::Complete()
f.access = 0;
f.kind = 100;
}
assist_type.Clear();
PopUpAssist(true);
}
@ -490,13 +499,13 @@ bool AssistEditor::Key(dword key, int count)
else
SyncAssist();
}
else {
if(auto_assist &&
(key == '.' || key == '>' && Ch(GetCursor() - 2) == '-' ||
key == ':' && Ch(GetCursor() - 2) == ':') &&
InCode())
Assist();
else
if(auto_assist && InCode()) {
if(key == '.' || key == '>' && Ch(GetCursor() - 2) == '-' ||
key == ':' && Ch(GetCursor() - 2) == ':')
Assist();
if(key == '(')
Assist();
}
if(key == ',') {
if(Ch(GetCursor()) == 184) {

View file

@ -229,7 +229,8 @@ int CharFilterT(int c)
return c >= '0' && c <= '9' ? "TUVWXYZMNO"[c - '0'] : c;
}
void AssistEditor::GatherItems(const String& type, bool nom, Index<String>& in_types, bool tp)
void AssistEditor::GatherItems(const String& type, bool only_public, Index<String>& in_types, bool types,
bool thisback)
{
LLOG("GatherItems " << type);
if(in_types.Find(type) >= 0) {
@ -241,7 +242,7 @@ void AssistEditor::GatherItems(const String& type, bool nom, Index<String>& in_t
String ntp = ParseTemplatedType(type, tparam);
int q = BrowserBase().Find(ntp);
if(q >= 0) {
if(tp) {
if(types) {
if(ntp.GetCount())
ntp << "::";
int typei = assist_type.FindAdd("<types>");
@ -268,8 +269,8 @@ void AssistEditor::GatherItems(const String& type, bool nom, Index<String>& in_t
const CppItem& im = n[i];
if(im.IsType())
base = im.qptype;
if((im.IsCode() || im.IsData() || im.IsMacro() && type == "")
&& (nom || im.access == PUBLIC)) {
if((im.IsCode() || !thisback && (im.IsData() || im.IsMacro() && type == ""))
&& (!only_public || im.access == PUBLIC)) {
int q = assist_item.Find(im.name);
while(q >= 0) {
if(assist_item[q].typei != typei)
@ -281,11 +282,13 @@ void AssistEditor::GatherItems(const String& type, bool nom, Index<String>& in_t
(CppItem&)f = im;
}
}
Vector<String> b = Split(base, ';');
ResolveTParam(b, tparam);
for(int i = 0; i < b.GetCount(); i++)
if(b[i].GetCount())
GatherItems(b[i], nom, in_types, tp);
if(!thisback) {
Vector<String> b = Split(base, ';');
ResolveTParam(b, tparam);
for(int i = 0; i < b.GetCount(); i++)
if(b[i].GetCount())
GatherItems(b[i], only_public, in_types, types, thisback);
}
}
in_types.Drop();
}

View file

@ -234,14 +234,17 @@ bool Ide::SwapSIf(const char *cref)
if(cref && MakeCodeRef(p.current_scope, p.current_key) != cref)
return false;
q = FindItem(n, qitem);
int count = GetCount(n, q);
if(q < 0 || count == 1) {
q = FindName(n, p.current_name);
if(q < 0)
return false;
count = GetCount(n, q);
if(count == 1)
return false;
int count = q >= 0 ? GetCount(n, q) : 0;
if(!cref && count < 2) {
for(int i = 0; i < n.GetCount(); i++) {
if(i >= n.GetCount())
return false;
if(n[i].name == p.current_name) {
GotoCpp(n[i]);
return true;
}
}
return false;
}
int file = GetCppFileIndex(editfile);
int line = p.current.line;

View file

@ -425,7 +425,8 @@ struct AssistEditor : CodeEditor {
void DCopy();
void Virtuals();
void Thisbacks();
void GatherItems(const String& type, bool nom, Index<String>& in_types, bool tp);
void GatherItems(const String& type, bool only_public, Index<String>& in_types,
bool types, bool thisback);
void SelParam();
int Ch(int q);