From afd5f32e56d3d30bfa98fb35deff51febf50e594 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 11 Apr 2023 19:09:36 +0300 Subject: Improve extension --- atk16-syntax/extension.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'atk16-syntax/extension.js') diff --git a/atk16-syntax/extension.js b/atk16-syntax/extension.js index e49dd07..2c8e294 100644 --- a/atk16-syntax/extension.js +++ b/atk16-syntax/extension.js @@ -135,21 +135,20 @@ async function findSubroutineInDocument(document, labelText) { for (let i = 0; i < document.lineCount; i++) { const line = document.lineAt(i); if (line.text.includes(`@label ${labelText}`)) { - let labelDefinition = ''; for (let j = i + 1; j < document.lineCount; j++) { const docLine = document.lineAt(j); - const docCommentMatch = docLine.text.match(/;\? (.*)/); + const docCommentMatch = docLine.text.match(/;;;\s+(.*)/); if (docCommentMatch) { const lineText = docCommentMatch[1]; - const parts = lineText.split(/\s/); + const parts = lineText.trim().split(/\s+/g); if (lineText.startsWith('subroutine')) { - name = parts[parts.length - 1]; + name = parts[parts.length - 1].trim(); } else if (lineText.startsWith('param')) { - const [_, reg, ...desc] = parts; - params.push([reg, desc.join(" ")]) + const [_kw, reg, ...desc] = parts; + params.push([reg.trim(), desc.filter(a => a).join(" ")]) } else if (lineText.startsWith('return')) { - const [_, reg, ...desc] = parts; - returns.push([reg, desc.join(" ")]) + const [_kw, reg, ...desc] = parts; + returns.push([reg.trim(), desc.filter(a => a).join(" ")]) } else { extra += `${lineText}\n`; } -- cgit v1.3