Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WI #2699 Implement new command InsertVariableDisplay #2701

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a8472fc
WI #2699 Use separate namespaces for each command
fm-117 Jan 17, 2025
5b7d35b
WI #2699 Add support for recursive test directories in RefactoringTests
fm-117 Jan 17, 2025
05e3648
WI #2699 Fix bug in refactoring tests to allow empty lines in test files
fm-117 Jan 17, 2025
67f76af
WI #2699 Remove duplicate BOM
fm-117 Jan 17, 2025
4226214
WI #2699 Introduce base class for refactoring processors
fm-117 Jan 17, 2025
c400424
WI #2699 Introduce variable provider to isolate from environment duri…
fm-117 Jan 17, 2025
0753c7b
WI #2699 Rename AdjustFillers processor
fm-117 Jan 17, 2025
cad1aa9
WI #2699 Introduce new command source/insertVariableDisplay
fm-117 Jan 17, 2025
64d16a2
WI #2699 Add visitor on selected nodes class
fm-117 Jan 17, 2025
55ff5de
WI #2699 Add CobolStringBuilder class
fm-117 Jan 20, 2025
f2082cd
WI #2699 Add abstraction for Cobol code providers
fm-117 Jan 20, 2025
abffa46
WI #2699 Add index generator
fm-117 Jan 20, 2025
8e188fe
WI #2699 Add helper for data accessor computing
fm-117 Jan 20, 2025
6896cc6
WI #2699 Add generated statements classes
fm-117 Jan 20, 2025
cf6523a
WI #2699 Add visitor implementing display generation
fm-117 Jan 20, 2025
b279c73
WI #2699 Implement InsertVariableDisplay processor
fm-117 Jan 21, 2025
6827d09
WI #2699 Fix spacing in error message
fm-117 Jan 21, 2025
2135189
WI #2699 Add unit tests
fm-117 Jan 21, 2025
a9594e5
WI #2699 Refactoring: simplify DataAccessor
fm-117 Jan 21, 2025
59b6520
WI #2699 Refactoring: remove useless OCCURS dimension variable
fm-117 Jan 21, 2025
9d6cfd0
WI #2699 Refactoring: optimize selection by name
fm-117 Jan 21, 2025
06f8c44
WI #2699 Simplify hash generation and make it independent from platform
fm-117 Jan 23, 2025
6e60399
WI #2699 Improve IsGroup method
fm-117 Jan 27, 2025
c1be37d
WI #2699 Factorize IsGroup / IsNationalOrNationalEdited helper methods
fm-117 Jan 28, 2025
9b2f771
WI #2699 Always use PIC 9(4) COMP-5 for generated indices
fm-117 Jan 30, 2025
faae8e8
WI #2699 Generalize PictureCategory testing for DataDefinitions
fm-117 Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions TypeCobol.LanguageServer.Test/RefactoringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TypeCobol.Compiler;
using TypeCobol.Compiler.Directives;
using TypeCobol.LanguageServer.Commands.Refactor;
using TypeCobol.LanguageServer.Commands;
using TypeCobol.LanguageServer.Test.RefactoringTests;
using TypeCobol.LanguageServer.VsCodeProtocol;
using TypeCobol.Test.Utils;
Expand Down Expand Up @@ -71,6 +71,8 @@ public FixedTextEditGenerator()

public string ExpectedResult { get; }

public IEnvironmentVariableProvider EnvironmentVariableProvider { get; set; }

public TextDocumentIdentifier PrepareRefactoring(object[] arguments)
{
return new TextDocumentIdentifier(){ uri = nameof(FixedTextEditGenerator) };
Expand Down Expand Up @@ -123,8 +125,8 @@ private static void TestDirectory([CallerMemberName] string directoryName = null
string path = Path.GetFullPath("RefactoringTests");
path = Path.Combine(path, directoryName);

var failedTests = new List<(string TestName, Exception Exception)>();
foreach (var testFile in Directory.GetFiles(path))
var failedTests = new List<(string TestFile, Exception Exception)>();
foreach (var testFile in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
{
try
{
Expand All @@ -133,8 +135,7 @@ private static void TestDirectory([CallerMemberName] string directoryName = null
}
catch (Exception exception)
{
string testName = Path.GetFileNameWithoutExtension(testFile);
failedTests.Add((testName, exception));
failedTests.Add((testFile, exception));
}
}

Expand All @@ -144,7 +145,7 @@ private static void TestDirectory([CallerMemberName] string directoryName = null
Console.WriteLine();
foreach (var failedTest in failedTests)
{
Console.WriteLine($"[{failedTest.TestName}] failed !");
Console.WriteLine($"[{failedTest.TestFile}] failed !");
Console.WriteLine(failedTest.Exception.Message);
Console.WriteLine();
}
Expand All @@ -164,5 +165,8 @@ public void TestServerSideApplyEdit()

[TestMethod]
public void AdjustFillers() => TestDirectory();

[TestMethod]
public void InsertVariableDisplay() => TestDirectory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
GOBACK
.
END PROGRAM TCOMFL06.
---------------------------------------------------------------------------
TypeCobol.LanguageServer.Commands.Refactor.AdjustFillerRefactoringProcessor
---------------------------------------------------------------------------
---------------------------------------------------------------------------------
TypeCobol.LanguageServer.Commands.AdjustFillers.AdjustFillersRefactoringProcessor
---------------------------------------------------------------------------------
[{"uri":"file:/test.expected.cbl"}]
---------------------------------------------------------------------------
---------------------------------------------------------------------------------
refactoring.label=Adjust FILLERs: 3 FILLER(s) modified
refactoring.source=
IDENTIFICATION DIVISION.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 var1 PIC N(200).
PROCEDURE DIVISION.
GOBACK
.
END PROGRAM TCOMFL06.
-------------------------------------------------------------------------------------------------
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
-------------------------------------------------------------------------------------------------
[
{
"textDocument": { "uri": "file:/test.expected.cbl" },
"position": { "line": 5, "character": 26 }
},
false,
{
"vm": 1, "idx": 0, "ch": [
{
"vm": 0, "name": "var1"
}
]
}
]
-------------------------------------------------------------------------------------------------
refactoring.label=Debug instructions successfully generated.
refactoring.source=
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 var1 PIC N(200).
PROCEDURE DIVISION.
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
D DISPLAY 'var1 <' FUNCTION DISPLAY-OF (var1) '>'
*</DBG>

GOBACK
.
END PROGRAM TCOMFL06.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 group1.
05 group1-1.
10 var1 PIC N.
10 var2 PIC N.
01 group2.
05 group2-1.
10 var3 PIC N.
10 var4 PIC N.
10 var5 PIC N.
05 group2-2.
10 var6 PIC N.
10 var7 PIc N.
PROCEDURE DIVISION.
GOBACK
.
END PROGRAM TCOMFL06.
-------------------------------------------------------------------------------------------------
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
-------------------------------------------------------------------------------------------------
[
{
"textDocument": { "uri": "file:/test.expected.cbl" },
"position": { "line": 16, "character": 26 }
},
false,
{
"vm": 1, "idx": 0, "ch": [
{
"vm": 1, "name": "group1", "ch": [
{
"vm": 1, "name": "group1-1", "ch": [
{
"vm": 0, "name": "var1"
}
]
}
]
},
{
"vm": 2, "name": "group2"
}
]
}
]
-------------------------------------------------------------------------------------------------
refactoring.label=Debug instructions successfully generated.
refactoring.source=
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 group1.
05 group1-1.
10 var1 PIC N.
10 var2 PIC N.
01 group2.
05 group2-1.
10 var3 PIC N.
10 var4 PIC N.
10 var5 PIC N.
05 group2-2.
10 var6 PIC N.
10 var7 PIc N.
PROCEDURE DIVISION.
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
D DISPLAY ' var1 <' FUNCTION DISPLAY-OF (var1) '>'
D DISPLAY 'group2'
D DISPLAY ' group2-1'
D DISPLAY ' var3 <' FUNCTION DISPLAY-OF (var3) '>'
D DISPLAY ' var4 <' FUNCTION DISPLAY-OF (var4) '>'
D DISPLAY ' var5 <' FUNCTION DISPLAY-OF (var5) '>'
D DISPLAY ' group2-2'
D DISPLAY ' var6 <' FUNCTION DISPLAY-OF (var6) '>'
D DISPLAY ' var7 <' FUNCTION DISPLAY-OF (var7) '>'
*</DBG>

GOBACK
.
END PROGRAM TCOMFL06.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 three-levels.
05 OCCURS 1000.
10 OCCURS 200.
15 OCCURS 30.
20 var1 PIC X.
20 FILLER PIC X(20).
20 var2 PIC X.
PROCEDURE DIVISION.
GOBACK
.
END PROGRAM TCOMFL06.
-------------------------------------------------------------------------------------------------
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
-------------------------------------------------------------------------------------------------
[
{
"textDocument": { "uri": "file:/test.expected.cbl" },
"position": { "line": 11, "character": 26 }
},
false,
{
"vm": 1, "idx": 0, "ch": [
{
"vm": 1, "name": "three-levels", "ch": [
{
"vm": 1, "idx": 0, "ch": [
{
"vm": 1, "idx": 0, "ch": [
{
"vm": 1, "idx": 0, "ch": [
{
"vm": 0, "idx": 1
}
]
}
]
}
]
}
]
}
]
}
]
-------------------------------------------------------------------------------------------------
refactoring.label=Debug instructions successfully generated.
refactoring.source=
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 three-levels.
05 OCCURS 1000.
10 OCCURS 200.
15 OCCURS 30.
20 var1 PIC X.
20 FILLER PIC X(20).
20 var2 PIC X.
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
D77 Idx-d4df4249-1 PIC 9(4) COMP-5.
D77 Idx-d4df4249-2 PIC 9(4) COMP-5.
D77 Idx-d4df4249-3 PIC 9(4) COMP-5.
*</DBG>

PROCEDURE DIVISION.
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
D PERFORM VARYING Idx-d4df4249-1 FROM 1 BY 1 UNTIL
D Idx-d4df4249-1 > 1000
D PERFORM VARYING Idx-d4df4249-2 FROM 1 BY 1 UNTIL
D Idx-d4df4249-2 > 200
D PERFORM VARYING Idx-d4df4249-3 FROM 1 BY 1 UNTIL
D Idx-d4df4249-3 > 30
D DISPLAY ' FILLER (' Idx-d4df4249-1 ' '
D Idx-d4df4249-2 ' ' Idx-d4df4249-3 ') <' three-levels (2
D + (Idx-d4df4249-3 - 1) * 22 + (Idx-d4df4249-2 - 1) *
D 660 + (Idx-d4df4249-1 - 1) * 132000:20) '>'
D END-PERFORM
D END-PERFORM
D END-PERFORM
*</DBG>

GOBACK
.
END PROGRAM TCOMFL06.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 three-levels.
05 root-table-3 OCCURS 1000.
10 table-level1-2 OCCURS 200.
15 table-level2-1 OCCURS 30.
20 var1 PIC X.
20 FILLER PIC X(20).
20 var2 PIC X.
PROCEDURE DIVISION.
GOBACK
.
END PROGRAM TCOMFL06.
-------------------------------------------------------------------------------------------------
TypeCobol.LanguageServer.Commands.InsertVariableDisplay.InsertVariableDisplayRefactoringProcessor
-------------------------------------------------------------------------------------------------
[
{
"textDocument": { "uri": "file:/test.expected.cbl" },
"position": { "line": 11, "character": 26 }
},
false,
{
"vm": 1, "idx": 0, "ch": [
{
"vm": 1, "name": "three-levels", "ch": [
{
"vm": 1, "name": "root-table-3", "ch": [
{
"vm": 1, "name": "table-level1-2", "ch": [
{
"vm": 1, "name": "table-level2-1", "ch": [
{
"vm": 0, "idx": 1
}
]
}
]
}
]
}
]
}
]
}
]
-------------------------------------------------------------------------------------------------
refactoring.label=Debug instructions successfully generated.
refactoring.source=
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOMFL06.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 three-levels.
05 root-table-3 OCCURS 1000.
10 table-level1-2 OCCURS 200.
15 table-level2-1 OCCURS 30.
20 var1 PIC X.
20 FILLER PIC X(20).
20 var2 PIC X.
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
D77 Idx-d4df4249-1 PIC 9(4) COMP-5.
D77 Idx-d4df4249-2 PIC 9(4) COMP-5.
D77 Idx-d4df4249-3 PIC 9(4) COMP-5.
*</DBG>

PROCEDURE DIVISION.
*<DBG>InsertVariableDisplay 1959/09/18 11:09 TESTUSER
D PERFORM VARYING Idx-d4df4249-1 FROM 1 BY 1 UNTIL
D Idx-d4df4249-1 > 1000
D PERFORM VARYING Idx-d4df4249-2 FROM 1 BY 1 UNTIL
D Idx-d4df4249-2 > 200
D PERFORM VARYING Idx-d4df4249-3 FROM 1 BY 1 UNTIL
D Idx-d4df4249-3 > 30
D DISPLAY ' FILLER (' Idx-d4df4249-1 ' '
D Idx-d4df4249-2 ' ' Idx-d4df4249-3 ') (2:20) <'
D table-level2-1 (Idx-d4df4249-1 Idx-d4df4249-2
D Idx-d4df4249-3) (2:20) '>'
D END-PERFORM
D END-PERFORM
D END-PERFORM
*</DBG>

GOBACK
.
END PROGRAM TCOMFL06.
Loading
Loading