mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:44:27 +00:00
[analysis_server] Use FileResult.content for LSP TextDocumentContentProvider
Change-Id: I09546804419bb5d78c3add4e1fa3d80a11526160 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347022 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
5a60ceeff8
commit
97ac9ace13
1 changed files with 3 additions and 5 deletions
|
@ -6,6 +6,7 @@ import 'package:analysis_server/lsp_protocol/protocol.dart';
|
|||
import 'package:analysis_server/src/lsp/constants.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
|
||||
import 'package:analysis_server/src/lsp/registration/feature_registration.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
|
||||
typedef StaticOptions = DartTextDocumentContentProviderRegistrationOptions?;
|
||||
|
||||
|
@ -38,11 +39,8 @@ class DartTextDocumentContentProviderHandler extends SharedMessageHandler<
|
|||
}
|
||||
|
||||
return pathOfUri(uri).mapResult((filePath) async {
|
||||
var result = await server.getResolvedUnit(filePath);
|
||||
var content = result?.content;
|
||||
// TODO(dantup): Switch to this once implemented to avoid resolved result.
|
||||
// var file = server.getAnalysisDriver(filePath)?.getFileSync(filePath);
|
||||
// var content = file is FileResult ? file.file.readAsStringSync() : null;
|
||||
var file = server.getAnalysisDriver(filePath)?.getFileSync(filePath);
|
||||
var content = file is FileResult ? file.content : null;
|
||||
|
||||
return success(DartTextDocumentContent(content: content));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue