Skip to content

Commit

Permalink
more verbose document outline + fix some scopes
Browse files Browse the repository at this point in the history
fix #463
  • Loading branch information
WebFreak001 committed Nov 2, 2023
1 parent df3033d commit ac0b6c3
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 191 deletions.
2 changes: 2 additions & 0 deletions source/served/commands/complete.d
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ SymbolKind convertFromDscannerType(char type, string name = null)
return SymbolKind.variable;
case 'a':
return SymbolKind.field;
case ':':
return SymbolKind.module_;
default:
return cast(SymbolKind) 0;
}
Expand Down
10 changes: 6 additions & 4 deletions source/served/commands/symbol_search.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ JsonValue provideDocumentSymbols(DocumentSymbolParams params)
.hierarchicalDocumentSymbolSupport.orDefault)
return provideDocumentSymbolsHierarchical(params).toJsonValue;
else
return provideDocumentSymbolsOld(DocumentSymbolParamsEx(params)).map!"a.downcast".array.toJsonValue;
return provideDocumentSymbolsOld(DocumentSymbolParamsEx(params, true)).map!"a.downcast".array.toJsonValue;
}

private struct OldSymbolsCache
Expand Down Expand Up @@ -120,8 +120,10 @@ SymbolInformationEx makeSymbolInfoEx(scope const ref DefinitionElement def, stri
info.containerName = *ptr;
if ("deprecation" in attribs)
info.tags = [SymbolTag.deprecated_];
if (auto name = "name" in attribs)
info.detail = *name;
if (auto signature = "signature" in attribs)
info.detail = *signature;
if (auto detail = "detail" in attribs)
info.detail = *detail;
return info;
}

Expand All @@ -140,7 +142,7 @@ DocumentSymbolInfo[] provideDocumentSymbolsHierarchical(DocumentSymbolParams par
if (cached.length)
return cached;
DocumentSymbolInfo[] all;
auto symbols = provideDocumentSymbolsOld(DocumentSymbolParamsEx(params));
auto symbols = provideDocumentSymbolsOld(DocumentSymbolParamsEx(params, true));
foreach (symbol; symbols)
{
DocumentSymbolInfo sym;
Expand Down
6 changes: 6 additions & 0 deletions source/served/lsp/protoext.d
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ struct DocumentSymbolParamsEx
textDocument = params.textDocument;
}

this(DocumentSymbolParams params, bool verbose)
{
textDocument = params.textDocument;
this.verbose = verbose;
}

this(TextDocumentIdentifier textDocument, bool verbose)
{
this.textDocument = textDocument;
Expand Down
10 changes: 5 additions & 5 deletions test/data/list_definition/_basic.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ unittest
{
}

class X
private class X
{
this(int x) {}
this(this) {}
Expand All @@ -40,8 +40,8 @@ shared static this()

__EOF__
hello 6 f {"signature": "()", "access": "public", "return": "void"} 46 74
y 10 v {"access": "public"} 76 86
y 10 v {"access": "public", "detail": "int"} 76 86
bar 13 f {"signature": "()", "access": "public", "return": "int"} 88 101
X 26 c {"access": "public"} 144 215
this 28 f {"signature": "(int x)", "access": "public", "class": "X"} 155 169
~this 30 f {"access": "public", "class": "X"} 186 196
X 26 c {"access": "private", "detail": "class"} 152 223
this 28 f {"signature": "(int x)", "access": "public", "class": "X"} 163 177
~this 30 f {"access": "public", "class": "X"} 194 204
20 changes: 10 additions & 10 deletions test/data/list_definition/_verbose.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bar()
{
}

unittest
deprecated unittest
{
}

Expand Down Expand Up @@ -43,13 +43,13 @@ __EOF__
Foo 3 V {"access": "public"} 17 31
Bar 4 D {"access": "public"} 32 44
hello 6 f {"signature": "()", "access": "public", "return": "void"} 46 74
y 10 v {"access": "public"} 76 86
y 10 v {"access": "public", "detail": "int"} 76 86
bar 13 f {"signature": "()", "access": "public", "return": "int"} 88 101
__unittest_L17_C1 17 U {"access": "public"} 103 115
__unittest_L22_C1 22 U {"access": "public", "name": "named"} 130 142
X 26 c {"access": "public"} 144 215
this 28 f {"signature": "(int x)", "access": "public", "class": "X"} 155 169
this(this) 29 f {"access": "public", "class": "X"} 171 184
~this 30 f {"access": "public", "class": "X"} 186 196
__unittest_L32_C2 32 U {"access": "public", "class": "X"} 199 213
shared static this() 37 S {"access": "public"} 217 241
__unittest_L17_C12 17 U {"deprecation":"", "access": "public"} 114 126
__unittest_L22_C1 22 U {"access": "public", "detail": "named"} 141 153
X 26 c {"access": "public", "detail": "class"} 155 226
this 28 f {"signature": "(int x)", "access": "public", "class": "X"} 166 180
this(this) 29 f {"access": "public", "class": "X"} 182 195
~this 30 f {"access": "public", "class": "X"} 197 207
__unittest_L32_C2 32 U {"access": "public", "class": "X"} 210 224
shared static this() 37 S {"access": "public"} 228 252
4 changes: 2 additions & 2 deletions test/data/list_definition/static_ctors.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class Foo : Bar {
}
__EOF__
:verbose=true
Foo 1 c {"access":"public"} 7 111
Foo 1 c {"access":"public", "detail":"class"} 7 111
static this() 2 C {"access": "public", "class": "Foo"} 26 93
arr 8 v {"access":"public","class":"Foo"} 96 109
arr 8 v {"access":"public", "class":"Foo", "detail":"int[256]"} 96 109
Loading

0 comments on commit ac0b6c3

Please sign in to comment.