initial support for extracting comments
This commit is contained in:
@@ -139,16 +139,23 @@ class KDoc(val outputDir: File) : KDocSupport() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun commentsFor(psiElement: DeclarationDescriptor): String {
|
protected fun commentsFor(descriptor: DeclarationDescriptor): String {
|
||||||
if (psiElement is PsiElement) {
|
val psiElement = try {
|
||||||
// This method is a hack. Doc comments should be easily accessible, but they aren't for now.
|
context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
// ignore exceptions on fake descriptors
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method is a hack. Doc comments should be easily accessible, but they aren't for now.
|
||||||
|
if (psiElement != null) {
|
||||||
var node = psiElement.getNode()?.getTreePrev()
|
var node = psiElement.getNode()?.getTreePrev()
|
||||||
while (node != null && (node?.getElementType() == JetTokens.WHITE_SPACE || node?.getElementType() == JetTokens.BLOCK_COMMENT)) {
|
while (node != null && (node?.getElementType() == JetTokens.WHITE_SPACE || node?.getElementType() == JetTokens.BLOCK_COMMENT)) {
|
||||||
node = node?.getTreePrev();
|
node = node?.getTreePrev()
|
||||||
}
|
}
|
||||||
if (node == null) return "";
|
if (node == null) return ""
|
||||||
if (node?.getElementType() != JetTokens.DOC_COMMENT) return "";
|
if (node?.getElementType() != JetTokens.DOC_COMMENT) return ""
|
||||||
return node?.getText() ?: "";
|
return node?.getText() ?: ""
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user