Skip to content

Commit

Permalink
Partial static mode changes for vm-service and tests (part 3).
Browse files Browse the repository at this point in the history
Bug: #31587
Change-Id: I812fd4cd8e74875ce7ada9886035137af2fef73a
Reviewed-on: https://dart-review.googlesource.com/33100
Reviewed-by: Siva Annamalai <asiva@google.com>
  • Loading branch information
rmacnak-google committed Jan 9, 2018
1 parent 19920f0 commit 6ccd7b8
Show file tree
Hide file tree
Showing 42 changed files with 385 additions and 455 deletions.
2 changes: 1 addition & 1 deletion runtime/lib/developer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ _runExtension(
SendPort replyPort,
Object id,
bool trace_service) {
var parameters = {};
var parameters = <String, String>{};
for (var i = 0; i < parameterKeys.length; i++) {
parameters[parameterKeys[i]] = parameterValues[i];
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/observatory/lib/object_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class ObjectVertex {
var doms = _graph._doms;

var parentId = _id;
var domChildren = [];
var domChildren = <ObjectVertex>[];

for (var childId = ROOT; childId <= N; childId++) {
if (doms[childId] == parentId) {
Expand Down
24 changes: 12 additions & 12 deletions runtime/observatory/lib/src/debugger/debugger_location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ class DebuggerLocation {

static Future<List<Script>> _lookupScript(Isolate isolate, String name,
{bool allowPrefix: false}) {
var pending = [];
var pending = <Future>[];
for (var lib in isolate.libraries) {
if (!lib.loaded) {
pending.add(lib.load());
}
}
return Future.wait(pending).then((_) {
List matches = [];
var matches = <Script>[];
for (var lib in isolate.libraries) {
for (var script in lib.scripts) {
if (allowPrefix) {
Expand All @@ -140,7 +140,7 @@ class DebuggerLocation {

static List<ServiceFunction> _lookupFunction(Isolate isolate, String name,
{bool allowPrefix: false}) {
var matches = [];
var matches = <ServiceFunction>[];
for (var lib in isolate.libraries) {
assert(lib.loaded);
for (var function in lib.functions) {
Expand All @@ -163,7 +163,7 @@ class DebuggerLocation {
if (isolate == null) {
return [];
}
var pending = [];
var pending = <Future>[];
for (var lib in isolate.libraries) {
assert(lib.loaded);
for (var cls in lib.classes) {
Expand All @@ -173,7 +173,7 @@ class DebuggerLocation {
}
}
await Future.wait(pending);
var matches = [];
var matches = <Class>[];
for (var lib in isolate.libraries) {
for (var cls in lib.classes) {
if (allowPrefix) {
Expand Down Expand Up @@ -260,7 +260,7 @@ class DebuggerLocation {

/// Completes a partial source location description.
static Future<List<String>> complete(Debugger debugger, String locDesc) {
List<Future<List<String>>> pending = [];
var pending = <Future<List<String>>>[];
var match = partialFunctionMatcher.firstMatch(locDesc);
if (match != null) {
pending.add(_completeFunction(debugger, match));
Expand All @@ -272,7 +272,7 @@ class DebuggerLocation {
}

return Future.wait(pending).then((List<List<String>> responses) {
var completions = [];
var completions = <String>[];
for (var response in responses) {
completions.addAll(response);
}
Expand All @@ -289,7 +289,7 @@ class DebuggerLocation {

if (qualifier == null) {
return _lookupClass(isolate, base, allowPrefix: true).then((classes) {
var completions = [];
var completions = <String>[];

// Complete top-level function names.
var functions = _lookupFunction(isolate, base, allowPrefix: true);
Expand All @@ -306,7 +306,7 @@ class DebuggerLocation {
});
} else {
return _lookupClass(isolate, base, allowPrefix: false).then((classes) {
var completions = [];
var completions = <String>[];
for (var cls in classes) {
for (var function in cls.functions) {
if (function.kind == M.FunctionKind.constructor) {
Expand Down Expand Up @@ -375,7 +375,7 @@ class DebuggerLocation {
// The script name is incomplete. Complete it.
var scripts =
await _lookupScript(debugger.isolate, scriptName, allowPrefix: true);
List completions = [];
var completions = <String>[];
for (var script in scripts) {
completions.add(script.name + ':');
}
Expand All @@ -393,7 +393,7 @@ class DebuggerLocation {
if (!lineStrComplete) {
// Complete the line.
var sharedPrefix = '${script.name}:';
List completions = [];
var completions = <String>[];
var report = await script.isolate
.getSourceReport([Isolate.kPossibleBreakpointsReport], script);
Set<int> possibleBpts = getPossibleBreakpointLines(report, script);
Expand All @@ -410,7 +410,7 @@ class DebuggerLocation {
int lineNum = int.parse(lineStr);
var scriptLine = script.getLine(lineNum);
var sharedPrefix = '${script.name}:${lineStr}:';
List completions = [];
var completions = <String>[];
int maxCol = scriptLine.text.trimRight().runes.length;
for (int i = 1; i <= maxCol; i++) {
var currentColStr = i.toString();
Expand Down
8 changes: 4 additions & 4 deletions runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class HeapSnapshot implements M.HeapSnapshot {

Future<List<MergedVertex>> buildMergedVertices(
S.Isolate isolate, ObjectGraph graph, signal) async {
final cidToMergedVertex = {};
final cidToMergedVertex = <int, MergedVertex>{};

int count = 0;
final Stopwatch watch = new Stopwatch();
Expand Down Expand Up @@ -104,7 +104,7 @@ class HeapSnapshot implements M.HeapSnapshot {

buildOwnershipClasses(S.Isolate isolate, ObjectGraph graph) {
var numCids = graph.numCids;
var classes = new List();
var classes = new List<HeapSnapshotOwnershipClass>();
for (var cid = 0; cid < numCids; cid++) {
var size = graph.getOwnedByCid(cid);
if (size != 0) {
Expand Down Expand Up @@ -144,8 +144,8 @@ class HeapSnapshotDominatorNode implements M.HeapSnapshotDominatorNode {
if (_preloaded != null) {
return new Future.value(_preloaded);
} else {
return isolate.getObjectByAddress(v.address).then((S.HeapObject obj) {
return _preloaded = obj;
return isolate.getObjectByAddress(v.address).then((S.ServiceObject obj) {
return _preloaded = obj as S.HeapObject;
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/observatory/lib/src/models/objects/instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ abstract class Instance extends Object implements InstanceRef {
/// Int32x4List
/// Float32x4List
/// Float64x2List
Iterable<dynamic> get typedElements;
List<dynamic> get typedElements;

/// [optional] The native fields of this Instance.
Iterable<NativeField> get nativeFields;
Expand Down
24 changes: 14 additions & 10 deletions runtime/observatory/lib/src/sample_profile/sample_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class FunctionCallTreeNodeCode {
FunctionCallTreeNodeCode(this.code, this.ticks);
}

class FunctionCallTreeNode extends CallTreeNode {
class FunctionCallTreeNode extends CallTreeNode<FunctionCallTreeNode> {
final ProfileFunction profileFunction;
final codes = new List<FunctionCallTreeNodeCode>();
int _totalCodeTicks = 0;
Expand Down Expand Up @@ -210,7 +210,7 @@ class FunctionCallTreeNode extends CallTreeNode {
typedef bool CallTreeNodeFilter(CallTreeNode node);

/// Build a filter version of a FunctionCallTree.
abstract class _FilteredCallTreeBuilder {
abstract class _FilteredCallTreeBuilder<NodeT extends CallTreeNode> {
/// The filter.
final CallTreeNodeFilter filter;

Expand All @@ -235,14 +235,15 @@ abstract class _FilteredCallTreeBuilder {

CallTreeNode _findInChildren(CallTreeNode current, CallTreeNode needle) {
for (var child in current.children) {
if (child.profileData == needle.profileData) {
if ((child as CallTreeNode).profileData ==
(needle as CallTreeNode).profileData) {
return child;
}
}
return null;
}

CallTreeNode _copyNode(CallTreeNode node);
NodeT _copyNode(NodeT node);

/// Add all nodes in [_currentPath].
FunctionCallTreeNode _addCurrentPath() {
Expand Down Expand Up @@ -320,7 +321,8 @@ abstract class _FilteredCallTreeBuilder {
}
}

class _FilteredFunctionCallTreeBuilder extends _FilteredCallTreeBuilder {
class _FilteredFunctionCallTreeBuilder
extends _FilteredCallTreeBuilder<FunctionCallTreeNode> {
_FilteredFunctionCallTreeBuilder(
CallTreeNodeFilter filter, FunctionCallTree tree)
: super(
Expand All @@ -329,8 +331,8 @@ class _FilteredFunctionCallTreeBuilder extends _FilteredCallTreeBuilder {
new FunctionCallTree(
tree.inclusive,
new FunctionCallTreeNode(
tree.root.profileData,
tree.root.count,
(tree.root as CallTreeNode).profileData,
(tree.root as CallTreeNode).count,
tree.root.inclusiveNativeAllocations,
tree.root.exclusiveNativeAllocations)));

Expand All @@ -340,7 +342,8 @@ class _FilteredFunctionCallTreeBuilder extends _FilteredCallTreeBuilder {
}
}

class _FilteredCodeCallTreeBuilder extends _FilteredCallTreeBuilder {
class _FilteredCodeCallTreeBuilder
extends _FilteredCallTreeBuilder<CodeCallTreeNode> {
_FilteredCodeCallTreeBuilder(CallTreeNodeFilter filter, CodeCallTree tree)
: super(
filter,
Expand All @@ -359,7 +362,8 @@ class _FilteredCodeCallTreeBuilder extends _FilteredCallTreeBuilder {
}
}

class FunctionCallTree extends CallTree implements M.FunctionCallTree {
class FunctionCallTree extends CallTree<FunctionCallTreeNode>
implements M.FunctionCallTree {
FunctionCallTree(bool inclusive, FunctionCallTreeNode root)
: super(inclusive, root) {
if ((root.inclusiveNativeAllocations != null) &&
Expand Down Expand Up @@ -439,7 +443,7 @@ class FunctionCallTree extends CallTree implements M.FunctionCallTree {

_markFunctionCalls() {
for (var child in root.children) {
_markFunctionCallsInner(null, child);
_markFunctionCallsInner(null, child as FunctionCallTreeNode);
}
}
}
Expand Down
Loading

0 comments on commit 6ccd7b8

Please sign in to comment.