Skip to content

Commit 29d4103

Browse files
authored
Merge pull request #2051 from TypeCobolTeam/v1.5.7
V1.5.7
2 parents 4a58a30 + 08d2acb commit 29d4103

File tree

245 files changed

+6020
-3395
lines changed

Some content is hidden

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

245 files changed

+6020
-3395
lines changed

Analytics/packages.config

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Elasticsearch.Net" version="7.5.1" targetFramework="net47" />
4-
<package id="NLog" version="4.7.2" targetFramework="net47" />
5-
<package id="System.Buffers" version="4.5.0" targetFramework="net47" />
6-
<package id="System.Diagnostics.DiagnosticSource" version="4.7.0" targetFramework="net47" />
7-
<package id="System.Memory" version="4.5.3" targetFramework="net47" />
8-
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net47" />
9-
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0" targetFramework="net47" />
3+
<package id="Elasticsearch.Net" version="7.5.1" targetFramework="net472" />
4+
<package id="NLog" version="4.7.2" targetFramework="net472" />
5+
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
6+
<package id="System.Diagnostics.DiagnosticSource" version="4.7.0" targetFramework="net472" />
7+
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
8+
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
9+
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0" targetFramework="net472" />
1010
</packages>

CLI/src/CLI.cs

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ internal static ReturnCode runOnce(TypeCobolConfiguration config)
4141
debugLine += Path.GetFileName(config.InputFiles[0]);
4242
}
4343
debugLine += "\n";
44-
//Use user-defined log path if -log option used, otherwise use default location for log file
45-
File.AppendAllText(config.LogFile ?? TypeCobolConfiguration.DefaultLogFileName, debugLine);
44+
Logger(config, debugLine);
4645
Console.WriteLine(debugLine);
4746
TextWriter textWriter = config.ErrorFile == null ? Console.Error : File.CreateText(config.ErrorFile);
4847
AbstractErrorWriter errorWriter;
@@ -84,8 +83,7 @@ internal static ReturnCode runOnce(TypeCobolConfiguration config)
8483

8584
stopWatch.Stop();
8685
debugLine = " parsed in " + stopWatch.Elapsed + " ms\n";
87-
//Use user-defined log path if -log option used, otherwise use default location for log file
88-
File.AppendAllText(config.LogFile ?? TypeCobolConfiguration.DefaultLogFileName, debugLine);
86+
Logger(config, debugLine);
8987
Console.WriteLine(debugLine);
9088

9189
AnalyticsWrapper.Telemetry.TrackMetricsEvent(EventType.Duration, LogType.Genration, "ExecutionTime", stopWatch.Elapsed.Milliseconds);
@@ -122,11 +120,11 @@ private ReturnCode Compile()
122120
var rootSymbolTable = LoadIntrinsicsAndDependencies();
123121

124122
//Add analyzers
125-
var analyzerProvider = new CompositeAnalyzerProvider();
123+
var analyzerProvider = new AnalyzerProviderWrapper(str => Logger(_configuration, str));
126124
var reports = RegisterAnalyzers(analyzerProvider);
127125

128126
//Add external analyzers
129-
analyzerProvider.AddCustomProviders(_configuration.CustomAnalyzerFiles);
127+
analyzerProvider.AddCustomProviders(_configuration.CustomAnalyzerFiles, str => Logger(_configuration, str));
130128

131129
//Normalize TypeCobolOptions, the parser does not need to go beyond SemanticCheck for the first phase
132130
var typeCobolOptions = new TypeCobolOptions(_configuration);
@@ -199,10 +197,24 @@ private ReturnCode Compile()
199197
//Write used and missing copies files
200198
WriteCopiesFile(_configuration.ExtractedCopiesFilePath, _usedCopies);
201199
WriteCopiesFile(_configuration.HaltOnMissingCopyFilePath, _missingCopies);
200+
#if EUROINFO_RULES
201+
WriteUsedCopiesFile();
202+
#endif
202203

203204
return AddErrorsAndComputeReturnCode();
204205
}
205206

