Repository navigation
[kotlin] Fix #6677: Add auxClasspath language property - #6678
Conversation
Wire JvmLanguagePropertyBundle so --aux-classpath is accepted for Kotlin analysis. Introduce KotlinLanguageProcessor and KotlinAuxClasspathResolver (3-tier resolution: string property, URLClassLoader hierarchy, java.class.path system property). Note pmd#4953 TODO on getAnalysisClassLoader() tier for future deprecation. Add DataMap keys to KotlinNode ready for type-mapper population: - TYPE_NAME_KEY: resolved type FQN for PropertyDeclaration / UnescapedAnnotation - RETURN_TYPE_KEY: resolved return type FQN for FunctionDeclaration - ANNOTATION_NAMES_KEY: comma-separated FQN annotation names on declaration nodes Refactor KotlinHandler to use XPathHandlerHolder pattern (deferred init). XPath functions (hasAnnotation, hasImport, etc.) registered in a follow-up PR.
40df60d to
f1edf89
Compare
|
Compared to main: (comment created at 2026-06-18 13:25:05+00:00 for d9c36f4) |
getTypeName() and getReturnTypeName() on KotlinNode return null before type analysis runs. Filter them out so they do not appear as null XPath attributes. Update Simple.txt reference dump accordingly.
…sspath-standalone
|
Hi @adangel, this PR is reworked to move as much as possible the code from KotlinNode, in line with previous related merged PRs. Can you please have a look? I think this is the next step to get to type awareness in Kotlin rules. |
adangel
left a comment
There was a problem hiding this comment.
Thanks for the PR.
Let's scope this PR down to just "[kotlin] Add auxclasspath language property" and add the KotlinNodeTypeData with the PR, that actually uses it.
So in short:
- Please remove KotlinNodeTypeData from this PR
- Make KotlinAuxClasspathResolver simpler to only support one way of configuring aux classpath.
- Refactor KotlinAuxClasspathResolver#resolve to return
List<Path>instead ofList<File> - Add documentation about the new auxclasspath language property for Kotlin
The XPath functions can only be added, when you have types... So, I guess, the next PR should then focus on integrating kotlin-type-mapper, adding the additional AST processing phase and put the types into the nodes. Also note: The types you have designed now are simple Strings... is this what you want? At some point, rules probably want to query something like "what are the methods of this type", or "is this type a subtype of this other type". Depending on the use cases, Strings are maybe too simple... (Note: I didn't look at all into #6645 - so not sure what use cases you already implemented). |
|
Thanks for the thorough review! I will go through each of the points. The three "tiers" of classpath handling were there for three usages:
If both Designer and tests can use the same approach we can indeed consolidate on one way. |
Scope this PR down to auxclasspath language property only. KotlinNodeTypeData will be added with the PR that actually uses it (kotlin-type-mapper integration).
…asspath property Only support the auxClasspath language property; remove URLClassLoader hierarchy and java.class.path fallbacks. Returns List<Path> instead of List<File>. Update tests accordingly.
- Log warning when auxClasspath is empty so users know type resolution will not work - Use tempDir.resolve() for non-existent paths in tests for determinism docs(kotlin): add auxclasspath section and language property entry Add "Providing the auxiliary classpath" section to kotlin.md and add auxClasspath entry to language_properties.md. Since 7.26.0.
…is PR Holder-class pattern belongs with the PR that adds XPath functions.
Changes
KotlinLanguageModulenow usesJvmLanguagePropertyBundleso--aux-classpathis accepted for Kotlin analysisKotlinLanguageProcessor+KotlinAuxClasspathResolver: resolves classpath entries via the language property auxClasspathRelated issues/PRs
Follow-up
KotlinNodeDataMap keys (TYPE_NAME_KEY,RETURN_TYPE_KEY,ANNOTATION_NAMES_KEY) + accessors — API contract for the kotlin-type-mapper to populateKotlinHandlerrefactored toXPathHandlerHolderpattern (deferred init); XPath functions registered in follow-up PRshasAnnotation,hasImport) and full kotlin-type-mapper integration are in separate PRs.