From 795b842adffbfa21cdd1ef08bc9ecec0dd6ef1a4 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Sat, 13 Aug 2022 11:41:01 +0200 Subject: [PATCH] alt+j -> .lay, .iml --- uppsrc/ide/ContextGoto.cpp | 34 ++++++++++++++++++++++++++++++++-- uppsrc/ide/LayDes/layfile.cpp | 2 ++ uppsrc/ide/clang/todo.txt | 6 ++++++ uppsrc/ide/ide.h | 1 + uppsrc/ide/idetool.cpp | 13 +++++++++---- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/uppsrc/ide/ContextGoto.cpp b/uppsrc/ide/ContextGoto.cpp index 20926c1e5..07d139a53 100644 --- a/uppsrc/ide/ContextGoto.cpp +++ b/uppsrc/ide/ContextGoto.cpp @@ -168,6 +168,8 @@ void Ide::ContextGoto0(int pos) String found_path; Point found_pos(INT_MAX, INT_MAX); bool found_definition = false; + String found_name; + String found_nest; for(const auto& f : ~CodeIndex()) for(const AnnotationItem& m : f.value.items) { @@ -178,10 +180,38 @@ void Ide::ContextGoto0(int pos) found_path = f.key; found_pos = m.pos; found_definition = m.definition; + found_name = m.name; + found_nest = m.nest; } } - if(found_path.GetCount()) - GotoPos(found_path, found_pos); + if(found_path.GetCount()) { + AddHistory(); + EditFile(found_path); + LayDesigner *l = dynamic_cast(~designer); + if(l) { + String cls = found_nest; + int q = cls.ReverseFind(':'); + if(q >= 0) + cls = cls.Mid(q + 1); + if(cls.TrimStart("With")) { + l->FindLayout(cls, found_name); + return; + } + else + if(found_name.TrimStart("SetLayout_")) { + l->FindLayout(found_name, Null); + return; + } + DoEditAsText(found_path); + } + IdeIconDes *k = dynamic_cast(~designer); + if(k) { + k->FindId(found_name); + return; + } + GotoPos(found_pos); + AddHistory(); + } } } diff --git a/uppsrc/ide/LayDes/layfile.cpp b/uppsrc/ide/LayDes/layfile.cpp index 12826f1a2..33cb16918 100644 --- a/uppsrc/ide/LayDes/layfile.cpp +++ b/uppsrc/ide/LayDes/layfile.cpp @@ -83,11 +83,13 @@ void LayDes::RestoreEditPos() void LayDes::FindLayout(const String& name, const String& item_name) { + DDUMP(item_name); for(int i = 0; i < layout.GetCount(); i++) if(layout[i].name == name) { GoTo(i); if(!IsNull(item_name)) { int q = item.Find(item_name, 1); + DDUMP(q); if(q >= 0) SelectOne(q, 0); } diff --git a/uppsrc/ide/clang/todo.txt b/uppsrc/ide/clang/todo.txt index f9c27a11f..fcd48d8dd 100644 --- a/uppsrc/ide/clang/todo.txt +++ b/uppsrc/ide/clang/todo.txt @@ -156,6 +156,12 @@ ISUES: - Alt-J on layout +- Alt-J relaxed rules if not found (in templates, different parameters) + +- Remove IdeGotoFileAndId (after fixing laydes Alt+K) + +- remove bool Ide::GotoDesignerFile(const String& path, const String& scope, const String& name, int line) + GREAT CODEBASE PURGE: - ReferenceDlg diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index 8b2f81da4..322d247d3 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -808,6 +808,7 @@ public: void SelectMode(); void SerializeOutputMode(Stream& s); + void GotoPos(Point pos); void GotoPos(String path, int line); void GotoPos(String path, Point pos); diff --git a/uppsrc/ide/idetool.cpp b/uppsrc/ide/idetool.cpp index 3681699ee..31c1764b2 100644 --- a/uppsrc/ide/idetool.cpp +++ b/uppsrc/ide/idetool.cpp @@ -2,6 +2,14 @@ #define LLOG(x) // DLOG(x) +void Ide::GotoPos(Point pos) +{ + editor.SetCursor(editor.GetPos64(pos.y, pos.x)); + editor.TopCursor(4); + editor.SetFocus(); + AddHistory(); +} + void Ide::GotoPos(String path, int line) { GotoPos(path, Point(0, line)); @@ -16,10 +24,7 @@ void Ide::GotoPos(String path, Point pos) DoEditAsText(path); EditFile(path); } - editor.SetCursor(editor.GetPos64(pos.y, pos.x)); - editor.TopCursor(4); - editor.SetFocus(); - AddHistory(); + GotoPos(pos); } String PosFn(const String& pkg, const String& n)