Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
3bbc4c9
1.3.3
SSlinky May 28, 2024
557867e
Better snippets
SSlinky May 28, 2024
5e425d8
Fixes #3
SSlinky May 28, 2024
f2bb7c0
args no longer require spaces between=assignment
SSlinky May 28, 2024
5cad513
Support for inline methods
SSlinky May 28, 2024
41d6fb6
Added caret to typeHint rule
SSlinky May 28, 2024
c50f62c
Updated error handling
SSlinky May 29, 2024
253bda1
Support for Type declarations
SSlinky May 29, 2024
1383f0d
Separate folding and normal blocks
SSlinky May 29, 2024
be2bb96
Removed "unknown" lines in favour of error recovery
SSlinky May 29, 2024
120a637
Bug fix: operator statements
SSlinky May 29, 2024
66102f1
Improved readability and removed labels
SSlinky May 29, 2024
d6a44e6
Update imports and clean logging lines
SSlinky May 29, 2024
e62863a
Chaining methods
SSlinky May 29, 2024
e5248ce
Added wend keyword
SSlinky May 29, 2024
d296d2c
1.3.4
SSlinky May 29, 2024
d8293fa
Merge branch 'master' into dev
SSlinky May 29, 2024
5467f71
Merge branch 'master' into dev
SSlinky May 29, 2024
31596df
methods sort
SSlinky May 29, 2024
95bbada
Fixed bug with module header
SSlinky May 29, 2024
45d08e0
Support for while/wend blocks
SSlinky May 29, 2024
fa8f4a3
Better async support and trigger parse on doc open
SSlinky May 29, 2024
55c6242
1.3.5
SSlinky May 29, 2024
8a8d068
Enable chaining
SSlinky May 31, 2024
de2820d
Missing Option Explicit diagnostic
SSlinky May 31, 2024
e09841a
lineLabel now parses with space
SSlinky May 31, 2024
737e61b
Merged stashed changes
SSlinky May 31, 2024
e802a4f
New ts version broke extensions
SSlinky May 31, 2024
ef2e7bc
Separate name attribute to make it easier to target and add descripti…
SSlinky Jun 1, 2024
572977b
Upgrade packages and typescript
SSlinky Jun 1, 2024
29eb283
Rename property set for clarity
SSlinky Jun 1, 2024
b6dc2c4
Upgrade to antlr4ng. Everything is broken!
SSlinky Jun 1, 2024
6ae38bf
Add MissingAttributeDiagnostic and DuplicateAttributeDiagnostic
SSlinky Jun 1, 2024
13dbf00
Module supports Option Explicit diagnostic
SSlinky Jun 1, 2024
4a9fc91
Class supports MissingOptionExplicitDiagnostic
SSlinky Jun 2, 2024
3796d6e
Fixed issue causing Optional not to be recognised in arguments list
SSlinky Jun 2, 2024
db94018
String literals now behave like they do in VBA
SSlinky Jun 2, 2024
0029656
end if # now optional
SSlinky Jun 2, 2024
bebbb21
Method signature no longer requires space before closing paren
SSlinky Jun 2, 2024
44125c9
Expressions can now have function calls on left side
SSlinky Jun 2, 2024
35aad82
Sub calls no longer required to have multiple args to work
SSlinky Jun 2, 2024
bc8e9ac
subCall lower in priority to avoid overriding object model
SSlinky Jun 2, 2024
a28e9e7
Fixes escape issue in expressions
SSlinky Jun 2, 2024
c29e05b
Fixed attributes
SSlinky Jun 2, 2024
46434dd
Attempting to handle args with line separators
SSlinky Jun 2, 2024
943d045
line separated args still not working
SSlinky Jun 2, 2024
803306d
1.3.6
SSlinky Jun 2, 2024
4a8894d
Merge branch 'dev' into NewParser to update textMate grammar
SSlinky Jun 2, 2024
e5c6922
INTEGERLITERAL now supports negative numbers
SSlinky Jun 3, 2024
093682e
JS !== Python
SSlinky Jun 4, 2024
5cabb06
Support for ignored attributes
SSlinky Jun 4, 2024
f70eda2
Implement enums. Create base Scope element.
SSlinky Jun 4, 2024
ef87508
Implemented WhileWend diagnostic
SSlinky Jun 4, 2024
f47c498
Enter scopes now paird with exits
SSlinky Jun 4, 2024
5ab618a
Enabled error node logging
SSlinky Jun 4, 2024
0bd616b
No longer throws for forms.
SSlinky Jun 4, 2024
b35dc93
Enabled Type declarations
SSlinky Jun 4, 2024
40bbe5c
Support for constants
SSlinky Jun 4, 2024
f357e15
Support for Type declarations
SSlinky Jun 4, 2024
2cd6f20
Enable duplicate property declaration diagnostics
SSlinky Jun 4, 2024
402381a
Only register property name once
SSlinky Jun 4, 2024
ff8d98e
Added property type to name in SymbolInformation
SSlinky Jun 4, 2024
fa1e5af
Methods now parse with args out of order
SSlinky Jun 4, 2024
f7d7bff
Increased file max size
SSlinky Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 54 additions & 24 deletions client/src/syntaxes/vba.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ patterns:
repository:
fileStructure:
patterns:
- include: "#moduleHeader"
- include: "#comments" # Handle comments here so they aren't broken by other stuff.
- include: "#strings" # Handle strings here so they aren't broken by other stuff.
- include: "#labels" # Handle labels first so they aren't handled by lines.
- include: "#inlineMethod" # Try not to be too sad people can, and do, do this.
- include: "#methodSignature"
- include: "#continuations" # Consume continuations so they "continue" other matches.
- include: "#enum"
Expand Down Expand Up @@ -52,7 +54,6 @@ repository:

