Revert "When parts of the program are changed in a hot reload, but not executed during the reassemble, warn that a restart may be needed. (#12304)" (#12406)
This reverts commit 90028813a89a3de8154144e6e0f1edbe90dc2e4f. This change caused a few bots to fail with 'JSON-RPC error 110: Extension error', which is odd because _getUnusedChangesInLastReload is not an extension.
This commit is contained in:
parent
90028813a8
commit
5e7bcbacf8
@ -339,16 +339,6 @@ class DevFS {
|
||||
Uri _baseUri;
|
||||
Uri get baseUri => _baseUri;
|
||||
|
||||
Uri deviceUriToHostUri(Uri deviceUri) {
|
||||
final String deviceUriString = deviceUri.toString();
|
||||
final String baseUriString = baseUri.toString();
|
||||
if (deviceUriString.startsWith(baseUriString)) {
|
||||
final String deviceUriSuffix = deviceUriString.substring(baseUriString.length);
|
||||
return rootDirectory.uri.resolve(deviceUriSuffix);
|
||||
}
|
||||
return deviceUri;
|
||||
}
|
||||
|
||||
Future<Uri> create() async {
|
||||
printTrace('DevFS: Creating new filesystem on the device ($_baseUri)');
|
||||
try {
|
||||
|
@ -139,26 +139,6 @@ class FlutterDevice {
|
||||
return reports;
|
||||
}
|
||||
|
||||
// Lists program elements changed in the most recent reload that have not
|
||||
// since executed.
|
||||
Future<List<ProgramElement>> unusedChangesInLastReload() async {
|
||||
final List<Future<List<ProgramElement>>> reports =
|
||||
<Future<List<ProgramElement>>>[];
|
||||
for (FlutterView view in views) {
|
||||
reports.add(view.uiIsolate.getUnusedChangesInLastReload());
|
||||
}
|
||||
final List<ProgramElement> elements = <ProgramElement>[];
|
||||
for (Future<List<ProgramElement>> report in reports) {
|
||||
for (ProgramElement element in await report) {
|
||||
elements.add(new ProgramElement(element.qualifiedName,
|
||||
devFS.deviceUriToHostUri(element.uri),
|
||||
element.line,
|
||||
element.column));
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
Future<Null> debugDumpApp() async {
|
||||
for (FlutterView view in views)
|
||||
await view.uiIsolate.flutterDebugDumpApp();
|
||||
@ -825,15 +805,14 @@ abstract class ResidentRunner {
|
||||
}
|
||||
|
||||
class OperationResult {
|
||||
OperationResult(this.code, this.message, [this.hint]);
|
||||
static final OperationResult ok = new OperationResult(0, '');
|
||||
|
||||
OperationResult(this.code, this.message);
|
||||
|
||||
final int code;
|
||||
final String message;
|
||||
final String hint;
|
||||
|
||||
bool get isOk => code == 0;
|
||||
|
||||
static final OperationResult ok = new OperationResult(0, '');
|
||||
}
|
||||
|
||||
/// Given the value of the --target option, return the path of the Dart file
|
||||
|
@ -426,8 +426,6 @@ class HotRunner extends ResidentRunner {
|
||||
status.cancel();
|
||||
if (result.isOk)
|
||||
printStatus("${result.message} in ${getElapsedAsMilliseconds(timer.elapsed)}.");
|
||||
if (result.hint != null)
|
||||
printStatus(result.hint);
|
||||
return result;
|
||||
} catch (error) {
|
||||
status.cancel();
|
||||
@ -436,14 +434,6 @@ class HotRunner extends ResidentRunner {
|
||||
}
|
||||
}
|
||||
|
||||
String _uriToRelativePath(Uri uri) {
|
||||
final String path = uri.toString();
|
||||
final String base = new Uri.file(projectRootPath).toString();
|
||||
if (path.startsWith(base))
|
||||
return path.substring(base.length + 1);
|
||||
return path;
|
||||
}
|
||||
|
||||
Future<OperationResult> _reloadSources({ bool pause: false }) async {
|
||||
for (FlutterDevice device in flutterDevices) {
|
||||
for (FlutterView view in device.views) {
|
||||
@ -632,41 +622,9 @@ class HotRunner extends ResidentRunner {
|
||||
!reassembleTimedOut &&
|
||||
shouldReportReloadTime)
|
||||
flutterUsage.sendTiming('hot', 'reload', reloadTimer.elapsed);
|
||||
|
||||
String unusedElementMessage;
|
||||
if (!reassembleAndScheduleErrors && !reassembleTimedOut) {
|
||||
final List<Future<List<ProgramElement>>> unusedReports =
|
||||
<Future<List<ProgramElement>>>[];
|
||||
for (FlutterDevice device in flutterDevices)
|
||||
unusedReports.add(device.unusedChangesInLastReload());
|
||||
final List<ProgramElement> unusedElements = <ProgramElement>[];
|
||||
for (Future<List<ProgramElement>> unusedReport in unusedReports)
|
||||
unusedElements.addAll(await unusedReport);
|
||||
|
||||
if (unusedElements.isNotEmpty) {
|
||||
unusedElementMessage =
|
||||
'\nThe following program elements were changed by the reload, '
|
||||
'but did not run when the view was reassembled. If this code '
|
||||
'only runs at start-up, you will need to restart ("R") for '
|
||||
'the changes to have an effect.';
|
||||
for (ProgramElement unusedElement in unusedElements) {
|
||||
final String name = unusedElement.qualifiedName;
|
||||
final String path = _uriToRelativePath(unusedElement.uri);
|
||||
final int line = unusedElement.line;
|
||||
String elementDescription;
|
||||
if (line == null) {
|
||||
elementDescription = '$name ($path)';
|
||||
} else {
|
||||
elementDescription = '$name ($path:$line)';
|
||||
}
|
||||
unusedElementMessage += '\n - $elementDescription';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new OperationResult(
|
||||
reassembleAndScheduleErrors ? 1 : OperationResult.ok.code,
|
||||
reloadMessage, unusedElementMessage
|
||||
reloadMessage
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -897,25 +897,6 @@ class HeapSpace extends ServiceObject {
|
||||
}
|
||||
}
|
||||
|
||||
// A function, field or class along with its source location.
|
||||
class ProgramElement {
|
||||
ProgramElement(this.qualifiedName, this.uri, this.line, this.column);
|
||||
|
||||
final String qualifiedName;
|
||||
final Uri uri;
|
||||
final int line;
|
||||
final int column;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (line == null) {
|
||||
return '$qualifiedName ($uri)';
|
||||
} else {
|
||||
return '$qualifiedName ($uri:$line)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An isolate running inside the VM. Instances of the Isolate class are always
|
||||
/// canonicalized.
|
||||
class Isolate extends ServiceObjectOwner {
|
||||
@ -1048,58 +1029,6 @@ class Isolate extends ServiceObjectOwner {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getObject(Map<String, dynamic> objectRef) {
|
||||
return invokeRpcRaw('getObject',
|
||||
params: <String, dynamic>{'objectId': objectRef['id']});
|
||||
}
|
||||
|
||||
Future<ProgramElement> _describeElement(Map<String, dynamic> elementRef) async {
|
||||
String name = elementRef['name'];
|
||||
Map<String, dynamic> owner = elementRef['owner'];
|
||||
while (owner != null) {
|
||||
final String ownerType = owner['type'];
|
||||
if (ownerType == 'Library' || ownerType == '@Library')
|
||||
break;
|
||||
final String ownerName = owner['name'];
|
||||
name = "$ownerName.$name";
|
||||
owner = owner['owner'];
|
||||
}
|
||||
|
||||
final Map<String, dynamic> fullElement = await getObject(elementRef);
|
||||
final Map<String, dynamic> location = fullElement['location'];
|
||||
final int tokenPos = location['tokenPos'];
|
||||
final Map<String, dynamic> script = await getObject(location['script']);
|
||||
|
||||
// The engine's tag handler doesn't seem to create proper URIs.
|
||||
Uri uri = Uri.parse(script['uri']);
|
||||
if (uri.scheme == '')
|
||||
uri = uri.replace(scheme: 'file');
|
||||
|
||||
// See https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md
|
||||
for (List<int> lineTuple in script['tokenPosTable']) {
|
||||
final int line = lineTuple[0];
|
||||
for (int i = 1; i < lineTuple.length; i += 2) {
|
||||
if (lineTuple[i] == tokenPos) {
|
||||
final int column = lineTuple[i + 1];
|
||||
return new ProgramElement(name, uri, line, column);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ProgramElement(name, uri, null, null);
|
||||
}
|
||||
|
||||
// Lists program elements changed in the most recent reload that have not
|
||||
// since executed.
|
||||
Future<List<ProgramElement>> getUnusedChangesInLastReload() async {
|
||||
final Map<String, dynamic> response =
|
||||
await invokeRpcRaw('_getUnusedChangesInLastReload');
|
||||
final List<Future<ProgramElement>> unusedElements =
|
||||
<Future<ProgramElement>>[];
|
||||
for (Map<String, dynamic> element in response['unused'])
|
||||
unusedElements.add(_describeElement(element));
|
||||
return Future.wait(unusedElements);
|
||||
}
|
||||
|
||||
/// Resumes the isolate.
|
||||
Future<Map<String, dynamic>> resume() {
|
||||
return invokeRpcRaw('resume');
|
||||
|
Loading…
x
Reference in New Issue
Block a user