diff --git a/foo/_empty_test.cc b/foo/_empty_test.cc index f8cb862a..b23e8ee3 100644 --- a/foo/_empty_test.cc +++ b/foo/_empty_test.cc @@ -27,7 +27,9 @@ int foo() { float MyBar::MemberFunc(int a, char b, std::vector foo) { this->x = 100; - return 0; + this->MemberFunc(0, 0, {}); + + return ::foo(); } diff --git a/foo/a.cc b/foo/a.cc new file mode 100644 index 00000000..9c77fd3b --- /dev/null +++ b/foo/a.cc @@ -0,0 +1,96 @@ +/* +abc +daaa +faf +dakkdakk +abaa +*/ +#include + +#include "a.h" + +struct Middle : public Parent { + void foo() override {} +}; +struct DerivedA : public Middle { + void foo() override {} +}; +struct DerivedB : public Middle { + void foo() override {} +}; +struct Derived2B : public DerivedB { + void foo() override {} +}; + +struct Derived2C : public DerivedB { + void foo() override; +}; + + +void Derived2C::foo() {} + +void User() { + Parent p; + Middle m; + DerivedA da; + DerivedB db; + Derived2B d2b; + + p.foo(); + m.foo(); + da.foo(); + db.foo(); + d2b.foo(); +} + + + + + +struct Saaaaaa {}; + +struct S2 { + S2() {} + + int a; + int b; +}; + +struct MyFoo { + std::string name; +}; + +void f() { + S2 s2; + s2.a += 10; + s2.b -= 100; + s2.b -= 5; + + MyFoo f; + // f.name = 10; + f.name = "okay"; + + MyFoo f2; + f2.name = "yes!"; +} + + +void baz(); + +void foo(); +void foo(); + +void foo() {} + +/**/ +void caller() { + MyFoo fff; + fff.name = "this name"; + baz(); + baz(); + baz(); + foo(); + + foo(); + foo(); +} \ No newline at end of file diff --git a/foo/a.h b/foo/a.h new file mode 100644 index 00000000..5b31fe11 --- /dev/null +++ b/foo/a.h @@ -0,0 +1,3 @@ +struct Parent { + virtual void foo() {} +}; diff --git a/src/command_line.cc b/src/command_line.cc index 394d653b..dacc2a05 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -951,8 +951,6 @@ void QueryDbMainLoop( } case IpcId::TextDocumentCodeLens: { - // TODO: add code lens for - // - jump to parent method for functions auto msg = static_cast(message.get()); Out_TextDocumentCodeLens response; @@ -991,27 +989,6 @@ void QueryDbMainLoop( int offset = 0; - /* - // TODO: See if we can get this working. - optional base_definition = GetBaseDefinitionSpelling(db, func); - if (base_definition) { - optional ls_base = GetLsLocation(db, working_files, *base_definition); - if (ls_base) { - optional range = GetLsRange(common.working_file, ref.loc.range); - if (range) { - TCodeLens code_lens; - code_lens.range = *range; - code_lens.command = lsCommand(); - code_lens.command->command = "superindex.goto"; - code_lens.command->arguments.uri = GetLsDocumentUri(db, ref.loc.path); - code_lens.command->arguments.position = code_lens.range.start; - code_lens.command->arguments.locations.push_back(*ls_base); - response.result.push_back(code_lens); - } - } - } - */ - std::vector base_callers = GetCallersForAllBaseFunctions(db, func); std::vector derived_callers = GetCallersForAllDerivedFunctions(db, func); if (base_callers.empty() && derived_callers.empty()) { @@ -1027,11 +1004,32 @@ void QueryDbMainLoop( } AddCodeLens(&common, ref.loc.OffsetStartColumn(offset++), ToQueryableLocation(db, func.derived), "derived", "derived"); + + // "Base" + optional base_definition = GetBaseDefinitionSpelling(db, func); + if (base_definition) { + optional ls_base = GetLsLocation(db, working_files, *base_definition); + if (ls_base) { + optional range = GetLsRange(common.working_file, ref.loc.range); + if (range) { + TCodeLens code_lens; + code_lens.range = *range; + code_lens.range.start.character += offset++; + code_lens.command = lsCommand(); + code_lens.command->title = "Base"; + code_lens.command->command = "superindex.goto"; + code_lens.command->arguments.uri = ls_base->uri; + code_lens.command->arguments.position = ls_base->range.start; + response.result.push_back(code_lens); + } + } + } + break; } case SymbolKind::Var: { QueryableVarDef& def = db->vars[symbol.idx]; - AddCodeLens(&common, ref.loc.OffsetStartColumn(0), def.uses, "reference", "references", true /*exclude_loc*/, false /*only_interesting*/); + AddCodeLens(&common, ref.loc.OffsetStartColumn(0), def.uses, "ref", "refs", true /*exclude_loc*/, false /*only_interesting*/); break; } case SymbolKind::File: