Bmap approach mostly working now
parent
fc46349bfe
commit
67fd01e68d
@ -0,0 +1,32 @@
|
||||
|
||||
(require 'phpinspect-parser)
|
||||
|
||||
(ert-deftest phpinspect-parse-bmap ()
|
||||
(let* ((ctx (phpinspect-make-pctx :incremental t))
|
||||
(code "
|
||||
class TestClass {
|
||||
public function getCurrentStatisticAction(): JsonResponse
|
||||
{
|
||||
$statistic = $this->repository->getCurrentStatistic();
|
||||
if (!$this->authorization->isGranted(EntityAction::VIEW, $statistic)) {
|
||||
return $this->responder->respondUnauthorized();
|
||||
}
|
||||
|
||||
return $this->responder->respond($statistic);
|
||||
}
|
||||
}")
|
||||
(bmap))
|
||||
(phpinspect-with-parse-context ctx
|
||||
(phpinspect-parse-string code))
|
||||
(setq bmap (phpinspect-pctx-bmap ctx))
|
||||
|
||||
(let ((enclosing (phpinspect-bmap-tokens-overlapping bmap 350))
|
||||
(parent))
|
||||
(should enclosing)
|
||||
(should (phpinspect-variable-p (phpinspect-meta-token (car enclosing))))
|
||||
(should (string= "statistic" (cadr (phpinspect-meta-token (car enclosing)))))
|
||||
(should (phpinspect-meta-parent (car enclosing)))
|
||||
|
||||
(setq parent (phpinspect-meta-parent (car enclosing)))
|
||||
(should (phpinspect-list-p (phpinspect-meta-token parent)))
|
||||
(should (phpinspect-block-p (phpinspect-meta-token (phpinspect-meta-parent parent)))))))
|
@ -0,0 +1,27 @@
|
||||
|
||||
(require 'phpinspect)
|
||||
|
||||
(ert-deftest phinspect-get-resolvecontext ()
|
||||
(let* ((ctx (phpinspect-make-pctx :incremental t))
|
||||
(code "
|
||||
class TestClass {
|
||||
public function getCurrentStatisticAction(): JsonResponse
|
||||
{
|
||||
$statistic = $this->repository->getCurrentStatistic();
|
||||
if (!$this->authorization->isGranted(EntityAction::VIEW, $statistic)) {
|
||||
return $this->responder->respondUnauthorized();
|
||||
}
|
||||
|
||||
$this->
|
||||
|
||||
return $this->responder->respond($statistic);
|
||||
}
|
||||
}")
|
||||
(bmap))
|
||||
(phpinspect-with-parse-context ctx
|
||||
(phpinspect-parse-string code))
|
||||
(setq bmap (phpinspect-pctx-bmap ctx))
|
||||
|
||||
(let ((rctx (phpinspect-get-resolvecontext bmap 317)))
|
||||
(should (phpinspect--resolvecontext-subject rctx))
|
||||
(should (phpinspect--resolvecontext-enclosing-tokens rctx)))))
|
Loading…
Reference in New Issue