mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Make ResolvedUnitResult.content/unit non-nullable.
Change-Id: Ia79567d248f2c91290bfdf8204ea7e9f3dc85fa4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206668 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
109ba28c6e
commit
79327c9f05
|
@ -736,74 +736,69 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
analysisServer.getExtensionCacheFor(result)?.cacheFromResult(result);
|
||||
|
||||
var unit = result.unit;
|
||||
if (unit != null) {
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.HIGHLIGHTS, path)) {
|
||||
_runDelayed(() {
|
||||
_notificationManager.recordHighlightRegions(
|
||||
NotificationManager.serverId,
|
||||
path,
|
||||
_computeHighlightRegions(unit));
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.NAVIGATION, path)) {
|
||||
_runDelayed(() {
|
||||
_notificationManager.recordNavigationParams(
|
||||
NotificationManager.serverId,
|
||||
path,
|
||||
_computeNavigationParams(path, unit));
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.OCCURRENCES, path)) {
|
||||
_runDelayed(() {
|
||||
_notificationManager.recordOccurrences(
|
||||
NotificationManager.serverId, path, _computeOccurrences(unit));
|
||||
});
|
||||
}
|
||||
// if (analysisServer._hasAnalysisServiceSubscription(
|
||||
// AnalysisService.OUTLINE, path)) {
|
||||
// _runDelayed(() {
|
||||
// // TODO(brianwilkerson) Change NotificationManager to store params
|
||||
// // so that fileKind and libraryName can be recorded / passed along.
|
||||
// notificationManager.recordOutlines(NotificationManager.serverId, path,
|
||||
// _computeOutlineParams(path, unit, result.lineInfo));
|
||||
// });
|
||||
// }
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.CLOSING_LABELS, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationClosingLabels(
|
||||
analysisServer, path, result.lineInfo, unit);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.FOLDING, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationFolding(
|
||||
analysisServer, path, result.lineInfo, unit);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.OUTLINE, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationOutline(analysisServer, result);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.OVERRIDES, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationOverrides(analysisServer, path, unit);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasFlutterServiceSubscription(
|
||||
FlutterService.OUTLINE, path)) {
|
||||
_runDelayed(() {
|
||||
sendFlutterNotificationOutline(analysisServer, result);
|
||||
});
|
||||
}
|
||||
// TODO(scheglov) Implement notifications for AnalysisService.IMPLEMENTED.
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.HIGHLIGHTS, path)) {
|
||||
_runDelayed(() {
|
||||
_notificationManager.recordHighlightRegions(
|
||||
NotificationManager.serverId, path, _computeHighlightRegions(unit));
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.NAVIGATION, path)) {
|
||||
_runDelayed(() {
|
||||
_notificationManager.recordNavigationParams(
|
||||
NotificationManager.serverId,
|
||||
path,
|
||||
_computeNavigationParams(path, unit));
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.OCCURRENCES, path)) {
|
||||
_runDelayed(() {
|
||||
_notificationManager.recordOccurrences(
|
||||
NotificationManager.serverId, path, _computeOccurrences(unit));
|
||||
});
|
||||
}
|
||||
// if (analysisServer._hasAnalysisServiceSubscription(
|
||||
// AnalysisService.OUTLINE, path)) {
|
||||
// _runDelayed(() {
|
||||
// // TODO(brianwilkerson) Change NotificationManager to store params
|
||||
// // so that fileKind and libraryName can be recorded / passed along.
|
||||
// notificationManager.recordOutlines(NotificationManager.serverId, path,
|
||||
// _computeOutlineParams(path, unit, result.lineInfo));
|
||||
// });
|
||||
// }
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.CLOSING_LABELS, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationClosingLabels(
|
||||
analysisServer, path, result.lineInfo, unit);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.FOLDING, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationFolding(
|
||||
analysisServer, path, result.lineInfo, unit);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.OUTLINE, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationOutline(analysisServer, result);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasAnalysisServiceSubscription(
|
||||
AnalysisService.OVERRIDES, path)) {
|
||||
_runDelayed(() {
|
||||
sendAnalysisNotificationOverrides(analysisServer, path, unit);
|
||||
});
|
||||
}
|
||||
if (analysisServer._hasFlutterServiceSubscription(
|
||||
FlutterService.OUTLINE, path)) {
|
||||
_runDelayed(() {
|
||||
sendFlutterNotificationOutline(analysisServer, result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,17 +17,9 @@ class DartUnitOutlineComputer {
|
|||
|
||||
DartUnitOutlineComputer(this.resolvedUnit, {this.withBasicFlutter = false});
|
||||
|
||||
CompilationUnit get _unit {
|
||||
var unit = resolvedUnit.unit;
|
||||
if (unit == null) {
|
||||
throw StateError('DartUnitOutlineComputer created with invalid result');
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
/// Returns the computed outline, not `null`.
|
||||
Outline compute() {
|
||||
var unit = _unit;
|
||||
var unit = resolvedUnit.unit;
|
||||
var unitContents = <Outline>[];
|
||||
for (var unitMember in unit.declarations) {
|
||||
if (unitMember is ClassDeclaration) {
|
||||
|
@ -325,7 +317,7 @@ class DartUnitOutlineComputer {
|
|||
}
|
||||
|
||||
Outline _newUnitOutline(List<Outline> unitContents) {
|
||||
var unit = _unit;
|
||||
var unit = resolvedUnit.unit;
|
||||
var element = Element(
|
||||
ElementKind.COMPILATION_UNIT, '<unit>', Element.makeFlags(),
|
||||
location: _getLocationNode(unit));
|
||||
|
|
|
@ -32,11 +32,6 @@ class ImportElementsComputer {
|
|||
Future<SourceChange> createEdits(
|
||||
List<ImportedElements> importedElementsList) async {
|
||||
var unit = libraryResult.unit;
|
||||
if (unit == null) {
|
||||
// We should never reach this point because the libraryResult should be
|
||||
// valid.
|
||||
return SourceChange('');
|
||||
}
|
||||
var filteredImportedElements =
|
||||
_filterImportedElements(importedElementsList);
|
||||
var libraryElement = libraryResult.libraryElement;
|
||||
|
@ -279,11 +274,6 @@ class ImportElementsComputer {
|
|||
/// Partially copied from DartFileEditBuilderImpl.
|
||||
_InsertionDescription _getInsertionDescription(String importUri) {
|
||||
var unit = libraryResult.unit;
|
||||
if (unit == null) {
|
||||
// We should never reach this point because the libraryResult should be
|
||||
// valid.
|
||||
return _InsertionDescription(0, after: 2);
|
||||
}
|
||||
LibraryDirective? libraryDirective;
|
||||
var importDirectives = <ImportDirective>[];
|
||||
var otherDirectives = <Directive>[];
|
||||
|
|
|
@ -63,7 +63,7 @@ class AnalysisDomainHandler extends AbstractRequestHandler {
|
|||
server.sendResponse(Response.fileNotAnalyzed(request, file));
|
||||
return;
|
||||
}
|
||||
var unit = result.unit!;
|
||||
var unit = result.unit;
|
||||
|
||||
// Prepare the hovers.
|
||||
var hovers = <HoverInformation>[];
|
||||
|
@ -105,7 +105,7 @@ class AnalysisDomainHandler extends AbstractRequestHandler {
|
|||
elements = <ImportedElements>[];
|
||||
} else {
|
||||
elements =
|
||||
ImportedElementsComputer(result.unit!, params.offset, params.length)
|
||||
ImportedElementsComputer(result.unit, params.offset, params.length)
|
||||
.compute();
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ class AnalysisDomainHandler extends AbstractRequestHandler {
|
|||
var allResults = <AnalysisNavigationParams>[];
|
||||
var result = await server.getResolvedUnit(file);
|
||||
if (result != null && result.state == ResultState.VALID) {
|
||||
var unit = result.unit!;
|
||||
var unit = result.unit;
|
||||
var collector = NavigationCollectorImpl();
|
||||
computeDartNavigation(
|
||||
server.resourceProvider, collector, unit, offset, length);
|
||||
|
@ -237,7 +237,7 @@ class AnalysisDomainHandler extends AbstractRequestHandler {
|
|||
}
|
||||
|
||||
// Ensure the offset provided is a valid location in the file.
|
||||
final unit = result.unit!;
|
||||
final unit = result.unit;
|
||||
final computer = DartUnitSignatureComputer(
|
||||
server.getDartdocDirectiveInfoFor(result), unit, params.offset);
|
||||
if (!computer.offsetIsValid) {
|
||||
|
|
|
@ -330,7 +330,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
|
|||
}
|
||||
server.requestStatistics?.addItemTimeNow(request, 'resolvedUnit');
|
||||
if (resolvedUnit.state == ResultState.VALID) {
|
||||
if (offset < 0 || offset > resolvedUnit.content!.length) {
|
||||
if (offset < 0 || offset > resolvedUnit.content.length) {
|
||||
server.sendResponse(Response.invalidParameter(
|
||||
request,
|
||||
'params.offset',
|
||||
|
@ -339,7 +339,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
recordRequest(performance, file, resolvedUnit.content!, offset);
|
||||
recordRequest(performance, file, resolvedUnit.content, offset);
|
||||
}
|
||||
var declarationsTracker = server.declarationsTracker;
|
||||
if (declarationsTracker == null) {
|
||||
|
|
|
@ -47,8 +47,8 @@ class KytheDomainHandler extends AbstractRequestHandler {
|
|||
var entries = <KytheEntry>[];
|
||||
// TODO(brianwilkerson) Figure out how to get the list of files.
|
||||
var files = <String>[];
|
||||
result.unit!.accept(KytheDartVisitor(server.resourceProvider, entries,
|
||||
file, InheritanceManager3(), result.content!));
|
||||
result.unit.accept(KytheDartVisitor(server.resourceProvider, entries,
|
||||
file, InheritanceManager3(), result.content));
|
||||
allResults.add(KytheGetKytheEntriesResult(entries, files));
|
||||
}
|
||||
//
|
||||
|
|
|
@ -53,7 +53,7 @@ class RuntimeCompletionComputer {
|
|||
|
||||
// Compute the patched context file content.
|
||||
var targetCode = SourceEdit.applySequence(
|
||||
contextResult.content!,
|
||||
contextResult.content,
|
||||
changeBuilder.sourceChange.edits[0].edits,
|
||||
);
|
||||
|
||||
|
|
|
@ -401,7 +401,7 @@ class EditDomainHandler extends AbstractRequestHandler {
|
|||
return;
|
||||
}
|
||||
var libraryUnit = result.libraryElement.definingCompilationUnit;
|
||||
if (libraryUnit != result.unit!.declaredElement) {
|
||||
if (libraryUnit != result.unit.declaredElement) {
|
||||
// The file in the request is a part of a library. We need to pass the
|
||||
// defining compilation unit to the computer, not the part.
|
||||
result = await server.getResolvedUnit(libraryUnit.source.fullName);
|
||||
|
@ -483,8 +483,8 @@ class EditDomainHandler extends AbstractRequestHandler {
|
|||
return;
|
||||
}
|
||||
var fileStamp = -1;
|
||||
var code = result.content!;
|
||||
var unit = result.unit!;
|
||||
var code = result.content;
|
||||
var unit = result.unit;
|
||||
var errors = result.errors;
|
||||
// check if there are scan/parse errors in the file
|
||||
var numScanParseErrors = _getNumberOfScanParseErrors(errors);
|
||||
|
@ -627,7 +627,7 @@ error: $error
|
|||
error.errorCode: ${error.errorCode}
|
||||
''';
|
||||
throw CaughtExceptionWithFiles(exception, stackTrace, {
|
||||
file: result.content!,
|
||||
file: result.content,
|
||||
'parameters': parametersFile,
|
||||
});
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ offset: $offset
|
|||
length: $length
|
||||
''';
|
||||
throw CaughtExceptionWithFiles(exception, stackTrace, {
|
||||
file: result.content!,
|
||||
file: result.content,
|
||||
'parameters': parametersFile,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class FlutterOutlineComputer {
|
|||
|
||||
// Create outlines for widgets.
|
||||
var visitor = _FlutterOutlineBuilder(this);
|
||||
resolvedUnit.unit!.accept(visitor);
|
||||
resolvedUnit.unit.accept(visitor);
|
||||
|
||||
// Associate Flutter outlines with Dart outlines.
|
||||
for (var outline in visitor.outlines) {
|
||||
|
@ -66,7 +66,7 @@ class FlutterOutlineComputer {
|
|||
|
||||
var name = parameter.displayName;
|
||||
|
||||
var label = resolvedUnit.content!.substring(argument.offset, argument.end);
|
||||
var label = resolvedUnit.content.substring(argument.offset, argument.end);
|
||||
if (label.contains('\n')) {
|
||||
label = '…';
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ class OrganizeImportsCommandHandler extends SimpleEditCommandHandler {
|
|||
}
|
||||
|
||||
return result.mapResult((result) {
|
||||
final code = result.content!;
|
||||
final unit = result.unit!;
|
||||
final code = result.content;
|
||||
final unit = result.unit;
|
||||
|
||||
if (hasScanParseErrors(result.errors)) {
|
||||
// It's not uncommon for editors to run this command automatically on-save
|
||||
|
|
|
@ -205,7 +205,7 @@ class CompletionHandler
|
|||
) async {
|
||||
final performance = CompletionPerformance();
|
||||
performance.path = unit.path;
|
||||
performance.setContentsAndOffset(unit.content!, offset);
|
||||
performance.setContentsAndOffset(unit.content, offset);
|
||||
server.performanceStats.completion.add(performance);
|
||||
|
||||
return await performance.runRequestOperation((perf) async {
|
||||
|
|
|
@ -34,7 +34,7 @@ class DocumentHighlightsHandler extends MessageHandler<
|
|||
|
||||
return offset.mapResult((requestedOffset) {
|
||||
final collector = OccurrencesCollectorImpl();
|
||||
addDartOccurrences(collector, unit.result.unit!);
|
||||
addDartOccurrences(collector, unit.result.unit);
|
||||
|
||||
// Find an occurrence that has an instance that spans the position.
|
||||
for (final occurrence in collector.allOccurrences) {
|
||||
|
|
|
@ -83,10 +83,6 @@ class HoverHandler extends MessageHandler<TextDocumentPositionParams, Hover?> {
|
|||
|
||||
ErrorOr<Hover?> _getHover(ResolvedUnitResult unit, int offset) {
|
||||
final compilationUnit = unit.unit;
|
||||
if (compilationUnit == null) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
final computer = DartUnitHoverComputer(
|
||||
server.getDartdocDirectiveInfoFor(unit), compilationUnit, offset);
|
||||
final hover = computer.compute();
|
||||
|
|
|
@ -83,7 +83,7 @@ class ReferencesHandler
|
|||
convert(results, toLocation).whereNotNull().toList();
|
||||
|
||||
final compilationUnit = unit.unit;
|
||||
if (compilationUnit != null && params.context.includeDeclaration == true) {
|
||||
if (params.context.includeDeclaration == true) {
|
||||
// Also include the definition for the symbol at this location.
|
||||
referenceResults.addAll(_getDeclarations(compilationUnit, offset));
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class SignatureHelpHandler
|
|||
// signature help for that.
|
||||
final typeArgsSignature = _tryGetTypeArgsSignatureHelp(
|
||||
dartDocInfo,
|
||||
unit.result.unit!,
|
||||
unit.result.unit,
|
||||
offset,
|
||||
autoTriggered,
|
||||
formats,
|
||||
|
@ -72,7 +72,7 @@ class SignatureHelpHandler
|
|||
}
|
||||
|
||||
final computer =
|
||||
DartUnitSignatureComputer(dartDocInfo, unit.result.unit!, offset);
|
||||
DartUnitSignatureComputer(dartDocInfo, unit.result.unit, offset);
|
||||
if (!computer.offsetIsValid) {
|
||||
return success(null); // No error, just no valid hover.
|
||||
}
|
||||
|
|
|
@ -864,28 +864,26 @@ class LspServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
analysisServer.getExtensionCacheFor(result)?.cacheFromResult(result);
|
||||
|
||||
final unit = result.unit;
|
||||
if (unit != null) {
|
||||
if (analysisServer.shouldSendClosingLabelsFor(path)) {
|
||||
final labels = DartUnitClosingLabelsComputer(result.lineInfo, unit)
|
||||
.compute()
|
||||
.map((l) => toClosingLabel(result.lineInfo, l))
|
||||
.toList();
|
||||
if (analysisServer.shouldSendClosingLabelsFor(path)) {
|
||||
final labels = DartUnitClosingLabelsComputer(result.lineInfo, unit)
|
||||
.compute()
|
||||
.map((l) => toClosingLabel(result.lineInfo, l))
|
||||
.toList();
|
||||
|
||||
analysisServer.publishClosingLabels(path, labels);
|
||||
}
|
||||
if (analysisServer.shouldSendOutlineFor(path)) {
|
||||
final outline = DartUnitOutlineComputer(
|
||||
result,
|
||||
withBasicFlutter: true,
|
||||
).compute();
|
||||
final lspOutline = toOutline(result.lineInfo, outline);
|
||||
analysisServer.publishOutline(path, lspOutline);
|
||||
}
|
||||
if (analysisServer.shouldSendFlutterOutlineFor(path)) {
|
||||
final outline = FlutterOutlineComputer(result).compute();
|
||||
final lspOutline = toFlutterOutline(result.lineInfo, outline);
|
||||
analysisServer.publishFlutterOutline(path, lspOutline);
|
||||
}
|
||||
analysisServer.publishClosingLabels(path, labels);
|
||||
}
|
||||
if (analysisServer.shouldSendOutlineFor(path)) {
|
||||
final outline = DartUnitOutlineComputer(
|
||||
result,
|
||||
withBasicFlutter: true,
|
||||
).compute();
|
||||
final lspOutline = toOutline(result.lineInfo, outline);
|
||||
analysisServer.publishOutline(path, lspOutline);
|
||||
}
|
||||
if (analysisServer.shouldSendFlutterOutlineFor(path)) {
|
||||
final outline = FlutterOutlineComputer(result).compute();
|
||||
final lspOutline = toFlutterOutline(result.lineInfo, outline);
|
||||
analysisServer.publishFlutterOutline(path, lspOutline);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void sendAnalysisNotificationOutline(
|
|||
AnalysisServer server, ResolvedUnitResult resolvedUnit) {
|
||||
_sendNotification(server, () {
|
||||
protocol.FileKind fileKind;
|
||||
var unit = resolvedUnit.unit!;
|
||||
var unit = resolvedUnit.unit;
|
||||
if (unit.directives.any((d) => d is PartOfDirective)) {
|
||||
fileKind = protocol.FileKind.PART;
|
||||
} else {
|
||||
|
|
|
@ -44,7 +44,7 @@ class CompletionRequestImpl implements CompletionRequest {
|
|||
ResourceProvider get resourceProvider => result.session.resourceProvider;
|
||||
|
||||
@override
|
||||
Source get source => result.unit!.declaredElement!.source;
|
||||
Source get source => result.unit.declaredElement!.source;
|
||||
|
||||
@override
|
||||
String? get sourceContents => result.content;
|
||||
|
|
|
@ -458,7 +458,7 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
|
|||
return performance.run(
|
||||
'build DartCompletionRequest',
|
||||
(_) {
|
||||
var unit = request.result.unit!;
|
||||
var unit = request.result.unit;
|
||||
var libSource = unit.declaredElement!.library.source;
|
||||
var objectType = request.result.typeProvider.objectType;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class DocumentationCache {
|
|||
|
||||
/// Fill the cache with data from the [result].
|
||||
void cacheFromResult(ResolvedUnitResult result) {
|
||||
var compilationUnit = result.unit?.declaredElement;
|
||||
var compilationUnit = result.unit.declaredElement;
|
||||
if (compilationUnit != null) {
|
||||
documentationCache.remove(_keyForUnit(compilationUnit));
|
||||
_cacheFromElement(compilationUnit);
|
||||
|
|
|
@ -21,7 +21,7 @@ class ExtensionCache {
|
|||
|
||||
/// Fill the cache with data from the [result].
|
||||
void cacheFromResult(ResolvedUnitResult result) {
|
||||
var element = result.unit?.declaredElement;
|
||||
var element = result.unit.declaredElement;
|
||||
if (element != null) {
|
||||
_cacheFromElement(element);
|
||||
for (var library in result.libraryElement.importedLibraries) {
|
||||
|
|
|
@ -158,7 +158,7 @@ class LocalLibraryContributor extends DartCompletionContributor {
|
|||
return;
|
||||
}
|
||||
|
||||
var libraryUnits = request.result.unit?.declaredElement?.library.units;
|
||||
var libraryUnits = request.result.unit.declaredElement?.library.units;
|
||||
if (libraryUnits == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ DefaultArgument? getDefaultStringParameterValue(ParameterElement parameter,
|
|||
}
|
||||
|
||||
String getRequestLineIndent(DartCompletionRequest request) {
|
||||
var content = request.result.content!;
|
||||
var content = request.result.content;
|
||||
var lineStartOffset = request.offset;
|
||||
var notWhitespaceOffset = request.offset;
|
||||
for (; lineStartOffset > 0; lineStartOffset--) {
|
||||
|
|
|
@ -128,7 +128,7 @@ class StatementCompletionProcessor {
|
|||
|
||||
Source get source => unitElement.source;
|
||||
|
||||
CompilationUnit get unit => statementContext.resolveResult.unit!;
|
||||
CompilationUnit get unit => statementContext.resolveResult.unit;
|
||||
|
||||
CompilationUnitElement get unitElement => unit.declaredElement!;
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ class CorrectionProducerContext {
|
|||
sessionHelper = AnalysisSessionHelper(resolvedResult.session),
|
||||
typeProvider = resolvedResult.typeProvider,
|
||||
selectionEnd = selectionOffset + selectionLength,
|
||||
unit = resolvedResult.unit!,
|
||||
unit = resolvedResult.unit,
|
||||
utils = CorrectionUtils(resolvedResult);
|
||||
|
||||
/// Return `true` if the lint with the given [name] is enabled.
|
||||
|
|
|
@ -39,7 +39,7 @@ class FlutterWrap extends MultiCorrectionProducer {
|
|||
Iterable<CorrectionProducer> _wrapMultipleWidgets() sync* {
|
||||
var selectionRange = SourceRange(selectionOffset, selectionLength);
|
||||
var analyzer = SelectionAnalyzer(selectionRange);
|
||||
resolvedResult.unit!.accept(analyzer);
|
||||
resolvedResult.unit.accept(analyzer);
|
||||
|
||||
var widgetExpressions = <Expression>[];
|
||||
if (analyzer.hasSelectedNodes) {
|
||||
|
|
|
@ -25,7 +25,7 @@ class OrganizeImports extends CorrectionProducer {
|
|||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var organizer =
|
||||
ImportOrganizer(resolvedResult.content!, unit, resolvedResult.errors);
|
||||
ImportOrganizer(resolvedResult.content, unit, resolvedResult.errors);
|
||||
// todo (pq): consider restructuring organizer to allow a passed-in change
|
||||
// builder
|
||||
for (var edit in organizer.organize()) {
|
||||
|
|
|
@ -52,7 +52,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
|
||||
/// Analyze the selection, compute [status] and nodes.
|
||||
void analyze() {
|
||||
resolveResult.unit!.accept(this);
|
||||
resolveResult.unit.accept(this);
|
||||
}
|
||||
|
||||
/// Records fatal error with given message and [Location].
|
||||
|
@ -73,7 +73,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
{
|
||||
var selectionStart = selection.offset;
|
||||
var selectionEnd = selection.end;
|
||||
var commentRanges = getCommentRanges(resolveResult.unit!);
|
||||
var commentRanges = getCommentRanges(resolveResult.unit);
|
||||
for (var commentRange in commentRanges) {
|
||||
if (commentRange.contains(selectionStart)) {
|
||||
invalidSelection('Selection begins inside a comment.');
|
||||
|
@ -208,9 +208,9 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
|
||||
/// Returns `true` if there are [Token]s in the given [SourceRange].
|
||||
bool _hasTokens(SourceRange range) {
|
||||
var fullText = resolveResult.content!;
|
||||
var fullText = resolveResult.content;
|
||||
var rangeText = fullText.substring(range.offset, range.end);
|
||||
return _getTokens(rangeText, resolveResult.unit!.featureSet).isNotEmpty;
|
||||
return _getTokens(rangeText, resolveResult.unit.featureSet).isNotEmpty;
|
||||
}
|
||||
|
||||
/// Returns `true` if [nodes] contains [node].
|
||||
|
|
|
@ -537,9 +537,9 @@ class CorrectionUtils {
|
|||
String? _endOfLine;
|
||||
|
||||
CorrectionUtils(ResolvedUnitResult result)
|
||||
: unit = result.unit!,
|
||||
: unit = result.unit,
|
||||
_library = result.libraryElement,
|
||||
_buffer = result.content!;
|
||||
_buffer = result.content;
|
||||
|
||||
/// Returns the EOL to use for this [CompilationUnit].
|
||||
String get endOfLine {
|
||||
|
|
|
@ -659,7 +659,7 @@ class _EdgeInsetsProperty {
|
|||
|
||||
String? _expressionCode(Expression? expression) {
|
||||
if (expression != null) {
|
||||
var content = property.resolvedUnit.content!;
|
||||
var content = property.resolvedUnit.content;
|
||||
return content.substring(expression.offset, expression.end);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -336,7 +336,7 @@ class _WidgetDescriptionComputer {
|
|||
|
||||
String? valueExpressionCode;
|
||||
if (valueExpression != null) {
|
||||
valueExpressionCode = resolvedUnit.content!.substring(
|
||||
valueExpressionCode = resolvedUnit.content.substring(
|
||||
valueExpression.offset,
|
||||
valueExpression.end,
|
||||
);
|
||||
|
|
|
@ -66,7 +66,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
|||
@override
|
||||
String get refactoringName => 'Extract Local Variable';
|
||||
|
||||
CompilationUnit get unit => resolveResult.unit!;
|
||||
CompilationUnit get unit => resolveResult.unit;
|
||||
|
||||
CompilationUnitElement get unitElement => unit.declaredElement!;
|
||||
|
||||
|
@ -231,7 +231,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
|||
return RefactoringStatus.fatal(
|
||||
'The selection offset must be greater than zero.');
|
||||
}
|
||||
if (selectionOffset + selectionLength >= resolveResult.content!.length) {
|
||||
if (selectionOffset + selectionLength >= resolveResult.content.length) {
|
||||
return RefactoringStatus.fatal(
|
||||
'The selection end offset must be less then the length of the file.');
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
|||
// add replace edit
|
||||
var edit = newSourceEdit_range(range, invocationSource);
|
||||
doSourceChange_addElementEdit(
|
||||
change, resolveResult.unit!.declaredElement!, edit);
|
||||
change, resolveResult.unit.declaredElement!, edit);
|
||||
}
|
||||
// add method declaration
|
||||
{
|
||||
|
@ -378,7 +378,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
|||
var offset = _parentMember!.end;
|
||||
var edit = SourceEdit(offset, 0, '$eol$eol$prefix$declarationSource');
|
||||
doSourceChange_addElementEdit(
|
||||
change, resolveResult.unit!.declaredElement!, edit);
|
||||
change, resolveResult.unit.declaredElement!, edit);
|
||||
}
|
||||
}
|
||||
// done
|
||||
|
@ -450,7 +450,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
|||
return RefactoringStatus.fatal(
|
||||
'The selection offset must be greater than zero.');
|
||||
}
|
||||
if (selectionOffset + selectionLength >= resolveResult.content!.length) {
|
||||
if (selectionOffset + selectionLength >= resolveResult.content.length) {
|
||||
return RefactoringStatus.fatal(
|
||||
'The selection end offset must be less then the length of the file.');
|
||||
}
|
||||
|
@ -658,12 +658,11 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
|||
var originalSource = utils.getText(range.offset, range.length);
|
||||
var pattern = _SourcePattern();
|
||||
var replaceEdits = <SourceEdit>[];
|
||||
resolveResult.unit!
|
||||
.accept(_GetSourcePatternVisitor(range, pattern, replaceEdits));
|
||||
resolveResult.unit.accept(_GetSourcePatternVisitor(range, pattern, replaceEdits));
|
||||
replaceEdits = replaceEdits.reversed.toList();
|
||||
var source = SourceEdit.applySequence(originalSource, replaceEdits);
|
||||
pattern.normalizedSource =
|
||||
_getNormalizedSource(source, resolveResult.unit!.featureSet);
|
||||
_getNormalizedSource(source, resolveResult.unit.featureSet);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
|
@ -706,7 +705,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
|||
var result = RefactoringStatus();
|
||||
var assignedUsedVariables = <VariableElement>[];
|
||||
|
||||
var unit = resolveResult.unit!;
|
||||
var unit = resolveResult.unit;
|
||||
_visibleRangeMap = VisibleRangesComputer.forNode(unit);
|
||||
unit.accept(
|
||||
_InitializeParametersVisitor(this, assignedUsedVariables),
|
||||
|
|
|
@ -85,7 +85,7 @@ class ExtractWidgetRefactoringImpl extends RefactoringImpl
|
|||
}
|
||||
|
||||
FeatureSet get _featureSet {
|
||||
return resolveResult.unit!.featureSet;
|
||||
return resolveResult.unit.featureSet;
|
||||
}
|
||||
|
||||
Flutter get _flutter => Flutter.instance;
|
||||
|
|
|
@ -114,7 +114,7 @@ class InlineLocalRefactoringImpl extends RefactoringImpl
|
|||
@override
|
||||
Future<SourceChange> createChange() {
|
||||
var change = SourceChange(refactoringName);
|
||||
var unitElement = resolveResult.unit!.declaredElement!;
|
||||
var unitElement = resolveResult.unit.declaredElement!;
|
||||
var state = _initialState!;
|
||||
// remove declaration
|
||||
{
|
||||
|
|
|
@ -363,7 +363,7 @@ class InlineMethodRefactoringImpl extends RefactoringImpl
|
|||
_methodNode = methodNode;
|
||||
|
||||
var resolvedUnit = declaration.resolvedUnit!;
|
||||
_methodUnit = resolvedUnit.unit!;
|
||||
_methodUnit = resolvedUnit.unit;
|
||||
_methodUtils = CorrectionUtils(resolvedUnit);
|
||||
|
||||
if (methodNode is MethodDeclaration) {
|
||||
|
|
|
@ -71,7 +71,7 @@ class MoveFileRefactoringImpl extends RefactoringImpl
|
|||
@override
|
||||
Future<SourceChange> createChange() async {
|
||||
var changeBuilder = ChangeBuilder(session: resolvedUnit.session);
|
||||
var element = resolvedUnit.unit!.declaredElement;
|
||||
var element = resolvedUnit.unit.declaredElement;
|
||||
if (element == null) {
|
||||
return changeBuilder.sourceChange;
|
||||
}
|
||||
|
@ -92,14 +92,14 @@ class MoveFileRefactoringImpl extends RefactoringImpl
|
|||
var definingUnitResult = libraryResult.units.first;
|
||||
for (var result in libraryResult.units) {
|
||||
if (result.isPart) {
|
||||
var partOfs = result.unit!.directives
|
||||
var partOfs = result.unit.directives
|
||||
.whereType<PartOfDirective>()
|
||||
.map((e) => e.uri)
|
||||
.whereNotNull()
|
||||
.where((uri) => _isRelativeUri(uri.stringValue));
|
||||
if (partOfs.isNotEmpty) {
|
||||
await changeBuilder.addDartFileEdit(
|
||||
result.unit!.declaredElement!.source.fullName, (builder) {
|
||||
result.unit.declaredElement!.source.fullName, (builder) {
|
||||
partOfs.forEach((uri) {
|
||||
var newLocation =
|
||||
pathContext.join(newDir, pathos.basename(newFile));
|
||||
|
@ -114,7 +114,7 @@ class MoveFileRefactoringImpl extends RefactoringImpl
|
|||
|
||||
if (newDir != oldDir) {
|
||||
await changeBuilder.addDartFileEdit(definingUnitResult.path, (builder) {
|
||||
for (var directive in definingUnitResult.unit!.directives) {
|
||||
for (var directive in definingUnitResult.unit.directives) {
|
||||
if (directive is UriBasedDirective) {
|
||||
_updateUriReference(builder, directive, oldDir, newDir);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class MoveFileRefactoringImpl extends RefactoringImpl
|
|||
}
|
||||
} else if (newDir != oldDir) {
|
||||
// Otherwise, we need to update any relative part-of references.
|
||||
var partOfs = resolvedUnit.unit!.directives
|
||||
var partOfs = resolvedUnit.unit.directives
|
||||
.whereType<PartOfDirective>()
|
||||
.map((e) => e.uri)
|
||||
.whereNotNull()
|
||||
|
|
|
@ -334,9 +334,6 @@ class _RenameClassMemberValidator extends _BaseClassMemberValidator {
|
|||
}
|
||||
|
||||
var unit = result.unit;
|
||||
if (unit == null) {
|
||||
return const [];
|
||||
}
|
||||
|
||||
var collector = _LocalElementsCollector(name);
|
||||
unit.accept(collector);
|
||||
|
|
|
@ -165,9 +165,6 @@ class _ExtensionMemberValidator {
|
|||
}
|
||||
|
||||
var unit = result.unit;
|
||||
if (unit == null) {
|
||||
return const [];
|
||||
}
|
||||
|
||||
var collector = _LocalElementsCollector(name);
|
||||
unit.accept(collector);
|
||||
|
|
|
@ -246,7 +246,7 @@ class AstPage extends DiagnosticPageWithNav {
|
|||
var result = await driver.getResult2(filePath);
|
||||
if (result is ResolvedUnitResult) {
|
||||
var writer = AstWriter(buf);
|
||||
result.unit!.accept(writer);
|
||||
result.unit.accept(writer);
|
||||
} else {
|
||||
p(
|
||||
'An AST could not be produced for the file '
|
||||
|
@ -836,7 +836,7 @@ class ElementModelPage extends DiagnosticPageWithNav {
|
|||
var result = await driver.getResult2(filePath);
|
||||
CompilationUnitElement? compilationUnitElement;
|
||||
if (result is ResolvedUnitResult) {
|
||||
compilationUnitElement = result.unit?.declaredElement;
|
||||
compilationUnitElement = result.unit.declaredElement;
|
||||
}
|
||||
if (compilationUnitElement != null) {
|
||||
var writer = ElementWriter(buf);
|
||||
|
|
|
@ -72,8 +72,8 @@ class AbstractSingleUnitTest extends AbstractContextTest {
|
|||
Future<void> resolveTestFile() async {
|
||||
var result = await session.getResolvedUnit(testFile) as ResolvedUnitResult;
|
||||
testAnalysisResult = result;
|
||||
testCode = result.content!;
|
||||
testUnit = result.unit!;
|
||||
testCode = result.content;
|
||||
testUnit = result.unit;
|
||||
if (verifyNoTestUnitErrors) {
|
||||
expect(result.errors.where((AnalysisError error) {
|
||||
return error.errorCode != HintCode.DEAD_CODE &&
|
||||
|
|
|
@ -583,7 +583,7 @@ import 'package:b/a.dart';''');
|
|||
Future<void> _computeUnitAndErrors(String code) async {
|
||||
addTestSource(code);
|
||||
var result = await session.getResolvedUnit(testFile) as ResolvedUnitResult;
|
||||
testUnit = result.unit!;
|
||||
testUnit = result.unit;
|
||||
testErrors = result.errors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ class PubPackageResolutionTest extends AbstractContextTest {
|
|||
result = await resolveFile(path);
|
||||
expect(result.state, ResultState.VALID);
|
||||
|
||||
findNode = FindNode(result.content!, result.unit!);
|
||||
findElement = FindElement(result.unit!);
|
||||
findNode = FindNode(result.content, result.unit);
|
||||
findElement = FindElement(result.unit);
|
||||
}
|
||||
|
||||
/// Put the [code] into the test file, and resolve it.
|
||||
|
|
|
@ -806,7 +806,7 @@ import 'a.dart';
|
|||
/// for completion we don't resolve unnecessary node.
|
||||
void _configureToCheckNotResolved({required Set<String> identifiers}) {
|
||||
_testResolvedUnit = (resolvedUnitResult) {
|
||||
var unit = resolvedUnitResult.unit!;
|
||||
var unit = resolvedUnitResult.unit;
|
||||
unit.accept(
|
||||
FunctionAstVisitor(
|
||||
simpleIdentifier: (node) {
|
||||
|
|
|
@ -399,7 +399,7 @@ void myMethod() {
|
|||
newFile(sourcePath, content: sourceContent);
|
||||
var result =
|
||||
await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
|
||||
var computer = DartUnitClosingLabelsComputer(result.lineInfo, result.unit!);
|
||||
var computer = DartUnitClosingLabelsComputer(result.lineInfo, result.unit);
|
||||
return computer.compute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -583,7 +583,7 @@ main() {}
|
|||
newFile(sourcePath, content: sourceContent);
|
||||
var result =
|
||||
await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
|
||||
var computer = DartUnitFoldingComputer(result.lineInfo, result.unit!);
|
||||
var computer = DartUnitFoldingComputer(result.lineInfo, result.unit);
|
||||
return computer.compute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ void main() {
|
|||
expect(result.errors, isEmpty);
|
||||
}
|
||||
|
||||
var computer = DartUnitHighlightsComputer(result.unit!);
|
||||
var computer = DartUnitHighlightsComputer(result.unit);
|
||||
highlights = computer.compute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ bool randomBool() {
|
|||
var result =
|
||||
await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
|
||||
var computer = ImportedElementsComputer(
|
||||
result.unit!, content.indexOf(selection), selection.length);
|
||||
result.unit, content.indexOf(selection), selection.length);
|
||||
importedElements = computer.compute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ void a(String b) {
|
|||
newFile(sourcePath, content: sourceContent);
|
||||
var result =
|
||||
await session.getResolvedUnit(sourcePath) as ResolvedUnitResult;
|
||||
var computer = DartSelectionRangeComputer(result.unit!, offset);
|
||||
var computer = DartSelectionRangeComputer(result.unit, offset);
|
||||
return computer.compute();
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void f() {
|
|||
}
|
||||
void g(int x, int y) {}
|
||||
''');
|
||||
var unit = testAnalysisResult.unit!;
|
||||
var unit = testAnalysisResult.unit;
|
||||
var function = unit.declarations[0] as FunctionDeclaration;
|
||||
var body = function.functionExpression.body as BlockFunctionBody;
|
||||
var statement = body.block.statements[0] as ExpressionStatement;
|
||||
|
|
|
@ -24,7 +24,7 @@ class WidgetDescriptionBase extends AbstractSingleUnitTest {
|
|||
expect(fileEdit.file, testAnalysisResult.path);
|
||||
|
||||
var actual = SourceEdit.applySequence(
|
||||
testAnalysisResult.content!,
|
||||
testAnalysisResult.content,
|
||||
fileEdit.edits,
|
||||
);
|
||||
expect(actual, expected);
|
||||
|
@ -50,7 +50,7 @@ class WidgetDescriptionBase extends AbstractSingleUnitTest {
|
|||
|
||||
Future<protocol.FlutterGetWidgetDescriptionResult?> getDescription(
|
||||
String search) async {
|
||||
var content = testAnalysisResult.content!;
|
||||
var content = testAnalysisResult.content;
|
||||
|
||||
var offset = content.indexOf(search);
|
||||
if (offset == -1) {
|
||||
|
|
|
@ -82,9 +82,9 @@ class CompletionRunner {
|
|||
output.write('.');
|
||||
var result = await context.currentSession.getResolvedUnit(path)
|
||||
as ResolvedUnitResult;
|
||||
var content = result.content!;
|
||||
var content = result.content;
|
||||
var lineInfo = result.lineInfo;
|
||||
var identifiers = _identifiersIn(result.unit!);
|
||||
var identifiers = _identifiersIn(result.unit);
|
||||
|
||||
for (var identifier in identifiers) {
|
||||
identifierCount++;
|
||||
|
|
|
@ -1411,7 +1411,7 @@ class CodeShapeMetricsComputer {
|
|||
continue;
|
||||
}
|
||||
|
||||
resolvedUnitResult.unit!.accept(collector);
|
||||
resolvedUnitResult.unit.accept(collector);
|
||||
} catch (exception) {
|
||||
print('Exception caught analyzing: "$filePath"');
|
||||
print(exception.toString());
|
||||
|
|
|
@ -1319,7 +1319,7 @@ class CompletionMetricsComputer {
|
|||
// Use the ExpectedCompletionsVisitor to compute the set of expected
|
||||
// completions for this CompilationUnit.
|
||||
final visitor = ExpectedCompletionsVisitor(filePath);
|
||||
_resolvedUnitResult.unit!.accept(visitor);
|
||||
_resolvedUnitResult.unit.accept(visitor);
|
||||
|
||||
for (var expectedCompletion in visitor.expectedCompletions) {
|
||||
var resolvedUnitResult = _resolvedUnitResult;
|
||||
|
@ -1328,7 +1328,7 @@ class CompletionMetricsComputer {
|
|||
// have the context reanalyze the file
|
||||
if (options.overlay != CompletionMetricsOptions.OVERLAY_NONE) {
|
||||
var overlayContents = _getOverlayContents(
|
||||
_resolvedUnitResult.content!, expectedCompletion);
|
||||
_resolvedUnitResult.content, expectedCompletion);
|
||||
|
||||
_provider.setOverlay(filePath,
|
||||
content: overlayContents,
|
||||
|
|
|
@ -224,7 +224,7 @@ class FlutterMetricsComputer {
|
|||
continue;
|
||||
}
|
||||
|
||||
resolvedUnitResult.unit!.accept(collector);
|
||||
resolvedUnitResult.unit.accept(collector);
|
||||
} catch (exception, stackTrace) {
|
||||
print('');
|
||||
print('Exception caught analyzing: "$filePath"');
|
||||
|
|
|
@ -208,7 +208,7 @@ class ImpliedTypeComputer {
|
|||
continue;
|
||||
}
|
||||
|
||||
resolvedUnitResult.unit!.accept(collector);
|
||||
resolvedUnitResult.unit.accept(collector);
|
||||
} catch (exception, stacktrace) {
|
||||
print('Exception caught analyzing: "$filePath"');
|
||||
print(exception);
|
||||
|
|
|
@ -1964,7 +1964,7 @@ class RelevanceMetricsComputer {
|
|||
continue;
|
||||
}
|
||||
|
||||
resolvedUnitResult.unit!.accept(collector);
|
||||
resolvedUnitResult.unit.accept(collector);
|
||||
} catch (exception, stacktrace) {
|
||||
print('Exception caught analyzing: "$filePath"');
|
||||
print(exception);
|
||||
|
|
|
@ -317,7 +317,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
|
|||
|
||||
/// Initialize this collector prior to visiting the unit in the [result].
|
||||
void initializeFrom(ResolvedUnitResult result) {
|
||||
unit = result.unit!;
|
||||
unit = result.unit;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1484,7 +1484,7 @@ class RelevanceMetricsComputer {
|
|||
}
|
||||
|
||||
collector.initializeFrom(resolvedUnitResult);
|
||||
resolvedUnitResult.unit!.accept(collector);
|
||||
resolvedUnitResult.unit.accept(collector);
|
||||
} catch (exception, stacktrace) {
|
||||
print('Exception caught analyzing: "$filePath"');
|
||||
print(exception);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
* Changed `ParsedLibraryResult.units` to be non-nullable.
|
||||
* Changed `ResolvedLibraryResult.element` to be non-nullable.
|
||||
* Changed `ResolvedLibraryResult.units` to be non-nullable.
|
||||
* Changed `ResolvedUnitResult.content` to be non-nullable.
|
||||
* Changed `ResolvedUnitResult.unit` to be non-nullable.
|
||||
* Deprecated and renamed `AnalysisSession.getXyz2()` into `getXyz()`.
|
||||
* Changed `AnalysisDriver.results` to `Stream<Object>`.
|
||||
It used to always produce `ResolvedUnitResult`s, but sometimes its
|
||||
|
|
|
@ -231,7 +231,7 @@ abstract class ResolvedLibraryResult
|
|||
abstract class ResolvedUnitResult
|
||||
implements SomeResolvedUnitResult, AnalysisResultWithErrors {
|
||||
/// The content of the file that was scanned, parsed and resolved.
|
||||
String? get content;
|
||||
String get content;
|
||||
|
||||
/// Return `true` if the file exists.
|
||||
bool get exists;
|
||||
|
@ -246,7 +246,7 @@ abstract class ResolvedUnitResult
|
|||
TypeSystem get typeSystem;
|
||||
|
||||
/// The fully resolved compilation unit for the [content].
|
||||
CompilationUnit? get unit;
|
||||
CompilationUnit get unit;
|
||||
}
|
||||
|
||||
/// An indication of whether an analysis result is valid, and if not why.
|
||||
|
|
|
@ -1672,7 +1672,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
List<AnalysisError> errors = _getErrorsFromSerialized(file, unit.errors);
|
||||
_updateHasErrorOrWarningFlag(file, errors);
|
||||
var index = unit.index!;
|
||||
if (resolvedUnit != null) {
|
||||
if (content != null && resolvedUnit != null) {
|
||||
var resolvedUnitResult = ResolvedUnitResultImpl(
|
||||
currentSession,
|
||||
file.path,
|
||||
|
|
|
@ -204,13 +204,8 @@ class ResolvedLibraryResultImpl extends AnalysisResultImpl
|
|||
},
|
||||
);
|
||||
|
||||
var unit = unitResult.unit;
|
||||
if (unit == null) {
|
||||
throw StateError('The result has no unit');
|
||||
}
|
||||
|
||||
var locator = _DeclarationByElementLocator(element);
|
||||
unit.accept(locator);
|
||||
unitResult.unit.accept(locator);
|
||||
var declaration = locator.result;
|
||||
|
||||
if (declaration == null) {
|
||||
|
@ -227,10 +222,10 @@ class ResolvedUnitResultImpl extends FileResultImpl
|
|||
final bool exists;
|
||||
|
||||
@override
|
||||
final String? content;
|
||||
final String content;
|
||||
|
||||
@override
|
||||
final CompilationUnit? unit;
|
||||
final CompilationUnit unit;
|
||||
|
||||
@override
|
||||
final List<AnalysisError> errors;
|
||||
|
@ -249,10 +244,6 @@ class ResolvedUnitResultImpl extends FileResultImpl
|
|||
|
||||
@override
|
||||
LibraryElement get libraryElement {
|
||||
final unit = this.unit;
|
||||
if (unit == null) {
|
||||
throw StateError('The result has no unit');
|
||||
}
|
||||
return unit.declaredElement!.library;
|
||||
}
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ class Search {
|
|||
var unitResult = await _driver.getResult2(unitPath);
|
||||
if (unitResult is ResolvedUnitResult) {
|
||||
var visitor = _ImportElementReferencesVisitor(element, unitElement);
|
||||
unitResult.unit!.accept(visitor);
|
||||
unitResult.unit.accept(visitor);
|
||||
results.addAll(visitor.results);
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ class Search {
|
|||
String unitPath = unitElement.source.fullName;
|
||||
var unitResult = await _driver.getResult2(unitPath);
|
||||
if (unitResult is ResolvedUnitResult) {
|
||||
CompilationUnit unit = unitResult.unit!;
|
||||
CompilationUnit unit = unitResult.unit;
|
||||
for (Directive directive in unit.directives) {
|
||||
if (directive is PartOfDirective && directive.element == element) {
|
||||
results.add(
|
||||
|
@ -433,9 +433,6 @@ class Search {
|
|||
return const <SearchResult>[];
|
||||
}
|
||||
var unit = unitResult.unit;
|
||||
if (unit == null) {
|
||||
return const <SearchResult>[];
|
||||
}
|
||||
|
||||
// Prepare the node.
|
||||
var node = NodeLocator(element.nameOffset).searchWithin(unit);
|
||||
|
@ -487,7 +484,7 @@ class Search {
|
|||
var unitResult = await _driver.getResult2(unitPath);
|
||||
if (unitResult is ResolvedUnitResult) {
|
||||
var visitor = _LocalReferencesVisitor(element, unitElement);
|
||||
unitResult.unit!.accept(visitor);
|
||||
unitResult.unit.accept(visitor);
|
||||
results.addAll(visitor.results);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ class FileResolver {
|
|||
result.forEach((filePath) {
|
||||
var resolved = resolve(path: filePath);
|
||||
var collector = ReferencesCollector(element);
|
||||
resolved.unit?.accept(collector);
|
||||
resolved.unit.accept(collector);
|
||||
var offsets = collector.offsets;
|
||||
if (offsets.isNotEmpty) {
|
||||
references.add(CiderSearchMatch(filePath, offsets));
|
||||
|
|
|
@ -166,7 +166,7 @@ main() {
|
|||
var fa = findNode.topLevelVariableDeclaration('fa');
|
||||
var fb = findNode.topLevelVariableDeclaration('fb');
|
||||
|
||||
var source = result.unit!.declaredElement!.source;
|
||||
var source = result.unit.declaredElement!.source;
|
||||
var reporter = ErrorReporter(
|
||||
listener,
|
||||
source,
|
||||
|
@ -201,7 +201,7 @@ main() {
|
|||
var ba = findNode.topLevelVariableDeclaration('ba');
|
||||
var bb = findNode.topLevelVariableDeclaration('bb');
|
||||
|
||||
var source = result.unit!.declaredElement!.source;
|
||||
var source = result.unit.declaredElement!.source;
|
||||
var reporter = ErrorReporter(
|
||||
listener,
|
||||
source,
|
||||
|
|
|
@ -761,7 +761,7 @@ class C = D with E;
|
|||
class D {}
|
||||
class E {}
|
||||
''');
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
ClassElement classC = unit.declaredElement!.getType('C')!;
|
||||
expect(classC.documentationComment, isNotNull);
|
||||
}
|
||||
|
@ -1610,7 +1610,7 @@ mixin M<T> on A<T> {}
|
|||
|
||||
class C extends A<B> with M {}
|
||||
''');
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
ClassElement classC = unit.declaredElement!.getType('C')!;
|
||||
expect(classC.mixins, hasLength(1));
|
||||
assertType(classC.mixins[0], 'M<B>');
|
||||
|
@ -1632,7 +1632,7 @@ class C extends A<int Function(String)> with M {}
|
|||
1,
|
||||
),
|
||||
]);
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
ClassElement classC = unit.declaredElement!.getType('C')!;
|
||||
expect(classC.mixins, hasLength(1));
|
||||
assertType(classC.mixins[0], 'M<int, String>');
|
||||
|
@ -1648,7 +1648,7 @@ mixin M<T> on A<List<T>> {}
|
|||
|
||||
class C extends A<List<B>> with M {}
|
||||
''');
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
ClassElement classC = unit.declaredElement!.getType('C')!;
|
||||
expect(classC.mixins, hasLength(1));
|
||||
assertType(classC.mixins[0], 'M<B>');
|
||||
|
@ -2095,7 +2095,7 @@ void main() {
|
|||
error(HintCode.UNUSED_LOCAL_VARIABLE, 93, 1),
|
||||
error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 97, 1),
|
||||
]);
|
||||
var z = result.unit!.declaredElement!.topLevelVariables
|
||||
var z = result.unit.declaredElement!.topLevelVariables
|
||||
.where((e) => e.name == 'z')
|
||||
.single;
|
||||
assertType(z.type, 'List<String>');
|
||||
|
@ -2275,7 +2275,7 @@ class A<T> {}
|
|||
class B<T> = Object with A<T>;
|
||||
class C = Object with B;
|
||||
''');
|
||||
var bReference = result.unit!.declaredElement!.getType('C')!.mixins[0];
|
||||
var bReference = result.unit.declaredElement!.getType('C')!.mixins[0];
|
||||
assertTypeDynamic(bReference.typeArguments[0]);
|
||||
}
|
||||
|
||||
|
@ -2294,7 +2294,7 @@ class C = Base with B;
|
|||
''', [
|
||||
error(CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT, 122, 1),
|
||||
]);
|
||||
var bReference = result.unit!.declaredElement!.getType('C')!.mixins[0];
|
||||
var bReference = result.unit.declaredElement!.getType('C')!.mixins[0];
|
||||
assertType(bReference.typeArguments[0], 'int');
|
||||
}
|
||||
|
||||
|
@ -2333,7 +2333,7 @@ void main () {
|
|||
x;
|
||||
}
|
||||
''');
|
||||
var main = result.unit!.declarations.last as FunctionDeclaration;
|
||||
var main = result.unit.declarations.last as FunctionDeclaration;
|
||||
var mainBody = main.functionExpression.body as BlockFunctionBody;
|
||||
var xDecl = mainBody.block.statements[0] as VariableDeclarationStatement;
|
||||
var xElem = xDecl.variables.variables[0].declaredElement!;
|
||||
|
@ -2804,8 +2804,8 @@ import 'b.dart';
|
|||
@B.named8()
|
||||
main() {}
|
||||
''');
|
||||
expect(result.unit!.declarations, hasLength(1));
|
||||
final mainDecl = result.unit!.declarations[0];
|
||||
expect(result.unit.declarations, hasLength(1));
|
||||
final mainDecl = result.unit.declarations[0];
|
||||
expect(mainDecl.metadata, hasLength(8));
|
||||
mainDecl.metadata.forEach((metadata) {
|
||||
final value = metadata.elementAnnotation!.computeConstantValue()!;
|
||||
|
|
|
@ -1264,7 +1264,7 @@ main() {
|
|||
/// Verify that all of the identifiers in the [result] have been resolved.
|
||||
void verifyTestResolved() {
|
||||
var verifier = ResolutionVerifier();
|
||||
result.unit!.accept(verifier);
|
||||
result.unit.accept(verifier);
|
||||
verifier.assertResolved();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class StrongModeLocalInferenceTest extends PubPackageResolutionTest
|
|||
|
||||
late final AsserterBuilder<Element, DartType> _hasElement;
|
||||
|
||||
CompilationUnit get unit => result.unit!;
|
||||
CompilationUnit get unit => result.unit;
|
||||
|
||||
@override
|
||||
Future<void> resolveTestFile() async {
|
||||
|
@ -2404,7 +2404,7 @@ class B<T2, U2> {
|
|||
}
|
||||
''');
|
||||
|
||||
var b = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var b = result.unit.declarations[1] as ClassDeclaration;
|
||||
var bConstructor = b.members[0] as ConstructorDeclaration;
|
||||
var redirected = bConstructor.redirectedConstructor as ConstructorName;
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ class BaseDependencyTest extends PubPackageResolutionTest {
|
|||
var session = contextFor(libraryPath).currentSession;
|
||||
var resolvedLibrary = await session.getResolvedLibrary(libraryPath);
|
||||
resolvedLibrary as ResolvedLibraryResult;
|
||||
return resolvedLibrary.units.map((ru) => ru.unit!).toList();
|
||||
return resolvedLibrary.units.map((ru) => ru.unit).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ void topLevelFunction() {}
|
|||
await resolveTestFile();
|
||||
|
||||
var myDeclaration =
|
||||
result.unit!.declarations[0] as TopLevelVariableDeclaration;
|
||||
result.unit.declarations[0] as TopLevelVariableDeclaration;
|
||||
var myVariable = myDeclaration.variables.variables[0];
|
||||
var myElement = myVariable.declaredElement as TopLevelVariableElement;
|
||||
|
||||
|
@ -157,7 +157,7 @@ void topLevelFunction() {}
|
|||
}
|
||||
|
||||
{
|
||||
var classNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var classNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
assertMyAnnotation(classNode);
|
||||
|
||||
{
|
||||
|
@ -177,12 +177,12 @@ void topLevelFunction() {}
|
|||
}
|
||||
|
||||
{
|
||||
var node = result.unit!.declarations[2] as TopLevelVariableDeclaration;
|
||||
var node = result.unit.declarations[2] as TopLevelVariableDeclaration;
|
||||
assertMyAnnotation(node);
|
||||
}
|
||||
|
||||
{
|
||||
var node = result.unit!.declarations[3] as FunctionDeclaration;
|
||||
var node = result.unit.declarations[3] as FunctionDeclaration;
|
||||
assertMyAnnotation(node);
|
||||
}
|
||||
}
|
||||
|
@ -346,11 +346,11 @@ main() {
|
|||
|
||||
await resolveTestFile();
|
||||
|
||||
var c = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var c = result.unit.declarations[0] as ClassDeclaration;
|
||||
var constructor = c.members[1] as ConstructorDeclaration;
|
||||
ConstructorElement element = constructor.declaredElement!;
|
||||
|
||||
var main = result.unit!.declarations[1] as FunctionDeclaration;
|
||||
var main = result.unit.declarations[1] as FunctionDeclaration;
|
||||
var statement = (main.functionExpression.body as BlockFunctionBody)
|
||||
.block
|
||||
.statements[0] as VariableDeclarationStatement;
|
||||
|
@ -377,11 +377,11 @@ class C {
|
|||
await resolveTestFile();
|
||||
|
||||
var myDeclaration =
|
||||
result.unit!.declarations[0] as TopLevelVariableDeclaration;
|
||||
result.unit.declarations[0] as TopLevelVariableDeclaration;
|
||||
VariableDeclaration myVariable = myDeclaration.variables.variables[0];
|
||||
var myElement = myVariable.declaredElement as TopLevelVariableElement;
|
||||
|
||||
var classNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var classNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
var node = classNode.members[0] as MethodDeclaration;
|
||||
var statement = (node.body as BlockFunctionBody).block.statements[0]
|
||||
as VariableDeclarationStatement;
|
||||
|
@ -406,7 +406,7 @@ import 'a.dart' as p;
|
|||
main() {}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
ImportElement aImport = unit.declaredElement!.library.imports[0];
|
||||
PrefixElement aPrefix = aImport.prefix!;
|
||||
|
@ -445,7 +445,7 @@ import 'a.dart' as p;
|
|||
main() {}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
ImportElement aImport = unit.declaredElement!.library.imports[0];
|
||||
PrefixElement aPrefix = aImport.prefix!;
|
||||
|
@ -486,7 +486,7 @@ import 'a.dart' as p;
|
|||
main() {}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
ImportElement aImport = unit.declaredElement!.library.imports[0];
|
||||
PrefixElement aPrefix = aImport.prefix!;
|
||||
|
@ -527,7 +527,7 @@ import 'a.dart' as p;
|
|||
main() {}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
ImportElement aImport = unit.declaredElement!.library.imports[0];
|
||||
PrefixElement aPrefix = aImport.prefix!;
|
||||
|
@ -560,7 +560,7 @@ class A {
|
|||
}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
ClassElement aClass = unitElement.getType('A')!;
|
||||
|
@ -590,7 +590,7 @@ class A {
|
|||
}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
ClassElement aClass = unitElement.getType('A')!;
|
||||
|
@ -620,7 +620,7 @@ class A {
|
|||
}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
ClassElement aClass = unitElement.getType('A')!;
|
||||
|
@ -657,11 +657,11 @@ class D {
|
|||
f() {}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
var elementC = AstFinder.getClass(result.unit!, 'C').declaredElement!;
|
||||
var elementC = AstFinder.getClass(result.unit, 'C').declaredElement!;
|
||||
var constructorC = elementC.constructors[0];
|
||||
var elementD = AstFinder.getClass(result.unit!, 'D').declaredElement!;
|
||||
var elementD = AstFinder.getClass(result.unit, 'D').declaredElement!;
|
||||
var constructorD = elementD.constructors[0];
|
||||
var atD = AstFinder.getTopLevelFunction(result.unit!, 'f').metadata[0];
|
||||
var atD = AstFinder.getTopLevelFunction(result.unit, 'f').metadata[0];
|
||||
var constC = atD.arguments!.arguments[0] as InstanceCreationExpression;
|
||||
|
||||
expect(atD.name.staticElement, elementD);
|
||||
|
@ -689,16 +689,16 @@ void main() {
|
|||
await resolveTestFile();
|
||||
|
||||
var declaration_1 =
|
||||
result.unit!.declarations[0] as TopLevelVariableDeclaration;
|
||||
result.unit.declarations[0] as TopLevelVariableDeclaration;
|
||||
VariableDeclaration variable_1 = declaration_1.variables.variables[0];
|
||||
var element_1 = variable_1.declaredElement as TopLevelVariableElement;
|
||||
|
||||
var declaration_2 =
|
||||
result.unit!.declarations[1] as TopLevelVariableDeclaration;
|
||||
result.unit.declarations[1] as TopLevelVariableDeclaration;
|
||||
VariableDeclaration variable_2 = declaration_2.variables.variables[0];
|
||||
var element_2 = variable_2.declaredElement as TopLevelVariableElement;
|
||||
|
||||
var main = result.unit!.declarations[2] as FunctionDeclaration;
|
||||
var main = result.unit.declarations[2] as FunctionDeclaration;
|
||||
|
||||
Annotation annotation_1 = main.metadata[0];
|
||||
expect(annotation_1.element, same(element_1.getter));
|
||||
|
@ -959,7 +959,7 @@ main() {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var mainDeclaration = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var mainDeclaration = result.unit.declarations[0] as FunctionDeclaration;
|
||||
var mainElement = mainDeclaration.declaredElement as FunctionElement;
|
||||
var mainBody = mainDeclaration.functionExpression.body as BlockFunctionBody;
|
||||
List<Statement> mainStatements = mainBody.block.statements;
|
||||
|
@ -1090,7 +1090,7 @@ class C {
|
|||
}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var c = unit.declarations[0] as ClassDeclaration;
|
||||
var declaration = c.members[0] as FieldDeclaration;
|
||||
|
@ -1107,7 +1107,7 @@ class C {
|
|||
var v = (() => 42)();
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var declaration = unit.declarations[0] as TopLevelVariableDeclaration;
|
||||
VariableDeclaration variable = declaration.variables.variables[0];
|
||||
|
@ -1164,7 +1164,7 @@ class C {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
|
||||
var constructorNode = cNode.members[0] as ConstructorDeclaration;
|
||||
ParameterElement pElement = constructorNode.declaredElement!.parameters[0];
|
||||
|
@ -1188,7 +1188,7 @@ class C {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
FieldElement fElement = cElement.getField('f')!;
|
||||
|
||||
|
@ -1219,10 +1219,10 @@ class B extends A {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement aElement = aNode.declaredElement!;
|
||||
|
||||
var bNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var bNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
|
||||
{
|
||||
var constructor = bNode.members[0] as ConstructorDeclaration;
|
||||
|
@ -1261,7 +1261,7 @@ class C {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
||||
{
|
||||
|
@ -1312,10 +1312,10 @@ class B {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isEmpty);
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement aElement = aNode.declaredElement!;
|
||||
|
||||
var bNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var bNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
|
||||
{
|
||||
ConstructorElement aUnnamed = aElement.constructors[0];
|
||||
|
@ -1373,10 +1373,10 @@ class B<U> {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isEmpty);
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement aElement = aNode.declaredElement!;
|
||||
|
||||
var bNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var bNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
TypeParameterType uType =
|
||||
typeParameterTypeNone(bNode.declaredElement!.typeParameters[0]);
|
||||
InterfaceType auType = aElement.instantiate(
|
||||
|
@ -1714,7 +1714,7 @@ main(MyEnum e) {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var enumNode = result.unit!.declarations[0] as EnumDeclaration;
|
||||
var enumNode = result.unit.declarations[0] as EnumDeclaration;
|
||||
ClassElement enumElement = enumNode.declaredElement!;
|
||||
|
||||
List<Statement> mainStatements = _getMainStatements(result);
|
||||
|
@ -1758,7 +1758,7 @@ class C<T> {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
var tElement = cNode.declaredElement!.typeParameters[0];
|
||||
|
||||
var fDeclaration = cNode.members[0] as FieldDeclaration;
|
||||
|
@ -1806,7 +1806,7 @@ class A {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var clazz = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var clazz = result.unit.declarations[0] as ClassDeclaration;
|
||||
var constructor = clazz.members[0] as ConstructorDeclaration;
|
||||
List<FormalParameter> parameters = constructor.parameters.parameters;
|
||||
|
||||
|
@ -1841,7 +1841,7 @@ class A {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var clazz = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var clazz = result.unit.declarations[0] as ClassDeclaration;
|
||||
|
||||
var fDeclaration = clazz.members[0] as FieldDeclaration;
|
||||
VariableDeclaration fNode = fDeclaration.fields.variables[0];
|
||||
|
@ -1886,7 +1886,7 @@ class A {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var clazz = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var clazz = result.unit.declarations[0] as ClassDeclaration;
|
||||
|
||||
var fDeclaration = clazz.members[0] as FieldDeclaration;
|
||||
VariableDeclaration fNode = fDeclaration.fields.variables[0];
|
||||
|
@ -1916,7 +1916,7 @@ class A {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var clazz = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var clazz = result.unit.declarations[0] as ClassDeclaration;
|
||||
|
||||
var fDeclaration = clazz.members[0] as FieldDeclaration;
|
||||
VariableDeclaration fNode = fDeclaration.fields.variables[0];
|
||||
|
@ -2078,7 +2078,7 @@ var b = new C.named();
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cNode = unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
@ -2131,7 +2131,7 @@ var v = new X(1, b: true, c: 3.0);
|
|||
''');
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var xNode = unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement xElement = xNode.declaredElement!;
|
||||
|
@ -2172,7 +2172,7 @@ var b = new C.named(2);
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cNode = unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
@ -2239,7 +2239,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
ImportElement aImport = unit.declaredElement!.library.imports[0];
|
||||
LibraryElement aLibrary = aImport.importedLibrary!;
|
||||
|
@ -2356,7 +2356,7 @@ class C<T> {
|
|||
}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
ClassElement cElement = unitElement.getType('C')!;
|
||||
|
@ -4342,7 +4342,7 @@ void main(List<String> p) {
|
|||
}
|
||||
''');
|
||||
|
||||
var main = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var main = result.unit.declarations[0] as FunctionDeclaration;
|
||||
List<Statement> statements = _getMainStatements(result);
|
||||
|
||||
// (int p)
|
||||
|
@ -4735,7 +4735,7 @@ void main() {
|
|||
|
||||
InterfaceType intType = typeProvider.intType;
|
||||
|
||||
var main = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var main = result.unit.declarations[0] as FunctionDeclaration;
|
||||
expect(main.declaredElement, isNotNull);
|
||||
expect(main.name.staticElement, isNotNull);
|
||||
expect(main.name.staticType, isNull);
|
||||
|
@ -4778,7 +4778,7 @@ class C {
|
|||
}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cDeclaration = unit.declarations[0] as ClassDeclaration;
|
||||
|
||||
|
@ -4849,7 +4849,7 @@ void main() {
|
|||
num v;
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
List<Statement> statements = _getMainStatements(result);
|
||||
|
||||
|
@ -5089,7 +5089,7 @@ void g(C c) {
|
|||
String fTypeString = 'double Function(int, {String b, bool c})';
|
||||
|
||||
await resolveTestFile();
|
||||
var classDeclaration = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var classDeclaration = result.unit.declarations[0] as ClassDeclaration;
|
||||
var methodDeclaration = classDeclaration.members[0] as MethodDeclaration;
|
||||
var methodElement = methodDeclaration.declaredElement as MethodElement;
|
||||
|
||||
|
@ -5134,7 +5134,7 @@ void g(C c) {
|
|||
// Validate the arguments at the call site.
|
||||
//
|
||||
var functionDeclaration =
|
||||
result.unit!.declarations[1] as FunctionDeclaration;
|
||||
result.unit.declarations[1] as FunctionDeclaration;
|
||||
var body = functionDeclaration.functionExpression.body as BlockFunctionBody;
|
||||
var statement = body.block.statements[0] as ExpressionStatement;
|
||||
var invocation = statement.expression as MethodInvocation;
|
||||
|
@ -5157,7 +5157,7 @@ main() {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isEmpty);
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
MethodElement callElement = cElement.methods[0];
|
||||
|
||||
|
@ -5183,7 +5183,7 @@ f(double computation(int p)) {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isEmpty);
|
||||
|
||||
var main = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var main = result.unit.declarations[0] as FunctionDeclaration;
|
||||
var mainElement = main.declaredElement as FunctionElement;
|
||||
ParameterElement parameter = mainElement.parameters[0];
|
||||
|
||||
|
@ -5220,7 +5220,7 @@ main(B b) {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
var fooNode = aNode.members[0] as MethodDeclaration;
|
||||
var fooElement = fooNode.declaredElement as MethodElement;
|
||||
|
||||
|
@ -5305,7 +5305,7 @@ void foo(int a, {bool b, double c}) {}
|
|||
await resolveTestFile();
|
||||
List<Statement> mainStatements = _getMainStatements(result);
|
||||
|
||||
var foo = result.unit!.declarations[1] as FunctionDeclaration;
|
||||
var foo = result.unit.declarations[1] as FunctionDeclaration;
|
||||
ExecutableElement fooElement = foo.declaredElement!;
|
||||
|
||||
var statement = mainStatements[0] as ExpressionStatement;
|
||||
|
@ -5452,7 +5452,7 @@ class C {
|
|||
await resolveTestFile();
|
||||
List<Statement> mainStatements = _getMainStatements(result);
|
||||
|
||||
var cNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
var mNode = cNode.members[0] as MethodDeclaration;
|
||||
var mElement = mNode.declaredElement as MethodElement;
|
||||
|
@ -5509,7 +5509,7 @@ class C<T> {
|
|||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
TypeParameterElement tElement = cNode.declaredElement!.typeParameters[0];
|
||||
|
||||
var barNode = cNode.members[1] as MethodDeclaration;
|
||||
|
@ -5535,7 +5535,7 @@ double f(int a, String b) {}
|
|||
|
||||
InterfaceType doubleType = typeProvider.doubleType;
|
||||
|
||||
var fNode = result.unit!.declarations[1] as FunctionDeclaration;
|
||||
var fNode = result.unit.declarations[1] as FunctionDeclaration;
|
||||
var fElement = fNode.declaredElement as FunctionElement;
|
||||
|
||||
var statement = mainStatements[0] as ExpressionStatement;
|
||||
|
@ -5564,7 +5564,7 @@ void f<T, U>(T a, U b) {}
|
|||
|
||||
List<Statement> mainStatements = _getMainStatements(result);
|
||||
|
||||
var fNode = result.unit!.declarations[1] as FunctionDeclaration;
|
||||
var fNode = result.unit.declarations[1] as FunctionDeclaration;
|
||||
var fElement = fNode.declaredElement as FunctionElement;
|
||||
|
||||
// f<bool, String>(true, 'str');
|
||||
|
@ -6030,7 +6030,7 @@ class C {
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cClassDeclaration = unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement cClassElement = cClassDeclaration.declaredElement!;
|
||||
|
@ -6129,7 +6129,7 @@ class C {
|
|||
|
||||
List<Statement> statements = _getMainStatements(result);
|
||||
|
||||
var cDeclaration = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var cDeclaration = result.unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement cElement = cDeclaration.declaredElement!;
|
||||
FieldElement fElement = cElement.fields[0];
|
||||
|
||||
|
@ -6164,7 +6164,7 @@ class C {
|
|||
|
||||
List<Statement> statements = _getMainStatements(result);
|
||||
|
||||
var cDeclaration = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var cDeclaration = result.unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement cElement = cDeclaration.declaredElement!;
|
||||
FieldElement fElement = cElement.fields[0];
|
||||
|
||||
|
@ -6189,7 +6189,7 @@ f(double computation(int p)) {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isEmpty);
|
||||
|
||||
var main = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var main = result.unit.declarations[0] as FunctionDeclaration;
|
||||
var mainElement = main.declaredElement as FunctionElement;
|
||||
ParameterElement parameter = mainElement.parameters[0];
|
||||
|
||||
|
@ -6232,7 +6232,7 @@ main() {
|
|||
// TODO(scheglov) Uncomment and fix "unused imports" hint.
|
||||
// expect(result.errors, isEmpty);
|
||||
|
||||
var unitElement = result.unit!.declaredElement!;
|
||||
var unitElement = result.unit.declaredElement!;
|
||||
ImportElement myImport = unitElement.library.imports[0];
|
||||
PrefixElement myPrefix = myImport.prefix!;
|
||||
|
||||
|
@ -6405,7 +6405,7 @@ class C {
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cClassDeclaration = unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement cClassElement = cClassDeclaration.declaredElement!;
|
||||
|
@ -6467,7 +6467,7 @@ class C {
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cClassDeclaration = unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement cClassElement = cClassDeclaration.declaredElement!;
|
||||
|
@ -6504,7 +6504,7 @@ class C {
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cClassDeclaration = unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement cClassElement = cClassDeclaration.declaredElement!;
|
||||
|
@ -6571,7 +6571,7 @@ void main() {
|
|||
}
|
||||
''');
|
||||
|
||||
var main = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var main = result.unit.declarations[0] as FunctionDeclaration;
|
||||
expect(main.declaredElement, isNotNull);
|
||||
expect(main.name.staticElement, isNotNull);
|
||||
expect(main.name.staticType, isNull);
|
||||
|
@ -6655,8 +6655,8 @@ class B extends A {
|
|||
addTestFile(content);
|
||||
await resolveTestFile();
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var bNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
var bNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
|
||||
var methodElement = aNode.members[0].declaredElement as MethodElement;
|
||||
var getterElement =
|
||||
|
@ -6784,7 +6784,7 @@ class A {
|
|||
addTestFile(content);
|
||||
await resolveTestFile();
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
|
||||
var methodElement = aNode.members[0].declaredElement as MethodElement;
|
||||
var getterElement =
|
||||
|
@ -6900,7 +6900,7 @@ class C {
|
|||
addTestFile(content);
|
||||
await resolveTestFile();
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
||||
var constructorNode = cNode.members[1] as ConstructorDeclaration;
|
||||
|
@ -6945,16 +6945,16 @@ class D extends A<bool> with B<int> implements C<double> {}
|
|||
addTestFile(content);
|
||||
await resolveTestFile();
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement aElement = aNode.declaredElement!;
|
||||
|
||||
var bNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var bNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement bElement = bNode.declaredElement!;
|
||||
|
||||
var cNode = result.unit!.declarations[2] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[2] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
||||
var dNode = result.unit!.declarations[3] as ClassDeclaration;
|
||||
var dNode = result.unit.declarations[3] as ClassDeclaration;
|
||||
Element dElement = dNode.declaredElement!;
|
||||
|
||||
SimpleIdentifier dName = dNode.name;
|
||||
|
@ -7014,16 +7014,16 @@ class D = A<bool> with B<int> implements C<double>;
|
|||
addTestFile(content);
|
||||
await resolveTestFile();
|
||||
|
||||
var aNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var aNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement aElement = aNode.declaredElement!;
|
||||
|
||||
var bNode = result.unit!.declarations[1] as ClassDeclaration;
|
||||
var bNode = result.unit.declarations[1] as ClassDeclaration;
|
||||
ClassElement bElement = bNode.declaredElement!;
|
||||
|
||||
var cNode = result.unit!.declarations[2] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[2] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
||||
var dNode = result.unit!.declarations[3] as ClassTypeAlias;
|
||||
var dNode = result.unit.declarations[3] as ClassTypeAlias;
|
||||
Element dElement = dNode.declaredElement!;
|
||||
|
||||
SimpleIdentifier dName = dNode.name;
|
||||
|
@ -7082,7 +7082,7 @@ enum MyEnum {
|
|||
addTestFile(content);
|
||||
await resolveTestFile();
|
||||
|
||||
var enumNode = result.unit!.declarations[0] as EnumDeclaration;
|
||||
var enumNode = result.unit.declarations[0] as EnumDeclaration;
|
||||
ClassElement enumElement = enumNode.declaredElement!;
|
||||
|
||||
SimpleIdentifier dName = enumNode.name;
|
||||
|
@ -7123,7 +7123,7 @@ class C {
|
|||
ClassElement doubleElement = doubleType.element;
|
||||
ClassElement intElement = intType.element;
|
||||
|
||||
var cNode = result.unit!.declarations[0] as ClassDeclaration;
|
||||
var cNode = result.unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
||||
// The class name identifier.
|
||||
|
@ -7248,7 +7248,7 @@ void set topSetter(double p) {}
|
|||
|
||||
// topFunction()
|
||||
{
|
||||
var node = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var node = result.unit.declarations[0] as FunctionDeclaration;
|
||||
expect(node.declaredElement, isNotNull);
|
||||
assertType(node.declaredElement!.type, 'int Function(double)');
|
||||
|
||||
|
@ -7281,7 +7281,7 @@ void set topSetter(double p) {}
|
|||
|
||||
// topGetter()
|
||||
{
|
||||
var node = result.unit!.declarations[1] as FunctionDeclaration;
|
||||
var node = result.unit.declarations[1] as FunctionDeclaration;
|
||||
expect(node.declaredElement, isNotNull);
|
||||
assertType(node.declaredElement!.type, 'int Function()');
|
||||
|
||||
|
@ -7299,7 +7299,7 @@ void set topSetter(double p) {}
|
|||
|
||||
// topSetter()
|
||||
{
|
||||
var node = result.unit!.declarations[2] as FunctionDeclaration;
|
||||
var node = result.unit.declarations[2] as FunctionDeclaration;
|
||||
expect(node.declaredElement, isNotNull);
|
||||
assertType(node.declaredElement!.type, 'void Function(double)');
|
||||
|
||||
|
@ -7341,7 +7341,7 @@ class C<T> {
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
var cNode = unit.declarations[0] as ClassDeclaration;
|
||||
|
@ -7388,7 +7388,7 @@ class C {
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var cNode = unit.declarations[0] as ClassDeclaration;
|
||||
ClassElement cElement = cNode.declaredElement!;
|
||||
|
@ -7432,7 +7432,7 @@ double b = 2.3;
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
{
|
||||
|
@ -7474,7 +7474,7 @@ var a = 1, b = 2.3;
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
var variableDeclaration =
|
||||
|
@ -7518,7 +7518,7 @@ void main() {
|
|||
String fTypeString = 'double Function(int, {String b, bool c})';
|
||||
|
||||
await resolveTestFile();
|
||||
var fDeclaration = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var fDeclaration = result.unit.declarations[0] as FunctionDeclaration;
|
||||
var fElement = fDeclaration.declaredElement as FunctionElement;
|
||||
|
||||
InterfaceType doubleType = typeProvider.doubleType;
|
||||
|
@ -7571,7 +7571,7 @@ void main() {
|
|||
//
|
||||
// Validate the arguments at the call site.
|
||||
//
|
||||
var mainDeclaration = result.unit!.declarations[1] as FunctionDeclaration;
|
||||
var mainDeclaration = result.unit.declarations[1] as FunctionDeclaration;
|
||||
var body = mainDeclaration.functionExpression.body as BlockFunctionBody;
|
||||
var statement = body.block.statements[0] as ExpressionStatement;
|
||||
var invocation = statement.expression as MethodInvocation;
|
||||
|
@ -7589,7 +7589,7 @@ typedef int F<T>(bool a, T b);
|
|||
addTestFile(content);
|
||||
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var alias = unit.declarations[0] as FunctionTypeAlias;
|
||||
TypeAliasElement aliasElement = alias.declaredElement!;
|
||||
|
@ -7623,7 +7623,7 @@ class C<T extends A, U extends List<A>, V> {}
|
|||
''';
|
||||
addTestFile(content);
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
CompilationUnitElement unitElement = unit.declaredElement!;
|
||||
|
||||
var aNode = unit.declarations[0] as ClassDeclaration;
|
||||
|
@ -7870,7 +7870,7 @@ b.A a1;
|
|||
c.A a2;
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
ImportElement bImport = unit.declaredElement!.library.imports[0];
|
||||
ImportElement cImport = unit.declaredElement!.library.imports[1];
|
||||
|
@ -7915,7 +7915,7 @@ void main() {
|
|||
typedef void F(int p);
|
||||
''');
|
||||
await resolveTestFile();
|
||||
CompilationUnit unit = result.unit!;
|
||||
CompilationUnit unit = result.unit;
|
||||
|
||||
var fNode = unit.declarations[1] as FunctionTypeAlias;
|
||||
TypeAliasElement fElement = fNode.declaredElement!;
|
||||
|
@ -8033,7 +8033,7 @@ main() {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isNotEmpty);
|
||||
|
||||
var unitElement = result.unit!.declaredElement!;
|
||||
var unitElement = result.unit.declaredElement!;
|
||||
var foo = unitElement.library.imports[0].prefix;
|
||||
|
||||
List<Statement> statements = _getMainStatements(result);
|
||||
|
@ -8117,7 +8117,7 @@ main() {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isNotEmpty);
|
||||
|
||||
var unitElement = result.unit!.declaredElement!;
|
||||
var unitElement = result.unit.declaredElement!;
|
||||
var mathImport = unitElement.library.imports[0];
|
||||
var foo = mathImport.prefix;
|
||||
|
||||
|
@ -8163,7 +8163,7 @@ main() {
|
|||
await resolveTestFile();
|
||||
expect(result.errors, isNotEmpty);
|
||||
|
||||
var unitElement = result.unit!.declaredElement!;
|
||||
var unitElement = result.unit.declaredElement!;
|
||||
var mathImport = unitElement.library.imports[0];
|
||||
var foo = mathImport.prefix;
|
||||
var randomElement = mathImport.importedLibrary!.getType('Random')!;
|
||||
|
@ -8716,7 +8716,7 @@ main() {
|
|||
}
|
||||
|
||||
List<Statement> _getMainStatements(ResolvedUnitResult result) {
|
||||
for (var declaration in result.unit!.declarations) {
|
||||
for (var declaration in result.unit.declarations) {
|
||||
if (declaration is FunctionDeclaration &&
|
||||
declaration.name.name == 'main') {
|
||||
var body = declaration.functionExpression.body as BlockFunctionBody;
|
||||
|
@ -8728,7 +8728,7 @@ main() {
|
|||
|
||||
TopLevelVariableElement _getTopLevelVariable(
|
||||
ResolvedUnitResult result, String name) {
|
||||
for (var variable in result.unit!.declaredElement!.topLevelVariables) {
|
||||
for (var variable in result.unit.declaredElement!.topLevelVariables) {
|
||||
if (variable.name == name) {
|
||||
return variable;
|
||||
}
|
||||
|
|
|
@ -448,9 +448,9 @@ part of 'lib.dart';
|
|||
ResolvedUnitResult partResult1 = await driver.getResultValid(part1);
|
||||
ResolvedUnitResult partResult2 = await driver.getResultValid(part2);
|
||||
|
||||
CompilationUnit libUnit = libResult.unit!;
|
||||
CompilationUnit partUnit1 = partResult1.unit!;
|
||||
CompilationUnit partUnit2 = partResult2.unit!;
|
||||
CompilationUnit libUnit = libResult.unit;
|
||||
CompilationUnit partUnit1 = partResult1.unit;
|
||||
CompilationUnit partUnit2 = partResult2.unit;
|
||||
|
||||
CompilationUnitElement unitElement = libUnit.declaredElement!;
|
||||
CompilationUnitElement partElement1 = partUnit1.declaredElement!;
|
||||
|
@ -676,7 +676,7 @@ var A = B;
|
|||
ResolvedUnitResult ar = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == a);
|
||||
_assertTopLevelVarType(ar.unit!, 'A', 'int');
|
||||
_assertTopLevelVarType(ar.unit, 'A', 'int');
|
||||
}
|
||||
allResults.clear();
|
||||
|
||||
|
@ -695,7 +695,7 @@ var A = B;
|
|||
ResolvedUnitResult ar = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == a);
|
||||
_assertTopLevelVarType(ar.unit!, 'A', 'double');
|
||||
_assertTopLevelVarType(ar.unit, 'A', 'double');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,14 +751,14 @@ var B1 = A1;
|
|||
ResolvedUnitResult ar = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == a);
|
||||
_assertTopLevelVarType(ar.unit!, 'A1', 'int');
|
||||
_assertTopLevelVarType(ar.unit!, 'A2', 'int');
|
||||
_assertTopLevelVarType(ar.unit, 'A1', 'int');
|
||||
_assertTopLevelVarType(ar.unit, 'A2', 'int');
|
||||
}
|
||||
{
|
||||
ResolvedUnitResult br = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == b);
|
||||
_assertTopLevelVarType(br.unit!, 'B1', 'int');
|
||||
_assertTopLevelVarType(br.unit, 'B1', 'int');
|
||||
}
|
||||
|
||||
// Clear the results and update "a".
|
||||
|
@ -778,14 +778,14 @@ var A2 = B1;
|
|||
ResolvedUnitResult ar = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == a);
|
||||
_assertTopLevelVarType(ar.unit!, 'A1', 'double');
|
||||
_assertTopLevelVarType(ar.unit!, 'A2', 'double');
|
||||
_assertTopLevelVarType(ar.unit, 'A1', 'double');
|
||||
_assertTopLevelVarType(ar.unit, 'A2', 'double');
|
||||
}
|
||||
{
|
||||
ResolvedUnitResult br = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == b);
|
||||
_assertTopLevelVarType(br.unit!, 'B1', 'double');
|
||||
_assertTopLevelVarType(br.unit, 'B1', 'double');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -798,7 +798,7 @@ var A2 = B1;
|
|||
expect(allResults, hasLength(1));
|
||||
var result = allResults[0] as ResolvedUnitResult;
|
||||
expect(result.path, testFile);
|
||||
_assertTopLevelVarType(result.unit!, 'V', 'int');
|
||||
_assertTopLevelVarType(result.unit, 'V', 'int');
|
||||
}
|
||||
|
||||
// Update the file, but don't notify the driver.
|
||||
|
@ -821,7 +821,7 @@ var A2 = B1;
|
|||
expect(allResults, hasLength(1));
|
||||
var result = allResults[0] as ResolvedUnitResult;
|
||||
expect(result.path, testFile);
|
||||
_assertTopLevelVarType(result.unit!, 'V', 'double');
|
||||
_assertTopLevelVarType(result.unit, 'V', 'double');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,7 +836,7 @@ class A {
|
|||
class C {}
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
var atD = AstFinder.getClass(result.unit!, 'C').metadata[0];
|
||||
var atD = AstFinder.getClass(result.unit, 'C').metadata[0];
|
||||
var atDI = atD.elementAnnotation as ElementAnnotationImpl;
|
||||
var value = atDI.evaluationResult!.value;
|
||||
// That is illegal.
|
||||
|
@ -853,7 +853,7 @@ class D {
|
|||
}
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
var atD = AstFinder.getClass(result.unit!, 'C').metadata[0];
|
||||
var atD = AstFinder.getClass(result.unit, 'C').metadata[0];
|
||||
var atDI = atD.elementAnnotation as ElementAnnotationImpl;
|
||||
var value = atDI.evaluationResult!.value!;
|
||||
expect(value.type, isNotNull);
|
||||
|
@ -869,7 +869,7 @@ const x = 1;
|
|||
@x class C {}
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
Annotation at_x = AstFinder.getClass(result.unit!, 'C').metadata[0];
|
||||
Annotation at_x = AstFinder.getClass(result.unit, 'C').metadata[0];
|
||||
expect(at_x.elementAnnotation!.computeConstantValue()!.toIntValue(), 1);
|
||||
}
|
||||
|
||||
|
@ -879,7 +879,7 @@ const x = y + 1;
|
|||
const y = x + 1;
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit!, 'x')
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit, 'x')
|
||||
as TopLevelVariableElementImpl;
|
||||
_expectCircularityError(x.evaluationResult!);
|
||||
}
|
||||
|
@ -890,8 +890,8 @@ const x = y + 1;
|
|||
const y = 1;
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit!, 'x');
|
||||
var y = AstFinder.getTopLevelVariableElement(result.unit!, 'y');
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit, 'x');
|
||||
var y = AstFinder.getTopLevelVariableElement(result.unit, 'y');
|
||||
expect(x.computeConstantValue()!.toIntValue(), 2);
|
||||
expect(y.computeConstantValue()!.toIntValue(), 1);
|
||||
}
|
||||
|
@ -907,7 +907,7 @@ class C extends B {
|
|||
class B {}
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit!, 'x');
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit, 'x');
|
||||
expect(x.computeConstantValue(), isNotNull);
|
||||
}
|
||||
|
||||
|
@ -973,7 +973,7 @@ class Derived extends Base {
|
|||
const x = const Derived();
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit!, 'x');
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit, 'x');
|
||||
expect(x.computeConstantValue(), isNotNull);
|
||||
}
|
||||
|
||||
|
@ -982,7 +982,7 @@ const x = const Derived();
|
|||
const x = 1;
|
||||
''');
|
||||
var result = await driver.getResultValid(testFile);
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit!, 'x');
|
||||
var x = AstFinder.getTopLevelVariableElement(result.unit, 'x');
|
||||
expect(x.computeConstantValue()!.toIntValue(), 1);
|
||||
}
|
||||
|
||||
|
@ -1528,7 +1528,7 @@ class B {}
|
|||
expect(result.unit, isNotNull);
|
||||
expect(result.errors, hasLength(0));
|
||||
|
||||
var f = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var f = result.unit.declarations[0] as FunctionDeclaration;
|
||||
assertType(f.declaredElement!.type, 'int Function()');
|
||||
assertType(f.returnType!.typeOrThrow, 'int');
|
||||
|
||||
|
@ -1673,7 +1673,7 @@ class C {
|
|||
await waitForIdleWithoutExceptions();
|
||||
|
||||
ResolvedUnitResult result = await driver.getResultValid(testFile);
|
||||
_assertClassFieldType(result.unit!, 'C', 'f', 'int');
|
||||
_assertClassFieldType(result.unit, 'C', 'f', 'int');
|
||||
}
|
||||
|
||||
test_getResult_inferTypes_instanceMethod() async {
|
||||
|
@ -1688,8 +1688,8 @@ class B extends A {
|
|||
await waitForIdleWithoutExceptions();
|
||||
|
||||
ResolvedUnitResult result = await driver.getResultValid(testFile);
|
||||
_assertClassMethodReturnType(result.unit!, 'A', 'm', 'int');
|
||||
_assertClassMethodReturnType(result.unit!, 'B', 'm', 'int');
|
||||
_assertClassMethodReturnType(result.unit, 'A', 'm', 'int');
|
||||
_assertClassMethodReturnType(result.unit, 'B', 'm', 'int');
|
||||
}
|
||||
|
||||
test_getResult_invalid_annotation_functionAsConstructor() async {
|
||||
|
@ -1701,7 +1701,7 @@ class C {}
|
|||
''', priority: true);
|
||||
|
||||
ResolvedUnitResult result = await driver.getResultValid(testFile);
|
||||
ClassDeclaration c = result.unit!.declarations[1] as ClassDeclaration;
|
||||
ClassDeclaration c = result.unit.declarations[1] as ClassDeclaration;
|
||||
Annotation a = c.metadata[0];
|
||||
expect(a.name.name, 'fff');
|
||||
expect(a.name.staticElement, isFunctionElement);
|
||||
|
@ -1788,7 +1788,7 @@ class A{}
|
|||
''');
|
||||
|
||||
var result = await driver.getResultValid(path);
|
||||
var languageVersion = result.unit!.languageVersionToken!;
|
||||
var languageVersion = result.unit.languageVersionToken!;
|
||||
expect(languageVersion.major, 2);
|
||||
expect(languageVersion.minor, 7);
|
||||
}
|
||||
|
@ -1871,7 +1871,7 @@ main() {
|
|||
|
||||
ResolvedUnitResult result = await driver.getResultValid(path);
|
||||
expect(result, isNotNull);
|
||||
expect(result.unit!.declaredElement!.classes.map((e) => e.name), ['A']);
|
||||
expect(result.unit.declaredElement!.classes.map((e) => e.name), ['A']);
|
||||
}
|
||||
|
||||
test_getResult_recursiveFlatten() async {
|
||||
|
@ -1904,18 +1904,18 @@ var VC = new A<double>();
|
|||
|
||||
{
|
||||
ResolvedUnitResult result = await driver.getResultValid(b);
|
||||
expect(_getImportSource(result.unit!, 0).uri.toString(),
|
||||
expect(_getImportSource(result.unit, 0).uri.toString(),
|
||||
'package:test/a.dart');
|
||||
_assertTopLevelVarType(result.unit!, 'VB', 'A<int>');
|
||||
_assertTopLevelVarType(result.unit, 'VB', 'A<int>');
|
||||
}
|
||||
|
||||
{
|
||||
ResolvedUnitResult result = await driver.getResultValid(c);
|
||||
expect(
|
||||
_getImportSource(result.unit!, 0).uri,
|
||||
_getImportSource(result.unit, 0).uri,
|
||||
toUri('/test/lib/a.dart'),
|
||||
);
|
||||
_assertTopLevelVarType(result.unit!, 'VC', 'A<double>');
|
||||
_assertTopLevelVarType(result.unit, 'VC', 'A<double>');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1938,8 +1938,8 @@ var B1 = A1;
|
|||
|
||||
{
|
||||
ResolvedUnitResult result = await driver.getResultValid(a);
|
||||
_assertTopLevelVarType(result.unit!, 'A1', 'int');
|
||||
_assertTopLevelVarType(result.unit!, 'A2', 'int');
|
||||
_assertTopLevelVarType(result.unit, 'A1', 'int');
|
||||
_assertTopLevelVarType(result.unit, 'A2', 'int');
|
||||
}
|
||||
|
||||
// Update "a" so that "A1" is now "double".
|
||||
|
@ -1958,8 +1958,8 @@ var A2 = B1;
|
|||
|
||||
{
|
||||
ResolvedUnitResult result = await driver.getResultValid(a);
|
||||
_assertTopLevelVarType(result.unit!, 'A1', 'double');
|
||||
_assertTopLevelVarType(result.unit!, 'A2', 'double');
|
||||
_assertTopLevelVarType(result.unit, 'A1', 'double');
|
||||
_assertTopLevelVarType(result.unit, 'A2', 'double');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2094,7 +2094,7 @@ class C {
|
|||
''');
|
||||
|
||||
var result = await driver.getResultValid(b);
|
||||
var c = _getTopLevelVar(result.unit!, 'c');
|
||||
var c = _getTopLevelVar(result.unit, 'c');
|
||||
var typeC = c.declaredElement!.type as InterfaceType;
|
||||
// The class C has an old field 'foo', not the new 'bar'.
|
||||
expect(typeC.element.getField('foo'), isNotNull);
|
||||
|
@ -2533,15 +2533,15 @@ var b = new B();
|
|||
{
|
||||
ResolvedUnitResult result = await driver.getResultValid(a);
|
||||
expect(result.errors, isEmpty);
|
||||
_assertTopLevelVarType(result.unit!, 'c', 'C');
|
||||
_assertTopLevelVarType(result.unit, 'c', 'C');
|
||||
}
|
||||
|
||||
// Now c.dart can be resolved without errors in the context of a.dart
|
||||
{
|
||||
ResolvedUnitResult result = await driver.getResultValid(c);
|
||||
expect(result.errors, isEmpty);
|
||||
_assertTopLevelVarType(result.unit!, 'a', 'A');
|
||||
_assertTopLevelVarType(result.unit!, 'b', 'B');
|
||||
_assertTopLevelVarType(result.unit, 'a', 'A');
|
||||
_assertTopLevelVarType(result.unit, 'b', 'B');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2572,8 +2572,8 @@ var b = new B();
|
|||
// So, A and B references are resolved.
|
||||
ResolvedUnitResult result = await driver.getResultValid(c);
|
||||
expect(result.errors, isEmpty);
|
||||
_assertTopLevelVarType(result.unit!, 'a', 'A');
|
||||
_assertTopLevelVarType(result.unit!, 'b', 'B');
|
||||
_assertTopLevelVarType(result.unit, 'a', 'A');
|
||||
_assertTopLevelVarType(result.unit, 'b', 'B');
|
||||
}
|
||||
|
||||
test_part_getResult_changePart_invalidatesLibraryCycle() async {
|
||||
|
@ -2883,13 +2883,13 @@ var A = B;
|
|||
ResolvedUnitResult ar = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == a);
|
||||
_assertTopLevelVarType(ar.unit!, 'A', 'int');
|
||||
_assertTopLevelVarType(ar.unit, 'A', 'int');
|
||||
}
|
||||
{
|
||||
ResolvedUnitResult br = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == b);
|
||||
_assertTopLevelVarType(br.unit!, 'B', 'int');
|
||||
_assertTopLevelVarType(br.unit, 'B', 'int');
|
||||
}
|
||||
allResults.clear();
|
||||
|
||||
|
@ -2907,7 +2907,7 @@ var A = B;
|
|||
ResolvedUnitResult ar = allResults
|
||||
.whereType<ResolvedUnitResult>()
|
||||
.firstWhere((r) => r.path == a);
|
||||
_assertTopLevelVarType(ar.unit!, 'A', 'double');
|
||||
_assertTopLevelVarType(ar.unit, 'A', 'double');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3119,7 +3119,7 @@ class F extends X {}
|
|||
expect(result.unit, isNotNull);
|
||||
expect(result.errors, hasLength(0));
|
||||
|
||||
var f = result.unit!.declarations[0] as FunctionDeclaration;
|
||||
var f = result.unit.declarations[0] as FunctionDeclaration;
|
||||
assertType(f.declaredElement!.type, 'int Function()');
|
||||
assertType(f.returnType!.typeOrThrow, 'int');
|
||||
}
|
||||
|
|
|
@ -1734,7 +1734,7 @@ mixin _IndexMixin on PubPackageResolutionTest {
|
|||
Future<void> _indexTestUnit(String code) async {
|
||||
await resolveTestCode(code);
|
||||
|
||||
var indexBuilder = indexUnit(result.unit!);
|
||||
var indexBuilder = indexUnit(result.unit);
|
||||
var indexBytes = indexBuilder.toBuffer();
|
||||
index = AnalysisDriverUnitIndex.fromBuffer(indexBytes);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class A {} // 2
|
|||
expect(node.name.name, 'A');
|
||||
expect(
|
||||
node.name.offset,
|
||||
this.result.content!.indexOf('A {} // 1'),
|
||||
this.result.content.indexOf('A {} // 1'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class A {} // 2
|
|||
expect(node.name.name, 'A');
|
||||
expect(
|
||||
node.name.offset,
|
||||
this.result.content!.indexOf('A {} // 2'),
|
||||
this.result.content.indexOf('A {} // 2'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class A {}
|
|||
await resolveTestCode(r'''
|
||||
part 'a.dart';
|
||||
''');
|
||||
var library = this.result.unit!.declaredElement!.library;
|
||||
var library = this.result.unit.declaredElement!.library;
|
||||
var element = library.getType('A')!;
|
||||
var result = await getElementDeclaration(element);
|
||||
var node = result!.node as ClassDeclaration;
|
||||
|
@ -139,7 +139,7 @@ class A {
|
|||
expect(node.name!.name, 'named');
|
||||
expect(
|
||||
node.name!.offset,
|
||||
this.result.content!.indexOf('named(); // 1'),
|
||||
this.result.content.indexOf('named(); // 1'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ class A {
|
|||
expect(node.name!.name, 'named');
|
||||
expect(
|
||||
node.name!.offset,
|
||||
this.result.content!.indexOf('named(); // 2'),
|
||||
this.result.content.indexOf('named(); // 2'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class A {
|
|||
expect(node.name, isNull);
|
||||
expect(
|
||||
node.returnType.offset,
|
||||
this.result.content!.indexOf('A(); // 1'),
|
||||
this.result.content.indexOf('A(); // 1'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ class A {
|
|||
expect(node.name, isNull);
|
||||
expect(
|
||||
node.returnType.offset,
|
||||
this.result.content!.indexOf('A(); // 2'),
|
||||
this.result.content.indexOf('A(); // 2'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class ExpectedResult {
|
|||
class SearchTest extends PubPackageResolutionTest {
|
||||
AnalysisDriver get driver => driverFor(testFilePath);
|
||||
|
||||
CompilationUnitElement get resultUnitElement => result.unit!.declaredElement!;
|
||||
CompilationUnitElement get resultUnitElement => result.unit.declaredElement!;
|
||||
|
||||
String get testUriStr => 'package:test/test.dart';
|
||||
|
||||
|
@ -378,7 +378,7 @@ class A {
|
|||
var element = findElement.unnamedConstructor('A');
|
||||
|
||||
var otherUnitResult = await driver.getResult2(other) as ResolvedUnitResult;
|
||||
CompilationUnit otherUnit = otherUnitResult.unit!;
|
||||
CompilationUnit otherUnit = otherUnitResult.unit;
|
||||
Element main = otherUnit.declaredElement!.functions[0];
|
||||
var expected = [
|
||||
ExpectedResult(main, SearchResultKind.REFERENCE,
|
||||
|
|
|
@ -91,7 +91,7 @@ class B {}
|
|||
''');
|
||||
var element = findNode.classDeclaration('A').declaredElement!;
|
||||
var resolvedUnit = (await helper.getResolvedUnitByElement(element))!;
|
||||
expect(resolvedUnit.unit!.declarations, hasLength(2));
|
||||
expect(resolvedUnit.unit.declarations, hasLength(2));
|
||||
}
|
||||
|
||||
test_getTopLevelPropertyAccessor_defined_getter() async {
|
||||
|
|
|
@ -476,8 +476,8 @@ class B2 extends X {}
|
|||
expect(aUnitResult.uri, Uri.parse('package:test/a.dart'));
|
||||
expect(aUnitResult.content, aContent);
|
||||
expect(aUnitResult.unit, isNotNull);
|
||||
expect(aUnitResult.unit!.directives, hasLength(1));
|
||||
expect(aUnitResult.unit!.declarations, hasLength(1));
|
||||
expect(aUnitResult.unit.directives, hasLength(1));
|
||||
expect(aUnitResult.unit.declarations, hasLength(1));
|
||||
expect(aUnitResult.errors, isEmpty);
|
||||
|
||||
var bUnitResult = resolvedLibrary.units[1];
|
||||
|
@ -485,8 +485,8 @@ class B2 extends X {}
|
|||
expect(bUnitResult.uri, Uri.parse('package:test/b.dart'));
|
||||
expect(bUnitResult.content, bContent);
|
||||
expect(bUnitResult.unit, isNotNull);
|
||||
expect(bUnitResult.unit!.directives, hasLength(1));
|
||||
expect(bUnitResult.unit!.declarations, hasLength(2));
|
||||
expect(bUnitResult.unit.directives, hasLength(1));
|
||||
expect(bUnitResult.unit.declarations, hasLength(2));
|
||||
expect(bUnitResult.errors, isNotEmpty);
|
||||
|
||||
var aDeclaration = resolvedLibrary.getElementDeclaration(aClass)!;
|
||||
|
@ -588,7 +588,7 @@ part 'c.dart';
|
|||
expect(result.path, testPath);
|
||||
expect(result.uri, Uri.parse('package:test/test.dart'));
|
||||
expect(result.units, hasLength(1));
|
||||
expect(result.units[0].unit!.declaredElement, isNotNull);
|
||||
expect(result.units[0].unit.declaredElement, isNotNull);
|
||||
}
|
||||
|
||||
test_getResolvedLibraryByElement2_differentSession() async {
|
||||
|
@ -617,7 +617,7 @@ class B {}
|
|||
expect(unitResult.session, session);
|
||||
expect(unitResult.path, testPath);
|
||||
expect(unitResult.uri, Uri.parse('package:test/test.dart'));
|
||||
expect(unitResult.unit!.declarations, hasLength(2));
|
||||
expect(unitResult.unit.declarations, hasLength(2));
|
||||
expect(unitResult.typeProvider, isNotNull);
|
||||
expect(unitResult.libraryElement, isNotNull);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void main() {
|
|||
test_locate_CompilationUnit() async {
|
||||
await resolveTestCode('// only comment');
|
||||
|
||||
var unitElement = result.unit!.declaredElement!;
|
||||
var unitElement = result.unit.declaredElement!;
|
||||
|
||||
var element = ElementLocator.locate(result.unit);
|
||||
expect(element, same(unitElement));
|
||||
|
|
|
@ -1218,9 +1218,6 @@ class ConstantVisitorTestSupport extends PubPackageResolutionTest {
|
|||
var expression = findNode.topVariableDeclarationByName(name).initializer!;
|
||||
|
||||
var unit = this.result.unit;
|
||||
if (unit == null) {
|
||||
throw StateError('analysis result unit is null');
|
||||
}
|
||||
var source = unit.declaredElement!.source;
|
||||
var errorListener = GatheringErrorListener();
|
||||
var errorReporter = ErrorReporter(
|
||||
|
|
|
@ -74,8 +74,8 @@ class FileResolutionTest with ResourceProviderMixin, ResolutionTest {
|
|||
Future<void> resolveTestFile() async {
|
||||
var path = convertPath(_testFile);
|
||||
result = await resolveFile(path);
|
||||
findNode = FindNode(result.content!, result.unit!);
|
||||
findElement = FindElement(result.unit!);
|
||||
findNode = FindNode(result.content, result.unit);
|
||||
findElement = FindElement(result.unit);
|
||||
}
|
||||
|
||||
void setUp() {
|
||||
|
|
|
@ -351,7 +351,7 @@ f() {
|
|||
List<String> expectedArguments,
|
||||
) {
|
||||
var argumentStrings = argumentList.arguments
|
||||
.map((e) => result.content!.substring(e.offset, e.end))
|
||||
.map((e) => result.content.substring(e.offset, e.end))
|
||||
.toList();
|
||||
expect(argumentStrings, expectedArguments);
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ f() {
|
|||
}
|
||||
|
||||
var argumentStrings = argumentList.arguments
|
||||
.map((e) => result.content!.substring(e.offset, e.end))
|
||||
.map((e) => result.content.substring(e.offset, e.end))
|
||||
.toList();
|
||||
expect(argumentStrings, expectedArguments);
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ class B extends A {
|
|||
result = await resolveFile(convertPath('$testPackageLibPath/a.dart'));
|
||||
assertErrorsInResolvedUnit(result, []);
|
||||
|
||||
var bElement = FindElement(result.unit!).field('b') as ConstVariableElement;
|
||||
var bElement = FindElement(result.unit).field('b') as ConstVariableElement;
|
||||
var bValue = bElement.evaluationResult!.value!;
|
||||
var superFields = bValue.getField(GenericState.SUPERCLASS_FIELD);
|
||||
expect(superFields!.getField('f1')!.toBoolValue(), false);
|
||||
|
|
|
@ -152,7 +152,7 @@ const x = p.C<int>();
|
|||
}
|
||||
|
||||
void _fillLibraries([LibraryElement? library]) {
|
||||
library ??= result.unit!.declaredElement!.library;
|
||||
library ??= result.unit.declaredElement!.library;
|
||||
var uriStr = library.source.uri.toString();
|
||||
if (!libraries.containsKey(uriStr)) {
|
||||
libraries[uriStr] = library;
|
||||
|
|
|
@ -924,8 +924,8 @@ mixin ResolutionTest implements ResourceProviderMixin {
|
|||
result = await resolveFile(path);
|
||||
expect(result.state, ResultState.VALID);
|
||||
|
||||
findNode = FindNode(result.content!, result.unit!);
|
||||
findElement = FindElement(result.unit!);
|
||||
findNode = FindNode(result.content, result.unit);
|
||||
findElement = FindElement(result.unit);
|
||||
}
|
||||
|
||||
/// Create a new file with the [path] and [content], resolve it into [result].
|
||||
|
|
|
@ -1102,7 +1102,7 @@ void f() sync* {
|
|||
Future<void> _assertHasReturn(String code, int n, bool expected) async {
|
||||
await resolveTestCode(code);
|
||||
|
||||
var function = result.unit!.declarations.last as FunctionDeclaration;
|
||||
var function = result.unit.declarations.last as FunctionDeclaration;
|
||||
var body = function.functionExpression.body as BlockFunctionBody;
|
||||
Statement statement = body.block.statements[n];
|
||||
expect(ExitDetector.exits(statement), expected);
|
||||
|
|
|
@ -111,7 +111,7 @@ mixin DirectoryAddOnsMixin implements Directory {}
|
|||
error(HintCode.UNUSED_ELEMENT, 96, 15),
|
||||
]);
|
||||
var mixins =
|
||||
result.unit!.declaredElement!.getType('_LocalDirectory')!.mixins;
|
||||
result.unit.declaredElement!.getType('_LocalDirectory')!.mixins;
|
||||
assertType(mixins[0], 'ForwardingDirectory<_LocalDirectory>');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ void main() {}
|
|||
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 65, 3),
|
||||
]);
|
||||
// Instantiate-to-bounds should have instantiated "Bar" to "Bar<Foo>".
|
||||
assertType(result.unit!.declaredElement!.getType('Baz')!.supertype,
|
||||
assertType(result.unit.declaredElement!.getType('Baz')!.supertype,
|
||||
'Bar<Foo<dynamic>>');
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ abstract class AbstractLinterContextTest extends PubPackageResolutionTest {
|
|||
|
||||
Future<void> resolve(String content) async {
|
||||
await resolveTestCode(content);
|
||||
var contextUnit = LinterContextUnit(result.content!, result.unit!);
|
||||
var contextUnit = LinterContextUnit(result.content, result.unit);
|
||||
|
||||
final libraryElement = result.libraryElement;
|
||||
final analysisContext = libraryElement.session.analysisContext;
|
||||
|
|
|
@ -347,8 +347,8 @@ main() {
|
|||
}
|
||||
|
||||
void _assertTypeAnnotations() {
|
||||
var code = result.content!;
|
||||
var unit = result.unit!;
|
||||
var code = result.content;
|
||||
var unit = result.unit;
|
||||
|
||||
var types = <int, String>{};
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class InferredTypeTest extends PubPackageResolutionTest
|
|||
// TODO(https://github.com/dart-lang/sdk/issues/44666): Use null safety in
|
||||
// test cases.
|
||||
CompilationUnitElement get _resultUnitElement {
|
||||
return result.unit!.declaredElement!;
|
||||
return result.unit.declaredElement!;
|
||||
}
|
||||
|
||||
test_asyncClosureReturnType_flatten() async {
|
||||
|
|
|
@ -196,7 +196,7 @@ Future<TestResult<T>> runTestForConfig<T>(
|
|||
});
|
||||
} else {
|
||||
String _formatError(AnalysisError e) {
|
||||
var locationInfo = result.unit!.lineInfo!.getLocation(e.offset);
|
||||
var locationInfo = result.unit.lineInfo!.getLocation(e.offset);
|
||||
return '$locationInfo: ${e.errorCode}: ${e.message}';
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ Future<TestResult<T>> runTestForConfig<T>(
|
|||
|
||||
results.forEach((testUri, result) {
|
||||
dataComputer.computeUnitData(
|
||||
driver.testingData!, result.unit!, actualMapFor(testUri));
|
||||
driver.testingData!, result.unit, actualMapFor(testUri));
|
||||
});
|
||||
var compiledData = AnalyzerCompiledData<T>(
|
||||
testData.code, testData.entryPoint, actualMaps, globalData);
|
||||
|
|
|
@ -27,7 +27,7 @@ mixin DartNavigationMixin implements NavigationMixin {
|
|||
var length = parameters.length;
|
||||
if (offset < 0 && length < 0) {
|
||||
offset = 0;
|
||||
length = result.content?.length ?? 0;
|
||||
length = result.content.length;
|
||||
}
|
||||
return DartNavigationRequestImpl(resourceProvider, offset, length, result);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ class ChangeBuilderImpl implements ChangeBuilder {
|
|||
}
|
||||
var timeStamp = result.exists ? 0 : -1;
|
||||
|
||||
var declaredUnit = result.unit?.declaredElement;
|
||||
var declaredUnit = result.unit.declaredElement;
|
||||
var libraryUnit = declaredUnit?.library.definingCompilationUnit;
|
||||
|
||||
DartFileEditBuilderImpl? libraryEditBuilder;
|
||||
|
|
|
@ -1353,7 +1353,7 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
|
|||
|
||||
@override
|
||||
void format(SourceRange range) {
|
||||
var newContent = resolvedUnit.content!;
|
||||
var newContent = resolvedUnit.content;
|
||||
var newRangeOffset = range.offset;
|
||||
var newRangeLength = range.length;
|
||||
for (var edit in fileEdit.edits) {
|
||||
|
@ -1437,7 +1437,7 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
|
|||
LibraryDirective? libraryDirective;
|
||||
var importDirectives = <ImportDirective>[];
|
||||
PartDirective? partDirective;
|
||||
var unit = resolvedUnit.unit!;
|
||||
var unit = resolvedUnit.unit;
|
||||
for (var directive in unit.directives) {
|
||||
if (directive is LibraryDirective) {
|
||||
libraryDirective = directive;
|
||||
|
|
|
@ -35,7 +35,7 @@ class InheritedReferenceContributor
|
|||
Future<void> computeSuggestions(
|
||||
DartCompletionRequest request, CompletionCollector collector) async {
|
||||
var target =
|
||||
CompletionTarget.forOffset(request.result.unit!, request.offset);
|
||||
CompletionTarget.forOffset(request.result.unit, request.offset);
|
||||
var optype = OpType.forCompletion(target, request.offset);
|
||||
if (!optype.includeIdentifiers) {
|
||||
return;
|
||||
|
@ -59,7 +59,7 @@ class InheritedReferenceContributor
|
|||
CompletionTarget? target,
|
||||
OpType? optype,
|
||||
}) async {
|
||||
target ??= CompletionTarget.forOffset(request.result.unit!, request.offset,
|
||||
target ??= CompletionTarget.forOffset(request.result.unit, request.offset,
|
||||
entryPoint: entryPoint);
|
||||
optype ??= OpType.forCompletion(target, request.offset);
|
||||
if (!optype.includeIdentifiers) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class TypeMemberContributor implements CompletionContributor {
|
|||
Expression? _computeDotTarget(
|
||||
DartCompletionRequest request, AstNode? entryPoint) {
|
||||
var target = CompletionTarget.forOffset(
|
||||
request.result.unit!, request.offset,
|
||||
request.result.unit, request.offset,
|
||||
entryPoint: entryPoint);
|
||||
var node = target.containingNode;
|
||||
if (node is MethodInvocation) {
|
||||
|
|
|
@ -790,7 +790,7 @@ class MyClass {}''';
|
|||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
|
||||
var A = unit?.declarations[1] as ClassDeclaration;
|
||||
var A = unit.declarations[1] as ClassDeclaration;
|
||||
|
||||
var builder = newBuilder();
|
||||
await builder.addDartFileEdit(path, (builder) {
|
||||
|
@ -821,7 +821,7 @@ class MyClass {}''';
|
|||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
|
||||
var A = unit?.declarations[1] as ClassDeclaration;
|
||||
var A = unit.declarations[1] as ClassDeclaration;
|
||||
|
||||
var builder = newBuilder();
|
||||
await builder.addDartFileEdit(path, (builder) {
|
||||
|
@ -857,7 +857,7 @@ class MyClass {}''';
|
|||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
|
||||
var A = unit?.declarations[1] as ClassDeclaration;
|
||||
var A = unit.declarations[1] as ClassDeclaration;
|
||||
|
||||
var builder = newBuilder();
|
||||
await builder.addDartFileEdit(path, (builder) {
|
||||
|
@ -1026,7 +1026,7 @@ class A {}
|
|||
''';
|
||||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
var g = unit?.declarations[1] as FunctionDeclaration;
|
||||
var g = unit.declarations[1] as FunctionDeclaration;
|
||||
var body = g.functionExpression.body as BlockFunctionBody;
|
||||
var statement = body.block.statements[0] as ExpressionStatement;
|
||||
var invocation = statement.expression as MethodInvocation;
|
||||
|
@ -1048,7 +1048,7 @@ class A {}
|
|||
addSource(path, content);
|
||||
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
var f = unit?.declarations[0] as FunctionDeclaration;
|
||||
var f = unit.declarations[0] as FunctionDeclaration;
|
||||
var parameters = f.functionExpression.parameters;
|
||||
var elements = parameters?.parameters.map((p) => p.declaredElement!);
|
||||
|
||||
|
@ -1068,7 +1068,7 @@ class A {}
|
|||
var content = 'f(int a, [bool b = false, String c]) {}';
|
||||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
var f = unit?.declarations[0] as FunctionDeclaration;
|
||||
var f = unit.declarations[0] as FunctionDeclaration;
|
||||
var parameters = f.functionExpression.parameters;
|
||||
var elements = parameters?.parameters.map((p) => p.declaredElement!);
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ class A {}
|
|||
var content = 'f(int i, String s) {}';
|
||||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
var f = unit?.declarations[0] as FunctionDeclaration;
|
||||
var f = unit.declarations[0] as FunctionDeclaration;
|
||||
var parameters = f.functionExpression.parameters;
|
||||
var elements = parameters?.parameters.map((p) => p.declaredElement!);
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ f(int i, String s) {
|
|||
}''';
|
||||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
var f = unit?.declarations[0] as FunctionDeclaration;
|
||||
var f = unit.declarations[0] as FunctionDeclaration;
|
||||
var body = f.functionExpression.body as BlockFunctionBody;
|
||||
var statement = body.block.statements[0] as ExpressionStatement;
|
||||
var invocation = statement.expression as MethodInvocation;
|
||||
|
@ -1133,7 +1133,7 @@ f(int i, String s) {
|
|||
}''';
|
||||
addSource(path, content);
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
var f = unit?.declarations[0] as FunctionDeclaration;
|
||||
var f = unit.declarations[0] as FunctionDeclaration;
|
||||
var body = f.functionExpression.body as BlockFunctionBody;
|
||||
var statement = body.block.statements[0] as ExpressionStatement;
|
||||
var invocation = statement.expression as MethodInvocation;
|
||||
|
@ -1330,7 +1330,7 @@ import 'a.dart' as p;
|
|||
var builder = newBuilder();
|
||||
await builder.addDartFileEdit(path, (builder) {
|
||||
builder.addInsertion(content.length - 1, (builder) {
|
||||
var typeProvider = unit!.declaredElement!.library.typeProvider;
|
||||
var typeProvider = unit.declaredElement!.library.typeProvider;
|
||||
builder.writeType(typeProvider.dynamicType);
|
||||
});
|
||||
});
|
||||
|
@ -1543,7 +1543,7 @@ class B {}
|
|||
var builder = newBuilder();
|
||||
await builder.addDartFileEdit(path, (builder) {
|
||||
builder.addInsertion(content.length - 1, (builder) {
|
||||
var typeProvider = unit!.declaredElement!.library.typeProvider;
|
||||
var typeProvider = unit.declaredElement!.library.typeProvider;
|
||||
builder.writeType(typeProvider.dynamicType, required: true);
|
||||
});
|
||||
});
|
||||
|
@ -1690,13 +1690,13 @@ class B {}
|
|||
|
||||
Future<ClassElement> _getClassElement(String path, String name) async {
|
||||
var result = (await resolveFile(path)).unit;
|
||||
return result!.declaredElement!.getType(name)!;
|
||||
return result.declaredElement!.getType(name)!;
|
||||
}
|
||||
|
||||
Future<PropertyAccessorElement> _getTopLevelAccessorElement(
|
||||
String path, String name) async {
|
||||
var result = (await resolveFile(path)).unit;
|
||||
return result!.declaredElement!.accessors.firstWhere((v) => v.name == name);
|
||||
return result.declaredElement!.accessors.firstWhere((v) => v.name == name);
|
||||
}
|
||||
|
||||
Future<InterfaceType> _getType(
|
||||
|
@ -1720,7 +1720,7 @@ class DartFileEditBuilderImplTest extends AbstractContextTest
|
|||
addSource(path, '''var f = () {}''');
|
||||
|
||||
var resolvedUnit = await resolveFile(path);
|
||||
var findNode = FindNode(resolvedUnit.content!, resolvedUnit.unit!);
|
||||
var findNode = FindNode(resolvedUnit.content, resolvedUnit.unit);
|
||||
var body = findNode.functionBody('{}');
|
||||
|
||||
var builder = newBuilder();
|
||||
|
@ -1737,7 +1737,7 @@ class DartFileEditBuilderImplTest extends AbstractContextTest
|
|||
addSource(path, 'String f() {}');
|
||||
|
||||
var resolvedUnit = await resolveFile(path);
|
||||
var findNode = FindNode(resolvedUnit.content!, resolvedUnit.unit!);
|
||||
var findNode = FindNode(resolvedUnit.content, resolvedUnit.unit);
|
||||
var body = findNode.functionBody('{}');
|
||||
|
||||
var builder = newBuilder();
|
||||
|
@ -1850,7 +1850,7 @@ void functionAfter() {
|
|||
addSource(path, 'String f() {}');
|
||||
|
||||
var resolvedUnit = await resolveFile(path);
|
||||
var findNode = FindNode(resolvedUnit.content!, resolvedUnit.unit!);
|
||||
var findNode = FindNode(resolvedUnit.content, resolvedUnit.unit);
|
||||
var type = findNode.typeAnnotation('String');
|
||||
|
||||
var builder = newBuilder();
|
||||
|
@ -1873,7 +1873,7 @@ class B extends A {}
|
|||
class C extends B {}
|
||||
''');
|
||||
var unit = (await resolveFile(path)).unit;
|
||||
var classC = unit?.declarations[2] as ClassDeclaration;
|
||||
var classC = unit.declarations[2] as ClassDeclaration;
|
||||
var builder = DartLinkedEditBuilderImpl(MockEditBuilderImpl());
|
||||
builder.addSuperTypesAsSuggestions(
|
||||
classC.declaredElement?.instantiate(
|
||||
|
@ -2895,10 +2895,10 @@ class B extends A {
|
|||
{
|
||||
var unitResult = (await resolveFile(path)).unit;
|
||||
if (targetMixinName != null) {
|
||||
targetElement = unitResult!.declaredElement!.mixins
|
||||
targetElement = unitResult.declaredElement!.mixins
|
||||
.firstWhere((e) => e.name == targetMixinName);
|
||||
} else {
|
||||
targetElement = unitResult!.declaredElement!.classes
|
||||
targetElement = unitResult.declaredElement!.classes
|
||||
.firstWhere((e) => e.name == targetClassName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -954,9 +954,9 @@ class _Base extends AbstractContextTest {
|
|||
newFile(path, content: content);
|
||||
|
||||
var result = await resolveFile(path);
|
||||
findElement = FindElement(result.unit!);
|
||||
findElement = FindElement(result.unit);
|
||||
|
||||
target = CompletionTarget.forOffset(result.unit!, offset!);
|
||||
target = CompletionTarget.forOffset(result.unit, offset!);
|
||||
}
|
||||
|
||||
static String _executableNameStr(ExecutableElement executable) {
|
||||
|
|
|
@ -50,7 +50,7 @@ abstract class AbstractOpTypeTest extends AbstractContextTest {
|
|||
//
|
||||
var resolvedUnit = await resolveFile(testPath);
|
||||
var completionTarget =
|
||||
CompletionTarget.forOffset(resolvedUnit.unit!, completionOffset);
|
||||
CompletionTarget.forOffset(resolvedUnit.unit, completionOffset);
|
||||
var opType = OpType.forCompletion(completionTarget, completionOffset);
|
||||
//
|
||||
// Validate the OpType.
|
||||
|
|
|
@ -95,8 +95,8 @@ class AbstractSingleUnitTest extends AbstractContextTest {
|
|||
|
||||
Future<void> resolveTestFile() async {
|
||||
var result = await resolveFile(testFile);
|
||||
testCode = result.content!;
|
||||
testUnit = result.unit!;
|
||||
testCode = result.content;
|
||||
testUnit = result.unit;
|
||||
if (verifyNoTestUnitErrors) {
|
||||
expect(result.errors.where((AnalysisError error) {
|
||||
return error.errorCode != HintCode.DEAD_CODE &&
|
||||
|
|
|
@ -418,7 +418,7 @@ abstract class DartCompletionContributorTest extends AbstractContextTest {
|
|||
DartCompletionRequestImpl(resourceProvider, completionOffset!, result);
|
||||
|
||||
var target =
|
||||
CompletionTarget.forOffset(request!.result.unit!, request!.offset);
|
||||
CompletionTarget.forOffset(request!.result.unit, request!.offset);
|
||||
var range = target.computeReplacementRange(request!.offset);
|
||||
replacementOffset = range.offset;
|
||||
replacementLength = range.length;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue