diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index 74bd9b1bc..0617955ba 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -12,8 +12,11 @@ on: jobs: build: + strategy: + matrix: + os: [windows-latest, ubuntu-latest] - runs-on: windows-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -22,10 +25,10 @@ jobs: with: dotnet-version: 8.0.x - name: Restore dependencies - run: dotnet restore .\TypeCobol.sln + run: dotnet restore ./TypeCobol.sln - name: Build CSCup - run: dotnet build .\CSCup\CSCup.csproj --no-restore --configuration ${{ inputs.build-configuration }} + run: dotnet build ./CSCup/CSCup.csproj --no-restore --configuration ${{ inputs.build-configuration }} - name: Build solution - run: dotnet build .\TypeCobol.sln --no-restore --configuration ${{ inputs.build-configuration }} + run: dotnet build ./TypeCobol.sln --no-restore --configuration ${{ inputs.build-configuration }} - name: Test - run: dotnet test .\TypeCobol.sln --no-build --verbosity normal --configuration ${{ inputs.build-configuration }} + run: dotnet test ./TypeCobol.sln --no-build --verbosity normal --configuration ${{ inputs.build-configuration }} diff --git a/CLI/test/CLITest.cs b/CLI/test/CLITest.cs index 50a08938a..dac8b3c27 100644 --- a/CLI/test/CLITest.cs +++ b/CLI/test/CLITest.cs @@ -421,10 +421,10 @@ internal static void ReadConsoleWarnings(string testFolderName, ReturnCode expec string standardOutput = Test(workingDirectory, arguments, expectedReturnCode).Trim(); string warnings = string.Empty; - foreach (string line in standardOutput.Split(new string[] { "\r\n" }, StringSplitOptions.None)) + foreach (string line in standardOutput.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)) { if (line.StartsWith("Line")) - warnings += line + "\r\n"; + warnings += line + Environment.NewLine; } warnings = warnings.Trim(); diff --git a/CLI/test/ressources/CopyInsideTypeDefInsideDependency_EI/output_expected/CopyInsideTypeDefInsideDependency.rdz.tcbl b/CLI/test/ressources/CopyInsideTypeDefInsideDependency_EI/output_expected/CopyInsideTypeDefInsideDependency.rdz.tcbl index 45caaafbe..e6efc9a53 100644 --- a/CLI/test/ressources/CopyInsideTypeDefInsideDependency_EI/output_expected/CopyInsideTypeDefInsideDependency.rdz.tcbl +++ b/CLI/test/ressources/CopyInsideTypeDefInsideDependency_EI/output_expected/CopyInsideTypeDefInsideDependency.rdz.tcbl @@ -5,7 +5,7 @@ * YPRTD20 * YCONVEA * ). - + DATA DIVISION. Working-STORAGE SECTION. diff --git a/CLI/test/ressources/arguments_errors_1/ExpectedConsole.txt b/CLI/test/ressources/arguments_errors_1/ExpectedConsole.txt index 9efff3a5b..834ad46be 100644 --- a/CLI/test/ressources/arguments_errors_1/ExpectedConsole.txt +++ b/CLI/test/ressources/arguments_errors_1/ExpectedConsole.txt @@ -5,7 +5,7 @@ Code: 124 TypeCobol.CLI: Missing copy path given is unreachable. Code: 126 TypeCobol.CLI: The format 'BadFormat' is not supported. The input encoding 'BadInputEncoding' could not be found. Code: 127 TypeCobol.CLI: Intrinsic files given are unreachable. Code: 128 TypeCobol.CLI: Copies files given are unreachable. -Code: 129 TypeCobol.CLI: Dependencies files given are unreachable: input\MissingDependencies1 +Code: 129 TypeCobol.CLI: Dependencies files given are unreachable: input/MissingDependencies1 Code: 130 TypeCobol.CLI: Maximum diagnostics have to be an integer. Code: 131 TypeCobol.CLI: Unexpected parameter given for Output format option. Accepted parameters are Cobol85/0(default), PublicSignature/1. Code: 132 TypeCobol.CLI: Expanding copy path given is unreachable. diff --git a/CLI/test/ressources/dependencies_4/ExpectedConsole.txt b/CLI/test/ressources/dependencies_4/ExpectedConsole.txt index c639ab8c2..af2c001ff 100644 --- a/CLI/test/ressources/dependencies_4/ExpectedConsole.txt +++ b/CLI/test/ressources/dependencies_4/ExpectedConsole.txt @@ -1,2 +1,2 @@ -Code: 129 TypeCobol.CLI: Dependencies files given are unreachable: input\DoesntExists.rdz.tcbl +Code: 129 TypeCobol.CLI: Dependencies files given are unreachable: input/DoesntExists.rdz.tcbl Try TypeCobol.CLI --help for usage information. \ No newline at end of file diff --git a/CLI/test/ressources/documentation/output_expected/DocGen.json b/CLI/test/ressources/documentation/output_expected/DocGen.json index 54f265e11..757b78274 100644 --- a/CLI/test/ressources/documentation/output_expected/DocGen.json +++ b/CLI/test/ressources/documentation/output_expected/DocGen.json @@ -1 +1 @@ -{"Documentations":[{"__type":"DocumentationForProgram:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"My program \r\ndescription ","Name":"DocGen","Namespace":"DocGen","Needs":["some needs","description"],"ReplacedBy":"MyFonction2 ","Restriction":"Do not Use BOOL var ","See":"Thank you for your attention ","ToDos":["Add BOOL support","implement a call counter"]},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"inline typedef ","Name":"myType","Namespace":"DocGen","Restriction":"Do not Use BOOL var ","Visibility":1,"DocDataType":{"MaxOccurence":1,"Picture":"X(01)"}},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Description":"Vect2D ","Name":"Vect2D","Namespace":"DocGen","Visibility":1,"Childrens":[{"Childrens":[{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"X"},{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"Y"}],"DocDataType":{"MaxOccurence":1},"Name":"Coord2d"}],"DocDataType":{"MaxOccurence":1}},{"__type":"DocumentationForFunction:#TypeCobol.Compiler.Nodes","Deprecated":"It is deprecated ","Description":"MyProc info \r\n","Name":"MyProc","Namespace":"DocGen","Needs":["long need"],"ToDos":["todo1","todo 2"],"Visibility":1,"Parameters":[{"DocDataType":{"MaxOccurence":1,"TypeName":"DATE"},"Info":"just a date","Name":"myDate","PassingType":0},{"DocDataType":{"MaxOccurence":1,"Picture":"S9(1)V9(12)"},"Info":"bla < 2","Name":"bla","PassingType":0},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Name":"myBool","PassingType":2},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Info":"toto","Name":"toto","PassingType":1},{"DocDataType":{"MaxOccurence":1,"Picture":"PPP999PPP"},"Name":"bli","PassingType":1}]}],"TypeCobolVersion":"[[ParserVersion]]"} +{"Documentations":[{"__type":"DocumentationForProgram:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"My program description","Name":"DocGen","Namespace":"DocGen","Needs":["some needs","description"],"ReplacedBy":"MyFonction2","Restriction":"Do not Use BOOL var","See":"Thank you for your attention","ToDos":["Add BOOL support","implement a call counter"]},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"inline typedef","Name":"myType","Namespace":"DocGen","Restriction":"Do not Use BOOL var","Visibility":1,"DocDataType":{"MaxOccurence":1,"Picture":"X(01)"}},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Description":"Vect2D","Name":"Vect2D","Namespace":"DocGen","Visibility":1,"Childrens":[{"Childrens":[{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"X"},{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"Y"}],"DocDataType":{"MaxOccurence":1},"Name":"Coord2d"}],"DocDataType":{"MaxOccurence":1}},{"__type":"DocumentationForFunction:#TypeCobol.Compiler.Nodes","Deprecated":"It is deprecated","Description":"MyProc info","Name":"MyProc","Namespace":"DocGen","Needs":["long need"],"ToDos":["todo1","todo 2"],"Visibility":1,"Parameters":[{"DocDataType":{"MaxOccurence":1,"TypeName":"DATE"},"Info":"just a date","Name":"myDate","PassingType":0},{"DocDataType":{"MaxOccurence":1,"Picture":"S9(1)V9(12)"},"Info":"bla < 2","Name":"bla","PassingType":0},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Name":"myBool","PassingType":2},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Info":"toto","Name":"toto","PassingType":1},{"DocDataType":{"MaxOccurence":1,"Picture":"PPP999PPP"},"Name":"bli","PassingType":1}]}],"TypeCobolVersion":"[[ParserVersion]]"} diff --git a/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2.cbl b/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2.cbl index a5a9a7119..33f9c966d 100644 --- a/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2.cbl +++ b/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2.cbl @@ -95,7 +95,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. STACKED. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-STACKED-FctList-Loaded PIC X(02) VALUE space. 88 TC-STACKED-FctList-IsLoaded VALUE 'OK'. @@ -113,7 +113,7 @@ 05 TC-STACKED-b4a83777-Idt PIC X(08) VALUE 'b4a83777'. 05 TC-STACKED-b4a83777 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. 01 TC-A1 PIC X. @@ -161,7 +161,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. STACKED2. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-STACKED2-FctList-Loaded PIC X(02) VALUE space. 88 TC-STACKED2-FctList-IsLoaded VALUE 'OK'. @@ -174,7 +174,7 @@ 05 TC-STACKED2-f22bfcb0-Idt PIC X(08) VALUE 'f22bfcb0'. 05 TC-STACKED2-f22bfcb0 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. 01 TC-A1 PIC X. diff --git a/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2Same.cbl b/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2Same.cbl index 2b01ff5d7..c822c6394 100644 --- a/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2Same.cbl +++ b/CLI/test/ressources/generate_stackedProc/output_expected/Pgm2Same.cbl @@ -2,7 +2,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM2. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM2-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM2-FctList-IsLoaded VALUE 'OK'. @@ -15,7 +15,7 @@ 05 TC-PGM2-a4ee502d-Idt PIC X(08) VALUE 'a4ee502d'. 05 TC-PGM2-a4ee502d PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. 01 TC-A1 PIC X. diff --git a/CLI/test/ressources/typedefCopy_EI/output_expected/Client.rdz.tcbl b/CLI/test/ressources/typedefCopy_EI/output_expected/Client.rdz.tcbl index 31658f2c0..9b9c85667 100644 --- a/CLI/test/ressources/typedefCopy_EI/output_expected/Client.rdz.tcbl +++ b/CLI/test/ressources/typedefCopy_EI/output_expected/Client.rdz.tcbl @@ -4,7 +4,7 @@ *REMARKS. COPY=( * TESTCPY * ). - + data division. working-storage section. *01 MyType typedef strict public. diff --git a/CLI/test/ressources/ycopylist/output_expected/CopyTestwithOrWithoutReplace.rdz.cbl b/CLI/test/ressources/ycopylist/output_expected/CopyTestwithOrWithoutReplace.rdz.cbl index 4d1ea3cc8..16127572b 100644 --- a/CLI/test/ressources/ycopylist/output_expected/CopyTestwithOrWithoutReplace.rdz.cbl +++ b/CLI/test/ressources/ycopylist/output_expected/CopyTestwithOrWithoutReplace.rdz.cbl @@ -5,7 +5,7 @@ * XMYCOPY * YMYCOPY1 * ). - + ENVIRONMENT DIVISION. DATA DIVISION. diff --git a/Codegen/src/Actions/Qualifier.cs b/Codegen/src/Actions/Qualifier.cs index 02cad6f2d..e85e4e65a 100644 --- a/Codegen/src/Actions/Qualifier.cs +++ b/Codegen/src/Actions/Qualifier.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using TypeCobol.Codegen.Nodes; +using TypeCobol.Codegen.Nodes; using TypeCobol.Compiler.CodeElements; using TypeCobol.Compiler.CodeModel; using TypeCobol.Compiler.Nodes; @@ -112,7 +109,7 @@ public override bool Visit(StorageArea storageArea) { if (this.CurrentNode.IsFlagSet(Node.Flag.NodeContainsIndex) || this.CurrentNode.IsFlagSet(Node.Flag.NodeContainsBoolean)) { - Tuple, List> sourcePositions = this.Generator.FromToPositions(this.CurrentNode); + NodePositions sourcePositions = this.Generator.FromToPositions(this.CurrentNode); foreach (TypeCobol.Compiler.CodeElements.StorageArea storage_area in this.CurrentNode.QualifiedStorageAreas.Keys) { if (this.CurrentNode.IsFlagSet(Node.Flag.NodeContainsIndex)) @@ -130,7 +127,7 @@ public override bool Visit(StorageArea storageArea) return true; } - private void QualifiedStorageAreaSelecterForBoolean(StorageArea storage_area, Tuple, List> sourcePositions) + private void QualifiedStorageAreaSelecterForBoolean(StorageArea storage_area, NodePositions sourcePositions) { if (UsedStorageArea != null && UsedStorageArea.Contains(storage_area)) return; @@ -147,7 +144,7 @@ private void QualifiedStorageAreaSelecterForBoolean(StorageArea storage_area, Tu UsedStorageArea.Add(storage_area); } - private void QualifiedStorageAreaSelecterForIndexes(StorageArea storageArea, Tuple, List> sourcePositions) + private void QualifiedStorageAreaSelecterForIndexes(StorageArea storageArea, NodePositions sourcePositions) { if (storageArea.SymbolReference != null && !storageArea.SymbolReference.IsQualifiedReference) { @@ -257,7 +254,7 @@ public override bool Visit(IndexDefinition indexDefinition) { if (index.Name.Equals(indexDefinition.Name)) { - Tuple, List> sourcePositions = this.Generator.FromToPositions(indexDefinition.Parent); + NodePositions sourcePositions = this.Generator.FromToPositions(indexDefinition.Parent); string qualified_name = indexDefinition.QualifiedName.ToString(); GenerateToken item = null; string hashName = GeneratorHelper.ComputeIndexHashName(qualified_name, indexDefinition.Parent); @@ -558,7 +555,7 @@ internal void Perform(Node sourceNode) //Now this Node Is Visited sourceNode.SetFlag(Node.Flag.HasBeenTypeCobolQualifierVisited, true); - Tuple, List> sourcePositions = this.Generator.FromToPositions(sourceNode); + NodePositions sourcePositions = this.Generator.FromToPositions(sourceNode); IList nodeTokens = sourceNode.CodeElement.ConsumedTokens; List> boundaries = ItemsListIndexBoundary(nodeTokens); int b = 0; @@ -724,7 +721,7 @@ internal class GenerateToken : GenericNode, GeneratedAndReplace /// The Code element of this Node /// The replace code /// The Positions of the Source Node - public GenerateToken(CodeElement codelement, string code, Tuple, List> sourcePositions) + public GenerateToken(CodeElement codelement, string code, NodePositions sourcePositions) : base(codelement) { ReplaceCode = code; @@ -734,7 +731,7 @@ public GenerateToken(CodeElement codelement, string code, Tuple /// Source Node Positions /// - public Tuple, List> SourceNodePositions + public NodePositions SourceNodePositions { get; private set; diff --git a/Codegen/src/Codegen.csproj b/Codegen/src/Codegen.csproj index f8e76986f..3dfa12f1c 100644 --- a/Codegen/src/Codegen.csproj +++ b/Codegen/src/Codegen.csproj @@ -8,13 +8,8 @@ - - - all - - - all - + + diff --git a/Codegen/src/Generator.cs b/Codegen/src/Generator.cs index 479f93f76..6f6f69702 100644 --- a/Codegen/src/Generator.cs +++ b/Codegen/src/Generator.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; +using System.Diagnostics; using TypeCobol.Codegen.Actions; using TypeCobol.Codegen.Nodes; using TypeCobol.Compiler; @@ -17,6 +13,15 @@ namespace TypeCobol.Codegen { + /// + /// Capture positions for actual or generated nodes. + /// + /// Start position of the node. + /// End position of the node. + /// End offset of the node, this is the end column of the node on its last line. + /// List of line numbers the node spans across. + public record NodePositions(int From, int To, int Span, List LineNumbers); + /// /// The Second Code Generator which can Handle correctly all preprocessor directives /// during the Code Generation Phase. @@ -149,7 +154,7 @@ public Generator(TypeCobol.Compiler.CompilationDocument document, StringBuilder /// The method also calculate the ending span offset from the beginning of the last line. /// It also get the list of Line numbers occupated by this node, and the offset of each line. /// - public Tuple, List> FromToPositions(Node node) + public NodePositions FromToPositions(Node node) { if (node.CodeElement == null || node.CodeElement.ConsumedTokens == null || node is ParameterEntry) return null; @@ -161,7 +166,6 @@ public Tuple, List> FromToPositions(Node node) int i = 0; int span = 0; List lineNumbers = new List(); - List lineOffsets = new List(); SourceDocument.SourceLine srcFirstLine = null; do { @@ -180,15 +184,12 @@ public Tuple, List> FromToPositions(Node node) while (++lastLine < curLineIndex) { lineNumbers.Add(lastLine); - SourceDocument.SourceLine srcLine = TargetDocument[lastLine - 1]; - if (srcFirstLine != null) lineOffsets.Add(srcLine.From - srcFirstLine.From); } } SourceDocument.SourceLine curLine = TargetDocument[curLineIndex - 1]; if (srcFirstLine == null) srcFirstLine = curLine; lineNumbers.Add(curLineIndex); - lineOffsets.Add(curLine.From - srcFirstLine.From); span = 0; while ((i < node.CodeElement.ConsumedTokens.Count) && ((curLineIndex == node.CodeElement.ConsumedTokens[i].Line) || (node.CodeElement.ConsumedTokens[i] is TypeCobol.Compiler.Preprocessor.ImportedToken))) @@ -209,8 +210,7 @@ public Tuple, List> FromToPositions(Node node) } } while (i < node.CodeElement.ConsumedTokens.Count); lineNumbers.TrimExcess(); - lineOffsets.TrimExcess(); - return new Tuple, List>(from, to, span, lineNumbers, lineOffsets); + return new NodePositions(from, to, span, lineNumbers); } return null; } diff --git a/Codegen/src/Generators/DefaultGenerator.cs b/Codegen/src/Generators/DefaultGenerator.cs index 533f6727d..2fcc623fe 100644 --- a/Codegen/src/Generators/DefaultGenerator.cs +++ b/Codegen/src/Generators/DefaultGenerator.cs @@ -587,7 +587,7 @@ protected SourceText LinearGeneration(LinearNodeSourceCodeMapper mapper, Line //Pad a splitted segment if (mapper.Nodes[node_index].Positions != null) { - int span = mapper.Nodes[node_index].Positions.Item3; + int span = mapper.Nodes[node_index].Positions.Span; string pad = new string(' ', span); curSourceText.Insert(pad, to.Pos, to.Pos); } diff --git a/Codegen/src/Generators/ExpandingCopyGenerator.cs b/Codegen/src/Generators/ExpandingCopyGenerator.cs index ba79a9b58..c378cbc5b 100644 --- a/Codegen/src/Generators/ExpandingCopyGenerator.cs +++ b/Codegen/src/Generators/ExpandingCopyGenerator.cs @@ -176,15 +176,10 @@ private void EraseCompilerDirectiveTokens() /// Get the From and To Positions of this Node based on the consumed Token, if no ConsumedTokens the return value is NULL. /// In the consumed tokens span over several lines then the size of the newline sequence is included for each line. /// The method also calculate the ending span offset from the beginning of the last line. - /// It also get the list of Line numbers occupated by this node, and the offset of each line. - /// Item1 is the start column - /// Item2 is the en column - /// Item3 is the span - /// Item4 is the list of line numbers - /// Item5 is the list of offset inside the line numbers. + /// It also gets the list of Line numbers occupated by this node, and the offset of each line. /// /// - public Tuple, List> FromToPositions(IList ConsumedTokens) + public NodePositions FromToPositions(IList ConsumedTokens) { if (ConsumedTokens.Count > 0) { @@ -194,7 +189,6 @@ public Tuple, List> FromToPositions(IList C int i = 0; int span = 0; List lineNumbers = new List(); - List lineOffsets = new List(); SourceDocument.SourceLine srcFirstLine = null; do { @@ -212,15 +206,12 @@ public Tuple, List> FromToPositions(IList C while (++lastLine < curLineIndex) { lineNumbers.Add(lastLine); - SourceDocument.SourceLine srcLine = TargetDocument[lastLine - 1]; - if (srcFirstLine != null) lineOffsets.Add(srcLine.From - srcFirstLine.From); } } SourceDocument.SourceLine curLine = TargetDocument[curLineIndex - 1]; if (srcFirstLine == null) srcFirstLine = curLine; lineNumbers.Add(curLineIndex); - lineOffsets.Add(curLine.From - srcFirstLine.From); span = 0; while ((i < ConsumedTokens.Count) && ((curLineIndex == ConsumedTokens[i].Line) || (ConsumedTokens[i] is TypeCobol.Compiler.Preprocessor.ImportedToken))) @@ -241,8 +232,7 @@ public Tuple, List> FromToPositions(IList C } } while (i < ConsumedTokens.Count); lineNumbers.TrimExcess(); - lineOffsets.TrimExcess(); - return new Tuple, List>(from, to, span, lineNumbers, lineOffsets); + return new NodePositions(from, to, span, lineNumbers); } return null; } @@ -253,13 +243,13 @@ public Tuple, List> FromToPositions(IList C /// The list of token to compute positions /// Output of the from position /// Output of the to position - public Tuple, List> ComputePositions(IList tokens, out Position from, out Position to) + public NodePositions ComputePositions(IList tokens, out Position from, out Position to) { - Tuple, List> positions = FromToPositions(tokens); - SourceDocument.SourceLine firstLine = TargetDocument[positions.Item4[0] - 1]; - SourceDocument.SourceLine lastLine = TargetDocument[positions.Item4[positions.Item4.Count - 1] - 1]; - from = new Position(firstLine.From + positions.Item1 - 1); - to = new Position(lastLine.From + positions.Item2); + NodePositions positions = FromToPositions(tokens); + SourceDocument.SourceLine firstLine = TargetDocument[positions.LineNumbers[0] - 1]; + SourceDocument.SourceLine lastLine = TargetDocument[positions.LineNumbers[^1] - 1]; + from = new Position(firstLine.From + positions.From - 1); + to = new Position(lastLine.From + positions.To); return positions; } @@ -271,7 +261,7 @@ private void EraseCompilerDirectiveToken(IList tokens) { Position from = null; Position to = null; - Tuple, List> positions = ComputePositions(tokens, out from, out to); + NodePositions positions = ComputePositions(tokens, out from, out to); TargetDocument.Source.AddPosition(from);//from position TargetDocument.Source.AddPosition(to);//To Pos Compiler.Source.StringSourceText del_buffer = new Compiler.Source.StringSourceText(new string(' ', to.Pos - from.Pos)); @@ -288,12 +278,12 @@ public Position ComputeErasureAfterCopyInstructionAction(TypeCobol.Compiler.Scan bAddNewLine = false; Position cfrom = null; Position cto = null; - Tuple, List> positions = ComputePositions(new List() { copyToken, lastToken }, out cfrom, out cto); + NodePositions positions = ComputePositions(new List() { copyToken, lastToken }, out cfrom, out cto); TargetDocument.Source.AddPosition(cfrom);//from position if (this.Layout == ColumnsLayout.FreeTextFormat) return cfrom; - SourceDocument.SourceLine sourceLine = TargetDocument[positions.Item4[positions.Item4.Count - 1] - 1]; + SourceDocument.SourceLine sourceLine = TargetDocument[positions.LineNumbers[^1] - 1]; int lineLen = -1; int lineStartOffset = -1; int lineEndOffset = -1; diff --git a/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs b/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs index 5b9f760f7..8d4533288 100644 --- a/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs +++ b/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs @@ -223,7 +223,7 @@ public LinearGeneratedNode() /// /// Precalculated positions /// - public Tuple, List> Positions + public NodePositions Positions { get; set; @@ -315,14 +315,13 @@ public class NodeData /// public Node LastNode; /// - /// Node's Position - /// Item1 = From - /// Item2 = to - /// Item3 = span on the last line - /// Item4 = Node's Target Line Numbers. - /// Item5 = Node's Target Line offsets. + /// Node's Positions: + /// - From + /// - To + /// - Span on the last line + /// - Node's Target Line Numbers. /// - public Tuple, List> Positions; + public NodePositions Positions; /// /// The Buffer where this Node is Generated. /// @@ -525,10 +524,10 @@ private bool ProcessFunctionDeclaration(Node node) data = Nodes[node.NodeIndex]; if (funData.BodyFistLineIndex == 0) {//Remember the first the first line of the function body - funData.BodyFistLineIndex = data.Positions.Item4[0]; + funData.BodyFistLineIndex = data.Positions.LineNumbers[0]; } //Track the last line of the function body. - funData.BodyLastLineIndex = data.Positions.Item4[0]; + funData.BodyLastLineIndex = data.Positions.LineNumbers[0]; } } if (node.NodeIndex > 0) @@ -560,11 +559,8 @@ bool CanInsertBeforeNode(Node beforeNode) //Debug.Assert(Nodes[beforeNode.NodeIndex].Positions != null); if (!(Nodes[beforeNode.NodeIndex].Positions != null)) return false; - //Debug.Assert(Nodes[beforeNode.NodeIndex].Positions.Item4.Count > 0); - if (!(Nodes[beforeNode.NodeIndex].Positions.Item4.Count > 0)) - return false; - //Debug.Assert(Nodes[beforeNode.NodeIndex].Positions.Item5.Count > 0); - if (!(Nodes[beforeNode.NodeIndex].Positions.Item5.Count > 0)) + //Debug.Assert(Nodes[beforeNode.NodeIndex].Positions.LineNumbers.Count > 0); + if (!(Nodes[beforeNode.NodeIndex].Positions.LineNumbers.Count > 0)) return false; //Debug.Assert(Nodes[beforeNode.NodeIndex].From != null); if (!(Nodes[beforeNode.NodeIndex].From != null)) @@ -600,11 +596,8 @@ private bool InsertNodeBeforeNode(Node theNode, Node beforeNode) Debug.Assert(Nodes[beforeNode.NodeIndex].Positions != null); if (!(Nodes[beforeNode.NodeIndex].Positions != null)) return false; - Debug.Assert(Nodes[beforeNode.NodeIndex].Positions.Item4.Count > 0); - if (!(Nodes[beforeNode.NodeIndex].Positions.Item4.Count > 0)) - return false; - Debug.Assert(Nodes[beforeNode.NodeIndex].Positions.Item5.Count > 0); - if (!(Nodes[beforeNode.NodeIndex].Positions.Item5.Count > 0)) + Debug.Assert(Nodes[beforeNode.NodeIndex].Positions.LineNumbers.Count > 0); + if (!(Nodes[beforeNode.NodeIndex].Positions.LineNumbers.Count > 0)) return false; Debug.Assert(Nodes[beforeNode.NodeIndex].From != null); if (!(Nodes[beforeNode.NodeIndex].From != null)) @@ -614,7 +607,7 @@ private bool InsertNodeBeforeNode(Node theNode, Node beforeNode) return false; //Determine the Line number of the before line. - int before_line = Nodes[beforeNode.NodeIndex].Positions.Item4[0] - 1; + int before_line = Nodes[beforeNode.NodeIndex].Positions.LineNumbers[0] - 1; //Add the node to the same line int insertIndex = LineData[before_line].LineNodes.IndexOf(beforeNode.NodeIndex); LineData[before_line].LineNodes.Insert(insertIndex, theNode.NodeIndex); @@ -623,12 +616,11 @@ private bool InsertNodeBeforeNode(Node theNode, Node beforeNode) Nodes[theNode.NodeIndex].From = Nodes[beforeNode.NodeIndex].From; Nodes[theNode.NodeIndex].To = Nodes[beforeNode.NodeIndex].From; //Give to the Node its new span - Nodes[theNode.NodeIndex].Positions = new Tuple, List>( - Nodes[beforeNode.NodeIndex].Positions.Item1, - Nodes[beforeNode.NodeIndex].Positions.Item1, - Nodes[beforeNode.NodeIndex].Positions.Item1, - new List() { Nodes[beforeNode.NodeIndex].Positions.Item4[0] }, - new List() { Nodes[beforeNode.NodeIndex].Positions.Item5[0] } + Nodes[theNode.NodeIndex].Positions = new NodePositions( + Nodes[beforeNode.NodeIndex].Positions.From, + Nodes[beforeNode.NodeIndex].Positions.From, + Nodes[beforeNode.NodeIndex].Positions.From, + new List() { Nodes[beforeNode.NodeIndex].Positions.LineNumbers[0] } ); //We must insert a NewLine @@ -661,11 +653,8 @@ private bool InsertNodeAfterNode(Node theNode, Node afterNode) Debug.Assert(Nodes[afterNode.NodeIndex].Positions != null); if (!(Nodes[afterNode.NodeIndex].Positions != null)) return false; - Debug.Assert(Nodes[afterNode.NodeIndex].Positions.Item4.Count > 0); - if (!(Nodes[afterNode.NodeIndex].Positions.Item4.Count > 0)) - return false; - Debug.Assert(Nodes[afterNode.NodeIndex].Positions.Item5.Count > 0); - if (!(Nodes[afterNode.NodeIndex].Positions.Item5.Count > 0)) + Debug.Assert(Nodes[afterNode.NodeIndex].Positions.LineNumbers.Count > 0); + if (!(Nodes[afterNode.NodeIndex].Positions.LineNumbers.Count > 0)) return false; Debug.Assert(Nodes[afterNode.NodeIndex].From != null); if (!(Nodes[afterNode.NodeIndex].From != null)) @@ -675,7 +664,7 @@ private bool InsertNodeAfterNode(Node theNode, Node afterNode) return false; //Determine the Line number of the before line. - int before_line = Nodes[afterNode.NodeIndex].Positions.Item4[0] - 1; + int before_line = Nodes[afterNode.NodeIndex].Positions.LineNumbers[0] - 1; //Add the node to the same line LineData[before_line].LineNodes.Add(theNode.NodeIndex); //The Node is Inserted at the beginning of the before node @@ -683,12 +672,11 @@ private bool InsertNodeAfterNode(Node theNode, Node afterNode) Nodes[theNode.NodeIndex].From = Nodes[afterNode.NodeIndex].To; Nodes[theNode.NodeIndex].To = Nodes[afterNode.NodeIndex].To; //Give to the Node its new span - Nodes[theNode.NodeIndex].Positions = new Tuple, List>( - Nodes[afterNode.NodeIndex].Positions.Item1, - Nodes[afterNode.NodeIndex].Positions.Item1, - Nodes[afterNode.NodeIndex].Positions.Item2, - new List() { Nodes[afterNode.NodeIndex].Positions.Item4[0] }, - new List() { Nodes[afterNode.NodeIndex].Positions.Item5[0] } + Nodes[theNode.NodeIndex].Positions = new NodePositions( + Nodes[afterNode.NodeIndex].Positions.To, + Nodes[afterNode.NodeIndex].Positions.To, + Nodes[afterNode.NodeIndex].Positions.Span, + new List() { Nodes[afterNode.NodeIndex].Positions.LineNumbers[^1] } ); //First generate a new line befor this node theNode.SetFlag(Node.Flag.FactoryGeneratedNodeWithFirstNewLine, true); @@ -795,7 +783,7 @@ private bool ProcessLinearization(Node node, bool functionBody = false) //Remember the Global Storage Section node. this.ClonedGlobalStorageSection = (GlobalStorageSection)node; } - Tuple, List> positions = this.Generator.FromToPositions(node); + NodePositions positions = this.Generator.FromToPositions(node); if (positions == null) { //Node without positions probably a generated node. node.NodeIndex = -1; @@ -806,7 +794,7 @@ private bool ProcessLinearization(Node node, bool functionBody = false) } return true; } - if (positions.Item4.Count == 0) + if (positions.LineNumbers.Count == 0) { //This must be a Node in an imported COPY it has no lines associated to it //So We must First try to create a COPY Node so that we can capture the COPY Line. if (node.IsInsideCopy()) @@ -859,7 +847,7 @@ private bool ProcessLinearization(Node node, bool functionBody = false) node.NodeIndex = -1; return true; } - if (positions.Item1 > positions.Item2) + if (positions.From > positions.To) { //This is a very strange node that I encountered with position (from > to) //I encountered this situation with tests files like: //CCC1B045.PGM, CCTF0011.PGM, CCTZ015B, CCTZ0300B, etc.. @@ -881,7 +869,7 @@ private bool ProcessLinearization(Node node, bool functionBody = false) LineStringSourceText buffer = null; //The first line number of the target buffer int lineindex_buffer = -1; - foreach (int i in data.Positions.Item4) + foreach (int i in data.Positions.LineNumbers) {//For each line concerned by the Node int lineIndex = i - 1;//Zero based Index Line Number NodedLines[lineIndex] = true;//Now this line is associated to at leat one node. @@ -920,7 +908,7 @@ private bool ProcessLinearization(Node node, bool functionBody = false) //Add the participating line buffer buffer.AddLine(lineIndex); //Propagate Comment from buffer line index to current line. - //That is to say mark all line concerned by a Commnented Node as commented. + //That is to say mark all line concerned by a Commented Node as commented. if (bCommented) { for (int k = lineindex_buffer; k < lineIndex; k++) @@ -930,16 +918,15 @@ private bool ProcessLinearization(Node node, bool functionBody = false) //Associate this node to its buffer data.Buffer = buffer; //Update the positions by translating the position to the real position in the source document. - //The source document is the document which contais the Full original source code - int line_from = data.Positions.Item1 - 1; - int line_to = data.Positions.Item2; - int span = data.Positions.Item3; - List lines = data.Positions.Item4; - List line_offsets = data.Positions.Item5; - SourceDocument.SourceLine lineindex_srcline = Generator.TargetDocument[lineindex_buffer]; + //The source document is the document which contains the Full original source code + int line_from = data.Positions.From - 1; + int line_to = data.Positions.To; + int span = data.Positions.Span; + List lines = data.Positions.LineNumbers; + SourceDocument.SourceLine lineindex_srcline = Generator.TargetDocument[lineindex_buffer]; SourceDocument.SourceLine line = Generator.TargetDocument[lines[0] - 1]; int delta = line.From - lineindex_srcline.From; - data.Positions = new Tuple, List>(delta + line_from, delta + line_to, span, lines, line_offsets); + data.Positions = new NodePositions(delta + line_from, delta + line_to, span, lines); //Add Node's data to the list of all Node Data Nodes.Add(data); //------------------------------------------------------------------------------ @@ -1140,8 +1127,7 @@ private void CollectFunctionBodyUnNodedLines(NodeFunctionData funData) int to = data.Buffer.Size;//To the end of the buffer int span = 0; List lines = new List(){ lineGot };//Line number - List offsets = new List(){0};//Line number start at offse 0 - Tuple, List> pos = new Tuple, List>(from, to, span, lines, offsets); + NodePositions pos = new NodePositions(from, to, span, lines); dummy_node.Positions = pos; } } @@ -1155,18 +1141,18 @@ private void CollectFunctionBodyUnNodedLines(NodeFunctionData funData) private void RelocateFunctionBodyNoPositionNodes(NodeFunctionData funData) { //The last line of the function declaration - int lastBufferLineNumber = funData.Positions.Item4.Count > 0 ? funData.Positions.Item4[funData.Positions.Item4.Count - 1] :-1; + int lastBufferLineNumber = funData.Positions.LineNumbers.Count > 0 ? funData.Positions.LineNumbers[^1] :-1; for (int j = 0; j < funData.FunctionDeclNodes.Count; j++) {//For each Node in the function declaration body NodeData node_data = Nodes[funData.FunctionDeclNodes[j]]; //Get its positions - Tuple, List> positions = + NodePositions positions = node_data.node.IsFlagSet(Node.Flag.ExtraGeneratedLinearNode) ? ((LinearGeneratedNode)node_data.node).Positions : this.Generator.FromToPositions(node_data.node); if (positions != null && node_data.Buffer != null) {//If the Node has positions and it is associated to a buffer //The keep the the first line number having a valid buffer - lastBufferLineNumber = positions.Item4[0]; + lastBufferLineNumber = positions.LineNumbers[0]; } else if (positions == null && lastBufferLineNumber > 0) { //The node has no positions but we know a valid last line number having a valid buffer @@ -1202,16 +1188,16 @@ private Tuple ComputeFunctionBodyInsertionLines(NodeFunctionData f for (int j = 0; j < funData.FunctionDeclNodes.Count; j++) {//For each node in the function declaration body. NodeData node_data = Nodes[funData.FunctionDeclNodes[j]]; - Tuple, List> positions = this.Generator.FromToPositions(node_data.node); + NodePositions positions = this.Generator.FromToPositions(node_data.node); if (positions != null) {//A Node with positions - if (!lineNumbers.Contains(positions.Item4[0])) + if (!lineNumbers.Contains(positions.LineNumbers[0])) { //Insert interval to the previous insertion point. if (lineNumbers.Count > 0) { int prevPoint = insertPoints[insertPoints.Count - 1]; - for (int i = lineNumbers[lineNumbers.Count - 1] + 1; i < positions.Item4[0]; i++) + for (int i = lineNumbers[lineNumbers.Count - 1] + 1; i < positions.LineNumbers[0]; i++) { //Each line numbers not associated to a node must be associated to the last valid insertion point. //Such insertion point is added with negative value to distinguish it from a valid insertion point. lineNumbers.Add(i); @@ -1219,8 +1205,8 @@ private Tuple ComputeFunctionBodyInsertionLines(NodeFunctionData f } } //Add the line number and its position to valid number and insertion point lists. - lineNumbers.Add(positions.Item4[0]); - insertPoints.Add(j); + lineNumbers.Add(positions.LineNumbers[0]); + insertPoints.Add(j); } } } @@ -1260,8 +1246,8 @@ private void CreateNodeSourceTextBufferContents() { if (Nodes[i].Positions != null) {//Only for Nodes with positions - Position from = new Position(Nodes[i].Positions.Item1); - Position to = new Position(Nodes[i].Positions.Item2); + Position from = new Position(Nodes[i].Positions.From); + Position to = new Position(Nodes[i].Positions.To); Nodes[i].Buffer.AddPosition(from);//from position Nodes[i].Buffer.AddPosition(to);//To Pos Nodes[i].From = from; @@ -1424,7 +1410,7 @@ internal void GetAfterLinearizationLastLine(Node node, ref int lastLine, ref Nod { if (Nodes[node.NodeIndex].Positions != null) { - lastLine = Nodes[node.NodeIndex].Positions.Item4[Nodes[node.NodeIndex].Positions.Item4.Count - 1]; + lastLine = Nodes[node.NodeIndex].Positions.LineNumbers[^1]; lastNode = node; } } @@ -1519,8 +1505,8 @@ public void CommentBetweenTokens(Node node, TokenType startTokenType, TokenType // for each lines, if it is inside the formalized comment then comment them (replace the 7th character by a '*') for (int i = 0; i < bufferLines.GetLength(0) - 1; i++) { - if (nodeData.Positions.Item4[i] >= delimiterToken.Item1.Line && - nodeData.Positions.Item4[i] <= delimiterToken.Item2.Line && + if (nodeData.Positions.LineNumbers[i] >= delimiterToken.Item1.Line && + nodeData.Positions.LineNumbers[i] <= delimiterToken.Item2.Line && bufferLines[i, 1] >= 7) // Avoid comment blank lines { if (positionList.Any() && positionList[0].Pos == bufferLines[i, 0] + 6) @@ -1598,15 +1584,15 @@ public void Dump() StringBuilder lines = new StringBuilder(); if (data.Positions != null) { - foreach (int n in data.Positions.Item4) + foreach (int n in data.Positions.LineNumbers) { lines.Append(n); lines.Append(","); } } - int from = data.Positions != null ? data.Positions.Item1 : -1; - int to = data.Positions != null ? data.Positions.Item2 : -1; - int span = data.Positions != null ? data.Positions.Item3 : -1; + int from = data.Positions != null ? data.Positions.From : -1; + int to = data.Positions != null ? data.Positions.To : -1; + int span = data.Positions != null ? data.Positions.Span : -1; System.Console.WriteLine("Node {0}<{6}> {7}: Index={1}, Positions[from={2}, To={3}, Span={4}, Lines={5} {8}]", i, i, from, to, span, lines.ToString(), data.node.GetType().FullName, data.Removed ? "?REMOVED?" : "", data.node.Comment != null ? (data.node.Comment.Value ? "COMMENTED" : "") : ""); @@ -1658,15 +1644,15 @@ public void DebugDump() StringBuilder lines = new StringBuilder(); if (data.Positions != null) { - foreach (int n in data.Positions.Item4) + foreach (int n in data.Positions.LineNumbers) { lines.Append(n); lines.Append(","); } } - int from = data.Positions != null ? data.Positions.Item1 : -1; - int to = data.Positions != null ? data.Positions.Item2 : -1; - int span = data.Positions != null ? data.Positions.Item3 : -1; + int from = data.Positions != null ? data.Positions.From : -1; + int to = data.Positions != null ? data.Positions.To : -1; + int span = data.Positions != null ? data.Positions.Span : -1; Debug.WriteLine("Node {0}<{6}> {7}: Index={1}, Positions[from={2}, To={3}, Span={4}, Lines={5} {8}]", i, i, from, to, span, lines.ToString(), data.node.GetType().FullName, data.Removed ? "?REMOVED?" : "", data.node.Comment != null ? (data.node.Comment.Value ? "COMMENTED" : "") : ""); diff --git a/Codegen/test/CodegenTestUtils.cs b/Codegen/test/CodegenTestUtils.cs index c0d5bd9be..3655844e0 100644 --- a/Codegen/test/CodegenTestUtils.cs +++ b/Codegen/test/CodegenTestUtils.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; +using System.Text; using TypeCobol.Compiler; using TypeCobol.Compiler.Diagnostics; using TypeCobol.Compiler.Directives; @@ -73,15 +71,15 @@ private static void ParseGenerateCompare(string path, TypeCobolOptions options, } // compare with expected result - string expected = File.ReadAllText(Path.Combine(ROOT, OUTPUT, path), format.Encoding); - TypeCobol.Test.TestUtils.CompareLines(path, writer.ToString(), expected, PlatformUtils.GetPathForProjectFile(Path.Combine(ROOT, OUTPUT, path), "Codegen\\test")); + var expected = new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(Path.Combine(ROOT, OUTPUT, path), "Codegen/test"), format.Encoding); + TestUtils.CompareContent(path, writer.ToString(), expected); if (lmStream != null) { //compare with expected line mapping - string lm = System.Text.ASCIIEncoding.Default.GetString(lmStream.ToArray()); - string expectedLm = File.ReadAllText(Path.Combine(ROOT, OUTPUT, path + ML_SUFFIX), format.Encoding); - TypeCobol.Test.TestUtils.CompareLines(path + ML_SUFFIX, lm, expectedLm, PlatformUtils.GetPathForProjectFile(Path.Combine(ROOT, OUTPUT, path + ML_SUFFIX), "Codegen\\test")); + string lm = Encoding.Default.GetString(lmStream.ToArray()); + var expectedLm = new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(Path.Combine(ROOT, OUTPUT, path + ML_SUFFIX), "Codegen/test"), format.Encoding); + TestUtils.CompareContent(path + ML_SUFFIX, lm, expectedLm); } } diff --git a/Codegen/test/TestTypeCobolCodegen.cs b/Codegen/test/TestTypeCobolCodegen.cs index 5e29af5f0..537911339 100644 --- a/Codegen/test/TestTypeCobolCodegen.cs +++ b/Codegen/test/TestTypeCobolCodegen.cs @@ -103,7 +103,7 @@ public void ParseQualifReferenceModifierProc() [TestCategory("Codegen")] [TestProperty("Time","fast")] public void ParseFunctions() { - CodegenTestUtils.ParseGenerateCompare(Path.Combine("TypeCobol","Function")+".rdz.cbl"); + CodegenTestUtils.ParseGenerateCompare(Path.Combine("TypeCobol","FUNCTION")+".rdz.cbl"); } [TestMethod] diff --git a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc.rdz.tcbl index 582746ded..d8adb01f0 100644 --- a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc.rdz.tcbl @@ -31,7 +31,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PersonService. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PersonSe-FctList-Loaded PIC X(02) VALUE space. 88 TC-PersonSe-FctList-IsLoaded VALUE 'OK'. @@ -43,7 +43,7 @@ 05 TC-PersonSe-cd991005-Idt PIC X(08) VALUE 'cd991005'. 05 TC-PersonSe-cd991005 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc3.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc3.rdz.tcbl index c3f248bee..0446d601f 100644 --- a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc3.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc3.rdz.tcbl @@ -1,7 +1,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. TCOZCHKP. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-TCOZCHKP-FctList-Loaded PIC X(02) VALUE space. 88 TC-TCOZCHKP-FctList-IsLoaded VALUE 'OK'. @@ -13,7 +13,7 @@ 05 TC-TCOZCHKP-b179d81b-Idt PIC X(08) VALUE 'b179d81b'. 05 TC-TCOZCHKP-b179d81b PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc4.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc4.rdz.tcbl index 2cfee8bc4..4810a1615 100644 --- a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc4.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPrivateProc4.rdz.tcbl @@ -1,7 +1,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM1. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM1-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM1-FctList-IsLoaded VALUE 'OK'. @@ -13,7 +13,7 @@ 05 TC-PGM1-f1c0385c-Idt PIC X(08) VALUE 'f1c0385c'. 05 TC-PGM1-f1c0385c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. @@ -49,7 +49,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM2. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM2-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM2-FctList-IsLoaded VALUE 'OK'. @@ -61,7 +61,7 @@ 05 TC-PGM2-f73481e6-Idt PIC X(08) VALUE 'f73481e6'. 05 TC-PGM2-f73481e6 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc-DeclarativesNoDebug.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc-DeclarativesNoDebug.rdz.tcbl index 443236626..567eb6bb1 100644 --- a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc-DeclarativesNoDebug.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc-DeclarativesNoDebug.rdz.tcbl @@ -1,7 +1,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM1. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM1-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM1-FctList-IsLoaded VALUE 'OK'. @@ -14,7 +14,7 @@ 05 TC-PGM1-e3685b69-Idt PIC X(08) VALUE 'e3685b69'. 05 TC-PGM1-e3685b69 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. @@ -57,7 +57,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. MyPGM. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-MyPGM-FctList-Loaded PIC X(02) VALUE space. 88 TC-MyPGM-FctList-IsLoaded VALUE 'OK'. @@ -70,7 +70,7 @@ 05 TC-MyPGM-bfc74757-Idt PIC X(08) VALUE 'bfc74757'. 05 TC-MyPGM-bfc74757 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc.rdz.tcbl index 1aa82ebec..937190cb8 100644 --- a/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/CallPublicProcFromPublicProc.rdz.tcbl @@ -1,7 +1,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM1. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM1-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM1-FctList-IsLoaded VALUE 'OK'. @@ -13,7 +13,7 @@ 05 TC-PGM1-f1c0385c-Idt PIC X(08) VALUE 'f1c0385c'. 05 TC-PGM1-f1c0385c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. @@ -49,7 +49,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM2. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM2-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM2-FctList-IsLoaded VALUE 'OK'. @@ -61,7 +61,7 @@ 05 TC-PGM2-f73481e6-Idt PIC X(08) VALUE 'f73481e6'. 05 TC-PGM2-f73481e6 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/DeclarativesWithInstructionsWithin.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/DeclarativesWithInstructionsWithin.rdz.tcbl index 6d1a788f4..832af153b 100644 --- a/Codegen/test/resources/output/TypeCobol/DeclarativesWithInstructionsWithin.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/DeclarativesWithInstructionsWithin.rdz.tcbl @@ -110,7 +110,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. Callee. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-Callee-FctList-Loaded PIC X(02) VALUE space. 88 TC-Callee-FctList-IsLoaded VALUE 'OK'. @@ -123,7 +123,7 @@ 05 TC-Callee-ca0ab46c-Idt PIC X(08) VALUE 'ca0ab46c'. 05 TC-Callee-ca0ab46c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/FormalizedComments.tcbl b/Codegen/test/resources/output/TypeCobol/FormalizedComments.tcbl index 53476ecad..9f0ad9fa5 100644 --- a/Codegen/test/resources/output/TypeCobol/FormalizedComments.tcbl +++ b/Codegen/test/resources/output/TypeCobol/FormalizedComments.tcbl @@ -80,7 +80,7 @@ set PntTab-Pnt TO ADDRESS OF TC-DocCodeG-PntTab . - + *<<< MyProc info * @ deprec : It is diff --git a/Codegen/test/resources/output/TypeCobol/Library4.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/Library4.rdz.tcbl index ad426476a..c2cd7c678 100644 --- a/Codegen/test/resources/output/TypeCobol/Library4.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/Library4.rdz.tcbl @@ -1,7 +1,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. DVZZDATE. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-DVZZDATE-FctList-Loaded PIC X(02) VALUE space. 88 TC-DVZZDATE-FctList-IsLoaded VALUE 'OK'. @@ -13,7 +13,7 @@ 05 TC-DVZZDATE-b173dd7b-Idt PIC X(08) VALUE 'b173dd7b'. 05 TC-DVZZDATE-b173dd7b PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/LineExceed5.rdz.cbl b/Codegen/test/resources/output/TypeCobol/LineExceed5.rdz.cbl index 1ace20d13..93c9debeb 100644 --- a/Codegen/test/resources/output/TypeCobol/LineExceed5.rdz.cbl +++ b/Codegen/test/resources/output/TypeCobol/LineExceed5.rdz.cbl @@ -1,7 +1,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM1. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM1-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM1-FctList-IsLoaded VALUE 'OK'. @@ -13,7 +13,7 @@ 05 TC-PGM1-f1c0385c-Idt PIC X(08) VALUE 'f1c0385c'. 05 TC-PGM1-f1c0385c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. @@ -49,7 +49,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. PGM2. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-PGM2-FctList-Loaded PIC X(02) VALUE space. 88 TC-PGM2-FctList-IsLoaded VALUE 'OK'. @@ -61,7 +61,7 @@ 05 TC-PGM2-f73481e6-Idt PIC X(08) VALUE 'f73481e6'. 05 TC-PGM2-f73481e6 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/MisPlaceCopyInstrWithProcMetaData.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/MisPlaceCopyInstrWithProcMetaData.rdz.tcbl index aeb539c70..adca1c4d4 100644 --- a/Codegen/test/resources/output/TypeCobol/MisPlaceCopyInstrWithProcMetaData.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/MisPlaceCopyInstrWithProcMetaData.rdz.tcbl @@ -81,7 +81,7 @@ ID DIVISION. PROGRAM-ID. DVZF0OS2. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-DVZF0OS2-FctList-Loaded PIC X(02) VALUE space. 88 TC-DVZF0OS2-FctList-IsLoaded VALUE 'OK'. @@ -94,7 +94,7 @@ 05 TC-DVZF0OS2-bdb3e928-Idt PIC X(08) VALUE 'bdb3e928'. 05 TC-DVZF0OS2-bdb3e928 PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives.rdz.tcbl index 89d5dfff9..80b275369 100644 --- a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives.rdz.tcbl @@ -99,7 +99,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. Callee. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-Callee-FctList-Loaded PIC X(02) VALUE space. 88 TC-Callee-FctList-IsLoaded VALUE 'OK'. @@ -112,7 +112,7 @@ 05 TC-Callee-ca0ab46c-Idt PIC X(08) VALUE 'ca0ab46c'. 05 TC-Callee-ca0ab46c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives2.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives2.rdz.tcbl index 6da9a59f0..5eee1e493 100644 --- a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives2.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives2.rdz.tcbl @@ -99,7 +99,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. Callee. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-Callee-FctList-Loaded PIC X(02) VALUE space. 88 TC-Callee-FctList-IsLoaded VALUE 'OK'. @@ -112,7 +112,7 @@ 05 TC-Callee-ca0ab46c-Idt PIC X(08) VALUE 'ca0ab46c'. 05 TC-Callee-ca0ab46c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives3.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives3.rdz.tcbl index c4ca3aeed..2e76bf09a 100644 --- a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives3.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives3.rdz.tcbl @@ -103,7 +103,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. Callee. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-Callee-FctList-Loaded PIC X(02) VALUE space. 88 TC-Callee-FctList-IsLoaded VALUE 'OK'. @@ -116,7 +116,7 @@ 05 TC-Callee-ca0ab46c-Idt PIC X(08) VALUE 'ca0ab46c'. 05 TC-Callee-ca0ab46c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives4.rdz.tcbl b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives4.rdz.tcbl index d7fc3a899..62339b318 100644 --- a/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives4.rdz.tcbl +++ b/Codegen/test/resources/output/TypeCobol/ProcedureCall-PublicAndDeclaratives4.rdz.tcbl @@ -102,7 +102,7 @@ IDENTIFICATION DIVISION. PROGRAM-ID. Callee. DATA DIVISION. - + WORKING-STORAGE SECTION. 01 TC-Callee-FctList-Loaded PIC X(02) VALUE space. 88 TC-Callee-FctList-IsLoaded VALUE 'OK'. @@ -115,7 +115,7 @@ 05 TC-Callee-ca0ab46c-Idt PIC X(08) VALUE 'ca0ab46c'. 05 TC-Callee-ca0ab46c PROCEDURE-POINTER. - + LINKAGE SECTION. 01 PntTab-Pnt POINTER. diff --git a/Codegen/test/resources/output/TypeCobol/Remarks/RemarksLess.rdz.cbl b/Codegen/test/resources/output/TypeCobol/Remarks/RemarksLess.rdz.cbl index 7f5c09be4..64fd6a0e1 100644 --- a/Codegen/test/resources/output/TypeCobol/Remarks/RemarksLess.rdz.cbl +++ b/Codegen/test/resources/output/TypeCobol/Remarks/RemarksLess.rdz.cbl @@ -4,7 +4,7 @@ * YPRTD20L * YCONVEAL * ). - + 000000 ENVIRONMENT DIVISION. 000000 DATA DIVISION. 000000 WORKING-STORAGE section. diff --git a/TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfbounds0.diag b/TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfBounds0.diag similarity index 100% rename from TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfbounds0.diag rename to TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfBounds0.diag diff --git a/TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfbounds0.dot b/TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfBounds0.dot similarity index 100% rename from TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfbounds0.dot rename to TypeCobol.Analysis.Test/BasicCfgInstrs/PerformGoesOutOfBounds0.dot diff --git a/TypeCobol.Analysis.Test/CfgDfaDominatorTests.cs b/TypeCobol.Analysis.Test/CfgDfaDominatorTests.cs index 248b7c0dd..95bab6276 100644 --- a/TypeCobol.Analysis.Test/CfgDfaDominatorTests.cs +++ b/TypeCobol.Analysis.Test/CfgDfaDominatorTests.cs @@ -1,10 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; -using TypeCobol.Analysis.Graph; using TypeCobol.Test; + +using CFG = TypeCobol.Analysis.Graph.ControlFlowGraph>; + using static TypeCobol.Analysis.Test.CfgTestUtils; -using CFG = TypeCobol.Analysis.Graph.ControlFlowGraph>; namespace TypeCobol.Analysis.Test { @@ -25,8 +24,7 @@ public void HanoiPrgCfgExtendedDominator() CFG.DumpDominators(blocks_dominators.Item2, writer); // compare with expected result string result = writer.ToString(); - string expected = File.ReadAllText(expectedDomsFile); - TestUtils.CompareLines(path, result, expected, expectedDomsFile); + TestUtils.CompareContent(path, result, new TestUtils.FileInfo(expectedDomsFile)); } private static void HanoiPrgCfgExtendedImmediateDominator(bool duplicate) @@ -42,8 +40,7 @@ private static void HanoiPrgCfgExtendedImmediateDominator(bool duplicate) CFG.DumpDominators(idoms, writer); // compare with expected result string result = writer.ToString(); - string expected = File.ReadAllText(expectedDomsFile); - TestUtils.CompareLines(path, result, expected, expectedDomsFile); + TestUtils.CompareContent(path, result, new TestUtils.FileInfo(expectedDomsFile)); } [TestMethod] diff --git a/TypeCobol.Analysis.Test/CfgTestUtils.cs b/TypeCobol.Analysis.Test/CfgTestUtils.cs index ba6226502..fed35a481 100644 --- a/TypeCobol.Analysis.Test/CfgTestUtils.cs +++ b/TypeCobol.Analysis.Test/CfgTestUtils.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; +using System.Diagnostics; using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; using TypeCobol.Analysis.Dfa; using TypeCobol.Analysis.Graph; using TypeCobol.Analysis.Util; @@ -79,8 +74,7 @@ public static DfaTestResults ParseCompareDiagnosticsWithDfa(string sourceFilePat GenVariableLivenessResults(dfaResults, writer); string result = writer.ToString(); - string expected = File.ReadAllText(expectedLivenessFilePath); - TestUtils.CompareLines(sourceFilePath, result, expected, expectedLivenessFilePath); + TestUtils.CompareContent(sourceFilePath, result, new TestUtils.FileInfo(expectedLivenessFilePath)); } return dfaResults; @@ -140,8 +134,7 @@ public static IList> ParseCompareDiagnostics(string string diagnosticsText = ParserUtils.DiagnosticsToString(diagnostics); if (File.Exists(expectedDiagnosticsFilePath)) { - string expectedResult = File.ReadAllText(expectedDiagnosticsFilePath); - TestUtils.CompareLines(sourceFilePath, diagnosticsText, expectedResult, expectedDiagnosticsFilePath); + TestUtils.CompareContent(sourceFilePath, diagnosticsText, new TestUtils.FileInfo(expectedDiagnosticsFilePath)); } else { @@ -215,8 +208,7 @@ public static void GenDotCfgAndCompare(ControlFlowGraph cfg, string // compare with expected result string result = writer.ToString(); - string expected = File.ReadAllText(expectedDotFile); - TestUtils.CompareLines(testPath, result, expected, expectedDotFile); + TestUtils.CompareContent(testPath, result, new TestUtils.FileInfo(expectedDotFile)); } /// diff --git a/TypeCobol.Analysis.Test/DfaCallPgmReport.cs b/TypeCobol.Analysis.Test/DfaCallPgmReport.cs index 540ebee50..0138af63b 100644 --- a/TypeCobol.Analysis.Test/DfaCallPgmReport.cs +++ b/TypeCobol.Analysis.Test/DfaCallPgmReport.cs @@ -1,6 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TypeCobol.Compiler; -using System.IO; using TypeCobol.Analysis.Dfa; using TypeCobol.Analysis.Report; using TypeCobol.Compiler.Symbols; @@ -30,8 +29,7 @@ public void InBulkCallPgmReportTest() // compare with expected result string result = sw.ToString(); string output = Path.Combine(CfgTestUtils.Report, "InBulkCallPgm.csv"); - string expected = File.ReadAllText(output, DocumentFormat.RDZReferenceFormat.Encoding); - TypeCobol.Test.TestUtils.CompareLines(path, result, expected, output); + TypeCobol.Test.TestUtils.CompareContent(path, result, new TypeCobol.Test.TestUtils.FileInfo(output, DocumentFormat.RDZReferenceFormat.Encoding)); } } @@ -50,8 +48,7 @@ public void InBulkCallPgm88SetReportTest() // compare with expected result string result = sw.ToString(); string output = Path.Combine(CfgTestUtils.Report, "InBulkCallPgm88Set.csv"); - string expected = File.ReadAllText(output, DocumentFormat.RDZReferenceFormat.Encoding); - TypeCobol.Test.TestUtils.CompareLines(path, result, expected, output); + TypeCobol.Test.TestUtils.CompareContent(path, result, new TypeCobol.Test.TestUtils.FileInfo(output, DocumentFormat.RDZReferenceFormat.Encoding)); } } @@ -70,8 +67,7 @@ public void ProcCallPgmReportTest() // compare with expected result string result = sw.ToString(); string output = Path.Combine(CfgTestUtils.Report, "ProcCallPgm.csv"); - string expected = File.ReadAllText(output, DocumentFormat.RDZReferenceFormat.Encoding); - TypeCobol.Test.TestUtils.CompareLines(path, result, expected, output); + TypeCobol.Test.TestUtils.CompareContent(path, result, new TypeCobol.Test.TestUtils.FileInfo(output, DocumentFormat.RDZReferenceFormat.Encoding)); } } diff --git a/TypeCobol.Analysis.Test/ViolationTest.cs b/TypeCobol.Analysis.Test/ViolationTest.cs index 8d76a9d06..369850bb3 100644 --- a/TypeCobol.Analysis.Test/ViolationTest.cs +++ b/TypeCobol.Analysis.Test/ViolationTest.cs @@ -32,8 +32,7 @@ private static void TestCreation([CallerMemberName] string testName = null) // Compare to expected var expectedPath = Path.Combine(folder, $"{fileName}-expected.txt"); - var expected = File.ReadAllText(expectedPath); - TestUtils.CompareLines(testName, result.ToString(), expected, expectedPath); + TestUtils.CompareContent(testName, result.ToString(), new TestUtils.FileInfo(expectedPath)); } [TestMethod] diff --git a/TypeCobol.Analysis/Graph/CfgDotFileForNodeGenerator.cs b/TypeCobol.Analysis/Graph/CfgDotFileForNodeGenerator.cs index 3844c91e3..2658b86f5 100644 --- a/TypeCobol.Analysis/Graph/CfgDotFileForNodeGenerator.cs +++ b/TypeCobol.Analysis/Graph/CfgDotFileForNodeGenerator.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.IO; +using System.Diagnostics; using System.Text; using TypeCobol.Analysis.Cfg; using TypeCobol.Compiler; @@ -37,8 +36,10 @@ private static string Escape(string text) sb.Append('\\'); break; case '\n': + sb.Append(" "); // Lines breaks translate to two spaces regardless of the platform + continue; case '\r': - sb.Append(' '); + // Ignore CR continue; } sb.Append(c); @@ -46,10 +47,35 @@ private static string Escape(string text) return sb.ToString(); } + /// + /// Set of encountered blocks during one generation, each block is identified by its index. + /// Instantiated once in the constructor of root generator, then shared with all of its children. + /// Cleared each time a new generation is requested. + /// private readonly HashSet _encounteredBlocks; - private readonly StringBuilder _blocksBuffer; - private readonly StringBuilder _edgesBuffer; + + /// + /// Buffer for blocks. Each generator has its own instance. This buffer is created as soon as + /// we have the format parameters (FormatProvider and NewLine): + /// - for root generator that is when the generation is requested, using the supplied TextWriter + /// - for children generators, this is in the constructor having the parent generator as argument + /// + private StringWriter _blocksBuffer; + + /// + /// Buffer for edges. This buffer is shared across root generator and its children. + /// Like block generator, it is parameterized using the target writer properties. + /// + private StringWriter _edgesBuffer; + + /// + /// The current CFG to generate in DOT language. + /// private ControlFlowGraph _cfg; + + /// + /// The identifier of current graph or subgraph being generated, a new identifier is generated for each block group coming from the CFG. + /// private readonly int _clusterIndex; public delegate void BlockEmitted(BasicBlock block, int clusterIndex); @@ -67,32 +93,34 @@ public CfgDotFileForNodeGenerator(ControlFlowGraph cfg) private CfgDotFileForNodeGenerator(ControlFlowGraph cfg, CfgDotFileForNodeGenerator parentGenerator, int clusterIndex) { - this._clusterIndex = clusterIndex; if (parentGenerator != null) { //List of encountered blocks is inherited from parent _encounteredBlocks = parentGenerator._encounteredBlocks; + //Separate block writer but keep params from parent + _blocksBuffer = new StringWriter(parentGenerator._blocksBuffer.FormatProvider) { NewLine = parentGenerator._blocksBuffer.NewLine }; //In DOT, if an edge belongs to a subgraph, then its target block must be included into that subgraph //To avoid unwanted block inclusions, we write all edges at the root level (main digraph) _edgesBuffer = parentGenerator._edgesBuffer; + this.BlockEmittedEvent = parentGenerator.BlockEmittedEvent; } else { _encounteredBlocks = new HashSet(); - _edgesBuffer = new StringBuilder(); + // Instances are created when generation is requested, using the parameters from target writer + _blocksBuffer = null; + _edgesBuffer = null; } - //The blocks buffer is per instance - _blocksBuffer = new StringBuilder(); - _cfg = cfg; + _clusterIndex = clusterIndex; } /// /// Controls the instruction format in generated dot file. /// - public bool FullInstruction { get; set; } + public bool FullInstruction { get; init; } /// /// Generate the Control Flow Graph in the given TextWriter @@ -111,13 +139,21 @@ public void Generate(TextWriter writer, ControlFlowGraph cfg) /// Output TextWriter public void Report(TextWriter writer, CompilationUnit unit = null) { - //Reset state - _encounteredBlocks.Clear(); - _blocksBuffer.Clear(); - _edgesBuffer.Clear(); + if (_blocksBuffer != null || _edgesBuffer != null) + { + throw new InvalidOperationException("Cannot generate subgraph using arbitrary parent graph generator ! Generate using root graph only !"); + } + + if (_cfg == null) + { + //Nothing to generate + return; + } - //Nothing to generate - if (_cfg == null) return; + //Initialize buffers with target writer parameters and reset encountered blocks + _encounteredBlocks.Clear(); + _blocksBuffer = new StringWriter(writer.FormatProvider) { NewLine = writer.NewLine }; + _edgesBuffer = new StringWriter(writer.FormatProvider) { NewLine = writer.NewLine }; //Write header writer.WriteLine("digraph Cfg {"); @@ -145,12 +181,15 @@ public void Report(TextWriter writer, CompilationUnit unit = null) //Close graph writer.WriteLine("}"); writer.Flush(); + + //Reset writers + _blocksBuffer = null; + _edgesBuffer = null; } private bool EmitBlock(BasicBlock block, int incomingEdge, BasicBlock predecessorBlock, ControlFlowGraph cfg) { - if (_encounteredBlocks.Contains(block.Index)) return false; - _encounteredBlocks.Add(block.Index); + if (!_encounteredBlocks.Add(block.Index)) return false; //Write block to blocks buffer WriteBlock(block); @@ -158,46 +197,42 @@ private bool EmitBlock(BasicBlock block, int incomingEdge, BasicBlock.BasicBlockForNodeGroup group && !group.HasFlag(BasicBlock.Flags.GroupGrafted)) { - StringWriter writer = new StringWriter(); if (group.Group.Count > 0) { //Generate blocks for subgraph using a nested generator - var subgraphGenerator = new CfgDotFileForNodeGenerator(_cfg, this, group.GroupIndex); - subgraphGenerator.FullInstruction = this.FullInstruction; + var subgraphGenerator = new CfgDotFileForNodeGenerator(_cfg, this, group.GroupIndex) { FullInstruction = this.FullInstruction }; BasicBlock first = group.Group.First.Value; _cfg.DFS(first, subgraphGenerator.EmitBlock); string blocks = subgraphGenerator._blocksBuffer.ToString(); - System.Diagnostics.Debug.Assert(blocks != null); + Debug.Assert(blocks != null); if (blocks != string.Empty) { - //Write subgraph - writer.WriteLine("subgraph cluster_" + group.GroupIndex + '{'); - writer.WriteLine("color = blue;"); - writer.WriteLine($"label = \"{((ControlFlowGraphBuilder.BasicBlockForNode) first).Tag}\";"); - writer.WriteLine(blocks); - writer.WriteLine('}'); + //Include subgraph into parent graph + _blocksBuffer.WriteLine("subgraph cluster_" + group.GroupIndex + '{'); + _blocksBuffer.WriteLine("color = blue;"); + _blocksBuffer.WriteLine($"label = \"{((ControlFlowGraphBuilder.BasicBlockForNode) first).Tag}\";"); + _blocksBuffer.WriteLine(blocks); + _blocksBuffer.WriteLine('}'); } //Create dashed link to the group - writer.WriteLine("Block{0} -> Block{1} [style=dashed]", block.Index, first.Index); + _blocksBuffer.WriteLine("Block{0} -> Block{1} [style=dashed]", block.Index, first.Index); } else { //Group is empty, create link to an empty block - writer.WriteLine("Block{0} -> \"\" [style=dashed]", block.Index); + _blocksBuffer.WriteLine("Block{0} -> \"\" [style=dashed]", block.Index); } - writer.Flush(); - //Include subgraph into parent graph - _blocksBuffer.AppendLine(writer.ToString()); + _blocksBuffer.WriteLine(); } //Write edges to edges buffer foreach (var edge in block.SuccessorEdges) { - System.Diagnostics.Debug.Assert(edge >= 0 && edge < _cfg.SuccessorEdges.Count); - _edgesBuffer.AppendLine($"Block{block.Index} -> Block{_cfg.SuccessorEdges[edge].Index}"); + Debug.Assert(edge >= 0 && edge < _cfg.SuccessorEdges.Count); + _edgesBuffer.WriteLine($"Block{block.Index} -> Block{_cfg.SuccessorEdges[edge].Index}"); } if (BlockEmittedEvent != null) BlockEmittedEvent(block, _clusterIndex); @@ -207,21 +242,21 @@ private bool EmitBlock(BasicBlock block, int incomingEdge, BasicBlock block) { //Block title - _blocksBuffer.AppendLine($"Block{block.Index} ["); - _blocksBuffer.Append("label = \"{"); - _blocksBuffer.Append(BlockName(block)); - _blocksBuffer.Append("|"); + _blocksBuffer.WriteLine($"Block{block.Index} ["); + _blocksBuffer.Write("label = \"{"); + _blocksBuffer.Write(BlockName(block)); + _blocksBuffer.Write("|"); //Print all instructions inside the block. foreach (var i in block.Instructions) { - _blocksBuffer.Append(InstructionToString(i)); - _blocksBuffer.Append("\\l"); + _blocksBuffer.Write(InstructionToString(i)); + _blocksBuffer.Write("\\l"); } //Close block - _blocksBuffer.AppendLine("}\""); - _blocksBuffer.AppendLine("]"); + _blocksBuffer.WriteLine("}\""); + _blocksBuffer.WriteLine("]"); } /// @@ -258,7 +293,7 @@ private string InstructionToString(Node instruction) ? "" : FullInstruction ? Escape(instruction.CodeElement.SourceText) - : System.Enum.GetName(typeof(CodeElementType), instruction.CodeElement.Type); + : Enum.GetName(typeof(CodeElementType), instruction.CodeElement.Type); } } } diff --git a/TypeCobol.Analysis/TypeCobol.Analysis.csproj b/TypeCobol.Analysis/TypeCobol.Analysis.csproj index 61e27a796..6d932f13e 100644 --- a/TypeCobol.Analysis/TypeCobol.Analysis.csproj +++ b/TypeCobol.Analysis/TypeCobol.Analysis.csproj @@ -8,10 +8,7 @@ - - - all - + diff --git a/TypeCobol.LanguageServer.Test/LSRTest.cs b/TypeCobol.LanguageServer.Test/LSRTest.cs index 4bc312e28..9de7d0663 100644 --- a/TypeCobol.LanguageServer.Test/LSRTest.cs +++ b/TypeCobol.LanguageServer.Test/LSRTest.cs @@ -433,7 +433,7 @@ public void CompletionUsingCopy() [TestCategory("Completion")] public void ReplacingSyntaxOff() { - LSRTestHelper.Test("replacingSyntaxOff", LsrTestingOptions.NoLsrTesting, true, false, false, "CopyFolder"); + LSRTestHelper.Test("ReplacingSyntaxOff", LsrTestingOptions.NoLsrTesting, true, false, false, "CopyFolder"); } [TestMethod] @@ -558,18 +558,32 @@ public void CopyEditAddDataItem() LSRTestHelper.Test("CopyEditAddDataItem", LsrTestingOptions.NoLsrTesting, true); } + #region Refactoring tests + + /* + * These tests are platform-dependent as the server will generate source code using the NewLine of current OS. + * It is assumed that client and server both use the same line break sequence ! + * + * When creating a new LSR refactoring test, start with Windows and then duplicate the file for its "NoWindows_" + * counterpart and replace the line breaks. + */ + + private static readonly string _OSPrefix = OperatingSystem.IsWindows() ? string.Empty : "NoWindows_"; + [TestMethod] [TestCategory("Refactorings")] public void ExecuteCommandRefactorAdjustFillers() { - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers", LsrTestingOptions.NoLsrTesting); - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_WithCopy", LsrTestingOptions.NoLsrTesting, copyFolder: "CopyFolder"); - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_BadEdits_1", LsrTestingOptions.NoLsrTesting); - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_BadEdits_2", LsrTestingOptions.NoLsrTesting); - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_BadLocation", LsrTestingOptions.NoLsrTesting); - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_WithSequenceNumbers", LsrTestingOptions.NoLsrTesting); - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_NestedRedefines", LsrTestingOptions.NoLsrTesting); - LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_WithOccurs", LsrTestingOptions.NoLsrTesting); + LSRTestHelper.Test($"{_OSPrefix}ExecuteCommandRefactorAdjustFillers", LsrTestingOptions.NoLsrTesting); + LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_WithCopy", LsrTestingOptions.NoLsrTesting, copyFolder: "CopyFolder"); // No newlines involved + LSRTestHelper.Test($"{_OSPrefix}ExecuteCommandRefactorAdjustFillers_BadEdits_1", LsrTestingOptions.NoLsrTesting); + LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_BadEdits_2", LsrTestingOptions.NoLsrTesting); // No newlines involved + LSRTestHelper.Test($"{_OSPrefix}ExecuteCommandRefactorAdjustFillers_BadLocation", LsrTestingOptions.NoLsrTesting); + LSRTestHelper.Test("ExecuteCommandRefactorAdjustFillers_WithSequenceNumbers", LsrTestingOptions.NoLsrTesting); // No newlines involved + LSRTestHelper.Test($"{_OSPrefix}ExecuteCommandRefactorAdjustFillers_NestedRedefines", LsrTestingOptions.NoLsrTesting); + LSRTestHelper.Test($"{_OSPrefix}ExecuteCommandRefactorAdjustFillers_WithOccurs", LsrTestingOptions.NoLsrTesting); } + + #endregion } } diff --git a/TypeCobol.LanguageServer.Test/LSRTestHelper.cs b/TypeCobol.LanguageServer.Test/LSRTestHelper.cs index 43d886b06..8af30e61a 100644 --- a/TypeCobol.LanguageServer.Test/LSRTestHelper.cs +++ b/TypeCobol.LanguageServer.Test/LSRTestHelper.cs @@ -103,6 +103,7 @@ public static void Test(string testFolderName, LsrTestingOptions lsrTestingOptio if (useSyntaxColoring) lsOptions.Add("-sc"); // if true, activate syntax coloring if (useOutline) lsOptions.Add("-ol"); // if true, activate outline if (useCfg) lsOptions.Add("-cfg=AsContent"); // if true, activate cfg as content directly included in messages + lsOptions.Add("-now"); // Disable copy and dependencies watchers //Build full path to default Cpy Copy names file for LSR tests string cpyCopiesFile = Path.GetFullPath(Path.Combine(testWorkingDirectory, "input", "CpyCopies.lst")); diff --git a/TypeCobol.LanguageServer.Test/LSRTests/CfgDataInformation/input/CfgDataInformation.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/CfgDataInformation/input/CfgDataInformation.tlsp index b84c20614..b92f00d66 100644 --- a/TypeCobol.LanguageServer.Test/LSRTests/CfgDataInformation/input/CfgDataInformation.tlsp +++ b/TypeCobol.LanguageServer.Test/LSRTests/CfgDataInformation/input/CfgDataInformation.tlsp @@ -19,7 +19,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"method\":\"typecobol/CfgDfa\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MAYANJE/workspaces/runtime-GEFTest2/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/RE/RE.MAYANJE2.SOURCE/DVZZJCM6.cbl\"},\"dotContent\":\"digraph Cfg {\\r\\ncompound=true;\\r\\nnode [\\r\\nshape = \\\"record\\\"\\r\\n]\\r\\n\\r\\nedge [\\r\\narrowtail = \\\"empty\\\"\\r\\n]\\r\\nBlock0 [\\r\\nlabel = \\\"{START|}\\\"\\r\\n]\\r\\nBlock1 [\\r\\nlabel = \\\"{Block1| PERFORM FctList-Process-Mode\\\\l}\\\"\\r\\n]\\r\\nsubgraph cluster_1{\\r\\ncolor = blue;\\r\\nlabel = \\\"FctList-Process-Mode\\\";\\r\\nBlock11 [\\r\\nlabel = \\\"{FCTLIST-PROCESS-MODE. Block11| evaluate true\\\\l when Fct-f1c0385c-StartCheckpoint\\\\l}\\\"\\r\\n]\\r\\nBlock12 [\\r\\nlabel = \\\"{Block12| call 'f1c0385c' using arg1\\\\l}\\\"\\r\\n]\\r\\nBlock16 [\\r\\nlabel = \\\"{Block16|}\\\"\\r\\n]\\r\\nBlock13 [\\r\\nlabel = \\\"{Block13|}\\\"\\r\\n]\\r\\nBlock14 [\\r\\nlabel = \\\"{Block14| Perform Handle-Error\\\\l}\\\"\\r\\n]\\r\\nsubgraph cluster_2{\\r\\ncolor = blue;\\r\\nlabel = \\\"Handle-Error\\\";\\r\\nBlock18 [\\r\\nlabel = \\\"{HANDLE-ERROR. Block18| continue\\\\l}\\\"\\r\\n]\\r\\n\\r\\n}\\r\\nBlock14 -> Block18 [style=dashed]\\r\\n\\r\\nBlock15 [\\r\\nlabel = \\\"{Block15|}\\\"\\r\\n]\\r\\n\\r\\n}\\r\\nBlock1 -> Block11 [style=dashed]\\r\\n\\r\\nBlock2 [\\r\\nlabel = \\\"{Block2| GOBACK\\\\l}\\\"\\r\\n]\\r\\nBlock0 -> Block1\\r\\nBlock11 -> Block12\\r\\nBlock11 -> Block13\\r\\nBlock12 -> Block16\\r\\nBlock13 -> Block14\\r\\nBlock14 -> Block15\\r\\nBlock15 -> Block16\\r\\nBlock1 -> Block2\\r\\n\\r\\n}\\r\\n\",\"instructionPositions\":[{\"line\":22,\"character\":11},{\"line\":23,\"character\":14},{\"line\":24,\"character\":17},{\"line\":30,\"character\":11},{\"line\":26,\"character\":17},{\"line\":18,\"character\":11},{\"line\":19,\"character\":11}],\"basicBlockInfos\":[{\"id\":0,\"subgraphId\":-1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":11,\"subgraphId\":1,\"fstInstIdx\":0,\"lstInstIdx\":2},{\"id\":12,\"subgraphId\":1,\"fstInstIdx\":2,\"lstInstIdx\":3},{\"id\":16,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":13,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":18,\"subgraphId\":2,\"fstInstIdx\":3,\"lstInstIdx\":4},{\"id\":14,\"subgraphId\":1,\"fstInstIdx\":4,\"lstInstIdx\":5},{\"id\":15,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":1,\"subgraphId\":-1,\"fstInstIdx\":5,\"lstInstIdx\":6},{\"id\":2,\"subgraphId\":-1,\"fstInstIdx\":6,\"lstInstIdx\":7}]}}" + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"typecobol/CfgDfa\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MAYANJE/workspaces/runtime-GEFTest2/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/RE/RE.MAYANJE2.SOURCE/DVZZJCM6.cbl\"},\"dotContent\":\"digraph Cfg { compound=true; node [ shape = \\\"record\\\" ] edge [ arrowtail = \\\"empty\\\" ] Block0 [ label = \\\"{START|}\\\" ] Block1 [ label = \\\"{Block1| PERFORM FctList-Process-Mode\\\\l}\\\" ] subgraph cluster_1{ color = blue; label = \\\"FctList-Process-Mode\\\"; Block11 [ label = \\\"{FCTLIST-PROCESS-MODE. Block11| evaluate true\\\\l when Fct-f1c0385c-StartCheckpoint\\\\l}\\\" ] Block12 [ label = \\\"{Block12| call 'f1c0385c' using arg1\\\\l}\\\" ] Block16 [ label = \\\"{Block16|}\\\" ] Block13 [ label = \\\"{Block13|}\\\" ] Block14 [ label = \\\"{Block14| Perform Handle-Error\\\\l}\\\" ] subgraph cluster_2{ color = blue; label = \\\"Handle-Error\\\"; Block18 [ label = \\\"{HANDLE-ERROR. Block18| continue\\\\l}\\\" ] } Block14 -> Block18 [style=dashed] Block15 [ label = \\\"{Block15|}\\\" ] } Block1 -> Block11 [style=dashed] Block2 [ label = \\\"{Block2| GOBACK\\\\l}\\\" ] Block0 -> Block1 Block11 -> Block12 Block11 -> Block13 Block12 -> Block16 Block13 -> Block14 Block14 -> Block15 Block15 -> Block16 Block1 -> Block2 } \",\"instructionPositions\":[{\"line\":22,\"character\":11},{\"line\":23,\"character\":14},{\"line\":24,\"character\":17},{\"line\":30,\"character\":11},{\"line\":26,\"character\":17},{\"line\":18,\"character\":11},{\"line\":19,\"character\":11}],\"basicBlockInfos\":[{\"id\":0,\"subgraphId\":-1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":11,\"subgraphId\":1,\"fstInstIdx\":0,\"lstInstIdx\":2},{\"id\":12,\"subgraphId\":1,\"fstInstIdx\":2,\"lstInstIdx\":3},{\"id\":16,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":13,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":18,\"subgraphId\":2,\"fstInstIdx\":3,\"lstInstIdx\":4},{\"id\":14,\"subgraphId\":1,\"fstInstIdx\":4,\"lstInstIdx\":5},{\"id\":15,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":1,\"subgraphId\":-1,\"fstInstIdx\":5,\"lstInstIdx\":6},{\"id\":2,\"subgraphId\":-1,\"fstInstIdx\":6,\"lstInstIdx\":7}]}}" }, { "category": 1, @@ -27,7 +27,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"method\":\"typecobol/CfgDfa\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MAYANJE/workspaces/runtime-GEFTest2/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/RE/RE.MAYANJE2.SOURCE/DVZZJCM6.cbl\"},\"dotContent\":\"digraph Cfg {\\r\\ncompound=true;\\r\\nnode [\\r\\nshape = \\\"record\\\"\\r\\n]\\r\\n\\r\\nedge [\\r\\narrowtail = \\\"empty\\\"\\r\\n]\\r\\nBlock0 [\\r\\nlabel = \\\"{START|}\\\"\\r\\n]\\r\\nBlock1 [\\r\\nlabel = \\\"{Block1| PERFORM FctList-Process-Mode\\\\l}\\\"\\r\\n]\\r\\nsubgraph cluster_1{\\r\\ncolor = blue;\\r\\nlabel = \\\"FctList-Process-Mode\\\";\\r\\nBlock11 [\\r\\nlabel = \\\"{FCTLIST-PROCESS-MODE. Block11| evaluate true\\\\l when Fct-f1c0385c-StartCheckpoint\\\\l}\\\"\\r\\n]\\r\\nBlock12 [\\r\\nlabel = \\\"{Block12| call 'f1c0385c' using arg1\\\\l}\\\"\\r\\n]\\r\\nBlock16 [\\r\\nlabel = \\\"{Block16|}\\\"\\r\\n]\\r\\nBlock13 [\\r\\nlabel = \\\"{Block13|}\\\"\\r\\n]\\r\\nBlock14 [\\r\\nlabel = \\\"{Block14| Perform Handle-Error\\\\l}\\\"\\r\\n]\\r\\nsubgraph cluster_2{\\r\\ncolor = blue;\\r\\nlabel = \\\"Handle-Error\\\";\\r\\nBlock18 [\\r\\nlabel = \\\"{HANDLE-ERROR. Block18| continue\\\\l}\\\"\\r\\n]\\r\\n\\r\\n}\\r\\nBlock14 -> Block18 [style=dashed]\\r\\n\\r\\nBlock15 [\\r\\nlabel = \\\"{Block15|}\\\"\\r\\n]\\r\\n\\r\\n}\\r\\nBlock1 -> Block11 [style=dashed]\\r\\n\\r\\nBlock2 [\\r\\nlabel = \\\"{Block2| GOBACK\\\\l}\\\"\\r\\n]\\r\\nBlock0 -> Block1\\r\\nBlock11 -> Block12\\r\\nBlock11 -> Block13\\r\\nBlock12 -> Block16\\r\\nBlock13 -> Block14\\r\\nBlock14 -> Block15\\r\\nBlock15 -> Block16\\r\\nBlock1 -> Block2\\r\\n\\r\\n}\\r\\n\",\"instructionPositions\":[{\"line\":22,\"character\":11},{\"line\":23,\"character\":14},{\"line\":24,\"character\":17},{\"line\":30,\"character\":11},{\"line\":26,\"character\":17},{\"line\":18,\"character\":11},{\"line\":19,\"character\":11}],\"basicBlockInfos\":[{\"id\":0,\"subgraphId\":-1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":11,\"subgraphId\":1,\"fstInstIdx\":0,\"lstInstIdx\":2},{\"id\":12,\"subgraphId\":1,\"fstInstIdx\":2,\"lstInstIdx\":3},{\"id\":16,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":13,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":18,\"subgraphId\":2,\"fstInstIdx\":3,\"lstInstIdx\":4},{\"id\":14,\"subgraphId\":1,\"fstInstIdx\":4,\"lstInstIdx\":5},{\"id\":15,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":1,\"subgraphId\":-1,\"fstInstIdx\":5,\"lstInstIdx\":6},{\"id\":2,\"subgraphId\":-1,\"fstInstIdx\":6,\"lstInstIdx\":7}]}}" + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"typecobol/CfgDfa\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MAYANJE/workspaces/runtime-GEFTest2/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/RE/RE.MAYANJE2.SOURCE/DVZZJCM6.cbl\"},\"dotContent\":\"digraph Cfg { compound=true; node [ shape = \\\"record\\\" ] edge [ arrowtail = \\\"empty\\\" ] Block0 [ label = \\\"{START|}\\\" ] Block1 [ label = \\\"{Block1| PERFORM FctList-Process-Mode\\\\l}\\\" ] subgraph cluster_1{ color = blue; label = \\\"FctList-Process-Mode\\\"; Block11 [ label = \\\"{FCTLIST-PROCESS-MODE. Block11| evaluate true\\\\l when Fct-f1c0385c-StartCheckpoint\\\\l}\\\" ] Block12 [ label = \\\"{Block12| call 'f1c0385c' using arg1\\\\l}\\\" ] Block16 [ label = \\\"{Block16|}\\\" ] Block13 [ label = \\\"{Block13|}\\\" ] Block14 [ label = \\\"{Block14| Perform Handle-Error\\\\l}\\\" ] subgraph cluster_2{ color = blue; label = \\\"Handle-Error\\\"; Block18 [ label = \\\"{HANDLE-ERROR. Block18| continue\\\\l}\\\" ] } Block14 -> Block18 [style=dashed] Block15 [ label = \\\"{Block15|}\\\" ] } Block1 -> Block11 [style=dashed] Block2 [ label = \\\"{Block2| GOBACK\\\\l}\\\" ] Block0 -> Block1 Block11 -> Block12 Block11 -> Block13 Block12 -> Block16 Block13 -> Block14 Block14 -> Block15 Block15 -> Block16 Block1 -> Block2 } \",\"instructionPositions\":[{\"line\":22,\"character\":11},{\"line\":23,\"character\":14},{\"line\":24,\"character\":17},{\"line\":30,\"character\":11},{\"line\":26,\"character\":17},{\"line\":18,\"character\":11},{\"line\":19,\"character\":11}],\"basicBlockInfos\":[{\"id\":0,\"subgraphId\":-1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":11,\"subgraphId\":1,\"fstInstIdx\":0,\"lstInstIdx\":2},{\"id\":12,\"subgraphId\":1,\"fstInstIdx\":2,\"lstInstIdx\":3},{\"id\":16,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":13,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":18,\"subgraphId\":2,\"fstInstIdx\":3,\"lstInstIdx\":4},{\"id\":14,\"subgraphId\":1,\"fstInstIdx\":4,\"lstInstIdx\":5},{\"id\":15,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":1,\"subgraphId\":-1,\"fstInstIdx\":5,\"lstInstIdx\":6},{\"id\":2,\"subgraphId\":-1,\"fstInstIdx\":6,\"lstInstIdx\":7}]}}" }, { "category": 0, @@ -43,7 +43,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"method\":\"typecobol/CfgDfa\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MAYANJE/workspaces/runtime-GEFTest2/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/RE/RE.MAYANJE2.SOURCE/DVZZJCM6.cbl\"},\"dotContent\":\"digraph Cfg {\\r\\ncompound=true;\\r\\nnode [\\r\\nshape = \\\"record\\\"\\r\\n]\\r\\n\\r\\nedge [\\r\\narrowtail = \\\"empty\\\"\\r\\n]\\r\\nBlock0 [\\r\\nlabel = \\\"{START|}\\\"\\r\\n]\\r\\nBlock1 [\\r\\nlabel = \\\"{Block1| PERFORM FctList-Process-Mode\\\\l}\\\"\\r\\n]\\r\\nsubgraph cluster_1{\\r\\ncolor = blue;\\r\\nlabel = \\\"FctList-Process-Mode\\\";\\r\\nBlock11 [\\r\\nlabel = \\\"{FCTLIST-PROCESS-MODE. Block11| evaluate true\\\\l when Fct-f1c0385c-StartCheckpoint\\\\l}\\\"\\r\\n]\\r\\nBlock12 [\\r\\nlabel = \\\"{Block12| call 'f1c0385c' using arg1\\\\l}\\\"\\r\\n]\\r\\nBlock16 [\\r\\nlabel = \\\"{Block16|}\\\"\\r\\n]\\r\\nBlock13 [\\r\\nlabel = \\\"{Block13|}\\\"\\r\\n]\\r\\nBlock14 [\\r\\nlabel = \\\"{Block14| Perform Handle-Error\\\\l}\\\"\\r\\n]\\r\\nsubgraph cluster_2{\\r\\ncolor = blue;\\r\\nlabel = \\\"Handle-Error\\\";\\r\\nBlock18 [\\r\\nlabel = \\\"{HANDLE-ERROR. Block18| continue\\\\l}\\\"\\r\\n]\\r\\n\\r\\n}\\r\\nBlock14 -> Block18 [style=dashed]\\r\\n\\r\\nBlock15 [\\r\\nlabel = \\\"{Block15|}\\\"\\r\\n]\\r\\n\\r\\n}\\r\\nBlock1 -> Block11 [style=dashed]\\r\\n\\r\\nBlock2 [\\r\\nlabel = \\\"{Block2| GOBACK\\\\l}\\\"\\r\\n]\\r\\nBlock0 -> Block1\\r\\nBlock11 -> Block12\\r\\nBlock11 -> Block13\\r\\nBlock12 -> Block16\\r\\nBlock13 -> Block14\\r\\nBlock14 -> Block15\\r\\nBlock15 -> Block16\\r\\nBlock1 -> Block2\\r\\n\\r\\n}\\r\\n\",\"instructionPositions\":[{\"line\":23,\"character\":11},{\"line\":24,\"character\":14},{\"line\":25,\"character\":17},{\"line\":31,\"character\":11},{\"line\":27,\"character\":17},{\"line\":19,\"character\":11},{\"line\":20,\"character\":11}],\"basicBlockInfos\":[{\"id\":0,\"subgraphId\":-1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":11,\"subgraphId\":1,\"fstInstIdx\":0,\"lstInstIdx\":2},{\"id\":12,\"subgraphId\":1,\"fstInstIdx\":2,\"lstInstIdx\":3},{\"id\":16,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":13,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":18,\"subgraphId\":2,\"fstInstIdx\":3,\"lstInstIdx\":4},{\"id\":14,\"subgraphId\":1,\"fstInstIdx\":4,\"lstInstIdx\":5},{\"id\":15,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":1,\"subgraphId\":-1,\"fstInstIdx\":5,\"lstInstIdx\":6},{\"id\":2,\"subgraphId\":-1,\"fstInstIdx\":6,\"lstInstIdx\":7}]}}" + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"typecobol/CfgDfa\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MAYANJE/workspaces/runtime-GEFTest2/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/RE/RE.MAYANJE2.SOURCE/DVZZJCM6.cbl\"},\"dotContent\":\"digraph Cfg { compound=true; node [ shape = \\\"record\\\" ] edge [ arrowtail = \\\"empty\\\" ] Block0 [ label = \\\"{START|}\\\" ] Block1 [ label = \\\"{Block1| PERFORM FctList-Process-Mode\\\\l}\\\" ] subgraph cluster_1{ color = blue; label = \\\"FctList-Process-Mode\\\"; Block11 [ label = \\\"{FCTLIST-PROCESS-MODE. Block11| evaluate true\\\\l when Fct-f1c0385c-StartCheckpoint\\\\l}\\\" ] Block12 [ label = \\\"{Block12| call 'f1c0385c' using arg1\\\\l}\\\" ] Block16 [ label = \\\"{Block16|}\\\" ] Block13 [ label = \\\"{Block13|}\\\" ] Block14 [ label = \\\"{Block14| Perform Handle-Error\\\\l}\\\" ] subgraph cluster_2{ color = blue; label = \\\"Handle-Error\\\"; Block18 [ label = \\\"{HANDLE-ERROR. Block18| continue\\\\l}\\\" ] } Block14 -> Block18 [style=dashed] Block15 [ label = \\\"{Block15|}\\\" ] } Block1 -> Block11 [style=dashed] Block2 [ label = \\\"{Block2| GOBACK\\\\l}\\\" ] Block0 -> Block1 Block11 -> Block12 Block11 -> Block13 Block12 -> Block16 Block13 -> Block14 Block14 -> Block15 Block15 -> Block16 Block1 -> Block2 } \",\"instructionPositions\":[{\"line\":23,\"character\":11},{\"line\":24,\"character\":14},{\"line\":25,\"character\":17},{\"line\":31,\"character\":11},{\"line\":27,\"character\":17},{\"line\":19,\"character\":11},{\"line\":20,\"character\":11}],\"basicBlockInfos\":[{\"id\":0,\"subgraphId\":-1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":11,\"subgraphId\":1,\"fstInstIdx\":0,\"lstInstIdx\":2},{\"id\":12,\"subgraphId\":1,\"fstInstIdx\":2,\"lstInstIdx\":3},{\"id\":16,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":13,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":18,\"subgraphId\":2,\"fstInstIdx\":3,\"lstInstIdx\":4},{\"id\":14,\"subgraphId\":1,\"fstInstIdx\":4,\"lstInstIdx\":5},{\"id\":15,\"subgraphId\":1,\"fstInstIdx\":-1,\"lstInstIdx\":-1},{\"id\":1,\"subgraphId\":-1,\"fstInstIdx\":5,\"lstInstIdx\":6},{\"id\":2,\"subgraphId\":-1,\"fstInstIdx\":6,\"lstInstIdx\":7}]}}" }, { "category": 1, diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers/input/ExecuteCommandRefactorAdjustFillers.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers/input/ExecuteCommandRefactorAdjustFillers.tlsp new file mode 100644 index 000000000..7651e2201 --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers/input/ExecuteCommandRefactorAdjustFillers.tlsp @@ -0,0 +1,43 @@ +{ + "name": "ExecuteCommandRefactorAdjustFillers.tlsp", + "session": "C:\\Users\\GDLRUSER\\AppData\\Roaming\\TypeCobol.LanguageServerRobot\\Repository\\Session2023_09_07_10_40_16_316\\TestSuite_2023_09_07_10_40_16_316.slsp", + "user": "GDLRUSER", + "date": "2023/09/07 10:40:16 340", + "uri": "file:///C:/Users/GDLRUSER/Documents/TCOB/ExecuteCommandRefactorAdjustFillers.tlsp", + "initialize": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"initialize\",\"params\":{\"processId\":-1,\"rootPath\":\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\",\"rootUri\":\"file:/C:/Users/GDLRUSER/Documents/RepoGit/TCOB/Parser/bin/LS/EI_Debug/\",\"capabilities\":{\"workspace\":{\"applyEdit\":true,\"didChangeConfiguration\":{\"dynamicRegistration\":true},\"didChangeWatchedFiles\":{\"dynamicRegistration\":false},\"symbol\":{\"dynamicRegistration\":true},\"executeCommand\":{\"dynamicRegistration\":true}},\"textDocument\":{\"synchronization\":{\"willSave\":true,\"willSaveWaitUntil\":true,\"didSave\":true,\"dynamicRegistration\":true},\"completion\":{\"completionItem\":{\"snippetSupport\":true},\"dynamicRegistration\":true},\"hover\":{\"dynamicRegistration\":true},\"definition\":{\"dynamicRegistration\":true}}},\"trace\":\"off\"}}", + "initialize_result": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"result\":{\"capabilities\":{\"experimental\":[{\"Item1\":\"version\",\"Item2\":\"0.0.0-local\"}],\"textDocumentSync\":2,\"hoverProvider\":true,\"completionProvider\":{\"resolveProvider\":false,\"triggerCharacters\":[\"::\"]},\"signatureHelpProvider\":{\"triggerCharacters\":[]},\"definitionProvider\":true,\"referencesProvider\":false,\"documentHighlightProvider\":false,\"documentSymbolProvider\":false,\"workspaceSymbolProvider\":false,\"codeActionProvider\":false,\"documentFormattingProvider\":false,\"documentRangeFormattingProvider\":false,\"renameProvider\":false}}}", + "did_change_configuation": "{\"jsonrpc\":\"2.0\",\"method\":\"workspace/didChangeConfiguration\",\"params\":{\"settings\":[\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\\\\TypeCobol.CLI.exe\",\"-e\",\"rdz\",\"{-c}\",\"--autoremarks\",\"-cob\",\"-dol\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production_suffixedCPY\",\"-dcsm\"]}}", + "didOpen": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"languageId\":\"__lsp4j_Cobol\",\"version\":0,\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 target-zone PIC X(200).\\n 01 redef1 REDEFINES target-zone.\\n 05 var1 PIC X(100).\\n * Adjust FILLER size here (20 -> 100)\\n 05 FILLER PIC X(20).\\n 01 redef2 REDEFINES target-zone.\\n 05 var2 PIC X(125).\\n * Add here new FILLER, length 75\\n 01 redef3 REDEFINES target-zone.\\n 05 var3 PIC X(200).\\n * Remove this FILLER entirely\\n 05 FILLER PIC X(25).\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}}", + "messages": [ + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didSave\",\"params\":{\"textDocument\":{\"version\":0,\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"},\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 target-zone PIC X(200).\\n 01 redef1 REDEFINES target-zone.\\n 05 var1 PIC X(100).\\n * Adjust FILLER size here (20 -> 100)\\n 05 FILLER PIC X(20).\\n 01 redef2 REDEFINES target-zone.\\n 05 var2 PIC X(125).\\n * Add here new FILLER, length 75\\n 01 redef3 REDEFINES target-zone.\\n 05 var3 PIC X(200).\\n * Remove this FILLER entirely\\n 05 FILLER PIC X(25).\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/executeCommand\",\"params\":{\"command\":\"refactor/adjustFillers\",\"arguments\":[{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/applyEdit\",\"params\":{\"label\":\"Adjust FILLERs: 3 FILLER(s) modified\",\"edit\":{\"changes\":{\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\":[{\"range\":{\"start\":{\"line\":9,\"character\":24},\"end\":{\"line\":9,\"character\":30}},\"newText\":\"X(100).\"},{\"range\":{\"start\":{\"line\":11,\"character\":29},\"end\":{\"line\":11,\"character\":29}},\"newText\":\"\\n 05 FILLER PIC X(75).\"},{\"range\":{\"start\":{\"line\":16,\"character\":10},\"end\":{\"line\":16,\"character\":30}},\"newText\":\" \"}]}}}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"applied\":true}}" + } + ], + "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}}}", + "IsValid": true +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers/output_expected/ExecuteCommandRefactorAdjustFillers.rlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers/output_expected/ExecuteCommandRefactorAdjustFillers.rlsp new file mode 100644 index 000000000..3622a50ee --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers/output_expected/ExecuteCommandRefactorAdjustFillers.rlsp @@ -0,0 +1,6 @@ +{ + "success": true, + "diff_index": [ + -1 + ] +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadEdits_1/input/ExecuteCommandRefactorAdjustFillers_BadEdits_1.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadEdits_1/input/ExecuteCommandRefactorAdjustFillers_BadEdits_1.tlsp new file mode 100644 index 000000000..ac7aed6f6 --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadEdits_1/input/ExecuteCommandRefactorAdjustFillers_BadEdits_1.tlsp @@ -0,0 +1,43 @@ +{ + "name": "ExecuteCommandRefactorAdjustFillers_BadEdits_1.tlsp", + "session": "C:\\Users\\GDLRUSER\\AppData\\Roaming\\TypeCobol.LanguageServerRobot\\Repository\\Session2023_09_07_10_40_16_316\\TestSuite_2023_09_07_10_40_16_316.slsp", + "user": "GDLRUSER", + "date": "2023/09/07 10:40:16 340", + "uri": "file:///C:/Users/GDLRUSER/Documents/TCOB/ExecuteCommandRefactorAdjustFillers_BadEdits_1.tlsp", + "initialize": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"initialize\",\"params\":{\"processId\":-1,\"rootPath\":\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\",\"rootUri\":\"file:/C:/Users/GDLRUSER/Documents/RepoGit/TCOB/Parser/bin/LS/EI_Debug/\",\"capabilities\":{\"workspace\":{\"applyEdit\":true,\"didChangeConfiguration\":{\"dynamicRegistration\":true},\"didChangeWatchedFiles\":{\"dynamicRegistration\":false},\"symbol\":{\"dynamicRegistration\":true},\"executeCommand\":{\"dynamicRegistration\":true}},\"textDocument\":{\"synchronization\":{\"willSave\":true,\"willSaveWaitUntil\":true,\"didSave\":true,\"dynamicRegistration\":true},\"completion\":{\"completionItem\":{\"snippetSupport\":true},\"dynamicRegistration\":true},\"hover\":{\"dynamicRegistration\":true},\"definition\":{\"dynamicRegistration\":true}}},\"trace\":\"off\"}}", + "initialize_result": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"result\":{\"capabilities\":{\"experimental\":[{\"Item1\":\"version\",\"Item2\":\"0.0.0-local\"}],\"textDocumentSync\":2,\"hoverProvider\":true,\"completionProvider\":{\"resolveProvider\":false,\"triggerCharacters\":[\"::\"]},\"signatureHelpProvider\":{\"triggerCharacters\":[]},\"definitionProvider\":true,\"referencesProvider\":false,\"documentHighlightProvider\":false,\"documentSymbolProvider\":false,\"workspaceSymbolProvider\":false,\"codeActionProvider\":false,\"documentFormattingProvider\":false,\"documentRangeFormattingProvider\":false,\"renameProvider\":false}}}", + "did_change_configuation": "{\"jsonrpc\":\"2.0\",\"method\":\"workspace/didChangeConfiguration\",\"params\":{\"settings\":[\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\\\\TypeCobol.CLI.exe\",\"-e\",\"rdz\",\"{-c}\",\"--autoremarks\",\"-cob\",\"-dol\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production_suffixedCPY\",\"-dcsm\"]}}", + "didOpen": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"languageId\":\"__lsp4j_Cobol\",\"version\":0,\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 target-zone PIC X(200).\\n * Adding a FILLER should not break the format !\\n 01 redef1 REDEFINES target-zone.\\n 05 var1 PIC X(100). 01234567\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}}", + "messages": [ + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didSave\",\"params\":{\"textDocument\":{\"version\":0,\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"},\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 target-zone PIC X(200).\\n * Adding a FILLER should not break the format !\\n 01 redef1 REDEFINES target-zone.\\n 05 var1 PIC X(100). 01234567\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/executeCommand\",\"params\":{\"command\":\"refactor/adjustFillers\",\"arguments\":[{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/applyEdit\",\"params\":{\"label\":\"Adjust FILLERs: 1 FILLER(s) modified\",\"edit\":{\"changes\":{\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\":[{\"range\":{\"start\":{\"line\":8,\"character\":80},\"end\":{\"line\":8,\"character\":80}},\"newText\":\"\\n 05 FILLER PIC X(100).\"}]}}}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"applied\":true}}" + } + ], + "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}}}", + "IsValid": true +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadEdits_1/output_expected/ExecuteCommandRefactorAdjustFillers_BadEdits_1.rlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadEdits_1/output_expected/ExecuteCommandRefactorAdjustFillers_BadEdits_1.rlsp new file mode 100644 index 000000000..3622a50ee --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadEdits_1/output_expected/ExecuteCommandRefactorAdjustFillers_BadEdits_1.rlsp @@ -0,0 +1,6 @@ +{ + "success": true, + "diff_index": [ + -1 + ] +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadLocation/input/ExecuteCommandRefactorAdjustFillers_BadLocation.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadLocation/input/ExecuteCommandRefactorAdjustFillers_BadLocation.tlsp new file mode 100644 index 000000000..f539542cd --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadLocation/input/ExecuteCommandRefactorAdjustFillers_BadLocation.tlsp @@ -0,0 +1,43 @@ +{ + "name": "ExecuteCommandRefactorAdjustFillers_BadLocation.tlsp", + "session": "C:\\Users\\GDLRUSER\\AppData\\Roaming\\TypeCobol.LanguageServerRobot\\Repository\\Session2023_09_07_10_40_16_316\\TestSuite_2023_09_07_10_40_16_316.slsp", + "user": "GDLRUSER", + "date": "2023/09/07 10:40:16 340", + "uri": "file:///C:/Users/GDLRUSER/Documents/TCOB/ExecuteCommandRefactorAdjustFillers_BadLocation.tlsp", + "initialize": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"initialize\",\"params\":{\"processId\":-1,\"rootPath\":\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\",\"rootUri\":\"file:/C:/Users/GDLRUSER/Documents/RepoGit/TCOB/Parser/bin/LS/EI_Debug/\",\"capabilities\":{\"workspace\":{\"applyEdit\":true,\"didChangeConfiguration\":{\"dynamicRegistration\":true},\"didChangeWatchedFiles\":{\"dynamicRegistration\":false},\"symbol\":{\"dynamicRegistration\":true},\"executeCommand\":{\"dynamicRegistration\":true}},\"textDocument\":{\"synchronization\":{\"willSave\":true,\"willSaveWaitUntil\":true,\"didSave\":true,\"dynamicRegistration\":true},\"completion\":{\"completionItem\":{\"snippetSupport\":true},\"dynamicRegistration\":true},\"hover\":{\"dynamicRegistration\":true},\"definition\":{\"dynamicRegistration\":true}}},\"trace\":\"off\"}}", + "initialize_result": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"result\":{\"capabilities\":{\"experimental\":[{\"Item1\":\"version\",\"Item2\":\"0.0.0-local\"}],\"textDocumentSync\":2,\"hoverProvider\":true,\"completionProvider\":{\"resolveProvider\":false,\"triggerCharacters\":[\"::\"]},\"signatureHelpProvider\":{\"triggerCharacters\":[]},\"definitionProvider\":true,\"referencesProvider\":false,\"documentHighlightProvider\":false,\"documentSymbolProvider\":false,\"workspaceSymbolProvider\":false,\"codeActionProvider\":false,\"documentFormattingProvider\":false,\"documentRangeFormattingProvider\":false,\"renameProvider\":false}}}", + "did_change_configuation": "{\"jsonrpc\":\"2.0\",\"method\":\"workspace/didChangeConfiguration\",\"params\":{\"settings\":[\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\\\\TypeCobol.CLI.exe\",\"-e\",\"rdz\",\"{-c}\",\"--autoremarks\",\"-cob\",\"-dol\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production_suffixedCPY\",\"-dcsm\"]}}", + "didOpen": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZADJ1.cbl\",\"languageId\":\"__lsp4j_Cobol\",\"version\":0,\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOZADJ1.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 group0.\\n 05 target-zone PIC X(1000).\\n 05 redef1 REDEFINES target-zone.\\n 10 group1.\\n 15 group11.\\n 20 group111.\\n 25 var1 PIC X(500).\\n * Insert here a FILLER with size 500\\n 05 redef2 REDEFINES target-zone.\\n 10 group2.\\n 15 group22.\\n 20 group222.\\n 25 var2 PIC X(25) OCCURS 10 INDEXED BY idx2.\\n * Insert here a FILLER with size 750\\n 05 redef3 REDEFINES target-zone PIC X OCCURS 100 INDEXED idx3.\\n * No crash\\n\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOZADJ1.\"}}}", + "messages": [ + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didSave\",\"params\":{\"textDocument\":{\"version\":0,\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZADJ1.cbl\"},\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOZADJ1.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 group0.\\n 05 target-zone PIC X(1000).\\n 05 redef1 REDEFINES target-zone.\\n 10 group1.\\n 15 group11.\\n 20 group111.\\n 25 var1 PIC X(500).\\n * Insert here a FILLER with size 500\\n 05 redef2 REDEFINES target-zone.\\n 10 group2.\\n 15 group22.\\n 20 group222.\\n 25 var2 PIC X(25) OCCURS 10 INDEXED BY idx2.\\n * Insert here a FILLER with size 750\\n 05 redef3 REDEFINES target-zone PIC X OCCURS 100 INDEXED idx3.\\n * No crash\\n\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOZADJ1.\"}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZADJ1.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZADJ1.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/executeCommand\",\"params\":{\"command\":\"refactor/adjustFillers\",\"arguments\":[{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZADJ1.cbl\"}]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/applyEdit\",\"params\":{\"label\":\"Adjust FILLERs: 2 FILLER(s) modified\",\"edit\":{\"changes\":{\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZADJ1.cbl\":[{\"range\":{\"start\":{\"line\":11,\"character\":41},\"end\":{\"line\":11,\"character\":41}},\"newText\":\"\\n 10 FILLER PIC X(500).\"},{\"range\":{\"start\":{\"line\":17,\"character\":66},\"end\":{\"line\":17,\"character\":66}},\"newText\":\"\\n 10 FILLER PIC X(750).\"}]}}}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"applied\":true}}" + } + ], + "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZADJ1.cbl\"}}}", + "IsValid": true +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadLocation/output_expected/ExecuteCommandRefactorAdjustFillers_BadLocation.rlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadLocation/output_expected/ExecuteCommandRefactorAdjustFillers_BadLocation.rlsp new file mode 100644 index 000000000..3622a50ee --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_BadLocation/output_expected/ExecuteCommandRefactorAdjustFillers_BadLocation.rlsp @@ -0,0 +1,6 @@ +{ + "success": true, + "diff_index": [ + -1 + ] +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_NestedRedefines/input/ExecuteCommandRefactorAdjustFillers_NestedRedefines.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_NestedRedefines/input/ExecuteCommandRefactorAdjustFillers_NestedRedefines.tlsp new file mode 100644 index 000000000..10689386e --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_NestedRedefines/input/ExecuteCommandRefactorAdjustFillers_NestedRedefines.tlsp @@ -0,0 +1,43 @@ +{ + "name": "ExecuteCommandRefactorAdjustFillers_NestedRedefines.tlsp", + "session": "C:\\Users\\GDLRUSER\\AppData\\Roaming\\TypeCobol.LanguageServerRobot\\Repository\\Session2023_09_07_10_40_16_316\\TestSuite_2023_09_07_10_40_16_316.slsp", + "user": "GDLRUSER", + "date": "2023/09/07 10:40:16 340", + "uri": "file:///C:/Users/GDLRUSER/Documents/TCOB/ExecuteCommandRefactorAdjustFillers_NestedRedefines.tlsp", + "initialize": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"initialize\",\"params\":{\"processId\":-1,\"rootPath\":\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\",\"rootUri\":\"file:/C:/Users/GDLRUSER/Documents/RepoGit/TCOB/Parser/bin/LS/EI_Debug/\",\"capabilities\":{\"workspace\":{\"applyEdit\":true,\"didChangeConfiguration\":{\"dynamicRegistration\":true},\"didChangeWatchedFiles\":{\"dynamicRegistration\":false},\"symbol\":{\"dynamicRegistration\":true},\"executeCommand\":{\"dynamicRegistration\":true}},\"textDocument\":{\"synchronization\":{\"willSave\":true,\"willSaveWaitUntil\":true,\"didSave\":true,\"dynamicRegistration\":true},\"completion\":{\"completionItem\":{\"snippetSupport\":true},\"dynamicRegistration\":true},\"hover\":{\"dynamicRegistration\":true},\"definition\":{\"dynamicRegistration\":true}}},\"trace\":\"off\"}}", + "initialize_result": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"result\":{\"capabilities\":{\"experimental\":[{\"Item1\":\"version\",\"Item2\":\"0.0.0-local\"}],\"textDocumentSync\":2,\"hoverProvider\":true,\"completionProvider\":{\"resolveProvider\":false,\"triggerCharacters\":[\"::\"]},\"signatureHelpProvider\":{\"triggerCharacters\":[]},\"definitionProvider\":true,\"referencesProvider\":false,\"documentHighlightProvider\":false,\"documentSymbolProvider\":false,\"workspaceSymbolProvider\":false,\"codeActionProvider\":false,\"documentFormattingProvider\":false,\"documentRangeFormattingProvider\":false,\"renameProvider\":false}}}", + "did_change_configuation": "{\"jsonrpc\":\"2.0\",\"method\":\"workspace/didChangeConfiguration\",\"params\":{\"settings\":[\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\\\\TypeCobol.CLI.exe\",\"-e\",\"rdz\",\"{-c}\",\"--autoremarks\",\"-cob\",\"-dol\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production_suffixedCPY\",\"-dcsm\"]}}", + "didOpen": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"languageId\":\"__lsp4j_Cobol\",\"version\":0,\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 group1.\\n 05 zone1 PIC X(1000).\\n 05 redef1 REDEFINES zone1.\\n 10 zone2 PIC X(500).\\n 10 nested-redef1 REDEFINES zone2.\\n 15 zone3 PIC X(250).\\n 15 nested-nested-redef1 REDEFINES zone3.\\n 20 zone4 PIC X(125).\\n * Add: 20 FILLER PIC X(125).\\n 15 nested-nested-redef2 REDEFINES zone3.\\n 20 zone5 PIC X(125).\\n * Add: 20 FILLER PIC X(125).\\n * Add: 15 FILLER PIC X(250).\\n * Add: 10 FILLER PIC X(500).\\n 05 redef2 REDEFINES zone1.\\n 10 zone6 PIC X(500).\\n * Add: 10 FILLER PIC X(500).\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}}", + "messages": [ + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didSave\",\"params\":{\"textDocument\":{\"version\":0,\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"},\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 group1.\\n 05 zone1 PIC X(1000).\\n 05 redef1 REDEFINES zone1.\\n 10 zone2 PIC X(500).\\n 10 nested-redef1 REDEFINES zone2.\\n 15 zone3 PIC X(250).\\n 15 nested-nested-redef1 REDEFINES zone3.\\n 20 zone4 PIC X(125).\\n * Add: 20 FILLER PIC X(125).\\n 15 nested-nested-redef2 REDEFINES zone3.\\n 20 zone5 PIC X(125).\\n * Add: 20 FILLER PIC X(125).\\n * Add: 15 FILLER PIC X(250).\\n * Add: 10 FILLER PIC X(500).\\n 05 redef2 REDEFINES zone1.\\n 10 zone6 PIC X(500).\\n * Add: 10 FILLER PIC X(500).\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/executeCommand\",\"params\":{\"command\":\"refactor/adjustFillers\",\"arguments\":[{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/applyEdit\",\"params\":{\"label\":\"Adjust FILLERs: 5 FILLER(s) modified\",\"edit\":{\"changes\":{\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\":[{\"range\":{\"start\":{\"line\":12,\"character\":40},\"end\":{\"line\":12,\"character\":40}},\"newText\":\"\\n 20 FILLER PIC X(125).\"},{\"range\":{\"start\":{\"line\":15,\"character\":40},\"end\":{\"line\":15,\"character\":40}},\"newText\":\"\\n 20 FILLER PIC X(125).\"},{\"range\":{\"start\":{\"line\":15,\"character\":40},\"end\":{\"line\":15,\"character\":40}},\"newText\":\"\\n 15 FILLER PIC X(250).\"},{\"range\":{\"start\":{\"line\":15,\"character\":40},\"end\":{\"line\":15,\"character\":40}},\"newText\":\"\\n 10 FILLER PIC X(500).\"},{\"range\":{\"start\":{\"line\":20,\"character\":33},\"end\":{\"line\":20,\"character\":33}},\"newText\":\"\\n 10 FILLER PIC X(500).\"}]}}}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"applied\":true}}" + } + ], + "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}}}", + "IsValid": true +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_NestedRedefines/output_expected/ExecuteCommandRefactorAdjustFillers_NestedRedefines.rlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_NestedRedefines/output_expected/ExecuteCommandRefactorAdjustFillers_NestedRedefines.rlsp new file mode 100644 index 000000000..3622a50ee --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_NestedRedefines/output_expected/ExecuteCommandRefactorAdjustFillers_NestedRedefines.rlsp @@ -0,0 +1,6 @@ +{ + "success": true, + "diff_index": [ + -1 + ] +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_WithOccurs/input/ExecuteCommandRefactorAdjustFillers_WithOccurs.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_WithOccurs/input/ExecuteCommandRefactorAdjustFillers_WithOccurs.tlsp new file mode 100644 index 000000000..8ced2a015 --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_WithOccurs/input/ExecuteCommandRefactorAdjustFillers_WithOccurs.tlsp @@ -0,0 +1,43 @@ +{ + "name": "ExecuteCommandRefactorAdjustFillers_WithOccurs.tlsp", + "session": "C:\\Users\\GDLRUSER\\AppData\\Roaming\\TypeCobol.LanguageServerRobot\\Repository\\Session2023_09_07_10_40_16_316\\TestSuite_2023_09_07_10_40_16_316.slsp", + "user": "GDLRUSER", + "date": "2023/09/07 10:40:16 340", + "uri": "file:///C:/Users/GDLRUSER/Documents/TCOB/ExecuteCommandRefactorAdjustFillers_WithOccurs.tlsp", + "initialize": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"initialize\",\"params\":{\"processId\":-1,\"rootPath\":\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\",\"rootUri\":\"file:/C:/Users/GDLRUSER/Documents/RepoGit/TCOB/Parser/bin/LS/EI_Debug/\",\"capabilities\":{\"workspace\":{\"applyEdit\":true,\"didChangeConfiguration\":{\"dynamicRegistration\":true},\"didChangeWatchedFiles\":{\"dynamicRegistration\":false},\"symbol\":{\"dynamicRegistration\":true},\"executeCommand\":{\"dynamicRegistration\":true}},\"textDocument\":{\"synchronization\":{\"willSave\":true,\"willSaveWaitUntil\":true,\"didSave\":true,\"dynamicRegistration\":true},\"completion\":{\"completionItem\":{\"snippetSupport\":true},\"dynamicRegistration\":true},\"hover\":{\"dynamicRegistration\":true},\"definition\":{\"dynamicRegistration\":true}}},\"trace\":\"off\"}}", + "initialize_result": "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"result\":{\"capabilities\":{\"experimental\":[{\"Item1\":\"version\",\"Item2\":\"0.0.0-local\"}],\"textDocumentSync\":2,\"hoverProvider\":true,\"completionProvider\":{\"resolveProvider\":false,\"triggerCharacters\":[\"::\"]},\"signatureHelpProvider\":{\"triggerCharacters\":[]},\"definitionProvider\":true,\"referencesProvider\":false,\"documentHighlightProvider\":false,\"documentSymbolProvider\":false,\"workspaceSymbolProvider\":false,\"codeActionProvider\":false,\"documentFormattingProvider\":false,\"documentRangeFormattingProvider\":false,\"renameProvider\":false}}}", + "did_change_configuation": "{\"jsonrpc\":\"2.0\",\"method\":\"workspace/didChangeConfiguration\",\"params\":{\"settings\":[\"C:\\\\Users\\\\GDLRUSER\\\\Documents\\\\RepoGit\\\\TCOB\\\\Parser\\\\bin\\\\LS\\\\EI_Debug\\\\TypeCobol.CLI.exe\",\"-e\",\"rdz\",\"{-c}\",\"--autoremarks\",\"-cob\",\"-dol\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Test_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UATL_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\UAT_suffixedCPY\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production\",\"-c\",\"C:\\\\Users\\\\GDLRUSER\\\\AppData\\\\Local\\\\Euro-Information\\\\TCOB\\\\CobolEditorEI\\\\Copys\\\\Production_suffixedCPY\",\"-dcsm\"]}}", + "didOpen": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"languageId\":\"__lsp4j_Cobol\",\"version\":0,\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 group1.\\n 05 target-zone PIC X(1000).\\n 05 redef1 REDEFINES target-zone OCCURS 10.\\n 10 var1 PIC X(20).\\n * Add: 10 FILLER PIC X(80).\\n 05 redef2 REDEFINES target-zone OCCURS 10.\\n 10 var2 PIC X(20).\\n * Adjust: from 50 to 80\\n 10 FILLER PIC X(50).\\n 05 redef3 REDEFINES target-zone OCCURS 10.\\n 10 var3 PIC X(20).\\n * Adjust: from 20 to 40\\n 10 FILLER PIC X(20) OCCURS 2.\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}}", + "messages": [ + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didSave\",\"params\":{\"textDocument\":{\"version\":0,\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"},\"text\":\" IDENTIFICATION DIVISION.\\n PROGRAM-ID. TCOMFL06.\\n DATA DIVISION.\\n WORKING-STORAGE SECTION.\\n 01 group1.\\n 05 target-zone PIC X(1000).\\n 05 redef1 REDEFINES target-zone OCCURS 10.\\n 10 var1 PIC X(20).\\n * Add: 10 FILLER PIC X(80).\\n 05 redef2 REDEFINES target-zone OCCURS 10.\\n 10 var2 PIC X(20).\\n * Adjust: from 50 to 80\\n 10 FILLER PIC X(50).\\n 05 redef3 REDEFINES target-zone OCCURS 10.\\n 10 var3 PIC X(20).\\n * Adjust: from 20 to 40\\n 10 FILLER PIC X(20) OCCURS 2.\\n PROCEDURE DIVISION.\\n GOBACK\\n .\\n END PROGRAM TCOMFL06.\"}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\",\"diagnostics\":[]}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/executeCommand\",\"params\":{\"command\":\"refactor/adjustFillers\",\"arguments\":[{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}]}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{}}" + }, + { + "category": 1, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"workspace/applyEdit\",\"params\":{\"label\":\"Adjust FILLERs: 3 FILLER(s) modified\",\"edit\":{\"changes\":{\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\":[{\"range\":{\"start\":{\"line\":8,\"character\":31},\"end\":{\"line\":8,\"character\":31}},\"newText\":\"\\n 10 FILLER PIC X(80).\"},{\"range\":{\"start\":{\"line\":13,\"character\":27},\"end\":{\"line\":13,\"character\":33}},\"newText\":\"X(80).\"},{\"range\":{\"start\":{\"line\":17,\"character\":27},\"end\":{\"line\":17,\"character\":42}},\"newText\":\"X(40) OCCURS 2.\"}]}}}}" + }, + { + "category": 0, + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"applied\":true}}" + } + ], + "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/GDLRUSER/workspaces/runtime-CobolEditorEI/RemoteSystemsTempFiles/FttRemoteTempFiles/nitcpip.e-i.net/ZZ/ZZ.DY530.ZGEN.SOURCE.TST2.PERM/TCOZEFR0.cbl\"}}}", + "IsValid": true +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_WithOccurs/output_expected/ExecuteCommandRefactorAdjustFillers_WithOccurs.rlsp b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_WithOccurs/output_expected/ExecuteCommandRefactorAdjustFillers_WithOccurs.rlsp new file mode 100644 index 000000000..3622a50ee --- /dev/null +++ b/TypeCobol.LanguageServer.Test/LSRTests/NoWindows_ExecuteCommandRefactorAdjustFillers_WithOccurs/output_expected/ExecuteCommandRefactorAdjustFillers_WithOccurs.rlsp @@ -0,0 +1,6 @@ +{ + "success": true, + "diff_index": [ + -1 + ] +} \ No newline at end of file diff --git a/TypeCobol.LanguageServer.Test/LSRTests/OnHover/input/OnHover.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/OnHover/input/OnHover.tlsp index 1cc84565a..8a85d5da8 100644 --- a/TypeCobol.LanguageServer.Test/LSRTests/OnHover/input/OnHover.tlsp +++ b/TypeCobol.LanguageServer.Test/LSRTests/OnHover/input/OnHover.tlsp @@ -23,7 +23,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 StringBuilder typedef strict public PIC X(5).\\r\\n\\r\\na description \\r\\n\\r\\nSee: issue #123 \\r\\n\\r\\nTo do:\\r\\n\\t-\\tTo complete\\r\\n\"}],\"range\":{\"start\":{\"line\":15,\"character\":11},\"end\":{\"line\":15,\"character\":49}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 StringBuilder typedef strict public PIC X(5). a description See: issue #123 To do: \\t-\\tTo complete \"}],\"range\":{\"start\":{\"line\":15,\"character\":11},\"end\":{\"line\":15,\"character\":49}}}}" }, { "category": 0, @@ -31,7 +31,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 TextWriter typedef strict public.\\r\\n 05 sBuilder type StringBuilder.\\r\\n\"}],\"range\":{\"start\":{\"line\":23,\"character\":7},\"end\":{\"line\":23,\"character\":46}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 TextWriter typedef strict public. 05 sBuilder type StringBuilder. \"}],\"range\":{\"start\":{\"line\":23,\"character\":7},\"end\":{\"line\":23,\"character\":46}}}}" }, { "category": 0, @@ -39,7 +39,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"This is a description \\r\\nthis is a extent to the description and \\r\\nyet I need a description that is a bit longer \\r\\n\\r\\nParameters:\\r\\n\\t-\\tbuffer: a buffer\\r\\n\\t-\\tblen: length\\r\\n\\t-\\ttw: a TextWriter\\r\\n\"}],\"range\":{\"start\":{\"line\":36,\"character\":11},\"end\":{\"line\":38,\"character\":50}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"This is a description this is a extent to the description and yet I need a description that is a bit longer Parameters: \\t-\\tbuffer: a buffer \\t-\\tblen: length \\t-\\ttw: a TextWriter \"}],\"range\":{\"start\":{\"line\":36,\"character\":11},\"end\":{\"line\":38,\"character\":50}}}}" }, { "category": 0, @@ -47,7 +47,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"This is a description \\r\\nthis is a extent to the description and \\r\\nyet I need a description that is a bit longer \\r\\n\\r\\nParameters:\\r\\n\\t-\\tbuffer: a buffer\\r\\n\\t-\\tblen: length\\r\\n\\t-\\ttw: a TextWriter\\r\\n\"}],\"range\":{\"start\":{\"line\":36,\"character\":11},\"end\":{\"line\":38,\"character\":50}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"This is a description this is a extent to the description and yet I need a description that is a bit longer Parameters: \\t-\\tbuffer: a buffer \\t-\\tblen: length \\t-\\ttw: a TextWriter \"}],\"range\":{\"start\":{\"line\":36,\"character\":11},\"end\":{\"line\":38,\"character\":50}}}}" }, { "category": 0, @@ -55,7 +55,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"5\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"This is a description \\r\\nthis is a extent to the description and \\r\\nyet I need a description that is a bit longer \\r\\nRestriction: a restriction \\r\\n\\r\\nDeprecated\\r\\nReplaced By: nothing \\r\\n\\r\\nSee: issue 35 \\r\\n\\r\\nParameters:\\r\\n\\t-\\tsrc: boolean\\r\\n\\t-\\tsrc2: boolean\\r\\n\\t-\\tsb: a comment\\r\\n\\r\\nNeeds:\\r\\n\\t-\\tneed 1\\r\\n\\t-\\tneed 2\\r\\n\\t-\\tneed 3\\r\\n\\t-\\tneed 4\\r\\n\\r\\nTo do:\\r\\n\\t-\\tfix that comment thing\\r\\n\"}],\"range\":{\"start\":{\"line\":31,\"character\":11},\"end\":{\"line\":33,\"character\":34}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"5\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"This is a description this is a extent to the description and yet I need a description that is a bit longer Restriction: a restriction Deprecated Replaced By: nothing See: issue 35 Parameters: \\t-\\tsrc: boolean \\t-\\tsrc2: boolean \\t-\\tsb: a comment Needs: \\t-\\tneed 1 \\t-\\tneed 2 \\t-\\tneed 3 \\t-\\tneed 4 To do: \\t-\\tfix that comment thing \"}],\"range\":{\"start\":{\"line\":31,\"character\":11},\"end\":{\"line\":33,\"character\":34}}}}" }, { "category": 0, @@ -63,7 +63,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"6\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 TextWriter typedef strict public.\\r\\n 05 sBuilder type StringBuilder.\\r\\n\"}],\"range\":{\"start\":{\"line\":85,\"character\":6},\"end\":{\"line\":98,\"character\":12}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"6\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 TextWriter typedef strict public. 05 sBuilder type StringBuilder. \"}],\"range\":{\"start\":{\"line\":85,\"character\":6},\"end\":{\"line\":98,\"character\":12}}}}" }, { "category": 0, @@ -71,7 +71,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"7\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 TextWriter typedef strict public.\\r\\n 05 sBuilder type StringBuilder.\\r\\n\"}],\"range\":{\"start\":{\"line\":85,\"character\":6},\"end\":{\"line\":98,\"character\":12}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"7\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 TextWriter typedef strict public. 05 sBuilder type StringBuilder. \"}],\"range\":{\"start\":{\"line\":85,\"character\":6},\"end\":{\"line\":98,\"character\":12}}}}" } ], "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/BALLMA/AppData/Local/Temp/1/tcbl/TCOZBMX16595831499420203922.cee\"}}}", diff --git a/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinition/input/OnHoverDisplayVariableDefinition.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinition/input/OnHoverDisplayVariableDefinition.tlsp index c644e14ea..be406988c 100644 --- a/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinition/input/OnHoverDisplayVariableDefinition.tlsp +++ b/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinition/input/OnHoverDisplayVariableDefinition.tlsp @@ -23,7 +23,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 var1 pic 9(10).\\r\\n\"}],\"range\":{\"start\":{\"line\":14,\"character\":11},\"end\":{\"line\":14,\"character\":28}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 var1 pic 9(10). \"}],\"range\":{\"start\":{\"line\":14,\"character\":11},\"end\":{\"line\":14,\"character\":28}}}}" }, { "category": 0, @@ -31,7 +31,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 var2.\\r\\n 05 var3 pic X(10).\\r\\n\"}],\"range\":{\"start\":{\"line\":14,\"character\":11},\"end\":{\"line\":14,\"character\":28}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 var2. 05 var3 pic X(10). \"}],\"range\":{\"start\":{\"line\":14,\"character\":11},\"end\":{\"line\":14,\"character\":28}}}}" }, { "category": 0, @@ -39,7 +39,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"05 var3 pic X(10).\\r\\n\"}],\"range\":{\"start\":{\"line\":15,\"character\":11},\"end\":{\"line\":15,\"character\":23}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"05 var3 pic X(10). \"}],\"range\":{\"start\":{\"line\":15,\"character\":11},\"end\":{\"line\":15,\"character\":23}}}}" }, { "category": 0, @@ -47,7 +47,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 var4 type MyType.\\r\\n\"}],\"range\":{\"start\":{\"line\":16,\"character\":11},\"end\":{\"line\":16,\"character\":23}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 var4 type MyType. \"}],\"range\":{\"start\":{\"line\":16,\"character\":11},\"end\":{\"line\":16,\"character\":23}}}}" } ], "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MILLETFL/AppData/Local/Temp/3/tcbl/DVZZMFT081153230217563314.cee\"}}}", diff --git a/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinitionFromCopy/input/OnHoverDisplayVariableDefinitionFromCopy.tlsp b/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinitionFromCopy/input/OnHoverDisplayVariableDefinitionFromCopy.tlsp index cefacdb48..2a08ed666 100644 --- a/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinitionFromCopy/input/OnHoverDisplayVariableDefinitionFromCopy.tlsp +++ b/TypeCobol.LanguageServer.Test/LSRTests/OnHoverDisplayVariableDefinitionFromCopy/input/OnHoverDisplayVariableDefinitionFromCopy.tlsp @@ -19,7 +19,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"15 varC-1 pic 9.\\r\\n\"}],\"range\":{\"start\":{\"line\":8,\"character\":11},\"end\":{\"line\":8,\"character\":25}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"15 varC-1 pic 9. \"}],\"range\":{\"start\":{\"line\":8,\"character\":11},\"end\":{\"line\":8,\"character\":25}}}}" }, { "category": 0, @@ -27,7 +27,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"10 groupC.\\r\\n 15 varC-1 pic 9.\\r\\n\"}],\"range\":{\"start\":{\"line\":9,\"character\":11},\"end\":{\"line\":9,\"character\":25}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"10 groupC. 15 varC-1 pic 9. \"}],\"range\":{\"start\":{\"line\":9,\"character\":11},\"end\":{\"line\":9,\"character\":25}}}}" }, { "category": 0, @@ -35,7 +35,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"05 groupB.\\r\\n 10 groupC.\\r\\n 15 varC-1 pic 9.\\r\\n 10 varB-1 pic X.\\r\\n 10 varB-2 pic X.\\r\\n\"}],\"range\":{\"start\":{\"line\":10,\"character\":11},\"end\":{\"line\":10,\"character\":25}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"05 groupB. 10 groupC. 15 varC-1 pic 9. 10 varB-1 pic X. 10 varB-2 pic X. \"}],\"range\":{\"start\":{\"line\":10,\"character\":11},\"end\":{\"line\":10,\"character\":25}}}}" }, { "category": 0, @@ -43,7 +43,7 @@ }, { "category": 1, - "message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 groupA.\\r\\n 05 varA-1 pic X.\\r\\n 05 varA-2 pic X.\\r\\n 05 varA-3 pic X.\\r\\n 05 varA-4 pic X.\\r\\n 05 varA-5 pic 9.\\r\\n 05 groupB.\\r\\n 10 groupC.\\r\\n 15 varC-1 pic 9.\\r\\n 10 varB-1 pic X.\\r\\n 10 varB-2 pic X.\\r\\n\"}],\"range\":{\"start\":{\"line\":11,\"character\":11},\"end\":{\"line\":11,\"character\":25}}}}" + "message": "{\"jsonrpc\":\"2.0\",\"id\":\"4\",\"result\":{\"contents\":[{\"language\":\"Cobol\",\"value\":\"01 groupA. 05 varA-1 pic X. 05 varA-2 pic X. 05 varA-3 pic X. 05 varA-4 pic X. 05 varA-5 pic 9. 05 groupB. 10 groupC. 15 varC-1 pic 9. 10 varB-1 pic X. 10 varB-2 pic X. \"}],\"range\":{\"start\":{\"line\":11,\"character\":11},\"end\":{\"line\":11,\"character\":25}}}}" } ], "didClose": "{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didClose\",\"params\":{\"textDocument\":{\"uri\":\"file:/C:/Users/MILLETFL/AppData/Local/Temp/2/tcbl/DVZZMFT04767119620262366036.cee\"}}}", diff --git a/TypeCobol.LanguageServer.Test/ProcessorTests/DataLayoutProcessorCSVTest.cs b/TypeCobol.LanguageServer.Test/ProcessorTests/DataLayoutProcessorCSVTest.cs index 0907fa5fd..b8b962339 100644 --- a/TypeCobol.LanguageServer.Test/ProcessorTests/DataLayoutProcessorCSVTest.cs +++ b/TypeCobol.LanguageServer.Test/ProcessorTests/DataLayoutProcessorCSVTest.cs @@ -47,8 +47,7 @@ private void DoTestProcessor(string sourceFileName, bool isCopy = false, [Caller } // Compare to expected - var expected = testData.Expected; - TestUtils.CompareLines(testName, result.ToString(), expected, null); + TestUtils.CompareContent(testName, result.ToString(), testData.Expected); } private (string Root, string Header, string[] Rows) ExecuteProcessor(CompilationUnit compilationUnit, Position position) diff --git a/TypeCobol.LanguageServer.Test/RefactoringTests/RefactoringProcessorTest.cs b/TypeCobol.LanguageServer.Test/RefactoringTests/RefactoringProcessorTest.cs index d63f7b343..4400c21c7 100644 --- a/TypeCobol.LanguageServer.Test/RefactoringTests/RefactoringProcessorTest.cs +++ b/TypeCobol.LanguageServer.Test/RefactoringTests/RefactoringProcessorTest.cs @@ -63,7 +63,6 @@ private static (string OriginalSource, string ProcessorType, string CommandArgum var parts = LanguageServerTestUtils.ParseMultiplePartsContent(testDataFilePath); return (parts[0], parts[1], parts[2], parts[3]); - } internal RefactoringProcessorTest(string testName, CompilationUnit target, IRefactoringProcessor refactoringProcessor, object[] arguments, string expectedResult) @@ -97,7 +96,7 @@ public void Run() string actualResult = ApplyTextEdits(refactoring.Label, refactoring.TextEdits); // Compare actual modified code with expected modified code - TestUtils.CompareLines(_testName, actualResult, _expectedResult, null); + TestUtils.CompareContent(_testName, actualResult, _expectedResult); } private string ApplyTextEdits(string label, List changes) diff --git a/TypeCobol.LanguageServer/TypeCobolLanguageServer.cs b/TypeCobol.LanguageServer/TypeCobolLanguageServer.cs index b01e656ca..6542c15a5 100644 --- a/TypeCobol.LanguageServer/TypeCobolLanguageServer.cs +++ b/TypeCobol.LanguageServer/TypeCobolLanguageServer.cs @@ -304,11 +304,10 @@ public CfgDfaParams UpdateCfgDfaInformation(DocumentContext docContext, bool wri { //Create a temporary dot file. string tempFile = Path.GetTempFileName(); - using (TextWriter writer = writeToFile ? File.CreateText(tempFile) : (TextWriter)new StringWriter()) + using (TextWriter writer = writeToFile ? File.CreateText(tempFile) : new StringWriter() { NewLine = " " }) // Do not output newlines when writing to notification param object { CfgDfaParamsBuilder builder = new CfgDfaParamsBuilder(new TextDocumentIdentifier() { uri = docContext.TextDocument.uri }, writeToFile ? tempFile : null); - CfgDotFileForNodeGenerator gen = new CfgDotFileForNodeGenerator(cfgs[0]); - gen.FullInstruction = true; + CfgDotFileForNodeGenerator gen = new CfgDotFileForNodeGenerator(cfgs[0]) { FullInstruction = true }; gen.BlockEmittedEvent += (block, subgraph) => builder.AddBlock(block, subgraph); gen.Report(writer); result = builder.GetParams(); diff --git a/TypeCobol.LanguageServer/TypeCobolServer.cs b/TypeCobol.LanguageServer/TypeCobolServer.cs index 5d824a9fa..ff56c7071 100644 --- a/TypeCobol.LanguageServer/TypeCobolServer.cs +++ b/TypeCobol.LanguageServer/TypeCobolServer.cs @@ -453,20 +453,20 @@ protected override Hover OnHover(TextDocumentPosition parameters) if (matchingNode == null) return resultHover; - string message = string.Empty; + var tooltipWriter = new StringWriter() { NewLine = " " }; // Tooltip text on a single line: platform-independent but the client has to do its own formatting //Switch between all nodes that can return information switch (matchingNode) { case DataDefinition data: if (data.TypeDefinition != null) - message = data.TypeDefinition.ToString(); + data.TypeDefinition.Write(tooltipWriter); break; case ProcedureStyleCall call: //don't show hover on params if (call.FunctionDeclaration != null && lastSignificantToken.TokenType != TokenType.INPUT && lastSignificantToken.TokenType != TokenType.IN_OUT && lastSignificantToken.TokenType != TokenType.OUTPUT) { - message = call.ToString(); + call.Write(tooltipWriter); } break; case FunctionDeclaration fun: @@ -482,7 +482,10 @@ protected override Hover OnHover(TextDocumentPosition parameters) param.CodeElement.StopIndex > parameters.position.character) { if (param.TypeDefinition != null) - message = param.TypeDefinition.ToString(); + { + param.TypeDefinition.Write(tooltipWriter); + break; + } } } } @@ -505,17 +508,18 @@ protected override Hover OnHover(TextDocumentPosition parameters) // Trace back to the DataDefinition corresponding to the storage area. var targetDataDefinition = matchingNode.GetDataDefinitionFromStorageAreaDictionary(targetStorageArea); - message = ToolTipHelper.GetToolTipText(targetDataDefinition); + ToolTipHelper.WriteToolTipText(tooltipWriter, targetDataDefinition); } } break; } - if (message != string.Empty) + string tooltip = tooltipWriter.ToString(); + if (tooltip != string.Empty) { resultHover.range = Range.FromPositions(matchingCodeElement.Line, matchingCodeElement.StartIndex, matchingCodeElement.LineEnd, matchingCodeElement.StopIndex + 1); resultHover.contents = - new MarkedString[] { new MarkedString() { language = "Cobol", value = message } }; + new MarkedString[] { new MarkedString() { language = "Cobol", value = tooltip } }; return resultHover; } @@ -994,21 +998,21 @@ private static IEnumerable> GetLinesWithLevel(Node node, i } /// - /// Builds tooltip text for a Node. + /// Writes tooltip text for a Node to a text writer. /// + /// Target TextWriter /// Node to render as text. /// A textual representation of the given node. - public static string GetToolTipText(Node node) + public static void WriteToolTipText(TextWriter writer, Node node) { - if (node == null) return string.Empty; - StringBuilder sb = new StringBuilder(); + if (node == null) return; + foreach (var tuple in GetLinesWithLevel(node)) { // Replace original indent with custom indent (3 spaces per level). - sb.Append(' ', 3 * tuple.Item1); - sb.AppendLine(tuple.Item2.Text.TrimStart()); + writer.Write(new string(' ', 3 * tuple.Item1)); + writer.WriteLine(tuple.Item2.Text.TrimStart()); } - return sb.ToString(); } } } diff --git a/TypeCobol.LanguageServer/TypeCobolServerHost.cs b/TypeCobol.LanguageServer/TypeCobolServerHost.cs index 1cbe5d30b..58d68ed3f 100644 --- a/TypeCobol.LanguageServer/TypeCobolServerHost.cs +++ b/TypeCobol.LanguageServer/TypeCobolServerHost.cs @@ -236,7 +236,7 @@ static int Main(string[] args) { "lsr=","{PATH} the lsr path", (string v) => LsrPath = v }, { "s|script=","{PATH} script path in lsr", (string v) => LsrScript = v }, { "td|timerdisabled","Disable the delay that handle the automatic launch of Node Phase analyze", _ => TimerDisabledOption = true }, - { "ro|roptions=","Path to LSR options file", (string v) => LsrOptions = v + " " }, + { "ro|roptions=","Path to LSR options file", (string v) => LsrOptions = v }, { "tsource", "Source document testing mode.", _ => LsrSourceTesting = true}, { "tscanner", "Scanner testing mode.", _ => LsrScannerTesting = true}, { "tpreprocess", "Preprocessing testing mode.", _ => LsrPreprocessTesting = true}, diff --git a/TypeCobol.LanguageServer/Workspace.cs b/TypeCobol.LanguageServer/Workspace.cs index f5a5347eb..2f8b6fe66 100644 --- a/TypeCobol.LanguageServer/Workspace.cs +++ b/TypeCobol.LanguageServer/Workspace.cs @@ -11,6 +11,7 @@ using TypeCobol.Logging; using TypeCobol.Tools; using System.Collections.Concurrent; +using System.Diagnostics; using TypeCobol.Compiler.CodeElements; #if EUROINFO_RULES using System.Text.RegularExpressions; @@ -157,7 +158,8 @@ public bool TimerDisabledOption static Workspace() { var folder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - DefaultCopyFolder = folder + @"\DefaultCopies\"; + Debug.Assert(folder != null); + DefaultCopyFolder = Path.Combine(folder, "DefaultCopies"); } public Workspace(string rootDirectoryFullName, string workspaceName, System.Collections.Concurrent.ConcurrentQueue messagesActionsQueue, Action logger) diff --git a/TypeCobol.Test/GrammarTest.cs b/TypeCobol.Test/GrammarTest.cs index b65c77977..0e39579d3 100644 --- a/TypeCobol.Test/GrammarTest.cs +++ b/TypeCobol.Test/GrammarTest.cs @@ -1,9 +1,5 @@ -using System; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Diagnostics; -using System.Collections.Generic; -using System.IO; using TypeCobol.Compiler.Diagnostics; using TypeCobol.Compiler.Directives; using TypeCobol.Test.Utils; @@ -54,7 +50,7 @@ public static void CheckTests(string rootFolder, string resultFolder, string tim options.ExecToStep = ExecutionStep.SemanticCrossCheck; options.IsCobolLanguage = true; //Designed for Cobol85 only because we expect generated code to be identical to input code - string[] files = Directory.GetFiles(rootFolder, regex, SearchOption.AllDirectories); + string[] files = Directory.EnumerateFiles(rootFolder, regex, SearchOption.AllDirectories).OrderBy(p => p).ToArray(); var format = TypeCobol.Compiler.DocumentFormat.RDZReferenceFormat; string resultFile = "GeneratedResultFile.txt"; @@ -238,12 +234,9 @@ public static void CheckTests(string rootFolder, string resultFolder, string tim if (nbFilesInError > 0 && expectedResultFile == null) Assert.Fail('\n'+message); //If no expectedFile to compare throw assert if error else if (expectedResultFile != null) //If expectedFileResult exists compare the DefaultGeneratedFile with expectedFile { - StreamReader expectedResultReader = new StreamReader(new FileStream(expectedResultFile, FileMode.Open)); - StreamReader actualResultReader = new StreamReader(new FileStream(resultFile, FileMode.Open)); - TestUtils.CompareLines("GrammarTestCompareFiles", expectedResultReader.ReadToEnd(), actualResultReader.ReadToEnd(), expectedResultFile); //The test will fail if result files are different - - expectedResultReader.Close(); - actualResultReader.Close(); + var actual = new TestUtils.FileInfo(resultFile); + var expected = new TestUtils.FileInfo(expectedResultFile); + TestUtils.CompareFiles("GrammarTestCompareFiles", actual, expected); //The test will fail if result files are different } } diff --git a/TypeCobol.Test/Misc/TestExpressions.cs b/TypeCobol.Test/Misc/TestExpressions.cs index 8a12eb2b9..a583a04b7 100644 --- a/TypeCobol.Test/Misc/TestExpressions.cs +++ b/TypeCobol.Test/Misc/TestExpressions.cs @@ -1,11 +1,6 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Text; using TypeCobol.Compiler.CodeElements; -using TypeCobol.Compiler.Nodes; using TypeCobol.Compiler.Scanner; using TypeCobol.Test.Utils; @@ -193,9 +188,8 @@ public void CheckExpressionTrees() } var expectedPath = Path.ChangeExtension(Path.Combine("Misc", "Expressions-expected"), "txt"); - var expected = File.ReadAllText(expectedPath); // ensure the string and the file are the same - TestUtils.CompareLines("CheckExpressions", strToString.ToString(), expected, PlatformUtils.GetPathForProjectFile(expectedPath)); + TestUtils.CompareContent("CheckExpressions", strToString.ToString(), new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(expectedPath))); } /// @@ -262,9 +256,8 @@ public void CheckExpressionTokens() } var expectedPath = Path.ChangeExtension(Path.Combine("Misc", "ExpressionsTokens-expected"), "txt"); - var expected = File.ReadAllText(expectedPath); // ensure the string and the file are the same - TestUtils.CompareLines("CheckExpressionTokens", strToString.ToString(), expected, PlatformUtils.GetPathForProjectFile(expectedPath)); + TestUtils.CompareContent("CheckExpressionTokens", strToString.ToString(), new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(expectedPath))); } private class TokenCollector : AbstractAstVisitor diff --git a/TypeCobol.Test/Misc/TestTokenProperties.cs b/TypeCobol.Test/Misc/TestTokenProperties.cs index 8a3fb8891..5cb1f8a61 100644 --- a/TypeCobol.Test/Misc/TestTokenProperties.cs +++ b/TypeCobol.Test/Misc/TestTokenProperties.cs @@ -30,8 +30,8 @@ private static void TestTokenProperty(string propertyName, Func e // Compare to expected var expectedPath = Path.Combine(folder, fileName) + $"-{propertyName}.txt"; - var expected = File.ReadAllText(expectedPath); - TestUtils.CompareLines(testName, result.ToString(), expected, expectedPath); + var expected = new TestUtils.FileInfo(expectedPath); + TestUtils.CompareContent(testName, result.ToString(), expected); } /// diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationCombined.Doc.txt b/TypeCobol.Test/Parser/Documentation/DocumentationCombined.Doc.txt index ad9a59c96..1757d1672 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationCombined.Doc.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationCombined.Doc.txt @@ -8,16 +8,15 @@ Line 77[21,26] <37, Warning, General> - Warning: Parameter does not have any des Line 78[21,24] <37, Warning, General> - Warning: Parameter does not have any description inside the formalized comments: toto ======================== Nodes properties ======================== Name : DocCombined -Description : My program -description +Description : My program description Visibility : Local Namespace : DocCombined NodeType : Program IsDeprecated : True Deprecated : -ReplacedBy : MyFonction2 -Restriction : Do not Use BOOL var -See : Thank you for your attention +ReplacedBy : MyFonction2 +Restriction : Do not Use BOOL var +See : Thank you for your attention Needs : some needs description @@ -29,14 +28,14 @@ Parameters : --------------------- Name : myType -Description : inline typedef +Description : inline typedef Visibility : Public Namespace : DocCombined NodeType : TypeDef IsDeprecated : True Deprecated : ReplacedBy : -Restriction : Do not Use BOOL var +Restriction : Do not Use BOOL var See : Needs : ToDo : @@ -53,7 +52,7 @@ DataType : --------------------- Name : Vect2D -Description : Vect2D +Description : Vect2D Visibility : Local Namespace : DocCombined NodeType : TypeDef @@ -119,13 +118,12 @@ TypeDefChild : --------------------- Name : MyProc -Description : MyProc info - +Description : MyProc info Visibility : Public Namespace : DocCombined NodeType : Function IsDeprecated : True -Deprecated : It is deprecated +Deprecated : It is deprecated ReplacedBy : Restriction : See : @@ -188,7 +186,7 @@ Parameters : --------------------- Name : MyPrivateProc -Description : MyPrivateProc is a Proc but Private +Description : MyPrivateProc is a Proc but Private Visibility : Private Namespace : DocCombined NodeType : Function @@ -224,7 +222,7 @@ Parameters : --------------------- Name : MyLocalProc -Description : MyLocalProc is a Proc but Local (no access modifier) +Description : MyLocalProc is a Proc but Local (no access modifier) Visibility : Local Namespace : DocCombined NodeType : Function @@ -261,12 +259,11 @@ Parameters : ======================== Code Element properties ======================== == DocCombined == -Description : My program -description +Description : My program description Deprecated : *is present* -ReplacedBy : MyFonction2 -Restriction : Do not Use BOOL var -See : Thank you for your attention +ReplacedBy : MyFonction2 +Restriction : Do not Use BOOL var +See : Thank you for your attention Needs : some needs description @@ -278,10 +275,10 @@ Parameters : --------------------- == myType == -Description : inline typedef +Description : inline typedef Deprecated : *is present* ReplacedBy : -Restriction : Do not Use BOOL var +Restriction : Do not Use BOOL var See : Needs : ToDo : @@ -291,7 +288,7 @@ Parameters : --------------------- == Vect2D == -Description : Vect2D +Description : Vect2D Deprecated : ReplacedBy : Restriction : @@ -303,9 +300,8 @@ Parameters : --------------------- == MyProc == -Description : MyProc info - -Deprecated : It is deprecated +Description : MyProc info +Deprecated : It is deprecated ReplacedBy : Restriction : See : @@ -323,7 +319,7 @@ Parameters : --------------------- == MyPrivateProc == -Description : MyPrivateProc is a Proc but Private +Description : MyPrivateProc is a Proc but Private Deprecated : *is present* ReplacedBy : Restriction : @@ -336,7 +332,7 @@ Parameters : --------------------- == MyLocalProc == -Description : MyLocalProc is a Proc but Local (no access modifier) +Description : MyLocalProc is a Proc but Local (no access modifier) Deprecated : *is present* ReplacedBy : Restriction : diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationCombined.DocJson.txt b/TypeCobol.Test/Parser/Documentation/DocumentationCombined.DocJson.txt index bab7f8246..4fc478bd8 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationCombined.DocJson.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationCombined.DocJson.txt @@ -10,16 +10,16 @@ Line 78[21,24] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForProgram:#TypeCobol.Compiler.Nodes", "Deprecated": "", - "Description": "My program \r\ndescription ", + "Description": "My program description", "Name": "DocCombined", "Namespace": "DocCombined", "Needs": [ "some needs", "description" ], - "ReplacedBy": "MyFonction2 ", - "Restriction": "Do not Use BOOL var ", - "See": "Thank you for your attention ", + "ReplacedBy": "MyFonction2", + "Restriction": "Do not Use BOOL var", + "See": "Thank you for your attention", "ToDos": [ "Add BOOL support", "implement a call counter" @@ -30,10 +30,10 @@ Line 78[21,24] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForType:#TypeCobol.Compiler.Nodes", "Deprecated": "", - "Description": "inline typedef ", + "Description": "inline typedef", "Name": "myType", "Namespace": "DocCombined", - "Restriction": "Do not Use BOOL var ", + "Restriction": "Do not Use BOOL var", "Visibility": 1, "DocDataType": { "MaxOccurence": 1, @@ -44,7 +44,7 @@ Line 78[21,24] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForType:#TypeCobol.Compiler.Nodes", - "Description": "Vect2D ", + "Description": "Vect2D", "Name": "Vect2D", "Namespace": "DocCombined", "Childrens": [ @@ -79,8 +79,8 @@ Line 78[21,24] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForFunction:#TypeCobol.Compiler.Nodes", - "Deprecated": "It is deprecated ", - "Description": "MyProc info \r\n", + "Deprecated": "It is deprecated", + "Description": "MyProc info", "Name": "MyProc", "Namespace": "DocCombined", "Needs": [ @@ -142,7 +142,7 @@ Line 78[21,24] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForFunction:#TypeCobol.Compiler.Nodes", "Deprecated": "", - "Description": "MyPrivateProc is a Proc but Private ", + "Description": "MyPrivateProc is a Proc but Private", "Name": "MyPrivateProc", "Namespace": "DocCombined", "ToDos": [ @@ -173,7 +173,7 @@ Line 78[21,24] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForFunction:#TypeCobol.Compiler.Nodes", "Deprecated": "", - "Description": "MyLocalProc is a Proc but Local (no access modifier) ", + "Description": "MyLocalProc is a Proc but Local (no access modifier)", "Name": "MyLocalProc", "Namespace": "DocCombined", "ToDos": [ diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.Doc.txt b/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.Doc.txt index a325dcbd8..eec716de8 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.Doc.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.Doc.txt @@ -24,15 +24,15 @@ Parameters : --------------------- Name : MyProc1 -Description : MyProc1 description +Description : MyProc1 description Visibility : Private Namespace : DocForFunctions NodeType : Function IsDeprecated : True Deprecated : -ReplacedBy : ReplacedBy MyProc8 -Restriction : Do not support discount code -See : you later +ReplacedBy : ReplacedBy MyProc8 +Restriction : Do not support discount code +See : you later Needs : first need second need @@ -92,7 +92,7 @@ Parameters : --------------------- Name : MyProc2 -Description : MyProc2 description +Description : MyProc2 description Visibility : Local Namespace : DocForFunctions NodeType : Function @@ -127,7 +127,7 @@ Parameters : --------------------- Name : MyProc3 -Description : MyProc3 description +Description : MyProc3 description Visibility : Public Namespace : DocForFunctions NodeType : Function @@ -168,11 +168,11 @@ No formalized comment found --------------------- == MyProc1 == -Description : MyProc1 description +Description : MyProc1 description Deprecated : *is present* -ReplacedBy : ReplacedBy MyProc8 -Restriction : Do not support discount code -See : you later +ReplacedBy : ReplacedBy MyProc8 +Restriction : Do not support discount code +See : you later Needs : first need second need @@ -188,7 +188,7 @@ Parameters : --------------------- == MyProc2 == -Description : MyProc2 description +Description : MyProc2 description Deprecated : ReplacedBy : Restriction : @@ -200,7 +200,7 @@ Parameters : --------------------- == MyProc3 == -Description : MyProc3 description +Description : MyProc3 description Deprecated : ReplacedBy : Restriction : diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.DocJson.txt b/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.DocJson.txt index 7152f9d33..181c1d1de 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.DocJson.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationFunctions.DocJson.txt @@ -17,16 +17,16 @@ Line 52[21,25] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForFunction:#TypeCobol.Compiler.Nodes", "Deprecated": "", - "Description": "MyProc1 description ", + "Description": "MyProc1 description", "Name": "MyProc1", "Namespace": "DocForFunctions", "Needs": [ "first need", "second need" ], - "ReplacedBy": "ReplacedBy MyProc8 ", - "Restriction": "Do not support discount code ", - "See": "you later ", + "ReplacedBy": "ReplacedBy MyProc8", + "Restriction": "Do not support discount code", + "See": "you later", "ToDos": [ "implement a call to MyProc8 in case of discount code" ], @@ -81,7 +81,7 @@ Line 52[21,25] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForFunction:#TypeCobol.Compiler.Nodes", - "Description": "MyProc2 description ", + "Description": "MyProc2 description", "Name": "MyProc2", "Namespace": "DocForFunctions", "Parameters": [ @@ -107,7 +107,7 @@ Line 52[21,25] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForFunction:#TypeCobol.Compiler.Nodes", - "Description": "MyProc3 description ", + "Description": "MyProc3 description", "Name": "MyProc3", "Namespace": "DocForFunctions", "Visibility": 1, diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.Doc.txt b/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.Doc.txt index 9ac152b4d..9c9a3260b 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.Doc.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.Doc.txt @@ -3,15 +3,15 @@ Line 63[34,39] <37, Warning, General> - Warning: Parameter does not have any des Line 64[34,39] <37, Warning, General> - Warning: Parameter does not have any description inside the formalized comments: param3 ======================== Nodes properties ======================== Name : DocForPrograms -Description : Main Program +Description : Main Program Visibility : Local Namespace : DocForPrograms NodeType : Program IsDeprecated : False Deprecated : ReplacedBy : -Restriction : restriction value -See : Thank you for your attention +Restriction : restriction value +See : Thank you for your attention Needs : This is my first need This is also my first need This is my second need @@ -21,7 +21,7 @@ Parameters : --------------------- Name : NestedPgm -Description : Nested Program +Description : Nested Program Visibility : Local Namespace : DocForPrograms NodeType : Program @@ -78,7 +78,7 @@ Parameters : --------------------- Name : StackedPgm -Description : Stacked Program +Description : Stacked Program Visibility : Local Namespace : DocForPrograms NodeType : Program @@ -114,11 +114,11 @@ Parameters : ======================== Code Element properties ======================== == DocForPrograms == -Description : Main Program +Description : Main Program Deprecated : ReplacedBy : -Restriction : restriction value -See : Thank you for your attention +Restriction : restriction value +See : Thank you for your attention Needs : This is my first need This is also my first need This is my second need @@ -128,7 +128,7 @@ Parameters : --------------------- == NestedPgm == -Description : Nested Program +Description : Nested Program Deprecated : ReplacedBy : Restriction : @@ -145,7 +145,7 @@ Parameters : --------------------- == StackedPgm == -Description : Stacked Program +Description : Stacked Program Deprecated : ReplacedBy : Restriction : diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.DocJson.txt b/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.DocJson.txt index 7d1baa5d3..9d419445a 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.DocJson.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationPrograms.DocJson.txt @@ -4,21 +4,21 @@ Line 64[34,39] <37, Warning, General> - Warning: Parameter does not have any des ======================== Documentation ======================== { "__type": "DocumentationForProgram:#TypeCobol.Compiler.Nodes", - "Description": "Main Program ", + "Description": "Main Program", "Name": "DocForPrograms", "Namespace": "DocForPrograms", "Needs": [ "This is my first need This is also my first need", "This is my second need" ], - "Restriction": "restriction value ", - "See": "Thank you for your attention " + "Restriction": "restriction value", + "See": "Thank you for your attention" } --------------------- { "__type": "DocumentationForProgram:#TypeCobol.Compiler.Nodes", - "Description": "Nested Program ", + "Description": "Nested Program", "Name": "NestedPgm", "Namespace": "DocForPrograms", "Needs": [ @@ -70,7 +70,7 @@ Line 64[34,39] <37, Warning, General> - Warning: Parameter does not have any des { "__type": "DocumentationForProgram:#TypeCobol.Compiler.Nodes", - "Description": "Stacked Program ", + "Description": "Stacked Program", "Name": "StackedPgm", "Namespace": "DocForPrograms", "Parameters": [ diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.Doc.txt b/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.Doc.txt index c0684bd80..5ef61ee8e 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.Doc.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.Doc.txt @@ -42,7 +42,7 @@ DataType : --------------------- Name : Type11 -Description : Description for Type11 +Description : Description for Type11 Visibility : Public Namespace : DocForTypeDefs NodeType : TypeDef @@ -66,13 +66,13 @@ DataType : --------------------- Name : Type12 -Description : Description for Type12 +Description : Description for Type12 Visibility : Private Namespace : DocForTypeDefs NodeType : TypeDef IsDeprecated : True Deprecated : -ReplacedBy : Type42 +ReplacedBy : Type42 Restriction : See : Needs : @@ -241,7 +241,7 @@ TypeDefChild : --------------------- Name : Type21 -Description : Description for Type21 +Description : Description for Type21 Visibility : Public Namespace : DocForTypeDefs NodeType : TypeDef @@ -392,7 +392,7 @@ TypeDefChild : --------------------- Name : Type22 -Description : Description for Type22 +Description : Description for Type22 Visibility : Private Namespace : DocForTypeDefs NodeType : TypeDef @@ -555,7 +555,7 @@ No formalized comment found --------------------- == Type11 == -Description : Description for Type11 +Description : Description for Type11 Deprecated : ReplacedBy : Restriction : @@ -567,9 +567,9 @@ Parameters : --------------------- == Type12 == -Description : Description for Type12 +Description : Description for Type12 Deprecated : *is present* -ReplacedBy : Type42 +ReplacedBy : Type42 Restriction : See : Needs : @@ -586,7 +586,7 @@ No formalized comment found --------------------- == Type21 == -Description : Description for Type21 +Description : Description for Type21 Deprecated : ReplacedBy : Restriction : @@ -598,7 +598,7 @@ Parameters : --------------------- == Type22 == -Description : Description for Type22 +Description : Description for Type22 Deprecated : *is present* ReplacedBy : Restriction : diff --git a/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.DocJson.txt b/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.DocJson.txt index 1886a818c..eefa45694 100644 --- a/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.DocJson.txt +++ b/TypeCobol.Test/Parser/Documentation/DocumentationTypeDefs.DocJson.txt @@ -21,7 +21,7 @@ Line 59[13,18] <37, Warning, General> - Warning: Type Definition does not suppor { "__type": "DocumentationForType:#TypeCobol.Compiler.Nodes", - "Description": "Description for Type11 ", + "Description": "Description for Type11", "Name": "Type11", "Namespace": "DocForTypeDefs", "Visibility": 1, @@ -35,10 +35,10 @@ Line 59[13,18] <37, Warning, General> - Warning: Type Definition does not suppor { "__type": "DocumentationForType:#TypeCobol.Compiler.Nodes", "Deprecated": "", - "Description": "Description for Type12 ", + "Description": "Description for Type12", "Name": "Type12", "Namespace": "DocForTypeDefs", - "ReplacedBy": "Type42 ", + "ReplacedBy": "Type42", "Visibility": 2, "DocDataType": { "MaxOccurence": 1, @@ -137,7 +137,7 @@ Line 59[13,18] <37, Warning, General> - Warning: Type Definition does not suppor { "__type": "DocumentationForType:#TypeCobol.Compiler.Nodes", - "Description": "Description for Type21 ", + "Description": "Description for Type21", "Name": "Type21", "Namespace": "DocForTypeDefs", "Visibility": 1, @@ -228,7 +228,7 @@ Line 59[13,18] <37, Warning, General> - Warning: Type Definition does not suppor { "__type": "DocumentationForType:#TypeCobol.Compiler.Nodes", "Deprecated": "", - "Description": "Description for Type22 ", + "Description": "Description for Type22", "Name": "Type22", "Namespace": "DocForTypeDefs", "Needs": [ diff --git a/TypeCobol.Test/Parser/Incremental/TestIncrementalPipeline.cs b/TypeCobol.Test/Parser/Incremental/TestIncrementalPipeline.cs index 6aec745da..43bf9b5d5 100644 --- a/TypeCobol.Test/Parser/Incremental/TestIncrementalPipeline.cs +++ b/TypeCobol.Test/Parser/Incremental/TestIncrementalPipeline.cs @@ -13,8 +13,8 @@ namespace TypeCobol.Test.Parser.Incremental [TestClass] public class IncrementalTextLineChanges { - private static readonly string _Root = PlatformUtils.GetPathForProjectFile(@"Parser\Incremental"); - private static readonly string _RootPrograms = PlatformUtils.GetPathForProjectFile(@"Parser\Programs"); + private static readonly string _Root = PlatformUtils.GetPathForProjectFile(@"Parser/Incremental"); + private static readonly string _RootPrograms = PlatformUtils.GetPathForProjectFile(@"Parser/Programs"); private static void TestFolder([CallerMemberName] string folder = null) { diff --git a/TypeCobol.Test/Parser/Preprocessor/PreprocessorUtils.cs b/TypeCobol.Test/Parser/Preprocessor/PreprocessorUtils.cs index cd32a796e..725b2a68e 100644 --- a/TypeCobol.Test/Parser/Preprocessor/PreprocessorUtils.cs +++ b/TypeCobol.Test/Parser/Preprocessor/PreprocessorUtils.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Text; +using System.Text; using TypeCobol.Compiler; using TypeCobol.Compiler.Diagnostics; using TypeCobol.Compiler.File; @@ -63,8 +62,7 @@ private static string BuildResultString(IProcessedTokensLine line) public static void CheckWithDirectiveResultFile(string result, string testName) { string path = Path.Combine(Root, "DirectiveResultFiles", testName + ".txt"); - string expected = File.ReadAllText(PlatformUtils.GetPathForProjectFile(path)); - TestUtils.CompareLines(path, result, expected, PlatformUtils.GetPathForProjectFile(path)); + TestUtils.CompareContent(path, result, new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(path))); } private static string ProcessTokensDocument(ProcessedTokensDocument processedDoc) @@ -125,8 +123,7 @@ public static string ProcessCopyDirectives(CompilationProject project, string na public static void CheckWithCopyResultFile(string result, string testName) { string path = Path.Combine(Root, "CopyResultFiles", testName + ".txt"); - string expected = File.ReadAllText(PlatformUtils.GetPathForProjectFile(path)); - TestUtils.CompareLines(path, result, expected, PlatformUtils.GetPathForProjectFile(path)); + TestUtils.CompareContent(path, result, new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(path))); } public static string ProcessReplaceDirectives(CompilationProject project, string name) @@ -137,8 +134,7 @@ public static string ProcessReplaceDirectives(CompilationProject project, string public static void CheckWithReplaceResultFile(string result, string testName) { string path = Path.Combine(Root, "ReplaceResultFiles", testName + ".txt"); - string expected = File.ReadAllText(PlatformUtils.GetPathForProjectFile(path)); - TestUtils.CompareLines(path, result, expected, PlatformUtils.GetPathForProjectFile(path)); + TestUtils.CompareContent(path, result, new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(path))); } } } diff --git a/TypeCobol.Test/Parser/Scanner/ScannerUtils.cs b/TypeCobol.Test/Parser/Scanner/ScannerUtils.cs index 090c05843..8867b9f88 100644 --- a/TypeCobol.Test/Parser/Scanner/ScannerUtils.cs +++ b/TypeCobol.Test/Parser/Scanner/ScannerUtils.cs @@ -2,7 +2,6 @@ using TypeCobol.Compiler.Concurrency; using TypeCobol.Compiler.Diagnostics; using TypeCobol.Compiler.Directives; -using TypeCobol.Compiler.File; using TypeCobol.Compiler.Scanner; using TypeCobol.Compiler.Sql.Scanner; using TypeCobol.Compiler.Text; @@ -109,12 +108,9 @@ public static string BuildResultString(ITokensLine tokensLine) public static void CheckWithResultFile(string result, string testName) { - string expectedResult; - using (StreamReader reader = new StreamReader(PlatformUtils.GetStreamForProjectFile(@"Parser\Scanner\ResultFiles\" + testName + ".txt"))) - { - expectedResult = reader.ReadToEnd(); - } - TestUtils.CompareLines(testName, result, expectedResult, PlatformUtils.GetPathForProjectFile(@"Parser\Scanner\ResultFiles\" + testName + ".txt")); + string resultFilePath = PlatformUtils.GetPathForProjectFile(@"Parser/Scanner/ResultFiles/" + testName + ".txt"); + var expected = new TestUtils.FileInfo(resultFilePath); + TestUtils.CompareContent(testName, result, expected); } public static string ScanSqlLines(string[] lines, bool decimalPointIsComma) diff --git a/TypeCobol.Test/Parser/Scanner/TestRealPrograms.cs b/TypeCobol.Test/Parser/Scanner/TestRealPrograms.cs index dc7d8ed5d..8dd2eb9f1 100644 --- a/TypeCobol.Test/Parser/Scanner/TestRealPrograms.cs +++ b/TypeCobol.Test/Parser/Scanner/TestRealPrograms.cs @@ -10,7 +10,7 @@ namespace TypeCobol.Test.Parser.Scanner { static class TestRealPrograms { - private static readonly string ParserScannerSamples = @"Parser\Scanner\Samples"; + private static readonly string ParserScannerSamples = @"Parser/Scanner/Samples"; public static void CheckAllFilesForExceptions() diff --git a/TypeCobol.Test/Report/ReportTestHelper.cs b/TypeCobol.Test/Report/ReportTestHelper.cs index e6ef6a84a..4f3374469 100644 --- a/TypeCobol.Test/Report/ReportTestHelper.cs +++ b/TypeCobol.Test/Report/ReportTestHelper.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; +using System.Diagnostics; using TypeCobol.Analysis; using TypeCobol.Compiler; using TypeCobol.Compiler.Directives; @@ -64,8 +60,7 @@ public static ReturnCode ParseWithNodeListenerReportCompare(string fileName, report.Report(sw); // compare with expected result string result = sw.ToString(); - string expected = File.ReadAllText(output, format.Encoding); - TestUtils.CompareLines(input, result, expected, PlatformUtils.GetPathForProjectFile(output)); + TestUtils.CompareContent(input, result, new TestUtils.FileInfo(PlatformUtils.GetPathForProjectFile(output), format.Encoding)); return ReturnCode.Success; } } diff --git a/TypeCobol.Test/TestCollection.cs b/TypeCobol.Test/TestCollection.cs index c44e408a3..bf4996b9d 100644 --- a/TypeCobol.Test/TestCollection.cs +++ b/TypeCobol.Test/TestCollection.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using TypeCobol.Test.Compiler.Parser; using TypeCobol.Test.Parser; using TypeCobol.Test.Parser.FileFormat; @@ -202,7 +199,7 @@ public void CheckParserTcblPrograms() [TestProperty("Time", "fast")] public void TCBLAutoReplaceSecurityTest() { - TestUtils.CompareLines(string.Empty, string.Empty, string.Empty, string.Empty); + TestUtils.CompareLines(null, null, null, null); } diff --git a/TypeCobol.Test/TestUtils.cs b/TypeCobol.Test/TestUtils.cs index 545c7a972..e77557b38 100644 --- a/TypeCobol.Test/TestUtils.cs +++ b/TypeCobol.Test/TestUtils.cs @@ -8,79 +8,128 @@ namespace TypeCobol.Test { public class TestUtils { + public class FileInfo + { + public string Path { get; } + + public Encoding Encoding { get; } + + public FileInfo(string path, Encoding encoding = null) + { + Path = path; + Encoding = encoding ?? Encoding.UTF8; + } - //folder name for test results - private static string _report = "PerformanceReports"; - - /// - /// Compare result and expectedResult line by line. - /// If there is at least one difference, throw an exception for the test named by the parameter testName or - /// Replace ExpectedResult content if content is different and boolean "autoReplace" is true - /// - /// Name of the test - /// - /// - /// - /// - public static void CompareLines(string testName, string result, string expectedResult, string expectedResultPath) + public string ReadAllText() => File.ReadAllText(Path, Encoding); + + public string[] ReadAllLines() => SplitLines(ReadAllText()); + + public void WriteAllLines(string[] contents) + { + using (var writer = new StreamWriter(new FileStream(Path, FileMode.Truncate), Encoding)) + { + for (int i = 0; i < contents.Length; i++) + { + string line = contents[i]; + if (i == contents.Length - 1) + { + writer.Write(line); + } + else + { + writer.WriteLine(line); + } + } + } + } + } + + private static string[] SplitLines(string content) => content.ReplaceLineEndings().Split(Environment.NewLine); + + public static void CompareFiles(string testName, FileInfo actual, FileInfo expected) { - StringBuilder errors = new StringBuilder(); + CompareContent(testName, actual?.ReadAllText(), expected); + } - //Set to true to automatically replace content in ExpectedResult File + public static void CompareContent(string testName, string actualResult, FileInfo expected) + { + var actualLines = SplitLines(actualResult); + var expectedLines = expected?.ReadAllLines(); + CompareLines(testName, actualLines, expectedLines, expected); + } + + public static void CompareContent(string testName, string actualResult, string expectedResult) + { + var actualLines = SplitLines(actualResult); + var expectedLines = SplitLines(expectedResult); + CompareLines(testName, actualLines, expectedLines, null); + } + + public static void CompareLines(string testName, string[] actualLines, string[] expectedLines, FileInfo expected) + { + // Set to true to automatically replace content in expected file. bool autoReplace = false; - if (testName == string.Empty && result == string.Empty && expectedResult == string.Empty && - expectedResultPath == string.Empty) + if (testName == null && actualLines == null && expectedLines == null && expected == null) { if (autoReplace) Assert.Fail("Set AutoReplace to false in TestUtils.CompareLines()\n\n"); + else + return; } - result = Regex.Replace(result, "(?(); - for (int c = 0; c < resultLines.Length && c < expectedResultLines.Length; c++) + var lineFaults = new List(); + for (int c = 0; c < actualLines.Length && c < expectedLines.Length; c++) { - if (expectedResultLines[c] != resultLines[c]) linefaults.Add(c / 2 + 1); + var actualLine = actualLines[c]; + var expectedLine = expectedLines[c]; + if (actualLine != expectedLine) + { + lineFaults.Add(c); + } } - if (result != expectedResult) + if (lineFaults.Count > 0 || actualLines.Length != expectedLines.Length) { - if (autoReplace && expectedResultPath != null) + var errors = new StringBuilder(); + errors.AppendLine("result != expectedResult In test:" + testName); + if (lineFaults.Count > 0) + { + errors.AppendLine("at line" + (lineFaults.Count > 1 ? "s" : "") + ": " + string.Join(",", lineFaults)); + } + else { - replaceLines(result, expectedResultPath); - errors.AppendLine("result != expectedResult In test:" + testName); - errors.AppendLine("at line" + (linefaults.Count > 1 ? "s" : "") + ": " + string.Join(",", linefaults)); - errors.AppendLine("Output file has been modified\n"); + errors.AppendLine($"line count differs: expecting {expectedLines.Length} lines but found {actualLines.Length} lines instead."); + } + + if (autoReplace && expected != null) + { + expected.WriteAllLines(actualLines); + errors.AppendLine("autoReplace is active ! Output file has been rewritten\n"); errors.AppendLine("Please rerun unit test\n"); } else { - errors.Append("result != expectedResult In test:" + testName) - .AppendLine(" at line" + (linefaults.Count > 1 ? "s" : "") + ": " + string.Join(",", linefaults)); - errors.AppendLine("See TestUtils.cs CompareLines method to autoreplace ExpectedResult"); - errors.Append("=== RESULT ==========\n" + result + "===================="); - throw new Exception(errors.ToString()); + errors.AppendLine("See TestUtils.cs CompareLines method to auto-replace ExpectedResult"); + errors.AppendLine("======= RESULT ======="); + foreach (var actualLine in actualLines) + { + errors.AppendLine(actualLine); + } + errors.AppendLine("======================"); } - } - } - private static void replaceLines(string result, string expectedResultPath) - { - using (StreamWriter writer = new StreamWriter(expectedResultPath)) - { - writer.Write(result); + throw new Exception(errors.ToString()); } - } public static string GetReportDirectoryPath() { - return Path.Combine(Directory.GetCurrentDirectory(), _report); + return Path.Combine(Directory.GetCurrentDirectory(), "PerformanceReports"); } public static void CreateRunReport(string reportName, string localDirectoryFullName, string cobolFileName, diff --git a/TypeCobol.Test/TypeCobol.Test.csproj b/TypeCobol.Test/TypeCobol.Test.csproj index a84da06e3..95f8d75c9 100644 --- a/TypeCobol.Test/TypeCobol.Test.csproj +++ b/TypeCobol.Test/TypeCobol.Test.csproj @@ -10,7 +10,6 @@ - diff --git a/TypeCobol.Test/Utils/Comparators.cs b/TypeCobol.Test/Utils/Comparators.cs index e17852feb..026f06350 100644 --- a/TypeCobol.Test/Utils/Comparators.cs +++ b/TypeCobol.Test/Utils/Comparators.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; +using System.Text; using Antlr4.Runtime; using TypeCobol.Compiler; using TypeCobol.Compiler.CodeElements; @@ -41,10 +37,7 @@ public void Compare(CompilationUnit compilationResult, IncrementalChangesHistory string stepDescription = ChangeId != null ? $"after incremental change: {ChangeId}" : "after initial parsing"; string comparisonName = $"{compilationResult.TextSourceInfo.Name} vs {_formatter.GetType().Name} ({stepDescription})"; string actual = _formatter.Format(compilationResult, history); - using (var expected = new StreamReader(new FileStream(_expectedResultPath, FileMode.Open))) - { - ParserUtils.CheckWithResultReader(comparisonName, actual, expected, _expectedResultPath); - } + TestUtils.CompareContent(comparisonName, actual, new TestUtils.FileInfo(_expectedResultPath)); } } diff --git a/TypeCobol.Test/Utils/ParserUtils.cs b/TypeCobol.Test/Utils/ParserUtils.cs index c1968e06b..498ae0c7e 100644 --- a/TypeCobol.Test/Utils/ParserUtils.cs +++ b/TypeCobol.Test/Utils/ParserUtils.cs @@ -271,85 +271,6 @@ private static void DumpInTypeDef(StringBuilder str, TypeCobol.Compiler.Nodes.Da DumpInTypeDef(str, (TypeCobol.Compiler.Nodes.DataDescription)sub, indent + 1); } - /*TODO#249 - private static void Dump(StringBuilder str, IList functions) { - if (functions == null || functions.Count < 1) return; - str.AppendLine("FUNCTIONS:"); - foreach(var function in functions) { - str.Append(" £ ").Append(function.Name).Append(':').Append(function.Visibility); - str.AppendLine(); - foreach(var parameter in function.Profile.InputParameters) { - str.Append(" in: "); - Dump(str, parameter); - str.AppendLine(); - } - foreach(var parameter in function.Profile.OutputParameters) { - str.Append(" out: "); - Dump(str, parameter); - str.AppendLine(); - } - foreach(var parameter in function.Profile.InoutParameters) { - str.Append(" io: "); - Dump(str, parameter); - str.AppendLine(); - } - if (function.Profile.ReturningParameter != null) { - str.Append(" return: "); - Dump(str, function.Profile.ReturningParameter); - str.AppendLine(); - } - } - } - private static void Dump(StringBuilder str, ParameterDescription parameter) { - str.Append(parameter.Name).Append(':'); - var entry = (ParameterDescriptionEntry)parameter.CodeElement; - if (entry.CustomType != null) str.Append(entry.CustomType); - else - if (entry.Picture != null) str.Append(entry.Picture); - else str.Append("?"); - } - // [/TYPECOBOL] - - private static void Dump(StringBuilder str, Dictionary> map) { - foreach(string key in map.Keys) { - foreach (var data in map[key]) { - Dump(str, data, 1); - str.Append("\n"); - } - } - } - - private static StringBuilder Dump(StringBuilder str, Named data, int indent = 0) - { - DumpIndent(str, indent); - str.Append(data.Name); - return str; - } - - private static StringBuilder DumpIndent(StringBuilder str, int indent) - { - for (int c=0; c GetDocumentedNodes(Node root) { List documentedNodes = new List(); diff --git a/TypeCobol/Compiler/CodeElements/Expressions/FormalizedCommentDocumentation.cs b/TypeCobol/Compiler/CodeElements/Expressions/FormalizedCommentDocumentation.cs index 02e07a134..6e7d83492 100644 --- a/TypeCobol/Compiler/CodeElements/Expressions/FormalizedCommentDocumentation.cs +++ b/TypeCobol/Compiler/CodeElements/Expressions/FormalizedCommentDocumentation.cs @@ -171,28 +171,28 @@ public void Add(Fields parameter, IToken symbol = null, bool isContinuation = fa break; case Fields.Description: if (!string.IsNullOrEmpty(Description)) - Description += Environment.NewLine; - Description += value + " "; + Description += " "; + Description += value; break; case Fields.Deprecated: if (!string.IsNullOrEmpty(Deprecated)) - Description += Environment.NewLine; - Deprecated += value + " "; + Deprecated += " "; + Deprecated += value; break; case Fields.ReplacedBy: if (!string.IsNullOrEmpty(ReplacedBy)) - ReplacedBy += Environment.NewLine; - ReplacedBy += value + " "; + ReplacedBy += " "; + ReplacedBy += value; break; case Fields.Restriction: if (!string.IsNullOrEmpty(Restriction)) - Restriction += Environment.NewLine; - Restriction += value + " "; + Restriction += " "; + Restriction += value; break; case Fields.See: if (!string.IsNullOrEmpty(See)) - See += Environment.NewLine; - See += value + " "; + See += " "; + See += value; break; case Fields.Parameters: if (isContinuation) @@ -233,66 +233,85 @@ public void Add(Fields parameter, string key, string value) public override string ToString() { - StringBuilder sb = new StringBuilder(); + var writer = new StringWriter(); + Write(writer); + return writer.ToString(); + } + + public void Write(TextWriter writer) + { + bool empty = true; if (Description != null) - sb.AppendLine(Description); + { + writer.WriteLine(Description); + empty = Description.Length == 0; + } if (Restriction != null) - sb.AppendLine("Restriction: " + Restriction); + { + writer.WriteLine("Restriction: " + Restriction); + empty = false; + } if (Deprecated != null) { - if (sb.Length != 0) - sb.AppendLine(); - sb.AppendLine(Deprecated != string.Empty ? "Deprecated: " + Deprecated : "Deprecated"); + if (!empty) + writer.WriteLine(); + writer.WriteLine(Deprecated != string.Empty ? "Deprecated: " + Deprecated : "Deprecated"); + empty = false; } if (ReplacedBy != null) - sb.AppendLine("Replaced By: " + ReplacedBy); + { + writer.WriteLine("Replaced By: " + ReplacedBy); + empty = false; + } if (See != null) { - if (sb.Length != 0) - sb.AppendLine(); - sb.AppendLine("See: " + See); + if (!empty) + writer.WriteLine(); + writer.WriteLine("See: " + See); + empty = false; } - if (Parameters.Count > 0) { - if (sb.Length != 0) - sb.AppendLine(); - sb.AppendLine("Parameters:"); + if (!empty) + writer.WriteLine(); + writer.WriteLine("Parameters:"); foreach (var parameter in Parameters) { - sb.AppendLine("\t-\t" + parameter.Key + ": " + parameter.Value); + writer.WriteLine("\t-\t" + parameter.Key + ": " + parameter.Value); } + + empty = false; } if (Needs.Count > 0) { - if (sb.Length != 0) - sb.AppendLine(); - sb.AppendLine("Needs:"); + if (!empty) + writer.WriteLine(); + writer.WriteLine("Needs:"); foreach (var need in Needs) { - sb.AppendLine("\t-\t" + need); + writer.WriteLine("\t-\t" + need); } + + empty = false; } if (ToDo.Count > 0) { - if (sb.Length != 0) - sb.AppendLine(); - sb.AppendLine("To do:"); + if (!empty) + writer.WriteLine(); + writer.WriteLine("To do:"); foreach (var todo in ToDo) { - sb.AppendLine("\t-\t" + todo); + writer.WriteLine("\t-\t" + todo); } } - - return sb.ToString(); } } } diff --git a/TypeCobol/Compiler/File/LocalDirectoryLibrary.cs b/TypeCobol/Compiler/File/LocalDirectoryLibrary.cs index 8729cb0c8..b1b21bfe7 100644 --- a/TypeCobol/Compiler/File/LocalDirectoryLibrary.cs +++ b/TypeCobol/Compiler/File/LocalDirectoryLibrary.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Text; namespace TypeCobol.Compiler.File { @@ -16,8 +11,7 @@ public class LocalDirectoryLibrary : ICobolLibrary // Local directory properties public DirectoryInfo RootDirectory { get; } - private string _rootPath; - private bool includeSubdirectories; + private readonly EnumerationOptions enumerationOptions; private string[] fileExtensions; // Library file format properties @@ -41,13 +35,19 @@ public LocalDirectoryLibrary(string libraryName, string rootPath, bool includeSu { Name = libraryName; - this._rootPath = rootPath; RootDirectory = new DirectoryInfo(rootPath); if (!RootDirectory.Exists) { throw new ArgumentException($"Local copy library {rootPath} does not exist on disk."); } - this.includeSubdirectories = includeSubdirectories; + + this.enumerationOptions = new EnumerationOptions() + { + MatchCasing = + MatchCasing.CaseInsensitive, // Looking up textnames from Cobol source which is case-insensitive + RecurseSubdirectories = includeSubdirectories + }; + if (fileExtensions != null) { foreach (var fileExtension in fileExtensions) @@ -169,9 +169,7 @@ private string FindFirstMatchingFilePathWithExtensionsFirst(string textName) /// Name of the Cobol library, as specified in a Cobol program (COPY textName OF libraryName) public FileInfo SearchForFileWithoutExtensions(string textName) { - return RootDirectory.EnumerateFiles(textName, - includeSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly) - .FirstOrDefault(); + return RootDirectory.EnumerateFiles(textName, enumerationOptions).FirstOrDefault(); } /// @@ -180,7 +178,7 @@ public FileInfo SearchForFileWithoutExtensions(string textName) /// Name of the Cobol library, as specified in a Cobol program (COPY textName OF libraryName) public FileInfo SearchForFileWithExtensions(string textName) { - return RootDirectory.EnumerateFiles($"{textName}.*", includeSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly) + return RootDirectory.EnumerateFiles($"{textName}.*", enumerationOptions) .FirstOrDefault(f => fileExtensions.Any(suffix => f.Extension.Equals(suffix, StringComparison.OrdinalIgnoreCase))); @@ -237,7 +235,7 @@ internal void StartMonitoringCobolFile(LocalCobolFile localCobolFile) if (fileSystemWatcher == null) { fileSystemWatcher = new FileSystemWatcher(RootDirectory.FullName); - fileSystemWatcher.IncludeSubdirectories = includeSubdirectories; + fileSystemWatcher.IncludeSubdirectories = enumerationOptions.RecurseSubdirectories; fileSystemWatcher.Changed += fileSystemWatcher_Changed; fileSystemWatcher.Renamed += fileSystemWatcher_Renamed; fileSystemWatcher.Deleted += fileSystemWatcher_Deleted; diff --git a/TypeCobol/Compiler/Nodes/Data.cs b/TypeCobol/Compiler/Nodes/Data.cs index a49580ac4..81e87d3e3 100644 --- a/TypeCobol/Compiler/Nodes/Data.cs +++ b/TypeCobol/Compiler/Nodes/Data.cs @@ -887,35 +887,38 @@ public override int GetHashCode() public override string ToString() { - StringBuilder sb = new StringBuilder(); - FormalizedCommentDocumentation doc = this.CodeElement.FormalizedCommentDocumentation; + var writer = new StringWriter(); + Write(writer); + return writer.ToString(); + } + public void Write(TextWriter writer) + { + var lines = SelfAndChildrenLines.ToArray(); int i = 0; - - while (i < SelfAndChildrenLines.Count()) + while (i < lines.Length) { - if (SelfAndChildrenLines.ElementAt(i) is CodeElementsLine line) + if (lines[i] is CodeElementsLine line) { if (line.ScanState.InsideFormalizedComment) { - while ((SelfAndChildrenLines.ElementAt(i) as CodeElementsLine)?.ScanState.InsideFormalizedComment == true) + while ((lines[i] as CodeElementsLine)?.ScanState.InsideFormalizedComment == true) i++; } else if (line.IndicatorChar != '*') { - sb.AppendLine(line.Text.Remove(0, 7)); + writer.WriteLine(line.Text.Remove(0, 7)); } } i++; } + var doc = CodeElement.FormalizedCommentDocumentation; if (doc != null) { - sb.AppendLine(); - sb.Append(doc); + writer.WriteLine(); + doc.Write(writer); } - - return sb.ToString(); } } // [/COBOL 2002] diff --git a/TypeCobol/Compiler/Nodes/Statement.cs b/TypeCobol/Compiler/Nodes/Statement.cs index 16c2b888a..c678de75f 100644 --- a/TypeCobol/Compiler/Nodes/Statement.cs +++ b/TypeCobol/Compiler/Nodes/Statement.cs @@ -77,12 +77,17 @@ public override bool VisitNode(IASTVisitor astVisitor) } public override string ToString() + { + var writer = new StringWriter(); + Write(writer); + return writer.ToString(); + } + + public void Write(TextWriter writer) { var doc = FunctionDeclaration.CodeElement.FormalizedCommentDocumentation; if (doc != null) - return doc.ToString(); - - return string.Empty; + doc.Write(writer); } public CodeElementType EndType => CodeElementType.CallStatementEnd; diff --git a/TypeCobol/Tools/Options-Config/TypeCobolConfiguration.cs b/TypeCobol/Tools/Options-Config/TypeCobolConfiguration.cs index 857251a3d..c8207c81e 100644 --- a/TypeCobol/Tools/Options-Config/TypeCobolConfiguration.cs +++ b/TypeCobol/Tools/Options-Config/TypeCobolConfiguration.cs @@ -397,7 +397,7 @@ public static Dictionary InitializeCobolOptions(TypeCobolCon file = string.Empty; if ((!Directory.Exists(directory) || !string.IsNullOrEmpty(file) && !File.Exists(dependency)) && !errorStack.ContainsKey(ReturnCode.DependenciesError)) - errorStack.Add(ReturnCode.DependenciesError, TypeCobolConfiguration.ErrorMessages[ReturnCode.DependenciesError] + directory + Path.DirectorySeparatorChar + file); + errorStack.Add(ReturnCode.DependenciesError, TypeCobolConfiguration.ErrorMessages[ReturnCode.DependenciesError] + dependency); } } diff --git a/TypeCobol/TypeCobol.csproj b/TypeCobol/TypeCobol.csproj index d14771a85..ffcda5efe 100644 --- a/TypeCobol/TypeCobol.csproj +++ b/TypeCobol/TypeCobol.csproj @@ -17,12 +17,9 @@ - - all - - - all - + + +