ide: Context goto now works on local variables and parameters too

git-svn-id: svn://ultimatepp.org/upp/trunk@7524 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-07-20 14:36:24 +00:00
parent 37ae7466c5
commit 0162bb2bde
3 changed files with 18 additions and 3 deletions

View file

@ -436,6 +436,7 @@ public:
struct Local : Moveable<Local> {
String type;
bool isptr;
int line;
};
VectorMap<String, Local> local;

View file

@ -785,11 +785,13 @@ Array<Parser::Decl> Parser::Declaration(bool l0, bool more)
void Parser::Locals(const String& type)
{
Line();
Array<Parser::Decl> d = Declaration(true, true);
for(int i = 0; i < d.GetCount(); i++) {
Local& l = local.Add(d[i].name);
l.type = type;
l.isptr = d[i].isptr;
l.line = line + 1;
}
}
@ -829,6 +831,7 @@ bool Parser::TryDecl()
if(t == tk_int || t == tk_bool || t == tk_float || t == tk_double || t == tk_void ||
t == tk_long || t == tk_signed || t == tk_unsigned || t == tk_short ||
t == tk_char || t == tk___int8 || t == tk___int16 || t == tk___int32 || t == tk___int64) {
q++;
while(lex[q] == '*' || lex[q] == '&')
q++;
if(!lex.IsId(q))
@ -1246,6 +1249,7 @@ CppItem& Parser::Fn(const Decl& d, const String& templ, bool body,
Local& l = local.Add(p.name);
l.type = p.type;
l.isptr = p.isptr;
l.line = line + 1;
}
ScAdd(param, p.natural);
if(i)

View file

@ -1157,6 +1157,7 @@ void Ide::ContextGoto0(int pos)
ci++;
}
editor.Context(parser, ci);
if(xp.GetCount() == 0 && IsNull(tp))
type.Add(parser.current_scope);
else {
@ -1167,8 +1168,19 @@ void Ide::ContextGoto0(int pos)
String id = editor.GetWord(pos);
if(id.GetCount() == 0)
return;
if(xp.GetCount() == 0) {
q = parser.local.Find(id);
if(q >= 0) {
AddHistory();
editor.SetCursor(editor.GetPos(parser.local[q].line - 1));
return;
}
}
Vector<String> scope;
bool istype = false;
if(xp.GetCount() == 0) { // 'String'
String t = Qualify(CodeBase(), parser.current_scope, id);
if(CodeBase().Find(t) >= 0) {
@ -1191,6 +1203,7 @@ void Ide::ContextGoto0(int pos)
if(GetIdScope(r, type[i], id, done))
scope.Add(r);
}
if(scope.GetCount() == 0) {
Index<String> done;
String r;
@ -1198,9 +1211,6 @@ void Ide::ContextGoto0(int pos)
scope.Add(r);
}
if(scope.GetCount() == 0)
return;
for(int j = 0; j < scope.GetCount(); j++) {
q = CodeBase().Find(scope[j]);
if(q >= 0) {