From e22a690211df27d900bb1648686e8e7189f3b578 Mon Sep 17 00:00:00 2001
From: "PMD CI (pmd-bot)"
When PMD added Apex support with version 5.5.0, it utilized the Apex Jorje library to parse Apex source +and generate an AST. This library is however a binary-blob provided as part of the +Salesforce Extensions for VS Code, and it is closed-source.
+ +This causes problems, if binary blobs are not allowed by e.g. a company-wide policy. In that case, the Jorje +library prevented that PMD Apex could be used at all.
+ +Also having access to the source code, enhancements and modifications are easier to do.
+ +Under the hood, we use two open source libraries instead:
+ +Although the parsers is completely switched, there are only little known changes to the AST. +These are documented in the Migration Guide for PMD 7: Apex AST.
+ +See #3766 for details.
+ +Contributors: Aaron Hurst (@aaronhurst-google), + Edward Klimoshenko (@eklimo)
+Support for HTML was introduced in PMD 6.55.0 as an experimental feature. With PMD 7.0.0 this @@ -2131,6 +2160,11 @@ The rules have been moved into categories with PMD 6.
ASTMethod
has been removed.
+With the switch from Jorje to Summit AST as underlying parser, no synthetic methods are generated by the
+parser anymore. This also means, that there is no XPath attribute @Synthetic
anymore.STATIC_INITIALIZER_METHOD_NAME
in FieldDeclarationsShouldBeAtStartRule
+has been removed. It was used to filter out synthetic methods, but these are not generated anymore with the
+new parser.getContext()
in ASTReferenceExpression
has been removed.
+It was not used and always returned null
.getNamespace()
in all AST nodes (defined in ApexNode
) has
+been removed, as it was never fully implemented. It always returned an empty string.getNameSpace()
in ApexQualifiedName
has been removed.net.sourceforge.pmd.lang.apex.ast.ASTBridgeMethodCreator
has been removed. This was a node that has
+been generated by the old Jorje parser only.net.sourceforge.pmd.util.Predicate
has been removed. It was marked as Experimental before. Use
@@ -2939,6 +2995,15 @@ has been removed as well. If you don’t want colors, use External Contributions
+ - #4093: [apex] Summit-AST Apex module - Part 1 - Edward Klimoshenko (@eklimo)
+ - #4151: [apex] Summit-AST Apex module - Part 2 - expression nodes - Aaron Hurst (@aaronhurst-google)
+ - #4171: [apex] Summit-AST Apex module - Part 3 - initializers - Aaron Hurst (@aaronhurst-google)
+ - #4206: [apex] Summit-AST Apex module - Part 4 - statements - Aaron Hurst (@aaronhurst-google)
+ - #4219: [apex] Summit-AST Apex module - Part 5 - annotations, triggers, misc. - Aaron Hurst (@aaronhurst-google)
+ - #4242: [apex] Merge 6.52 into experimental-apex-parser - Aaron Hurst (@aaronhurst-google)
+ - #4251: [apex] Summit-AST Apex module - Part 6 Passing testsuite - Aaron Hurst (@aaronhurst-google)
+ - #4448: [apex] Bump summit-ast to new release 2.1.0 (and remove workaround) - Aaron Hurst (@aaronhurst-google)
+ - #4479: [apex] Merge main (7.x) branch into experimental-apex-parser and fix tests - Aaron Hurst (@aaronhurst-google)
- #4640: [cli] Launch script fails if run via “bash pmd” - Shai Bennathan (@shai-bennathan)
- #4673: [javascript] CPD: Added support for decorator notation - Wener (@wener-tiobe)
- #4677: [apex] Add new rule: OperationWithHighCostInLoop - Thomas Prouvot (@tprouvot)
@@ -3132,11 +3197,6 @@ literals were ignored. The new option additional ignores identifiers as well in
- See PR #4470 for details.
-Changed: Apex Jorje Updated
-
-With the new version of Apex Jorje, the new language constructs like User Mode Database Operations
-can be parsed now. PMD should now be able to parse Apex code up to version 59.0 (Winter ‘23).
-
Changed: Groovy Support (CPD)
@@ -3145,6 +3205,35 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0
- See PR #4726 for details.
+Changed: Apex Support: Replaced Jorje with fully open source front-end
+
+When PMD added Apex support with version 5.5.0, it utilized the Apex Jorje library to parse Apex source
+and generate an AST. This library is however a binary-blob provided as part of the
+Salesforce Extensions for VS Code, and it is closed-source.
+
+This causes problems, if binary blobs are not allowed by e.g. a company-wide policy. In that case, the Jorje
+library prevented that PMD Apex could be used at all.
+
+Also having access to the source code, enhancements and modifications are easier to do.
+
+Under the hood, we use two open source libraries instead:
+
+
+ - apex-parser by Kevin Jones (@nawforce)
+This project provides the grammar for a ANTLR based parser.
+ - Summit-AST by Google (@google)
+This project translates the ANTLR parse tree into an AST, that is similar to the AST Jorje provided.
+Note: This is not an official Google product.
+
+
+Although the parsers is completely switched, there are only little known changes to the AST.
+These are documented in the Migration Guide for PMD 7: Apex AST.
+
+See #3766 for details.
+
+Contributors: Aaron Hurst (@aaronhurst-google),
+Edward Klimoshenko (@eklimo)
+
Changed: Rule properties
@@ -3504,6 +3593,7 @@ of the changes listed here, see Detailed R
- #1648: [apex,vf] Remove CodeClimate dependency
- #1750: [apex] Remove apex statistical rules
- #2836: [apex] Remove Apex ProjectMirror
+ - #3766: [apex] Replace Jorje with fully open source front-end
- #3973: [apex] Update parser to support new ‘as user’ keywords (User Mode for Database Operations)
- #4427: [apex] ApexBadCrypto test failing to detect inline code
- #4453: [apex] [7.0-rc1] Exception while initializing Apexlink (Index 34812 out of bounds for length 34812)
@@ -3775,6 +3865,13 @@ of the changes listed here, see Detailed R
- #1882: [swift] UnavailableFunction Swift rule - Tomás de Lucca (@tomidelucca)
- #2830: [apex] Apexlink POC - Kevin Jones (@nawforce)
- #3866: [core] Add CLI Progress Bar - @JerritEic (@JerritEic)
+ - #4093: [apex] Summit-AST Apex module - Part 1 - Edward Klimoshenko (@eklimo)
+ - #4151: [apex] Summit-AST Apex module - Part 2 - expression nodes - Aaron Hurst (@aaronhurst-google)
+ - #4171: [apex] Summit-AST Apex module - Part 3 - initializers - Aaron Hurst (@aaronhurst-google)
+ - #4206: [apex] Summit-AST Apex module - Part 4 - statements - Aaron Hurst (@aaronhurst-google)
+ - #4219: [apex] Summit-AST Apex module - Part 5 - annotations, triggers, misc. - Aaron Hurst (@aaronhurst-google)
+ - #4242: [apex] Merge 6.52 into experimental-apex-parser - Aaron Hurst (@aaronhurst-google)
+ - #4251: [apex] Summit-AST Apex module - Part 6 Passing testsuite - Aaron Hurst (@aaronhurst-google)
- #4402: [javascript] CPD: add support for Typescript using antlr4 grammar - Paul Guyot (@pguyot)
- #4403: [julia] CPD: Add support for Julia code duplication - Wener (@wener-tiobe)
- #4412: [doc] Added new error msg to ConstantsInInterface - David Ljunggren (@dague1)
@@ -3782,10 +3879,12 @@ of the changes listed here, see Detailed R
- #4428: [apex] ApexBadCrypto bug fix for #4427 - inline detection of hard coded values - Steven Stearns (@sfdcsteve)
- #4431: [coco] CPD: Coco support for code duplication detection - Wener (@wener-tiobe)
- #4444: [java] CommentDefaultAccessModifier - ignore org.junit.jupiter.api.extension.RegisterExtension by default - Nirvik Patel (@nirvikpatel)
+ - #4448: [apex] Bump summit-ast to new release 2.1.0 (and remove workaround) - Aaron Hurst (@aaronhurst-google)
- #4450: [java] Fix #4449 AvoidAccessibilityAlteration: Correctly handle Lambda expressions in PrivilegedAction scenarios - Seren (@mohui1999)
- #4452: [doc] Update PMD_APEX_ROOT_DIRECTORY documentation reference - nwcm (@nwcm)
- #4470: [cpp] CPD: Added strings as literal and ignore identifiers in sequences - Wener (@wener-tiobe)
- #4474: [java] ImmutableField: False positive with lombok (fixes #4254) - Pim van der Loos (@PimvanderLoos)
+ - #4479: [apex] Merge main (7.x) branch into experimental-apex-parser and fix tests - Aaron Hurst (@aaronhurst-google)
- #4488: [java] Fix #4477: A false-positive about SignatureDeclareThrowsException - AnnaDev (@LynnBroe)
- #4494: [java] Fix #4487: A false-positive about UnnecessaryConstructor and @Inject and @Autowired - AnnaDev (@LynnBroe)
- #4495: [java] Fix #4493: false-positive about MissingStaticMethodInNonInstantiatableClass and @Inject - AnnaDev (@LynnBroe)
diff --git a/pmd_rules_apex_errorprone.html b/pmd_rules_apex_errorprone.html
index 944a6cefb6..ca9560c6d9 100644
--- a/pmd_rules_apex_errorprone.html
+++ b/pmd_rules_apex_errorprone.html
@@ -2102,8 +2102,17 @@ or reported.
Empty block statements serve no purpose and should be removed.
This rule is defined by the following XPath expression:
-//Method[$reportEmptyPrivateNoArgConstructor = true() or (@Constructor != true() or ./ModifierNode[@Private != true()] or ./Parameter[count(*) > 0])]/ModifierNode[@Abstract != true() and ($reportEmptyVirtualMethod = true() or @Virtual != true()) and ../BlockStatement[count(*) = 0]]
-| //Method/BlockStatement//BlockStatement[count(*) = 0 and @RealLoc = true()]
+//Method[$reportEmptyPrivateNoArgConstructor = true()
+ or (@Constructor != true()
+ or ./ModifierNode[@Private != true()]
+ or ./Parameter[count(*) > 0])]/ModifierNode[@Abstract != true()
+ and ($reportEmptyVirtualMethod = true() or @Virtual != true())
+ and ../BlockStatement[count(*) = 0]
+ ]
+| //Method/BlockStatement//BlockStatement
+ [not(parent::CatchBlockStatement)]
+ [count(*) = 0]
+ [@RealLoc = true()]
Example(s):
diff --git a/pmd_userdocs_migrating_to_pmd7.html b/pmd_userdocs_migrating_to_pmd7.html
index 177cddba6c..8005e28417 100644
--- a/pmd_userdocs_migrating_to_pmd7.html
+++ b/pmd_userdocs_migrating_to_pmd7.html
@@ -5328,6 +5328,32 @@ parenthesis, which makes it harder to fool rules that look at the structure of t
+Apex AST
+
+PMD 7.0.0 switched the underlying parser for Apex code from Jorje to Summit AST,
+which is based on an open source grammar for Apex: apex-parser.
+
+The produced AST is mostly compatible, there are some unavoidable changes however:
+
+
+ - Node
Method
(ASTMethod
)
+
+ - No attribute
@Synthetic
anymore. Unlike Jorje, Summit AST doesn’t generate synthetic methods anymore, so
+this attribute would have been always false and is of no use. Therefore it has been removed completely.
+ - There will be no methods anymore with the name
<clinit>
, <init>
.
+
+
+ - There is no node
BridgeMethodCreator
anymore. This was an artificially generated node by Jorje. Since the
+new parser doesn’t generate synthetic methods anymore, this node is not needed anymore.
+ - There is in general no attribute
@Namespace
anymore. The attribute has been removed, as it was never fully
+implemented. It always returned an empty string.
+ - Node
ReferenceExpression
(ASTReferenceExpression
)
+
+ - No attribute
@Context
anymore. It was not used and always returned null
.
+
+
+
+
Language versions