@@ -66,8 +66,7 @@ pub struct DiagnosticContext<'a> {
66
66
pub library : & ' a Library ,
67
67
68
68
/// The symbols exported by packages loaded via `library()` calls in this
69
- /// document. Currently global. TODO: Store individual exports in a BTreeMap
70
- /// sorted by position in the source?
69
+ /// document. Currently global.
71
70
pub library_symbols : BTreeMap < Point , HashSet < String > > ,
72
71
73
72
// Whether or not we're inside of a formula.
@@ -84,7 +83,7 @@ impl Default for DiagnosticsConfig {
84
83
}
85
84
86
85
impl < ' a > DiagnosticContext < ' a > {
87
- pub fn new ( contents : & ' a Rope , library : & ' a crate :: lsp :: inputs :: library :: Library ) -> Self {
86
+ pub fn new ( contents : & ' a Rope , library : & ' a Library ) -> Self {
88
87
Self {
89
88
contents,
90
89
document_symbols : Vec :: new ( ) ,
@@ -103,21 +102,20 @@ impl<'a> DiagnosticContext<'a> {
103
102
symbols. insert ( name. to_string ( ) , location) ;
104
103
}
105
104
106
- // First, check document symbols.
107
105
pub fn has_definition ( & self , name : & str , start_position : Point ) -> bool {
106
+ // Check document symbols
108
107
for symbols in & self . document_symbols {
109
108
if symbols. contains_key ( name) {
110
109
return true ;
111
110
}
112
111
}
113
112
114
- // Then, check workspace symbols.
113
+ // Check workspace symbols
115
114
if self . workspace_symbols . contains ( name) {
116
115
return true ;
117
116
}
118
117
119
- // Finally, check package symbols from `library()` calls.
120
- // Check all symbols exported by `library()` before the given position.
118
+ // Check all symbols exported by `library()` calls before the given position
121
119
for ( library_position, exports) in self . library_symbols . iter ( ) {
122
120
if * library_position > start_position {
123
121
break ;
@@ -127,7 +125,7 @@ impl<'a> DiagnosticContext<'a> {
127
125
}
128
126
}
129
127
130
- // Finally, check session symbols.
128
+ // Finally, check session symbols
131
129
self . session_symbols . contains ( name)
132
130
}
133
131
}
0 commit comments