|
|
|
@ -160,14 +160,243 @@ class OutlineService {
@@ -160,14 +160,243 @@ class OutlineService {
|
|
|
|
|
await _loadUftObject(rootPath, dirNode.value, dirNode); |
|
|
|
|
break; |
|
|
|
|
case 'Component': |
|
|
|
|
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}"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Future<void> _loadComponent( |
|
|
|
|
String rootPath, |
|
|
|
|
String? fieldName, |
|
|
|
|
OutlineNode parentNode, |
|
|
|
|
) async { |
|
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
|
|
|
|
|
|
final componentFile = File('$rootPath/metadata/component.xml'); |
|
|
|
|
if (!await componentFile.exists()) { |
|
|
|
|
Logger().error('component.xml文件不存在'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
final content = await componentFile.readAsString(); |
|
|
|
|
final document = XmlDocument.parse(content); |
|
|
|
|
|
|
|
|
|
// 查找所有items节点 |
|
|
|
|
for (final item in document.findAllElements('items')) { |
|
|
|
|
// 检查name属性是否匹配fieldName |
|
|
|
|
if (item.getAttribute('name') == fieldName) { |
|
|
|
|
// 获取父节点 |
|
|
|
|
final parentElement = item.parent; |
|
|
|
|
if (parentElement != null) { |
|
|
|
|
// 获取父节点的name和chineseName属性 |
|
|
|
|
final parentName = parentElement.getAttribute('name'); |
|
|
|
|
final parentChineseName = parentElement.getAttribute('chineseName'); |
|
|
|
|
|
|
|
|
|
if (parentName != null && parentChineseName != null) { |
|
|
|
|
// 创建并添加子节点 |
|
|
|
|
parentNode.children.add( |
|
|
|
|
OutlineNode( |
|
|
|
|
name: parentName, |
|
|
|
|
title: parentChineseName, |
|
|
|
|
value: 'Component', |
|
|
|
|
frequency: 0, |
|
|
|
|
isDirectory: false, |
|
|
|
|
depth: 4, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Logger().info('为 $fieldName 找到 ${parentNode.children.length} 个匹配项'); |
|
|
|
|
} catch (e) { |
|
|
|
|
Logger().error('加载Component失败: $e'); |
|
|
|
|
rethrow; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//加载原子逻辑层 |
|
|
|
|
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, |
|
|
|
@ -206,8 +435,8 @@ class OutlineService {
@@ -206,8 +435,8 @@ class OutlineService {
|
|
|
|
|
final structureNode = document.findAllElements('structure:Structure').firstOrNull; |
|
|
|
|
final chineseName = structureNode?.getAttribute('chineseName') ?? '未命名'; |
|
|
|
|
|
|
|
|
|
// 获取文件名(不带路径和扩展名) |
|
|
|
|
final fileName = file.path.split('/').last.replaceFirst('.uftstructure', ''); |
|
|
|
|
// 获取文件名(不带路径) |
|
|
|
|
final fileName = file.path; |
|
|
|
|
|
|
|
|
|
// 创建并添加子节点 |
|
|
|
|
parentNode.children.add( |
|
|
|
@ -217,7 +446,7 @@ class OutlineService {
@@ -217,7 +446,7 @@ class OutlineService {
|
|
|
|
|
value: 'UFTTable', |
|
|
|
|
frequency: 0, |
|
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
|
depth: parentNode.depth + 1, |
|
|
|
|
depth: 4, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -274,7 +503,7 @@ class OutlineService {
@@ -274,7 +503,7 @@ class OutlineService {
|
|
|
|
|
title: entry.value, |
|
|
|
|
frequency: 0, |
|
|
|
|
isDirectory: true, |
|
|
|
|
depth: parentNode.depth + 1, |
|
|
|
|
depth: 3, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
@ -306,6 +535,7 @@ class OutlineService {
@@ -306,6 +535,7 @@ class OutlineService {
|
|
|
|
|
frequency: entry.value, |
|
|
|
|
isDirectory: true, |
|
|
|
|
depth: 1, |
|
|
|
|
isRoot: true, |
|
|
|
|
wordClass: _wordClassDict[entry.key], |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|