33
33
import lombok .extern .slf4j .Slf4j ;
34
34
import org .apache .commons .io .FileUtils ;
35
35
import org .eclipse .lsp4j .TextDocumentItem ;
36
- import org .springframework .beans .factory .annotation . Lookup ;
36
+ import org .springframework .beans .factory .ObjectProvider ;
37
37
import org .springframework .stereotype .Component ;
38
38
39
39
import javax .annotation .CheckForNull ;
55
55
@ Slf4j
56
56
@ Component
57
57
@ RequiredArgsConstructor
58
- public abstract class ServerContext {
58
+ public class ServerContext {
59
+ private final ObjectProvider <DocumentContext > documentContextProvider ;
59
60
private final WorkDoneProgressHelper workDoneProgressHelper ;
60
61
private final Map <URI , DocumentContext > documents = Collections .synchronizedMap (new HashMap <>());
61
62
private final Lazy <Configuration > configurationMetadata = new Lazy <>(this ::computeConfigurationMetadata );
@@ -177,9 +178,6 @@ public Configuration getConfiguration() {
177
178
return configurationMetadata .getOrCompute ();
178
179
}
179
180
180
- @ Lookup
181
- protected abstract DocumentContext lookupDocumentContext (URI absoluteURI );
182
-
183
181
@ SneakyThrows
184
182
private DocumentContext createDocumentContext (File file ) {
185
183
String content = FileUtils .readFileToString (file , StandardCharsets .UTF_8 );
@@ -189,7 +187,7 @@ private DocumentContext createDocumentContext(File file) {
189
187
private DocumentContext createDocumentContext (URI uri , String content , int version ) {
190
188
URI absoluteURI = Absolute .uri (uri );
191
189
192
- var documentContext = lookupDocumentContext (absoluteURI );
190
+ var documentContext = documentContextProvider . getObject (absoluteURI );
193
191
documentContext .rebuild (content , version );
194
192
195
193
documents .put (absoluteURI , documentContext );
0 commit comments