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

Loading…
Cancel
Save