Conversation
1e22083 to
f75de8a
Compare
lib/Extension/LanguageServer/Listener/IncrementalUpdateListener.php
Outdated
Show resolved
Hide resolved
lib/WorseReflection/Bridge/TolerantParser/AstProvider/IncrementalAstUpdater.php
Outdated
Show resolved
Hide resolved
lib/WorseReflection/Bridge/TolerantParser/AstProvider/IncrementalAstUpdater.php
Show resolved
Hide resolved
82fdf8c to
ae9eaeb
Compare
lib/Extension/LanguageServerWorseReflection/LanguageServerWorseReflectionExtension.php
Show resolved
Hide resolved
lib/Extension/LanguageServerWorseReflection/Listener/IncrementalAstListener.php
Show resolved
Hide resolved
a113f6a to
7a4931e
Compare
| $updatedSource = TextEdits::one($edit)->apply($this->node->getFileContents()); | ||
|
|
||
| try { | ||
| $reason = $this->doApply($node, $edit); |
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.
| $newToken = $newTokens[0]; | ||
|
|
||
| // WHY? | ||
| if (strlen($editedTokenText) !== $newToken->length) { |
| if (null === $extractStartPosition) { | ||
| $extractStartPosition = $compoundNode->openBrace->getStartPosition() + 1; | ||
| $statementNb = 0; | ||
| } |
There was a problem hiding this comment.
add comment here - can any of this code be optimised?
| use Phpactor\WorseReflection\Core\AstProvider; | ||
| use Throwable; | ||
|
|
||
| class IncrementalAstUpdater |
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
It's not clear how the token strategy can take half a second in some cases (35k lines of code) |
|
Eventually I found time to merge this PR into my working branch to at least catch possible crashes. |
it doesn't work 🙂 |
At least there was no crash or regression for over a week :) I still haven't analyzed this PR at all. |
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: