Skip to content

Commit 116d73e

Browse files
committed
[TASK] Remove LinesIterator from DocumentParserContext
The current content is now handled in the BlockContext
1 parent c3da057 commit 116d73e

File tree

6 files changed

+2
-16
lines changed

6 files changed

+2
-16
lines changed

packages/guides-restructured-text/src/RestructuredText/MarkupLanguageParser.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public function parse(ParserContext $parserContext, string $contents): DocumentN
7676
$this->parserContext = $parserContext;
7777

7878
$this->documentParser = new DocumentParserContext(
79-
$contents,
8079
$parserContext,
8180
$this->textRoleFactory,
8281
$this,

packages/guides-restructured-text/src/RestructuredText/Parser/DocumentParserContext.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class DocumentParserContext
2929
public bool $nextIndentedBlockShouldBeALiteralBlock = false;
3030

3131
public DocumentNode|null $document = null;
32-
33-
private LinesIterator $documentIterator;
32+
3433
private int $currentTitleLevel;
3534
/* Each Document has its own text role factory as text roles can be changed on a per document base
3635
by directives */
@@ -40,14 +39,11 @@ class DocumentParserContext
4039
private array $titleLetters = [];
4140

4241
public function __construct(
43-
string $content,
4442
private readonly ParserContext $context,
4543
TextRoleFactory $textRoleFactory,
4644
private readonly MarkupLanguageParser $markupLanguageParser,
4745
) {
48-
$this->documentIterator = new LinesIterator();
4946
$this->textRoleFactoryForDocument = clone $textRoleFactory;
50-
$this->documentIterator->load($content);
5147
$this->currentTitleLevel = $context->getInitialHeaderLevel() - 1;
5248
}
5349

@@ -79,12 +75,7 @@ public function setDocument(DocumentNode $document): void
7975
{
8076
$this->document = $document;
8177
}
82-
83-
public function getDocumentIterator(): LinesIterator
84-
{
85-
return $this->documentIterator;
86-
}
87-
78+
8879
public function getLevel(string $overlineLetter, string $underlineLetter): int
8980
{
9081
$letter = $overlineLetter . ':' . $underlineLetter;

packages/guides-restructured-text/tests/unit/Parser/InlineTokenParserTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public function setUp(): void
6060
],
6161
);
6262
$this->documentParserContext = new DocumentParserContext(
63-
'',
6463
$this->createStub(ParserContext::class),
6564
$this->textRoleFactory,
6665
$this->createStub(MarkupLanguageParser::class),

packages/guides-restructured-text/tests/unit/Parser/Productions/InlineRules/TextRoleRuleTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public function __construct(
9393
$textRoleRule = new TextRoleRule();
9494
self::assertTrue($textRoleRule->applies($lexer));
9595
$documentParserContext = new DocumentParserContext(
96-
'',
9796
$this->createStub(ParserContext::class),
9897
$textRoleFactory,
9998
$this->createStub(MarkupLanguageParser::class),

packages/guides-restructured-text/tests/unit/Parser/Productions/RuleTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ protected function createContext(string $input): BlockContext
4444
new UrlGenerator(),
4545
);
4646
$documentParserContext = new DocumentParserContext(
47-
$input,
4847
$parserContext,
4948
$this->createStub(TextRoleFactory::class),
5049
$this->createStub(MarkupLanguageParser::class),

packages/guides-restructured-text/tests/unit/Parser/Productions/SectionRuleTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ private function getDocumentParserContext(string $content): BlockContext
200200
);
201201

202202
$documentParserContext = new DocumentParserContext(
203-
$content,
204203
$parserContext,
205204
$this->createStub(TextRoleFactory::class),
206205
$this->createStub(MarkupLanguageParser::class),

0 commit comments

Comments
 (0)