@pharaoh-so/local-analyzer 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer.mjs +26 -5
- package/package.json +1 -1
package/dist/analyzer.mjs
CHANGED
|
@@ -27577,6 +27577,8 @@ function buildFunctionMetadata(node2, source, name) {
|
|
|
27577
27577
|
let signature = buildSignature2(node2, source, name), bodyHash = computeBodyHash3(node2), complexity = computeComplexity3(node2), paramCount = countParams3(node2), errorFlow = detectErrorFlow(node2), jsdoc = extractJSDoc(node2), isAsync = source.slice(node2.startIndex, node2.endIndex).startsWith("async");
|
|
27578
27578
|
return {
|
|
27579
27579
|
signature,
|
|
27580
|
+
sourceStart: node2.startIndex,
|
|
27581
|
+
sourceEnd: node2.endIndex,
|
|
27580
27582
|
lineStart: node2.startPosition.row + 1,
|
|
27581
27583
|
lineEnd: node2.endPosition.row + 1,
|
|
27582
27584
|
loc: node2.endPosition.row - node2.startPosition.row + 1,
|
|
@@ -27645,6 +27647,8 @@ function pushFunctionValue(holder, name, valueNode, source, functions, className
|
|
|
27645
27647
|
let fn = {
|
|
27646
27648
|
name,
|
|
27647
27649
|
signature,
|
|
27650
|
+
sourceStart: holder.startIndex,
|
|
27651
|
+
sourceEnd: valueNode.endIndex,
|
|
27648
27652
|
lineStart: holder.startPosition.row + 1,
|
|
27649
27653
|
lineEnd: valueNode.endPosition.row + 1,
|
|
27650
27654
|
loc: valueNode.endPosition.row - holder.startPosition.row + 1,
|
|
@@ -27746,9 +27750,11 @@ function extractVariableDeclaration(node2, source, functions, exports) {
|
|
|
27746
27750
|
functions.push({
|
|
27747
27751
|
name,
|
|
27748
27752
|
signature: buildArrowSignature(nameNode, valueNode, source),
|
|
27749
|
-
|
|
27753
|
+
sourceStart: declarator.startIndex,
|
|
27754
|
+
sourceEnd: valueNode.endIndex,
|
|
27755
|
+
lineStart: declarator.startPosition.row + 1,
|
|
27750
27756
|
lineEnd: valueNode.endPosition.row + 1,
|
|
27751
|
-
loc: valueNode.endPosition.row -
|
|
27757
|
+
loc: valueNode.endPosition.row - declarator.startPosition.row + 1,
|
|
27752
27758
|
complexity: computeComplexity3(valueNode),
|
|
27753
27759
|
isExported,
|
|
27754
27760
|
isAsync,
|
|
@@ -28417,6 +28423,7 @@ var ExportRegistry = class {
|
|
|
28417
28423
|
isExported: fn.isExported,
|
|
28418
28424
|
lineStart: fn.lineStart,
|
|
28419
28425
|
lineEnd: fn.lineEnd,
|
|
28426
|
+
...fn.sourceStart !== void 0 && fn.sourceEnd !== void 0 ? { sourceStart: fn.sourceStart, sourceEnd: fn.sourceEnd } : {},
|
|
28420
28427
|
loc: fn.loc,
|
|
28421
28428
|
signature: fn.signature,
|
|
28422
28429
|
complexity: fn.complexity,
|
|
@@ -28668,6 +28675,7 @@ var ExportRegistry = class {
|
|
|
28668
28675
|
signature: fn.signature,
|
|
28669
28676
|
lineStart: fn.lineStart,
|
|
28670
28677
|
lineEnd: fn.lineEnd,
|
|
28678
|
+
...fn.sourceStart !== void 0 && fn.sourceEnd !== void 0 ? { sourceStart: fn.sourceStart, sourceEnd: fn.sourceEnd } : {},
|
|
28671
28679
|
loc: fn.loc,
|
|
28672
28680
|
complexity: fn.complexity,
|
|
28673
28681
|
isExported: fn.isExported,
|
|
@@ -29794,8 +29802,16 @@ function functionNodesByRow(root2) {
|
|
|
29794
29802
|
let name = child.childForFieldName("name"), value = child.childForFieldName("value");
|
|
29795
29803
|
if (name?.type !== "identifier" || !value || !FUNCTION_VALUE_NODE_TYPES.has(value.type))
|
|
29796
29804
|
continue;
|
|
29797
|
-
let key = declarationKey(
|
|
29798
|
-
|
|
29805
|
+
let key = declarationKey(
|
|
29806
|
+
"binding",
|
|
29807
|
+
child.startPosition.row,
|
|
29808
|
+
value.endPosition.row,
|
|
29809
|
+
name.text
|
|
29810
|
+
);
|
|
29811
|
+
byDeclaration.has(key) || byDeclaration.set(key, value), byDeclaration.set(
|
|
29812
|
+
declarationKey("binding-range", child.startIndex, value.endIndex, name.text),
|
|
29813
|
+
value
|
|
29814
|
+
);
|
|
29799
29815
|
}
|
|
29800
29816
|
if (type === "function_declaration" || type === "function_definition") {
|
|
29801
29817
|
let name = node2.childForFieldName("name");
|
|
@@ -29815,7 +29831,12 @@ function functionNodesByRow(root2) {
|
|
|
29815
29831
|
function indexedFunctionNode(index, fn) {
|
|
29816
29832
|
let row = fn.lineStart - 1;
|
|
29817
29833
|
if (!fn.className) {
|
|
29818
|
-
let kind = /^(?:async )?const /.test(fn.signature) ? "binding" : "named"
|
|
29834
|
+
let kind = /^(?:async )?const /.test(fn.signature) ? "binding" : "named";
|
|
29835
|
+
if (kind === "binding" && fn.sourceStart !== void 0 && fn.sourceEnd !== void 0)
|
|
29836
|
+
return index.byDeclaration.get(
|
|
29837
|
+
declarationKey("binding-range", fn.sourceStart, fn.sourceEnd, fn.name)
|
|
29838
|
+
);
|
|
29839
|
+
let exact = index.byDeclaration.get(declarationKey(kind, row, fn.lineEnd - 1, fn.name));
|
|
29819
29840
|
if (exact) return exact;
|
|
29820
29841
|
}
|
|
29821
29842
|
return index.byRow.get(row);
|