commit 0cd7ff4f88f38558a6e007d920304cf22b1db09a Author: osmedile Date: Sun May 3 19:05:51 2020 +0200 ISearchableReadOnlyList : Remove count in method GetEnumerator and remove unused method ConvertAll count in GetEnumerator was always with magic value -1 which means use the "Count" of this list. diff --git a/TypeCobol/Compiler/Concurrency/ImmutableList.cs b/TypeCobol/Compiler/Concurrency/ImmutableList.cs index 64986962d..4d5f0302c 100644 --- a/TypeCobol/Compiler/Concurrency/ImmutableList.cs +++ b/TypeCobol/Compiler/Concurrency/ImmutableList.cs @@ -358,23 +358,6 @@ namespace TypeCobol.Compiler.Concurrency /*UPDATE to MICROSOFT code ->*/ public interface ISearchableReadOnlyList : IReadOnlyList { - /// - /// Converts the elements in the current to - /// another type, and returns a list containing the converted elements. - /// - /// - /// A delegate that converts each element from - /// one type to another type. - /// - /// - /// The type of the elements of the target array. - /// - /// - /// A of the target type containing the converted - /// elements from the current . - /// - ImmutableList ConvertAll(Func converter); - /// /// Performs the specified action on each element of the list. /// @@ -538,9 +521,8 @@ namespace TypeCobol.Compiler.Concurrency /// Returns an enumerator that iterates through the collection. /// /// The index of the first element to enumerate. - /// The number of elements in this collection. /// true if the list should be enumerated in reverse order. - IEnumerator GetEnumerator(int startIndex, int count, bool reversed); + IEnumerator GetEnumerator(int startIndex, bool reversed); /// /// Searches for the specified object around the initial index of the object @@ -1674,27 +1656,6 @@ namespace TypeCobol.Compiler.Concurrency return this.Wrap(Node.NodeTreeFromList(this, index, count)); } - /// - /// Converts the elements in the current to - /// another type, and returns a list containing the converted elements. - /// - /// - /// A delegate that converts each element from - /// one type to another type. - /// - /// - /// The type of the elements of the target array. - /// - /// - /// A of the target type containing the converted - /// elements from the current . - /// - public ImmutableList ConvertAll(Func converter) - { - Requires.NotNull(converter, "converter"); - return ImmutableList.WrapNode(_root.ConvertAll(converter)); - } - /// /// Determines whether the contains elements /// that match the conditions defined by the specified predicate. @@ -2376,11 +2337,10 @@ namespace TypeCobol.Compiler.Concurrency /// Returns an enumerator that iterates through the collection. /// /// The index of the first element to enumerate. - /// The number of elements in this collection. /// true if the list should be enumerated in reverse order. - public IEnumerator GetEnumerator(int startIndex, int count, bool reversed) + public IEnumerator GetEnumerator(int startIndex, bool reversed) { - return _root.GetEnumerator(startIndex, count, reversed); + return _root.GetEnumerator(startIndex, reversed); } /// @@ -3065,6 +3025,17 @@ namespace TypeCobol.Compiler.Concurrency // --- START of EXTENSION to MICROSOFT code --- // --- Methods added for TypeCobol --- + /// + /// Returns an enumerator that iterates through the collection. + /// + /// The index of the first element to enumerate. + /// true if the list should be enumerated in reverse order. + internal Enumerator GetEnumerator(int startIndex, bool reversed) + { + return new Enumerator(this, null, startIndex, -1, reversed); + } + + /// /// Returns an enumerator that iterates through the collection. /// @@ -4650,11 +4621,10 @@ namespace TypeCobol.Compiler.Concurrency /// Returns an enumerator that iterates through the collection. /// /// The index of the first element to enumerate. - /// The number of elements in this collection. /// true if the list should be enumerated in reverse order. - public IEnumerator GetEnumerator(int startIndex, int count, bool reversed) + public IEnumerator GetEnumerator(int startIndex, bool reversed) { - return this.Root.GetEnumerator(startIndex, count, reversed); + return this.Root.GetEnumerator(startIndex, reversed); } /// @@ -4777,27 +4747,6 @@ namespace TypeCobol.Compiler.Concurrency return ImmutableList.WrapNode(Node.NodeTreeFromList(this, index, count)); } - /// - /// Converts the elements in the current ImmutableList<T> to - /// another type, and returns a list containing the converted elements. - /// - /// - /// A System.Converter<TInput,TOutput> delegate that converts each element from - /// one type to another type. - /// - /// - /// The type of the elements of the target array. - /// - /// - /// A ImmutableList<T> of the target type containing the converted - /// elements from the current ImmutableList<T>. - /// - public ImmutableList ConvertAll(Func converter) - { - Requires.NotNull(converter, "converter"); - return ImmutableList.WrapNode(_root.ConvertAll(converter)); - } - /// /// Determines whether the ImmutableList<T> contains elements /// that match the conditions defined by the specified predicate. diff --git a/TypeCobol/Compiler/Parser/CodeElementsParserStep.cs b/TypeCobol/Compiler/Parser/CodeElementsParserStep.cs index a0b18ef01..ec71d4e39 100644 --- a/TypeCobol/Compiler/Parser/CodeElementsParserStep.cs +++ b/TypeCobol/Compiler/Parser/CodeElementsParserStep.cs @@ -454,7 +454,7 @@ namespace TypeCobol.Compiler.Parser { int previousLineIndex = lineIndex; int lastLineIndexReset = lastParseSection != null ? lastParseSection.StopLineIndex : -1; - IEnumerator reversedEnumerator = documentLines.GetEnumerator(previousLineIndex - 1, -1, true); + IEnumerator reversedEnumerator = documentLines.GetEnumerator(previousLineIndex - 1, true); bool previousLineHasCodeElements = false; while (reversedEnumerator.MoveNext() && (--previousLineIndex > lastLineIndexReset)) { @@ -502,7 +502,7 @@ namespace TypeCobol.Compiler.Parser if (lineIndex < (documentLines.Count - 1)) { int nextLineIndex = lineIndex; - IEnumerator enumerator = documentLines.GetEnumerator(nextLineIndex + 1, -1, false); + IEnumerator enumerator = documentLines.GetEnumerator(nextLineIndex + 1, false); bool nextLineHasCodeElements = false; //---------------------------------------------------------------------------- // Because we use multi line comments once we have figure out diff --git a/TypeCobol/Compiler/Preprocessor/PreprocessorStep.cs b/TypeCobol/Compiler/Preprocessor/PreprocessorStep.cs index a9a43c1e1..3e64f0e4e 100644 --- a/TypeCobol/Compiler/Preprocessor/PreprocessorStep.cs +++ b/TypeCobol/Compiler/Preprocessor/PreprocessorStep.cs @@ -391,7 +391,7 @@ namespace TypeCobol.Compiler.Preprocessor if (lineIndex > 0) { int previousLineIndex = lineIndex; - IEnumerator reversedEnumerator = documentLines.GetEnumerator(previousLineIndex - 1, -1, true); + IEnumerator reversedEnumerator = documentLines.GetEnumerator(previousLineIndex - 1, true); while (reversedEnumerator.MoveNext() && (--previousLineIndex > lastLineIndexReset)) { // Get the previous line until a non continued line is encountered @@ -426,7 +426,7 @@ namespace TypeCobol.Compiler.Preprocessor if (lineIndex < (documentLines.Count - 1)) { int nextLineIndex = lineIndex; - IEnumerator enumerator = documentLines.GetEnumerator(nextLineIndex + 1, -1, true); + IEnumerator enumerator = documentLines.GetEnumerator(nextLineIndex + 1, true); while (enumerator.MoveNext()) { // Get the next line until non continuation line is encountered diff --git a/TypeCobol/Compiler/Scanner/ScannerStep.cs b/TypeCobol/Compiler/Scanner/ScannerStep.cs index 8d16cdbb5..0a3b899a7 100644 --- a/TypeCobol/Compiler/Scanner/ScannerStep.cs +++ b/TypeCobol/Compiler/Scanner/ScannerStep.cs @@ -276,7 +276,7 @@ namespace TypeCobol.Compiler.Scanner if (lineToScan.Type == CobolTextLineType.Continuation && lineToScanIndex > 0) { int revLineToScanIndex = lineToScanIndex; - using (var reversedEnumerator = documentLines.GetEnumerator(lineToScanIndex - 1, -1, true)) + using (var reversedEnumerator = documentLines.GetEnumerator(lineToScanIndex - 1, true)) { while (reversedEnumerator.MoveNext()) { @@ -313,7 +313,7 @@ namespace TypeCobol.Compiler.Scanner // Navigate forwards to the end of the multiline continuation if (lineToScanIndex < (documentLines.Count - 1)) { - using (var enumerator = documentLines.GetEnumerator(lineToScanIndex + 1, -1, false)) + using (var enumerator = documentLines.GetEnumerator(lineToScanIndex + 1, false)) { while (enumerator.MoveNext()) {