From f785f67ca89a1a10258268f7e85440a0235f4d39 Mon Sep 17 00:00:00 2001 From: N1ebieski Date: Sat, 15 Mar 2025 08:49:58 +0000 Subject: [PATCH] Add VariableParser and VariableContext Fixes N1ebieski/vs-code-php-parser-cli#5 --- app/Contexts/Variable.php | 22 +++++++++++++++++ app/Parsers/VariableParser.php | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 app/Contexts/Variable.php create mode 100644 app/Parsers/VariableParser.php diff --git a/app/Contexts/Variable.php b/app/Contexts/Variable.php new file mode 100644 index 0000000..4b691fc --- /dev/null +++ b/app/Contexts/Variable.php @@ -0,0 +1,22 @@ + $this->name, + ]; + } +} diff --git a/app/Parsers/VariableParser.php b/app/Parsers/VariableParser.php new file mode 100644 index 0000000..e0fd7bc --- /dev/null +++ b/app/Parsers/VariableParser.php @@ -0,0 +1,43 @@ +context->name = $node->getName(); + + if (Settings::$capturePosition) { + $range = PositionUtilities::getRangeFromPosition( + $node->getStartPosition(), + mb_strlen($node->getText()), + $node->getRoot()->getFullText(), + ); + + if (Settings::$calculatePosition !== null) { + $range = Settings::adjustPosition($range); + } + + $this->context->setPosition($range); + } + + return $this->context; + } + + public function initNewContext(): ?AbstractContext + { + return new VariableContext; + } +}