Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rohd Devtools Extension Refactor to BLoC #562

Merged
merged 12 commits into from
Feb 19, 2025
2 changes: 1 addition & 1 deletion .github/workflows/build_devtool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: flutter-actions/setup-flutter@v2
with:
channel: stable
version: 3.19.3
version: 3.29.0

- name: Run Flutter Test
run: tool/gh_actions/devtool/run_devtool_test.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
uses: flutter-actions/setup-flutter@v2
with:
channel: stable
version: 3.19.3
version: 3.29.0

- name: Run Flutter Test
run: tool/gh_actions/devtool/run_devtool_test.sh
Expand Down
3 changes: 2 additions & 1 deletion extension/devtools/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: rohd
issueTracker: https://github.com/intel/rohd/issues
version: 0.0.1
materialIconCodePoint: '0xe1c5'
materialIconCodePoint: '0xe1c5'
requiresConnection: true # optional field - defaults to true
12 changes: 6 additions & 6 deletions rohd_devtools_extension/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "f65dd3bac0c44c036fe4b158c5d550c4ec529a60"
channel: "master"
revision: "17025dd88227cd9532c33fa78f5250d548d87e9a"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60
base_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: web
create_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60
base_revision: f65dd3bac0c44c036fe4b158c5d550c4ec529a60
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a

# User provided section

Expand Down
34 changes: 24 additions & 10 deletions rohd_devtools_extension/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
// Copyright (C) 2024 Intel Corporation
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// main.dart
// Entry point for main application.
// Main entry for the app.
//
// 2024 January 5
// Author: Yao Jing Quek <yao.jing.quek@intel.com>
// 2025 January 28
// Author: Roberto Torres <roberto.torres@intel.com>

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'src/modules/rohd_devtools_module.dart';
import 'package:devtools_extensions/devtools_extensions.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:rohd_devtools_extension/rohd_devtools/view/rohd_devtools_page.dart';

import 'package:rohd_devtools_extension/rohd_devtools_observer.dart';

void main() {
runApp(const ProviderScope(
child: RohdDevToolsModule(),
));
/// Initializing the [BlocObserver] created and calling runApp
Bloc.observer = const RohdDevToolsObserver();

runApp(const RohdDevToolsApp());
}

