No type information provided for CastExpression
With a type cast, there is no information about the type.
If I have this example code
class Test {
private void main() {
Id test = (Id) '006D600000ZaBOeIAN';
}
}
In the AST I would expect the CastExpression to provide a clue about the type, but this is all I get:
<CastExpression DefiningType='Test' Image='' RealLoc='true'>
The full XML for the sample code is as follows.
<?xml version='1.0' encoding='UTF-8' ?>
<ApexFile DefiningType='Test' Image='' RealLoc='true'>
<UserClass DefiningType='Test' Image='Test' InterfaceNames='[]' Nested='false' RealLoc='true' SimpleName='Test' SuperClassName=''>
<ModifierNode Abstract='false' DefiningType='Test' DeprecatedTestMethod='false' Final='false' Global='false' Image='' InheritedSharing='false' Modifiers='0' Override='false' Private='false' Protected='false' Public='false' RealLoc='false' Static='false' Test='false' TestOrTestSetup='false' Transient='false' Virtual='false' WebService='false' WithSharing='false' WithoutSharing='false' />
<Method Arity='0' CanonicalName='main' Constructor='false' DefiningType='Test' Image='main' RealLoc='true' ReturnType='void' StaticInitializer='false'>
<ModifierNode Abstract='false' DefiningType='Test' DeprecatedTestMethod='false' Final='false' Global='false' Image='' InheritedSharing='false' Modifiers='2' Override='false' Private='true' Protected='false' Public='false' RealLoc='true' Static='false' Test='false' TestOrTestSetup='false' Transient='false' Virtual='false' WebService='false' WithSharing='false' WithoutSharing='false' />
<BlockStatement CurlyBrace='true' DefiningType='Test' Image='' RealLoc='true'>
<VariableDeclarationStatements DefiningType='Test' Image='' RealLoc='true'>
<ModifierNode Abstract='false' DefiningType='Test' DeprecatedTestMethod='false' Final='false' Global='false' Image='' InheritedSharing='false' Modifiers='0' Override='false' Private='false' Protected='false' Public='false' RealLoc='false' Static='false' Test='false' TestOrTestSetup='false' Transient='false' Virtual='false' WebService='false' WithSharing='false' WithoutSharing='false' />
<VariableDeclaration DefiningType='Test' Image='test' RealLoc='true' Type='Id'>
<CastExpression DefiningType='Test' Image='' RealLoc='true'>
<LiteralExpression Boolean='false' Decimal='false' DefiningType='Test' Double='false' Image='006D600000ZaBOeIAN' Integer='false' LiteralType='STRING' Long='false' Name='' Null='false' RealLoc='true' String='true' />
</CastExpression>
<VariableExpression DefiningType='Test' Image='test' RealLoc='true'>
<EmptyReferenceExpression DefiningType='' Image='' RealLoc='false' />
</VariableExpression>
</VariableDeclaration>
</VariableDeclarationStatements>
</BlockStatement>
</Method>
</UserClass>
</ApexFile>
Thanks for reporting. This is however something, that needs to be fixed upstream in PMD. I've created an issue there: https://github.com/pmd/pmd/issues/5567
Happy to confirm this is now fixed in [email protected]. Thanks.
Can you clarify, what exactly you are using? The version number doesn't make sense to me (PMD is at 7.12.0, vscode-apex-pmd is at 0.8.0, so you must be using neither). Thanks.
Can you clarify, what exactly you are using? The version number doesn't make sense to me (PMD is at 7.12.0, vscode-apex-pmd is at 0.8.0, so you must be using neither). Thanks.
I may have reported this in the wrong place, I was reproducing the issue with the pmd-bin CLI not the VS Code extension.
Ok, thanks. I just wanted to make sure, we don't miss another downstream PMD project to be aware of...