Skip to content

fix: DML operations on method call results (#26) - #71

Merged
mshanemc merged 19 commits into
fix/issue-49-final-parameterfrom
fix/issue-26-dml-map-values
Oct 30, 2025
Merged

mshanemc merged 19 commits into
fix/issue-49-final-parameterfrom
fix/issue-26-dml-map-values

Conversation

@mshanemc

@mshanemc mshanemc commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Summary

Fixes syntax highlighting issue where DML operations (insert, update, delete, etc.) when applied to method call results like Map.values() were tokenized differently than when applied to new List expressions.

Related Issues

Changes

  • Added dml-expression pattern in src/apex.tmLanguage.yml to recognize DML operations followed by expressions (excluding new keyword which is handled separately)
  • Pattern matches delete|insert|undelete|update|upsert followed by any expression
  • Added test case verifying insert accounts.values() receives same scope as insert new List<Account>()
  • Both now correctly tokenize the DML keyword as support.function.apex

Testing

  • ✅ All existing tests pass (295 passing)
  • ✅ New test case passes
  • ✅ Build succeeds
  • ✅ No regressions introduced
Screenshot 2025-10-30 at 2 59 31 PM

mshanemc and others added 13 commits October 30, 2025 12:07
- Add test case for annotation on same line as method declaration
- Test verifies correct highlighting in this scenario
- Test currently passes, indicating issue may already be resolved

Closes #44
- Add test cases for nested ternary expressions
- Add test case for ternary with method calls
- Tests verify correct highlighting in these scenarios
- Tests currently pass, indicating issue may already be resolved

Closes #43
- Add dml-expression pattern to handle DML operations on expressions
- Pattern matches insert/update/delete/upsert/undelete followed by expressions
- Ensures DML operations receive same scope (support.function.apex) whether
  applied to new objects or method call results like Map.values()
- Add test case verifying insert accounts.values() gets same scope as insert new List

Closes #26
- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to use 'Id' instead of 'ID' to match Apex convention
- Add test cases for namespace-qualified extends and implements

Closes #50
- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50
- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type
Add initializer-block pattern to grammar to properly highlight code
inside initialization blocks (standalone { } blocks at class member level).
The pattern matches standalone curly brace blocks and includes statement
patterns for proper syntax highlighting, matching method body behavior.

Fixes: forcedotcom/salesforcedx-vscode#4920
Add comprehensive tests to verify initialization blocks are properly
highlighted, including:
- Empty initialization blocks
- Method calls with string literals (the main issue #4920)
- Multiple statements
- Nested class scenario
- Comparison with method body highlighting
Even though Apex doesn't support static initialization blocks,
verify the grammar handles the syntax for highlighting purposes.
- Remove lookbehind end patterns from all when-* statements that prevented proper brace matching
- Update end patterns to use lookahead that ends on closing brace or next when clause
- Improve when-string pattern to support multiple comma-separated strings
- Fix issue #2134: syntax highlighting and brace matching for switch/when statements

All switch statement tests passing.
- Remove quote character from when-statement pattern character class
- Change from ['_\-[:alnum:]]+ to [_\-[:alnum:]]+
- Ensures string literals with dashes like 'de-CH' and 'fr-CH' are matched by when-string pattern
- Add test case for string literals containing dashes in switch statements

This fixes an issue where the when-statement pattern would incorrectly match
string literals containing dashes, preventing proper syntax highlighting.
* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50

* test: add coverage for both Id and ID (case-insensitive Apex)

- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type

* feat: support for varied casing on ID/Id
@mshanemc
mshanemc changed the base branch from main to fix/issue-49-final-parameter October 30, 2025 20:00
mshanemc and others added 6 commits October 30, 2025 15:04
* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50

* test: add coverage for both Id and ID (case-insensitive Apex)

- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type

* feat: support for varied casing on ID/Id

* fix: Add syntax highlighting for initialization blocks

Add initializer-block pattern to grammar to properly highlight code
inside initialization blocks (standalone { } blocks at class member level).
The pattern matches standalone curly brace blocks and includes statement
patterns for proper syntax highlighting, matching method body behavior.

Fixes: forcedotcom/salesforcedx-vscode#4920

* test: Add tests for initialization block syntax highlighting

Add comprehensive tests to verify initialization blocks are properly
highlighted, including:
- Empty initialization blocks
- Method calls with string literals (the main issue #4920)
- Multiple statements
- Nested class scenario
- Comparison with method body highlighting

* test: Add test for static keyword before block

Even though Apex doesn't support static initialization blocks,
verify the grammar handles the syntax for highlighting purposes.
… (issue #2134) (#74)

* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50

* test: add coverage for both Id and ID (case-insensitive Apex)

- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type

* feat: support for varied casing on ID/Id

* fix: Add syntax highlighting for initialization blocks

Add initializer-block pattern to grammar to properly highlight code
inside initialization blocks (standalone { } blocks at class member level).
The pattern matches standalone curly brace blocks and includes statement
patterns for proper syntax highlighting, matching method body behavior.

Fixes: forcedotcom/salesforcedx-vscode#4920

* test: Add tests for initialization block syntax highlighting

Add comprehensive tests to verify initialization blocks are properly
highlighted, including:
- Empty initialization blocks
- Method calls with string literals (the main issue #4920)
- Multiple statements
- Nested class scenario
- Comparison with method body highlighting

* test: Add test for static keyword before block

Even though Apex doesn't support static initialization blocks,
verify the grammar handles the syntax for highlighting purposes.

* fix: Fix switch/when statement syntax highlighting and brace matching

- Remove lookbehind end patterns from all when-* statements that prevented proper brace matching
- Update end patterns to use lookahead that ends on closing brace or next when clause
- Improve when-string pattern to support multiple comma-separated strings
- Fix issue #2134: syntax highlighting and brace matching for switch/when statements

All switch statement tests passing.

* fix: Fix dash highlighting in switch statement string literals

- Remove quote character from when-statement pattern character class
- Change from ['_\-[:alnum:]]+ to [_\-[:alnum:]]+
- Ensures string literals with dashes like 'de-CH' and 'fr-CH' are matched by when-string pattern
- Add test case for string literals containing dashes in switch statements

This fixes an issue where the when-statement pattern would incorrectly match
string literals containing dashes, preventing proper syntax highlighting.
@mshanemc
mshanemc merged commit 5efbd5a into fix/issue-49-final-parameter Oct 30, 2025
12 checks passed
@mshanemc
mshanemc deleted the fix/issue-26-dml-map-values branch October 30, 2025 20:27
mshanemc added a commit that referenced this pull request Nov 4, 2025
* fix: support final keyword in method parameters

- Update parameter rule to recognize final keyword before type
- Add test case for method parameters with final keyword
- Fixes issue #49

The parameter rule previously only supported 'this' keyword as an optional
modifier. This change extends it to also support 'final', which is commonly
used in Apex to prevent parameter reassignment.

Closes #49

* test: add test for annotation on same line as method (issue #44) (#68)

- Add test case for annotation on same line as method declaration
- Test verifies correct highlighting in this scenario
- Test currently passes, indicating issue may already be resolved

Closes #44

* test: add tests for ternary expressions (issue #43) (#70)

* test: add test for annotation on same line as method (issue #44)

- Add test case for annotation on same line as method declaration
- Test verifies correct highlighting in this scenario
- Test currently passes, indicating issue may already be resolved

Closes #44

* test: add tests for ternary expressions (issue #43)

- Add test cases for nested ternary expressions
- Add test case for ternary with method calls
- Tests verify correct highlighting in these scenarios
- Tests currently pass, indicating issue may already be resolved

Closes #43

* fix: DML operations on method call results (#26) (#71)

* test: add test for annotation on same line as method (issue #44)

- Add test case for annotation on same line as method declaration
- Test verifies correct highlighting in this scenario
- Test currently passes, indicating issue may already be resolved

Closes #44

* test: add tests for ternary expressions (issue #43)

- Add test cases for nested ternary expressions
- Add test case for ternary with method calls
- Tests verify correct highlighting in these scenarios
- Tests currently pass, indicating issue may already be resolved

Closes #43

* fix: DML operations on method call results (issue #26)

- Add dml-expression pattern to handle DML operations on expressions
- Pattern matches insert/update/delete/upsert/undelete followed by expressions
- Ensures DML operations receive same scope (support.function.apex) whether
  applied to new objects or method call results like Map.values()
- Add test case verifying insert accounts.values() gets same scope as insert new List

Closes #26

* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to use 'Id' instead of 'ID' to match Apex convention
- Add test cases for namespace-qualified extends and implements

Closes #50

* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50

* test: add coverage for both Id and ID (case-insensitive Apex)

- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type

* feat: support for varied casing on ID/Id

* fix: Add syntax highlighting for initialization blocks

Add initializer-block pattern to grammar to properly highlight code
inside initialization blocks (standalone { } blocks at class member level).
The pattern matches standalone curly brace blocks and includes statement
patterns for proper syntax highlighting, matching method body behavior.

Fixes: forcedotcom/salesforcedx-vscode#4920

* test: Add tests for initialization block syntax highlighting

Add comprehensive tests to verify initialization blocks are properly
highlighted, including:
- Empty initialization blocks
- Method calls with string literals (the main issue #4920)
- Multiple statements
- Nested class scenario
- Comparison with method body highlighting

* test: Add test for static keyword before block

Even though Apex doesn't support static initialization blocks,
verify the grammar handles the syntax for highlighting purposes.

* fix: Fix switch/when statement syntax highlighting and brace matching

- Remove lookbehind end patterns from all when-* statements that prevented proper brace matching
- Update end patterns to use lookahead that ends on closing brace or next when clause
- Improve when-string pattern to support multiple comma-separated strings
- Fix issue #2134: syntax highlighting and brace matching for switch/when statements

All switch statement tests passing.

* fix: Fix dash highlighting in switch statement string literals

- Remove quote character from when-statement pattern character class
- Change from ['_\-[:alnum:]]+ to [_\-[:alnum:]]+
- Ensures string literals with dashes like 'de-CH' and 'fr-CH' are matched by when-string pattern
- Add test case for string literals containing dashes in switch statements

This fixes an issue where the when-statement pattern would incorrectly match
string literals containing dashes, preventing proper syntax highlighting.

* fix: support namespace-qualified types in extends/implements (#50) (#72)

* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50

* test: add coverage for both Id and ID (case-insensitive Apex)

- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type

* feat: support for varied casing on ID/Id

* chore: pr reproducers in sfdx project for visual inspection

* fix: 4920 initializer block syntax W-19265631 (#73)

* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50

* test: add coverage for both Id and ID (case-insensitive Apex)

- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type

* feat: support for varied casing on ID/Id

* fix: Add syntax highlighting for initialization blocks

Add initializer-block pattern to grammar to properly highlight code
inside initialization blocks (standalone { } blocks at class member level).
The pattern matches standalone curly brace blocks and includes statement
patterns for proper syntax highlighting, matching method body behavior.

Fixes: forcedotcom/salesforcedx-vscode#4920

* test: Add tests for initialization block syntax highlighting

Add comprehensive tests to verify initialization blocks are properly
highlighted, including:
- Empty initialization blocks
- Method calls with string literals (the main issue #4920)
- Multiple statements
- Nested class scenario
- Comparison with method body highlighting

* test: Add test for static keyword before block

Even though Apex doesn't support static initialization blocks,
verify the grammar handles the syntax for highlighting purposes.

* fix: Fix switch/when statement syntax highlighting and brace matching (issue #2134) (#74)

* fix: support namespace-qualified types in extends/implements (issue #50)

- Update extends-class pattern to handle namespace-qualified types
- Update implements-class pattern to handle namespace-qualified types
- Patterns now correctly tokenize System.Exception, Database.Batchable, etc.
- Use lookahead to distinguish namespace-qualified from simple types
- Fix type-builtin to support both 'Id' and 'ID' (Apex is case-insensitive)
- Add test cases for namespace-qualified extends and implements

Closes #50

* test: add coverage for both Id and ID (case-insensitive Apex)

- Add test for Id (lowercase d) as field type
- Add test for ID (uppercase D) as field type
- Add test for Id in generic type parameters
- Add test for ID in generic type parameters
- Verifies Apex case-insensitive support for Id/ID primitive type

* feat: support for varied casing on ID/Id

* fix: Add syntax highlighting for initialization blocks

Add initializer-block pattern to grammar to properly highlight code
inside initialization blocks (standalone { } blocks at class member level).
The pattern matches standalone curly brace blocks and includes statement
patterns for proper syntax highlighting, matching method body behavior.

Fixes: forcedotcom/salesforcedx-vscode#4920

* test: Add tests for initialization block syntax highlighting

Add comprehensive tests to verify initialization blocks are properly
highlighted, including:
- Empty initialization blocks
- Method calls with string literals (the main issue #4920)
- Multiple statements
- Nested class scenario
- Comparison with method body highlighting

* test: Add test for static keyword before block

Even though Apex doesn't support static initialization blocks,
verify the grammar handles the syntax for highlighting purposes.

* fix: Fix switch/when statement syntax highlighting and brace matching

- Remove lookbehind end patterns from all when-* statements that prevented proper brace matching
- Update end patterns to use lookahead that ends on closing brace or next when clause
- Improve when-string pattern to support multiple comma-separated strings
- Fix issue #2134: syntax highlighting and brace matching for switch/when statements

All switch statement tests passing.

* fix: Fix dash highlighting in switch statement string literals

- Remove quote character from when-statement pattern character class
- Change from ['_\-[:alnum:]]+ to [_\-[:alnum:]]+
- Ensures string literals with dashes like 'de-CH' and 'fr-CH' are matched by when-string pattern
- Add test case for string literals containing dashes in switch statements

This fixes an issue where the when-statement pattern would incorrectly match
string literals containing dashes, preventing proper syntax highlighting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DML operations receive different TM scope when being applied to the result of Map.values().

1 participant