pi-hashline-edit-pro 7.0.0 → 7.1.0
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/README.md +28 -9
- package/index.ts +31 -28
- package/package.json +1 -1
- package/src/auto-read-all.ts +2 -2
- package/src/config-ui.ts +6 -1
- package/src/config.ts +6 -1
- package/src/edit-common.ts +15 -7
- package/src/model-gate.ts +1 -0
- package/src/outline/parsers.ts +0 -1
- package/src/outline/render.ts +154 -82
- package/src/outline/vendor/README.md +4 -0
- package/src/outline/vendor/parsers/blade.ts +1 -1
- package/src/outline/vendor/parsers/java.ts +144 -331
- package/src/outline/vendor/parsers/manager.ts +12 -183
- package/src/outline/vendor/parsers/php.ts +16 -81
- package/src/outline/vendor/parsers/sass.ts +0 -11
- package/src/outline/vendor/parsers/scss.ts +0 -8
- package/src/outline/vendor/types.ts +0 -1
- package/src/outline-tool.ts +184 -0
- package/src/prompts.ts +1 -0
- package/src/read.ts +1 -0
- package/src/structured.ts +32 -0
- package/tool-prompts/outline-guidelines.md +2 -0
- package/tool-prompts/outline-snippet.md +1 -0
- package/tool-prompts/outline.md +3 -0
- package/tool-prompts/read-guidelines.md +1 -1
|
@@ -356,7 +356,6 @@ function extractJSChild(
|
|
|
356
356
|
type: value.type === "arrow_function" ? "arrow_function" : "function",
|
|
357
357
|
startLine: sl,
|
|
358
358
|
endLine: el,
|
|
359
|
-
detail: extractFnDetail(value, source),
|
|
360
359
|
});
|
|
361
360
|
} else {
|
|
362
361
|
const [sl, el] = nodeRange(d);
|
|
@@ -410,13 +409,7 @@ function extractJSChild(
|
|
|
410
409
|
|
|
411
410
|
const [sl, el] = nodeRange(child);
|
|
412
411
|
|
|
413
|
-
|
|
414
|
-
let detail: string | undefined;
|
|
415
|
-
if (type === "function_declaration" || type === "function_expression" || type === "method_definition" || type === "arrow_function") {
|
|
416
|
-
detail = extractFnDetail(child, source);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
return { name, type: symbolType, startLine: sl, endLine: el, detail };
|
|
412
|
+
return { name, type: symbolType, startLine: sl, endLine: el };
|
|
420
413
|
}
|
|
421
414
|
|
|
422
415
|
const TEST_CALLEES = new Set(["describe", "test", "it", "suite", "context", "specify"]);
|
|
@@ -455,17 +448,6 @@ function extractTestCalls(call: Node, source: string): SymbolInfo[] {
|
|
|
455
448
|
return results;
|
|
456
449
|
}
|
|
457
450
|
|
|
458
|
-
function extractFnDetail(
|
|
459
|
-
node: Node,
|
|
460
|
-
source: string,
|
|
461
|
-
): string | undefined {
|
|
462
|
-
const params = node.childForFieldName("parameters");
|
|
463
|
-
if (params) {
|
|
464
|
-
return source.slice(params.startIndex, params.endIndex);
|
|
465
|
-
}
|
|
466
|
-
return undefined;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
451
|
function findChildByType(
|
|
470
452
|
node: Node,
|
|
471
453
|
types: string[],
|
|
@@ -508,11 +490,7 @@ function extractPython(
|
|
|
508
490
|
} else if (child.type === "function_definition") {
|
|
509
491
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
510
492
|
const [sl, el] = nodeRange(child);
|
|
511
|
-
|
|
512
|
-
const detail = params
|
|
513
|
-
? source.slice(params.startIndex, params.endIndex)
|
|
514
|
-
: undefined;
|
|
515
|
-
symbol = { name, type: "function", startLine: sl, endLine: el, detail };
|
|
493
|
+
symbol = { name, type: "function", startLine: sl, endLine: el };
|
|
516
494
|
} else if (child.type === "decorated_definition") {
|
|
517
495
|
// Unwrap to the inner definition
|
|
518
496
|
const def = child.namedChild(child.namedChildCount - 1);
|
|
@@ -543,11 +521,7 @@ function extractPythonSingle(
|
|
|
543
521
|
if (child.type === "function_definition") {
|
|
544
522
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
545
523
|
const [sl, el] = nodeRange(child);
|
|
546
|
-
|
|
547
|
-
const detail = params
|
|
548
|
-
? source.slice(params.startIndex, params.endIndex)
|
|
549
|
-
: undefined;
|
|
550
|
-
return { name, type: "function", startLine: sl, endLine: el, detail };
|
|
524
|
+
return { name, type: "function", startLine: sl, endLine: el };
|
|
551
525
|
}
|
|
552
526
|
return null;
|
|
553
527
|
}
|
|
@@ -677,16 +651,11 @@ function extractGoFields(
|
|
|
677
651
|
const name = fieldChildText(child, "name", source);
|
|
678
652
|
if (!name) continue;
|
|
679
653
|
const [sl, el] = nodeRange(child);
|
|
680
|
-
const typeNode = child.childForFieldName("type");
|
|
681
|
-
const typeText = typeNode
|
|
682
|
-
? source.slice(typeNode.startIndex, typeNode.endIndex)
|
|
683
|
-
: "";
|
|
684
654
|
results.push({
|
|
685
655
|
name,
|
|
686
656
|
type: "field",
|
|
687
657
|
startLine: sl,
|
|
688
658
|
endLine: el,
|
|
689
|
-
detail: typeText,
|
|
690
659
|
});
|
|
691
660
|
}
|
|
692
661
|
|
|
@@ -714,11 +683,7 @@ function extractRust(
|
|
|
714
683
|
if (child.type === "function_item") {
|
|
715
684
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
716
685
|
const [sl, el] = nodeRange(child);
|
|
717
|
-
|
|
718
|
-
const detail = params
|
|
719
|
-
? source.slice(params.startIndex, params.endIndex)
|
|
720
|
-
: undefined;
|
|
721
|
-
symbol = { name, type: "function", startLine: sl, endLine: el, detail };
|
|
686
|
+
symbol = { name, type: "function", startLine: sl, endLine: el };
|
|
722
687
|
} else if (child.type === "struct_item") {
|
|
723
688
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
724
689
|
const [sl, el] = nodeRange(child);
|
|
@@ -784,11 +749,7 @@ function extractRustImplBody(
|
|
|
784
749
|
if (child.type === "function_item") {
|
|
785
750
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
786
751
|
const [sl, el] = nodeRange(child);
|
|
787
|
-
|
|
788
|
-
const detail = params
|
|
789
|
-
? source.slice(params.startIndex, params.endIndex)
|
|
790
|
-
: undefined;
|
|
791
|
-
symbol = { name, type: "method", startLine: sl, endLine: el, detail };
|
|
752
|
+
symbol = { name, type: "method", startLine: sl, endLine: el };
|
|
792
753
|
} else if (child.type === "const_item") {
|
|
793
754
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
794
755
|
const [sl, el] = nodeRange(child);
|
|
@@ -827,20 +788,7 @@ function extractSolidity(
|
|
|
827
788
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
828
789
|
const [sl, el] = nodeRange(child);
|
|
829
790
|
|
|
830
|
-
|
|
831
|
-
const inherits: string[] = [];
|
|
832
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
833
|
-
const c = child.namedChild(j);
|
|
834
|
-
if (c && c.type === "inheritance_specifier") {
|
|
835
|
-
const ancestor = c.childForFieldName("ancestor");
|
|
836
|
-
if (ancestor) {
|
|
837
|
-
inherits.push(source.slice(ancestor.startIndex, ancestor.endIndex));
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
const detail = inherits.length > 0 ? `is ${inherits.join(", ")}` : undefined;
|
|
842
|
-
|
|
843
|
-
symbol = { name, type: "contract", startLine: sl, endLine: el, detail };
|
|
791
|
+
symbol = { name, type: "contract", startLine: sl, endLine: el };
|
|
844
792
|
|
|
845
793
|
// Recurse into contract body
|
|
846
794
|
const body = child.childForFieldName("body");
|
|
@@ -851,19 +799,7 @@ function extractSolidity(
|
|
|
851
799
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
852
800
|
const [sl, el] = nodeRange(child);
|
|
853
801
|
|
|
854
|
-
|
|
855
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
856
|
-
const c = child.namedChild(j);
|
|
857
|
-
if (c && c.type === "inheritance_specifier") {
|
|
858
|
-
const ancestor = c.childForFieldName("ancestor");
|
|
859
|
-
if (ancestor) {
|
|
860
|
-
inherits.push(source.slice(ancestor.startIndex, ancestor.endIndex));
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
const detail = inherits.length > 0 ? `is ${inherits.join(", ")}` : undefined;
|
|
865
|
-
|
|
866
|
-
symbol = { name, type: "interface", startLine: sl, endLine: el, detail };
|
|
802
|
+
symbol = { name, type: "interface", startLine: sl, endLine: el };
|
|
867
803
|
|
|
868
804
|
const body = child.childForFieldName("body");
|
|
869
805
|
if (body && depth < MAX_DEPTH) {
|
|
@@ -914,17 +850,12 @@ function extractSolidityBody(
|
|
|
914
850
|
if (!m) continue;
|
|
915
851
|
if (m.type === "struct_member") {
|
|
916
852
|
const memberName = fieldChildText(m, "name", source) || "";
|
|
917
|
-
const memberType = m.childForFieldName("type");
|
|
918
|
-
const typeStr = memberType
|
|
919
|
-
? source.slice(memberType.startIndex, memberType.endIndex)
|
|
920
|
-
: "";
|
|
921
853
|
const [msl, mel] = nodeRange(m);
|
|
922
854
|
symbol.children.push({
|
|
923
855
|
name: memberName,
|
|
924
856
|
type: "field",
|
|
925
857
|
startLine: msl,
|
|
926
858
|
endLine: mel,
|
|
927
|
-
detail: typeStr,
|
|
928
859
|
});
|
|
929
860
|
}
|
|
930
861
|
}
|
|
@@ -953,22 +884,6 @@ function extractSolidityBody(
|
|
|
953
884
|
return results;
|
|
954
885
|
}
|
|
955
886
|
|
|
956
|
-
/** Collect all unnamed `parameter`/`event_parameter`/`error_parameter` named children and return their source ranges joined. */
|
|
957
|
-
function solidityParamsText(
|
|
958
|
-
node: Node,
|
|
959
|
-
source: string,
|
|
960
|
-
paramType: string = "parameter",
|
|
961
|
-
): string | undefined {
|
|
962
|
-
const parts: string[] = [];
|
|
963
|
-
for (let j = 0; j < node.namedChildCount; j++) {
|
|
964
|
-
const c = node.namedChild(j);
|
|
965
|
-
if (c && c.type === paramType) {
|
|
966
|
-
parts.push(source.slice(c.startIndex, c.endIndex));
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
return parts.length > 0 ? `(${parts.join(", ")})` : undefined;
|
|
970
|
-
}
|
|
971
|
-
|
|
972
887
|
function extractSolidityItem(
|
|
973
888
|
child: Node,
|
|
974
889
|
source: string,
|
|
@@ -978,71 +893,18 @@ function extractSolidityItem(
|
|
|
978
893
|
if (type === "function_definition") {
|
|
979
894
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
980
895
|
const [sl, el] = nodeRange(child);
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
// Check for return type
|
|
984
|
-
let returnType: string | undefined;
|
|
985
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
986
|
-
const c = child.namedChild(j);
|
|
987
|
-
if (c && c.type === "return_type_definition") {
|
|
988
|
-
returnType = source.slice(c.startIndex, c.endIndex);
|
|
989
|
-
break;
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
// Collect qualifiers: visibility, state_mutability, virtual, override, modifiers
|
|
994
|
-
const qualifiers: string[] = [];
|
|
995
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
996
|
-
const c = child.namedChild(j);
|
|
997
|
-
if (!c) continue;
|
|
998
|
-
if (c.type === "visibility" || c.type === "state_mutability") {
|
|
999
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1000
|
-
} else if (c.type === "virtual") {
|
|
1001
|
-
qualifiers.push("virtual");
|
|
1002
|
-
} else if (c.type === "override_specifier") {
|
|
1003
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1004
|
-
} else if (c.type === "modifier_invocation") {
|
|
1005
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
const parts: string[] = [];
|
|
1010
|
-
if (params) parts.push(params);
|
|
1011
|
-
if (qualifiers.length > 0) parts.push(qualifiers.join(" "));
|
|
1012
|
-
if (returnType) parts.push(returnType);
|
|
1013
|
-
const detail = parts.length > 0 ? parts.join(" ") : undefined;
|
|
1014
|
-
|
|
1015
|
-
return { name, type: "function", startLine: sl, endLine: el, detail };
|
|
896
|
+
return { name, type: "function", startLine: sl, endLine: el };
|
|
1016
897
|
}
|
|
1017
898
|
|
|
1018
899
|
if (type === "constructor_definition") {
|
|
1019
900
|
const [sl, el] = nodeRange(child);
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
const qualifiers: string[] = [];
|
|
1023
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
1024
|
-
const c = child.namedChild(j);
|
|
1025
|
-
if (!c) continue;
|
|
1026
|
-
if (c.type === "visibility" || c.type === "state_mutability") {
|
|
1027
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1028
|
-
} else if (c.type === "modifier_invocation") {
|
|
1029
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
const parts: string[] = [];
|
|
1034
|
-
if (params) parts.push(params);
|
|
1035
|
-
if (qualifiers.length > 0) parts.push(qualifiers.join(" "));
|
|
1036
|
-
const detail = parts.length > 0 ? parts.join(" ") : undefined;
|
|
1037
|
-
|
|
1038
|
-
return { name: "constructor", type: "constructor", startLine: sl, endLine: el, detail };
|
|
901
|
+
return { name: "constructor", type: "constructor", startLine: sl, endLine: el };
|
|
1039
902
|
}
|
|
1040
903
|
|
|
1041
904
|
if (type === "modifier_definition") {
|
|
1042
905
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
1043
906
|
const [sl, el] = nodeRange(child);
|
|
1044
|
-
|
|
1045
|
-
return { name, type: "modifier", startLine: sl, endLine: el, detail };
|
|
907
|
+
return { name, type: "modifier", startLine: sl, endLine: el };
|
|
1046
908
|
}
|
|
1047
909
|
|
|
1048
910
|
if (type === "event_definition") {
|
|
@@ -1054,21 +916,7 @@ function extractSolidityItem(
|
|
|
1054
916
|
if (type === "error_declaration") {
|
|
1055
917
|
const name = childText(child, "identifier", source) || "<anonymous>";
|
|
1056
918
|
const [sl, el] = nodeRange(child);
|
|
1057
|
-
|
|
1058
|
-
const params: string[] = [];
|
|
1059
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
1060
|
-
const c = child.namedChild(j);
|
|
1061
|
-
if (c && c.type === "error_parameter") {
|
|
1062
|
-
const typeName = c.childForFieldName("type");
|
|
1063
|
-
if (typeName) {
|
|
1064
|
-
const typeText = source.slice(typeName.startIndex, typeName.endIndex);
|
|
1065
|
-
const paramName = fieldChildText(c, "name", source);
|
|
1066
|
-
params.push(paramName ? `${typeText} ${paramName}` : typeText);
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
const detail = params.length > 0 ? `(${params.join(", ")})` : undefined;
|
|
1071
|
-
return { name, type: "error", startLine: sl, endLine: el, detail };
|
|
919
|
+
return { name, type: "error", startLine: sl, endLine: el };
|
|
1072
920
|
}
|
|
1073
921
|
|
|
1074
922
|
if (type === "struct_declaration") {
|
|
@@ -1096,36 +944,19 @@ function extractSolidityItem(
|
|
|
1096
944
|
}
|
|
1097
945
|
}
|
|
1098
946
|
|
|
1099
|
-
const qualifiers: string[] = [];
|
|
1100
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
1101
|
-
const c = child.namedChild(j);
|
|
1102
|
-
if (!c) continue;
|
|
1103
|
-
if (c.type === "visibility" || c.type === "state_mutability") {
|
|
1104
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1105
|
-
} else if (c.type === "virtual") {
|
|
1106
|
-
qualifiers.push("virtual");
|
|
1107
|
-
} else if (c.type === "override_specifier") {
|
|
1108
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1109
|
-
} else if (c.type === "modifier_invocation") {
|
|
1110
|
-
qualifiers.push(source.slice(c.startIndex, c.endIndex));
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
947
|
|
|
1114
948
|
return {
|
|
1115
949
|
name: symbolType,
|
|
1116
950
|
type: symbolType,
|
|
1117
951
|
startLine: sl,
|
|
1118
952
|
endLine: el,
|
|
1119
|
-
detail: qualifiers.length > 0 ? qualifiers.join(" ") : undefined,
|
|
1120
953
|
};
|
|
1121
954
|
}
|
|
1122
955
|
|
|
1123
956
|
if (type === "state_variable_declaration") {
|
|
1124
957
|
const name = fieldChildText(child, "name", source) || "<anonymous>";
|
|
1125
958
|
const [sl, el] = nodeRange(child);
|
|
1126
|
-
|
|
1127
|
-
const detail = varType ? source.slice(varType.startIndex, varType.endIndex) : undefined;
|
|
1128
|
-
return { name, type: "variable", startLine: sl, endLine: el, detail };
|
|
959
|
+
return { name, type: "variable", startLine: sl, endLine: el };
|
|
1129
960
|
}
|
|
1130
961
|
|
|
1131
962
|
return null;
|
|
@@ -1542,7 +1373,6 @@ function extractMarkdown(source: string): SymbolInfo[] {
|
|
|
1542
1373
|
startLine,
|
|
1543
1374
|
endLine: lines.length, // Will be updated later
|
|
1544
1375
|
children: [],
|
|
1545
|
-
detail: `#`.repeat(level),
|
|
1546
1376
|
};
|
|
1547
1377
|
|
|
1548
1378
|
// Find parent: pop stack until we find a heading with lower level
|
|
@@ -1589,7 +1419,6 @@ function extractMarkdown(source: string): SymbolInfo[] {
|
|
|
1589
1419
|
type: "code_block",
|
|
1590
1420
|
startLine,
|
|
1591
1421
|
endLine,
|
|
1592
|
-
detail: language,
|
|
1593
1422
|
};
|
|
1594
1423
|
|
|
1595
1424
|
// Find the heading that contains this code block
|
|
@@ -8,34 +8,23 @@ const PHP_TYPE_LABELS: Record<string, string> = {
|
|
|
8
8
|
enum_declaration: "enum",
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const MODIFIER_TYPES = new Set([
|
|
12
|
-
"visibility_modifier",
|
|
13
|
-
"static_modifier",
|
|
14
|
-
"abstract_modifier",
|
|
15
|
-
"final_modifier",
|
|
16
|
-
"readonly_modifier",
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
11
|
function textOf(node: Node, source: string): string {
|
|
20
12
|
return source.slice(node.startIndex, node.endIndex);
|
|
21
13
|
}
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
return [node.startPosition.row + 1, node.endPosition.row + 1];
|
|
25
|
-
}
|
|
15
|
+
const PHP_SKIPPED_TYPES = new Set(["attribute_list", "comment"]);
|
|
26
16
|
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
function firstDeclaredTokenRow(node: Node): number | undefined {
|
|
18
|
+
for (let index = 0; index < node.childCount; index++) {
|
|
19
|
+
const child = node.child(index);
|
|
20
|
+
if (child === null || PHP_SKIPPED_TYPES.has(child.type)) continue;
|
|
21
|
+
return child.startPosition.row + 1;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
35
|
-
const child = node.namedChild(i);
|
|
36
|
-
if (child && MODIFIER_TYPES.has(child.type)) modifiers.push(textOf(child, source));
|
|
37
|
-
}
|
|
38
|
-
return modifiers;
|
|
26
|
+
function rangeOf(node: Node): [number, number] {
|
|
27
|
+
return [firstDeclaredTokenRow(node) ?? node.startPosition.row + 1, node.endPosition.row + 1];
|
|
39
28
|
}
|
|
40
29
|
|
|
41
30
|
function findChild(node: Node, type: string): Node | undefined {
|
|
@@ -46,37 +35,11 @@ function findChild(node: Node, type: string): Node | undefined {
|
|
|
46
35
|
return undefined;
|
|
47
36
|
}
|
|
48
37
|
|
|
49
|
-
function nameFieldsOf(node: Node, source: string): string[] {
|
|
50
|
-
const names: string[] = [];
|
|
51
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
52
|
-
const child = node.namedChild(i);
|
|
53
|
-
if (child !== null && child.type === "name") names.push(textOf(child, source));
|
|
54
|
-
}
|
|
55
|
-
return names;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
38
|
function nameOf(node: Node, source: string): string {
|
|
59
39
|
const name = findChild(node, "name");
|
|
60
40
|
return name === undefined ? "<unknown>" : textOf(name, source);
|
|
61
41
|
}
|
|
62
42
|
|
|
63
|
-
function paramsOf(node: Node, source: string): string | undefined {
|
|
64
|
-
const params = node.childForFieldName("parameters");
|
|
65
|
-
return params === null ? undefined : textOf(params, source);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function returnOf(node: Node, source: string): string | undefined {
|
|
69
|
-
const returned = node.childForFieldName("return_type");
|
|
70
|
-
return returned === null ? undefined : `: ${textOf(returned, source)}`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function signatureOf(node: Node, source: string): string | undefined {
|
|
74
|
-
const params = paramsOf(node, source);
|
|
75
|
-
const returned = returnOf(node, source);
|
|
76
|
-
if (params === undefined) return returned;
|
|
77
|
-
return returned === undefined ? params : `${params}${returned}`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
43
|
function extractMethod(node: Node, source: string): SymbolInfo {
|
|
81
44
|
const [startLine, endLine] = rangeOf(node);
|
|
82
45
|
return {
|
|
@@ -84,7 +47,6 @@ function extractMethod(node: Node, source: string): SymbolInfo {
|
|
|
84
47
|
type: "method",
|
|
85
48
|
startLine,
|
|
86
49
|
endLine,
|
|
87
|
-
detail: detailOf([...modifiersOf(node, source), signatureOf(node, source)]),
|
|
88
50
|
};
|
|
89
51
|
}
|
|
90
52
|
|
|
@@ -95,58 +57,52 @@ function extractFunction(node: Node, source: string): SymbolInfo {
|
|
|
95
57
|
type: "function",
|
|
96
58
|
startLine,
|
|
97
59
|
endLine,
|
|
98
|
-
detail: detailOf([signatureOf(node, source)]),
|
|
99
60
|
};
|
|
100
61
|
}
|
|
101
62
|
|
|
102
63
|
function extractProperties(node: Node, source: string): SymbolInfo[] {
|
|
103
|
-
const modifiers = modifiersOf(node, source);
|
|
104
|
-
const typeNode = node.childForFieldName("type");
|
|
105
|
-
const propertyType = typeNode === null ? undefined : textOf(typeNode, source);
|
|
106
64
|
const results: SymbolInfo[] = [];
|
|
65
|
+
const declarationStart = firstDeclaredTokenRow(node) ?? node.startPosition.row + 1;
|
|
107
66
|
for (let i = 0; i < node.namedChildCount; i++) {
|
|
108
67
|
const element = node.namedChild(i);
|
|
109
68
|
if (element === null || element.type !== "property_element") continue;
|
|
110
|
-
const [
|
|
69
|
+
const [elementStart, endLine] = rangeOf(element);
|
|
70
|
+
const startLine = results.length === 0 ? Math.min(declarationStart, elementStart) : elementStart;
|
|
111
71
|
results.push({
|
|
112
72
|
name: element.childForFieldName("name")?.text ?? "<unknown>",
|
|
113
73
|
type: "property",
|
|
114
74
|
startLine,
|
|
115
75
|
endLine,
|
|
116
|
-
detail: detailOf([...modifiers, propertyType]),
|
|
117
76
|
});
|
|
118
77
|
}
|
|
119
78
|
return results;
|
|
120
79
|
}
|
|
121
80
|
|
|
122
81
|
function extractConstants(node: Node, source: string): SymbolInfo[] {
|
|
123
|
-
const modifiers = modifiersOf(node, source);
|
|
124
82
|
const results: SymbolInfo[] = [];
|
|
83
|
+
const declarationStart = firstDeclaredTokenRow(node) ?? node.startPosition.row + 1;
|
|
125
84
|
for (let i = 0; i < node.namedChildCount; i++) {
|
|
126
85
|
const element = node.namedChild(i);
|
|
127
86
|
if (element === null || element.type !== "const_element") continue;
|
|
128
|
-
const
|
|
129
|
-
const
|
|
87
|
+
const [elementStart, endLine] = rangeOf(element);
|
|
88
|
+
const startLine = results.length === 0 ? Math.min(declarationStart, elementStart) : elementStart;
|
|
130
89
|
results.push({
|
|
131
90
|
name: nameOf(element, source),
|
|
132
91
|
type: "const",
|
|
133
92
|
startLine,
|
|
134
93
|
endLine,
|
|
135
|
-
detail: detailOf([...modifiers, value === null ? undefined : `= ${textOf(value, source)}`]),
|
|
136
94
|
});
|
|
137
95
|
}
|
|
138
96
|
return results;
|
|
139
97
|
}
|
|
140
98
|
|
|
141
99
|
function extractEnumCase(node: Node, source: string): SymbolInfo {
|
|
142
|
-
const value = node.childForFieldName("value");
|
|
143
100
|
const [startLine, endLine] = rangeOf(node);
|
|
144
101
|
return {
|
|
145
102
|
name: node.childForFieldName("name")?.text ?? "<unknown>",
|
|
146
103
|
type: "case",
|
|
147
104
|
startLine,
|
|
148
105
|
endLine,
|
|
149
|
-
detail: detailOf([value === null ? undefined : `= ${textOf(value, source)}`]),
|
|
150
106
|
};
|
|
151
107
|
}
|
|
152
108
|
|
|
@@ -176,32 +132,12 @@ function extractMembers(body: Node, source: string): SymbolInfo[] {
|
|
|
176
132
|
}
|
|
177
133
|
|
|
178
134
|
function extractTypeDeclaration(node: Node, source: string, depth: number, maxDepth: number): SymbolInfo {
|
|
179
|
-
const detailParts: string[] = [...modifiersOf(node, source)];
|
|
180
|
-
const base = findChild(node, "base_clause");
|
|
181
|
-
if (base !== undefined) {
|
|
182
|
-
const baseNames = nameFieldsOf(base, source);
|
|
183
|
-
if (node.type === "interface_declaration") {
|
|
184
|
-
if (baseNames.length > 0) detailParts.push(`extends ${baseNames.join(", ")}`);
|
|
185
|
-
} else if (baseNames.length > 0 && baseNames[0] !== undefined) {
|
|
186
|
-
detailParts.push(`extends ${baseNames[0]}`);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (node.type === "enum_declaration") {
|
|
190
|
-
const backing = findChild(node, "primitive_type");
|
|
191
|
-
if (backing !== undefined) detailParts.push(`: ${textOf(backing, source)}`);
|
|
192
|
-
}
|
|
193
|
-
const implemented = findChild(node, "class_interface_clause");
|
|
194
|
-
if (implemented !== undefined) {
|
|
195
|
-
const implementedNames = nameFieldsOf(implemented, source);
|
|
196
|
-
if (implementedNames.length > 0) detailParts.push(`implements ${implementedNames.join(", ")}`);
|
|
197
|
-
}
|
|
198
135
|
const [startLine, endLine] = rangeOf(node);
|
|
199
136
|
const symbol: SymbolInfo = {
|
|
200
137
|
name: node.childForFieldName("name")?.text ?? "<unknown>",
|
|
201
138
|
type: PHP_TYPE_LABELS[node.type] ?? "class",
|
|
202
139
|
startLine,
|
|
203
140
|
endLine,
|
|
204
|
-
detail: detailOf(detailParts),
|
|
205
141
|
};
|
|
206
142
|
if (depth < maxDepth) {
|
|
207
143
|
const body = findChild(node, "declaration_list") ?? findChild(node, "enum_declaration_list");
|
|
@@ -227,7 +163,6 @@ function extractAssignedFunction(statement: Node, source: string): SymbolInfo |
|
|
|
227
163
|
type: value.type === "arrow_function" ? "arrow_function" : "function",
|
|
228
164
|
startLine,
|
|
229
165
|
endLine,
|
|
230
|
-
detail: detailOf([signatureOf(value, source)]),
|
|
231
166
|
};
|
|
232
167
|
}
|
|
233
168
|
return null;
|
|
@@ -96,18 +96,12 @@ function extractNamedBlock(
|
|
|
96
96
|
label: string,
|
|
97
97
|
): SymbolInfo | null {
|
|
98
98
|
let name = "<unknown>";
|
|
99
|
-
let detail: string | undefined;
|
|
100
99
|
|
|
101
100
|
for (let i = 0; i < child.namedChildCount; i++) {
|
|
102
101
|
const c = child.namedChild(i);
|
|
103
102
|
if (!c) continue;
|
|
104
103
|
if (c.type === "name") {
|
|
105
104
|
name = source.slice(c.startIndex, c.endIndex);
|
|
106
|
-
} else if (c.type === "parameters") {
|
|
107
|
-
detail =
|
|
108
|
-
"(" +
|
|
109
|
-
source.slice(c.startIndex, c.endIndex).replace(/^\(|\)$/g, "") +
|
|
110
|
-
")";
|
|
111
105
|
}
|
|
112
106
|
}
|
|
113
107
|
|
|
@@ -117,7 +111,6 @@ function extractNamedBlock(
|
|
|
117
111
|
type: label,
|
|
118
112
|
startLine: sl,
|
|
119
113
|
endLine: el,
|
|
120
|
-
detail,
|
|
121
114
|
};
|
|
122
115
|
|
|
123
116
|
if (depth < MAX_DEPTH) {
|
|
@@ -293,15 +286,12 @@ function extractBlockChildren(
|
|
|
293
286
|
|
|
294
287
|
function extractInclude(child: Node, source: string): SymbolInfo | null {
|
|
295
288
|
let name: string | undefined;
|
|
296
|
-
let detail: string | undefined;
|
|
297
289
|
|
|
298
290
|
for (let i = 0; i < child.namedChildCount; i++) {
|
|
299
291
|
const c = child.namedChild(i);
|
|
300
292
|
if (!c) continue;
|
|
301
293
|
if (c.type === "mixin_name") {
|
|
302
294
|
name = source.slice(c.startIndex, c.endIndex);
|
|
303
|
-
} else if (c.type === "arguments") {
|
|
304
|
-
detail = source.slice(c.startIndex, c.endIndex);
|
|
305
295
|
}
|
|
306
296
|
}
|
|
307
297
|
if (!name) return null;
|
|
@@ -311,7 +301,6 @@ function extractInclude(child: Node, source: string): SymbolInfo | null {
|
|
|
311
301
|
type: "include",
|
|
312
302
|
startLine: child.startPosition.row + 1,
|
|
313
303
|
endLine: child.endPosition.row + 1,
|
|
314
|
-
detail,
|
|
315
304
|
};
|
|
316
305
|
}
|
|
317
306
|
|
|
@@ -116,15 +116,12 @@ function extractNamedBlock(
|
|
|
116
116
|
nameField: string,
|
|
117
117
|
): SymbolInfo | null {
|
|
118
118
|
let name = "<unknown>";
|
|
119
|
-
let detail: string | undefined;
|
|
120
119
|
|
|
121
120
|
for (let i = 0; i < child.namedChildCount; i++) {
|
|
122
121
|
const c = child.namedChild(i);
|
|
123
122
|
if (!c) continue;
|
|
124
123
|
if (c.type === nameField) {
|
|
125
124
|
name = source.slice(c.startIndex, c.endIndex);
|
|
126
|
-
} else if (c.type === "parameters") {
|
|
127
|
-
detail = "(" + source.slice(c.startIndex, c.endIndex).replace(/^\(|\)$/g, "") + ")";
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
@@ -134,7 +131,6 @@ function extractNamedBlock(
|
|
|
134
131
|
type: label,
|
|
135
132
|
startLine: sl,
|
|
136
133
|
endLine: el,
|
|
137
|
-
detail,
|
|
138
134
|
};
|
|
139
135
|
|
|
140
136
|
if (depth < MAX_DEPTH) {
|
|
@@ -345,15 +341,12 @@ function extractBlockChildren(
|
|
|
345
341
|
*/
|
|
346
342
|
function extractInclude(child: Node, source: string): SymbolInfo | null {
|
|
347
343
|
let name: string | undefined;
|
|
348
|
-
let detail: string | undefined;
|
|
349
344
|
|
|
350
345
|
for (let i = 0; i < child.namedChildCount; i++) {
|
|
351
346
|
const c = child.namedChild(i);
|
|
352
347
|
if (!c) continue;
|
|
353
348
|
if (c.type === "identifier") {
|
|
354
349
|
name = source.slice(c.startIndex, c.endIndex);
|
|
355
|
-
} else if (c.type === "arguments") {
|
|
356
|
-
detail = source.slice(c.startIndex, c.endIndex);
|
|
357
350
|
}
|
|
358
351
|
}
|
|
359
352
|
if (!name) return null;
|
|
@@ -363,7 +356,6 @@ function extractInclude(child: Node, source: string): SymbolInfo | null {
|
|
|
363
356
|
type: "include",
|
|
364
357
|
startLine: child.startPosition.row + 1,
|
|
365
358
|
endLine: child.endPosition.row + 1,
|
|
366
|
-
detail,
|
|
367
359
|
};
|
|
368
360
|
}
|
|
369
361
|
|