@@ -371,7 +371,7 @@ declare function declareFunctionDefn(x3: xty3, y3: yty3): ret3;"
371
371
(" exportedDefaultDefn" . font-lock-function-name-face )
372
372
(" declareFunctionDefn" . font-lock-function-name-face )
373
373
((" x0" " x1" " x2" " x3" ) . font-lock-variable-name-face )
374
- ((" y0 " " y1 " " y2 " " y3 " ) . font-lock-variable-name-face )
374
+ ((" \\ by0 " " \\ by1 " " \\ by2 " " \\ by3 " ) . font-lock-variable-name-face )
375
375
((" ret0" " ret1" " ret2" " ret3" ) . nil ))))
376
376
377
377
(ert-deftest font-lock/level-four ()
@@ -393,7 +393,7 @@ snake_cased_function(1, 2, 3)"
393
393
(" methodCall" . font-lock-function-name-face )
394
394
(" snake_cased_function" . font-lock-function-name-face )
395
395
((" string" " boolean" " number" " any" ) . typescript-primitive-face)
396
- ((" endpoint" " data" ) . nil )
396
+ ((" endpoint" " data" ) . font-lock-variable-name-face )
397
397
((" <" " >" " ," ) . nil ))))
398
398
399
399
(ert-deftest font-lock/method-call-with-keyword-name ()
@@ -621,19 +621,24 @@ should be fontified as variable, keyword and type."
621
621
(should (eq (get-face-at " Namespaced" ) 'font-lock-type-face ))
622
622
(should (eq (get-face-at " ClassName" ) 'font-lock-type-face ))))
623
623
624
- (ert-deftest font-lock/variables-in-declaration -multiline-with-types ()
624
+ (ert-deftest font-lock/funargs--function- -multiline-with-types ()
625
625
" Variables should be highlighted in multiline declarations with types."
626
626
(test-with-fontified-buffer
627
627
" function test(
628
- var1: Type1,
629
- var2: Type2,
628
+ var1: Promise<U1, V1>,
629
+ var2: (xxx: Foo) => Bar,
630
+ var3: Type3,
630
631
): RetType {\n }"
631
632
(should (eq (get-face-at " var1" ) 'font-lock-variable-name-face ))
632
633
(should (eq (get-face-at " var2" ) 'font-lock-variable-name-face ))
633
- (should (eq (get-face-at " Type1" ) 'font-lock-type-face ))
634
- (should (eq (get-face-at " Type2" ) 'font-lock-type-face ))))
634
+ (should (eq (get-face-at " var3" ) 'font-lock-variable-name-face ))
635
+ (should (eq (get-face-at " xxx" ) 'font-lock-variable-name-face ))
636
+ (should (eq (get-face-at " Promise" ) 'font-lock-type-face ))
637
+ (should (eq (get-face-at " U1" ) 'font-lock-type-face ))
638
+ (should (eq (get-face-at " Foo" ) 'font-lock-type-face ))
639
+ (should (eq (get-face-at " Type3" ) 'font-lock-type-face ))))
635
640
636
- (ert-deftest font-lock/variables-in-declaration -multiline-without-types ()
641
+ (ert-deftest font-lock/funargs--function- -multiline-without-types ()
637
642
" Variables should be highlighted in multiline declarations without types."
638
643
(test-with-fontified-buffer
639
644
" function test(
@@ -643,33 +648,33 @@ var2,
643
648
(should (eq (get-face-at " var1" ) 'font-lock-variable-name-face ))
644
649
(should (eq (get-face-at " var2" ) 'font-lock-variable-name-face ))))
645
650
646
- (ert-deftest font-lock/variables-in-declaration-multiline-no -hanging-paren ()
647
- " Variables should be highlighted in multiline declarations with no hanging paren."
651
+ (ert-deftest font-lock/funargs--function--multiline -hanging-paren ()
652
+ " Variables should be highlighted in multiline declarations with hanging paren."
648
653
(test-with-fontified-buffer
649
654
" function test(
650
655
var1,
651
656
var2): RetType {\n }"
652
657
(should (eq (get-face-at " var1" ) 'font-lock-variable-name-face ))
653
658
(should (eq (get-face-at " var2" ) 'font-lock-variable-name-face ))))
654
659
655
- (ert-deftest font-lock/variables-in-declaration- multiline-ending-comma-no -hanging-paren ()
656
- " Variables should be highlighted in multiline declarations with no hanging paren and trailing comma."
660
+ (ert-deftest font-lock/funargs--function-- multiline-ending-comma-hanging-paren ()
661
+ " Variables should be highlighted in multiline declarations with hanging paren and trailing comma."
657
662
(test-with-fontified-buffer
658
663
" function test(
659
664
var1,
660
665
var2,): RetType {\n }"
661
666
(should (eq (get-face-at " var1" ) 'font-lock-variable-name-face ))
662
667
(should (eq (get-face-at " var2" ) 'font-lock-variable-name-face ))))
663
668
664
- (ert-deftest font-lock/variables-in-declaration- singleline-ending-comma-hanging-paren ()
665
- " Variables should be highlighted in singleline declarations with hanging paren and trailing comma."
669
+ (ert-deftest font-lock/funargs--function-- singleline-ending-comma-no -hanging-paren ()
670
+ " Variables should be highlighted in singleline declarations with no hanging paren and trailing comma."
666
671
(test-with-fontified-buffer
667
672
" function test(var1,var2,
668
673
): RetType {\n }"
669
674
(should (eq (get-face-at " var1" ) 'font-lock-variable-name-face ))
670
675
(should (eq (get-face-at " var2" ) 'font-lock-variable-name-face ))))
671
676
672
- (ert-deftest font-lock/variables-in-declaration -singleline-with-types ()
677
+ (ert-deftest font-lock/funargs--function- -singleline-with-types ()
673
678
" Variables should be highlighted in singleline declarations with types."
674
679
(test-with-fontified-buffer
675
680
" function test(var1: Foo, var2: Bar,): RetType {\n }"
@@ -678,13 +683,165 @@ var2,): RetType {\n}"
678
683
(should (eq (get-face-at " Foo" ) 'font-lock-type-face ))
679
684
(should (eq (get-face-at " Bar" ) 'font-lock-type-face ))))
680
685
681
- (ert-deftest font-lock/variables-in-declaration- singleline-ending-comma-no -hanging-paren ()
682
- " Variables should be highlighted in singleline declarations with no hanging paren and trailing comma."
686
+ (ert-deftest font-lock/funargs--function-- singleline-ending-comma-hanging-paren ()
687
+ " Variables should be highlighted in singleline declarations with hanging paren and trailing comma."
683
688
(test-with-fontified-buffer
684
689
" function test(var1,var2,): RetType {\n }"
685
690
(should (eq (get-face-at " var1" ) 'font-lock-variable-name-face ))
686
691
(should (eq (get-face-at " var2" ) 'font-lock-variable-name-face ))))
687
692
693
+ (ert-deftest font-lock/funargs--function--keywords-as-variables ()
694
+ " Keywords when used as variables should have variable face"
695
+ (test-with-fontified-buffer
696
+ " function test(type, unknown): void {}"
697
+ (should (eq (get-face-at " type" ) 'font-lock-variable-name-face ))
698
+ (should (eq (get-face-at " unknown" ) 'font-lock-variable-name-face ))))
699
+
700
+ (ert-deftest font-lock/funargs--arrow--keywords-as-variables ()
701
+ " Keywords when used as variables should have variable face"
702
+ (test-with-fontified-buffer
703
+ " const test = (type, unknown): void => {}"
704
+ (should (eq (get-face-at " type" ) 'font-lock-variable-name-face ))
705
+ (should (eq (get-face-at " unknown" ) 'font-lock-variable-name-face ))))
706
+
707
+ (ert-deftest font-lock/funargs--arrow--single-line--no-type ()
708
+ (test-with-fontified-buffer
709
+ " const test = (aaa, bbb, ccc): void => {}"
710
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
711
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
712
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))))
713
+
714
+ (ert-deftest font-lock/funargs--arrow--single-line--no-type--no-return-type ()
715
+ (test-with-fontified-buffer
716
+ " const test = (aaa, bbb, ccc) => {}"
717
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
718
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
719
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))))
720
+
721
+ (ert-deftest font-lock/funargs--arrow--single-line--no-type--trailing-comma ()
722
+ (test-with-fontified-buffer
723
+ " const test = (aaa, bbb, ccc,): void => {}"
724
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
725
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
726
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))))
727
+
728
+ (ert-deftest font-lock/funargs--arrow--single-line--no-type--optional ()
729
+ (test-with-fontified-buffer
730
+ " const test = (aaa, bbb?): void => {}"
731
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
732
+ (should (eq (get-face-at " bbb?" ) 'font-lock-variable-name-face ))))
733
+
734
+ (ert-deftest font-lock/funargs--arrow--multiline--no-type ()
735
+ (test-with-fontified-buffer
736
+ " const test = (aaa, bbb,
737
+ ccc, ddd): void => {}"
738
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
739
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
740
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))
741
+ (should (eq (get-face-at " ddd" ) 'font-lock-variable-name-face ))))
742
+
743
+ (ert-deftest font-lock/funargs--arrow--multiline--no-type--newline-after-last ()
744
+ (test-with-fontified-buffer
745
+ " const test = (aaa, bbb,
746
+ ccc, ddd
747
+ ): void => {}"
748
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
749
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
750
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))
751
+ (should (eq (get-face-at " ddd" ) 'font-lock-variable-name-face ))))
752
+
753
+ (ert-deftest font-lock/funargs--arrow--multiline--no-type--newline-before-first ()
754
+ (test-with-fontified-buffer
755
+ " const test = (
756
+ aaa, bbb,
757
+ ccc, ddd
758
+ ): void => {}"
759
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
760
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
761
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))
762
+ (should (eq (get-face-at " ddd" ) 'font-lock-variable-name-face ))))
763
+
764
+ (ert-deftest font-lock/funargs--arrow--multiline--no-type--with-comment ()
765
+ (test-with-fontified-buffer
766
+ " const test = (
767
+ aaa, bbb, // comment
768
+ ccc, ddd // comment
769
+ ): void => {}"
770
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
771
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
772
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))
773
+ (should (eq (get-face-at " ddd" ) 'font-lock-variable-name-face ))))
774
+
775
+ (ert-deftest font-lock/funargs--arrow--single--mixed-type--newline-before-first ()
776
+ (test-with-fontified-buffer
777
+ " const test = (aaa, bbb: Promise, ccc: number, ddd): void => {}"
778
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
779
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
780
+ (should (eq (get-face-at " ccc" ) 'font-lock-variable-name-face ))
781
+ (should (eq (get-face-at " ddd" ) 'font-lock-variable-name-face ))
782
+ (should (eq (get-face-at " Promise" ) 'font-lock-type-face ))
783
+ (should (eq (get-face-at " number" ) 'typescript-primitive-face ))))
784
+
785
+ (ert-deftest font-lock/funargs--arrow--single--with-type--complex-type ()
786
+ (test-with-fontified-buffer
787
+ " const test = (aaa: Promise<U, V, (xxx: A) => Foo>, bbb): void => {}"
788
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
789
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
790
+ (should (eq (get-face-at " xxx" ) 'font-lock-variable-name-face ))))
791
+
792
+ (ert-deftest font-lock/funargs--arrow--multiline--with-type--newline-before-first-after-last ()
793
+ (test-with-fontified-buffer
794
+ " const test = (
795
+ aaa: Foo,
796
+ bbb: Bar
797
+ ): void => {}"
798
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
799
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
800
+ (should (eq (get-face-at " Foo" ) 'font-lock-type-face ))
801
+ (should (eq (get-face-at " Bar" ) 'font-lock-type-face ))))
802
+
803
+ (ert-deftest font-lock/funargs--arrow--multiline--with-type--newline-before-first-after-last--hanging-comma ()
804
+ (test-with-fontified-buffer
805
+ " const test = (
806
+ aaa: Foo,
807
+ bbb: Bar,
808
+ ): void => {}"
809
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
810
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
811
+ (should (eq (get-face-at " Foo" ) 'font-lock-type-face ))
812
+ (should (eq (get-face-at " Bar" ) 'font-lock-type-face ))))
813
+
814
+ (ert-deftest font-lock/funargs--method--multiline--with-type ()
815
+ (test-with-fontified-buffer
816
+ " class Foo { foo(
817
+ aaa: Foo,
818
+ bbb: Bar,
819
+ ): void {}"
820
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
821
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
822
+ (should (eq (get-face-at " Foo" ) 'font-lock-type-face ))
823
+ (should (eq (get-face-at " Bar" ) 'font-lock-type-face ))))
824
+
825
+ (ert-deftest font-lock/funargs--method--single-line--with-type ()
826
+ (test-with-fontified-buffer
827
+ " class Foo { foo(aaa: Foo,bbb: Bar,): void {}"
828
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
829
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))
830
+ (should (eq (get-face-at " Foo" ) 'font-lock-type-face ))
831
+ (should (eq (get-face-at " Bar" ) 'font-lock-type-face ))))
832
+
833
+ (ert-deftest font-lock/funargs--method--single-line--no-type ()
834
+ (test-with-fontified-buffer
835
+ " class Foo { foo(aaa, bbb): void {}"
836
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
837
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))))
838
+
839
+ (ert-deftest font-lock/funargs--method--single-line--no-return-type ()
840
+ (test-with-fontified-buffer
841
+ " class Foo { foo(aaa, bbb) {}"
842
+ (should (eq (get-face-at " aaa" ) 'font-lock-variable-name-face ))
843
+ (should (eq (get-face-at " bbb" ) 'font-lock-variable-name-face ))))
844
+
688
845
(defun flyspell-predicate-test (search-for )
689
846
" This function runs a test on
690
847
`typescript--flyspell-mode-predicate' . `SEARCH-FOR' is a string
0 commit comments