@naturalcycles/dev-lib 20.12.3 → 20.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -54,6 +54,11 @@ function isMethodOverload(node) {
|
|
|
54
54
|
|
|
55
55
|
function getInsertionTarget(sourceCode, prevNode, nextNode) {
|
|
56
56
|
const decoratorTarget = findDecoratorTarget(sourceCode, prevNode, nextNode)
|
|
57
|
+
const baseNode = nextNode.declaration || nextNode
|
|
58
|
+
const targetStart = decoratorTarget?.range?.[0] ?? baseNode?.range?.[0] ?? nextNode.range[0]
|
|
59
|
+
const docCommentTarget = findDocCommentBeforeIndex(sourceCode, prevNode, targetStart)
|
|
60
|
+
if (docCommentTarget) return docCommentTarget
|
|
61
|
+
|
|
57
62
|
const commentTarget = findLeadingComment(sourceCode, prevNode, nextNode)
|
|
58
63
|
|
|
59
64
|
let target = decoratorTarget || nextNode
|
|
@@ -88,6 +93,17 @@ function findDecoratorTarget(sourceCode, prevNode, nextNode) {
|
|
|
88
93
|
return { range: [absolute, absolute], loc: null }
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
function findDocCommentBeforeIndex(sourceCode, prevNode, targetStart) {
|
|
97
|
+
if (targetStart === undefined || targetStart <= prevNode.range[1]) return null
|
|
98
|
+
|
|
99
|
+
const slice = sourceCode.text.slice(prevNode.range[1], targetStart)
|
|
100
|
+
const docMatch = slice.match(/(\/\*\*[\s\S]*?\*\/)([ \t]*\r?\n[ \t]*)?$/)
|
|
101
|
+
if (!docMatch || docMatch.index === undefined) return null
|
|
102
|
+
|
|
103
|
+
const commentStart = prevNode.range[1] + docMatch.index
|
|
104
|
+
return { range: [commentStart, commentStart], loc: null }
|
|
105
|
+
}
|
|
106
|
+
|
|
91
107
|
function hasBlankLineBetween(sourceCode, prevNode, nextNode) {
|
|
92
108
|
if (!prevNode || !nextNode) return false
|
|
93
109
|
if (!prevNode.range || !nextNode.range) return false
|