mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 15:13:08 +00:00
autodoc: index in search usingnamespace decls
This commit is contained in:
parent
5c9906c231
commit
83d1f6b15a
@ -3242,42 +3242,33 @@ const NAV_MODES = {
|
||||
|
||||
let len = t.pubDecls ? t.pubDecls.length : 0;
|
||||
for (let declI = 0; declI < len; declI += 1) {
|
||||
let mainDeclIndex = t.pubDecls[declI];
|
||||
if (list[mainDeclIndex] != null) continue;
|
||||
let declIndex = t.pubDecls[declI];
|
||||
if (list[declIndex] != null) continue;
|
||||
|
||||
let decl = getDecl(mainDeclIndex);
|
||||
let declVal = resolveValue(decl.value);
|
||||
let declNames = item.declNames.concat([decl.name]);
|
||||
list[mainDeclIndex] = {
|
||||
pkgNames: pkgNames,
|
||||
declNames: declNames,
|
||||
};
|
||||
if ("type" in declVal.expr) {
|
||||
let value = getType(declVal.expr.type);
|
||||
if (declCanRepresentTypeKind(value.kind)) {
|
||||
canonTypeDecls[declVal.type] = mainDeclIndex;
|
||||
}
|
||||
|
||||
if (isContainerType(value)) {
|
||||
stack.push({
|
||||
declNames: declNames,
|
||||
type: value,
|
||||
});
|
||||
}
|
||||
|
||||
// Generic function
|
||||
if (value.kind == typeKinds.Fn && value.generic_ret != null) {
|
||||
let resolvedVal = resolveValue({ expr: value.generic_ret });
|
||||
if ("type" in resolvedVal.expr) {
|
||||
let generic_type = getType(resolvedVal.expr.type);
|
||||
if (isContainerType(generic_type)) {
|
||||
stack.push({
|
||||
declNames: declNames,
|
||||
type: generic_type,
|
||||
});
|
||||
let decl = getDecl(declIndex);
|
||||
|
||||
if (decl.is_uns) {
|
||||
let unsDeclList = [decl];
|
||||
while(unsDeclList.length != 0) {
|
||||
let unsDecl = unsDeclList.pop();
|
||||
let unsDeclVal = resolveValue(unsDecl.value);
|
||||
if (!("type" in unsDeclVal.expr)) continue;
|
||||
let unsType = getType(unsDeclVal.expr.type);
|
||||
if (!isContainerType(unsType)) continue;
|
||||
let unsPubDeclLen = unsType.pubDecls ? unsType.pubDecls.length : 0;
|
||||
for (let unsDeclI = 0; unsDeclI < unsPubDeclLen; unsDeclI += 1) {
|
||||
let childDeclIndex = unsType.pubDecls[unsDeclI];
|
||||
let childDecl = getDecl(childDeclIndex);
|
||||
|
||||
if (childDecl.is_uns) {
|
||||
unsDeclList.push(childDecl);
|
||||
} else {
|
||||
addDeclToSearchResults(childDecl, childDeclIndex, pkgNames, item, list, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3286,6 +3277,45 @@ const NAV_MODES = {
|
||||
return list;
|
||||
}
|
||||
|
||||
function addDeclToSearchResults(decl, declIndex, pkgNames, item, list, stack) {
|
||||
let declVal = resolveValue(decl.value);
|
||||
let declNames = item.declNames.concat([decl.name]);
|
||||
|
||||
if (list[declIndex] != null) return;
|
||||
list[declIndex] = {
|
||||
pkgNames: pkgNames,
|
||||
declNames: declNames,
|
||||
};
|
||||
|
||||
if ("type" in declVal.expr) {
|
||||
let value = getType(declVal.expr.type);
|
||||
if (declCanRepresentTypeKind(value.kind)) {
|
||||
canonTypeDecls[declVal.type] = declIndex;
|
||||
}
|
||||
|
||||
if (isContainerType(value)) {
|
||||
stack.push({
|
||||
declNames: declNames,
|
||||
type: value,
|
||||
});
|
||||
}
|
||||
|
||||
// Generic function
|
||||
if (value.kind == typeKinds.Fn && value.generic_ret != null) {
|
||||
let resolvedVal = resolveValue({ expr: value.generic_ret });
|
||||
if ("type" in resolvedVal.expr) {
|
||||
let generic_type = getType(resolvedVal.expr.type);
|
||||
if (isContainerType(generic_type)) {
|
||||
stack.push({
|
||||
declNames: declNames,
|
||||
type: generic_type,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCanonDeclPath(index) {
|
||||
if (canonDeclPaths == null) {
|
||||
canonDeclPaths = computeCanonDeclPaths();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user