diff --git a/src/Peachpie.CodeAnalysis/Syntax/PhpSourceUnit.cs b/src/Peachpie.CodeAnalysis/Syntax/PhpSourceUnit.cs index 56b66851e9..ffc18740db 100644 --- a/src/Peachpie.CodeAnalysis/Syntax/PhpSourceUnit.cs +++ b/src/Peachpie.CodeAnalysis/Syntax/PhpSourceUnit.cs @@ -63,11 +63,6 @@ public override void Parse(INodesFactory factory, IErrorSink< Parse((NodesFactory)factory, errors, recovery, LanguageFeatures.Basic, Lexer.LexicalStates.INITIAL); } - static ILineBreaks CreateLineBreaks(SourceText source) - { - return Devsense.PHP.Text.LineBreaks.Create( - source.ToString(), - source.Lines.Select(line => line.EndIncludingLineBreak).ToList()); - } + static ILineBreaks CreateLineBreaks(SourceText source) => new SourceLineBreaks(source); } } diff --git a/src/Peachpie.CodeAnalysis/Syntax/SourceLineBreaks.cs b/src/Peachpie.CodeAnalysis/Syntax/SourceLineBreaks.cs new file mode 100644 index 0000000000..7d88223a78 --- /dev/null +++ b/src/Peachpie.CodeAnalysis/Syntax/SourceLineBreaks.cs @@ -0,0 +1,22 @@ +using Devsense.PHP.Text; +using Microsoft.CodeAnalysis.Text; + +namespace Peachpie.CodeAnalysis.Syntax +{ + /// + /// Implements of . + /// + sealed class SourceLineBreaks : LineBreaks + { + private readonly SourceText/*!*/_source; + + public SourceLineBreaks(SourceText source) : base(source.Length) + { + _source = source; + } + + public override int EndOfLineBreak(int index) => _source.Lines[index].EndIncludingLineBreak; + + public override int Count => _source.Lines.Count - 1; + } +} \ No newline at end of file