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
Fix incorrect handling of static members used within @see
tag
#2627
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -517,76 +517,73 @@ class ContentForSeeAlsoTest : BaseAbstractTest() { | |
} | ||
|
||
@Test | ||
fun `undocumented see also from java`(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved two tests to |
||
fun `should prefix static function and property links with class name`() { | ||
testInline( | ||
""" | ||
|/src/main/java/example/Source.java | ||
|package example; | ||
|/src/main/kotlin/com/example/package/CollectionExtensions.kt | ||
|package com.example.util | ||
| | ||
|public interface Source { | ||
| String getProperty(String k, String v); | ||
| | ||
| /** | ||
| * @see #getProperty(String, String) | ||
| */ | ||
| String getProperty(String k); | ||
|object CollectionExtensions { | ||
| val property = "Hi" | ||
| fun emptyList() {} | ||
|} | ||
""".trimIndent(), testConfiguration | ||
) { | ||
documentablesTransformationStage = { module -> | ||
val functionWithSeeTag = module.packages.flatMap { it.classlikes }.flatMap { it.functions }.find { it.name == "getProperty" && it.parameters.count() == 1 } | ||
val seeTag = functionWithSeeTag?.docs()?.firstIsInstanceOrNull<See>() | ||
val expectedLinkDestinationDRI = DRI( | ||
packageName = "example", | ||
classNames = "Source", | ||
callable = Callable( | ||
name = "getProperty", | ||
params = listOf(JavaClassReference("java.lang.String"), JavaClassReference("java.lang.String")) | ||
) | ||
) | ||
|
||
kotlin.test.assertNotNull(seeTag) | ||
assertEquals("getProperty(String, String)", seeTag.name) | ||
assertEquals(expectedLinkDestinationDRI, seeTag.address) | ||
assertEquals(emptyList(), seeTag.children) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `documented see also from java`(){ | ||
testInline( | ||
""" | ||
|/src/main/java/example/Source.java | ||
|package example; | ||
| | ||
|public interface Source { | ||
| String getProperty(String k, String v); | ||
|/src/main/kotlin/com/example/foo.kt | ||
|package com.example | ||
| | ||
| /** | ||
| * @see #getProperty(String, String) this is a reference to a method that is present on the same class. | ||
| */ | ||
| String getProperty(String k); | ||
|} | ||
""".trimIndent(), testConfiguration | ||
|import com.example.util.CollectionExtensions.property | ||
|import com.example.util.CollectionExtensions.emptyList | ||
| | ||
|/** | ||
| * @see [property] static property | ||
| * @see [emptyList] static emptyList | ||
| */ | ||
|fun function() {} | ||
""".trimIndent(), | ||
testConfiguration | ||
) { | ||
documentablesTransformationStage = { module -> | ||
val functionWithSeeTag = module.packages.flatMap { it.classlikes }.flatMap { it.functions }.find { it.name == "getProperty" && it.parameters.size == 1 } | ||
val seeTag = functionWithSeeTag?.docs()?.firstIsInstanceOrNull<See>() | ||
val expectedLinkDestinationDRI = DRI( | ||
packageName = "example", | ||
classNames = "Source", | ||
callable = Callable( | ||
name = "getProperty", | ||
params = listOf(JavaClassReference("java.lang.String"), JavaClassReference("java.lang.String")) | ||
) | ||
) | ||
pagesTransformationStage = { module -> | ||
val page = module.children.single { it.name == "com.example" } | ||
.children.single { it.name == "function" } as ContentPage | ||
|
||
kotlin.test.assertNotNull(seeTag) | ||
assertEquals("getProperty(String, String)", seeTag.name) | ||
assertEquals(expectedLinkDestinationDRI, seeTag.address) | ||
assertEquals("this is a reference to a method that is present on the same class.", seeTag.children.first().text().trim()) | ||
assertEquals(1, seeTag.children.size) | ||
page.content.assertNode { | ||
group { | ||
header(1) { +"function" } | ||
} | ||
divergentGroup { | ||
divergentInstance { | ||
divergent { | ||
bareSignature( | ||
annotations = emptyMap(), | ||
visibility = "", | ||
modifier = "", | ||
keywords = emptySet(), | ||
name = "function", | ||
returnType = null, | ||
) | ||
} | ||
after { | ||
header(4) { +"See also" } | ||
group { | ||
table { | ||
group { | ||
link { +"CollectionExtensions.property" } | ||
group { | ||
group { +"static property" } | ||
} | ||
} | ||
group { | ||
link { +"CollectionExtensions.emptyList" } | ||
group { | ||
group { +"static emptyList" } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall problem is basically here.
For
com.example.Object.function()
it would returncom.example.Object
, so if you have multiple@see
tags that point to multiple different functions from the sameobject
- there would be name collisions, and some members would be discarded bygroupBy
further down the road.This function is overall very wrong, and it would take a lot of effort to make it right