mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:19:49 +00:00
Add 'content' to FileResult.
Change-Id: I8600aed3beb712b4da9e4a157b2e87398057a9cd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346902 Reviewed-by: Phil Quitslund <pquitslund@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
bd989afb35
commit
5df56a153c
|
@ -131,6 +131,7 @@ class EditGetFixesHandler extends LegacyHandler
|
|||
var result = engine.ErrorsResultImpl(
|
||||
session: session,
|
||||
file: optionsFile,
|
||||
content: content,
|
||||
uri: optionsFile.toUri(),
|
||||
lineInfo: lineInfo,
|
||||
isAugmentation: false,
|
||||
|
@ -248,6 +249,7 @@ error.errorCode: ${error.errorCode}
|
|||
var result = engine.ErrorsResultImpl(
|
||||
session: session,
|
||||
file: pubspecFile,
|
||||
content: content,
|
||||
uri: pubspecFile.toUri(),
|
||||
lineInfo: lineInfo,
|
||||
isAugmentation: false,
|
||||
|
|
|
@ -133,6 +133,7 @@ abstract class AbstractCodeActionsProducer
|
|||
return engine.ErrorsResultImpl(
|
||||
session: session,
|
||||
file: file,
|
||||
content: file.readAsStringSync(),
|
||||
uri: server.uriConverter.toClientUri(path),
|
||||
lineInfo: lineInfo,
|
||||
isAugmentation: false,
|
||||
|
|
|
@ -84,6 +84,10 @@ abstract class ErrorsResult
|
|||
///
|
||||
/// Clients may not extend, implement or mix-in this class.
|
||||
abstract class FileResult implements SomeFileResult, AnalysisResult {
|
||||
/// The latest read content of [file], the same that was used to compute
|
||||
/// other properties of this result.
|
||||
String get content;
|
||||
|
||||
/// The file resource.
|
||||
File get file;
|
||||
|
||||
|
@ -210,9 +214,6 @@ abstract class ParsedLibraryResult
|
|||
/// Clients may not extend, implement or mix-in this class.
|
||||
abstract class ParsedUnitResult
|
||||
implements SomeParsedUnitResult, AnalysisResultWithErrors {
|
||||
/// The content of the file that was scanned and parsed.
|
||||
String get content;
|
||||
|
||||
/// The parsed, unresolved compilation unit for the [content].
|
||||
CompilationUnit get unit;
|
||||
}
|
||||
|
|
|
@ -1570,6 +1570,7 @@ class AnalysisDriver {
|
|||
return ErrorsResultImpl(
|
||||
session: currentSession,
|
||||
file: file.resource,
|
||||
content: file.content,
|
||||
lineInfo: file.lineInfo,
|
||||
uri: file.uri,
|
||||
isAugmentation: file.kind is AugmentationFileKind,
|
||||
|
@ -1622,7 +1623,6 @@ class AnalysisDriver {
|
|||
return ResolvedUnitResultImpl(
|
||||
session: currentSession,
|
||||
fileState: file,
|
||||
content: file.content,
|
||||
unit: unitResult.unit,
|
||||
errors: unitResult.errors,
|
||||
);
|
||||
|
@ -1835,6 +1835,7 @@ class AnalysisDriver {
|
|||
return ErrorsResultImpl(
|
||||
session: currentSession,
|
||||
file: file.resource,
|
||||
content: file.content,
|
||||
lineInfo: file.lineInfo,
|
||||
uri: file.uri,
|
||||
isAugmentation: file.kind is AugmentationFileKind,
|
||||
|
|
|
@ -69,9 +69,13 @@ class ErrorsResultImpl implements ErrorsResult {
|
|||
@override
|
||||
File file;
|
||||
|
||||
@override
|
||||
final String content;
|
||||
|
||||
ErrorsResultImpl({
|
||||
required this.session,
|
||||
required this.file,
|
||||
required this.content,
|
||||
required this.uri,
|
||||
required this.lineInfo,
|
||||
required this.isAugmentation,
|
||||
|
@ -88,6 +92,9 @@ class ErrorsResultImpl implements ErrorsResult {
|
|||
class FileResultImpl extends AnalysisResultImpl implements FileResult {
|
||||
final FileState fileState;
|
||||
|
||||
@override
|
||||
final String content;
|
||||
|
||||
@override
|
||||
final LineInfo lineInfo;
|
||||
|
||||
|
@ -103,7 +110,8 @@ class FileResultImpl extends AnalysisResultImpl implements FileResult {
|
|||
FileResultImpl({
|
||||
required super.session,
|
||||
required this.fileState,
|
||||
}) : lineInfo = fileState.lineInfo,
|
||||
}) : content = fileState.content,
|
||||
lineInfo = fileState.lineInfo,
|
||||
isAugmentation = fileState.kind is AugmentationFileKind,
|
||||
isLibrary = fileState.kind is LibraryFileKind,
|
||||
isPart = fileState.kind is PartFileKind;
|
||||
|
@ -172,9 +180,6 @@ class ParsedLibraryResultImpl extends AnalysisResultImpl
|
|||
}
|
||||
|
||||
class ParsedUnitResultImpl extends FileResultImpl implements ParsedUnitResult {
|
||||
@override
|
||||
final String content;
|
||||
|
||||
@override
|
||||
final CompilationUnit unit;
|
||||
|
||||
|
@ -186,7 +191,7 @@ class ParsedUnitResultImpl extends FileResultImpl implements ParsedUnitResult {
|
|||
required super.fileState,
|
||||
required this.unit,
|
||||
required this.errors,
|
||||
}) : content = fileState.content;
|
||||
});
|
||||
}
|
||||
|
||||
class ParseStringResultImpl implements ParseStringResult {
|
||||
|
@ -309,9 +314,6 @@ class ResolvedLibraryResultImpl extends AnalysisResultImpl
|
|||
|
||||
class ResolvedUnitResultImpl extends FileResultImpl
|
||||
implements ResolvedUnitResult {
|
||||
@override
|
||||
final String content;
|
||||
|
||||
@override
|
||||
final CompilationUnit unit;
|
||||
|
||||
|
@ -321,7 +323,6 @@ class ResolvedUnitResultImpl extends FileResultImpl
|
|||
ResolvedUnitResultImpl({
|
||||
required super.session,
|
||||
required super.fileState,
|
||||
required this.content,
|
||||
required this.unit,
|
||||
required this.errors,
|
||||
});
|
||||
|
|
|
@ -353,6 +353,7 @@ class FileResolver {
|
|||
return ErrorsResultImpl(
|
||||
session: contextObjects!.analysisSession,
|
||||
file: file.resource,
|
||||
content: file.content,
|
||||
uri: file.uri,
|
||||
lineInfo: file.lineInfo,
|
||||
isAugmentation: file.kind is AugmentationFileKind,
|
||||
|
@ -695,7 +696,6 @@ class FileResolver {
|
|||
return ResolvedUnitResultImpl(
|
||||
session: contextObjects!.analysisSession,
|
||||
fileState: file,
|
||||
content: file.content,
|
||||
unit: fileResult.unit,
|
||||
errors: fileResult.errors,
|
||||
);
|
||||
|
|
|
@ -1884,11 +1884,14 @@ void f(A a) {}
|
|||
}
|
||||
|
||||
test_getFileSync_library() async {
|
||||
final a = newFile('$testPackageLibPath/a.dart', '');
|
||||
var content = 'class A {}';
|
||||
final a = newFile('$testPackageLibPath/a.dart', content);
|
||||
final driver = driverFor(testFile);
|
||||
final result = driver.getFileSyncValid(a);
|
||||
expect(result.path, a.path);
|
||||
expect(result.uri.toString(), 'package:test/a.dart');
|
||||
expect(result.content, content);
|
||||
expect(result.isLibrary, isTrue);
|
||||
expect(result.isPart, isFalse);
|
||||
}
|
||||
|
||||
|
@ -1899,11 +1902,14 @@ void f(A a) {}
|
|||
}
|
||||
|
||||
test_getFileSync_part() async {
|
||||
final a = newFile('$testPackageLibPath/a.dart', 'part of lib;');
|
||||
var content = 'part of lib;';
|
||||
final a = newFile('$testPackageLibPath/a.dart', content);
|
||||
final driver = driverFor(testFile);
|
||||
final result = driver.getFileSyncValid(a);
|
||||
expect(result.path, a.path);
|
||||
expect(result.uri.toString(), 'package:test/a.dart');
|
||||
expect(result.content, content);
|
||||
expect(result.isLibrary, isFalse);
|
||||
expect(result.isPart, isTrue);
|
||||
}
|
||||
|
||||
|
|
|
@ -230,22 +230,28 @@ class AnalysisSessionImplTest extends PubPackageResolutionTest {
|
|||
}
|
||||
|
||||
test_getFile_library() async {
|
||||
var a = newFile('$testPackageLibPath/a.dart', '');
|
||||
var content = 'class A {}';
|
||||
var a = newFile('$testPackageLibPath/a.dart', content);
|
||||
|
||||
var session = contextFor(testFile).currentSession;
|
||||
var file = session.getFileValid(a);
|
||||
expect(file.path, a.path);
|
||||
expect(file.uri.toString(), 'package:test/a.dart');
|
||||
expect(file.content, content);
|
||||
expect(file.isLibrary, isTrue);
|
||||
expect(file.isPart, isFalse);
|
||||
}
|
||||
|
||||
test_getFile_part() async {
|
||||
var a = newFile('$testPackageLibPath/a.dart', 'part of lib;');
|
||||
var content = 'part of lib;';
|
||||
var a = newFile('$testPackageLibPath/a.dart', content);
|
||||
|
||||
var session = contextFor(testFile).currentSession;
|
||||
var file = session.getFileValid(a);
|
||||
expect(file.path, a.path);
|
||||
expect(file.uri.toString(), 'package:test/a.dart');
|
||||
expect(file.content, content);
|
||||
expect(file.isLibrary, isFalse);
|
||||
expect(file.isPart, isTrue);
|
||||
}
|
||||
|
||||
|
|
|
@ -262,6 +262,7 @@ class Driver implements CommandLineStarter {
|
|||
ErrorsResultImpl(
|
||||
session: analysisDriver.currentSession,
|
||||
file: file,
|
||||
content: content,
|
||||
uri: pathContext.toUri(path),
|
||||
lineInfo: lineInfo,
|
||||
isAugmentation: false,
|
||||
|
@ -306,6 +307,7 @@ class Driver implements CommandLineStarter {
|
|||
ErrorsResultImpl(
|
||||
session: analysisDriver.currentSession,
|
||||
file: file,
|
||||
content: content,
|
||||
uri: pathContext.toUri(path),
|
||||
lineInfo: lineInfo,
|
||||
isAugmentation: false,
|
||||
|
@ -333,6 +335,7 @@ class Driver implements CommandLineStarter {
|
|||
ErrorsResultImpl(
|
||||
session: analysisDriver.currentSession,
|
||||
file: file,
|
||||
content: content,
|
||||
uri: pathContext.toUri(path),
|
||||
lineInfo: lineInfo,
|
||||
isAugmentation: false,
|
||||
|
|
|
@ -115,6 +115,7 @@ ErrorsResultImpl mockResult(ErrorType type, ErrorSeverity severity) {
|
|||
return ErrorsResultImpl(
|
||||
session: _MockAnalysisSession(),
|
||||
file: file,
|
||||
content: '<mock>',
|
||||
uri: uri,
|
||||
lineInfo: lineInfo,
|
||||
isAugmentation: false,
|
||||
|
|
Loading…
Reference in a new issue