Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/home/bloc/home_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// dynamic calls is ok here
// ignore_for_file: avoid_dynamic_calls

import 'dart:io';

import 'package:ariadne/analyzer/analyzer.dart';
import 'package:ariadne/database/code/code_database.dart';
import 'package:ariadne/database/database_manager.dart';
import 'package:ariadne/database/projects/projects_database.dart';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:flutter/foundation.dart';
import 'package:glob/glob.dart';
import 'package:lsp_server/lsp_server.dart';
Expand All @@ -26,11 +26,13 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
required ProjectsDatabase projectsDB,
required CodeDatabaseManager codeDbManager,
required CodeDatabase codeDB,
FileSystem? fileSystem,
}) : _analyzer = analyzer,
_projectsDbManager = projectsDbManager,
_projectsDB = projectsDB,
_codeDbManager = codeDbManager,
_codeDB = codeDB,
_fileSystem = fileSystem ?? const LocalFileSystem(),
super(const HomeState()) {
on<ShowAnalyzedProjects>(_onShowAnalyzedProjects);
on<OpenProject>(_onOpenProject);
Expand All @@ -44,6 +46,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
final ProjectsDatabase _projectsDB;
final CodeDatabaseManager _codeDbManager;
final CodeDatabase _codeDB;
final FileSystem _fileSystem;

Future<void> _onShowAnalyzedProjects(
ShowAnalyzedProjects event,
Expand Down Expand Up @@ -78,7 +81,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
Emitter<HomeState> emit,
) async {
await _projectsDB.analyzedProjects.delete(projectId: event.projectId);
final file = File(event.dbPath);
final file = _fileSystem.file(event.dbPath);
if (file.existsSync()) {
file.deleteSync();
}
Expand All @@ -96,7 +99,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {

final dbFolder = await getApplicationSupportDirectory();
final path = p.join(dbFolder.path, 'analysis', '$fileName.sqlite');
final file = File(path);
final file = _fileSystem.file(path);
if (file.existsSync()) {
file.deleteSync();
}
Expand Down Expand Up @@ -153,8 +156,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
}

Future<List<File>> _findDartFiles({required String root}) async {
final rootDir = Directory(root);
final analysisOptionsFile = File(
final rootDir = _fileSystem.directory(root);
final analysisOptionsFile = _fileSystem.file(
p.join(rootDir.path, 'analysis_options.yaml'),
);

Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ packages:
source: hosted
version: "2.1.5"
file:
dependency: transitive
dependency: "direct main"
description:
name: file
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies:
collection: ^1.19.1
drift: ^2.30.1
equatable: ^2.0.8
file: ^7.0.1
flutter:
sdk: flutter
flutter_bloc: ^9.1.1
Expand Down