Skip to content

Commit b35e5cc

Browse files
authored
re-order constructors (#47)
1 parent 7fac0a0 commit b35e5cc

File tree

5 files changed

+87
-87
lines changed

5 files changed

+87
-87
lines changed

lib/device/device.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ import '../ui/elements.dart';
1414
// TODO(devoncarew): set toggle values on a full restart (when we see a new isolate)
1515

1616
class DeviceScreen extends Screen {
17-
StatusItem deviceStatus;
18-
19-
SetStateMixin framesChartStateMixin = new SetStateMixin();
20-
ExtensionTracker extensionTracker;
21-
22-
CoreElement togglesDiv;
23-
Map<String, bool> boolValues = <String, bool>{};
24-
2517
DeviceScreen()
2618
: super(
2719
name: 'Device', id: 'device', iconClass: 'octicon-device-mobile') {
@@ -34,6 +26,14 @@ class DeviceScreen extends Screen {
3426
addStatusItem(deviceStatus);
3527
}
3628

29+
StatusItem deviceStatus;
30+
31+
SetStateMixin framesChartStateMixin = new SetStateMixin();
32+
ExtensionTracker extensionTracker;
33+
34+
CoreElement togglesDiv;
35+
Map<String, bool> boolValues = <String, bool>{};
36+
3737
@override
3838
void createContent(Framework framework, CoreElement mainDiv) {
3939
mainDiv.add(<CoreElement>[
@@ -129,14 +129,6 @@ class DeviceScreen extends Screen {
129129
}
130130

131131
class ExtensionTracker {
132-
final StreamController<Null> _changeController =
133-
new StreamController<Null>.broadcast();
134-
135-
VmService service;
136-
137-
Map<String, Set<IsolateRef>> extensionToIsolatesMap =
138-
<String, Set<IsolateRef>>{};
139-
140132
ExtensionTracker(this.service) {
141133
service.onIsolateEvent.listen((Event e) {
142134
if (e.kind == 'ServiceExtensionAdded') {
@@ -149,6 +141,14 @@ class ExtensionTracker {
149141
serviceInfo.isolateManager.onIsolateExited.listen(_removeIsolate);
150142
}
151143

144+
final StreamController<Null> _changeController =
145+
new StreamController<Null>.broadcast();
146+
147+
VmService service;
148+
149+
Map<String, Set<IsolateRef>> extensionToIsolatesMap =
150+
<String, Set<IsolateRef>>{};
151+
152152
bool get hasConnection => service != null;
153153

154154
Stream<Null> get onChange => _changeController.stream;

lib/framework/framework.dart

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ import '../ui/primer.dart';
1616
import '../utils.dart';
1717

1818
class Framework {
19-
final List<Screen> screens = <Screen>[];
20-
Screen current;
21-
StatusLine globalStatus;
22-
StatusLine pageStatus;
23-
2419
Framework() {
2520
window.onPopState.listen(handlePopState);
2621
globalStatus =
@@ -29,6 +24,12 @@ class Framework {
2924
new StatusLine(new CoreElement.from(querySelector('#page-status')));
3025
}
3126

27+
final List<Screen> screens = <Screen>[];
28+
29+
Screen current;
30+
StatusLine globalStatus;
31+
StatusLine pageStatus;
32+
3233
void addScreen(Screen screen) {
3334
screens.add(screen);
3435
}
@@ -181,11 +182,11 @@ class Framework {
181182
}
182183

183184
class StatusLine {
185+
StatusLine(this.element);
186+
184187
final CoreElement element;
185188
final List<StatusItem> _items = <StatusItem>[];
186189

187-
StatusLine(this.element);
188-
189190
void add(StatusItem item) {
190191
_items.add(item);
191192

@@ -231,6 +232,12 @@ void toast(String message) {
231232
}
232233

233234
abstract class Screen {
235+
Screen({
236+
@required this.name,
237+
@required this.id,
238+
this.iconClass,
239+
});
240+
234241
final String name;
235242
final String id;
236243
final String iconClass;
@@ -241,12 +248,6 @@ abstract class Screen {
241248

242249
final List<StatusItem> statusItems = <StatusItem>[];
243250

244-
Screen({
245-
@required this.name,
246-
@required this.id,
247-
this.iconClass,
248-
});
249-
250251
String get ref => id == '/' ? id : '/$id';
251252

252253
bool get visible => _visible.value;
@@ -289,17 +290,17 @@ class SetStateMixin {
289290
}
290291

291292
class HelpInfo {
292-
final String title;
293-
final String url;
294-
295293
HelpInfo({
296294
@required this.title,
297295
@required this.url,
298296
});
297+
298+
final String title;
299+
final String url;
299300
}
300301

301302
class StatusItem {
302-
final CoreElement element;
303-
304303
StatusItem() : element = span();
304+
305+
final CoreElement element;
305306
}

lib/logging/logging.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ const int kMaxLogItemsUpperBound = 5500;
2727
DateFormat timeFormat = new DateFormat('HH:mm:ss.SSS');
2828

2929
class LoggingScreen extends Screen {
30-
Table<LogData> loggingTable;
31-
StatusItem logCountStatus;
32-
SetStateMixin loggingStateMixin = new SetStateMixin();
33-
3430
LoggingScreen()
3531
: super(name: 'Logs', id: 'logs', iconClass: 'octicon-clippy') {
3632
logCountStatus = new StatusItem();
@@ -44,6 +40,10 @@ class LoggingScreen extends Screen {
4440
serviceInfo.onConnectionClosed.listen(_handleConnectionStop);
4541
}
4642

43+
Table<LogData> loggingTable;
44+
StatusItem logCountStatus;
45+
SetStateMixin loggingStateMixin = new SetStateMixin();
46+
4747
@override
4848
void createContent(Framework framework, CoreElement mainDiv) {
4949
this.framework = framework;
@@ -324,15 +324,15 @@ class LoggingScreen extends Screen {
324324
/// we wait for up to 1ms when we get the `foo` event, to see if the next event
325325
/// is a single newline. If so, we add the newline to the previous log message.
326326
class _StdoutEventHandler {
327+
_StdoutEventHandler(this.loggingScreen, this.name, {this.isError = false});
328+
327329
final LoggingScreen loggingScreen;
328330
final String name;
329331
final bool isError;
330332

331333
LogData buffer;
332334
Timer timer;
333335

334-
_StdoutEventHandler(this.loggingScreen, this.name, {this.isError = false});
335-
336336
void handle(Event e) {
337337
final String message = decodeBase64(e.bytes);
338338

@@ -409,15 +409,6 @@ String _valueAsString(InstanceRef ref) {
409409
/// data is calculated, the log entry will be modified to contain the calculated
410410
/// `details` data.
411411
class LogData {
412-
final String kind;
413-
final int timestamp;
414-
final bool isError;
415-
final String summary;
416-
final String summaryHtml;
417-
418-
String _details;
419-
Future<String> detailsComputer;
420-
421412
LogData(
422413
this.kind,
423414
this._details,
@@ -428,6 +419,15 @@ class LogData {
428419
this.detailsComputer,
429420
});
430421

422+
final String kind;
423+
final int timestamp;
424+
final bool isError;
425+
final String summary;
426+
final String summaryHtml;
427+
428+
String _details;
429+
Future<String> detailsComputer;
430+
431431
String get details => _details;
432432

433433
bool get needsComputing => detailsComputer != null;
@@ -523,13 +523,6 @@ String getCssClassForEventKind(LogData item) {
523523
}
524524

525525
class LogDetailsUI extends CoreElement {
526-
static const JsonEncoder jsonEncoder = JsonEncoder.withIndent(' ');
527-
528-
LogData data;
529-
530-
CoreElement content;
531-
CoreElement message;
532-
533526
LogDetailsUI() : super('div') {
534527
layoutVertical();
535528

@@ -539,6 +532,13 @@ class LogDetailsUI extends CoreElement {
539532
]);
540533
}
541534

535+
static const JsonEncoder jsonEncoder = JsonEncoder.withIndent(' ');
536+
537+
LogData data;
538+
539+
CoreElement content;
540+
CoreElement message;
541+
542542
void setData(LogData data) {
543543
// Reset the vertical scroll value if any.
544544
content.element.scrollTop = 0;

lib/performance/performance.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ import '../ui/primer.dart';
1616
import '../utils.dart';
1717

1818
class PerformanceScreen extends Screen {
19-
StatusItem sampleCountStatus;
20-
StatusItem sampleFreqStatus;
21-
22-
PButton loadSnapshotButton;
23-
PButton resetButton;
24-
CoreElement progressElement;
25-
Table<PerfData> perfTable;
26-
27-
CpuChart cpuChart;
28-
SetStateMixin cpuChartStateMixin = new SetStateMixin();
29-
CpuTracker cpuTracker;
30-
3119
PerformanceScreen()
3220
: super(
3321
name: 'Performance',
@@ -40,6 +28,18 @@ class PerformanceScreen extends Screen {
4028
addStatusItem(sampleFreqStatus);
4129
}
4230

31+
StatusItem sampleCountStatus;
32+
StatusItem sampleFreqStatus;
33+
34+
PButton loadSnapshotButton;
35+
PButton resetButton;
36+
CoreElement progressElement;
37+
Table<PerfData> perfTable;
38+
39+
CpuChart cpuChart;
40+
SetStateMixin cpuChartStateMixin = new SetStateMixin();
41+
CpuTracker cpuTracker;
42+
4343
@override
4444
void createContent(Framework framework, CoreElement mainDiv) {
4545
mainDiv.add(<CoreElement>[
@@ -250,6 +250,8 @@ class CpuChart extends LineChart<CpuTracker> {
250250
}
251251

252252
class CpuTracker {
253+
CpuTracker(this.service);
254+
253255
static const Duration kMaxGraphTime = Duration(minutes: 1);
254256
static const Duration kUpdateDelay = Duration(seconds: 1);
255257

@@ -259,8 +261,6 @@ class CpuTracker {
259261
new StreamController<Null>.broadcast();
260262
List<int> samples = <int>[];
261263

262-
CpuTracker(this.service);
263-
264264
bool get hasConnection => service != null;
265265

266266
Stream<Null> get onChange => _changeController.stream;
@@ -299,13 +299,13 @@ class CpuTracker {
299299
}
300300

301301
class PerfData {
302+
PerfData(this.kind, this.name, this.self, this.inclusive);
303+
302304
final String kind;
303305
final String name;
304306
final double self;
305307
final double inclusive;
306308

307-
PerfData(this.kind, this.name, this.self, this.inclusive);
308-
309309
@override
310310
String toString() => '[$kind] $name';
311311
}
@@ -352,10 +352,10 @@ class PerfColumnMethodName extends Column<PerfData> {
352352
}
353353

354354
class _CalcProfile {
355-
final CpuProfile profile;
356-
357355
_CalcProfile(this.profile);
358356

357+
final CpuProfile profile;
358+
359359
Future<void> calc() async {
360360
// TODO:
361361
//profile.exclusiveCodeTrie;

lib/timeline/timeline.dart

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,6 @@ class TimelineScreen extends Screen {
258258
}
259259

260260
class TimelineFramesUI extends CoreElement {
261-
TimelineFrameUI selectedFrame;
262-
TimelineData timelineData;
263-
264-
final StreamController<TimelineFrame> _selectedFrameController =
265-
new StreamController<TimelineFrame>.broadcast();
266-
267261
TimelineFramesUI(TimelineFramesBuilder timelineFramesBuilder)
268262
: super('div', classes: 'timeline-frames') {
269263
timelineFramesBuilder.onFrameAdded.listen((TimelineFrame frame) {
@@ -283,6 +277,12 @@ class TimelineFramesUI extends CoreElement {
283277
});
284278
}
285279

280+
TimelineFrameUI selectedFrame;
281+
TimelineData timelineData;
282+
283+
final StreamController<TimelineFrame> _selectedFrameController =
284+
new StreamController<TimelineFrame>.broadcast();
285+
286286
bool hasStarted() => timelineData != null;
287287

288288
Stream<TimelineFrame> get onSelectedFrame => _selectedFrameController.stream;
@@ -303,9 +303,6 @@ class TimelineFramesUI extends CoreElement {
303303
}
304304

305305
class TimelineFrameUI extends CoreElement {
306-
final TimelineFramesUI framesUI;
307-
final TimelineFrame frame;
308-
309306
TimelineFrameUI(this.framesUI, this.frame)
310307
: super('div', classes: 'timeline-frame') {
311308
add(<CoreElement>[
@@ -348,6 +345,9 @@ class TimelineFrameUI extends CoreElement {
348345
});
349346
}
350347

348+
final TimelineFramesUI framesUI;
349+
final TimelineFrame frame;
350+
351351
void setSelected(bool selected) {
352352
toggleClass('selected', selected);
353353
}
@@ -464,10 +464,6 @@ class TimelineFramesBuilder {
464464
}
465465

466466
class FrameDetailsUI extends CoreElement {
467-
TimelineFrameData data;
468-
469-
CoreElement content;
470-
471467
FrameDetailsUI() : super('div') {
472468
layoutVertical();
473469
flex();
@@ -490,6 +486,9 @@ class FrameDetailsUI extends CoreElement {
490486
content.element.style.overflow = 'scroll';
491487
}
492488

489+
TimelineFrameData data;
490+
CoreElement content;
491+
493492
void updateData(TimelineFrameData data) {
494493
this.data = data;
495494

0 commit comments

Comments
 (0)