Open
Conversation
1e22083 to
f75de8a
Compare
dantleech
commented
Dec 31, 2025
lib/Extension/LanguageServer/Listener/IncrementalUpdateListener.php
Outdated
Show resolved
Hide resolved
dantleech
commented
Dec 31, 2025
lib/WorseReflection/Bridge/TolerantParser/AstProvider/IncrementalAstUpdater.php
Outdated
Show resolved
Hide resolved
dantleech
commented
Dec 31, 2025
lib/WorseReflection/Bridge/TolerantParser/AstProvider/IncrementalAstUpdater.php
Show resolved
Hide resolved
82fdf8c to
ae9eaeb
Compare
dantleech
commented
Jan 1, 2026
dantleech
commented
Jan 1, 2026
dantleech
commented
Jan 1, 2026
lib/Extension/LanguageServerWorseReflection/LanguageServerWorseReflectionExtension.php
Show resolved
Hide resolved
dantleech
commented
Jan 1, 2026
lib/Extension/LanguageServerWorseReflection/Listener/IncrementalAstListener.php
Show resolved
Hide resolved
a113f6a to
7a4931e
Compare
dantleech
commented
Jan 4, 2026
| $updatedSource = TextEdits::one($edit)->apply($this->node->getFileContents()); | ||
|
|
||
| try { | ||
| $reason = $this->doApply($node, $edit); |
Collaborator
Author
There was a problem hiding this comment.
maybe add a Result object here that can both indicate failure and success. i.e. the log should show:
PARS incremetal parse used (compound statement node)
the V/O should also make debug messages better.
dantleech
commented
Jan 4, 2026
| $newToken = $newTokens[0]; | ||
|
|
||
| // WHY? | ||
| if (strlen($editedTokenText) !== $newToken->length) { |
dantleech
commented
Jan 4, 2026
| if (null === $extractStartPosition) { | ||
| $extractStartPosition = $compoundNode->openBrace->getStartPosition() + 1; | ||
| $statementNb = 0; | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
add comment here - can any of this code be optimised?
dantleech
commented
Jan 4, 2026
| use Phpactor\WorseReflection\Core\AstProvider; | ||
| use Throwable; | ||
|
|
||
| class IncrementalAstUpdater |
Collaborator
Author
There was a problem hiding this comment.
it would be beneficial to add a benchmark
ebc04b2 to
a76c930
Compare
Introduces an opt-in to enable experimental incremental parser updates. When enabled the IDE will send text edits for each change to the LS instead of the full text. These text edits will be applied directly to the AST if possible and if not will cause a full reparsing.
a76c930 to
ba16755
Compare
Collaborator
Author
It's not clear how the token strategy can take half a second in some cases (35k lines of code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to introduce a level of incremental parsing for the Tolerant PHP Parser.
Currently:
$,a,bandc.completionrequests to PhpactorWith this change two strategies are employed to avoid reparsing:
In Token Changes
$,a,bandccedit is within aVariableNametoken and thatwhen the edit is applied to the previous token we go from
$abto$abcand
$abcis also a variable name token so we can just update it.Compound Node Edits
{}braces)Affect
In certain situations this can result in a 2x or more speed increase, especially in large, complex, files because:
Things become more difficult if more context is required (e.g.
public function foois meaningless without the surrounding class construct) but in those cases they could, I suppose, be artificially supported.TODO: