@@ -21,7 +21,7 @@ use lsp_types::MarkupContent;
21
21
use lsp_types:: MarkupKind ;
22
22
use starlark:: collections:: SmallMap ;
23
23
use starlark:: docs:: markdown:: render_doc_item;
24
- use starlark:: docs:: DocItem ;
24
+ use starlark:: docs:: DocMember ;
25
25
use starlark:: syntax:: AstModule ;
26
26
use starlark_syntax:: syntax:: ast:: AstAssignIdent ;
27
27
use starlark_syntax:: syntax:: ast:: Stmt ;
@@ -38,7 +38,7 @@ impl From<Symbol> for CompletionItem {
38
38
let documentation = value. doc . map ( |doc| {
39
39
Documentation :: MarkupContent ( MarkupContent {
40
40
kind : MarkupKind :: Markdown ,
41
- value : render_doc_item ( & value. name , & doc) ,
41
+ value : render_doc_item ( & value. name , & doc. to_doc_item ( ) ) ,
42
42
} )
43
43
} ) ;
44
44
Self {
@@ -63,17 +63,16 @@ impl AstModuleExportedSymbols for AstModule {
63
63
let mut result: SmallMap < & str , _ > = SmallMap :: new ( ) ;
64
64
65
65
fn add < ' a > (
66
- me : & AstModule ,
67
66
result : & mut SmallMap < & ' a str , Symbol > ,
68
67
name : & ' a AstAssignIdent ,
69
68
kind : SymbolKind ,
70
- resolve_docs : impl FnOnce ( ) -> Option < DocItem > ,
69
+ resolve_docs : impl FnOnce ( ) -> Option < DocMember > ,
71
70
) {
72
71
if !name. ident . starts_with ( '_' ) {
73
72
result. entry ( & name. ident ) . or_insert ( Symbol {
74
73
name : name. ident . clone ( ) ,
75
74
detail : None ,
76
- span : name. span ,
75
+ span : Some ( name. span ) ,
77
76
kind,
78
77
doc : resolve_docs ( ) ,
79
78
param : None ,
@@ -87,25 +86,24 @@ impl AstModuleExportedSymbols for AstModule {
87
86
Stmt :: Assign ( assign) => {
88
87
assign. lhs . visit_lvalue ( |name| {
89
88
let kind = SymbolKind :: from_expr ( & assign. rhs ) ;
90
- add ( self , & mut result, name, kind, || {
89
+ add ( & mut result, name, kind, || {
91
90
last_node
92
91
. and_then ( |last| get_doc_item_for_assign ( last, & assign. lhs ) )
93
- . map ( DocItem :: Property )
92
+ . map ( DocMember :: Property )
94
93
} ) ;
95
94
} ) ;
96
95
}
97
96
Stmt :: AssignModify ( dest, _, _) => {
98
97
dest. visit_lvalue ( |name| {
99
- add ( self , & mut result, name, SymbolKind :: Variable , || {
98
+ add ( & mut result, name, SymbolKind :: Variable , || {
100
99
last_node
101
100
. and_then ( |last| get_doc_item_for_assign ( last, dest) )
102
- . map ( DocItem :: Property )
101
+ . map ( DocMember :: Property )
103
102
} ) ;
104
103
} ) ;
105
104
}
106
105
Stmt :: Def ( def) => {
107
106
add (
108
- self ,
109
107
& mut result,
110
108
& def. name ,
111
109
SymbolKind :: Method {
@@ -115,7 +113,7 @@ impl AstModuleExportedSymbols for AstModule {
115
113
. filter_map ( |param| param. split ( ) . 0 . map ( |name| name. to_string ( ) ) )
116
114
. collect ( ) ,
117
115
} ,
118
- || get_doc_item_for_def ( def) . map ( DocItem :: Function ) ,
116
+ || get_doc_item_for_def ( def) . map ( DocMember :: Function ) ,
119
117
) ;
120
118
}
121
119
_ => { }
@@ -150,7 +148,11 @@ d = 2
150
148
) ;
151
149
let res = modu. exported_symbols ( ) ;
152
150
assert_eq ! (
153
- res. map( |symbol| format!( "{} {}" , modu. file_span( symbol. span) , symbol. name) ) ,
151
+ res. map( |symbol| format!(
152
+ "{} {}" ,
153
+ modu. file_span( symbol. span. expect( "span should be set" ) ) ,
154
+ symbol. name
155
+ ) ) ,
154
156
& [ "X:3:5-6 b" , "X:4:1-2 d" ]
155
157
) ;
156
158
}
0 commit comments