[kotlin] Request for an XPath function as simple partial replacement of missing typeIs function
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5.5k
- Forks
- 1.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 54
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository file or test; start with the reporter's pmd/7.0.0x-kotlin/hasImport branch and compare its initial implementation with the requested XPath example. Confirm the intended scope for a hasImport function; done means the example query works without the verbose import check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100