-
Notifications
You must be signed in to change notification settings - Fork 146
Prevent a manual technology root from overriding the module node with the same name #770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cbd6f3e
19c5971
98b28b9
2b72f08
f469e0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,8 +37,8 @@ struct ResolvedIdentifier: Equatable, Hashable { | |
/// After a path hierarchy has been fully created — with both symbols and non-symbols — it can be used to find elements in the hierarchy and to determine the least disambiguated paths for all elements. | ||
struct PathHierarchy { | ||
|
||
/// A map of module names to module nodes. | ||
private(set) var modules: [String: Node] | ||
/// The list of module nodes. | ||
private(set) var modules: [Node] | ||
/// The container of top-level articles in the documentation hierarchy. | ||
let articlesContainer: Node | ||
/// The container of tutorials in the documentation hierarchy. | ||
|
@@ -295,7 +295,7 @@ struct PathHierarchy { | |
""" | ||
) | ||
|
||
self.modules = roots | ||
self.modules = Array(roots.values) | ||
self.lookup = lookup | ||
|
||
assert(topLevelSymbols().allSatisfy({ lookup[$0] != nil })) | ||
|
@@ -352,7 +352,7 @@ struct PathHierarchy { | |
newNode.identifier = newReference | ||
self.lookup[newReference] = newNode | ||
|
||
modules[name] = newNode | ||
modules.append(newNode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @d-ronnqvist. It seems that this is what fixes the bug, and the rest is refactoring as a consequence of changing modules from a dictionary to an array. However, I'm confused about some other changes that don't appear to have any impact on resolving the bug. I'll add a comment to each of the things I believe are unnecessary in this PR, so you can explain me why these changes were made. |
||
|
||
return newReference | ||
} | ||
|
@@ -377,7 +377,7 @@ extension PathHierarchy { | |
|
||
fileprivate(set) unowned var parent: Node? | ||
/// The symbol, if a node has one. | ||
private(set) var symbol: SymbolGraph.Symbol? | ||
fileprivate(set) var symbol: SymbolGraph.Symbol? | ||
|
||
/// If the path hierarchy should disfavor this node in a link collision. | ||
/// | ||
|
@@ -452,7 +452,7 @@ extension PathHierarchy { | |
func topLevelSymbols() -> [ResolvedIdentifier] { | ||
var result: Set<ResolvedIdentifier> = [] | ||
// Roots represent modules and only have direct symbol descendants. | ||
for root in modules.values { | ||
for root in modules { | ||
for (_, tree) in root.children { | ||
for subtree in tree.storage.values { | ||
for node in subtree.values where node.symbol != nil { | ||
|
@@ -461,7 +461,7 @@ extension PathHierarchy { | |
} | ||
} | ||
} | ||
return Array(result) + modules.values.map { $0.identifier } | ||
return Array(result) + modules.map { $0.identifier } | ||
} | ||
} | ||
|
||
|
@@ -566,6 +566,8 @@ extension PathHierarchy { | |
pathComponents: [], | ||
docComment: nil, | ||
accessLevel: .public, | ||
// To make the file format smaller we don't store the symbol kind identifiers with each node. Instead, the kind identifier is stored | ||
// as disambiguation and is filled in while building up the hierarchy below. | ||
kind: SymbolGraph.Symbol.Kind(rawIdentifier: "", displayName: ""), | ||
mixins: [:] | ||
) | ||
|
@@ -584,11 +586,21 @@ extension PathHierarchy { | |
let childNode = lookup[identifiers[child.nodeID]]! | ||
// Even if this is a symbol node, explicitly pass the kind and hash disambiguation. | ||
node.add(child: childNode, kind: child.kind, hash: child.hash) | ||
if let kind = child.kind { | ||
// Since the symbol was created with an empty symbol kind, fill in its kind identifier here. | ||
childNode.symbol?.kind.identifier = .init(identifier: kind) | ||
} | ||
} | ||
} | ||
|
||
self.lookup = lookup | ||
self.modules = fileRepresentation.modules.mapValues({ lookup[identifiers[$0]]! }) | ||
let modules = fileRepresentation.modules.map({ lookup[identifiers[$0]]! }) | ||
// Fill in the symbol kind of all modules. This is needed since the modules were created with empty symbol kinds and since no other symbol has a | ||
// module as its child, so the modules didn't get their symbol kind set when building up the hierarchy above. | ||
for node in modules { | ||
node.symbol?.kind.identifier = .module | ||
} | ||
self.modules = modules | ||
sofiaromorales marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.articlesContainer = lookup[identifiers[fileRepresentation.articlesContainer]]! | ||
self.tutorialContainer = lookup[identifiers[fileRepresentation.tutorialContainer]]! | ||
self.tutorialOverviewContainer = lookup[identifiers[fileRepresentation.tutorialOverviewContainer]]! | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How this is related to the crash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a consequence of changing the modules from a dictionary to an array which also changed the file format of the serialized path hierarchy. Since that file format change isn't backwards compatible I bumped the version number.