Browse Source

就差最后一个bug了

master
hejl 4 weeks ago
parent
commit
9704e9e3eb
  1. 177
      win_text_editor/lib/modules/outline/services/outline_service.dart
  2. 2
      win_text_editor/lib/modules/outline/widgets/outline_explorer.dart

177
win_text_editor/lib/modules/outline/services/outline_service.dart

@ -163,7 +163,10 @@ class OutlineService { @@ -163,7 +163,10 @@ class OutlineService {
await _loadComponent(rootPath, dirNode.value, dirNode);
break;
case 'Business':
//
await _loadBusiness(rootPath, dirNode.value, dirNode);
break;
case 'Atom':
await _loadAtom(rootPath, dirNode.value, dirNode);
break;
default:
Logger().error("操作节点类型不支持: ${dirNode.value}");
@ -222,6 +225,178 @@ class OutlineService { @@ -222,6 +225,178 @@ class OutlineService {
}
}
//
static Future<void> _loadAtom(String rootPath, String? fieldName, OutlineNode parentNode) async {
if (fieldName == null || fieldName.isEmpty) return;
final uftatomDir = Directory('$rootPath\\uftatom');
if (!await uftatomDir.exists()) {
Logger().error('uftatom目录不存在');
return;
}
try {
// .uftstructure文件
final uftatomFiles =
await uftatomDir
.list(recursive: true)
.where(
(entity) =>
entity.path.endsWith('.uftatomfunction') ||
entity.path.endsWith('.uftatomservice'),
)
.cast<File>()
.toList();
for (final file in uftatomFiles) {
try {
final content = await file.readAsString();
final document = XmlDocument.parse(content);
String matchType = "I";
//
final List<XmlElement> matchingProperties =
document
.findAllElements('inputParameters')
.where((element) => element.getAttribute('id') == fieldName)
.toList();
if (matchingProperties.isEmpty) {
matchingProperties.addAll(
document
.findAllElements('outputParameters')
.where((element) => element.getAttribute('id') == fieldName),
);
matchType = "O";
}
if (matchingProperties.isEmpty) {
matchingProperties.addAll(
document
.findAllElements('internalParams')
.where((element) => element.getAttribute('id') == fieldName),
);
matchType = "X";
}
if (matchingProperties.isNotEmpty) {
// structure:Structure节点的chineseName
final businessNode = document.findAllElements('business:Function').firstOrNull;
final chineseName = businessNode?.getAttribute('chineseName') ?? '未命名';
//
final fileName = file.path;
//
parentNode.children.add(
OutlineNode(
name: fileName,
title: '$chineseName($matchType)',
value: 'Atom',
frequency: 0,
isDirectory: false, //
depth: 4,
),
);
}
} catch (e) {
Logger().error('解析文件 ${file.path} 失败: $e');
}
}
Logger().info('$fieldName 找到 ${parentNode.children.length} 个匹配项');
} catch (e) {
Logger().error('加载UFT对象失败: $e');
rethrow;
}
}
//
static Future<void> _loadBusiness(
String rootPath,
String? fieldName,
OutlineNode parentNode,
) async {
if (fieldName == null || fieldName.isEmpty) return;
final uftbusinessDir = Directory('$rootPath\\uftbusiness');
if (!await uftbusinessDir.exists()) {
Logger().error('uftbusiness目录不存在');
return;
}
try {
// .uftstructure文件
final uftbusinessFiles =
await uftbusinessDir
.list(recursive: true)
.where((entity) => entity.path.endsWith('.uftfunction'))
.cast<File>()
.toList();
for (final file in uftbusinessFiles) {
try {
final content = await file.readAsString();
final document = XmlDocument.parse(content);
String matchType = "I";
//
final List<XmlElement> matchingProperties =
document
.findAllElements('inputParameters')
.where((element) => element.getAttribute('id') == fieldName)
.toList();
if (matchingProperties.isEmpty) {
matchingProperties.addAll(
document
.findAllElements('outputParameters')
.where((element) => element.getAttribute('id') == fieldName),
);
matchType = "O";
}
if (matchingProperties.isEmpty) {
matchingProperties.addAll(
document
.findAllElements('internalParams')
.where((element) => element.getAttribute('id') == fieldName),
);
matchType = "X";
}
if (matchingProperties.isNotEmpty) {
// structure:Structure节点的chineseName
final businessNode = document.findAllElements('business:Function').firstOrNull;
final chineseName = businessNode?.getAttribute('chineseName') ?? '未命名';
//
final fileName = file.path;
//
parentNode.children.add(
OutlineNode(
name: fileName,
title: '$chineseName($matchType)',
value: 'Business',
frequency: 0,
isDirectory: false, //
depth: 4,
),
);
}
} catch (e) {
Logger().error('解析文件 ${file.path} 失败: $e');
}
}
Logger().info('$fieldName 找到 ${parentNode.children.length} 个匹配项');
} catch (e) {
Logger().error('加载UFT对象失败: $e');
rethrow;
}
}
// UFT对象
static Future<void> _loadUftObject(
String rootPath,

2
win_text_editor/lib/modules/outline/widgets/outline_explorer.dart

@ -199,7 +199,7 @@ class _OutlineExplorerState extends State<OutlineExplorer> { @@ -199,7 +199,7 @@ class _OutlineExplorerState extends State<OutlineExplorer> {
case "Business":
case "Atom":
if (widget.onFileDoubleTap != null) {
widget.onFileDoubleTap!(outlineNode.name, outlineNode.name);
widget.onFileDoubleTap!(outlineNode.name, null);
}
break;
case "Component":

Loading…
Cancel
Save