main:
patterns:
- include: "#moduleHeader"
- include: "#declareFunctionSignature"
- include: "#methodSignature"
- include: "#variableDeclarations"
Expand All @@ -68,8 +69,8 @@ repository:
- include: "#operators"
- include: "#keywords"
- include: "#functionCall"
- include: "#subCall"
- include: "#objectModel"
- include: "#subCall"


literals:
Expand All @@ -82,7 +83,7 @@ repository:
repository:
string:
name: string.quoted.double.vba
match: '"[^\r\n]*"'
match: '"("")*([^"\n]*)((?:"")[^"\n]+)?"("")*'
boolean:
name: constant.language.boolean.vba
match: "(?i)(true|false)"
Expand Down Expand Up @@ -151,11 +152,11 @@ repository:
repository:
flowDecision:
name: keyword.control.flow.decision.vba
match: (?i)(^|\s+)(#if|then|#elseif|[#]?else|#end if|select case|case|switch|end select)\b
match: (?i)(^|\s+)(#if|then|#elseif|[#]?else|[#]?end if|select case|case|switch|end select)\b

flowLoop:
name: keyword.control.flow.loop.vba
match: (?i)\b(do|exit\s+do|while|until|loop|for|each|in|to|exit\s+for|next|with)\b
match: (?i)\b(do|exit\s+do|while|wend|until|loop|for|each|in|to|exit\s+for|next|with)\b

forEachLoop:
name: meta.flow.foreach.vba
Expand Down Expand Up @@ -352,10 +353,10 @@ repository:
repository:
primativeType:
name: support.type.primitive.vba
match: (?i)(?<=\bAs)\s+(boolean|byte|currency|date|decimal|double|integer|long(long|ptr)?|single|string|variant)\b
match: (?i)(?<=\bAs)(?:\s+|\s+_\s*\n)+(boolean|byte|currency|date|decimal|double|integer|long(long|ptr)?|single|string|variant)\b
objectType:
name: support.type.object.vba
match: (?i)(?<=\bAs)(\s+New)?\s+([A-Z][A-Z0-9_]*)\b
match: (?i)(?<=\bAs)((?:\s+(?:\s*_\s*\n)*)New)?(?:\s+(?:\s*_\s*\n)*)([A-Z][A-Z0-9_]*)\b
captures:
1:
name: keyword.storage.new.vba
Expand All @@ -371,22 +372,24 @@ repository:
- include: "#paramArray"
- include: "#functionCall"
- include: "#argsVariable"
- include: "#argsLiteral"
- include: "#language"
- include: "#argsLiteral"
repository:
argsVariable:
match: (?i),?\s*(Optional\s+)?((?:ByVal|ByRef)\s+)?([a-z][a-z0-9_]*)(?:\s*(\bas\s+[a-z][a-z0-9_]*))?\b(\s+=\s+[^,)]*)?
name: meta.arguments.argsVariable.vba
match: (?i),?\s*((?:Optional\s+)?(?:(?:ByVal|ByRef)\s+)?)?([a-z][a-z0-9_]*)(?:\s+(as\s+[a-z][a-z0-9_]*))?(\s*=\s*[^,)]+)?
# Attempted replacing \s with (?:\s+|\s*_\s*\n) to consume a space or a line ending but it refuses to play the game.
# match: ~~ doesn't work (?i),?(?:\s+|\s*_\s*\n)*((?:Optional(?:\s+|\s*_\s*\n)+)?(?:(?:ByVal|ByRef)(?:\s+|\s*_\s*\n)+)?)?([a-z][a-z0-9_]*)(?:(?:\s+|\s*_\s*\n)+(as(?:\s+|\s*_\s*\n)+[a-z][a-z0-9_]*))?((?:\s+|\s*_\s*\n)*=(?:\s+|\s*_\s*\n)*[^,\n)]+)?
# match: ~~ all broken (?i),?(?:\s*_\s*\n)*((?:Optional(?:\s+(?:\s*_\s*\n)*))?(?:(?:ByVal|ByRef)(?:\s+(?:\s*_\s*\n)*))?)?([a-z][a-z0-9_]*)(?:(?:\s+(?:\s*_\s*\n)*)(as\(?:\s+(?:\s*_\s*\n)*)[a-z][a-z0-9_]*))?((?:\s*_\s*\n)*=(?:\s*_\s*\n)*[^,)]+)?
captures:
1:
1: # Optional? ByVal|ByRef?
name: storage.type.modifier.vba
2:
name: storage.type.modifier.vba
3:
2: # Identifier
name: variable.parameter.vba
4:
3: # As Type?
patterns:
- include: "#types"
5:
4:
patterns:
- include: "#language"

Expand All @@ -399,6 +402,7 @@ repository:
- include: "#literals"

paramArray:
name: meta.args.paramarray.vba
match: (?i),?\s*(ParamArray)\s+([a-z][a-z0-9_]*)(?:\(\))(\s+As\s+Variant)?
captures:
1:
Expand Down Expand Up @@ -431,10 +435,12 @@ repository:
match: (?i)(?<=^|:)\s*Rem\b.*

attribute:
name: entity.other.attribute-name.vba
match: (?i)^Attribute(.*)
name: meta.attribute.vba
match: (?i)^\s*(Attribute VB_\w+)\s+(.*)$
captures:
0:
1:
name: entity.other.attribute-name.vba
2:
patterns:
- include: "#language"

Expand All @@ -450,7 +456,7 @@ repository:
moduleAttributeBlock:
name: entity.other.attribute-name.block.vba
begin: (?i)^VERSION
end: ^(?i)End
end: (?i)^END
patterns:
- include: "#comments"
- include: "#literals"
Expand Down Expand Up @@ -566,10 +572,32 @@ repository:
patterns:
- include: "#arguments"

inlineMethod:
name: source.inline-method.please-dont.vba
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))
captures:
1: # Method type
name: storage.type.method.vba
2: # Identifier
name: entity.name.function.vba
3: # Arguments?
patterns:
- include: "#arguments"
4: # Return type?
patterns:
- include: "#types"
5: # Method lines
patterns:
- include: "#fileStructure"
6: # End method
name: storage.type.method.close.vba



methodSignature:
name: source.method.signature.vba
begin: '(?i)^\s*((?:Public|Private)?\b\s*(?:(?:Sub|Function)|Property\s+(?:Let|Get|Set)))\s+([a-z][a-z0-9_]*)\s*(\()'
end: '(?i)(\))\s+(as\s+[a-z][a-z0-9_]*)?'
begin: (?i)^\s*((?:Public|Private)?\b\s*(?:(?:Sub|Function)|Property\s+(?:Let|Get|Set)))\s+([a-z][a-z0-9_]*)\s*(\()
end: (?i)\s*(\))\s+(as\s+[a-z][a-z0-9_]*)?
beginCaptures:
1:
name: storage.type.method.vba
Expand All @@ -591,17 +619,18 @@ repository:
match: (?i)^\s*End\s+(Sub|Function|Property)

expression:
# (?:[*&/\+-]|\bMod\b)|
# (?:[*&\/\+-]|\bMod\b)|
# (?:[<>=]|\b(is|like)\b)|
# (?:[&+])|
# (?:\b(and|eqv|imp|not|or|xor)\b)|
# (?:\b(addressof|typeof)\b)

# This match just made up of the operators matchs. Don't look at it too hard.
match: (?i)(.*?)\s+((?:[*&/\+-]|\bMod\b)|(?:[<>=]|\b(is|like)\b)|(?:[&+])|(?:\b(and|eqv|imp|not|or|xor)\b)|(?:\b(addressof|typeof)\b))\s+(.*)
match: (?i)(.*?)\s+((?:[*&\/\+-]|\bMod\b)|(?:[<>=]|\b(is|like)\b)|(?:[&+])|(?:\b(and|eqv|imp|not|or|xor)\b)|(?:\b(addressof|typeof)\b))\s+(.*)
captures:
1: # Left sided of expression
patterns:
- include: "#functionCall"
- include: "#literal"
2: # Operator
patterns:
Expand Down Expand Up @@ -709,7 +738,8 @@ repository:
- include: "#lineContinuation"

subCall:
begin: (?i)([a-z][a-z0-9._]*)\s+(.*,.*)
name: meta.sub-call.vba
begin: (?i)([a-z][a-z0-9._]*)\s+(.*)
beginCaptures:
1:
name: entity.name.function.call.vba
Expand Down
Loading