Fix bug in `phpinspect-splayt-find-all-between' that impacted import indexation
ci/woodpecker/push/woodpecker Pipeline failed Details

master
Hugo Thunnissen 2 months ago
parent e436b3fae0
commit ea133c2044

@ -438,7 +438,7 @@ The PLACE is assigned the value of each node.
(phpinspect-splayt-node-traverse-lr (sibling (phpinspect-splayt-node-right first))
(when (>= (phpinspect-splayt-node-key sibling) key-max)
(throw 'return all))
(throw 'return (cdr all)))
(setq all-rear (setcdr all-rear (cons (phpinspect-splayt-node-value sibling) nil))))
(if (and (phpinspect-splayt-node-parent first)

@ -467,3 +467,27 @@ class YYY {
(phpinspect-buffer-project buffer)
(phpinspect--make-type :name "\\TestClass"))
"banana"))))))
(ert-deftest phpinspect-buffer-map-imports ()
(with-temp-buffer
(let ((buffer (phpinspect-make-buffer :buffer (current-buffer))))
(insert "<?php
declare(strict_types=1);
namespace App\\Controller\\Api\\V1;
use Illuminate\\Database\\Eloquent\\Model;
use Illuminate\\Database\\Eloquent\\Relations\\Relation;
use Illuminate\\Support\\Facades\\Auth;
class AccountStatisticsController {
function __construct(){}
}")
(let ((bmap (phpinspect-buffer-parse-map buffer)))
(should (equal
`((:use (:word "Illuminate\\Database\\Eloquent\\Model") (:terminator ";"))
(:use (:word "Illuminate\\Database\\Eloquent\\Relations\\Relation") (:terminator ";"))
(:use (:word "Illuminate\\Support\\Facades\\Auth") (:terminator ";")))
(mapcar #'phpinspect-meta-token
(phpinspect-splayt-to-list (phpinspect-bmap-imports bmap)))))))))

@ -172,3 +172,15 @@
(should (equal '("one" "two" "three") (phpinspect-splayt-to-list tree)))))
(ert-deftest phpinspect-splayt-find-all-between ()
(let ((tree (phpinspect-make-splayt)))
(phpinspect-splayt-insert tree 9 "nine")
(phpinspect-splayt-insert tree 3 "three")
(phpinspect-splayt-insert tree 11 "eleven")
(phpinspect-splayt-insert tree 8 "eight")
(phpinspect-splayt-insert tree 12 "twelve")
(phpinspect-splayt-insert tree 4 "four")
(phpinspect-splayt-insert tree 1 "one")
(should (equal '("three" "four") (phpinspect-splayt-find-all-between tree 1 5)))))

@ -48,4 +48,10 @@
(should (= 1 (length result-deleted)))
(should (eq tok1 (car result-deleted)))
(should (eq tok4 (car result-new))))))
(should (eq tok4 (car result-new))))
(should (equal '(token2 token3)
(mapcar #'phpinspect-meta-token (phpinspect-toc-tokens-in-region toc 0 70))))
(should (equal '(token2 token3 token4)
(mapcar #'phpinspect-meta-token (phpinspect-toc-tokens-in-region toc 0 91))))))

Loading…
Cancel
Save