Skip to content

Commit

Permalink
turn on implicit casts, fix Page.reload
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Jun 17, 2019
1 parent 611718d commit f7c21c3
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 169 deletions.
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
analyzer:
errors:
deprecated_member_use_from_same_package: ignore
strong-mode:
implicit-casts: false
9 changes: 5 additions & 4 deletions bin/multiplex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ main(List<String> argv) async {

hierarchicalLoggingEnabled = true;

if (args['verbose']) {
if (args['verbose'] == true) {
Logger.root.level = Level.ALL;
} else {
Logger.root.level = Level.WARNING;
Expand All @@ -33,7 +33,8 @@ main(List<String> argv) async {
stderr.writeln('${rec.level.name}: ${rec.time}: ${rec.message}');
});

var cr =
new ChromeConnection(args['chrome_host'], int.parse(args['chrome_port']));
new Server(int.parse(args['listen_port']), cr, modelDom: args['model_dom']);
var cr = new ChromeConnection(
args['chrome_host'] as String, int.parse(args['chrome_port'] as String));
new Server(int.parse(args['listen_port'] as String), cr,
modelDom: args['model_dom'] as bool);
}
8 changes: 4 additions & 4 deletions lib/forwarder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WipForwarder {
final StreamController<Null> _closedController =
new StreamController.broadcast();

factory WipForwarder(WipConnection debugger, Stream stream,
factory WipForwarder(WipConnection debugger, Stream<String> stream,
{StreamSink sink, WipDom domModel}) {
if (sink == null) {
sink = stream as StreamSink;
Expand All @@ -52,8 +52,8 @@ class WipForwarder {
var response = {'id': json['id']};
_log.info('Forwarding to debugger: $data');
try {
String method = json['method'];
Map<String, dynamic> params = json['params'];
var method = json['method'] as String;
var params = json['params'] as Map<String, dynamic>;
bool processed = false;

if (method.contains('reakpoint')) {
Expand All @@ -68,7 +68,7 @@ class WipForwarder {
break;
case 'DOM.getAttributes':
var attributes = flattenAttributesMap(
await domModel.getAttributes(params['nodeId']));
await domModel.getAttributes(params['nodeId'] as int));
response['result'] = {'attributes': attributes};
processed = true;
break;
Expand Down
10 changes: 6 additions & 4 deletions lib/multiplex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:logging/logging.dart' show Logger;
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_web_socket/shelf_web_socket.dart' as ws;
import 'package:web_socket_channel/web_socket_channel.dart'
show WebSocketChannel;
import 'package:webkit_inspection_protocol/dom_model.dart' show WipDomModel;
import 'package:webkit_inspection_protocol/forwarder.dart' show WipForwarder;
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
Expand Down Expand Up @@ -124,19 +126,19 @@ class Server {
}
_log.info('connecting to websocket: ${request.url}');

return ws.webSocketHandler((ws) async {
return ws.webSocketHandler((WebSocketChannel webSocket) async {
var debugger = await _connections.putIfAbsent(path[2], () async {
var tab = await chrome.getTab((tab) => tab.id == path[2]);
return WipConnection.connect(tab.webSocketDebuggerUrl);
});
var dom;
WipDomModel dom;
if (modelDom) {
dom = await _modelDoms.putIfAbsent(path[2], () {
return new WipDomModel(debugger.dom);
});
}
var forwarder =
new WipForwarder(debugger, ws.stream, sink: ws.sink, domModel: dom);
var forwarder = new WipForwarder(debugger, webSocket.stream.cast(),
sink: webSocket.sink, domModel: dom);
debugger.onClose.listen((_) {
_connections.remove(path[2]);
_modelDoms.remove(path[2]);
Expand Down
22 changes: 11 additions & 11 deletions lib/src/console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ class WipConsole extends WipDomain {
class ConsoleMessageEvent extends WrappedWipEvent {
ConsoleMessageEvent(WipEvent event) : super(event);

Map get _message => params['message'];
Map get _message => params['message'] as Map;

String get text => _message['text'];
String get level => _message['level'];
String get url => _message['url'];
String get text => _message['text'] as String;
String get level => _message['level'] as String;
String get url => _message['url'] as String;

Iterable<WipConsoleCallFrame> getStackTrace() {
if (_message.containsKey('stackTrace')) {
return params['stackTrace']
.map((frame) => new WipConsoleCallFrame.fromMap(frame));
return (params['stackTrace'] as List).map((frame) =>
new WipConsoleCallFrame.fromMap(frame as Map<String, dynamic>));
} else {
return [];
}
Expand All @@ -51,9 +51,9 @@ class WipConsoleCallFrame {

WipConsoleCallFrame.fromMap(this._map);

int get columnNumber => _map['columnNumber'];
String get functionName => _map['functionName'];
int get lineNumber => _map['lineNumber'];
String get scriptId => _map['scriptId'];
String get url => _map['url'];
int get columnNumber => _map['columnNumber'] as int;
String get functionName => _map['functionName'] as String;
int get lineNumber => _map['lineNumber'] as int;
String get scriptId => _map['scriptId'] as String;
String get url => _map['url'] as String;
}
59 changes: 31 additions & 28 deletions lib/src/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WipDebugger extends WipDomain {
Future<String> getScriptSource(String scriptId) async =>
(await sendCommand('Debugger.getScriptSource',
params: {'scriptId': scriptId}))
.result['scriptSource'];
.result['scriptSource'] as String;

Future pause() => sendCommand('Debugger.pause');
Future resume() => sendCommand('Debugger.resume');
Expand Down Expand Up @@ -85,11 +85,11 @@ class DebuggerResumedEvent extends WrappedWipEvent {
class DebuggerPausedEvent extends WrappedWipEvent {
DebuggerPausedEvent(WipEvent event) : super(event);

String get reason => params['reason'];
String get reason => params['reason'] as String;
Object get data => params['data'];

Iterable<WipCallFrame> getCallFrames() =>
params['callFrames'].map((frame) => new WipCallFrame(frame));
Iterable<WipCallFrame> getCallFrames() => (params['callFrames'] as List)
.map((frame) => new WipCallFrame(frame as Map<String, dynamic>));

String toString() => 'paused: ${reason}';
}
Expand All @@ -99,13 +99,15 @@ class WipCallFrame {

WipCallFrame(this._map);

String get callFrameId => _map['callFrameId'];
String get functionName => _map['functionName'];
WipLocation get location => new WipLocation(_map['location']);
WipRemoteObject get thisObject => new WipRemoteObject(_map['this']);
String get callFrameId => _map['callFrameId'] as String;
String get functionName => _map['functionName'] as String;
WipLocation get location =>
new WipLocation(_map['location'] as Map<String, dynamic>);
WipRemoteObject get thisObject =>
new WipRemoteObject(_map['this'] as Map<String, dynamic>);

Iterable<WipScope> getScopeChain() =>
_map['scopeChain'].map((scope) => new WipScope(scope));
Iterable<WipScope> getScopeChain() => (_map['scopeChain'] as List)
.map((scope) => new WipScope(scope as Map<String, dynamic>));

String toString() => '[${functionName}]';
}
Expand All @@ -115,9 +117,9 @@ class WipLocation {

WipLocation(this._map);

int get columnNumber => _map['columnNumber'];
int get lineNumber => _map['lineNumber'];
String get scriptId => _map['scriptId'];
int get columnNumber => _map['columnNumber'] as int;
int get lineNumber => _map['lineNumber'] as int;
String get scriptId => _map['scriptId'] as String;

String toString() => '[${scriptId}:${lineNumber}:${columnNumber}]';
}
Expand All @@ -127,11 +129,11 @@ class WipRemoteObject {

WipRemoteObject(this._map);

String get className => _map['className'];
String get description => _map['description'];
String get objectId => _map['objectId'];
String get subtype => _map['subtype'];
String get type => _map['type'];
String get className => _map['className'] as String;
String get description => _map['description'] as String;
String get objectId => _map['objectId'] as String;
String get subtype => _map['subtype'] as String;
String get type => _map['type'] as String;
Object get value => _map['value'];
}

Expand All @@ -140,14 +142,14 @@ class WipScript {

WipScript(this._map);

String get scriptId => _map['scriptId'];
String get url => _map['url'];
int get startLine => _map['startLine'];
int get startColumn => _map['startColumn'];
int get endLine => _map['endLine'];
int get endColumn => _map['endColumn'];
bool get isContentScript => _map['isContentScript'];
String get sourceMapURL => _map['sourceMapURL'];
String get scriptId => _map['scriptId'] as String;
String get url => _map['url'] as String;
int get startLine => _map['startLine'] as int;
int get startColumn => _map['startColumn'] as int;
int get endLine => _map['endLine'] as int;
int get endColumn => _map['endColumn'] as int;
bool get isContentScript => _map['isContentScript'] as bool;
String get sourceMapURL => _map['sourceMapURL'] as String;

String toString() => '[script ${scriptId}: ${url}]';
}
Expand All @@ -158,12 +160,13 @@ class WipScope {
WipScope(this._map);

// "catch", "closure", "global", "local", "with"
String get scope => _map['scope'];
String get scope => _map['scope'] as String;

/**
* Object representing the scope. For global and with scopes it represents the
* actual object; for the rest of the scopes, it is artificial transient
* object enumerating scope variables as its properties.
*/
WipRemoteObject get object => new WipRemoteObject(_map['object']);
WipRemoteObject get object =>
new WipRemoteObject(_map['object'] as Map<String, dynamic>);
}
Loading

0 comments on commit f7c21c3

Please sign in to comment.