|
|
@ -1,5 +1,6 @@ |
|
|
|
import 'dart:io'; |
|
|
|
import 'dart:io'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:win_text_editor/framework/common/constants.dart'; |
|
|
|
import 'package:win_text_editor/framework/controllers/logger.dart'; |
|
|
|
import 'package:win_text_editor/framework/controllers/logger.dart'; |
|
|
|
import 'package:win_text_editor/modules/outline/models/outline_node.dart'; |
|
|
|
import 'package:win_text_editor/modules/outline/models/outline_node.dart'; |
|
|
|
import 'package:win_text_editor/modules/outline/services/component_service.dart'; |
|
|
|
import 'package:win_text_editor/modules/outline/services/component_service.dart'; |
|
|
@ -10,12 +11,14 @@ class FunctionsService { |
|
|
|
static Map<String, List<String>> uftbusinessMap = {}; |
|
|
|
static Map<String, List<String>> uftbusinessMap = {}; |
|
|
|
|
|
|
|
|
|
|
|
//原子层索引 |
|
|
|
//原子层索引 |
|
|
|
static Map<String, List<String>> uftatomMap = {}; |
|
|
|
static Map<String, List<String>> uftatomserviceMap = {}; |
|
|
|
|
|
|
|
static Map<String, List<String>> uftatomFunctionMap = {}; |
|
|
|
|
|
|
|
|
|
|
|
static Future<void> initFunctionsMap(String rootPath) async { |
|
|
|
static Future<void> initFunctionsMap(String rootPath) async { |
|
|
|
await _initUftMap('uftbusiness', rootPath, uftbusinessMap, ['.uftfunction']); |
|
|
|
await _initUftMap('uftbusiness', rootPath, uftbusinessMap, ['.uftfunction']); |
|
|
|
|
|
|
|
|
|
|
|
await _initUftMap('uftatom', rootPath, uftatomMap, ['.uftatomfunction', '.uftatomservice']); |
|
|
|
await _initUftMap('uftatom', rootPath, uftatomserviceMap, ['.uftatomservice']); |
|
|
|
|
|
|
|
await _initUftMap('uftatom', rootPath, uftatomFunctionMap, ['.uftatomfunction']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Future<void> _initUftMap( |
|
|
|
static Future<void> _initUftMap( |
|
|
@ -78,17 +81,35 @@ class FunctionsService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//加载原子逻辑层 |
|
|
|
//加载原子服务层 |
|
|
|
static Future<void> loadAtom(String? fieldName, OutlineNode parentNode) async { |
|
|
|
static void loadAtomService(String? fieldName, OutlineNode parentNode) { |
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
|
|
|
|
|
|
|
|
uftatomMap.forEach((key, value) { |
|
|
|
uftatomserviceMap.forEach((key, value) { |
|
|
|
if (value.contains(fieldName)) { |
|
|
|
if (value.contains(fieldName)) { |
|
|
|
parentNode.children.add( |
|
|
|
parentNode.children.add( |
|
|
|
OutlineNode( |
|
|
|
OutlineNode( |
|
|
|
name: value[0], // 文件名 |
|
|
|
name: value[0], // 文件名 |
|
|
|
title: key, |
|
|
|
title: key, |
|
|
|
value: 'Atom', |
|
|
|
value: Constants.atomService, |
|
|
|
|
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
|
|
|
|
depth: 4, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Future<void> loadAtomFunction(String? fieldName, OutlineNode parentNode) async { |
|
|
|
|
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uftatomFunctionMap.forEach((key, value) { |
|
|
|
|
|
|
|
if (value.contains(fieldName)) { |
|
|
|
|
|
|
|
parentNode.children.add( |
|
|
|
|
|
|
|
OutlineNode( |
|
|
|
|
|
|
|
name: value[0], // 文件名 |
|
|
|
|
|
|
|
title: key, |
|
|
|
|
|
|
|
value: Constants.atomFunction, |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
depth: 4, |
|
|
|
depth: 4, |
|
|
|
), |
|
|
|
), |
|
|
@ -98,7 +119,7 @@ class FunctionsService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//加载业务逻辑层 |
|
|
|
//加载业务逻辑层 |
|
|
|
static Future<void> loadBusiness(String? fieldName, OutlineNode parentNode) async { |
|
|
|
static void loadBusiness(String? fieldName, OutlineNode parentNode) { |
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
|
|
|
|
|
|
|
|
uftbusinessMap.forEach((key, value) { |
|
|
|
uftbusinessMap.forEach((key, value) { |
|
|
@ -107,7 +128,7 @@ class FunctionsService { |
|
|
|
OutlineNode( |
|
|
|
OutlineNode( |
|
|
|
name: value[0], // 文件名 |
|
|
|
name: value[0], // 文件名 |
|
|
|
title: key, |
|
|
|
title: key, |
|
|
|
value: 'Atom', |
|
|
|
value: Constants.business, |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
depth: 4, |
|
|
|
depth: 4, |
|
|
|
), |
|
|
|
), |
|
|
@ -124,7 +145,26 @@ class FunctionsService { |
|
|
|
OutlineNode( |
|
|
|
OutlineNode( |
|
|
|
name: value[0], // 文件名 |
|
|
|
name: value[0], // 文件名 |
|
|
|
title: key, |
|
|
|
title: key, |
|
|
|
value: 'Atom', |
|
|
|
value: Constants.business, |
|
|
|
|
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
|
|
|
|
depth: 4, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nodes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static List<OutlineNode> searchAtomServices(String searchQuery) { |
|
|
|
|
|
|
|
final List<OutlineNode> nodes = []; |
|
|
|
|
|
|
|
uftatomserviceMap.forEach((key, value) { |
|
|
|
|
|
|
|
if (key.contains(searchQuery)) { |
|
|
|
|
|
|
|
nodes.add( |
|
|
|
|
|
|
|
OutlineNode( |
|
|
|
|
|
|
|
name: value[0], // 文件名 |
|
|
|
|
|
|
|
title: key, |
|
|
|
|
|
|
|
value: Constants.atomService, |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
depth: 4, |
|
|
|
depth: 4, |
|
|
|
), |
|
|
|
), |
|
|
@ -135,15 +175,15 @@ class FunctionsService { |
|
|
|
return nodes; |
|
|
|
return nodes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static List<OutlineNode> searchAtoms(String searchQuery) { |
|
|
|
static List<OutlineNode> searchAtomFunctions(String searchQuery) { |
|
|
|
final List<OutlineNode> nodes = []; |
|
|
|
final List<OutlineNode> nodes = []; |
|
|
|
uftatomMap.forEach((key, value) { |
|
|
|
uftatomFunctionMap.forEach((key, value) { |
|
|
|
if (key.contains(searchQuery)) { |
|
|
|
if (key.contains(searchQuery)) { |
|
|
|
nodes.add( |
|
|
|
nodes.add( |
|
|
|
OutlineNode( |
|
|
|
OutlineNode( |
|
|
|
name: value[0], // 文件名 |
|
|
|
name: value[0], // 文件名 |
|
|
|
title: key, |
|
|
|
title: key, |
|
|
|
value: 'Atom', |
|
|
|
value: Constants.atomFunction, |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
depth: 4, |
|
|
|
depth: 4, |
|
|
|
), |
|
|
|
), |
|
|
|