|
1 | | -import magpiebridge.core.*; |
2 | | -import magpiebridge.file.SourceFileManager; |
3 | | -import org.eclipse.lsp4j.InitializeParams; |
4 | | -import org.eclipse.lsp4j.InitializeResult; |
5 | | -import org.eclipse.lsp4j.jsonrpc.messages.Either; |
6 | | - |
7 | | -import java.util.concurrent.CompletableFuture; |
8 | | - |
9 | | -public class GoblintMagpieServer extends MagpieServer { |
10 | | - |
11 | | - /** |
12 | | - * Future that is completed once the configuration of the server has completed i.e. all analyses have been added. |
13 | | - */ |
14 | | - private final CompletableFuture<Void> configurationDoneFuture = new CompletableFuture<>(); |
15 | | - |
16 | | - /** |
17 | | - * Instantiates a new MagpieServer using default {@link MagpieTextDocumentService} and {@link |
18 | | - * MagpieWorkspaceService} with given {@link ServerConfiguration}. |
19 | | - * |
20 | | - * @param config the config |
21 | | - */ |
22 | | - public GoblintMagpieServer(ServerConfiguration config) { |
23 | | - super(config); |
24 | | - } |
25 | | - |
26 | | - /** |
27 | | - * Marks this server instance as fully configured, which allows the initialize request to complete. |
28 | | - * The server will receive no communication other than the initialize request from the client before this is called. |
29 | | - */ |
30 | | - public void configurationDone() { |
31 | | - configurationDoneFuture.complete(null); |
32 | | - } |
33 | | - |
34 | | - @Override |
35 | | - public CompletableFuture<InitializeResult> initialize(InitializeParams params) { |
36 | | - return configurationDoneFuture.thenCompose(_r -> super.initialize(params)); |
37 | | - } |
38 | | - |
39 | | - @Override |
40 | | - protected void doSingleAnalysis(String language, Either<ServerAnalysis, ToolAnalysis> analysis, boolean rerun) { |
41 | | - SourceFileManager fileManager = getSourceFileManager(language); |
42 | | - Analysis<AnalysisConsumer> a = analysis.isLeft() ? analysis.getLeft() : analysis.getRight(); |
43 | | - if (a != null) { |
44 | | - a.analyze(fileManager.getSourceFileModules().values(), this, rerun); |
45 | | - } |
46 | | - } |
47 | | - |
48 | | -} |
| 1 | +package magpiebridge; |
| 2 | + |
| 3 | +import magpiebridge.core.*; |
| 4 | +import magpiebridge.file.SourceFileManager; |
| 5 | +import org.eclipse.lsp4j.InitializeParams; |
| 6 | +import org.eclipse.lsp4j.InitializeResult; |
| 7 | +import org.eclipse.lsp4j.jsonrpc.messages.Either; |
| 8 | + |
| 9 | +import java.util.concurrent.CompletableFuture; |
| 10 | + |
| 11 | +public class GoblintMagpieServer extends MagpieServer { |
| 12 | + |
| 13 | + /** |
| 14 | + * Future that is completed once the configuration of the server has completed i.e. all analyses have been added. |
| 15 | + */ |
| 16 | + private final CompletableFuture<Void> configurationDoneFuture = new CompletableFuture<>(); |
| 17 | + |
| 18 | + /** |
| 19 | + * Instantiates a new MagpieServer using default {@link MagpieTextDocumentService} and {@link |
| 20 | + * MagpieWorkspaceService} with given {@link ServerConfiguration}. |
| 21 | + * |
| 22 | + * @param config the config |
| 23 | + */ |
| 24 | + public GoblintMagpieServer(ServerConfiguration config) { |
| 25 | + super(config); |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Marks this server instance as fully configured, which allows the initialize request to complete. |
| 30 | + * The server will receive no communication other than the initialize request from the client before this is called. |
| 31 | + */ |
| 32 | + public void configurationDone() { |
| 33 | + configurationDoneFuture.complete(null); |
| 34 | + } |
| 35 | + |
| 36 | + @Override |
| 37 | + public CompletableFuture<InitializeResult> initialize(InitializeParams params) { |
| 38 | + return configurationDoneFuture.thenCompose(_r -> super.initialize(params)); |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + protected void doSingleAnalysis(String language, Either<ServerAnalysis, ToolAnalysis> analysis, boolean rerun) { |
| 43 | + SourceFileManager fileManager = getSourceFileManager(language); |
| 44 | + Analysis<AnalysisConsumer> a = analysis.isLeft() ? analysis.getLeft() : analysis.getRight(); |
| 45 | + if (a != null) { |
| 46 | + a.analyze(fileManager.getSourceFileModules().values(), this, rerun); |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments