branch: externals/matlab-mode
commit 4f70e9bed539e7ef60a09a9431919b5ca60eebd7
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode--ei: simplify property attribute name=value handling
---
matlab-ts-mode--ei.el | 23 ++++++++--------------
.../electric_indent_prop_attribute_id_cell_value.m | 9 +++++++++
..._indent_prop_attribute_id_cell_value_expected.m | 9 +++++++++
...nt_prop_attribute_id_cell_value_expected_msgs.m | 9 +++++++++
.../electric_indent_prop_attribute_id_cell_value.m | 9 +++++++++
...ndent_prop_attribute_id_cell_value_expected.txt | 21 ++++++++++++++++++++
6 files changed, 65 insertions(+), 15 deletions(-)
diff --git a/matlab-ts-mode--ei.el b/matlab-ts-mode--ei.el
index 43c712d3f8..2a07f937c2 100644
--- a/matlab-ts-mode--ei.el
+++ b/matlab-ts-mode--ei.el
@@ -137,8 +137,10 @@
(,(rx bos (or "," ";" "command_argument" "command_name" "enum-id") eos)
"." 1)
- (,(rx bos "attribute-id" eos) "="
0)
- ("=" ,(rx bos "attribute-id" eos)
0)
+ ;; Case arguments name=value syntax, the "=" node is converted to "n=v"
+ ;; TopTester: electric_indent_name_value_args.m
+ ("." ,(rx bos "n=v" eos)
0)
+ (,(rx bos "n=v" eos) "."
0)
(,matlab-ts-mode--ei-0-after-re "."
0)
@@ -162,11 +164,6 @@
(,matlab-ts-mode--ei-pad-op-re "."
1)
("." ,matlab-ts-mode--ei-pad-op-re
1)
- ;; Case arguments name=value syntax, the "=" node is converted to "n=v"
- ;; TopTester: electric_indent_name_value_args.m
- ("." ,(rx bos "n=v" eos)
0)
- (,(rx bos "n=v" eos) "."
0)
-
;; Case: string followed by anything, e.g. ["string1" foo(1)]
(,(rx bos "string" eos) "."
1)
@@ -239,20 +236,18 @@ be unary-op even though the node type is \"+\"."
(cond
;; Case: Use string and not the elements of the string
- ;; Type is "string" or "attribute-id" for class properties
(SetAccess='value')
((string= parent-type "string")
(setq node parent
- node-type (if (equal (treesit-node-type (treesit-node-parent
parent)) "attribute")
- "attribute-id"
- parent-type)))
+ node-type parent-type))
;; Case: name=value argument pair
((and (string= node-type "=")
- (string= parent-type "arguments"))
+ (or (string= parent-type "arguments")
+ (string= parent-type "attribute")))
;; arguments name=value
(setq node-type "n=v"))
- ;; Case: prop-id, prop-class-id, enum-id, attribute-id
+ ;; Case: prop-id, prop-class-id, enum-id
((string= node-type "identifier")
(cond ((string= parent-type "property") ;; propertyWithOutDot?
(if (equal (treesit-node-child parent 0) node)
@@ -264,8 +259,6 @@ be unary-op even though the node type is \"+\"."
(setq node-type "prop-class-id")))
((string= parent-type "enum")
(setq node-type "enum-id"))
- ((string= parent-type "attribute")
- (setq node-type "attribute-id"))
))
;; Case: unary operator sign, + or -, e.g. [0 -e] or g = - e
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value.m
new file mode 100644
index 0000000000..3e8c8c769a
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in
error nodes
+
+classdef electric_indent_prop_attribute_id_cell_value
+ properties (SetAccess= 'private', GetAccess= {?foo.barj.zoo, ?foo.bar.goo})
+ ConnectionHandle
+ end
+end
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected.m
new file mode 100644
index 0000000000..f45329ce37
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in
error nodes
+
+classdef electric_indent_prop_attribute_id_cell_value
+ properties (SetAccess='private', GetAccess={?foo.barj.zoo, ?foo.bar.goo})
+ ConnectionHandle
+ end
+end
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected_msgs.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected_msgs.m
new file mode 100644
index 0000000000..465aca1e17
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected_msgs.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*- % <{Matched rule: (matlab-ts-mode--i-top-level
matlab-ts-mode--column-0 0)}>
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in
error nodes % <{Matched rule: (matlab-ts-mode--i-top-level
matlab-ts-mode--column-0 0)}>
+
+classdef electric_indent_prop_attribute_id_cell_value % <{Matched rule:
(matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+ properties (SetAccess='private', GetAccess={?foo.barj.zoo, ?foo.bar.goo})
% <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
+ ConnectionHandle % <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
+ end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
+end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value.m
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value.m
new file mode 100644
index 0000000000..3e8c8c769a
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in
error nodes
+
+classdef electric_indent_prop_attribute_id_cell_value
+ properties (SetAccess= 'private', GetAccess= {?foo.barj.zoo, ?foo.bar.goo})
+ ConnectionHandle
+ end
+end
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected.txt
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected.txt
new file mode 100644
index 0000000000..3e0044e660
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_cell_value_expected.txt
@@ -0,0 +1,21 @@
+# -*- t-utils-ts-parse-tree -*-
+(source_file<1,285> (comment[1,20]@{% -*- matlab-ts -*-}@) (comment[22,112]@{%
t-utils-test-indent: no-line-by-line-indent - li...}@) \n[112,114]
+ (class_definition<114,284> classdef[114,122] name:
(identifier[123,167]@{electric_indent_prop_attribute_id_cell_value}@)
\n[167,168]
+ (properties<172,280> properties[172,182]
+ (attributes<183,247> ([183,184]
+ (attribute<184,204> (identifier[184,193]@{SetAccess}@) =[193,194]
+ (string<195,204> '[195,196] (string_content[196,203]@{private}@)
'[203,204]))
+ ,[204,205]
+ (attribute<206,246> (identifier[206,215]@{GetAccess}@) =[215,216]
+ (cell<217,246> {[217,218]
+ (row<218,245>
+ (metaclass_operator<218,231> ?[218,219] (identifier[219,222]@{foo}@)
.[222,223] (identifier[223,227]@{barj}@) .[227,228]
(identifier[228,231]@{zoo}@))
+ ,[231,232]
+ (metaclass_operator<233,245> ?[233,234] (identifier[234,237]@{foo}@)
.[237,238] (identifier[238,241]@{bar}@) .[241,242]
(identifier[242,245]@{goo}@)))
+ }[245,246]))
+ )[246,247])
+ \n[247,248]
+ (property<256,272> name: (identifier[256,272]@{ConnectionHandle}@))
+ \n[272,273] end[277,280])
+ \n[280,281] end[281,284])
+ \n[284,285])