@@ -56,7 +56,6 @@ repository:
5656 - include : " #comments" # Handle comments here so they aren't broken by other stuff.
5757 - include : " #strings" # Handle strings here so they aren't broken by other stuff.
5858 - include : " #labels" # Handle labels first so they aren't handled by lines.
59- - include : " #inlineMethod" # Try not to be too sad people can, and do, do this.
6059 - include : " #methodSignature"
6160 - include : " #enum"
6261 - include : " #struct"
@@ -103,6 +102,8 @@ repository:
103102 - include : " #objectModel"
104103 - include : " #subCall"
105104 - include : " #subCallNoArgs"
105+ - name : keyword.control.line-separator.vba
106+ match : ' :'
106107
107108
108109 literals :
@@ -183,6 +184,7 @@ repository:
183184 - include : " #forEachLoop"
184185 - include : " #flowLoop"
185186 - include : " #flowCall"
187+ - include : " #methodClose"
186188 - include : " #flowPauseExit"
187189 - include : " #flowBranch"
188190 repository :
@@ -264,7 +266,7 @@ repository:
264266
265267 flowPauseExit :
266268 name : keyword.control.flow.other.vba
267- match : " (?i)\\ b(doevents|end(?! property)|exit\\ s+sub|exit\\ s+function|exit\\ s+property|stop)\\ b"
269+ match : " (?i)\\ b(doevents|end(?! (sub| property|function) )|exit\\ s+sub|exit\\ s+function|exit\\ s+property|stop)\\ b"
268270
269271 flowBranch :
270272 patterns :
@@ -409,43 +411,94 @@ repository:
409411 patterns :
410412 - include : " #AsTypePrimative"
411413 - include : " #AsTypeObject"
412- repository :
413- AsTypePrimative :
414- name : support.type.primitive.$1.vba
415- match : (?i)(boolean|byte|currency|date|decimal|double|integer|long(long|ptr)?|single|string|variant)\b
416- AsTypeObject :
417- name : support.type.object.$1.vba
418- match : (?i)([A-Z][A-Z0-9_]*)
414+ AsTypePrimative :
415+ name : support.type.primitive.$1.vba
416+ match : (?i)(boolean|byte|currency|date|decimal|double|integer|long(long|ptr)?|single|string|variant)\b
417+ AsTypeObject :
418+ name : support.type.object.$1.vba
419+ match : (?i)([a-z][a-z0-9._]*)
419420
420421 argumentsSignature :
421422 name : meta.arguments.signature.vba
422- match : (?i)(?:(,)|(=)|(\s*_\s*\n)|(as\s+(?:\s*_\s*\n)*[a-z][a-z0-9_.]*)|(".*"|True|False|\d+(?:\.\d+)?[%&@!#$]?)|([a-z][a-z0-9_.]*[%&@!#$]?(?:\(\))?))
423- captures :
424- 1 : # ,
425- patterns :
426- - include : " #separator"
427- 2 : # =
428- name : keyword.operator.assignment.vba
429- 3 : # _
430- name : punctuation.line-continuation.vba
431- 4 : # As Type?
432- patterns :
433- - include : " #types"
434- 5 : # "foo"
435- patterns :
436- - include : " #literals"
437- 6 :
423+ begin : (?=[^ ():_])
424+ end : (?=\))
425+ patterns :
426+ - include : " #separator"
427+ - include : " #lineContinuation"
428+ - include : " #argumentSignatureFromParamArray"
429+ - include : " #argumentSignatureFromOptional"
430+ - include : " #argumentSignatureFromBy"
431+ - include : " #argumentSignatureFromParam"
432+
433+ argumentSignatureFromParamArray :
434+ name : meta.argument-signature.paramarray.vba
435+ begin : (?i)paramarray
436+ end : (?=[,):'\n])
437+ beginCaptures :
438+ 0 :
439+ name : storage.type.modifier.vba
440+ patterns :
441+ - include : " #argumentSignatureFromParam"
442+ - include : " #lineContinuation"
443+
444+ argumentSignatureFromOptional :
445+ name : meta.argument-signature.optional.vba
446+ begin : (?i)optional
447+ end : (?=[,):'\n])
448+ beginCaptures :
449+ 0 :
450+ name : storage.type.modifier.vba
451+ patterns :
452+ - include : " #argumentSignatureFromBy"
453+ - include : " #argumentSignatureFromParam"
454+ - include : " #lineContinuation"
455+
456+ argumentSignatureFromBy :
457+ name : meta.argument-signature.by.vba
458+ begin : (?i)(byref|byval)
459+ end : (?=[,):'\n])
460+ beginCaptures :
461+ 0 :
462+ name : storage.type.modifier.vba
463+ patterns :
464+ - include : " #argumentSignatureFromParam"
465+ - include : " #lineContinuation"
466+
467+ argumentSignatureFromParam :
468+ name : meta.argument-signature.param.vba
469+ begin : (?i)[a-z][a-z0-9]*(\(\))?
470+ end : (?=[,):'\n])
471+ beginCaptures :
472+ 0 :
473+ name : variable.parameter.vba
474+ patterns :
475+ - include : " #argumentSignatureFromTypeAs"
476+ - include : " #lineContinuation"
477+
478+ argumentSignatureFromTypeAs :
479+ name : meta.argument-signature.as.vba
480+ begin : (?i)\bas\b
481+ end : (?=[,):'\n])
482+ beginCaptures :
483+ 0 :
438484 patterns :
439485 - include : " #keywords"
440- - include : " #argumentsVariableSignature"
441- repository :
442- argumentsVariableSignature :
443- match : (?i)(?:(Optional|ParamArray|ByRef|ByVal)|(.*))
444- captures :
445- 1 : # Optional? ByVal|ByRef?
446- name : storage.type.modifier.vba
447- 2 : # Identifier
448- name : variable.parameter.vba
486+ patterns :
487+ - include : " #argumentSignatureFromTypeName"
488+ - include : " #lineContinuation"
489+
490+ argumentSignatureFromTypeName :
491+ name : meta.argument-signature.type.vba
492+ begin : (?i)([a-z][a-z0-9._]*)
493+ end : (?=[,):'\n])
494+ beginCaptures :
495+ 0 :
496+ patterns :
497+ - include : " #AsTypePrimative"
498+ - include : " #AsTypeObject"
499+ patterns :
500+ - include : " #variableAssignment"
501+ - include : " #lineContinuation"
449502
450503 arguments :
451504 name : meta.arguments.vba
@@ -647,47 +700,22 @@ repository:
647700 patterns :
648701 - include : " #argumentsSignature"
649702
650- inlineMethod :
651- name : source.inline-method.please-dont.vba
652- match : (?i)^\s*((?:Public|Private)?\b\s*(?:(?:Sub|Function)|Property\s+(?:Let|Get|Set)))\s+([a-z][a-z0-9_]*)\s*\((.+)?\)(\s+as\s+[a-z][a-z0-9_]*)?:(.*)?:\s*(End\s+(?:Sub|Function|Property))
653- captures :
654- 1 : # Method type
655- name : storage.type.method.vba
656- 2 : # Identifier
657- name : entity.name.function.vba
658- 3 : # Arguments?
659- patterns :
660- - include : " #argumentsSignature"
661- 4 : # Return type?
662- patterns :
663- - include : " #types"
664- 5 : # Method lines
665- patterns :
666- - include : " #fileStructure"
667- 6 : # End method
668- name : storage.type.method.close.vba
669-
670-
671-
672703 methodSignature :
673704 name : source.method.signature.vba
674705 begin : (?i)^\s*((?:Public|Private)?\b\s*(?:(?:Sub|Function)|Property\s+(?:Let|Get|Set)))\s+([a-z][a-z0-9_]*)\s*(\()
675- end : (?i)\s*( \))\s+( as\s+[a-z][a-z0-9_]*)?
706+ end : (?i)(?<= \))( \s+as\s+[a-z][a-z0-9_]*)?
676707 beginCaptures :
677708 1 :
678709 name : storage.type.method.vba
679710 2 : # name
680711 name : entity.name.function.vba
681- 3 :
682- name : punctuation.definition.parameters.begin.vba
683712 endCaptures :
684- 1 :
685- name : punctuation.definition.parameters.end.vba
686- 2 : # return type
713+ 1 : # return type
687714 patterns :
688715 - include : " #types"
689716 patterns :
690717 - include : " #argumentsSignature"
718+ - include : " #lineContinuation"
691719
692720 methodAttribute :
693721 name : source.method.attribute.vba
@@ -707,13 +735,13 @@ repository:
707735
708736 methodClose :
709737 name : storage.type.method.close.vba
710- match : (?i)^\s* End\s+(Sub|Function|Property)
738+ match : (?i)End\s+(Sub|Function|Property)
711739
712740 expression :
713741 # Begins and ends without consuming anything.
714742 name : meta.expression.vba
715743 begin : (?=.)
716- end : (?=\n|\sThen|\)|'|,)
744+ end : (?=\n|\sThen|\)|'|,|: )
717745 patterns :
718746 - include : " #literals"
719747 - include : " #operators"
@@ -811,7 +839,7 @@ repository:
811839 variableAssignment :
812840 name : meta.variable-assignment.vba
813841 begin : (?i)(?:(Let|Set)\s+)?((?:[a-z][a-z0-9_]*)?(?:\.(?:(?:[a-z][a-z0-9_]*)?\.)*)?(?:[a-z][a-z0-9_]*)?)(\s*=\s*)
814- end : (?=[': \n])
842+ end : (?=[',:) \n])
815843 beginCaptures :
816844 1 : # Let|Set
817845 name : keyword.control.vba
@@ -845,7 +873,7 @@ repository:
845873 2 :
846874 patterns :
847875 - name : variable.other.constant
848- match : ([A-Z][A-Z0-9_]*)
876+ match : ([A-Z][A-Z0-9_]*)\b
849877 - name : variable.other.readwrite.vba
850878 match : (?i)([a-z][a-z0-9_]*)
851879 3 :
0 commit comments