207+
/// <summary>
208+
/// Log a string in the LogFile provided by the configuration.
209+
/// </summary>
210+
/// <param name="config">Configuration containing the log file.</param>
211+
/// <param name="message">String to log.</param>
212+
private static void Logger(TypeCobolConfiguration config, string message)
213+
{
214+
//Use user-defined log path if -log option used, otherwise use default location for log file
215+
File.AppendAllText(config.LogFile ?? TypeCobolConfiguration.DefaultLogFileName, message);
216+
}
217+
206218
private SymbolTable LoadIntrinsicsAndDependencies()
207219
{
208220
var intrinsicsAndDependenciesParser = new Parser();
@@ -251,21 +263,21 @@ private void CollectMissingCopies(IEnumerable<string> missingCopies)
251263
}
252264
}
253265

254-
private Dictionary<string, IReport> RegisterAnalyzers(AnalyzerProvider analyzerProvider)
266+
private Dictionary<string, IReport> RegisterAnalyzers(AnalyzerProviderWrapper analyzerProviderWrapper)
255267
{
256268
var reports = new Dictionary<string, IReport>();
257269
if (_configuration.ExecToStep >= ExecutionStep.CrossCheck)
258270
{
259271
//All purpose CFG/DFA
260-
analyzerProvider.AddActivator((o, t) => CfgDfaAnalyzerFactory.CreateCfgAnalyzer(_configuration.CfgBuildingMode));
272+
analyzerProviderWrapper.AddActivator((o, t) => CfgDfaAnalyzerFactory.CreateCfgAnalyzer(_configuration.CfgBuildingMode, o));
261273

262274
//CFG/DFA for ZCALL report
263275
if (!string.IsNullOrEmpty(_configuration.ReportZCallFilePath))
264276
{
265277
if (_configuration.CfgBuildingMode != CfgBuildingMode.WithDfa)
266278
{
267279
//Need to create a dedicated CFG builder with DFA activated
268-
analyzerProvider.AddActivator((o, t) => CfgDfaAnalyzerFactory.CreateCfgAnalyzer(CfgBuildingMode.WithDfa));
280+
analyzerProviderWrapper.AddActivator((o, t) => CfgDfaAnalyzerFactory.CreateCfgAnalyzer(CfgBuildingMode.WithDfa, o));
269281
}
270282

271283
string zCallCfgDfaId = CfgDfaAnalyzerFactory.GetIdForMode(CfgBuildingMode.WithDfa);
@@ -276,7 +288,7 @@ private Dictionary<string, IReport> RegisterAnalyzers(AnalyzerProvider analyzerP
276288
//CopyMoveInitializeReport
277289
if (!string.IsNullOrEmpty(_configuration.ReportCopyMoveInitializeFilePath))
278290
{
279-
analyzerProvider.AddActivator(
291+
analyzerProviderWrapper.AddActivator(
280292
(o, t) =>
281293
{
282294
var report = new CopyMoveInitializeReport();
@@ -461,6 +473,42 @@ private void WriteCopiesFile(string copiesFilePath, IEnumerable<string> copies)
461473
}
462474
}
463475

476+
#if EUROINFO_RULES
477+
private void WriteUsedCopiesFile()
478+
{
479+
if (_configuration.ReportUsedCopyNamesPath != null)
480+
{
481+
using (var output = File.CreateText(_configuration.ReportUsedCopyNamesPath))
482+
{
483+
foreach (var parserResult in _parserResults)
484+
{
485+
string fileName = Path.GetFileNameWithoutExtension(parserResult.Key);
486+
var usedCopies = parserResult.Value.CollectedCopyNames;
487+
488+
if (usedCopies == null)
489+
{
490+
output.WriteLine(fileName);
491+
continue;
492+
}
493+
494+
foreach (var usedCopy in usedCopies)
495+
{
496+
output.Write(fileName);
497+
output.Write(';');
498+
output.Write(usedCopy.Key);
499+
foreach (var suffixedName in usedCopy.Value)
500+
{
501+
output.Write(';');
502+
output.Write(suffixedName);
503+
}
504+
output.WriteLine();
505+
}
506+
}
507+
}
508+
}
509+
}
510+
#endif
511+
464512
private ReturnCode AddErrorsAndComputeReturnCode()
465513
{
466514
/*
@@ -513,7 +561,7 @@ private ReturnCode AddErrorsAndComputeReturnCode()
513561
if (generationException.Logged)
514562
{
515563
string message = generationException.Message + Environment.NewLine + generationException.StackTrace;
516-
var position = new Diagnostic.Position(generationException.LineNumber, generationException.ColumnStartIndex, generationException.ColumnEndIndex, null);
564+
var position = new Diagnostic.Position(generationException.LineNumber, generationException.ColumnStartIndex, generationException.LineNumber, generationException.ColumnEndIndex, null);
517565
Server.AddError(_errorWriter, generationException.Path, new Diagnostic(generationException.MessageCode, position, message));
518566
}
519567
}
@@ -524,7 +572,20 @@ private ReturnCode AddErrorsAndComputeReturnCode()
524572
CheckExternalDiagnostics(_dependenciesDiagnostics);
525573
CheckExternalDiagnostics(_intrinsicsDiagnostics);
526574

527-
//Always return MissingCopy when there is at least one missing copy because it could help the developer to correct several parsing errors at once
575+
//Avoid returning MissingCopy for users who are only interested in copies extraction
576+
if (_configuration.ExecToStep <= ExecutionStep.Preprocessor)
577+
{
578+
if (_configuration.ExtractedCopiesFilePath != null
579+
#if EUROINFO_RULES
580+
|| _configuration.ReportUsedCopyNamesPath != null
581+
#endif
582+
)
583+
{
584+
return returnCode;
585+
}
586+
}
587+
588+
//Return MissingCopy when there is at least one missing copy because it could help the developer to correct several parsing errors at once
528589
if (_missingCopies.Count > 0)
529590
{
530591
returnCode = ReturnCode.MissingCopy;

CLI/src/Writer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private void writeMessage(string id, Diagnostic error) {
141141
writer.WriteStartElement("MESSAGE");
142142
writer.WriteElementString("MSGNUMBER",
143143
"TC-" + error.Info.Code.ToString().PadLeft(5, '0') + AsIBMSuffix((int) error.Info.Severity));
144-
writer.WriteElementString("MSGLINE", error.Line.ToString());
144+
writer.WriteElementString("MSGLINE", error.LineStart.ToString());
145145
writer.WriteElementString("MSGFILE", id);
146146
writer.WriteElementString("MSGTEXT", error.Message);
147147
writer.WriteEndElement(); // MESSAGE
@@ -246,9 +246,9 @@ private void WriteDiagnostics()
246246

247247
//range
248248
_xmlWriter.WriteStartElement("range");
249-
_xmlWriter.WriteAttributeString("line-start", diagnostic.Line.ToString());
249+
_xmlWriter.WriteAttributeString("line-start", diagnostic.LineStart.ToString());
250250
_xmlWriter.WriteAttributeString("column-start", diagnostic.ColumnStart.ToString());
251-
_xmlWriter.WriteAttributeString("line-end", diagnostic.Line.ToString());
251+
_xmlWriter.WriteAttributeString("line-end", diagnostic.LineEnd.ToString());
252252
_xmlWriter.WriteAttributeString("column-end", diagnostic.ColumnEnd.ToString());
253253
_xmlWriter.WriteEndElement();
254254

CLI/test/CLI.Test.csproj

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,9 @@
1818
<ItemGroup>
1919
<Reference Include="System" />
2020
</ItemGroup>
21-
<Choose>
22-
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
23-
<ItemGroup>
24-
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
25-
</ItemGroup>
26-
</When>
27-
<Otherwise>
28-
<ItemGroup>
29-
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
30-
</ItemGroup>
31-
</Otherwise>
32-
</Choose>
21+
<ItemGroup>
22+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
23+
</ItemGroup>
3324
<ItemGroup>
3425
<Compile Include="*.cs" />
3526
<Compile Include="Properties\AssemblyInfo.cs" />

CLI/test/CLITest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ public void TestRDZFormatInputEncodings()
378378
[TestMethod]
379379
public void TestCustomAnalyzers()
380380
{
381-
CLITestHelper.Test("custom_analyzers", ReturnCode.Warning);
382-
CLITestHelper.Test("custom_analyzers_withcfg", ReturnCode.Warning);
381+
CLITestHelper.Test("custom_analyzers", ReturnCode.ParsingDiagnostics);
382+
CLITestHelper.Test("custom_analyzers_withcfg", ReturnCode.ParsingDiagnostics);
383383
}
384384

385385
#if EUROINFO_RULES
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
ReturnCode=Warning_
2-
6 errors in "input\CustomAnalyzers.rdz.tcbl":
1+
ReturnCode=ParsingDiagnostics_
2+
7 errors in "input\CustomAnalyzers.rdz.tcbl":
33
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummySyntaxDrivenAnalyzer': starting AST building...
44
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummySyntaxDrivenAnalyzer': finished AST building.
55
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummyQualityAnalyzer': number of tokens (after preprocessing): 32
66
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummyQualityAnalyzer': number of code elements: 9
77
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummyQualityAnalyzer': source file has 1 program(s), main program is 'DVZZMFT0'.
8+
Line 0[0,0] <46, Error, CodeAnalysis> - CodeAnalysis: analyzer 'DummyQualityAnalyzerErrorInAnalysis' failed. Exception message is 'Exception in AST analysis intended.'
89
Line 0[0,0] <45, Warning, General> - Info: CFG/DFA analysis: no control flow graph found for this file.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
ReturnCode=Warning_
2-
6 errors in "input\CustomAnalyzers.rdz.tcbl":
1+
ReturnCode=ParsingDiagnostics_
2+
7 errors in "input\CustomAnalyzers.rdz.tcbl":
33
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummySyntaxDrivenAnalyzer': starting AST building...
44
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummySyntaxDrivenAnalyzer': finished AST building.
55
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummyQualityAnalyzer': number of tokens (after preprocessing): 32
66
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummyQualityAnalyzer': number of code elements: 9
77
Line 0[0,0] <45, Warning, General> - Info: Analyzer 'DummyQualityAnalyzer': source file has 1 program(s), main program is 'DVZZMFT0'.
8+
Line 0[0,0] <46, Error, CodeAnalysis> - CodeAnalysis: analyzer 'DummyQualityAnalyzerErrorInAnalysis' failed. Exception message is 'Exception in AST analysis intended.'
89
Line 2[20,27] <45, Warning, General> - Info: CFG/DFA analysis: control flow graphs contains 2 blocks.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ReturnCode=ParsingDiagnostics_
1+
ReturnCode=ParsingDiagnostics_
22
2 errors in "input\MainPgm.rdz.tcbl":
3-
Line 15[12,20] <27, Error, Syntax> - Syntax error : Function 'DVZTEST1.GetTecMsg' expected parameter 'capt' of type DVZTEST2.Span and received 't1' of type TCOSMPL2.type1
4-
Line 18[12,20] <27, Error, Syntax> - Syntax error : Function 'GetTecMsg' expected parameter 'capt' of type DVZTEST2.Span and received 't1' of type TCOSMPL2.type1
3+
Range (15, 12) -> (16, 20) <27, Error, Syntax> - Syntax error : Function 'DVZTEST1.GetTecMsg' expected parameter 'capt' of type DVZTEST2.Span and received 't1' of type TCOSMPL2.type1
4+
Range (18, 12) -> (19, 20) <27, Error, Syntax> - Syntax error : Function 'GetTecMsg' expected parameter 'capt' of type DVZTEST2.Span and received 't1' of type TCOSMPL2.type1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ReturnCode=ParsingDiagnostics_
1+
ReturnCode=ParsingDiagnostics_
22
1 error in "input\PGM3.rdz.tcbl":
3-
Line 26[12,39] <30, Error, Semantics> - Semantic error: Function not found 'MyPublicProcedure' input(DATE)
3+
Range (26, 12) -> (27, 39) <30, Error, Semantics> - Semantic error: Function not found 'MyPublicProcedure' input(DATE)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ReturnCode=Warning_
22
6 errors in "input\DocGen.tcbl":
3-
Line 9[13,18] <37, Warning, General> - Warning: Type Definition does not support Parameters field
43
Line 9[13,18] <37, Warning, General> - Warning: Formalized comment field is declared more than once : params
54
Line 13[12,17] <37, Warning, General> - Warning: Formalized comment field is declared more than once : Params
5+
Line 9[13,18] <37, Warning, General> - Warning: Type Definition does not support Parameters field
66
Line 60[12,14] <37, Warning, General> - Warning: Parameter name does not match to any function parameter: blu
77
Line 65[21,26] <37, Warning, General> - Warning: Parameter does not have any description inside the formalized comments: myBool
88
Line 67[21,23] <37, Warning, General> - Warning: Parameter does not have any description inside the formalized comments: bli

0 commit comments

Comments
 (0)