Browse Source

全部搞完,打包发布v0.1

master
hejl 4 weeks ago
parent
commit
ed24565135
  1. 87
      win_text_editor/lib/modules/outline/services/outline_service.dart

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

@ -180,10 +180,28 @@ class OutlineService { @@ -180,10 +180,28 @@ class OutlineService {
) async {
if (fieldName == null || fieldName.isEmpty) return;
final matches = await _matchComponent(rootPath, fieldName);
matches.forEach(
(key, value) => parentNode.children.add(
OutlineNode(
name: key,
title: value,
value: 'Component',
frequency: 0,
isDirectory: false,
depth: 4,
),
),
);
}
//
static Future<Map<String, String>> _matchComponent(String rootPath, String fieldName) async {
Map<String, String> matchComponents = {};
final componentFile = File('$rootPath/metadata/component.xml');
if (!await componentFile.exists()) {
Logger().error('component.xml文件不存在');
return;
return matchComponents;
}
try {
@ -202,27 +220,15 @@ class OutlineService { @@ -202,27 +220,15 @@ class OutlineService {
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,
),
);
matchComponents[parentName] = parentChineseName;
}
}
}
}
Logger().info('$fieldName 找到 ${parentNode.children.length} 个匹配项');
} catch (e) {
Logger().error('加载Component失败: $e');
rethrow;
}
return matchComponents;
}
//
@ -236,6 +242,9 @@ class OutlineService { @@ -236,6 +242,9 @@ class OutlineService {
}
try {
//
final matchComponents = await _matchComponent(rootPath, fieldName);
// .uftstructure文件
final uftatomFiles =
await uftatomDir
@ -258,27 +267,46 @@ class OutlineService { @@ -258,27 +267,46 @@ class OutlineService {
final List<XmlElement> matchingProperties =
document
.findAllElements('inputParameters')
.where((element) => element.getAttribute('id') == fieldName)
.where(
(element) =>
element.getAttribute('id') == fieldName ||
element.getAttribute("paramType") == "COMPONENT" &&
matchComponents.containsKey(element.getAttribute('id')),
)
.toList();
//
if (matchingProperties.isEmpty) {
matchingProperties.addAll(
document
.findAllElements('outputParameters')
.where((element) => element.getAttribute('id') == fieldName),
.where(
(element) =>
element.getAttribute('id') == fieldName ||
element.getAttribute("paramType") == "COMPONENT" &&
matchComponents.containsKey(element.getAttribute('id')),
),
);
matchType = "O";
}
//
if (matchingProperties.isEmpty) {
matchingProperties.addAll(
document
.findAllElements('internalParams')
.where((element) => element.getAttribute('id') == fieldName),
.where(
(element) =>
element.getAttribute('id') == fieldName ||
element.getAttribute("paramType") == "COMPONENT" &&
matchComponents.containsKey(element.getAttribute('id')),
),
);
matchType = "X";
}
//
if (matchingProperties.isNotEmpty) {
// structure:Structure节点的chineseName
final businessNode = document.findAllElements('business:Function').firstOrNull;
@ -326,6 +354,8 @@ class OutlineService { @@ -326,6 +354,8 @@ class OutlineService {
}
try {
final matchComponents = await _matchComponent(rootPath, fieldName);
// .uftstructure文件
final uftbusinessFiles =
await uftbusinessDir
@ -344,14 +374,24 @@ class OutlineService { @@ -344,14 +374,24 @@ class OutlineService {
final List<XmlElement> matchingProperties =
document
.findAllElements('inputParameters')
.where((element) => element.getAttribute('id') == fieldName)
.where(
(element) =>
element.getAttribute('id') == fieldName ||
element.getAttribute("paramType") == "COMPONENT" &&
matchComponents.containsKey(element.getAttribute('id')),
)
.toList();
if (matchingProperties.isEmpty) {
matchingProperties.addAll(
document
.findAllElements('outputParameters')
.where((element) => element.getAttribute('id') == fieldName),
.where(
(element) =>
element.getAttribute('id') == fieldName ||
element.getAttribute("paramType") == "COMPONENT" &&
matchComponents.containsKey(element.getAttribute('id')),
),
);
matchType = "O";
}
@ -360,7 +400,12 @@ class OutlineService { @@ -360,7 +400,12 @@ class OutlineService {
matchingProperties.addAll(
document
.findAllElements('internalParams')
.where((element) => element.getAttribute('id') == fieldName),
.where(
(element) =>
element.getAttribute('id') == fieldName ||
element.getAttribute("paramType") == "COMPONENT" &&
matchComponents.containsKey(element.getAttribute('id')),
),
);
matchType = "X";
}

Loading…
Cancel
Save