branch: externals/matlab-mode
commit d361697444185580ec732aa8a0a556f53387c9e5
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode: use builtin face on validator functions, etc.
---
matlab-ts-mode.el | 177 ++++++++++-----------
.../font_lock_class_enum_expected.txt | 2 +-
.../font_lock_class_events_expected.txt | 2 +-
.../font_lock_class_properties_expected.txt | 2 +-
.../font_lock_comment_fcn_expected.txt | 2 +-
.../font_lock_enum_FlowRate_expected.txt | 2 +-
.../font_lock_fcn_arguments2_issue57_expected.txt | 4 +-
.../font_lock_fcn_arguments_expected.txt | 8 +-
.../font_lock_keywords_as_others2_expected.txt | 6 +-
.../font_lock_keywords_expected.txt | 2 +-
..._validation_fcns_with_args_issue78_expected.txt | 4 +-
11 files changed, 103 insertions(+), 108 deletions(-)
diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index d15ab0ecba..208c4c6cd0 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -712,6 +712,88 @@ Example, disp variable is overriding the disp builtin
functin:
:feature 'keyword
`([,@matlab-ts-mode--keywords] @font-lock-keyword-face)
+ ;; F-Rule: variable
+ ;; Could add font-lock-variable-name-face to variable uses. Consider
+ ;; i1 = [1, 2];
+ ;; i2 = i1(1) + i3 + i4(i3);
+ ;; we know i1 and i2 are variables from the (assignment left: (identifier))
+ ;; However, we don't know if i3 or i4 are variables or functions because a
function
+ ;; can be called with no arguments, e.g. to call i3 function use i3 or
i3(). i4 could
+ ;; be a variable indexed by i1 or a function.
+ ;;
+ ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_variable.m
+ :language 'matlab
+ :feature 'variable
+ '(((assignment left: (identifier)
@matlab-ts-mode-variable-override-builtin-face
+ (:pred matlab-ts-mode--is-variable-overriding-builtin
+ @matlab-ts-mode-variable-override-builtin-face)))
+ (assignment left: (identifier) @font-lock-variable-name-face)
+ (multioutput_variable (identifier)
@matlab-ts-mode-variable-override-builtin-face
+ (:pred matlab-ts-mode--is-variable-overriding-builtin
+ @matlab-ts-mode-variable-override-builtin-face))
+ (multioutput_variable (identifier) @font-lock-variable-name-face)
+ (global_operator (identifier)
@matlab-ts-mode-variable-override-builtin-face
+ (:pred matlab-ts-mode--is-variable-overriding-builtin
+ @matlab-ts-mode-variable-override-builtin-face))
+ (global_operator (identifier) @font-lock-variable-name-face)
+ (persistent_operator (identifier)
@matlab-ts-mode-variable-override-builtin-face
+ (:pred matlab-ts-mode--is-variable-overriding-builtin
+ @matlab-ts-mode-variable-override-builtin-face))
+ (persistent_operator (identifier) @font-lock-variable-name-face)
+ (for_statement (iterator (identifier)
@matlab-ts-mode-variable-override-builtin-face
+ (:pred
matlab-ts-mode--is-variable-overriding-builtin
+
@matlab-ts-mode-variable-override-builtin-face)))
+ (for_statement (iterator (identifier) @font-lock-variable-name-face))
+ ;; Function inputs: functionName(in1, in2, in3)
+ ;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_small_in_args.m
+ (function_arguments arguments:
+ (identifier) @font-lock-variable-name-face
+ ("," (identifier) @font-lock-variable-name-face) :*)
+ ;; Function single output argument: function out = functionName(in1, in2)
+ ;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_small_out_args.m
+ (function_output (identifier) @font-lock-variable-name-face)
+ ;; Function multiple output arguments: function [out1, out2] =
functionName(in1, in2)
+ (function_output (multioutput_variable (identifier)
@font-lock-variable-name-face))
+ ;; Enumeration's
+ ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_class_enum.m
+ ;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_enum_FlowRate.m
+ (enum (identifier) @matlab-ts-mode-property-face)
+ ;; Events block in classdef
+ ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_class_events.m
+ (events (identifier) @matlab-ts-mode-property-face))
+
+ ;; F-Rule: Types, e.g. int32()
+ :language 'matlab
+ :feature 'type
+ `((function_call name: (identifier)
+ @font-lock-type-face
+ (:match ,(rx-to-string `(seq bos
+ (or
,@matlab-ts-mode--type-functions)
+ eos)
+ t)
+ @font-lock-type-face))
+ (property name: (identifier) (identifier) @font-lock-type-face :?)
+ (property name: (property_name (identifier)) (identifier)
@font-lock-type-face :?))
+
+
+ ;; F-Rule: factory items that come with MATLAB, Simulink, or add-on products
+ ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_builtins.m
+ :language 'matlab
+ :feature 'builtins
+ `(((identifier) @font-lock-builtin-face
+ (:pred matlab-ts-mode--is-identifier-builtin @font-lock-builtin-face))
+ ((command_name) @font-lock-builtin-face
+ (:pred matlab-ts-mode--is-command-builtin @font-lock-builtin-face))
+ ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_boolean.m
+ ((boolean) @font-lock-builtin-face))
+
+ ;; F-Rule: namespaces (the +dir's, class methods, etc.)
+ ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_namespaces.m
+ :language 'matlab
+ :feature 'namespace-builtins
+ :override t
+ `((field_expression) @matlab-ts-mode--namespace-builtins-capture)
+
;; F-Rule: function/classdef and items defining them, e.g. the function
arguments
:language 'matlab
:feature 'definition
@@ -725,16 +807,6 @@ Example, disp variable is overriding the disp builtin
functin:
;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_MySubClass.m
;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_MySubSubClass.m
(superclasses (property_name (identifier)) @font-lock-function-name-face)
- ;; Function inputs: functionName(in1, in2, in3)
- ;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_small_in_args.m
- (function_arguments arguments:
- (identifier) @font-lock-variable-name-face
- ("," (identifier) @font-lock-variable-name-face) :*)
- ;; Function single output argument: function out = functionName(in1, in2)
- ;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_small_out_args.m
- (function_output (identifier) @font-lock-variable-name-face)
- ;; Function multiple output arguments: function [out1, out2] =
functionName(in1, in2)
- (function_output (multioutput_variable (identifier)
@font-lock-variable-name-face))
;; Fields of: arguments ... end , properties ... end
;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments.m
;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_class_properties.m
@@ -745,17 +817,8 @@ Example, disp variable is overriding the disp builtin
functin:
(property (validation_functions ((field_expression
(function_call name: (identifier)
@font-lock-function-call-face)))))
- (property name: (identifier) @matlab-ts-mode-property-face
- (identifier) @font-lock-type-face :?)
- (property name: (property_name (identifier) @matlab-ts-mode-property-face)
- (identifier) @font-lock-type-face :?)
- ;; Enumeration's
- ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_class_enum.m
- ;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_enum_FlowRate.m
- (enum (identifier) @matlab-ts-mode-property-face)
- ;; Events block in classdef
- ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_class_events.m
- (events (identifier) @matlab-ts-mode-property-face)
+ (property name: (identifier) @matlab-ts-mode-property-face)
+ (property name: (property_name (identifier)
@matlab-ts-mode-property-face))
;; Attributes of properties, methods
;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_class_attributes.m
(attribute (identifier) @font-lock-type-face "=" (identifier)
@font-lock-builtin-face)
@@ -768,39 +831,6 @@ Example, disp variable is overriding the disp builtin
functin:
'(((function_call (arguments (identifier) @matlab-ts-mode-property-face))
(:pred matlab-ts-mode--is-fcn-name-value @matlab-ts-mode-property-face)))
- ;; F-Rule: variable
- ;; Could add font-lock-variable-name-face to variable uses. Consider
- ;; i1 = [1, 2];
- ;; i2 = i1(1) + i3 + i4(i3);
- ;; we know i1 and i2 are variables from the (assignment left: (identifier))
- ;; However, we don't know if i3 or i4 are variables or functions because a
function
- ;; can be called with no arguments, e.g. to call i3 function use i3 or
i3(). i4 could
- ;; be a variable indexed by i1 or a function.
- ;;
- ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_variable.m
- :language 'matlab
- :feature 'variable
- '(((assignment left: (identifier)
@matlab-ts-mode-variable-override-builtin-face
- (:pred matlab-ts-mode--is-variable-overriding-builtin
- @matlab-ts-mode-variable-override-builtin-face)))
- (assignment left: (identifier) @font-lock-variable-name-face)
- (multioutput_variable (identifier)
@matlab-ts-mode-variable-override-builtin-face
- (:pred matlab-ts-mode--is-variable-overriding-builtin
- @matlab-ts-mode-variable-override-builtin-face))
- (multioutput_variable (identifier) @font-lock-variable-name-face)
- (global_operator (identifier)
@matlab-ts-mode-variable-override-builtin-face
- (:pred matlab-ts-mode--is-variable-overriding-builtin
- @matlab-ts-mode-variable-override-builtin-face))
- (global_operator (identifier) @font-lock-variable-name-face)
- (persistent_operator (identifier)
@matlab-ts-mode-variable-override-builtin-face
- (:pred matlab-ts-mode--is-variable-overriding-builtin
- @matlab-ts-mode-variable-override-builtin-face))
- (persistent_operator (identifier) @font-lock-variable-name-face)
- (for_statement (iterator (identifier)
@matlab-ts-mode-variable-override-builtin-face
- (:pred
matlab-ts-mode--is-variable-overriding-builtin
-
@matlab-ts-mode-variable-override-builtin-face)))
- (for_statement (iterator (identifier) @font-lock-variable-name-face)))
-
;; F-Rule: command dual arguments
:language 'matlab
:feature 'command-arg
@@ -835,17 +865,6 @@ Example, disp variable is overriding the disp builtin
functin:
:feature 'operator
`([,@matlab-ts-mode--operators] @matlab-ts-mode-operator-face)
- ;; F-Rule: Types, e.g. int32()
- :language 'matlab
- :feature 'type
- `((function_call name: (identifier)
- @font-lock-type-face
- (:match ,(rx-to-string `(seq bos
- (or
,@matlab-ts-mode--type-functions)
- eos)
- t)
- @font-lock-type-face)))
-
;; F-Rule: Brackets
;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_brackets.m
:language 'matlab
@@ -858,24 +877,6 @@ Example, disp variable is overriding the disp builtin
functin:
:feature 'delimiter
'((["." "," ":" ";"]) @font-lock-delimiter-face)
- ;; F-Rule: factory items that come with MATLAB, Simulink, or add-on products
- ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_builtins.m
- :language 'matlab
- :feature 'builtins
- `(((identifier) @font-lock-builtin-face
- (:pred matlab-ts-mode--is-identifier-builtin @font-lock-builtin-face))
- ((command_name) @font-lock-builtin-face
- (:pred matlab-ts-mode--is-command-builtin @font-lock-builtin-face))
- ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_boolean.m
- ((boolean) @font-lock-builtin-face))
-
- ;; F-Rule: namespaces (the +dir's, class methods, etc.)
- ;; See: tests/test-matlab-ts-mode-font-lock-files/font_lock_namespaces.m
- :language 'matlab
- :feature 'namespace-builtins
- :override t
- `((field_expression) @matlab-ts-mode--namespace-builtins-capture)
-
;; F-Rule: Syntax errors
;; Some errors span too much of the buffer's text, so one will probably not
want this
;; enabled. Perhaps, once
https://github.com/acristoffers/tree-sitter-matlab/issues/36
@@ -3438,15 +3439,9 @@ so configuration variables of that mode, do not affect
this mode.
;; Activate MATLAB script ";; heading" matlab-sections-minor-mode if needed
(matlab-sections-auto-enable-on-mfile-type-fcn
(matlab-ts-mode--mfile-type))
- ;; TODO font-lock: f1, f2, f3 in fcn-name face, mustBeReal builtin face
- ;; function fcnarg(in1)
- ;; arguments
- ;; in1 {f1, f2, f3, mustBeReal}
- ;; end
- ;; end
- ;; See:
tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments2_issue57.m
+ ;; TODO font-lock: matlab.mixin.SetGetExactNames is not in
matlab-ts-mode--builtins.el?
;;
- ;; TODO font-lock keywords uses as variables, struct fields, or namespaces
+ ;; TODO font-lock keywords used as variables, struct fields, or namespaces
;; Improve face used, see
;;
tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_as_others.m
;;
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_enum_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_enum_expected.txt
index 1774756d33..3029194a37 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_enum_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_enum_expected.txt
@@ -1,5 +1,5 @@
c ccc ccccccccc ccc
-kkkkkkkk ffffffffffffffffffff o fffff
+kkkkkkkk ffffffffffffffffffff o BBBBB
kkkkkkkkkkk
PPP bnb
PPPPPP bnb
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_events_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_events_expected.txt
index fba258f9fb..835765b326 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_events_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_events_expected.txt
@@ -1,5 +1,5 @@
c ccc ccccccccc ccc
-kkkkkkkk ffffffffffffffffffffff o ffffff
+kkkkkkkk ffffffffffffffffffffff o BBBBBB
kkkkkk
PPPPPPPPPPP
kkk
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_properties_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_properties_expected.txt
index b1ef8947b4..39b3a2b1ac 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_properties_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_class_properties_expected.txt
@@ -6,6 +6,6 @@ kkkkkkkk ffffffffffffffffffffffffff
PP tttttt o nD
PP bnDnb ttttttD
PP bnDnb tttttt o nD
- PP bnDnb tttttt bFFFFFFFFFFFFFFb o nD
+ PP bnDnb tttttt bBBBBBBBBBBBBBBb o nD
kkk
kkk
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_comment_fcn_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_comment_fcn_expected.txt
index fcb33c4d0a..63aab18274 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_comment_fcn_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_comment_fcn_expected.txt
@@ -5,7 +5,7 @@ h hhh hhhh hhhhhhh
BBBBBBbbD
- kkkkkkkk ffffff
+ kkkkkkkk BBBBBB
c cccc cc c cccccc ccccccc ccc cccc
BBBBbSss ssssssSbD
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_enum_FlowRate_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_enum_FlowRate_expected.txt
index 9ee389b96b..7639d59c3b 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_enum_FlowRate_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_enum_FlowRate_expected.txt
@@ -1,6 +1,6 @@
c ccc ccccccccc ccc
c ccc cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-kkkkkkkk fffffffffffffffffffffff o fffff
+kkkkkkkk fffffffffffffffffffffff o BBBBB
kkkkkkkkkkk
PPP bnnb
PPPPPP bddddddddDdddonb
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments2_issue57_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments2_issue57_expected.txt
index ee313062c6..fd446f6d49 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments2_issue57_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments2_issue57_expected.txt
@@ -2,8 +2,8 @@ c ccc ccccccccc ccc
kkkkkkkk ffffffffffffffffffffffffffffffffbvDvb
kkkkkkkkk
- P bnDDb tttttt bFFFFFFFFFFb
- P bnDDb tttttt bFFFFFFFFFFD FFFFFFFDFFFFFFFFFFFFFFbdD dbb
+ P bnDDb tttttt bBBBBBBBBBBb
+ P bnDDb tttttt bBBBBBBBBBBD FFFFFFFDFFFFFFFFFFFFFFbdD dbb
kkk
BBBBbdb
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments_expected.txt
index e78b995332..bae757b8a2 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments_expected.txt
@@ -1,12 +1,12 @@
c ccc ccccccccc ccc
kkkkkkkk fffffffffffffffffffffffbvvvD vvvvvvvvvvD vvvD vvvvvvvb
kkkkkkkkk
- PPP bnDDb bFFFFFFFFFFFFFb
- PPPPPPPPPP tttttt
+ PPP bnDDb bBBBBBBBBBBBBBb
+ BBBBBBBBBB tttttt
PPP bnDnb tttttt
PPPPPPPDPPP
- PPPPPPPDPPP tttttt
+ PPPPPPPDBBB tttttt
PPPPPPPDPPPPPPPPP bnDnb tttttt o SsS
- PPPPPPPDPPPPPPPPP bnDnb bFFFFFFFFFFFFFb o n
+ PPPPPPPDPPPPPPPPP bnDnb bBBBBBBBBBBBBBb o n
kkk
kkk
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_as_others2_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_as_others2_expected.txt
index 536aeb6fbb..a6b9b51e8b 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_as_others2_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_as_others2_expected.txt
@@ -1,12 +1,12 @@
c ccc ccccccccc ccc
-kkkkkkkk bttttttttb fffffffffffffffffffffffffffff o ffffff o
fffffffffffffffffffffffffffff
+kkkkkkkk bttttttttb fffffffffffffffffffffffffffff o BBBBBB o
BBBBBBDdddddDdddddddddddddddd
kkkkkkkkkk bttttttoSssssssSb
PP o bbD
PP o Ssssssss ssss sssssSD
PP o Sssssss ssss sssss sss s SD
PP o ddddddddbnDnbD
- PP bnDDb tttttt bFFFFFFFFFFFFFFb o nD
+ PP bnDDb tttttt bBBBBBBBBBBBBBBb o nD
kkk
kkkkkkkkkk bttttttttoBBBBD tttttttttttoBBBBb
@@ -55,7 +55,7 @@ kkkkkkkk bttttttttb fffffffffffffffffffffffffffff o ffffff o
fffffffffffffffffff
kkkkkkkk fffffffffffffffffffbobD kkk
kkk
kkkkkkk
- kkkkkkkk ffffffffffbob
+ kkkkkkkk BBBBBBBBBBbob
kkk
kkkkkkkk kkkkkkkbob
kkk
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_expected.txt
index 4580b24d6c..b2bd9c3d30 100644
--- a/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_expected.txt
+++ b/tests/test-matlab-ts-mode-font-lock-files/font_lock_keywords_expected.txt
@@ -1,5 +1,5 @@
c ccc ccccccccc ccc
-kkkkkkkk ffffffffffffffffff o ffffff
+kkkkkkkk ffffffffffffffffff o BBBBBB
kkkkkkkkkk
PP o n
kkk
diff --git
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_validation_fcns_with_args_issue78_expected.txt
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_validation_fcns_with_args_issue78_expected.txt
index d6ef228ad9..fd0f14a857 100644
---
a/tests/test-matlab-ts-mode-font-lock-files/font_lock_validation_fcns_with_args_issue78_expected.txt
+++
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_validation_fcns_with_args_issue78_expected.txt
@@ -4,7 +4,7 @@ c ccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
kkkkkkkk fffffffffffffffffffffffffffffffffffffffffffbvvvvvD vvvvb
kkkkkkkkk
- PPPPP bnD Db tttttt bFFFFFFFFFFb
- PPPP bnD Db tttttt bFFFFFFFFFFD FFFFFFFDFFFFFFFFFFFFFFbBBBBD BBBBBD
SssssSD SsssssSbb
+ BBBBB bnD Db tttttt bBBBBBBBBBBb
+ BBBB bnD Db tttttt bBBBBBBBBBBD FFFFFFFDFFFFFFFFFFFFFFbBBBBD BBBBBD
SssssSD SsssssSbb
kkk
kkk