fix: DML operations on method call results (#26) - #71
Merged
mshanemc merged 19 commits intoOct 30, 2025
Merged
Conversation
- 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
* 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.
…edotcom/apex-tmLanguage into fix/issue-26-dml-map-values
…to fix/issue-26-dml-map-values
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tonew Listexpressions.Related Issues
Changes
dml-expressionpattern insrc/apex.tmLanguage.ymlto recognize DML operations followed by expressions (excludingnewkeyword which is handled separately)delete|insert|undelete|update|upsertfollowed by any expressioninsert accounts.values()receives same scope asinsert new List<Account>()support.function.apexTesting