You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[kotlin] Request for an XPath function as simple partial replacement of missing typeIs function #4858
Is your feature request related to a problem? Please describe.
Because of a missing typeIf function in Kotlin, we are checking if the expected package of the type is imported, to come close to typeIs functionality. This is a verbose expression in XPath on the verbose parse tree and often needed.
Describe the solution you'd like
A function called hasImport with expected package as argument.
Example: /KotlinFile[pmd-kotlin:hasImport('javax.xml.xpath')]
Describe alternatives you've considered
copy-paste every time: we want to avoid this and be more concise
create a proper concise AST out of the kotlin parse tree: don't know how to do this, expected a lot of work
create a real typeIs function for Kotlin: expected to be difficult and much work
Additional context
This would be a small step to improve productivity of creating rule. Maybe one of the above could be next step.
I do have a initial version in a my repo fork in the 'pmd/7.0.0x-kotlin/hasImport' branch.
Not sure this is the way to go, so feedback requested.
changed the title [-]Request for Kotlin XPath function as simple partly replacement of missing typeIs function[/-][+][kotlin] Request for an XPath function as simple partial replacement of missing typeIs function[/+]on Mar 11, 2024
Activity
Initial version hasImport - Request for Kotlin XPath function as simp…
[-]Request for Kotlin XPath function as simple partly replacement of missing typeIs function[/-][+][kotlin] Request for an XPath function as simple partial replacement of missing typeIs function[/+]adangel commentedon Mar 14, 2024
Just for reference, the boilerplate XPath expression looks like this: