| ... | ... | @@ -57,15 +57,19 @@ |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @typedef { |
| 60 | | { kind: number } & ( |
| 61 | | | { name: string } // Type, Void, Bool, NoReturn, Int, Float, ComptimeExpr, ComptimeFloat, ComptimeInt, Undefined, Null, ErrorUnion, BoundFn, Opaque, Frame, AnyFrame, Vector, EnumLiteral |
| 62 | | | { name: string; child: TypeRef } // Optional |
| 63 | | | { len: WalkResult; child: TypeRef } // Array |
| 64 | | | { name: string; fields: { name: string; docs: string }[] } // ErrorSet |
| 65 | | | { size: "One" | "Many" | "Slice" | "C"; child: TypeRef } // Pointer |
| 66 | | | { name: string; src: number; privDecls: number[]; pubDecls: number[]; fields: WalkResult[] } // Struct, Enum, Union |
| 67 | | | { name: string; src: number; ret: WalkResult; params: WalkResult[] } // Fn |
| 68 | | ) |
| 60 | | { kind: number, name: string; src: number; privDecls: number[]; pubDecls: number[]; fields: WalkResult[] } // Struct, Enum, Union |
| 61 | } ContainerType |
| 62 | */ |
| 63 | |
| 64 | /** |
| 65 | * @typedef { |
| 66 | | { kind: number, name: string } // Type, Void, Bool, NoReturn, Int, Float, ComptimeExpr, ComptimeFloat, ComptimeInt, Undefined, Null, ErrorUnion, BoundFn, Opaque, Frame, AnyFrame, Vector, EnumLiteral |
| 67 | | { kind: number, name: string; child: TypeRef } // Optional |
| 68 | | { kind: number, len: WalkResult; child: TypeRef } // Array |
| 69 | | { kind: number, name: string; fields: { name: string; docs: string }[] } // ErrorSet |
| 70 | | { kind: number, size: "One" | "Many" | "Slice" | "C"; child: TypeRef } // Pointer |
| 71 | | ContainerType |
| 72 | | { kind: number, name: string; src: number; ret: WalkResult; params: WalkResult[] } // Fn |
| 69 | 73 | } Type |
| 70 | 74 | */ |
| 71 | 75 | |
| ... | ... | @@ -156,7 +160,7 @@ |
| 156 | 160 | errors: {}; |
| 157 | 161 | astNodes: AstNode[]; |
| 158 | 162 | calls: Call[]; |
| 159 | | files: Record<string, number>; |
| 163 | files: Record<string, string>; |
| 160 | 164 | types: Type[]; |
| 161 | 165 | decls: Decl[]; |
| 162 | 166 | comptimeExprs: ComptimeExpr[]; |
| ... | ... | @@ -168,53 +172,57 @@ |
| 168 | 172 | var zigAnalysis; |
| 169 | 173 | |
| 170 | 174 | (function() { |
| 171 | | var domStatus = document.getElementById("status"); |
| 172 | | var domSectNav = document.getElementById("sectNav"); |
| 173 | | var domListNav = document.getElementById("listNav"); |
| 174 | | var domSectMainPkg = document.getElementById("sectMainPkg"); |
| 175 | | var domSectPkgs = document.getElementById("sectPkgs"); |
| 176 | | var domListPkgs = document.getElementById("listPkgs"); |
| 177 | | var domSectTypes = document.getElementById("sectTypes"); |
| 178 | | var domListTypes = document.getElementById("listTypes"); |
| 179 | | var domSectTests = document.getElementById("sectTests"); |
| 180 | | var domListTests = document.getElementById("listTests"); |
| 181 | | var domSectNamespaces = document.getElementById("sectNamespaces"); |
| 182 | | var domListNamespaces = document.getElementById("listNamespaces"); |
| 183 | | var domSectErrSets = document.getElementById("sectErrSets"); |
| 184 | | var domListErrSets = document.getElementById("listErrSets"); |
| 185 | | var domSectFns = document.getElementById("sectFns"); |
| 186 | | var domListFns = document.getElementById("listFns"); |
| 187 | | var domSectFields = document.getElementById("sectFields"); |
| 188 | | var domListFields = document.getElementById("listFields"); |
| 189 | | var domSectGlobalVars = document.getElementById("sectGlobalVars"); |
| 190 | | var domListGlobalVars = document.getElementById("listGlobalVars"); |
| 191 | | var domSectValues = document.getElementById("sectValues"); |
| 192 | | var domListValues = document.getElementById("listValues"); |
| 193 | | var domFnProto = document.getElementById("fnProto"); |
| 194 | | var domFnProtoCode = document.getElementById("fnProtoCode"); |
| 195 | | var domSectParams = document.getElementById("sectParams"); |
| 196 | | var domListParams = document.getElementById("listParams"); |
| 197 | | var domTldDocs = document.getElementById("tldDocs"); |
| 198 | | var domSectFnErrors = document.getElementById("sectFnErrors"); |
| 199 | | var domListFnErrors = document.getElementById("listFnErrors"); |
| 200 | | var domTableFnErrors = document.getElementById("tableFnErrors"); |
| 201 | | var domFnErrorsAnyError = document.getElementById("fnErrorsAnyError"); |
| 202 | | var domFnExamples = document.getElementById("fnExamples"); |
| 203 | | var domListFnExamples = document.getElementById("listFnExamples"); |
| 204 | | var domFnNoExamples = document.getElementById("fnNoExamples"); |
| 205 | | var domDeclNoRef = document.getElementById("declNoRef"); |
| 206 | | var domSearch = document.getElementById("search"); |
| 207 | | var domSectSearchResults = document.getElementById("sectSearchResults"); |
| 208 | | var domListSearchResults = document.getElementById("listSearchResults"); |
| 209 | | var domSectSearchNoResults = document.getElementById("sectSearchNoResults"); |
| 210 | | var domSectInfo = document.getElementById("sectInfo"); |
| 211 | | var domTdTarget = document.getElementById("tdTarget"); |
| 212 | | var domPrivDeclsBox = document.getElementById("privDeclsBox"); |
| 213 | | var domTdZigVer = document.getElementById("tdZigVer"); |
| 214 | | var domHdrName = document.getElementById("hdrName"); |
| 215 | | var domHelpModal = document.getElementById("helpDialog"); |
| 216 | | |
| 175 | var domStatus = /** @type HTMLElement */(document.getElementById("status")); |
| 176 | var domSectNav = /** @type HTMLElement */(document.getElementById("sectNav")); |
| 177 | var domListNav = /** @type HTMLElement */(document.getElementById("listNav")); |
| 178 | var domSectMainPkg = /** @type HTMLElement */(document.getElementById("sectMainPkg")); |
| 179 | var domSectPkgs = /** @type HTMLElement */(document.getElementById("sectPkgs")); |
| 180 | var domListPkgs = /** @type HTMLElement */(document.getElementById("listPkgs")); |
| 181 | var domSectTypes = /** @type HTMLElement */(document.getElementById("sectTypes")); |
| 182 | var domListTypes = /** @type HTMLElement */(document.getElementById("listTypes")); |
| 183 | var domSectTests = /** @type HTMLElement */(document.getElementById("sectTests")); |
| 184 | var domListTests = /** @type HTMLElement */(document.getElementById("listTests")); |
| 185 | var domSectNamespaces = /** @type HTMLElement */(document.getElementById("sectNamespaces")); |
| 186 | var domListNamespaces = /** @type HTMLElement */(document.getElementById("listNamespaces")); |
| 187 | var domSectErrSets = /** @type HTMLElement */(document.getElementById("sectErrSets")); |
| 188 | var domListErrSets = /** @type HTMLElement */(document.getElementById("listErrSets")); |
| 189 | var domSectFns = /** @type HTMLElement */(document.getElementById("sectFns")); |
| 190 | var domListFns = /** @type HTMLElement */(document.getElementById("listFns")); |
| 191 | var domSectFields = /** @type HTMLElement */(document.getElementById("sectFields")); |
| 192 | var domListFields = /** @type HTMLElement */(document.getElementById("listFields")); |
| 193 | var domSectGlobalVars = /** @type HTMLElement */(document.getElementById("sectGlobalVars")); |
| 194 | var domListGlobalVars = /** @type HTMLElement */(document.getElementById("listGlobalVars")); |
| 195 | var domSectValues = /** @type HTMLElement */(document.getElementById("sectValues")); |
| 196 | var domListValues = /** @type HTMLElement */(document.getElementById("listValues")); |
| 197 | var domFnProto = /** @type HTMLElement */(document.getElementById("fnProto")); |
| 198 | var domFnProtoCode = /** @type HTMLElement */(document.getElementById("fnProtoCode")); |
| 199 | var domSectParams = /** @type HTMLElement */(document.getElementById("sectParams")); |
| 200 | var domListParams = /** @type HTMLElement */(document.getElementById("listParams")); |
| 201 | var domTldDocs = /** @type HTMLElement */(document.getElementById("tldDocs")); |
| 202 | var domSectFnErrors = /** @type HTMLElement */(document.getElementById("sectFnErrors")); |
| 203 | var domListFnErrors = /** @type HTMLElement */(document.getElementById("listFnErrors")); |
| 204 | var domTableFnErrors =/** @type HTMLElement */(document.getElementById("tableFnErrors")); |
| 205 | var domFnErrorsAnyError = /** @type HTMLElement */(document.getElementById("fnErrorsAnyError")); |
| 206 | var domFnExamples = /** @type HTMLElement */(document.getElementById("fnExamples")); |
| 207 | var domListFnExamples = /** @type HTMLElement */(document.getElementById("listFnExamples")); |
| 208 | var domFnNoExamples = /** @type HTMLElement */(document.getElementById("fnNoExamples")); |
| 209 | var domDeclNoRef = /** @type HTMLElement */(document.getElementById("declNoRef")); |
| 210 | var domSearch = /** @type HTMLInputElement */(document.getElementById("search")); |
| 211 | var domSectSearchResults = /** @type HTMLElement */(document.getElementById("sectSearchResults")); |
| 212 | |
| 213 | var domListSearchResults = /** @type HTMLElement */(document.getElementById("listSearchResults")); |
| 214 | var domSectSearchNoResults = /** @type HTMLElement */(document.getElementById("sectSearchNoResults")); |
| 215 | var domSectInfo = /** @type HTMLElement */(document.getElementById("sectInfo")); |
| 216 | var domTdTarget = /** @type HTMLElement */(document.getElementById("tdTarget")); |
| 217 | var domPrivDeclsBox = /** @type HTMLElement */(document.getElementById("privDeclsBox")); |
| 218 | var domTdZigVer = /** @type HTMLElement */(document.getElementById("tdZigVer")); |
| 219 | var domHdrName = /** @type HTMLElement */(document.getElementById("hdrName")); |
| 220 | var domHelpModal = /** @type HTMLElement */(document.getElementById("helpDialog")); |
| 221 | |
| 222 | /** @type number | null */ |
| 217 | 223 | var searchTimer = null; |
| 224 | |
| 225 | /** @type Object<string, string> */ |
| 218 | 226 | var escapeHtmlReplacements = { "&": "&amp;", '"': "&quot;", "<": "&lt;", ">": "&gt;" }; |
| 219 | 227 | |
| 220 | 228 | var typeKinds = indexTypeKinds(); |
| ... | ... | @@ -298,12 +306,6 @@ var zigAnalysis; |
| 298 | 306 | return isType(x) && typeKindIsContainer(x.kind) ; |
| 299 | 307 | } |
| 300 | 308 | |
| 301 | | function declContainsType(x){ |
| 302 | | console.assert("value" in x); |
| 303 | | |
| 304 | | |
| 305 | | } |
| 306 | | |
| 307 | 309 | function typeShorthandName(type) { |
| 308 | 310 | var name = type.name; |
| 309 | 311 | if (type.kind === typeKinds.Struct) { |
| ... | ... | @@ -1434,6 +1436,10 @@ var zigAnalysis; |
| 1434 | 1436 | } |
| 1435 | 1437 | |
| 1436 | 1438 | |
| 1439 | /** |
| 1440 | * @param {number[]} decls |
| 1441 | * @param {Decl[]} typesList, namespacesList, errSetsList, fnsList, varsList, valsList, testsList |
| 1442 | */ |
| 1437 | 1443 | function categorizeDecls(decls, |
| 1438 | 1444 | typesList, namespacesList, errSetsList, |
| 1439 | 1445 | fnsList, varsList, valsList, testsList) { |
| ... | ... | @@ -1495,13 +1501,23 @@ var zigAnalysis; |
| 1495 | 1501 | } |
| 1496 | 1502 | } |
| 1497 | 1503 | |
| 1504 | /** |
| 1505 | * @param {ContainerType} container |
| 1506 | */ |
| 1498 | 1507 | function renderContainer(container) { |
| 1508 | /** @type {Decl[]} */ |
| 1499 | 1509 | var typesList = []; |
| 1510 | /** @type {Decl[]} */ |
| 1500 | 1511 | var namespacesList = []; |
| 1512 | /** @type {Decl[]} */ |
| 1501 | 1513 | var errSetsList = []; |
| 1514 | /** @type {Decl[]} */ |
| 1502 | 1515 | var fnsList = []; |
| 1516 | /** @type {Decl[]} */ |
| 1503 | 1517 | var varsList = []; |
| 1518 | /** @type {Decl[]} */ |
| 1504 | 1519 | var valsList = []; |
| 1520 | /** @type {Decl[]} */ |
| 1505 | 1521 | var testsList = []; |
| 1506 | 1522 | |
| 1507 | 1523 | categorizeDecls(container.pubDecls, |
| ... | ... | @@ -1911,20 +1927,32 @@ var zigAnalysis; |
| 1911 | 1927 | return canonTypeDecls[index]; |
| 1912 | 1928 | } |
| 1913 | 1929 | |
| 1930 | /** @param {string} text */ |
| 1914 | 1931 | function escapeHtml(text) { |
| 1915 | 1932 | return text.replace(/[&"<>]/g, function (m) { |
| 1916 | 1933 | return escapeHtmlReplacements[m]; |
| 1917 | 1934 | }); |
| 1918 | 1935 | } |
| 1919 | 1936 | |
| 1937 | /** @param {string} docs */ |
| 1920 | 1938 | function shortDescMarkdown(docs) { |
| 1921 | 1939 | var parts = docs.trim().split("\n"); |
| 1922 | 1940 | var firstLine = parts[0]; |
| 1923 | 1941 | return markdown(firstLine); |
| 1924 | 1942 | } |
| 1925 | 1943 | |
| 1944 | /** @param {string} input */ |
| 1926 | 1945 | function markdown(input) { |
| 1927 | 1946 | const raw_lines = input.split('\n'); // zig allows no '\r', so we don't need to split on CR |
| 1947 | /** |
| 1948 | * @type Array<{ |
| 1949 | * indent: number, |
| 1950 | * raw_text: string, |
| 1951 | * text: string, |
| 1952 | * type: string, |
| 1953 | * ordered_number: number, |
| 1954 | * }> |
| 1955 | */ |
| 1928 | 1956 | const lines = []; |
| 1929 | 1957 | |
| 1930 | 1958 | // PHASE 1: |
| ... | ... | @@ -1941,6 +1969,7 @@ var zigAnalysis; |
| 1941 | 1969 | raw_text: raw_line, |
| 1942 | 1970 | text: raw_line.trim(), |
| 1943 | 1971 | type: "p", // p, h1 … h6, code, ul, ol, blockquote, skip, empty |
| 1972 | ordered_number: -1, // NOTE: hack to make the type checker happy |
| 1944 | 1973 | }; |
| 1945 | 1974 | |
| 1946 | 1975 | if (!is_reading_code) { |
| ... | ... | @@ -1977,7 +2006,7 @@ var zigAnalysis; |
| 1977 | 2006 | line.text = line.text.substr(1); |
| 1978 | 2007 | } |
| 1979 | 2008 | else if (line.text.match(/^\d+\..*$/)) { // if line starts with {number}{dot} |
| 1980 | | const match = line.text.match(/(\d+)\./); |
| 2009 | const match = /** @type {RegExpMatchArray} */(line.text.match(/(\d+)\./)); |
| 1981 | 2010 | line.type = "ul"; |
| 1982 | 2011 | line.text = line.text.substr(match[0].length); |
| 1983 | 2012 | line.ordered_number = Number(match[1].length); |
| ... | ... | @@ -2010,7 +2039,10 @@ var zigAnalysis; |
| 2010 | 2039 | // Render HTML from markdown lines. |
| 2011 | 2040 | // Look at each line and emit fitting HTML code |
| 2012 | 2041 | |
| 2013 | | function markdownInlines(innerText, stopChar) { |
| 2042 | /** |
| 2043 | * @param {string } innerText |
| 2044 | */ |
| 2045 | function markdownInlines(innerText) { |
| 2014 | 2046 | |
| 2015 | 2047 | // inline types: |
| 2016 | 2048 | // **{INLINE}** : <strong> |
| ... | ... | @@ -2023,6 +2055,8 @@ var zigAnalysis; |
| 2023 | 2055 | //  : <img> |
| 2024 | 2056 | // [[std;format.fmt]] : <a> (inner link) |
| 2025 | 2057 | |
| 2058 | /** @typedef {{marker: string, tag: string}} Fmt*/ |
| 2059 | /** @type {Array<Fmt>} */ |
| 2026 | 2060 | const formats = [ |
| 2027 | 2061 | { |
| 2028 | 2062 | marker: "**", |
| ... | ... | @@ -2042,6 +2076,7 @@ var zigAnalysis; |
| 2042 | 2076 | } |
| 2043 | 2077 | ]; |
| 2044 | 2078 | |
| 2079 | /** @type {Array<Fmt>} */ |
| 2045 | 2080 | const stack = []; |
| 2046 | 2081 | |
| 2047 | 2082 | var innerHTML = ""; |
| ... | ... | @@ -2093,7 +2128,7 @@ var zigAnalysis; |
| 2093 | 2128 | in_code = true; |
| 2094 | 2129 | } else { |
| 2095 | 2130 | var any = false; |
| 2096 | | for (var idx = (stack.length > 0 ? -1 : 0); idx < formats.length; idx++) { |
| 2131 | for (let idx = /** @type {number} */(stack.length > 0 ? -1 : 0); idx < formats.length; idx++) { |
| 2097 | 2132 | const fmt = idx >= 0 ? formats[idx] : stack[stack.length - 1]; |
| 2098 | 2133 | if (innerText.substr(i, fmt.marker.length) == fmt.marker) { |
| 2099 | 2134 | flushRun(); |
| ... | ... | @@ -2117,48 +2152,60 @@ var zigAnalysis; |
| 2117 | 2152 | flushRun(); |
| 2118 | 2153 | |
| 2119 | 2154 | while (stack.length > 0) { |
| 2120 | | const fmt = stack.pop(); |
| 2155 | const fmt = /** @type {Fmt} */(stack.pop()); |
| 2121 | 2156 | innerHTML += "</" + fmt.tag + ">"; |
| 2122 | 2157 | } |
| 2123 | 2158 | |
| 2124 | 2159 | return innerHTML; |
| 2125 | 2160 | } |
| 2126 | 2161 | |
| 2127 | | var html = ""; |
| 2128 | | for (var line_no = 0; line_no < lines.length; line_no++) { |
| 2129 | | const line = lines[line_no]; |
| 2130 | | |
| 2131 | | function previousLineIs(type) { |
| 2132 | | if (line_no > 0) { |
| 2133 | | return (lines[line_no - 1].type == type); |
| 2134 | | } else { |
| 2135 | | return false; |
| 2136 | | } |
| 2162 | /** |
| 2163 | * @param {string} type |
| 2164 | * @param {number} line_no |
| 2165 | */ |
| 2166 | function previousLineIs(type, line_no) { |
| 2167 | if (line_no > 0) { |
| 2168 | return (lines[line_no - 1].type == type); |
| 2169 | } else { |
| 2170 | return false; |
| 2137 | 2171 | } |
| 2172 | } |
| 2138 | 2173 | |
| 2139 | | function nextLineIs(type) { |
| 2140 | | if (line_no < (lines.length - 1)) { |
| 2141 | | return (lines[line_no + 1].type == type); |
| 2142 | | } else { |
| 2143 | | return false; |
| 2144 | | } |
| 2174 | /** |
| 2175 | * @param {string} type |
| 2176 | * @param {number} line_no |
| 2177 | */ |
| 2178 | function nextLineIs(type, line_no) { |
| 2179 | if (line_no < (lines.length - 1)) { |
| 2180 | return (lines[line_no + 1].type == type); |
| 2181 | } else { |
| 2182 | return false; |
| 2145 | 2183 | } |
| 2184 | } |
| 2146 | 2185 | |
| 2147 | | function getPreviousLineIndent() { |
| 2148 | | if (line_no > 0) { |
| 2149 | | return lines[line_no - 1].indent; |
| 2150 | | } else { |
| 2151 | | return 0; |
| 2152 | | } |
| 2186 | /** @param {number} line_no */ |
| 2187 | function getPreviousLineIndent(line_no) { |
| 2188 | if (line_no > 0) { |
| 2189 | return lines[line_no - 1].indent; |
| 2190 | } else { |
| 2191 | return 0; |
| 2153 | 2192 | } |
| 2193 | } |
| 2154 | 2194 | |
| 2155 | | function getNextLineIndent() { |
| 2156 | | if (line_no < (lines.length - 1)) { |
| 2157 | | return lines[line_no + 1].indent; |
| 2158 | | } else { |
| 2159 | | return 0; |
| 2160 | | } |
| 2195 | /** @param {number} line_no */ |
| 2196 | function getNextLineIndent(line_no) { |
| 2197 | if (line_no < (lines.length - 1)) { |
| 2198 | return lines[line_no + 1].indent; |
| 2199 | } else { |
| 2200 | return 0; |
| 2161 | 2201 | } |
| 2202 | } |
| 2203 | |
| 2204 | var html = ""; |
| 2205 | for (var line_no = 0; line_no < lines.length; line_no++) { |
| 2206 | const line = lines[line_no]; |
| 2207 | |
| 2208 | |
| 2162 | 2209 | |
| 2163 | 2210 | switch (line.type) { |
| 2164 | 2211 | case "h1": |
| ... | ... | @@ -2172,33 +2219,33 @@ var zigAnalysis; |
| 2172 | 2219 | |
| 2173 | 2220 | case "ul": |
| 2174 | 2221 | case "ol": |
| 2175 | | if (!previousLineIs("ul") || getPreviousLineIndent() < line.indent) { |
| 2222 | if (!previousLineIs("ul", line_no) || getPreviousLineIndent(line_no) < line.indent) { |
| 2176 | 2223 | html += "<" + line.type + ">\n"; |
| 2177 | 2224 | } |
| 2178 | 2225 | |
| 2179 | 2226 | html += "<li>" + markdownInlines(line.text) + "</li>\n"; |
| 2180 | 2227 | |
| 2181 | | if (!nextLineIs("ul") || getNextLineIndent() < line.indent) { |
| 2228 | if (!nextLineIs("ul", line_no) || getNextLineIndent(line_no) < line.indent) { |
| 2182 | 2229 | html += "</" + line.type + ">\n"; |
| 2183 | 2230 | } |
| 2184 | 2231 | break; |
| 2185 | 2232 | |
| 2186 | 2233 | case "p": |
| 2187 | | if (!previousLineIs("p")) { |
| 2234 | if (!previousLineIs("p", line_no)) { |
| 2188 | 2235 | html += "<p>\n"; |
| 2189 | 2236 | } |
| 2190 | 2237 | html += markdownInlines(line.text) + "\n"; |
| 2191 | | if (!nextLineIs("p")) { |
| 2238 | if (!nextLineIs("p", line_no)) { |
| 2192 | 2239 | html += "</p>\n"; |
| 2193 | 2240 | } |
| 2194 | 2241 | break; |
| 2195 | 2242 | |
| 2196 | 2243 | case "code": |
| 2197 | | if (!previousLineIs("code")) { |
| 2244 | if (!previousLineIs("code", line_no)) { |
| 2198 | 2245 | html += "<pre><code>"; |
| 2199 | 2246 | } |
| 2200 | 2247 | html += escapeHtml(line.text) + "\n"; |
| 2201 | | if (!nextLineIs("code")) { |
| 2248 | if (!nextLineIs("code", line_no)) { |
| 2202 | 2249 | html += "</code></pre>\n"; |
| 2203 | 2250 | } |
| 2204 | 2251 | break; |
| ... | ... | @@ -2219,12 +2266,13 @@ var zigAnalysis; |
| 2219 | 2266 | } |
| 2220 | 2267 | if (liDom != null) { |
| 2221 | 2268 | var aDom = liDom.children[0]; |
| 2222 | | location.href = aDom.getAttribute("href"); |
| 2269 | location.href = /** @type {string} */(aDom.getAttribute("href")); |
| 2223 | 2270 | curSearchIndex = -1; |
| 2224 | 2271 | } |
| 2225 | 2272 | domSearch.blur(); |
| 2226 | 2273 | } |
| 2227 | 2274 | |
| 2275 | /** @param {KeyboardEvent} ev */ |
| 2228 | 2276 | function onSearchKeyDown(ev) { |
| 2229 | 2277 | switch (getKeyString(ev)) { |
| 2230 | 2278 | case "Enter": |
| ... | ... | @@ -2268,6 +2316,8 @@ var zigAnalysis; |
| 2268 | 2316 | } |
| 2269 | 2317 | } |
| 2270 | 2318 | |
| 2319 | |
| 2320 | /** @param {number} dir */ |
| 2271 | 2321 | function moveSearchCursor(dir) { |
| 2272 | 2322 | if (curSearchIndex < 0 || curSearchIndex >= domListSearchResults.children.length) { |
| 2273 | 2323 | if (dir > 0) { |
| ... | ... | @@ -2287,6 +2337,7 @@ var zigAnalysis; |
| 2287 | 2337 | renderSearchCursor(); |
| 2288 | 2338 | } |
| 2289 | 2339 | |
| 2340 | /** @param {KeyboardEvent} ev */ |
| 2290 | 2341 | function getKeyString(ev) { |
| 2291 | 2342 | var name; |
| 2292 | 2343 | var ignoreShift = false; |
| ... | ... | @@ -2313,6 +2364,7 @@ var zigAnalysis; |
| 2313 | 2364 | return name; |
| 2314 | 2365 | } |
| 2315 | 2366 | |
| 2367 | /** @param {KeyboardEvent} ev */ |
| 2316 | 2368 | function onWindowKeyDown(ev) { |
| 2317 | 2369 | switch (getKeyString(ev)) { |
| 2318 | 2370 | case "Esc": |
| ... | ... | @@ -2451,7 +2503,7 @@ function renderSearch() { |
| 2451 | 2503 | |
| 2452 | 2504 | function renderSearchCursor() { |
| 2453 | 2505 | for (var i = 0; i < domListSearchResults.children.length; i += 1) { |
| 2454 | | var liDom = domListSearchResults.children[i]; |
| 2506 | var liDom = /** @type HTMLElement */(domListSearchResults.children[i]); |
| 2455 | 2507 | if (curSearchIndex === i) { |
| 2456 | 2508 | liDom.classList.add("selected"); |
| 2457 | 2509 | } else { |
| ... | ... | @@ -2462,35 +2514,42 @@ function renderSearchCursor() { |
| 2462 | 2514 | |
| 2463 | 2515 | |
| 2464 | 2516 | |
| 2465 | | function indexNodesToCalls() { |
| 2466 | | var map = {}; |
| 2467 | | for (var i = 0; i < zigAnalysis.calls.length; i += 1) { |
| 2468 | | var call = zigAnalysis.calls[i]; |
| 2469 | | var fn = zigAnalysis.fns[call.fn]; |
| 2470 | | if (map[fn.src] == null) { |
| 2471 | | map[fn.src] = [i]; |
| 2472 | | } else { |
| 2473 | | map[fn.src].push(i); |
| 2474 | | } |
| 2475 | | } |
| 2476 | | return map; |
| 2477 | | } |
| 2517 | // function indexNodesToCalls() { |
| 2518 | // var map = {}; |
| 2519 | // for (var i = 0; i < zigAnalysis.calls.length; i += 1) { |
| 2520 | // var call = zigAnalysis.calls[i]; |
| 2521 | // var fn = zigAnalysis.fns[call.fn]; |
| 2522 | // if (map[fn.src] == null) { |
| 2523 | // map[fn.src] = [i]; |
| 2524 | // } else { |
| 2525 | // map[fn.src].push(i); |
| 2526 | // } |
| 2527 | // } |
| 2528 | // return map; |
| 2529 | // } |
| 2478 | 2530 | |
| 2531 | |
| 2532 | /** |
| 2533 | * @param {{ name: string }} a |
| 2534 | * @param {{ name: string }} b |
| 2535 | */ |
| 2479 | 2536 | function byNameProperty(a, b) { |
| 2480 | 2537 | return operatorCompare(a.name, b.name); |
| 2481 | 2538 | } |
| 2482 | 2539 | |
| 2540 | |
| 2541 | /** |
| 2542 | * @template T |
| 2543 | * @param {T} obj |
| 2544 | * @returns {T} |
| 2545 | */ |
| 2483 | 2546 | function clone(obj) { |
| 2484 | | var res = {}; |
| 2547 | var res = /** @type T */({}); |
| 2485 | 2548 | for (var key in obj) { |
| 2486 | 2549 | res[key] = obj[key]; |
| 2487 | 2550 | } |
| 2488 | 2551 | return res; |
| 2489 | 2552 | } |
| 2490 | 2553 | |
| 2491 | | function firstObjectKey(obj) { |
| 2492 | | for (var key in obj) { |
| 2493 | | return key; |
| 2494 | | } |
| 2495 | | } |
| 2554 | |
| 2496 | 2555 | })(); |