Skip to content

Commit ccb8d73

Browse files
fm-117efr15
andauthored
WI #2724 Improve proposal filtering using name separators (#2752)
* WI #2724 Use Regex name filter for variables, paragraphs and sections * WI #2724 Create some unit tests * WI #2724 Add unit tests (#2747) * WI #2724 Add comment --------- Co-authored-by: efr15 <129841296+efr15@users.noreply.github.com>
1 parent 88f6548 commit ccb8d73

39 files changed

+3500
-24
lines changed

TypeCobol.LanguageServer.Test/LSRTests/AmbiguousVariablesCompletion/input/AmbiguousVariablesCompletion.tlsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
},
7676
{
7777
"category": 1,
78-
"message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"isIncomplete\":false,\"items\":[{\"label\":\"ambiguous (Alphanumeric) (Group1::Level1::ambiguous)\",\"kind\":6,\"insertText\":\"Group1::Level1::ambiguous\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"ambiguous (Alphanumeric) (Group1::Level2::ambiguous)\",\"kind\":6,\"insertText\":\"Group1::Level2::ambiguous\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}}]}}"
78+
"message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"isIncomplete\":false,\"items\":[{\"label\":\"ambiguous (Alphanumeric) (Group1::Level1::ambiguous)\",\"kind\":6,\"insertText\":\"Group1::Level1::ambiguous\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"ambiguous (Alphanumeric) (Group1::Level2::ambiguous)\",\"kind\":6,\"insertText\":\"Group1::Level2::ambiguous\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"non-ambiguous-1 (Alphanumeric) (Group1::Level1::non-ambiguous-1)\",\"kind\":6,\"insertText\":\"Group1::Level1::non-ambiguous-1\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"non-ambiguous-2 (Alphanumeric) (Group1::Level2::non-ambiguous-2)\",\"kind\":6,\"insertText\":\"Group1::Level2::non-ambiguous-2\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}}]}}"
7979
},
8080
{
8181
"category": 0,

TypeCobol.LanguageServer.Test/LSRTests/AmbiguousVariablesCompletionNoTC/input/AmbiguousVariablesCompletionNoTC.tlsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
},
7676
{
7777
"category": 1,
78-
"message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"isIncomplete\":false,\"items\":[{\"label\":\"ambiguous (Alphanumeric) (ambiguous OF Level1 OF Group1)\",\"kind\":6,\"insertText\":\"ambiguous OF Level1 OF Group1\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"ambiguous (Alphanumeric) (ambiguous OF Level2 OF Group1)\",\"kind\":6,\"insertText\":\"ambiguous OF Level2 OF Group1\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}}]}}"
78+
"message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"isIncomplete\":false,\"items\":[{\"label\":\"ambiguous (Alphanumeric) (ambiguous OF Level1 OF Group1)\",\"kind\":6,\"insertText\":\"ambiguous OF Level1 OF Group1\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"ambiguous (Alphanumeric) (ambiguous OF Level2 OF Group1)\",\"kind\":6,\"insertText\":\"ambiguous OF Level2 OF Group1\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"non-ambiguous-1 (Alphanumeric) (non-ambiguous-1)\",\"kind\":6,\"insertText\":\"non-ambiguous-1\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}},{\"label\":\"non-ambiguous-2 (Alphanumeric) (non-ambiguous-2)\",\"kind\":6,\"insertText\":\"non-ambiguous-2\",\"data\":{\"start\":{\"line\":12,\"character\":19},\"end\":{\"line\":12,\"character\":22}}}]}}"
7979
},
8080
{
8181
"category": 0,
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
PROCEDURE DIVISION.
4+
main.
5+
CALL proc
6+
GOBACK
7+
.
8+
DECLARE PROCEDURE proc1 PRIVATE.
9+
END-DECLARE.
10+
11+
DECLARE PROCEDURE another-proc1 PRIVATE.
12+
END-DECLARE.
13+
14+
DECLARE PROCEDURE func1 PRIVATE.
15+
END-DECLARE.
16+
17+
IDENTIFICATION DIVISION.
18+
PROGRAM-ID. ProcNested1.
19+
END PROGRAM ProcNested1.
20+
21+
IDENTIFICATION DIVISION.
22+
PROGRAM-ID. NestedProc1.
23+
END PROGRAM NestedProc1.
24+
25+
IDENTIFICATION DIVISION.
26+
PROGRAM-ID. AnotherNested.
27+
END PROGRAM AnotherNested.
28+
29+
END PROGRAM TCOMFL06.
30+
---------------------------------------------------------------------------------
31+
{"line":4,"character":20}
32+
---------------------------------------------------------------------------------
33+
[
34+
{
35+
"label": "proc1 ",
36+
"kind": 3,
37+
"insertText": "proc1",
38+
"data": [
39+
{
40+
"start": {
41+
"line": 4,
42+
"character": 16
43+
},
44+
"end": {
45+
"line": 4,
46+
"character": 20
47+
}
48+
},
49+
{
50+
"label": "TCOMFL06.proc1",
51+
"parameters": []
52+
},
53+
null
54+
]
55+
},
56+
{
57+
"label": "ProcNested1",
58+
"kind": 9,
59+
"data": {
60+
"start": {
61+
"line": 4,
62+
"character": 16
63+
},
64+
"end": {
65+
"line": 4,
66+
"character": 20
67+
}
68+
}
69+
}
70+
]
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
PROCEDURE DIVISION.
4+
main.
5+
CALL
6+
GOBACK
7+
.
8+
DECLARE PROCEDURE proc1 PRIVATE.
9+
END-DECLARE.
10+
11+
DECLARE PROCEDURE another-proc1 PRIVATE.
12+
END-DECLARE.
13+
14+
DECLARE PROCEDURE func1 PRIVATE.
15+
END-DECLARE.
16+
17+
IDENTIFICATION DIVISION.
18+
PROGRAM-ID. ProcNested1.
19+
END PROGRAM ProcNested1.
20+
21+
IDENTIFICATION DIVISION.
22+
PROGRAM-ID. NestedProc1.
23+
END PROGRAM NestedProc1.
24+
25+
IDENTIFICATION DIVISION.
26+
PROGRAM-ID. AnotherNested.
27+
END PROGRAM AnotherNested.
28+
29+
END PROGRAM TCOMFL06.
30+
---------------------------------------------------------------------------------
31+
{"line":4,"character":16}
32+
---------------------------------------------------------------------------------
33+
[
34+
{
35+
"label": "proc1 ",
36+
"kind": 3,
37+
"insertText": "proc1",
38+
"data": [
39+
null,
40+
{
41+
"label": "TCOMFL06.proc1",
42+
"parameters": []
43+
},
44+
null
45+
]
46+
},
47+
{
48+
"label": "another-proc1 ",
49+
"kind": 3,
50+
"insertText": "another-proc1",
51+
"data": [
52+
null,
53+
{
54+
"label": "TCOMFL06.another-proc1",
55+
"parameters": []
56+
},
57+
null
58+
]
59+
},
60+
{
61+
"label": "func1 ",
62+
"kind": 3,
63+
"insertText": "func1",
64+
"data": [
65+
null,
66+
{
67+
"label": "TCOMFL06.func1",
68+
"parameters": []
69+
},
70+
null
71+
]
72+
},
73+
{
74+
"label": "TCOMFL06",
75+
"kind": 9
76+
},
77+
{
78+
"label": "ProcNested1",
79+
"kind": 9
80+
},
81+
{
82+
"label": "NestedProc1",
83+
"kind": 9
84+
},
85+
{
86+
"label": "AnotherNested",
87+
"kind": 9
88+
}
89+
]
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOBCOMP.
3+
DATA DIVISION.
4+
WORKING-STORAGE SECTION.
5+
6+
* should suggest: matching variables
7+
01 SAY-VAR1 PIC 9.
8+
01 REDEF-SAY-VAR1 REDEFINES SAY-VAR1
9+
PIC 9.
10+
01 GROUP1-SAY.
11+
05 VAR2-SAY PIC X.
12+
66 SAY66 RENAMES VAR2-SAY.
13+
01 VAR3-SAY-VAR3 PIC 9.
14+
01 SAY-POINTER USAGE POINTER.
15+
77 SAY77 PIC X.
16+
17+
* should not suggest: not matching, invalid usage, 88
18+
01 VAR4 PIC 9.
19+
01 NOTSAY PIC 9.
20+
01 SAY-PROCEDURE-POINTER USAGE PROCEDURE-POINTER.
21+
01 SAY-FUNCTION-POINTER USAGE FUNCTION-POINTER.
22+
01 GROUP2 OCCURS 10 INDEXED BY SAY-INDEX
23+
PIC X.
24+
01 GROUP3.
25+
05 VAR5 PIC X.
26+
88 SAY88-YES VALUE 'Y'.
27+
88 SAY88-NO VALUE 'N'.
28+
29+
PROCEDURE DIVISION.
30+
MAIN.
31+
DISPLAY SAY
32+
GOBACK
33+
.
34+
* should not suggest: paragraph
35+
P-SAY-HELLO.
36+
DISPLAY "HELlO"
37+
.
38+
* should not suggest: section
39+
S-SAY-CONTINUE SECTION.
40+
CONTINUE
41+
.
42+
43+
END PROGRAM TCOBCOMP.
44+
---------------------------------------------------------------------------------
45+
{"line":30,"character":22}
46+
---------------------------------------------------------------------------------
47+
[
48+
{
49+
"label": "SAY-VAR1 (Numeric) (SAY-VAR1)",
50+
"kind": 6,
51+
"insertText": "SAY-VAR1",
52+
"data": {
53+
"start": {
54+
"line": 30,
55+
"character": 19
56+
},
57+
"end": {
58+
"line": 30,
59+
"character": 22
60+
}
61+
}
62+
},
63+
{
64+
"label": "REDEF-SAY-VAR1 (Numeric) (REDEF-SAY-VAR1)",
65+
"kind": 6,
66+
"insertText": "REDEF-SAY-VAR1",
67+
"data": {
68+
"start": {
69+
"line": 30,
70+
"character": 19
71+
},
72+
"end": {
73+
"line": 30,
74+
"character": 22
75+
}
76+
}
77+
},
78+
{
79+
"label": "GROUP1-SAY (Alphanumeric) (GROUP1-SAY)",
80+
"kind": 6,
81+
"insertText": "GROUP1-SAY",
82+
"data": {
83+
"start": {
84+
"line": 30,
85+
"character": 19
86+
},
87+
"end": {
88+
"line": 30,
89+
"character": 22
90+
}
91+
}
92+
},
93+
{
94+
"label": "VAR2-SAY (Alphanumeric) (GROUP1-SAY::VAR2-SAY)",
95+
"kind": 6,
96+
"insertText": "GROUP1-SAY::VAR2-SAY",
97+
"data": {
98+
"start": {
99+
"line": 30,
100+
"character": 19
101+
},
102+
"end": {
103+
"line": 30,
104+
"character": 22
105+
}
106+
}
107+
},
108+
{
109+
"label": "SAY66 (?) (GROUP1-SAY::SAY66)",
110+
"kind": 6,
111+
"insertText": "GROUP1-SAY::SAY66",
112+
"data": {
113+
"start": {
114+
"line": 30,
115+
"character": 19
116+
},
117+
"end": {
118+
"line": 30,
119+
"character": 22
120+
}
121+
}
122+
},
123+
{
124+
"label": "VAR3-SAY-VAR3 (Numeric) (VAR3-SAY-VAR3)",
125+
"kind": 6,
126+
"insertText": "VAR3-SAY-VAR3",
127+
"data": {
128+
"start": {
129+
"line": 30,
130+
"character": 19
131+
},
132+
"end": {
133+
"line": 30,
134+
"character": 22
135+
}
136+
}
137+
},
138+
{
139+
"label": "SAY-POINTER (Alphanumeric) (SAY-POINTER)",
140+
"kind": 6,
141+
"insertText": "SAY-POINTER",
142+
"data": {
143+
"start": {
144+
"line": 30,
145+
"character": 19
146+
},
147+
"end": {
148+
"line": 30,
149+
"character": 22
150+
}
151+
}
152+
},
153+
{
154+
"label": "SAY77 (Alphanumeric) (SAY77)",
155+
"kind": 6,
156+
"insertText": "SAY77",
157+
"data": {
158+
"start": {
159+
"line": 30,
160+
"character": 19
161+
},
162+
"end": {
163+
"line": 30,
164+
"character": 22
165+
}
166+
}
167+
}
168+
]

0 commit comments

Comments
 (0)