Skip to content

Commit 096eeac

Browse files
authored
Merge pull request #2745 from TypeCobolTeam/v2.8.0
v2.8.0
2 parents 6e67f44 + e091fdb commit 096eeac

File tree

46 files changed

+1840
-1258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1840
-1258
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
},
180180
{
181181
"category": 1,
182-
"message": "{\"jsonrpc\":\"2.0\",\"id\":\"7\",\"result\":{\"isIncomplete\":false,\"items\":[{\"label\":\"var2 (Numeric) (var2)\",\"kind\":6,\"insertText\":\"var2\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}},{\"label\":\"YYYY (Numeric) (groupA-1::groupA-2::varA::YYYY)\",\"kind\":6,\"insertText\":\"groupA-1::groupA-2::varA::YYYY\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}},{\"label\":\"YYYY (Numeric) (groupB-1::groupB-2::varB::YYYY)\",\"kind\":6,\"insertText\":\"groupB-1::groupB-2::varB::YYYY\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}},{\"label\":\"MM (Numeric) (groupA-1::groupA-2::varA::MM)\",\"kind\":6,\"insertText\":\"groupA-1::groupA-2::varA::MM\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}},{\"label\":\"MM (Numeric) (groupB-1::groupB-2::varB::MM)\",\"kind\":6,\"insertText\":\"groupB-1::groupB-2::varB::MM\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}},{\"label\":\"DD (Numeric) (groupA-1::groupA-2::varA::DD)\",\"kind\":6,\"insertText\":\"groupA-1::groupA-2::varA::DD\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}},{\"label\":\"DD (Numeric) (groupB-1::groupB-2::varB::DD)\",\"kind\":6,\"insertText\":\"groupB-1::groupB-2::varB::DD\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}}]}}"
182+
"message": "{\"jsonrpc\":\"2.0\",\"id\":\"7\",\"result\":{\"isIncomplete\":false,\"items\":[{\"label\":\"var2 (Numeric) (var2)\",\"kind\":6,\"insertText\":\"var2\",\"data\":{\"start\":{\"line\":38,\"character\":21},\"end\":{\"line\":38,\"character\":22}}}]}}"
183183
},
184184
{
185185
"category": 0,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
DATA DIVISION.
4+
WORKING-STORAGE SECTION.
5+
01 var1 PIC X.
6+
01 other-data PIC X.
7+
01 var2 PIC 9.
8+
PROCEDURE DIVISION.
9+
DISPLAY v
10+
GOBACK
11+
.
12+
END PROGRAM TCOMFL06.
13+
---------------------------------------------------------------------------------
14+
{"line":8,"character":20}
15+
---------------------------------------------------------------------------------
16+
[
17+
{
18+
"label": "var1 (Alphanumeric) (var1)",
19+
"kind": 6,
20+
"insertText": "var1",
21+
"data": {
22+
"start": {
23+
"line": 8,
24+
"character": 19
25+
},
26+
"end": {
27+
"line": 8,
28+
"character": 20
29+
}
30+
}
31+
},
32+
{
33+
"label": "var2 (Numeric) (var2)",
34+
"kind": 6,
35+
"insertText": "var2",
36+
"data": {
37+
"start": {
38+
"line": 8,
39+
"character": 19
40+
},
41+
"end": {
42+
"line": 8,
43+
"character": 20
44+
}
45+
}
46+
}
47+
]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System.Diagnostics;
2+
using System.Runtime.CompilerServices;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using Newtonsoft.Json;
5+
using TypeCobol.LanguageServer.Test.Utilities;
6+
using TypeCobol.Test.Utils;
7+
using TypeCobol.Test;
8+
using TypeCobol.Compiler.Directives;
9+
using TypeCobol.Compiler;
10+
using TypeCobol.LanguageServer.Processor;
11+
using Newtonsoft.Json.Linq;
12+
using TypeCobol.LanguageServer.VsCodeProtocol;
13+
14+
namespace TypeCobol.LanguageServer.Test.ProcessorTests
15+
{
16+
[TestClass]
17+
public class CompletionProcessorTest
18+
{
19+
private const string RELATIVE_PATH = "Completion";
20+
private const string ROOT_PATH = "ProcessorTests";
21+
22+
/*
23+
* Using a blank context as it is required by the processor but it won't matter during the tests
24+
* as each test is independent.
25+
*/
26+
protected readonly CompletionProcessor _processor = new(new SignatureCompletionContext());
27+
28+
private void ExecuteTest([CallerMemberName] string sourceFileName = null)
29+
{
30+
Debug.Assert(sourceFileName != null);
31+
32+
// Parse test data file
33+
var folder = PlatformUtils.GetPathForProjectFile(RELATIVE_PATH, Path.GetFullPath(ROOT_PATH));
34+
var testDataFilePath = $"{Path.Combine(folder, sourceFileName)}.txt";
35+
var testData = LanguageServerTestUtils.ParseMultiplePartsContent(testDataFilePath);
36+
Debug.Assert(testData.Count == 3);
37+
string cobolString = testData[0];
38+
string completionRequest = testData[1];
39+
string expectedProposals = testData[2];
40+
41+
// Parse original source code
42+
var options = new TypeCobolOptions();
43+
var format = DocumentFormat.RDZReferenceFormat;
44+
/*
45+
* Assuming the source code is not part of a copy. Testing completion inside a copy
46+
* is not very meaningful as they are usually made of data definitions only.
47+
*/
48+
var compilationUnit = ParserUtils.ParseCobolString(cobolString, false, options, format);
49+
50+
// Get completion request argument (single arg is Position)
51+
var position = JToken.Parse(completionRequest).ToObject<Position>();
52+
53+
// Execute processor and build actual result
54+
var completionItems = _processor.ComputeProposals(compilationUnit, position);
55+
string actualProposals = JToken.FromObject(completionItems, new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore })
56+
.ToString(Formatting.Indented)
57+
+ Environment.NewLine;
58+
59+
// Compare to expected
60+
TestUtils.CompareContent(sourceFileName, actualProposals, expectedProposals);
61+
}
62+
63+
[TestMethod]
64+
public void SimpleCompletionForVariable() => ExecuteTest();
65+
}
66+
}

