| ... | ... | @@ -3242,42 +3242,33 @@ const NAV_MODES = { |
| 3242 | 3242 | |
| 3243 | 3243 | let len = t.pubDecls ? t.pubDecls.length : 0; |
| 3244 | 3244 | for (let declI = 0; declI < len; declI += 1) { |
| 3245 | | let mainDeclIndex = t.pubDecls[declI]; |
| 3246 | | if (list[mainDeclIndex] != null) continue; |
| 3247 | | |
| 3248 | | let decl = getDecl(mainDeclIndex); |
| 3249 | | let declVal = resolveValue(decl.value); |
| 3250 | | let declNames = item.declNames.concat([decl.name]); |
| 3251 | | list[mainDeclIndex] = { |
| 3252 | | pkgNames: pkgNames, |
| 3253 | | declNames: declNames, |
| 3254 | | }; |
| 3255 | | if ("type" in declVal.expr) { |
| 3256 | | let value = getType(declVal.expr.type); |
| 3257 | | if (declCanRepresentTypeKind(value.kind)) { |
| 3258 | | canonTypeDecls[declVal.type] = mainDeclIndex; |
| 3259 | | } |
| 3260 | | |
| 3261 | | if (isContainerType(value)) { |
| 3262 | | stack.push({ |
| 3263 | | declNames: declNames, |
| 3264 | | type: value, |
| 3265 | | }); |
| 3266 | | } |
| 3267 | | |
| 3268 | | // Generic function |
| 3269 | | if (value.kind == typeKinds.Fn && value.generic_ret != null) { |
| 3270 | | let resolvedVal = resolveValue({ expr: value.generic_ret }); |
| 3271 | | if ("type" in resolvedVal.expr) { |
| 3272 | | let generic_type = getType(resolvedVal.expr.type); |
| 3273 | | if (isContainerType(generic_type)) { |
| 3274 | | stack.push({ |
| 3275 | | declNames: declNames, |
| 3276 | | type: generic_type, |
| 3277 | | }); |
| 3245 | let declIndex = t.pubDecls[declI]; |
| 3246 | if (list[declIndex] != null) continue; |
| 3247 | |
| 3248 | let decl = getDecl(declIndex); |
| 3249 | |
| 3250 | if (decl.is_uns) { |
| 3251 | let unsDeclList = [decl]; |
| 3252 | while(unsDeclList.length != 0) { |
| 3253 | let unsDecl = unsDeclList.pop(); |
| 3254 | let unsDeclVal = resolveValue(unsDecl.value); |
| 3255 | if (!("type" in unsDeclVal.expr)) continue; |
| 3256 | let unsType = getType(unsDeclVal.expr.type); |
| 3257 | if (!isContainerType(unsType)) continue; |
| 3258 | let unsPubDeclLen = unsType.pubDecls ? unsType.pubDecls.length : 0; |
| 3259 | for (let unsDeclI = 0; unsDeclI < unsPubDeclLen; unsDeclI += 1) { |
| 3260 | let childDeclIndex = unsType.pubDecls[unsDeclI]; |
| 3261 | let childDecl = getDecl(childDeclIndex); |
| 3262 | |
| 3263 | if (childDecl.is_uns) { |
| 3264 | unsDeclList.push(childDecl); |
| 3265 | } else { |
| 3266 | addDeclToSearchResults(childDecl, childDeclIndex, pkgNames, item, list, stack); |
| 3278 | 3267 | } |
| 3279 | 3268 | } |
| 3280 | 3269 | } |
| 3270 | } else { |
| 3271 | addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack); |
| 3281 | 3272 | } |
| 3282 | 3273 | } |
| 3283 | 3274 | } |
| ... | ... | @@ -3286,6 +3277,45 @@ const NAV_MODES = { |
| 3286 | 3277 | return list; |
| 3287 | 3278 | } |
| 3288 | 3279 | |
| 3280 | function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) { |
| 3281 | let declVal = resolveValue(decl.value); |
| 3282 | let declNames = item.declNames.concat([decl.name]); |
| 3283 | |
| 3284 | if (list[declIndex] != null) return; |
| 3285 | list[declIndex] = { |
| 3286 | pkgNames: pkgNames, |
| 3287 | declNames: declNames, |
| 3288 | }; |
| 3289 | |
| 3290 | if ("type" in declVal.expr) { |
| 3291 | let value = getType(declVal.expr.type); |
| 3292 | if (declCanRepresentTypeKind(value.kind)) { |
| 3293 | canonTypeDecls[declVal.type] = declIndex; |
| 3294 | } |
| 3295 | |
| 3296 | if (isContainerType(value)) { |
| 3297 | stack.push({ |
| 3298 | declNames: declNames, |
| 3299 | type: value, |
| 3300 | }); |
| 3301 | } |
| 3302 | |
| 3303 | // Generic function |
| 3304 | if (value.kind == typeKinds.Fn && value.generic_ret != null) { |
| 3305 | let resolvedVal = resolveValue({ expr: value.generic_ret }); |
| 3306 | if ("type" in resolvedVal.expr) { |
| 3307 | let generic_type = getType(resolvedVal.expr.type); |
| 3308 | if (isContainerType(generic_type)) { |
| 3309 | stack.push({ |
| 3310 | declNames: declNames, |
| 3311 | type: generic_type, |
| 3312 | }); |
| 3313 | } |
| 3314 | } |
| 3315 | } |
| 3316 | } |
| 3317 | } |
| 3318 | |
| 3289 | 3319 | function getCanonDeclPath(index) { |
| 3290 | 3320 | if (canonDeclPaths == null) { |
| 3291 | 3321 | canonDeclPaths = computeCanonDeclPaths(); |