Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vmishenev
Copy link
Contributor

@vmishenev vmishenev commented Jun 25, 2025

In K1, we register IDE's service JavadocManager, we could do the same in K2:
registerProjectService(JavadocManager::class.java, JavadocManagerImpl(project))
However, it seems unnecessary, since the link is unresolved in K1 as well.

@vmishenev vmishenev linked an issue Jun 25, 2025 that may be closed by this pull request
@vmishenev vmishenev force-pushed the vmishenev/4117-k2-Fix-NPE-in-javadoc-parsing branch from 7f017f1 to 3e2d889 Compare June 25, 2025 18:03
@vmishenev vmishenev force-pushed the vmishenev/4117-k2-Fix-NPE-in-javadoc-parsing branch from 3e2d889 to a23455d Compare June 25, 2025 18:06
@vmishenev
Copy link
Contributor Author

Notice

According to the specification , Javadoc links can have type parameters,

Parameterized types may be used in the class and member parts of the reference

In Dokka, rendered links and labels have no type parameters at all.

@vmishenev vmishenev requested a review from whyoleg June 26, 2025 11:51
@whyoleg
Copy link
Collaborator

whyoleg commented Jun 26, 2025

In K1, we register IDE's service JavadocManager; we could do the same in K2

Is there a reason not to do it in K2? I mean, if we don't register it, we may throw NPE in some cases when parsing Javadoc. But if we register it, as far as I understand, we will just receive some empty results instead of NPE.

Or maybe I'm wrong, and with the changes in this PR, we will not fall back to using JavadocManager at all?

@vmishenev
Copy link
Contributor Author

Or maybe I'm wrong, and with the changes in this PR, we will not fall back to using JavadocManager at all?

I mean this, at least in the current case. However, I do know why it was registered in K1. It just seems unnecessary.

valueElement ?: dataElements.firstOrNull { it !is PsiWhiteSpace }
dataElements.firstOrNull {
it.node.elementType == JavaDocElementType.DOC_REFERENCE_HOLDER ||
it.node.elementType == JavaDocElementType.DOC_METHOD_OR_FIELD_REF
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a comment on why those two specific types should be used here?
It's not really clear for me why only those two out of all JavaDocElementTypes we should care about

@vmishenev vmishenev merged commit 6b32cd6 into master Jul 28, 2025
12 of 14 checks passed
@vmishenev vmishenev deleted the vmishenev/4117-k2-Fix-NPE-in-javadoc-parsing branch July 28, 2025 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in javadoc parsing with K2 dokka

3 participants