branch: externals/matlab-mode
commit ea0a4dea0068fa9e2758982879c7d28c36dabdc6
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>

    matlab-ts-mode--ei: handle property attribute stirng values
---
 matlab-ts-mode--ei.el                                     |  5 ++++-
 .../electric_indent_keyword_fcns_expected.m               |  4 ++--
 .../electric_indent_keyword_fcns_expected_msgs.m          |  4 ++--
 .../electric_indent_prop_attribute_id_string.m            |  8 ++++++++
 .../electric_indent_prop_attribute_id_string_expected.m   |  8 ++++++++
 ...ectric_indent_prop_attribute_id_string_expected_msgs.m |  8 ++++++++
 .../electric_indent_prop_attribute_id_string.m            |  8 ++++++++
 .../electric_indent_prop_attribute_id_string_expected.txt | 15 +++++++++++++++
 8 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/matlab-ts-mode--ei.el b/matlab-ts-mode--ei.el
index 1138f234f7..43c712d3f8 100644
--- a/matlab-ts-mode--ei.el
+++ b/matlab-ts-mode--ei.el
@@ -239,9 +239,12 @@ 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 parent-type))
+            node-type (if (equal (treesit-node-type (treesit-node-parent 
parent)) "attribute")
+                          "attribute-id"
+                        parent-type)))
 
      ;; Case: name=value argument pair
      ((and (string= node-type "=")
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected.m
index cc5fa242af..7325617f11 100644
--- 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected.m
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected.m
@@ -8,7 +8,7 @@ classdef electric_indent_keyword_fcns < handle
         normalprop = 1;
     end
 
-    properties (Access= 'public')
+    properties (Access='public')
         % See if we can create properties using keywords
         %properties = 1;
         %methods = 1;
@@ -17,7 +17,7 @@ classdef electric_indent_keyword_fcns < handle
         prop = 1;
     end
 
-    events (Access= 'private')
+    events (Access='private')
         %properties
         %events
         %methods
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected_msgs.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected_msgs.m
index bbcc937a44..e7c577aba7 100644
--- 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected_msgs.m
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_keyword_fcns_expected_msgs.m
@@ -8,7 +8,7 @@ classdef electric_indent_keyword_fcns < handle %  <{Matched 
rule: (matlab-ts-mod
         normalprop = 1; %  <{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)}>
 
-    properties (Access= 'public') %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+    properties (Access='public') %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
         % See if we can create properties using keywords %  <{Matched rule: 
((parent-is 
"\\`\\(?:arguments_statement\\|e\\(?:numeration\\|vents\\)\\|f\\(?:or_statement\\|unction_definition\\)\\|if_statement\\|methods\\|properties\\|while_statement\\)\\'")
 parent 4)}>
         %properties = 1; %  <{Matched rule: 
(matlab-ts-mode--i-block-comment-end-matcher 
matlab-ts-mode--i-block-comment-end-anchor 0)}>
         %methods = 1; %  <{Matched rule: 
(matlab-ts-mode--i-block-comment-end-matcher 
matlab-ts-mode--i-block-comment-end-anchor 0)}>
@@ -17,7 +17,7 @@ classdef electric_indent_keyword_fcns < handle %  <{Matched 
rule: (matlab-ts-mod
         prop = 1; %  <{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)}>
 
-    events (Access= 'private') %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+    events (Access='private') %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
         %properties %  <{Matched rule: ((parent-is 
"\\`\\(?:arguments_statement\\|e\\(?:numeration\\|vents\\)\\|f\\(?:or_statement\\|unction_definition\\)\\|if_statement\\|methods\\|properties\\|while_statement\\)\\'")
 parent 4)}>
         %events %  <{Matched rule: 
(matlab-ts-mode--i-block-comment-end-matcher 
matlab-ts-mode--i-block-comment-end-anchor 0)}>
         %methods %  <{Matched rule: 
(matlab-ts-mode--i-block-comment-end-matcher 
matlab-ts-mode--i-block-comment-end-anchor 0)}>
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string.m
new file mode 100644
index 0000000000..eb478822ba
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string.m
@@ -0,0 +1,8 @@
+% -*- matlab-ts -*-
+
+classdef electric_indent_prop_attribute_id_string
+    properties (SetAccess='protected')
+        p1    char
+        prop2 logical
+    end
+end
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected.m
new file mode 100644
index 0000000000..eb478822ba
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected.m
@@ -0,0 +1,8 @@
+% -*- matlab-ts -*-
+
+classdef electric_indent_prop_attribute_id_string
+    properties (SetAccess='protected')
+        p1    char
+        prop2 logical
+    end
+end
diff --git 
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected_msgs.m
 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected_msgs.m
new file mode 100644
index 0000000000..17feb8cfaa
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected_msgs.m
@@ -0,0 +1,8 @@
+% -*- matlab-ts -*- %  <{Matched rule: (matlab-ts-mode--i-top-level 
matlab-ts-mode--column-0 0)}>
+
+classdef electric_indent_prop_attribute_id_string %  <{Matched rule: 
(matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+    properties (SetAccess='protected') %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+        p1    char %  <{Matched rule: ((node-is 
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
 parent 4)}>
+        prop2 logical %  <{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_string.m
 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string.m
new file mode 100644
index 0000000000..eb478822ba
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string.m
@@ -0,0 +1,8 @@
+% -*- matlab-ts -*-
+
+classdef electric_indent_prop_attribute_id_string
+    properties (SetAccess='protected')
+        p1    char
+        prop2 logical
+    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_string_expected.txt
 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected.txt
new file mode 100644
index 0000000000..602aa83b23
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_prop_attribute_id_string_expected.txt
@@ -0,0 +1,15 @@
+# -*- t-utils-ts-parse-tree -*-
+(source_file<1,164> (comment[1,20]@{% -*- matlab-ts -*-}@) \n[20,22]
+ (class_definition<22,163> classdef[22,30] name: 
(identifier[31,71]@{electric_indent_prop_attribute_id_string}@) \n[71,72]
+  (properties<76,159> properties[76,86]
+   (attributes<87,110> ([87,88]
+    (attribute<88,109> (identifier[88,97]@{SetAccess}@) =[97,98]
+     (string<98,109> '[98,99] (string_content[99,108]@{protected}@) 
'[108,109]))
+    )[109,110])
+   \n[110,111]
+   (property<119,129> name: (identifier[119,121]@{p1}@) 
(identifier[125,129]@{char}@))
+   \n[129,130]
+   (property<138,151> name: (identifier[138,143]@{prop2}@) 
(identifier[144,151]@{logical}@))
+   \n[151,152] end[156,159])
+  \n[159,160] end[160,163])
+ \n[163,164])

Reply via email to