Skip to content

Conversation

@AbdullinAM
Copy link
Member

Enable new KDoc resolution algorithm and add tests

@AbdullinAM AbdullinAM marked this pull request as ready for review December 18, 2025 14:49
@AbdullinAM AbdullinAM force-pushed the abdullin/kdoc-ambiguity-resolution branch from ce77cc5 to 65dff32 Compare December 18, 2025 16:17
compileOnly(libs.kotlinx.coroutines.core)

// to gain access to com.intellij.diagnostic.LoadingState in the compile time
compileOnly(libs.intellij.util.base)
Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason LoadingState bundled with the analysis api/compiler does not contains necessary APIs. We have the correct version of the LoadingState in the runtime

| * some text
| *
| * @see String
| * @throws Unit
Copy link
Contributor

@vmishenev vmishenev Dec 19, 2025

Choose a reason for hiding this comment

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

This case is quite unexpected without printing the reason. The KEEP only says @exception / @throws must only be resolvable to Throwables. Anyway, Dokka and the IDE should warn or print an error.
Maybe this should be resolved to better understand the misuse. A user should understand where the link refers, especially when it is ambiguous.
General idea:

class MyException : Exception
class Usage { 
        fun MyException()...
        /**
        @throws MyException
        */
        fun usage() {
        }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

IDE currently highlights this as a warning, makes sense to add a warning to Dokka too 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

It is already logged as a warning:

 /**
  * @throws String
  */
funfoo(arg: Int) {}
w: [:composeApp:dokkaGeneratePublicationHtml] Couldn't resolve link for String in main.kt/org.example.project.foo

Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, this warning should be enough.
Might make sense to add a test for unresolved links in a separate PR?

Copy link
Contributor

@vmishenev vmishenev Dec 22, 2025

Choose a reason for hiding this comment

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

I would make this message more straightforward about the reason: In this case, String should be Throwable.
There are two tpes of errors where the link:

  • is resolved, but not Throwable
  • is unresolved (e.g., because of a typo).

It seems we cannot distinguish between these two cases because the AA returns nothing in both.
Or do we agree Couldn't resolve link for String is enough?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, it would be nice to have a better message here, but I think that we will not be able to do it without some additional information from AA.

I think that for now, this warning should be enough, and we should probably create an issue on the AA side to design how this could be supported (in both IDE and Dokka). Perhaps in this case, we need to have some diagnostics inside AA that we can propagate to users? Or still return types from the AA resolver and then additionally check those? (hope not) I don't know.

@AbdullinAM AbdullinAM force-pushed the abdullin/kdoc-ambiguity-resolution branch from 65dff32 to 43e6081 Compare December 19, 2025 17:03
@AbdullinAM AbdullinAM requested a review from vmishenev December 19, 2025 18:04
@AbdullinAM
Copy link
Member Author

The failing tests on CI seem to be caused by external issues, master fails with same errors

@whyoleg
Copy link
Collaborator

whyoleg commented Dec 22, 2025

Note: TC IT are red because of #4402 (comment)

Copy link
Collaborator

@whyoleg whyoleg left a comment

Choose a reason for hiding this comment

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

Nice!
Looks like KT-83152 is the last piece of the puzzle here!

| * some text
| *
| * @see String
| * @throws Unit
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, this warning should be enough.
Might make sense to add a test for unresolved links in a separate PR?


@Test
@OnlySymbols("KEEP #389: New KDoc resolution")
fun `short link should lead to package rather than function K2`() = withExperimentalKDocResolution {
Copy link
Collaborator

Choose a reason for hiding this comment

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

test should be renamed, as with new resolution, it should lead to the function rather than package (and the test shows it)


@Test
@OnlySymbols("KEEP #389: New KDoc resolution")
fun `fully qualified link should lead to package K2`() = withExperimentalKDocResolution {
Copy link
Collaborator

Choose a reason for hiding this comment

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

as in the test below - the name of the test is missleading now



@Test
@Ignore("KT-83152 [Analysis API, KDoc] Make class name links on constructors point to the class")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's create an issue in Dokka to track it and put it here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or we could reuse #3604

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.

4 participants