✨ feat(vscode): 有说明的函数、类卡片也能重写注释
重写按钮不再只挂在单独的注释卡片上。只替换说明那几行,上下文用这块代码,不当成文件顶上的说明。
This commit is contained in:
1 parent
b608f6cb87
commit
a66e4410e7
5 files changed
+46
-7
No files matched your search
@@ -219,6 +219,16 @@ function ownDoc(block: CodeBlock): Node | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
/** 能重写的那段注释:注释块是整块;函数、类、枚举、异常、常量、变量是它的说明。没有说明就没有。 */
|
||||
export function commentSpan(block: CodeBlock): { startLine: number, endLine: number } | undefined {
|
||||
if (block.kind === 'comment')
|
||||
return { startLine: block.header.startRow, endLine: block.header.endRow }
|
||||
const doc = ownDoc(block)
|
||||
if (!doc)
|
||||
return undefined
|
||||
return { startLine: doc.startPosition.row, endLine: doc.endPosition.row }
|
||||
}
|
||||
|
||||
/** 类属性的说明,照源码顺序:紧挨在它上面的注释块、它这一行行尾的注释、Python 紧跟在后面的属性 docstring。 */
|
||||
function fieldDocs(children: readonly CodeBlock[], block: CodeBlock): Node[] {
|
||||
const trailing = block.node.nextNamedSibling
|
||||
|
||||
Reference in new issue
Block a user