Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: linking Java sources broken in 1.7.0 #2544

Closed
DanySK opened this issue Jun 21, 2022 · 2 comments · Fixed by #2547
Closed

Regression: linking Java sources broken in 1.7.0 #2544

DanySK opened this issue Jun 21, 2022 · 2 comments · Fixed by #2547
Assignees
Labels

Comments

@DanySK
Copy link

DanySK commented Jun 21, 2022

Describe the bug

Dokka used to be able to link Java sources, see, e.g., https://alchemistsimulator.github.io/reference/kdoc/alchemist/it.unibo.alchemist.core.implementations/-engine/add-output-monitor.html

Since 1.7.0, dokkaHtmlCollector fails with textRange must not be null.

Expected behaviour

Dokka does not fail, the generated documentation links Java sources as it used to do in 1.6.x

To Reproduce

git clone https://github.com/AlchemistSimulator/Alchemist.git
cd Alchemist
git checkout renovate/dokka
./gradlew dokkaHtmlCollector

Dokka configuration
Configuration of dokka used to reproduce the bug

    tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
        dokkaSourceSets.configureEach {
            jdkVersion.set(multiJvm.jvmVersionForCompilation)
            listOf("kotlin", "java") // remove "java" from this list to "fix" the bug!
                .map { "src/main/$it" }
                .map { it to File(projectDir, it) }
                .toMap()
                .filterValues { it.exists() }
                .forEach { (path, file) ->
                    sourceLink {
                        localDirectory.set(file)
                        val project = if (project == rootProject) "" else project.name
                        val url = "https://github.com/AlchemistSimulator/Alchemist/blob/master/$project/$path"
                        remoteUrl.set(uri(url).toURL())
                        remoteLineSuffix.set("#L")
                    }
                }
            configurations.implementation.get().dependencies.forEach { dep ->
                val javadocIOURLs = fetchJavadocIOForDependency(dep)
                if (javadocIOURLs != null) {
                    val (javadoc, packageList) = javadocIOURLs
                    externalDocumentationLink {
                        url.set(javadoc)
                        packageListUrl.set(packageList)
                    }
                }
            }
        }
        failOnWarning.set(true)
    }

Note: removing "java" from the list above "fixes" the issue (it just turns off the source linking for Java sources).

Installation

Additional context

Mixed Java-Kotlin projects (originally in Java, new parts written in Kotlin, slowly transitating to Kt).

Are you willing to provide a PR?

I have no idea what to fix, I need guidance at the very least.

@IgnatBeresnev
Copy link
Member

IgnatBeresnev commented Jun 21, 2022

Hi! Thanks for the report, this one was not expected :) Your project is rather good for testing releases on, I must admit

The change must've come from bumping intellij platform from 211 to 213, we use it to analyze Java sources among other things. This commit to be exact

EnumSyntheticMethod used to be extends LightMethod, which had overridden getTextRange()

@Override
public TextRange getTextRange() {
  return myMethod.getTextRange();
}

But I can see now that it's been changed to extends LightElement, implements PsiMethod, and LightElement only has the default implementation which returns null:

@Override
public TextRange getTextRange() {
  return null;
}

Thus NPE.

We should probably just ignore all synthetic elements. I'll fix it and it'll be released in 1.7.10 in roughly two weeks.


Debug screenshot for future references:

2022-06-21_19-28-11

@DanySK
Copy link
Author

DanySK commented Jun 22, 2022

@IgnatBeresnev nice bug hunt 🔫

Yeah, if you provide me with a tool I usually stress it as much as I can 😄

I don't know how the test suite of Dokka is built, but, in general, it should be possible to import external projects as submodules, then, when testing with the Gradle toolkit, patch them to run the current in-development version of a Gradle plugin. I do something similar with my own plugins.

Issue-wise, I'll be waiting for 1.7.10 (to be fair, my update bot will, I will hopefully just observe the result 😄 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants