(logger: Logger, sdks: DartSdks, private readonly dartCapabilities: DartCapabilities, wsContext: WorkspaceContext, private readonly analytics: Analytics)
| 47 | private readonly statusItem = getLanguageStatusItem("dart.analysisServer", ANALYSIS_FILTERS); |
| 48 | |
| 49 | constructor(logger: Logger, sdks: DartSdks, private readonly dartCapabilities: DartCapabilities, wsContext: WorkspaceContext, private readonly analytics: Analytics) { |
| 50 | super(new CategoryLogger(logger, LogCategory.Analyzer)); |
| 51 | |
| 52 | this.setupStatusItem(); |
| 53 | |
| 54 | this.client = this.createClient(this.logger, sdks, dartCapabilities, wsContext, this.buildMiddleware()); |
| 55 | this.disposables.push({ dispose: () => this.client.stop() }); |
| 56 | |
| 57 | |
| 58 | // Set up features that register capabilities and may also wrap client middleware. |
| 59 | this.disposables.push(this.refactors = new InteractiveRefactors(logger, this.client)); |
| 60 | this.disposables.push(this.snippetTextEdits = new SnippetTextEditFeature(this.client)); |
| 61 | this.disposables.push(this.fileTracker = new FileTracker(logger, this.client, wsContext)); |
| 62 | this.disposables.push(this.updateDiagnosticInformation = new AnalyzerUpdateDiagnosticInformationFeature(logger, this.client)); |
| 63 | |
| 64 | // Register all language client features. |
| 65 | this.client.registerFeature(new CommonCapabilitiesFeature().feature); |
| 66 | this.client.registerFeature(new AddDependencyCodeActionProvider(this.client).feature); |
| 67 | this.client.registerFeature(new LegacyRefactors(this.logger, this.client).feature); |
| 68 | this.client.registerFeature(this.refactors.feature); |
| 69 | this.client.registerFeature(this.snippetTextEdits.feature); |
| 70 | this.client.registerFeature(this.updateDiagnosticInformation.feature); |
| 71 | |
| 72 | void this.client.start().then(() => { |
| 73 | this.statusItem.text = "Dart Analysis Server"; |
| 74 | // Reminder: These onNotification calls only hold ONE handler! |
| 75 | this.client.onNotification(OpenUriNotification.type, (params) => { |
| 76 | const uri = vs.Uri.parse(params.uri); |
| 77 | switch (uri.scheme) { |
| 78 | case "file": |
| 79 | void vs.window.showTextDocument(uri); |
| 80 | break; |
| 81 | case "http": |
| 82 | case "https": |
| 83 | void envUtils.openInBrowser(uri.toString()); |
| 84 | break; |
| 85 | default: |
| 86 | this.logger.error(`Unable to open URI ${uri} as requested by LSP server. Unknown scheme.`); |
| 87 | |
| 88 | } |
| 89 | }); |
| 90 | this.onReadyCompleter.resolve(); |
| 91 | |
| 92 | void this.updateDiagnosticInformation?.updateDiagnosticInformationIfSupported(); |
| 93 | }); |
| 94 | } |
| 95 | |
| 96 | public async connectToDtd(dtd: DartToolingDaemon | undefined): Promise<void> { |
| 97 | if (!dtd) |
nothing calls this directly
no test coverage detected