[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:
Danny Tuppeny 2024-01-18 20:16:43 +00:00 committed by Commit Queue
parent 5a60ceeff8
commit 97ac9ace13

View file

@ -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));
});