File tree Expand file tree Collapse file tree 3 files changed +31
-23
lines changed
Sources/PeripheryKit/Indexer Expand file tree Collapse file tree 3 files changed +31
-23
lines changed Original file line number Diff line number Diff line change 1010
1111##### Bug Fixes
1212
13- - None .
13+ - Fix another crash while indexing .
1414
1515## 2.8.5 (2022-01-03)
1616
Original file line number Diff line number Diff line change @@ -93,10 +93,14 @@ public final class SourceGraph {
9393
9494 func markRetained( _ declaration: Declaration ) {
9595 mutationQueue. sync {
96- _ = retainedDeclarations . insert ( declaration)
96+ markRetainedUnsafe ( declaration)
9797 }
9898 }
9999
100+ func markRetainedUnsafe( _ declaration: Declaration ) {
101+ _ = retainedDeclarations. insert ( declaration)
102+ }
103+
100104 func markPotentialAssignOnlyProperty( _ declaration: Declaration ) {
101105 mutationQueue. sync {
102106 _ = potentialAssignOnlyProperties. insert ( declaration)
@@ -117,12 +121,16 @@ public final class SourceGraph {
117121
118122 func add( _ declaration: Declaration ) {
119123 mutationQueue. sync {
120- allDeclarations. insert ( declaration)
121- allDeclarationsByKind [ declaration. kind, default: [ ] ] . insert ( declaration)
124+ addUnsafe ( declaration)
125+ }
126+ }
122127
123- if !declaration. isImplicit {
124- declaration. usrs. forEach { allExplicitDeclarationsByUsr [ $0] = declaration }
125- }
128+ func addUnsafe( _ declaration: Declaration ) {
129+ allDeclarations. insert ( declaration)
130+ allDeclarationsByKind [ declaration. kind, default: [ ] ] . insert ( declaration)
131+
132+ if !declaration. isImplicit {
133+ declaration. usrs. forEach { allExplicitDeclarationsByUsr [ $0] = declaration }
126134 }
127135 }
128136
Original file line number Diff line number Diff line change @@ -280,14 +280,13 @@ public final class SwiftIndexer {
280280
281281 private func associateLatentReferences( ) {
282282 for (usr, refs) in referencesByUsr {
283- guard let decl = graph. explicitDeclaration ( withUsr: usr) else {
284- danglingReferences. append ( contentsOf: refs)
285- continue
286- }
287-
288283 graph. mutating {
289- for ref in refs {
290- associateUnsafe ( ref, with: decl)
284+ if let decl = graph. explicitDeclaration ( withUsr: usr) {
285+ for ref in refs {
286+ associateUnsafe ( ref, with: decl)
287+ }
288+ } else {
289+ danglingReferences. append ( contentsOf: refs)
291290 }
292291 }
293292 }
@@ -433,15 +432,16 @@ public final class SwiftIndexer {
433432 }
434433 }
435434
436- for param in params {
437- let paramDecl = param. declaration
438- paramDecl. parent = functionDecl
439- functionDecl. unusedParameters. insert ( paramDecl)
440- graph. add ( paramDecl)
441-
442- if ignoredParamNames. contains ( param. name) ||
443- ( functionDecl. isObjcAccessible && configuration. retainObjcAccessible) {
444- graph. markRetained ( paramDecl)
435+ graph. mutating {
436+ for param in params {
437+ let paramDecl = param. declaration
438+ paramDecl. parent = functionDecl
439+ functionDecl. unusedParameters. insert ( paramDecl)
440+ graph. addUnsafe ( paramDecl)
441+
442+ if ( functionDecl. isObjcAccessible && configuration. retainObjcAccessible) || ignoredParamNames. contains ( param. name) {
443+ graph. markRetainedUnsafe ( paramDecl)
444+ }
445445 }
446446 }
447447 }
You can’t perform that action at this time.
0 commit comments