TypeCobol.LanguageServer.Test/ProcessorTests/DataLayout/Tree-MiscPgm.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@
808808
65536,
809809
null,
810810
7,
811-
0
811+
10
812812
],
813813
"children": []
814814
},
@@ -824,7 +824,7 @@
824824
131072,
825825
null,
826826
8,
827-
0
827+
10
828828
],
829829
"children": [
830830
{
@@ -839,7 +839,7 @@
839839
1,
840840
null,
841841
0,
842-
0
842+
10
843843
],
844844
"children": []
845845
},
@@ -855,7 +855,7 @@
855855
1,
856856
null,
857857
1,
858-
0
858+
10
859859
],
860860
"children": [
861861
{
@@ -870,7 +870,7 @@
870870
1,
871871
null,
872872
0,
873-
0
873+
10
874874
],
875875
"children": []
876876
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
DATA DIVISION.
4+
WORKING-STORAGE SECTION.
5+
01 group1.
6+
05 item1 PIC X.
7+
05 non-displayable-index INDEX.
8+
05 non-displayable-func-pointer FUNCTION-POINTER.
9+
05 non-displayable-proc-pointer PROCEDURE-POINTER.
10+
05 FILLER PIC X.
11+
05 PIC X.
12+
05 too-many_occurences PIC X OCCURS 70000.
13+
05 item2 PIC X.
14+
PROCEDURE DIVISION.
15+
GOBACK
16+
.
17+
END PROGRAM TCOMFL06.
18+
-------------------------------------------------------------------------------------------------
19+
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
20+
-------------------------------------------------------------------------------------------------
21+
[
22+
{
23+
"textDocument": { "uri": "file:/test.expected.cbl" },
24+
"position": { "line": 13, "character": 26 }
25+
},
26+
false,
27+
{
28+
"vm": 1, "idx": 0, "ch": [
29+
{
30+
"vm": 2, "name": "group1"
31+
}
32+
]
33+
}
34+
]
35+
-------------------------------------------------------------------------------------------------
36+
refactoring.label=Debug instructions successfully generated.
37+
refactoring.source=
38+
IDENTIFICATION DIVISION.
39+
PROGRAM-ID. TCOMFL06.
40+
DATA DIVISION.
41+
WORKING-STORAGE SECTION.
42+
01 group1.
43+
05 item1 PIC X.
44+
05 non-displayable-index INDEX.
45+
05 non-displayable-func-pointer FUNCTION-POINTER.
46+
05 non-displayable-proc-pointer PROCEDURE-POINTER.
47+
05 FILLER PIC X.
48+
05 PIC X.
49+
05 too-many_occurences PIC X OCCURS 70000.
50+
05 item2 PIC X.
51+
PROCEDURE DIVISION.
52+
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
53+
D DISPLAY 'group1'
54+
D DISPLAY ' item1 <' item1 '>'
55+
D DISPLAY ' item2 <' item2 '>'
56+
*</DBG>
57+
58+
GOBACK
59+
.
60+
END PROGRAM TCOMFL06.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
DATA DIVISION.
4+
WORKING-STORAGE SECTION.
5+
01 var1 PIC X(200).
6+
PROCEDURE DIVISION.
7+
DISPLAY "end of pgm".
8+
END PROGRAM TCOMFL06.
9+
-------------------------------------------------------------------------------------------------
10+
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
11+
-------------------------------------------------------------------------------------------------
12+
[
13+
{
14+
"textDocument": { "uri": "file:/test.expected.cbl" },
15+
"position": { "line": 6, "character": 11 }
16+
},
17+
false,
18+
{
19+
"vm": 1, "idx": 0, "ch": [
20+
{
21+
"vm": 0, "name": "var1"
22+
}
23+
]
24+
}
25+
]
26+
-------------------------------------------------------------------------------------------------
27+
refactoring.label=Debug instructions successfully generated.
28+
refactoring.source=
29+
IDENTIFICATION DIVISION.
30+
PROGRAM-ID. TCOMFL06.
31+
DATA DIVISION.
32+
WORKING-STORAGE SECTION.
33+
01 var1 PIC X(200).
34+
PROCEDURE DIVISION.
35+
DISPLAY "end of pgm"
36+
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
37+
D DISPLAY 'var1 <' var1 '>'
38+
*</DBG>
39+
.
40+
END PROGRAM TCOMFL06.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
DATA DIVISION.
4+
WORKING-STORAGE SECTION.
5+
01 var1 PIC X(200).
6+
PROCEDURE DIVISION.
7+
DISPLAY "first" DISPLAY "second"
8+
END PROGRAM TCOMFL06.
9+
-------------------------------------------------------------------------------------------------
10+
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
11+
-------------------------------------------------------------------------------------------------
12+
[
13+
{
14+
"textDocument": { "uri": "file:/test.expected.cbl" },
15+
"position": { "line": 6, "character": 18 }
16+
},
17+
false,
18+
{
19+
"vm": 1, "idx": 0, "ch": [
20+
{
21+
"vm": 0, "name": "var1"
22+
}
23+
]
24+
}
25+
]
26+
-------------------------------------------------------------------------------------------------
27+
refactoring.label=Debug instructions successfully generated.
28+
refactoring.source=
29+
IDENTIFICATION DIVISION.
30+
PROGRAM-ID. TCOMFL06.
31+
DATA DIVISION.
32+
WORKING-STORAGE SECTION.
33+
01 var1 PIC X(200).
34+
PROCEDURE DIVISION.
35+
DISPLAY "first"
36+
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
37+
D DISPLAY 'var1 <' var1 '>'
38+
*</DBG>
39+
DISPLAY "second"
40+
END PROGRAM TCOMFL06.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
DATA DIVISION.
4+
WORKING-STORAGE SECTION.
5+
01 var1 PIC X(200).
6+
PROCEDURE DIVISION.
7+
DISPLAY "first" DISPLAY "second"
8+
END PROGRAM TCOMFL06.
9+
-------------------------------------------------------------------------------------------------
10+
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
11+
-------------------------------------------------------------------------------------------------
12+
[
13+
{
14+
"textDocument": { "uri": "file:/test.expected.cbl" },
15+
"position": { "line": 6, "character": 34 }
16+
},
17+
false,
18+
{
19+
"vm": 1, "idx": 0, "ch": [
20+
{
21+
"vm": 0, "name": "var1"
22+
}
23+
]
24+
}
25+
]
26+
-------------------------------------------------------------------------------------------------
27+
refactoring.label=Debug instructions successfully generated.
28+
refactoring.source=
29+
IDENTIFICATION DIVISION.
30+
PROGRAM-ID. TCOMFL06.
31+
DATA DIVISION.
32+
WORKING-STORAGE SECTION.
33+
01 var1 PIC X(200).
34+
PROCEDURE DIVISION.
35+
DISPLAY "first" DISPLAY "second"
36+
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
37+
D DISPLAY 'var1 <' var1 '>'
38+
*</DBG>
39+
40+
END PROGRAM TCOMFL06.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. TCOMFL06.
3+
DATA DIVISION.
4+
WORKING-STORAGE SECTION.
5+
01 var1 PIC X(200).
6+
PROCEDURE DIVISION.
7+
DISPLAY "first" DISPLAY "second"
8+
END PROGRAM TCOMFL06.
9+
-------------------------------------------------------------------------------------------------
10+
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
11+
-------------------------------------------------------------------------------------------------
12+
[
13+
{
14+
"textDocument": { "uri": "file:/test.expected.cbl" },
15+
"position": { "line": 6, "character": 18 }
16+
},
17+
true,
18+
{
19+
"vm": 1, "idx": 0, "ch": [
20+
{
21+
"vm": 0, "name": "var1"
22+
}
23+
]
24+
}
25+
]
26+
-------------------------------------------------------------------------------------------------
27+
refactoring.label=Debug instructions successfully generated.
28+
refactoring.source=
29+
IDENTIFICATION DIVISION.
30+
PROGRAM-ID. TCOMFL06.
31+
DATA DIVISION.
32+
WORKING-STORAGE SECTION.
33+
01 var1 PIC X(200).
34+
PROCEDURE DIVISION.
35+
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
36+
D DISPLAY 'var1 <' var1 '>'
37+
*</DBG>
38+
39+
DISPLAY "first" DISPLAY "second"
40+
END PROGRAM TCOMFL06.

0 commit comments

Comments
 (0)