mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-30 01:27:26 +08:00
1 parent
c3f6b61dfd
commit
36c0dc3ca0
1 file changed
+16
-2
@@ -20,7 +20,7 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
// resourceReferenceScopes 按文档归集资源标识和字体用字,共享资源索引合并所属文档的引用
|
// resourceReferenceScopes 按文档归集资源标识和字体用字,同文档索引共用只读结果,跨文档索引独立合并
|
||||||
// 入参: ctx 取消上下文, parts 输出改动, generated 自产页面引用, documents 文档入口, resources 资源索引, references 文件引用, selected 限定的文档入口,空值统计全部文档
|
// 入参: ctx 取消上下文, parts 输出改动, generated 自产页面引用, documents 文档入口, resources 资源索引, references 文件引用, selected 限定的文档入口,空值统计全部文档
|
||||||
// 返回: map[string]*editorResourceRefs 各资源索引的引用,存在无法归属的引用时为空, error 读取或取消错误
|
// 返回: map[string]*editorResourceRefs 各资源索引的引用,存在无法归属的引用时为空, error 读取或取消错误
|
||||||
func (r *Reader) resourceReferenceScopes(ctx context.Context, parts map[string][]byte, generated map[string]editorGeneratedReferences, documents map[string]bool, resources []string, references map[string]*editorResourceRefs, selected string) (map[string]*editorResourceRefs, error) {
|
func (r *Reader) resourceReferenceScopes(ctx context.Context, parts map[string][]byte, generated map[string]editorGeneratedReferences, documents map[string]bool, resources []string, references map[string]*editorResourceRefs, selected string) (map[string]*editorResourceRefs, error) {
|
||||||
@@ -30,6 +30,7 @@ func (r *Reader) resourceReferenceScopes(ctx context.Context, parts map[string][
|
|||||||
}
|
}
|
||||||
used := make(map[string]bool)
|
used := make(map[string]bool)
|
||||||
result := make(map[string]*editorResourceRefs)
|
result := make(map[string]*editorResourceRefs)
|
||||||
|
shared := make(map[string]bool)
|
||||||
for _, entry := range slices.Sorted(maps.Keys(documents)) {
|
for _, entry := range slices.Sorted(maps.Keys(documents)) {
|
||||||
scope, err := r.versionFileDependencies(ctx, entry, parts, generated)
|
scope, err := r.versionFileDependencies(ctx, entry, parts, generated)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -37,6 +38,9 @@ func (r *Reader) resourceReferenceScopes(ctx context.Context, parts map[string][
|
|||||||
}
|
}
|
||||||
refs := &editorResourceRefs{ids: make(map[string]bool), fonts: make(map[string]*editorFontUsage)}
|
refs := &editorResourceRefs{ids: make(map[string]bool), fonts: make(map[string]*editorFontUsage)}
|
||||||
for name := range scope {
|
for name := range scope {
|
||||||
|
if err := ctx.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if source := references[name]; source != nil {
|
if source := references[name]; source != nil {
|
||||||
used[name] = true
|
used[name] = true
|
||||||
if selected == "" || selected == entry {
|
if selected == "" || selected == entry {
|
||||||
@@ -48,11 +52,21 @@ func (r *Reader) resourceReferenceScopes(ctx context.Context, parts map[string][
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for name := range scope {
|
for name := range scope {
|
||||||
|
if err := ctx.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if !indexes[name] {
|
if !indexes[name] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if result[name] == nil {
|
if result[name] == nil {
|
||||||
result[name] = &editorResourceRefs{ids: make(map[string]bool), fonts: make(map[string]*editorFontUsage)}
|
result[name] = refs
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !shared[name] {
|
||||||
|
merged := &editorResourceRefs{ids: make(map[string]bool), fonts: make(map[string]*editorFontUsage)}
|
||||||
|
merged.merge(result[name])
|
||||||
|
result[name] = merged
|
||||||
|
shared[name] = true
|
||||||
}
|
}
|
||||||
result[name].merge(refs)
|
result[name].merge(refs)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user