class RohdDevToolsApp extends StatelessWidget {
const RohdDevToolsApp({super.key});
@override
Widget build(BuildContext context) {
return const DevToolsExtension(
child: RohdDevToolsPage(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// rohd_devtools_view.dart
// Main view for the app.
//
// 2025 January 28
// Author: Roberto Torres <[email protected]>

import 'package:devtools_app_shared/service.dart';
import 'package:devtools_extensions/devtools_extensions.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:rohd_devtools_extension/rohd_devtools/models/tree_model.dart';
import 'package:rohd_devtools_extension/rohd_devtools/services/tree_service.dart';

part 'rohd_service_state.dart';

class RohdServiceCubit extends Cubit<RohdServiceState> {
TreeService? treeService;

RohdServiceCubit() : super(RohdServiceInitial()) {
evalModuleTree();
}

Future<void> evalModuleTree() async {
try {
emit(RohdServiceLoading());
if (serviceManager.service == null) {
throw Exception('ServiceManager is not initialized');
}
treeService ??= TreeService(
EvalOnDartLibrary(
'package:rohd/src/diagnostics/inspector_service.dart',
serviceManager.service!,
serviceManager: serviceManager,
),
Disposable(),
);
final treeModel = await treeService!.evalModuleTree();
emit(RohdServiceLoaded(treeModel));
} catch (error, trace) {
emit(RohdServiceError(error.toString(), trace));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// rohd_devtools_view.dart
// Main view for the app.
//
// 2025 January 28
// Author: Roberto Torres <[email protected]>

part of 'rohd_service_cubit.dart';

abstract class RohdServiceState extends Equatable {
const RohdServiceState();

@override
List<Object?> get props => [];
}

class RohdServiceInitial extends RohdServiceState {}

class RohdServiceLoading extends RohdServiceState {}

class RohdServiceLoaded extends RohdServiceState {
final TreeModel? treeModel;

const RohdServiceLoaded(this.treeModel);

@override
List<Object?> get props => [treeModel];
}

class RohdServiceError extends RohdServiceState {
final String error;
final StackTrace trace;

const RohdServiceError(this.error, this.trace);

@override
List<Object?> get props => [error, trace];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// rohd_devtools_view.dart
// Main view for the app.
//
// 2025 January 28
// Author: Roberto Torres <[email protected]>

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:rohd_devtools_extension/rohd_devtools/models/tree_model.dart';

part 'selected_module_state.dart';

class SelectedModuleCubit extends Cubit<SelectedModuleState> {
SelectedModuleCubit() : super(SelectedModuleInitial());

void setModule(TreeModel module) {
emit(SelectedModuleLoaded(module));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// rohd_devtools_view.dart
// Main view for the app.
//
// 2025 January 28
// Author: Roberto Torres <[email protected]>

part of 'selected_module_cubit.dart';

abstract class SelectedModuleState extends Equatable {
const SelectedModuleState();

@override
List<Object?> get props => [];
}

class SelectedModuleInitial extends SelectedModuleState {}

class SelectedModuleLoaded extends SelectedModuleState {
final TreeModel module;

const SelectedModuleLoaded(this.module);

@override
List<Object?> get props => [module];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// rohd_devtools_view.dart
// Main view for the app.
//
// 2025 January 28
// Author: Roberto Torres <[email protected]>

import 'package:flutter_bloc/flutter_bloc.dart';

class SignalSearchTermCubit extends Cubit<String?> {
SignalSearchTermCubit() : super(null);

void setTerm(String term) {
emit(term);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// rohd_devtools_view.dart
// Main view for the app.
//
// 2025 January 28
// Author: Roberto Torres <[email protected]>

import 'package:flutter_bloc/flutter_bloc.dart';

class TreeSearchTermCubit extends Cubit<String?> {
TreeSearchTermCubit() : super(null);

void setTerm(String term) {
emit(term);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 Intel Corporation
// Copyright (C) 2024-2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// signal_model.dart
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 Intel Corporation
// Copyright (C) 2024-2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// tree_model.dart
Expand All @@ -7,7 +7,7 @@
// 2024 January 5
// Author: Yao Jing Quek <[email protected]>

import 'package:rohd_devtools_extension/src/modules/tree_structure/models/signal_model.dart';
import 'package:rohd_devtools_extension/rohd_devtools/models/signal_model.dart';

class TreeModel {
final String name;
Expand Down
13 changes: 13 additions & 0 deletions rohd_devtools_extension/lib/rohd_devtools/rohd_devtools.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// rohd_devtools.dart
//
// 2025 January 28
// Author: Roberto Torres <[email protected]>

export 'cubit/rohd_service_cubit.dart';
export 'cubit/selected_module_cubit.dart';
export 'cubit/signal_search_term_cubit.dart';
export 'cubit/tree_search_term_cubit.dart';
export 'view/view.dart';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 Intel Corporation
// Copyright (C) 2024-2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// signal_service.dart
Expand All @@ -7,10 +7,10 @@
// 2024 January 5
// Author: Yao Jing Quek <[email protected]>

import 'package:rohd_devtools_extension/src/modules/tree_structure/models/signal_model.dart';
import 'package:rohd_devtools_extension/rohd_devtools/models/signal_model.dart';

class SignalService {
List<SignalModel> filterSignals(
abstract class SignalService {
static List<SignalModel> filterSignals(
List<SignalModel> signals,
String searchTerm,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 Intel Corporation
// Copyright (C) 2024-2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// tree_services.dart
Expand All @@ -10,7 +10,7 @@
import 'dart:convert';

import 'package:devtools_app_shared/service.dart';
import 'package:rohd_devtools_extension/src/modules/tree_structure/models/tree_model.dart';
import 'package:rohd_devtools_extension/rohd_devtools/models/tree_model.dart';

class TreeService {
final invokeFunc = 'ModuleTree.instance.hierarchyJSON';
Expand All @@ -36,7 +36,8 @@ class TreeService {
}
}

bool isNodeOrDescendentMatching(TreeModel module, String? treeSearchTerm) {
static bool isNodeOrDescendentMatching(
TreeModel module, String? treeSearchTerm) {
if (module.name.toLowerCase().contains(treeSearchTerm!.toLowerCase())) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 Intel Corporation
// Copyright (C) 2024-2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// devtool_appbar.dart
Expand Down
Loading