Skip to content

Commit b60ca64

Browse files
committed
Fixed variable assignment to handle property chaining
1 parent 838008b commit b60ca64

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

client/src/syntaxes/vba.tmLanguage.yaml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -809,22 +809,48 @@ repository:
809809
patterns:
810810
- include: "#language"
811811

812-
# TODO: Redo this so it can take into account chaining, e.g.:
813-
# MyClass.MyProp = SomeObject.Foo(20)
814812
variableAssignment:
815-
match: (?i)((Get|Let|Set)\s+)?([a-z.][a-z0-9._]*)(\s*=\s*)(.*)
813+
match: (?i)(?:(Get|Let|Set)\s+)?(?:([a-z][a-z0-9_]*))?(\.(?:(?:[a-z][a-z0-9_]*)?\.)*)?([a-z][a-z0-9_]*)?(\s*=\s*)(.*)
816814
captures:
817-
2:
815+
1: # Get|Let|Set
818816
name: keyword.control.vba
819-
3:
817+
2: # Variable name
820818
name: variable.other.assignment.vba
821-
4:
819+
3: # Properties
820+
patterns:
821+
- include: "#propertyChain"
822+
4: # Property name
823+
name: support.variable.property.vba
824+
5: # =
822825
name: keyword.operator.assignment.vba
823-
5:
826+
6: # Expression
824827
patterns:
825828
- include: "#expression"
829+
- include: "#functionCall"
830+
- include: "#variable"
826831
- include: "#language"
827832

833+
propertyChain:
834+
match: (?i)(\.)([a-z][a-z0-9_]*)*
835+
captures:
836+
1:
837+
name: punctuation.accessor.vba
838+
2:
839+
name: support.variable.property.vba
840+
841+
variable:
842+
name: meta.variable-or-property.vba
843+
match: (?i)(?:(?:(Me)|([a-z][a-z0-9_]*)))((?:\.(?:[a-z][a-z0-9_]*))+)?
844+
captures:
845+
1:
846+
patterns:
847+
- include: "#kw-storageMe"
848+
2:
849+
name: variable.other.object.vba
850+
3:
851+
patterns:
852+
- include: "#propertyChain"
853+
828854
functionCall:
829855
name: meta.function.call.vba
830856
begin: (?i)([a-z][a-z0-9_]*)\(

0 commit comments

Comments
 (0)