From ffc17f89e447effe136fe59d67cca6009c50a127 Mon Sep 17 00:00:00 2001 From: Stephen M Moraco Date: Thu, 11 Jan 2024 01:15:03 -0700 Subject: [PATCH] fix settings use and adapt code to new eslint styles w/prettier formatting (now using code-standard typeScript) Update P1 & P2 - Adjust settings/configuration mechanism (turn on/off elastic tabs no longer requires vscode restart/reload) - Adjust text-cursor colors for our themes (Make them more visible and consistent with other themes) - NOTE: this does NOT affect the mouse pointer (arrow, or I-beam) which is controlled from your operating-system settings Update P2 Only - Minor DAT block highlighting fixes - Adjusted duplicate variable declaration message (clarified meaning) --- spin2/CHANGELOG.md | 15 +- spin2/LICENSE | 2 +- spin2/README.md | 2 +- .../TEST_LANG_SERVER/spin/param_test_p1.spin | 2 +- .../spin/test_declarations.spin | 2 +- spin2/TEST_LANG_SERVER/spin/test_pasm.spin | 2 +- spin2/TEST_LANG_SERVER/spin/test_spin.spin | 14 +- .../TEST_LANG_SERVER/spin2/220316-fixes.spin2 | 3 +- .../spin2/chk_code_comment_demo.spin2 | 4 +- .../spin2/chk_missing_objPrefixes.spin2 | 3 + .../spin2/dummy_isp_hub75_7seg.spin2 | 3 + .../spin2/test-file-001.spin2 | 4 +- spin2/client/src/extension.ts | 273 +- .../src/providers/spin.block.tracker.ts | 20 +- .../src/providers/spin.color.regions.ts | 148 +- .../src/providers/spin.document.generate.ts | 187 +- .../src/providers/spin.editMode.behavior.ts | 16 +- .../providers/spin.editMode.configuration.ts | 42 +- .../src/providers/spin.editMode.mode.ts | 16 +- .../providers/spin.editMode.statusBarItem.ts | 24 +- .../spin.tabFormatter.configuration.ts | 27 +- .../client/src/providers/spin.tabFormatter.ts | 242 +- .../src/spin.clientBehavior.configuration.ts | 15 +- spin2/client/src/spin.code.utils.ts | 96 +- spin2/client/src/spin.object.dependencies.ts | 187 +- spin2/client/src/spin.vscode.utils.ts | 24 +- spin2/client/src/test/completion.test.ts | 30 +- spin2/client/src/test/diagnostics.test.ts | 33 +- .../src/test/docs-pub-pri-blocks.test.ts | 25 +- spin2/client/src/test/helper.ts | 38 +- spin2/client/src/test/index.ts | 12 +- spin2/client/src/test/outline.spin2.test.ts | 199 +- spin2/client/src/test/runTest.ts | 54 +- spin2/copyright | 4 +- spin2/package-lock.json | 2183 +++++++++-- spin2/package.json | 70 +- spin2/scripts/LIVE-package.json | 70 +- spin2/scripts/TEST-package.json | 66 +- spin2/server/src/DocumentProcessor.ts | 73 +- spin2/server/src/context.ts | 10 +- spin2/server/src/files.ts | 48 +- spin2/server/src/geometry.ts | 2 +- spin2/server/src/parser/lang.utils.ts | 18 +- .../src/parser/lsp.textDocument.utils.ts | 25 +- spin2/server/src/parser/spin.common.ts | 98 +- .../server/src/parser/spin.extension.utils.ts | 158 +- .../src/parser/spin.objectReferenceParser.ts | 120 +- .../src/parser/spin.semantic.findings.ts | 548 +-- .../parser/spin1.documentSemanticParser.ts | 1596 ++++---- .../src/parser/spin1.documentSymbolParser.ts | 151 +- spin2/server/src/parser/spin1.utils.ts | 2124 ++++++----- .../parser/spin2.documentSemanticParser.ts | 3232 +++++++++------- .../src/parser/spin2.documentSymbolParser.ts | 194 +- spin2/server/src/parser/spin2.utils.ts | 3236 +++++++++-------- .../src/providers/CompletionProvider.ts | 35 +- .../src/providers/DefinitionProvider.ts | 70 +- .../src/providers/DocumentSymbolProvider.ts | 18 +- .../src/providers/FoldingRangeProvider.ts | 20 +- spin2/server/src/providers/HoverProvider.ts | 194 +- .../src/providers/SemanticTokensProvider.ts | 128 +- .../src/providers/SignatureHelpProvider.ts | 227 +- .../src/providers/TextDocumentSyncProvider.ts | 83 +- spin2/server/src/providers/index.ts | 29 +- spin2/server/src/server.ts | 25 +- spin2/themes/isp-spin-dark-bg-theme.json | 2 + spin2/themes/isp-spin-dark-theme-old.json | 319 -- spin2/themes/isp-spin-dark-theme.json | 8 +- spin2/themes/isp-spin-light-bg-theme.json | 4 +- spin2/themes/isp-spin-light-theme-old.json | 319 -- spin2/themes/isp-spin-light-theme.json | 2 + spin2/themes/isp-spin-syntax-theme.json | 6 +- 71 files changed, 10074 insertions(+), 7205 deletions(-) delete mode 100644 spin2/themes/isp-spin-dark-theme-old.json delete mode 100644 spin2/themes/isp-spin-light-theme-old.json diff --git a/spin2/CHANGELOG.md b/spin2/CHANGELOG.md index 567e136..1272198 100644 --- a/spin2/CHANGELOG.md +++ b/spin2/CHANGELOG.md @@ -12,12 +12,25 @@ Work to appear in upcoming releases: Possible next additions: -- More features comming. We're looking for what's next... +- More features coming. We're looking for what's next... - Investigate and possibly add unique coloring for method pointers - Add spin2 instruction templates as Snippets (_for instructions with two or more parameters_) - Add new-file templates as Snippets - Add additional Snippets as the community identifies them +## [2.2.14] 2024-01-11 + +Update P1 & P2 + +- Adjust settings/configuration mechanism (turn on/off elastic tabs no longer requires vscode restart/reload) +- Adjust text-cursor colors for our themes (Make them more visible and consistent with other themes) + - NOTE: this does NOT affect the mouse pointer (arrow, or I-beam) which is controlled from your operating-system settings + +Update P2 Only + +- Minor DAT block highlighting fixes +- Adjusted duplicate variable declaration message (clarified meaning) + ## [2.2.13] 2024-01-09 Update P2 diff --git a/spin2/LICENSE b/spin2/LICENSE index 6c292a7..293b56e 100644 --- a/spin2/LICENSE +++ b/spin2/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Iron Sheep Productions, LLC. +Copyright (c) 2024 Iron Sheep Productions, LLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/spin2/README.md b/spin2/README.md index f1ad938..2491d3b 100644 --- a/spin2/README.md +++ b/spin2/README.md @@ -1,4 +1,4 @@ -# VSCode support for the Parallax Propeller v1 & v2 8-Core MCU's +# VSCode support for the Parallax Propeller v1 & v2 8-Core MCU's Spin/Spin2 Language-Server based VSCode Extension diff --git a/spin2/TEST_LANG_SERVER/spin/param_test_p1.spin b/spin2/TEST_LANG_SERVER/spin/param_test_p1.spin index 159514e..edcd92c 100644 --- a/spin2/TEST_LANG_SERVER/spin/param_test_p1.spin +++ b/spin2/TEST_LANG_SERVER/spin/param_test_p1.spin @@ -19,4 +19,4 @@ PUB main3(param1, myvar2) | myVar1 myvar1 := 4 -PRI main4() : ok +PRI main4 : ok diff --git a/spin2/TEST_LANG_SERVER/spin/test_declarations.spin b/spin2/TEST_LANG_SERVER/spin/test_declarations.spin index 8735956..789a0e9 100644 --- a/spin2/TEST_LANG_SERVER/spin/test_declarations.spin +++ b/spin2/TEST_LANG_SERVER/spin/test_declarations.spin @@ -86,7 +86,7 @@ OBJ vga : "VGA_DRIVER" mouse : "USB_Mouse" v[16] : "VocalSynth" ' instantiate array of 16 objects -PUB null() +PUB null '' This is NOT a top level object diff --git a/spin2/TEST_LANG_SERVER/spin/test_pasm.spin b/spin2/TEST_LANG_SERVER/spin/test_pasm.spin index bd10c7d..474f040 100644 --- a/spin2/TEST_LANG_SERVER/spin/test_pasm.spin +++ b/spin2/TEST_LANG_SERVER/spin/test_pasm.spin @@ -13,7 +13,7 @@ '' this is our full PASM (P1) instruction set -PUB null() : nRet +PUB null : nRet '' This is NOT a top level object CON diff --git a/spin2/TEST_LANG_SERVER/spin/test_spin.spin b/spin2/TEST_LANG_SERVER/spin/test_spin.spin index b6c10e5..beec32b 100644 --- a/spin2/TEST_LANG_SERVER/spin/test_spin.spin +++ b/spin2/TEST_LANG_SERVER/spin/test_spin.spin @@ -108,11 +108,11 @@ chkBffr long 0[vga.MAX_BUFFER_LEN] long 0[vga.MAX_COG_BUFFER_SIZE_IN_LONGS] '} -PUB null() +PUB null '' This is NOT a top level object -PUB allSpinLanguageParts() +PUB allSpinLanguageParts '{ ' core spin verbs ABORT @@ -196,7 +196,7 @@ PUB allSpinLanguageParts() xtal2 xtal3 '} -PUB allHubVariableNames() +PUB allHubVariableNames '{ CLKFREQ CLKMODE @@ -220,7 +220,7 @@ PUB allHubVariableNames() '} -PUB allClockVariabless() +PUB allClockVariabless ' value can be set with HUBSET ' - these are the compiled values ' set via CLKSET() @@ -231,7 +231,7 @@ PUB allClockVariabless() CHIPVER cnt -PUB allSpinConstants() +PUB allSpinConstants '{ TRUE FALSE @@ -240,7 +240,7 @@ PUB allSpinConstants() PI '} -PUB allnamedOperators() +PUB allnamedOperators '{ NOT AND @@ -254,7 +254,7 @@ PUB allnamedOperators() -PRI allFlowControl() +PRI allFlowControl '{ ABORT CASE diff --git a/spin2/TEST_LANG_SERVER/spin2/220316-fixes.spin2 b/spin2/TEST_LANG_SERVER/spin2/220316-fixes.spin2 index c945b23..6922877 100644 --- a/spin2/TEST_LANG_SERVER/spin2/220316-fixes.spin2 +++ b/spin2/TEST_LANG_SERVER/spin2/220316-fixes.spin2 @@ -17,7 +17,7 @@ CON _clkfreq = 250_000_000 'system clock frequency gtzl_base = 16 'must be a multiple of 8 DAT org -' org (above) is not colored correctly unless comment follows?! +' org (above) is not colored correctly unless comment follows?! (fixed) asmclk 'set clock setq #gtzl_base 'launch Goertzel @@ -29,7 +29,6 @@ DAT org jmp #.loop DAT org -' org is not colored correctly unless comment follows?! pgm_gtzl add ptra,#7 'init ADC pin wrpin adcmode,ptra diff --git a/spin2/TEST_LANG_SERVER/spin2/chk_code_comment_demo.spin2 b/spin2/TEST_LANG_SERVER/spin2/chk_code_comment_demo.spin2 index dde557d..e22230d 100644 --- a/spin2/TEST_LANG_SERVER/spin2/chk_code_comment_demo.spin2 +++ b/spin2/TEST_LANG_SERVER/spin2/chk_code_comment_demo.spin2 @@ -59,7 +59,9 @@ CON { driver interface Constants} ' DCS_ESTOP - motor in emergency stop (external stop requested) #0, DCS_Unknown, DCS_STOPPED, DCS_SPIN_UP, DCS_AT_SPEED, DCS_SPIN_DN, DCS_SLOW_TO_CHG, DCS_FAULTED, DCS_ESTOP - user2 = trunc() ' <<< SHOULD be RED trunc without ()! or with empty ()'s + user2 = trunc ' <<< SHOULD be RED trunc without ()! or with empty ()'s + user3 = trunc() ' <<< SHOULD be RED trunc without ()! or with empty ()'s + user4 = trunc(6) ' <<< SHOULD be RED trunc without ()! or with empty ()'s OBJ { included objects } diff --git a/spin2/TEST_LANG_SERVER/spin2/chk_missing_objPrefixes.spin2 b/spin2/TEST_LANG_SERVER/spin2/chk_missing_objPrefixes.spin2 index c94a2b0..5c0cf58 100644 --- a/spin2/TEST_LANG_SERVER/spin2/chk_missing_objPrefixes.spin2 +++ b/spin2/TEST_LANG_SERVER/spin2/chk_missing_objPrefixes.spin2 @@ -24,6 +24,7 @@ CON OBJ Flash : "dummy_Draft_flash_fs" utils : "dummy_UT_utilities" + testAr[2]: "dummy_isp_hub75_7seg" DAT @@ -31,6 +32,8 @@ testfile byte "seektest.bin", 0 PUB go() : status, handle, longValue, longOffset + testAr[1].showDigit() + status := Flash.format() ' Comment out this line to not erase all files if status < 0 utils.showError(@"format()", status) diff --git a/spin2/TEST_LANG_SERVER/spin2/dummy_isp_hub75_7seg.spin2 b/spin2/TEST_LANG_SERVER/spin2/dummy_isp_hub75_7seg.spin2 index e69de29..16605a8 100644 --- a/spin2/TEST_LANG_SERVER/spin2/dummy_isp_hub75_7seg.spin2 +++ b/spin2/TEST_LANG_SERVER/spin2/dummy_isp_hub75_7seg.spin2 @@ -0,0 +1,3 @@ + + +pub showDigit() diff --git a/spin2/TEST_LANG_SERVER/spin2/test-file-001.spin2 b/spin2/TEST_LANG_SERVER/spin2/test-file-001.spin2 index 303872a..da9a19e 100644 --- a/spin2/TEST_LANG_SERVER/spin2/test-file-001.spin2 +++ b/spin2/TEST_LANG_SERVER/spin2/test-file-001.spin2 @@ -67,14 +67,14 @@ VAR CogNum ' the default variable size is LONG. BYTE StringChar ' byte variable BYTE StringBuffer[64] ' byte variable array (64 bytes) - BYTE a,b,c[1000],d ' command separated declarations + BYTE a,b1,c1[1000],d1 ' command separated declarations WORD CurrentCycle ' word variable WORD Cycles[200] ' word variable array (200 words) WORD ev,fv[5],gv,hv[10] ' command separated declarations WORD iv[1],jv,kv,lv[92] ' command separated declarations - LONG values ' long variable + LONG values0 ' long variable LONG values[15] ' long variable array (15 longs) LONG il[100],jl,kl,ll ' command separated declarations diff --git a/spin2/client/src/extension.ts b/spin2/client/src/extension.ts index b1dc5e1..359781e 100644 --- a/spin2/client/src/extension.ts +++ b/spin2/client/src/extension.ts @@ -2,31 +2,31 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -"use strict"; +'use strict'; // src/extensions.ts -import * as path from "path"; -import * as vscode from "vscode"; +import * as path from 'path'; +import * as vscode from 'vscode'; -import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from "vscode-languageclient/node"; +import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node'; -import { Formatter } from "./providers/spin.tabFormatter"; -import { DocGenerator } from "./providers/spin.document.generate"; -import { ObjectTreeProvider, Dependency } from "./spin.object.dependencies"; -import { RegionColorizer } from "./providers/spin.color.regions"; -import { overtypeBeforePaste, overtypeBeforeType } from "./providers/spin.editMode.behavior"; -import { editModeConfiguration, reloadEditModeConfiguration } from "./providers/spin.editMode.configuration"; -import { tabConfiguration } from "./providers/spin.tabFormatter.configuration"; -import { getMode, resetModes, toggleMode, toggleMode2State, eEditMode, modeName } from "./providers/spin.editMode.mode"; -import { createStatusBarItem, destroyStatusBarItem, updateStatusBarItem } from "./providers/spin.editMode.statusBarItem"; -import { isSpinOrPasmDocument } from "./spin.vscode.utils"; +import { Formatter } from './providers/spin.tabFormatter'; +import { DocGenerator } from './providers/spin.document.generate'; +import { ObjectTreeProvider, Dependency } from './spin.object.dependencies'; +import { RegionColorizer } from './providers/spin.color.regions'; +import { overtypeBeforePaste, overtypeBeforeType } from './providers/spin.editMode.behavior'; +import { editModeConfiguration, reloadEditModeConfiguration } from './providers/spin.editMode.configuration'; +import { tabConfiguration } from './providers/spin.tabFormatter.configuration'; +import { getMode, resetModes, toggleMode, toggleMode2State, eEditMode, modeName } from './providers/spin.editMode.mode'; +import { createStatusBarItem, destroyStatusBarItem, updateStatusBarItem } from './providers/spin.editMode.statusBarItem'; +import { isSpinOrPasmDocument } from './spin.vscode.utils'; let client: LanguageClient; const extensionDebugLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit -var extensionOutputChannel: vscode.OutputChannel | undefined = undefined; +let extensionOutputChannel: vscode.OutputChannel | undefined = undefined; -var objTreeProvider: ObjectTreeProvider = new ObjectTreeProvider(); +const objTreeProvider: ObjectTreeProvider = new ObjectTreeProvider(); const tabFormatter: Formatter = new Formatter(); const docGenerator: DocGenerator = new DocGenerator(); const codeBlockColorizer: RegionColorizer = new RegionColorizer(); @@ -41,7 +41,7 @@ const logExtensionMessage = (message: string): void => { function getSetupExtensionClient(context: vscode.ExtensionContext): LanguageClient { // The server is implemented in node - const serverModule = context.asAbsolutePath(path.join("server", "out", "server.js")); + const serverModule = context.asAbsolutePath(path.join('server', 'out', 'server.js')); // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used @@ -49,29 +49,30 @@ function getSetupExtensionClient(context: vscode.ExtensionContext): LanguageClie run: { module: serverModule, transport: TransportKind.ipc }, debug: { module: serverModule, - transport: TransportKind.ipc, - }, + transport: TransportKind.ipc + } }; // Options to control the language client const clientOptions: LanguageClientOptions = { // Register the server for plain text documents documentSelector: [ - { scheme: "file", language: "spin" }, - { scheme: "file", language: "spin2" }, - { scheme: "file", language: "p2asm" }, + { scheme: 'file', language: 'spin' }, + { scheme: 'file', language: 'spin2' }, + { scheme: 'file', language: 'p2asm' } ], synchronize: { // Notify the server about file changes to '.clientrc files contained in the workspace - fileEvents: vscode.workspace.createFileSystemWatcher("**/*"), - }, + fileEvents: vscode.workspace.createFileSystemWatcher('**/*') + } }; // Create the language client and start the client. - const client = new LanguageClient("spinExtension", "Spin2 Language Server", serverOptions, clientOptions); + const client = new LanguageClient('spinExtension', 'Spin2 Language Server', serverOptions, clientOptions); return client; } +// eslint-disable-next-line @typescript-eslint/no-unused-vars function registerProviders(context: vscode.ExtensionContext): void { // register client-side providers: tabbing and document generation } @@ -82,17 +83,17 @@ function registerCommands(context: vscode.ExtensionContext): void { // ---------------------------------------------------------------------------- // Hook GENERATE Object Public Interface Document // - const generateDocumentFileCommand: string = "spinExtension.generate.documentation.file"; + const generateDocumentFileCommand: string = 'spinExtension.generate.documentation.file'; context.subscriptions.push( vscode.commands.registerCommand(generateDocumentFileCommand, async () => { - docGenerator.logMessage("* generateDocumentFileCommand"); + docGenerator.logMessage('* generateDocumentFileCommand'); try { // and test it! docGenerator.generateDocument(); docGenerator.showDocument(); } catch (error) { - await vscode.window.showErrorMessage("Document Generation Problem"); + await vscode.window.showErrorMessage('Document Generation Problem'); console.error(error); } }) @@ -102,14 +103,14 @@ function registerCommands(context: vscode.ExtensionContext): void { handleActiveTextEditorChanged(); // now show or hide based upon current/active window context.subscriptions.push( - vscode.commands.registerCommand("spinExtension.insertMode.rotate", toggleCommand), - vscode.commands.registerCommand("spinExtension.insertMode.toggle", toggleCommand2State), + vscode.commands.registerCommand('spinExtension.insertMode.rotate', toggleCommand), + vscode.commands.registerCommand('spinExtension.insertMode.toggle', toggleCommand2State), - vscode.commands.registerCommand("type", typeCommand), - vscode.commands.registerCommand("paste", pasteCommand), + vscode.commands.registerCommand('type', typeCommand), + vscode.commands.registerCommand('paste', pasteCommand), - vscode.commands.registerCommand("spinExtension.insertMode.deleteLeft", deleteLeftCommand), - vscode.commands.registerCommand("spinExtension.insertMode.deleteRight", deleteRightCommand), + vscode.commands.registerCommand('spinExtension.insertMode.deleteLeft', deleteLeftCommand), + vscode.commands.registerCommand('spinExtension.insertMode.deleteRight', deleteRightCommand), vscode.window.onDidChangeActiveTextEditor(handleActiveTextEditorChanged), vscode.window.onDidChangeVisibleTextEditors(handleVisibleTextEditorChanged), @@ -127,9 +128,10 @@ function registerCommands(context: vscode.ExtensionContext): void { // Hook Update region colors in editor // + // eslint-disable-next-line @typescript-eslint/no-unused-vars function handleTextDocumentChanged(changeEvent: vscode.TextDocumentChangeEvent) { vscode.window.visibleTextEditors.map((editor) => { - recolorizeSpinDocumentIfChanged(editor, "handleTextDocumentChanged", "Ext-docDidChg"); + recolorizeSpinDocumentIfChanged(editor, 'handleTextDocumentChanged', 'Ext-docDidChg'); }); } @@ -138,7 +140,7 @@ function registerCommands(context: vscode.ExtensionContext): void { if (isSpinOrPasmDocument(textDocument)) { vscode.window.visibleTextEditors.map((editor) => { if (editor.document.uri == textDocument.uri) { - recolorizeSpinDocumentIfChanged(editor, "handleTextDocumentOpened", "Ext-docDidOpen", true); + recolorizeSpinDocumentIfChanged(editor, 'handleTextDocumentOpened', 'Ext-docDidOpen', true); } }); } @@ -147,19 +149,19 @@ function registerCommands(context: vscode.ExtensionContext): void { // ---------------------------------------------------------------------------- // Hook GENERATE PUB/PRI Comment Block // - const generateDocCommentCommand: string = "spinExtension.generate.doc.comment"; + const generateDocCommentCommand: string = 'spinExtension.generate.doc.comment'; context.subscriptions.push( vscode.commands.registerCommand(generateDocCommentCommand, async () => { - docGenerator.logMessage("* generateDocumentCommentCommand"); + docGenerator.logMessage('* generateDocumentCommentCommand'); try { // and test it! - const editor = vscode?.window.activeTextEditor!; + const editor = vscode?.window.activeTextEditor; const document = editor.document!; - var textEdits = await docGenerator.insertDocComment(document, editor.selections); + const textEdits = await docGenerator.insertDocComment(document, editor.selections); applyTextEdits(document, textEdits!); } catch (error) { - await vscode.window.showErrorMessage("Document Comment Generation Problem"); + await vscode.window.showErrorMessage('Document Comment Generation Problem'); console.error(error); } }) @@ -169,86 +171,90 @@ function registerCommands(context: vscode.ExtensionContext): void { // Set Up our TAB Formatting // // post information to out-side world via our CONTEXT - vscode.commands.executeCommand("setContext", "spinExtension.tabStops.enabled", tabFormatter.isEnbled()); + vscode.commands.executeCommand('setContext', 'spinExtension.tabStops.enabled', tabFormatter.isEnbled()); // Hook TAB Formatting - if (tabFormatter.isEnbled()) { - const insertTabStopsCommentCommand = "spinExtension.generate.tabStops.comment"; - - context.subscriptions.push( - vscode.commands.registerCommand(insertTabStopsCommentCommand, async () => { - logExtensionMessage("* insertTabStopsCommentCommand"); - try { - const editor = vscode?.window.activeTextEditor!; - const document = editor.document!; - var textEdits = await tabFormatter.insertTabStopsComment(document, editor.selections); - applyTextEdits(document, textEdits!); - } catch (error) { - await vscode.window.showErrorMessage("Formatter Add Comment Problem"); - console.error(error); - } - }) - ); - - const indentTabStopCommand = "spinExtension.indentTabStop"; - - context.subscriptions.push( - vscode.commands.registerCommand(indentTabStopCommand, async () => { - logExtensionMessage("* indentTabStopCommand"); - try { - const editor = vscode?.window.activeTextEditor!; - const document = editor.document!; - var textEdits = await tabFormatter.indentTabStop(document, editor); - let [cursorSelect, bShouldSelect] = tabFormatter.indentEndingSelection(); - applyTextEdits(document, textEdits!); - if (bShouldSelect) { - tabFormatter.logMessage(`* SET CURSOR sel=[${cursorSelect.anchor.line}:${cursorSelect.anchor.character}, ${cursorSelect.active.line}:${cursorSelect.active.character}]`); - editor.selection = cursorSelect; - } - } catch (error) { - await vscode.window.showErrorMessage("Formatter TAB Problem"); - console.error(error); + const insertTabStopsCommentCommand = 'spinExtension.elasticTabstops.generate.tabStops.comment'; + + context.subscriptions.push( + vscode.commands.registerCommand(insertTabStopsCommentCommand, async () => { + logExtensionMessage('* insertTabStopsCommentCommand'); + try { + const editor = vscode?.window.activeTextEditor; + const document = editor.document!; + const textEdits = await tabFormatter.insertTabStopsComment(document, editor.selections); + applyTextEdits(document, textEdits!); + } catch (error) { + await vscode.window.showErrorMessage(`Formatter Add Comment Problem: error=[${error}]`); + console.error(error); + } + }) + ); + + const indentTabStopCommand = 'spinExtension.elasticTabstops.indentTabStop'; + + context.subscriptions.push( + vscode.commands.registerCommand(indentTabStopCommand, async () => { + logExtensionMessage('* indentTabStopCommand'); + try { + const editor = vscode?.window.activeTextEditor; + const document = editor.document!; + const textEdits = await tabFormatter.indentTabStop(document, editor); + const [cursorSelect, bShouldSelect] = tabFormatter.indentEndingSelection(); + applyTextEdits(document, textEdits!); + if (bShouldSelect) { + tabFormatter.logMessage( + `* SET CURSOR sel=[${cursorSelect.anchor.line}:${cursorSelect.anchor.character}, ${cursorSelect.active.line}:${cursorSelect.active.character}]` + ); + editor.selection = cursorSelect; } - }) - ); - const outdentTabStopCommand = "spinExtension.outdentTabStop"; - - context.subscriptions.push( - vscode.commands.registerCommand(outdentTabStopCommand, async () => { - logExtensionMessage("* outdentTabStopCommand"); - try { - const editor = vscode.window.activeTextEditor!; - const document = editor.document!; - var textEdits = await tabFormatter.outdentTabStop(document, editor); - let [cursorSelect, bShouldSelect] = tabFormatter.outdentEndingSelection(); - applyTextEdits(document, textEdits!); - if (bShouldSelect) { - tabFormatter.logMessage(`* SET CURSOR sel=[${cursorSelect.anchor.line}:${cursorSelect.anchor.character}, ${cursorSelect.active.line}:${cursorSelect.active.character}]`); - editor.selection = cursorSelect; - } - console.log(); - } catch (error) { - await vscode.window.showErrorMessage("Formatter Shift+TAB Problem"); - console.error(error); + } catch (error) { + await vscode.window.showErrorMessage('Formatter TAB Problem'); + console.error(error); + } + }) + ); + const outdentTabStopCommand = 'spinExtension.elasticTabstops.outdentTabStop'; + + context.subscriptions.push( + vscode.commands.registerCommand(outdentTabStopCommand, async () => { + logExtensionMessage('* outdentTabStopCommand'); + try { + const editor = vscode.window.activeTextEditor!; + const document = editor.document!; + const textEdits = await tabFormatter.outdentTabStop(document, editor); + const [cursorSelect, bShouldSelect] = tabFormatter.outdentEndingSelection(); + applyTextEdits(document, textEdits!); + if (bShouldSelect) { + tabFormatter.logMessage( + `* SET CURSOR sel=[${cursorSelect.anchor.line}:${cursorSelect.anchor.character}, ${cursorSelect.active.line}:${cursorSelect.active.character}]` + ); + editor.selection = cursorSelect; } - }) - ); - } + console.log(); + } catch (error) { + await vscode.window.showErrorMessage('Formatter Shift+TAB Problem'); + console.error(error); + } + }) + ); // ---------------------------------------------------------------------------- // Object Tree View Provider // //vscode.window.registerTreeDataProvider("spinExtension.objectDependencies", objTreeProvider); - var objDepTreeView: vscode.TreeView; - objDepTreeView = vscode.window.createTreeView("spinExtension.objectDependencies", { + // WARNING this next statement actually DOES enable the tree view!!! don't remove it + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const objDepTreeView: vscode.TreeView = vscode.window.createTreeView('spinExtension.objectDependencies', { canSelectMany: false, showCollapseAll: true, - treeDataProvider: objTreeProvider, + treeDataProvider: objTreeProvider }); //objDepTreeView.onDidChangeSelection(objTreeProvider.onElementClick); - const objectTreeViewRefreshCommand = "spinExtension.objectDependencies.refreshEntry"; - const objectTreeViewActivateFileCommand = "spinExtension.objectDependencies.activateFile"; + + const objectTreeViewRefreshCommand = 'spinExtension.objectDependencies.refreshEntry'; + const objectTreeViewActivateFileCommand = 'spinExtension.objectDependencies.activateFile'; vscode.commands.registerCommand(objectTreeViewRefreshCommand, () => objTreeProvider.refresh()); vscode.commands.registerCommand(objectTreeViewActivateFileCommand, async (arg1) => objTreeProvider.onElementClick(arg1)); @@ -290,10 +296,10 @@ export function activate(context: vscode.ExtensionContext) { if (extensionDebugLogEnabled) { if (extensionOutputChannel === undefined) { //Create output channel - extensionOutputChannel = vscode.window.createOutputChannel("Spin/Spin2 Extension DEBUG"); - logExtensionMessage("Spin/Spin2 Extension log started."); + extensionOutputChannel = vscode.window.createOutputChannel('Spin/Spin2 Extension DEBUG'); + logExtensionMessage('Spin/Spin2 Extension log started.'); } else { - logExtensionMessage("\n\n------------------ NEW FILE ----------------\n\n"); + logExtensionMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } @@ -363,7 +369,7 @@ function handleVisibleTextEditorChanged(textEditors: vscode.TextEditor[]) { } function handleActiveTextEditorChanged(textEditor?: vscode.TextEditor) { - let argumentInterp: string = "undefined"; + let argumentInterp: string = 'undefined'; let isSpinWindow: boolean = false; let showStatusBarItem: boolean = true; const showInserModeIndicator: boolean = tabConfiguration.enable == true; @@ -376,7 +382,7 @@ function handleActiveTextEditorChanged(textEditor?: vscode.TextEditor) { docVersion = textEditor.document.version; argumentInterp = `${path.basename(textEditor.document.fileName)} v${docVersion}`; } else { - argumentInterp = "-- NOT-SPIN-WINDOW --"; + argumentInterp = '-- NOT-SPIN-WINDOW --'; showStatusBarItem = false; } } @@ -388,7 +394,7 @@ function handleActiveTextEditorChanged(textEditor?: vscode.TextEditor) { } if (isSpinWindow && textEditor) { - recolorizeSpinDocumentIfChanged(textEditor, "handleActiveTextEditorChanged", "Ext-actvEditorChg", true); // true=force the recolor + recolorizeSpinDocumentIfChanged(textEditor, 'handleActiveTextEditorChanged', 'Ext-actvEditorChg', true); // true=force the recolor const mode = getMode(textEditor); if (showInserModeIndicator) { @@ -396,7 +402,7 @@ function handleActiveTextEditorChanged(textEditor?: vscode.TextEditor) { //logExtensionMessage(`* SHOW SB-ITEM mode=[${modeName(mode)}]`); } // post information to out-side world via our CONTEXT - vscode.commands.executeCommand("setContext", "spinExtension.insert.mode", modeName(mode)); + vscode.commands.executeCommand('setContext', 'spinExtension.insert.mode', modeName(mode)); // if in overtype mode, set the cursor to secondary style; otherwise, reset to default let cursorStyle; @@ -431,6 +437,7 @@ function recolorizeSpinDocumentIfChanged(editor: vscode.TextEditor, callerId: st logExtensionMessage(`* recolorize ${callerId}(${editor.document.fileName})`); logExtensionMessage(` -- recolorize [${docBaseName}] v${priorVersion} -> v${newVersion} forced=(${forceUpdate})`); codeBlockColorizer.updateRegionColors(editor, reason, forceUpdate); + versionCacheByDocument.set(editor.document.fileName, newVersion); } } } @@ -439,7 +446,7 @@ const handleDidChangeConfiguration = () => { const previousPerEditor = editModeConfiguration.perEditor; const previousShowInStatusBar = getShowInStatusBar(); const previousInsertModeEnable = tabConfiguration.enable; - logExtensionMessage("* handleDidChangeConfiguration"); + logExtensionMessage('* handleDidChangeConfiguration'); // tell tabFormatter that is might have changed, too tabFormatter.updateTabConfiguration(); @@ -480,7 +487,7 @@ const handleDidChangeConfiguration = () => { function toggleCommand() { const textEditor = vscode.window.activeTextEditor; - logExtensionMessage("* toggle"); + logExtensionMessage('* toggle'); if (textEditor == null) { return; } @@ -491,7 +498,7 @@ function toggleCommand() { function toggleCommand2State() { const textEditor = vscode.window.activeTextEditor; - logExtensionMessage("* toggle2State"); + logExtensionMessage('* toggle2State'); if (textEditor == null) { return; } @@ -507,7 +514,7 @@ function getShowInStatusBar(): boolean { `* (DBG) labelInsertMode=[${editModeConfiguration.labelInsertMode}], labelOvertypeMode=[${editModeConfiguration.labelOvertypeMode}], labelAlignMode=[${editModeConfiguration.labelAlignMode}]` ); */ - if (editModeConfiguration.labelInsertMode === "" && editModeConfiguration.labelOvertypeMode === "" && editModeConfiguration.labelAlignMode === "") { + if (editModeConfiguration.labelInsertMode === '' && editModeConfiguration.labelOvertypeMode === '' && editModeConfiguration.labelAlignMode === '') { showOrNot = false; } return showOrNot; @@ -515,38 +522,38 @@ function getShowInStatusBar(): boolean { function typeCommand(args: { text: string }) { const editor = vscode.window.activeTextEditor; - var editMode: eEditMode = eEditMode.INSERT; + let editMode: eEditMode = eEditMode.INSERT; if (editor == undefined) { //logExtensionMessage("* VSCode type (early)"); - vscode.commands.executeCommand("default:type", args); + vscode.commands.executeCommand('default:type', args); return; } if (extensionDebugLogEnabled) { const firstChar: number = args.text.charCodeAt(0); if (args.text.length == 1 && firstChar < 0x20) { - logExtensionMessage("* type [0x" + firstChar.toString(16) + "](" + args.text.length + ")"); + logExtensionMessage('* type [0x' + firstChar.toString(16) + '](' + args.text.length + ')'); } else { - logExtensionMessage("* type [" + args.text + "](" + args.text.length + ")"); + logExtensionMessage('* type [' + args.text + '](' + args.text.length + ')'); } } if (editor != undefined) { editMode = getMode(editor); } if (editor != undefined && tabFormatter.isEnbled() && editMode == eEditMode.OVERTYPE) { - logExtensionMessage("* OVERTYPE type"); + logExtensionMessage('* OVERTYPE type'); overtypeBeforeType(editor, args.text, false); } else if (editor != undefined && tabFormatter.isEnbled() && editMode == eEditMode.ALIGN) { tabFormatter.alignBeforeType(editor, args.text, false); } else { //logExtensionMessage("* VSCode type"); - vscode.commands.executeCommand("default:type", args); + vscode.commands.executeCommand('default:type', args); } } function deleteLeftCommand() { const editor = vscode.window.activeTextEditor; - logExtensionMessage("* deleteLeft"); - var bAlignEdit: boolean = editor != undefined && tabFormatter.isEnbled(); + logExtensionMessage('* deleteLeft'); + let bAlignEdit: boolean = editor != undefined && tabFormatter.isEnbled(); if (editor != undefined) { const editMode = getMode(editor); if (editMode != eEditMode.ALIGN) { @@ -558,37 +565,37 @@ function deleteLeftCommand() { return null; } else { //logExtensionMessage("* VSCode deleteLeft"); - return vscode.commands.executeCommand("deleteLeft"); + return vscode.commands.executeCommand('deleteLeft'); } } function deleteRightCommand() { const editor = vscode.window.activeTextEditor; - logExtensionMessage("* deleteRight"); + logExtensionMessage('* deleteRight'); if (tabFormatter.isEnbled() && editor && getMode(editor) == eEditMode.ALIGN) { tabFormatter.alignDelete(editor, true); return null; } else { //logExtensionMessage("* VSCode deleteRight"); - return vscode.commands.executeCommand("deleteRight"); + return vscode.commands.executeCommand('deleteRight'); } } function pasteCommand(args: { text: string; pasteOnNewLine: boolean }) { const editor = vscode.window.activeTextEditor; if (editor != undefined) { - logExtensionMessage("* paste"); + logExtensionMessage('* paste'); if (getMode(editor) == eEditMode.OVERTYPE && editModeConfiguration.overtypePaste) { // TODO: Make paste work with align - logExtensionMessage("* OVERTYPE paste"); + logExtensionMessage('* OVERTYPE paste'); overtypeBeforePaste(editor, args.text, args.pasteOnNewLine); - return vscode.commands.executeCommand("default:paste", args); + return vscode.commands.executeCommand('default:paste', args); } else if (tabFormatter.isEnbled() && getMode(editor) == eEditMode.ALIGN && !args.pasteOnNewLine) { tabFormatter.alignBeforeType(editor, args.text, true); return null; } else { //logExtensionMessage("* VSCode paste"); - return vscode.commands.executeCommand("default:paste", args); + return vscode.commands.executeCommand('default:paste', args); } } return null; diff --git a/spin2/client/src/providers/spin.block.tracker.ts b/spin2/client/src/providers/spin.block.tracker.ts index 9a19310..b5dbeb7 100644 --- a/spin2/client/src/providers/spin.block.tracker.ts +++ b/spin2/client/src/providers/spin.block.tracker.ts @@ -1,7 +1,7 @@ -"use strict"; +'use strict'; // server/src/parser/spin.semantic.findings.ts -import * as vscode from "vscode"; +import * as vscode from 'vscode'; export enum eBLockType { Unknown = 0, @@ -10,7 +10,7 @@ export enum eBLockType { isVar, isObj, isPub, - isPri, + isPri } export interface IBlockSpan { @@ -77,15 +77,17 @@ export class LocatedBlockFindings { this.priorInstanceCount = 1; } else { // we are starting a later block, lets finish prior then start the new - const isFirstOfThisType: boolean = this.priorBlockType != eCurrBlockType ? false : true; + //const isFirstOfThisType: boolean = this.priorBlockType != eCurrBlockType ? false : true; const newBlockSpan: IBlockSpan = { blockType: this.priorBlockType, sequenceNbr: this.priorInstanceCount, startLineIdx: this.priorBlockStartLineIdx, - endLineIdx: currLineIdx - 1, // ends at prior line + endLineIdx: currLineIdx - 1 // ends at prior line }; this.codeBlockSpans.push(newBlockSpan); - this._logMessage(` -- FND-RCD-ADD sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]`); + this._logMessage( + ` -- FND-RCD-ADD sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]` + ); this.priorInstanceCount = this.priorBlockType == eCurrBlockType ? this.priorInstanceCount + 1 : 1; this.priorBlockStartLineIdx = currLineIdx; this.priorBlockType = eCurrBlockType; @@ -100,9 +102,11 @@ export class LocatedBlockFindings { blockType: this.priorBlockType, sequenceNbr: this.priorInstanceCount, startLineIdx: this.priorBlockStartLineIdx, - endLineIdx: finalLineIdx, // ends at the last line of the file + endLineIdx: finalLineIdx // ends at the last line of the file }; - this._logMessage(` -- FND-RCD-ADD LAST sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]`); + this._logMessage( + ` -- FND-RCD-ADD LAST sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]` + ); this.codeBlockSpans.push(newBlockSpan); } } diff --git a/spin2/client/src/providers/spin.color.regions.ts b/spin2/client/src/providers/spin.color.regions.ts index 4535433..73f3574 100644 --- a/spin2/client/src/providers/spin.color.regions.ts +++ b/spin2/client/src/providers/spin.color.regions.ts @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; // src/providers/spin.color.regions.ts -import * as vscode from "vscode"; -import * as path from "path"; -import { Position } from "vscode"; -import { LocatedBlockFindings, eBLockType, IBlockSpan } from "./spin.block.tracker"; -import { editorConfiguration, reloadEditorConfiguration } from "../spin.clientBehavior.configuration"; -import { isSpinOrPasmFile, activeSpinEditors } from "../spin.vscode.utils"; -import { SpinCodeUtils, eParseState } from "../spin.code.utils"; +import * as vscode from 'vscode'; +import * as path from 'path'; +import { Position } from 'vscode'; +import { LocatedBlockFindings, eBLockType, IBlockSpan } from './spin.block.tracker'; +import { editorConfiguration, reloadEditorConfiguration } from '../spin.clientBehavior.configuration'; +import { isSpinOrPasmFile, activeSpinEditors } from '../spin.vscode.utils'; +import { SpinCodeUtils, eParseState } from '../spin.code.utils'; interface DecoratorMap { [Identifier: string]: DecoratorDescription; @@ -74,18 +74,18 @@ export class RegionColorizer { pubDk: "#C4E1FFff", // HSB: 211,23,100 (25 was too dark/rich) */ // Mine (Jeff's recolored) - objLt: "#ffd9d9FF", // HSB: 0,15,100 - OBJ red - objDk: "#ffbfbfFF", // HSB: 0,25,100 - varLt: "#ffecd9FF", // HSB: 30,15,100 - VAR orange - varDk: "#ffdfbfFF", // HSB: 30,25,100 - conLt: "#ffffd9FF", // HSB: 60,15,100 - CON yellow - conDk: "#ffffbfFF", // HSB: 60,25,100 - datLt: "#d9ffd9FF", // HSB: 120,15,100 - DAT green - datDk: "#bfffbfFF", // HSB: 120,25,100 - priLt: "#d9ffffFF", // HSB: 180,15,100 - PRI blue - priDk: "#bfffffFF", // HSB: 180,25,100 - pubLt: "#d9d9ffFF", // HSB: 240,15,100 - PUB purple - pubDk: "#bfbfffFF", // HSB: 240,23,100 + objLt: '#ffd9d9FF', // HSB: 0,15,100 - OBJ red + objDk: '#ffbfbfFF', // HSB: 0,25,100 + varLt: '#ffecd9FF', // HSB: 30,15,100 - VAR orange + varDk: '#ffdfbfFF', // HSB: 30,25,100 + conLt: '#ffffd9FF', // HSB: 60,15,100 - CON yellow + conDk: '#ffffbfFF', // HSB: 60,25,100 + datLt: '#d9ffd9FF', // HSB: 120,15,100 - DAT green + datDk: '#bfffbfFF', // HSB: 120,25,100 + priLt: '#d9ffffFF', // HSB: 180,15,100 - PRI blue + priDk: '#bfffffFF', // HSB: 180,25,100 + pubLt: '#d9d9ffFF', // HSB: 240,15,100 - PUB purple + pubDk: '#bfbfffFF' // HSB: 240,23,100 }; private namedColorsAlpha: number = -1; @@ -103,13 +103,15 @@ export class RegionColorizer { if (this.coloringDebugLogEnabled) { if (this.coloringOutputChannel === undefined) { //Create output channel - this.coloringOutputChannel = vscode.window.createOutputChannel("Spin/Spin2 BGColor DEBUG"); - this.logMessage("Spin/Spin2 BGColor log started."); + this.coloringOutputChannel = vscode.window.createOutputChannel('Spin/Spin2 BGColor DEBUG'); + this.logMessage('Spin/Spin2 BGColor log started.'); } else { - this.logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this.logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } - this.logMessage(`* NEW Config: spinExtension.ClientBehavior.colorBackground=(${this.configuration.colorBackground}), backgroundApha=(${this.configuration.backgroundApha})`); + this.logMessage( + `* NEW Config: spinExtension.ClientBehavior.colorBackground=(${this.configuration.colorBackground}), backgroundApha=(${this.configuration.backgroundApha})` + ); this.updateColorizerConfiguration(); // ensure we match the current setting value } @@ -148,7 +150,7 @@ export class RegionColorizer { } public backgroundAlpha(): number { - let interpretedAlpha: number = this.configuration.backgroundApha ? this.configuration.backgroundApha : 80; + const interpretedAlpha: number = this.configuration.backgroundApha ? this.configuration.backgroundApha : 80; return interpretedAlpha; } @@ -156,14 +158,16 @@ export class RegionColorizer { const updated = reloadEditorConfiguration(); if (updated || this.namedColorsAlpha == -1) { this.logMessage(`* updateColorizerConfiguration() settings changed`); - this.logMessage(`* UPD Config: spinExtension.ClientBehavior.colorBackground=(${this.configuration.colorBackground}), backgroundApha=(${this.configuration.backgroundApha})`); + this.logMessage( + `* UPD Config: spinExtension.ClientBehavior.colorBackground=(${this.configuration.colorBackground}), backgroundApha=(${this.configuration.backgroundApha})` + ); const settingsAlpha: number = this.backgroundAlpha(); if (this.namedColorsAlpha != settingsAlpha) { this.namedColorsAlpha = this.backgroundAlpha(); this.updateColorTable(); } if (this.isColoringBackground() == false) { - this.removeBackgroundColors("updateCfg"); + this.removeBackgroundColors('updateCfg'); } // we need to force redraw of open editor when config changes! @@ -176,7 +180,7 @@ export class RegionColorizer { this.logMessage(`* config: re-coloring [${filespec}]`); const blockSpanInformation: LocatedBlockFindings = this.blockFindingsForFileSpec(filespec); if (blockSpanInformation) { - this.updateRegionColors(currEditor, "cfgChg", true); + this.updateRegionColors(currEditor, 'cfgChg', true); } else { this.logMessage(` -- config: NO cached DocumentFindings for [${filespec}]`); } @@ -219,7 +223,7 @@ export class RegionColorizer { const fullText: string = document.getText(); const lines: string[] = fullText.split(/\r\n|\r|\n/); - this.logMessage("---> Pre SCAN"); + this.logMessage('---> Pre SCAN'); let currState: eParseState = eParseState.inCon; // compiler defaults to CON at start let priorState: eParseState = currState; let prePAsmState: eParseState = currState; @@ -242,11 +246,11 @@ export class RegionColorizer { let currOffset: number = 0; let bFoundOpenClosePair: boolean = false; do { - nestedOpeningOffset = trimmedLine.indexOf("{", currOffset); + nestedOpeningOffset = trimmedLine.indexOf('{', currOffset); if (nestedOpeningOffset != -1) { bFoundOpenClosePair = false; // we have an opening { - closingOffset = trimmedLine.indexOf("}", nestedOpeningOffset); + closingOffset = trimmedLine.indexOf('}', nestedOpeningOffset); if (closingOffset != -1) { // and we have a closing, ignore this see if we have next currOffset = closingOffset + 1; @@ -256,7 +260,7 @@ export class RegionColorizer { } } } while (nestedOpeningOffset != -1 && bFoundOpenClosePair); - closingOffset = trimmedLine.indexOf("}", currOffset); + closingOffset = trimmedLine.indexOf('}', currOffset); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -265,7 +269,7 @@ export class RegionColorizer { continue; } else if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = line.indexOf("}}"); + const closingOffset = line.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -276,10 +280,10 @@ export class RegionColorizer { continue; // no further processing of blank line } else if (trimmedNonCommentLine.length > 0 && this.spinCodeUtils.isFlexspinPreprocessorDirective(lineParts[0])) { continue; // handled flexspin comment do next line - } else if (trimmedLine.startsWith("{{")) { + } else if (trimmedLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = line.indexOf("{{"); - const closingOffset = line.indexOf("}}", openingOffset + 2); + const openingOffset = line.indexOf('{{'); + const closingOffset = line.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this } else { @@ -289,11 +293,11 @@ export class RegionColorizer { // DO NOTHING Let Syntax highlighting do this } continue; - } else if (trimmedLine.startsWith("{")) { + } else if (trimmedLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = line.indexOf("{"); - const closingOffset = line.indexOf("}", openingOffset + 1); + const openingOffset = line.indexOf('{'); + const closingOffset = line.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line comment... } else { @@ -330,7 +334,7 @@ export class RegionColorizer { } blockSpanInformation.recordBlockStart(newBlockType, i); // start new one which ends prior - this.logMessage("- scan Ln#" + (i + 1) + " currState=[" + currState + "]"); + this.logMessage('- scan Ln#' + (i + 1) + ' currState=[' + currState + ']'); // ID the remainder of the line if (currState == eParseState.inPub || currState == eParseState.inPri) { // process PUB/PRI method signature @@ -338,10 +342,10 @@ export class RegionColorizer { // process a constant line } else if (currState == eParseState.inDat) { // process a class(static) variable line - if (trimmedNonCommentLine.length > 6 && trimmedNonCommentLine.toUpperCase().includes("ORG")) { + if (trimmedNonCommentLine.length > 6 && trimmedNonCommentLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH const nonStringLine: string = this.spinCodeUtils.removeDoubleQuotedStrings(trimmedNonCommentLine); - if (nonStringLine.toUpperCase().includes("ORG")) { + if (nonStringLine.toUpperCase().includes('ORG')) { prePAsmState = currState; currState = eParseState.inDatPAsm; continue; @@ -359,10 +363,10 @@ export class RegionColorizer { // process a data line if (trimmedLine.length > 0) { if (trimmedLine.length > 6) { - if (trimmedLine.toUpperCase().includes("ORG")) { + if (trimmedLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH const nonStringLine: string = this.spinCodeUtils.removeDoubleQuotedStrings(trimmedLine); - if (nonStringLine.toUpperCase().includes("ORG")) { + if (nonStringLine.toUpperCase().includes('ORG')) { prePAsmState = currState; currState = eParseState.inDatPAsm; continue; @@ -379,15 +383,15 @@ export class RegionColorizer { } } blockSpanInformation.finishFinalBlock(lines.length - 1); // mark end of final block in file - this.logMessage(" -- scan DONE"); + this.logMessage(' -- scan DONE'); } public updateRegionColors(activeEditor: vscode.TextEditor, caller: string, isForced: boolean = false) { // remove any prior colors, then recolor - const isConfigChange: boolean = caller.includes("cfgChg"); - const isWindowChange: boolean = caller.includes("actvEditorChg"); - const isFromRescan: boolean = caller.includes("end1stPass"); - const isDocChange: boolean = caller.includes("docDidChg"); + const isConfigChange: boolean = caller.includes('cfgChg'); + const isWindowChange: boolean = caller.includes('actvEditorChg'); + const isFromRescan: boolean = caller.includes('end1stPass'); + const isDocChange: boolean = caller.includes('docDidChg'); const filespec: string = activeEditor.document.fileName; let isNewDocument: boolean = false; if (this.docVersionByFilespec.has(filespec)) { @@ -401,7 +405,9 @@ export class RegionColorizer { isNewDocument = true; } this.logMessage(`- updRegionColors(${caller}), ver=[${activeEditor.document.version}] ENTRY`); - this.logMessage(` -- isConfigChange=(${isConfigChange}), isWindowChange=(${isWindowChange}), isFromRescan=(${isFromRescan}), isDocChange=(${isDocChange})`); + this.logMessage( + ` -- isConfigChange=(${isConfigChange}), isWindowChange=(${isWindowChange}), isFromRescan=(${isFromRescan}), isDocChange=(${isDocChange})` + ); if (isNewDocument || isFromRescan || isWindowChange || isDocChange) { // when we get real data save it for config change use this.parseDocumentForRegions(activeEditor.document); @@ -409,7 +415,9 @@ export class RegionColorizer { const isSpinFile = isSpinOrPasmFile(filespec); let instancesByColor: DecoratorInstanceHash = {}; let newInstance: boolean = false; - let foundInstancesByColor: DecoratorInstanceHash | undefined = this.decoratorInstancesByFilespec.has(filespec) ? this.decoratorInstancesByFilespec.get(filespec) : undefined; + const foundInstancesByColor: DecoratorInstanceHash | undefined = this.decoratorInstancesByFilespec.has(filespec) + ? this.decoratorInstancesByFilespec.get(filespec) + : undefined; if (foundInstancesByColor) { instancesByColor = foundInstancesByColor; this.logMessage(` -- using existing instance cache`); @@ -425,12 +433,14 @@ export class RegionColorizer { // only clear if coloring is OFF -OR- // if text changed, or if syntax pass requested update if (!isColoringEnabled) { - this.removeBackgroundColors("NOT COLORING updRgnCo():" + caller, activeEditor); + this.removeBackgroundColors('NOT COLORING updRgnCo():' + caller, activeEditor); } else { // only color if // (1) coloring is turned on this.logMessage(`- updRegionColors() fm=(${caller}) [${filespec}]`); - let decorationsByColor: DecoratorMap | undefined = this.colorInfoByFilespec.has(filespec) ? this.colorInfoByFilespec.get(filespec) : undefined; + let decorationsByColor: DecoratorMap | undefined = this.colorInfoByFilespec.has(filespec) + ? this.colorInfoByFilespec.get(filespec) + : undefined; if (isWindowChange && !newInstance) { // use existing color set this.logMessage(` -- widow change use existing colors`); @@ -463,7 +473,7 @@ export class RegionColorizer { //this.logMessage(`- updRegionColors(): FOUND ${codeBlockSpans.length} codeBlockSpan(s)`); if (decorationsByColor) { if (!isWindowChange) { - this.removeBackgroundColors("updRgnCo():" + caller, activeEditor); + this.removeBackgroundColors('updRgnCo():' + caller, activeEditor); } // for all decorations add to editor const keys = Object.keys(decorationsByColor); @@ -506,7 +516,7 @@ export class RegionColorizer { const endPos = new Position(codeBlockSpan.endLineIdx, 0); const decorationRange = { - range: new vscode.Range(startPos, endPos), + range: new vscode.Range(startPos, endPos) }; // if decoration for this color doesn't exist @@ -515,7 +525,7 @@ export class RegionColorizer { decorationsByColor[color] = { name: color, regions: [], - decorator: undefined, + decorator: undefined }; } @@ -540,7 +550,7 @@ export class RegionColorizer { const newInstance = vscode.window.createTextEditorDecorationType({ isWholeLine: true, - backgroundColor: color, + backgroundColor: color }); decoratorInstances[color] = newInstance; @@ -555,7 +565,7 @@ export class RegionColorizer { if (lhsColors.length != rhsColors.length) { mapsDiffStatus = true; } else { - for (let color in lhsColors) { + for (const color in lhsColors) { const lhsDescription: DecoratorDescription = lhsMap[color]; if (color in rhsColors) { /// both have same color? @@ -578,8 +588,8 @@ export class RegionColorizer { break; } for (let rgnIdx = 0; rgnIdx < lhsDescription.regions.length; rgnIdx++) { - const lhsRange: vscode.Range = lhsDescription.regions[rgnIdx]["range"]; - const rhsRange: vscode.Range = rhsDescription.regions[rgnIdx]["range"]; + const lhsRange: vscode.Range = lhsDescription.regions[rgnIdx]['range']; + const rhsRange: vscode.Range = rhsDescription.regions[rgnIdx]['range']; if (lhsRange.start != rhsRange.start || lhsRange.end != rhsRange.end) { // colored region linenumber range is diff. mapsDiffStatus = true; @@ -603,7 +613,7 @@ export class RegionColorizer { } private removeBackgroundColors(caller: string, activeEditor?: vscode.TextEditor) { - const activeFile: string = activeEditor ? activeEditor.document.fileName : "file=unknown"; + const activeFile: string = activeEditor ? activeEditor.document.fileName : 'file=unknown'; this.logMessage(`- rmvBackgroundColors(${caller}) [${activeFile}] - ENTRY`); if (!activeEditor) { activeEditor = vscode.window.activeTextEditor; @@ -633,7 +643,7 @@ export class RegionColorizer { // alpha is specified in percent [10-100] if (this.namedColorsAlpha > 0) { const bgAlphaHex: string = this.twoDigitHexForByteValue(255 * (this.namedColorsAlpha / 100)); - for (let colorKey in this.namedColors) { + for (const colorKey in this.namedColors) { const colorRGBA: string = this.namedColors[colorKey]; const updatedRGBA: string = colorRGBA.substring(0, 7) + bgAlphaHex; this.namedColors[colorKey] = updatedRGBA; @@ -665,21 +675,21 @@ export class RegionColorizer { private colorForBlock(currblockType: eBLockType, sequenceNbr: number): string | undefined { let colorKey: string | undefined = undefined; if (currblockType == eBLockType.isCon) { - colorKey = "con"; + colorKey = 'con'; } else if (currblockType == eBLockType.isObj) { - colorKey = "obj"; + colorKey = 'obj'; } else if (currblockType == eBLockType.isVar) { - colorKey = "var"; + colorKey = 'var'; } else if (currblockType == eBLockType.isDat) { - colorKey = "dat"; + colorKey = 'dat'; } else if (currblockType == eBLockType.isPub) { - colorKey = "pub"; + colorKey = 'pub'; } else if (currblockType == eBLockType.isPri) { - colorKey = "pri"; + colorKey = 'pri'; } let desiredColor: string | undefined = undefined; if (colorKey) { - const suffix: string = (sequenceNbr & 0x01) == 0x01 ? "Lt" : "Dk"; + const suffix: string = (sequenceNbr & 0x01) == 0x01 ? 'Lt' : 'Dk'; colorKey = `${colorKey}${suffix}`; if (colorKey in this.namedColors) { desiredColor = this.namedColors[colorKey]; diff --git a/spin2/client/src/providers/spin.document.generate.ts b/spin2/client/src/providers/spin.document.generate.ts index 1584a9e..d89506e 100644 --- a/spin2/client/src/providers/spin.document.generate.ts +++ b/spin2/client/src/providers/spin.document.generate.ts @@ -1,13 +1,14 @@ -"use strict"; +/* eslint-disable @typescript-eslint/no-unused-vars */ +'use strict'; -import * as vscode from "vscode"; -import { EndOfLine } from "vscode"; +import * as vscode from 'vscode'; +import { EndOfLine } from 'vscode'; -import * as fs from "fs"; -import * as path from "path"; +import * as fs from 'fs'; +import * as path from 'path'; -import { isSpin1Document, isSpin2File, isSpin1File } from "../spin.vscode.utils"; -import { SpinCodeUtils, eParseState } from "../spin.code.utils"; +import { isSpin1Document, isSpin2File, isSpin1File } from '../spin.vscode.utils'; +import { SpinCodeUtils, eParseState } from '../spin.code.utils'; export class DocGenerator { private generatorDebugLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit @@ -18,10 +19,10 @@ export class DocGenerator { if (this.generatorDebugLogEnabled) { if (this.docGenOutputChannel === undefined) { //Create output channel - this.docGenOutputChannel = vscode.window.createOutputChannel("Spin/Spin2 DocGen DEBUG"); - this.logMessage("Spin/Spin2 DocGen log started."); + this.docGenOutputChannel = vscode.window.createOutputChannel('Spin/Spin2 DocGen DEBUG'); + this.logMessage('Spin/Spin2 DocGen log started.'); } else { - this.logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this.logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -42,8 +43,8 @@ export class DocGenerator { public insertDocComment(document: vscode.TextDocument, selections: readonly vscode.Selection[]): vscode.ProviderResult { return selections .map((selection) => { - let results: vscode.ProviderResult = []; - let endOfLineStr: string = document.eol == EndOfLine.CRLF ? "\r\n" : "\n"; + const results: vscode.ProviderResult = []; + const endOfLineStr: string = document.eol == EndOfLine.CRLF ? '\r\n' : '\n'; const isSpin1Doc: boolean = isSpin1Document(document); this.logMessage( `* iDc selection(isSingle-[${selection.isSingleLine}] isSpin1Doc-(${isSpin1Doc}) isEmpty-[${selection.isEmpty}] s,e-[${selection.start.line}:${selection.start.character} - ${selection.end.line}:${selection.end.character}] activ-[${selection.active.character}] anchor-[${selection.anchor.character}])` @@ -51,9 +52,9 @@ export class DocGenerator { const { firstLine, lastLine, lineCount } = this._lineNumbersFromSelection(document, selection); const cursorPos: vscode.Position = new vscode.Position(firstLine + 1, 0); let linesToInsert: string[] = []; - let signatureLine: string = document.lineAt(firstLine).text.trim(); - const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ""; - const isSignature: boolean = linePrefix.startsWith("pub") || linePrefix.startsWith("pri"); + const signatureLine: string = document.lineAt(firstLine).text.trim(); + const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ''; + const isSignature: boolean = linePrefix.startsWith('pub') || linePrefix.startsWith('pri'); if (isSignature) { linesToInsert = this.generateDocCommentForSignature(signatureLine, isSpin1Doc); } else { @@ -62,7 +63,7 @@ export class DocGenerator { // insert the lines, if any if (linesToInsert.length > 0) { - for (let line of linesToInsert) { + for (const line of linesToInsert) { results.push(vscode.TextEdit.insert(cursorPos, `${line}` + endOfLineStr)); } } @@ -71,7 +72,10 @@ export class DocGenerator { .reduce((selections, selection) => selections.concat(selection), []); } - private _lineNumbersFromSelection(document: vscode.TextDocument, selection: vscode.Selection): { firstLine: number; lastLine: number; lineCount: number } { + private _lineNumbersFromSelection( + document: vscode.TextDocument, + selection: vscode.Selection + ): { firstLine: number; lastLine: number; lineCount: number } { let lineCount: number = 0; let firstLine: number = 0; let lastLine: number = 0; @@ -89,7 +93,7 @@ export class DocGenerator { firstLine = selection.start.line; lastLine = selection.end.line; //this.logMessage(` - (DBG) ${lineCount} lines: fm,to=[${firstLine}, ${lastLine}], allSelectedText=[${allSelectedText}](${allSelectedText.length}), lines=[${lines}](${lines.length})`); - for (var currLineIdx: number = 0; currLineIdx < lines.length; currLineIdx++) { + for (let currLineIdx: number = 0; currLineIdx < lines.length; currLineIdx++) { if (lines[currLineIdx].length == 0) { if (currLineIdx == lines.length - 1) { lastLine--; @@ -110,17 +114,17 @@ export class DocGenerator { } public generateDocCommentForSignature(signatureLine: string, isSpin1Method: boolean): string[] { - let desiredDocComment: string[] = []; + const desiredDocComment: string[] = []; this.logMessage(`* iDc SKIP - generateDocCommentForSignature([${signatureLine}], isSpin1=${isSpin1Method})`); - const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ""; - const isSignature: boolean = linePrefix.startsWith("pub") || linePrefix.startsWith("pri"); - const isPRI: boolean = linePrefix.startsWith("pri"); + const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ''; + const isSignature: boolean = linePrefix.startsWith('pub') || linePrefix.startsWith('pri'); + const isPRI: boolean = linePrefix.startsWith('pri'); if (isSignature) { const commentPrefix = isPRI ? "'" : "''"; - desiredDocComment.push(commentPrefix + " ..."); // for description - desiredDocComment.push(commentPrefix + " "); // blank line - const posOpenParen = signatureLine.indexOf("("); - const posCloseParen = signatureLine.indexOf(")"); + desiredDocComment.push(commentPrefix + ' ...'); // for description + desiredDocComment.push(commentPrefix + ' '); // blank line + const posOpenParen = signatureLine.indexOf('('); + const posCloseParen = signatureLine.indexOf(')'); // if we have name() it's spin1 or spin2 if (posOpenParen != -1 && posCloseParen != -1) { const bHasParameters: boolean = posCloseParen - posOpenParen > 1 ? true : false; @@ -133,11 +137,11 @@ export class DocGenerator { desiredDocComment.push(commentPrefix + ` @param ${paramNames[paramIdx]} - `); // blank line } } - const bHasReturnValues: boolean = signatureLine.includes(":") ? true : false; - const bHasLocalVariables: boolean = signatureLine.includes("|") ? true : false; + const bHasReturnValues: boolean = signatureLine.includes(':') ? true : false; + const bHasLocalVariables: boolean = signatureLine.includes('|') ? true : false; if (bHasReturnValues) { - const posStartReturn = signatureLine.indexOf(":") + 1; - const posEndReturn = bHasLocalVariables ? signatureLine.indexOf("|") - 1 : signatureLine.length; + const posStartReturn = signatureLine.indexOf(':') + 1; + const posEndReturn = bHasLocalVariables ? signatureLine.indexOf('|') - 1 : signatureLine.length; const returnsString: string = signatureLine.substring(posStartReturn, posEndReturn); const numberReturns: number = (returnsString.match(/,/g) || []).length + 1; const returnNames = returnsString.split(/[ \t,]/).filter(Boolean); @@ -148,17 +152,17 @@ export class DocGenerator { } let posTrailingComment = signatureLine.indexOf("'"); if (posTrailingComment == -1) { - posTrailingComment = signatureLine.indexOf("{"); + posTrailingComment = signatureLine.indexOf('{'); } if (bHasLocalVariables) { // locals are always non-doc single-line comments - const posStartLocal = signatureLine.indexOf("|") + 1; + const posStartLocal = signatureLine.indexOf('|') + 1; const posEndLocal = posTrailingComment != -1 ? posTrailingComment : signatureLine.length; const localsString: string = signatureLine.substring(posStartLocal, posEndLocal); const numberLocals: number = (localsString.match(/,/g) || []).length + 1; const localsNames = localsString.split(/[ \t,]/).filter(Boolean); this.logMessage(`* gDClocalsString=[${localsString}], localsNames=[${localsNames}]`); - desiredDocComment.push(""); // empty line so following is not shown in comments for method + desiredDocComment.push(''); // empty line so following is not shown in comments for method desiredDocComment.push("' Local Variables:"); // blank line for (let localIdx = 0; localIdx < numberLocals; localIdx++) { desiredDocComment.push("'" + ` @local ${localsNames[localIdx]} - `); // blank line @@ -166,11 +170,11 @@ export class DocGenerator { } } else if (isSpin1Method) { // spin1 methods don't need parens when no parameters are specified - const bHasReturnValues: boolean = signatureLine.includes(":") ? true : false; - const bHasLocalVariables: boolean = signatureLine.includes("|") ? true : false; + const bHasReturnValues: boolean = signatureLine.includes(':') ? true : false; + const bHasLocalVariables: boolean = signatureLine.includes('|') ? true : false; if (bHasReturnValues) { - const posStartReturn = signatureLine.indexOf(":") + 1; - const posEndReturn = bHasLocalVariables ? signatureLine.indexOf("|") - 1 : signatureLine.length; + const posStartReturn = signatureLine.indexOf(':') + 1; + const posEndReturn = bHasLocalVariables ? signatureLine.indexOf('|') - 1 : signatureLine.length; const returnsString: string = signatureLine.substring(posStartReturn, posEndReturn); // spin1 only allows 1 return variable const returnNames = returnsString.split(/[ \t,]/).filter(Boolean); @@ -179,17 +183,17 @@ export class DocGenerator { } let posTrailingComment = signatureLine.indexOf("'"); if (posTrailingComment == -1) { - posTrailingComment = signatureLine.indexOf("{"); + posTrailingComment = signatureLine.indexOf('{'); } if (bHasLocalVariables) { // locals are always non-doc single-line comments - const posStartLocal = signatureLine.indexOf("|") + 1; + const posStartLocal = signatureLine.indexOf('|') + 1; const posEndLocal = posTrailingComment != -1 ? posTrailingComment : signatureLine.length; const localsString: string = signatureLine.substring(posStartLocal, posEndLocal); const numberLocals: number = (localsString.match(/,/g) || []).length + 1; const localsNames = localsString.split(/[ \t,]/).filter(Boolean); this.logMessage(`* gDClocalsString=[${localsString}], localsNames=[${localsNames}]`); - desiredDocComment.push(""); // empty line so following is not shown in comments for method + desiredDocComment.push(''); // empty line so following is not shown in comments for method desiredDocComment.push("' Local Variables:"); // blank line for (let localIdx = 0; localIdx < numberLocals; localIdx++) { desiredDocComment.push("'" + ` @local ${localsNames[localIdx]} - `); // blank line @@ -201,35 +205,35 @@ export class DocGenerator { } public generateDocument(): void { - let textEditor = vscode.window.activeTextEditor; + const textEditor = vscode.window.activeTextEditor; if (textEditor) { - let endOfLineStr: string = textEditor.document.eol == EndOfLine.CRLF ? "\r\n" : "\n"; + const endOfLineStr: string = textEditor.document.eol == EndOfLine.CRLF ? '\r\n' : '\n'; let bHuntingForVersion: boolean = true; // initially we re hunting for a {Spin2_v##} spec in file-top comments - var currentlyOpenTabfilePath = textEditor.document.uri.fsPath; - var currentlyOpenTabfolderName = path.dirname(currentlyOpenTabfilePath); - var currentlyOpenTabfileName = path.basename(currentlyOpenTabfilePath); + const currentlyOpenTabfilePath = textEditor.document.uri.fsPath; + const currentlyOpenTabfolderName = path.dirname(currentlyOpenTabfilePath); + const currentlyOpenTabfileName = path.basename(currentlyOpenTabfilePath); this.logMessage(`+ (DBG) generateDocument() fsPath-(${currentlyOpenTabfilePath})`); this.logMessage(`+ (DBG) generateDocument() folder-(${currentlyOpenTabfolderName})`); this.logMessage(`+ (DBG) generateDocument() filename-(${currentlyOpenTabfileName})`); let isSpinFile: boolean = isSpin2File(currentlyOpenTabfileName); let isSpin1: boolean = false; - let fileType: string = ".spin2"; + let fileType: string = '.spin2'; if (!isSpinFile) { isSpinFile = isSpin1File(currentlyOpenTabfileName); if (isSpinFile) { isSpin1 = true; - fileType = ".spin"; + fileType = '.spin'; } } if (isSpinFile) { - const objectName: string = currentlyOpenTabfileName.replace(fileType, ""); - const docFilename: string = currentlyOpenTabfileName.replace(fileType, ".txt"); + const objectName: string = currentlyOpenTabfileName.replace(fileType, ''); + const docFilename: string = currentlyOpenTabfileName.replace(fileType, '.txt'); this.logMessage(`+ (DBG) generateDocument() outFn-(${docFilename})`); const outFSpec = path.join(currentlyOpenTabfolderName, docFilename); this.logMessage(`+ (DBG) generateDocument() outFSpec-(${outFSpec})`); - let outFile = fs.openSync(outFSpec, "w"); + const outFile = fs.openSync(outFSpec, 'w'); let shouldEmitTopDocComments: boolean = true; @@ -243,7 +247,7 @@ export class DocGenerator { // 1st pass: emit topfile doc comments then list of pub methods // for (let i = 0; i < textEditor.document.lineCount; i++) { - let line = textEditor.document.lineAt(i); + const line = textEditor.document.lineAt(i); const lineNbr = i + 1; const trimmedLine = line.text.trim(); @@ -256,7 +260,7 @@ export class DocGenerator { if (currState == eParseState.inMultiLineDocComment) { // skip all {{ --- }} multi-line doc comments // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = line.text.indexOf("}}"); + const closingOffset = line.text.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -274,8 +278,8 @@ export class DocGenerator { } else if (currState == eParseState.inMultiLineComment) { // skip all { --- } multi-line non-doc comments // in multi-line non-doc-comment, hunt for end '}' to exit - const openingOffset = line.text.indexOf("{"); - let closingOffset = line.text.indexOf("}"); + const openingOffset = line.text.indexOf('{'); + const closingOffset = line.text.indexOf('}'); if (openingOffset != -1 && closingOffset != -1 && openingOffset < closingOffset) { // do nothing with NESTED {cmt} lines } else if (closingOffset != -1) { @@ -291,10 +295,10 @@ export class DocGenerator { currState = sectionStatus.inProgressStatus; } - if (trimmedLine.startsWith("{{")) { + if (trimmedLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = line.text.indexOf("{{"); - const closingOffset = line.text.indexOf("}}", openingOffset + 2); + const openingOffset = line.text.indexOf('{{'); + const closingOffset = line.text.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line comment, just ignore it } else { @@ -307,11 +311,11 @@ export class DocGenerator { } } continue; - } else if (trimmedLine.startsWith("{")) { + } else if (trimmedLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = line.text.indexOf("{"); - const closingOffset = line.text.indexOf("}", openingOffset + 1); + const openingOffset = line.text.indexOf('{'); + const closingOffset = line.text.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment priorState = currState; @@ -338,14 +342,14 @@ export class DocGenerator { pubsFound++; if (shouldEmitTopDocComments) { this.logMessage(`+ (DBG) generateDocument() EMIT object header`); - fs.appendFileSync(outFile, "" + endOfLineStr); // blank line + fs.appendFileSync(outFile, '' + endOfLineStr); // blank line const introText: string = 'Object "' + objectName + '" Interface:'; fs.appendFileSync(outFile, introText + endOfLineStr); if (requiredLanguageVersion > 0) { const lanVersionText: string = ` (Requires Spin2 Language v${requiredLanguageVersion})`; fs.appendFileSync(outFile, lanVersionText + endOfLineStr); } - fs.appendFileSync(outFile, "" + endOfLineStr); // blank line + fs.appendFileSync(outFile, '' + endOfLineStr); // blank line } shouldEmitTopDocComments = false; // no more of these! // emit new PUB prototype (w/o any trailing comment) @@ -360,13 +364,13 @@ export class DocGenerator { let emitPubDocComment: boolean = false; let emitTrailingDocComment: boolean = false; for (let i = 0; i < textEditor.document.lineCount; i++) { - let line = textEditor.document.lineAt(i); + const line = textEditor.document.lineAt(i); const trimmedLine = line.text.trim(); // skip all {{ --- }} multi-line doc comments if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = line.text.indexOf("}}"); + const closingOffset = line.text.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -383,8 +387,8 @@ export class DocGenerator { continue; } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit - const openingOffset = line.text.indexOf("{"); - let closingOffset = line.text.indexOf("}"); + const openingOffset = line.text.indexOf('{'); + const closingOffset = line.text.indexOf('}'); if (openingOffset != -1 && closingOffset != -1 && openingOffset < closingOffset) { // do nothing with NESTED {cmt} lines } else if (closingOffset != -1) { @@ -399,10 +403,10 @@ export class DocGenerator { if (sectionStatus.isSectionStart) { currState = sectionStatus.inProgressStatus; } - if (trimmedLine.startsWith("{{")) { + if (trimmedLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = line.text.indexOf("{{"); - const closingOffset = line.text.indexOf("}}", openingOffset + 2); + const openingOffset = line.text.indexOf('{{'); + const closingOffset = line.text.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line comment, just ignore it } else { @@ -415,11 +419,11 @@ export class DocGenerator { } } continue; - } else if (trimmedLine.startsWith("{")) { + } else if (trimmedLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = line.text.indexOf("{"); - const closingOffset = line.text.indexOf("}", openingOffset + 1); + const openingOffset = line.text.indexOf('{'); + const closingOffset = line.text.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment priorState = currState; @@ -440,12 +444,12 @@ export class DocGenerator { pubsSoFar++; // emit new PUB prototype (w/o any trailing comment, and NO local variables) const trailingDocComment: string | undefined = this.getTrailingDocComment(trimmedLine); - let trimmedNonCommentLine = this.getNonCommentLineRemainder(0, trimmedLine); - const header: string = "_".repeat(trimmedNonCommentLine.length); - fs.appendFileSync(outFile, "" + endOfLineStr); // blank line + const trimmedNonCommentLine = this.getNonCommentLineRemainder(0, trimmedLine); + const header: string = '_'.repeat(trimmedNonCommentLine.length); + fs.appendFileSync(outFile, '' + endOfLineStr); // blank line fs.appendFileSync(outFile, header + endOfLineStr); // underscore header line fs.appendFileSync(outFile, trimmedNonCommentLine + endOfLineStr); - fs.appendFileSync(outFile, "" + endOfLineStr); // blank line + fs.appendFileSync(outFile, '' + endOfLineStr); // blank line if (trailingDocComment) { fs.appendFileSync(outFile, trailingDocComment + endOfLineStr); // underscore header line } @@ -455,7 +459,7 @@ export class DocGenerator { } } else if (sectionStatus.isSectionStart && currState != eParseState.inPub && emitTrailingDocComment) { // emit blank line just before we do final doc comment at end of file - fs.appendFileSync(outFile, "" + endOfLineStr); // blank line + fs.appendFileSync(outFile, '' + endOfLineStr); // blank line } } fs.closeSync(outFile); @@ -470,9 +474,9 @@ export class DocGenerator { private getNonCommentLineRemainder(offset: number, line: string): string { // remove comment and then local variables let trimmedNonCommentLine = this.spinCodeUtils.getNonCommentLineRemainder(offset, line); - const localSepPosn: number = trimmedNonCommentLine.indexOf("|"); + const localSepPosn: number = trimmedNonCommentLine.indexOf('|'); if (localSepPosn != -1) { - trimmedNonCommentLine = trimmedNonCommentLine.substring(0, localSepPosn - 1).replace(/\s+$/, ""); + trimmedNonCommentLine = trimmedNonCommentLine.substring(0, localSepPosn - 1).replace(/\s+$/, ''); } return trimmedNonCommentLine; } @@ -481,8 +485,8 @@ export class DocGenerator { // return any trailing doc comment from PUB line let docComment: string | undefined = undefined; const startDocTicCmt: number = line.indexOf("''"); - const startDocBraceCmt: number = line.indexOf("{{"); - const endDocBraceCmt: number = line.indexOf("}}"); + const startDocBraceCmt: number = line.indexOf('{{'); + const endDocBraceCmt: number = line.indexOf('}}'); if (startDocTicCmt != -1) { docComment = line.substring(startDocTicCmt + 2).trim(); } else if (startDocBraceCmt != -1 && endDocBraceCmt != -1) { @@ -492,31 +496,34 @@ export class DocGenerator { } async showDocument() { - let textEditor = vscode.window.activeTextEditor; + const textEditor = vscode.window.activeTextEditor; if (textEditor) { - var currentlyOpenTabfilePath = textEditor.document.uri.fsPath; - var currentlyOpenTabfolderName = path.dirname(currentlyOpenTabfilePath); - var currentlyOpenTabfileName = path.basename(currentlyOpenTabfilePath); + const currentlyOpenTabfilePath = textEditor.document.uri.fsPath; + const currentlyOpenTabfolderName = path.dirname(currentlyOpenTabfilePath); + const currentlyOpenTabfileName = path.basename(currentlyOpenTabfilePath); //this.logMessage(`+ (DBG) generateDocument() fsPath-(${currentlyOpenTabfilePath})`); //this.logMessage(`+ (DBG) generateDocument() folder-(${currentlyOpenTabfolderName})`); //this.logMessage(`+ (DBG) generateDocument() filename-(${currentlyOpenTabfileName})`); let isSpinFile: boolean = isSpin2File(currentlyOpenTabfileName); let isSpin1: boolean = false; - let fileType: string = ".spin2"; + let fileType: string = '.spin2'; if (!isSpinFile) { isSpinFile = isSpin1File(currentlyOpenTabfileName); if (isSpinFile) { isSpin1 = true; - fileType = ".spin"; + fileType = '.spin'; } } if (isSpinFile) { - const docFilename: string = currentlyOpenTabfileName.replace(fileType, ".txt"); + const docFilename: string = currentlyOpenTabfileName.replace(fileType, '.txt'); //this.logMessage(`+ (DBG) generateDocument() outFn-(${docFilename})`); const outFSpec = path.join(currentlyOpenTabfolderName, docFilename); //this.logMessage(`+ (DBG) generateDocument() outFSpec-(${outFSpec})`); - let doc = await vscode.workspace.openTextDocument(outFSpec); // calls back into the provider - await vscode.window.showTextDocument(doc, { preview: false, viewColumn: vscode.ViewColumn.Beside }); + const doc = await vscode.workspace.openTextDocument(outFSpec); // calls back into the provider + await vscode.window.showTextDocument(doc, { + preview: false, + viewColumn: vscode.ViewColumn.Beside + }); } } } diff --git a/spin2/client/src/providers/spin.editMode.behavior.ts b/spin2/client/src/providers/spin.editMode.behavior.ts index bbce277..d3b39ef 100644 --- a/spin2/client/src/providers/spin.editMode.behavior.ts +++ b/spin2/client/src/providers/spin.editMode.behavior.ts @@ -1,9 +1,9 @@ -"use strict"; -import * as vscode from "vscode"; +'use strict'; +import * as vscode from 'vscode'; export const overtypeBeforeTypeOrig = (editor: vscode.TextEditor, text: string) => { // skip overtype behavior when enter is pressed - if (text === "\r" || text === "\n" || text === "\r\n") { + if (text === '\r' || text === '\n' || text === '\r\n') { return; } @@ -24,11 +24,11 @@ export const overtypeBeforeTypeOrig = (editor: vscode.TextEditor, text: string) export function overtypeBeforeType(editor: vscode.TextEditor, text: string, undoStop: boolean) { // skip overtype behavior when enter is pressed - if (text === "\r" || text === "\n" || text === "\r\n") { - return vscode.commands.executeCommand("default:type", { text: text }); + if (text === '\r' || text === '\n' || text === '\r\n') { + return vscode.commands.executeCommand('default:type', { text: text }); } - if (text.indexOf(" ") !== -1) undoStop = true; + if (text.indexOf(' ') !== -1) undoStop = true; editor.edit( (edit) => { @@ -82,7 +82,7 @@ export const overtypeBeforePasteOrig = (editor: vscode.TextEditor, text: string, const lineEndOffset = editor.document.offsetAt(editor.document.lineAt(selection.end).range.end); const lineEndLength = lineEndOffset - selectionStartOffset; - const hasNewLine = text.indexOf("\r") !== -1 || text.indexOf("\n") !== -1; + const hasNewLine = text.indexOf('\r') !== -1 || text.indexOf('\n') !== -1; const newSelectionLength = Math.max(hasNewLine ? lineEndLength : Math.min(lineEndLength, text.length), selectionLength); const newSelectionEndPosition = editor.document.positionAt(selectionStartOffset + newSelectionLength); @@ -114,7 +114,7 @@ export function overtypeBeforePaste(editor: vscode.TextEditor, text: string, pas const lineEndOffset = editor.document.offsetAt(editor.document.lineAt(selection.end).range.end); const lineEndLength = lineEndOffset - selectionStartOffset; - const hasNewLine = text.indexOf("\r") !== -1 || text.indexOf("\n") !== -1; + const hasNewLine = text.indexOf('\r') !== -1 || text.indexOf('\n') !== -1; const newSelectionLength = Math.max(hasNewLine ? lineEndLength : Math.min(lineEndLength, text.length), selectionLength); const newSelectionEndPosition = editor.document.positionAt(selectionStartOffset + newSelectionLength); diff --git a/spin2/client/src/providers/spin.editMode.configuration.ts b/spin2/client/src/providers/spin.editMode.configuration.ts index 39cc6b1..90c05ae 100644 --- a/spin2/client/src/providers/spin.editMode.configuration.ts +++ b/spin2/client/src/providers/spin.editMode.configuration.ts @@ -1,19 +1,19 @@ -"use strict"; -import * as vscode from "vscode"; +'use strict'; +import * as vscode from 'vscode'; const stringToCursorStyle = (config: vscode.WorkspaceConfiguration, style: string, def: vscode.TextEditorCursorStyle) => { switch (config.get(style)) { - case "line": + case 'line': return vscode.TextEditorCursorStyle.Line; - case "line-thin": + case 'line-thin': return vscode.TextEditorCursorStyle.LineThin; - case "block": + case 'block': return vscode.TextEditorCursorStyle.Block; - case "block-outline": + case 'block-outline': return vscode.TextEditorCursorStyle.BlockOutline; - case "underline": + case 'underline': return vscode.TextEditorCursorStyle.Underline; - case "underline-thin": + case 'underline-thin': return vscode.TextEditorCursorStyle.UnderlineThin; default: return def; @@ -31,33 +31,33 @@ const getActiveConfiguration = (section: string): vscode.WorkspaceConfiguration }; const loadEditModeConfiguration = () => { - const insertModeConfiguration = vscode.workspace.getConfiguration("spinExtension.InsertMode"); - const editorConfiguration = vscode.workspace.getConfiguration("editor"); + const insertModeConfiguration = vscode.workspace.getConfiguration('spinExtension.insertMode'); + //const editorConfiguration = vscode.workspace.getConfiguration('editor'); return { - overtypePaste: insertModeConfiguration.get("overtypePaste"), - perEditor: insertModeConfiguration.get("perEditor") ? true : false, + overtypePaste: insertModeConfiguration.get('overtypePaste'), + perEditor: insertModeConfiguration.get('perEditor') ? true : false, - enableAlign: insertModeConfiguration.get("enableAlign"), + enableAlign: insertModeConfiguration.get('enableAlign'), - labelInsertMode: insertModeConfiguration.get("labelInsertMode"), - labelOvertypeMode: insertModeConfiguration.get("labelOvertypeMode"), - labelAlignMode: insertModeConfiguration.get("labelAlignMode"), + labelInsertMode: insertModeConfiguration.get('labelInsertMode'), + labelOvertypeMode: insertModeConfiguration.get('labelOvertypeMode'), + labelAlignMode: insertModeConfiguration.get('labelAlignMode'), // tslint:disable-next-line:object-literal-sort-keys get defaultCursorStyle(): vscode.TextEditorCursorStyle { - const editorConfiguration = getActiveConfiguration("editor"); - return stringToCursorStyle(editorConfiguration, "cursorStyle", vscode.TextEditorCursorStyle.Block); + const editorConfiguration = getActiveConfiguration('editor'); + return stringToCursorStyle(editorConfiguration, 'cursorStyle', vscode.TextEditorCursorStyle.Block); }, // Get the user defined cursor style for overtype mode secondaryCursorStyle: (() => { - return stringToCursorStyle(insertModeConfiguration, "secondaryCursorStyle", vscode.TextEditorCursorStyle.Line); + return stringToCursorStyle(insertModeConfiguration, 'secondaryCursorStyle', vscode.TextEditorCursorStyle.Line); })(), ternaryCursorStyle: (() => { - return stringToCursorStyle(insertModeConfiguration, "ternaryCursorStyle", vscode.TextEditorCursorStyle.Line); - })(), + return stringToCursorStyle(insertModeConfiguration, 'ternaryCursorStyle', vscode.TextEditorCursorStyle.Line); + })() }; }; diff --git a/spin2/client/src/providers/spin.editMode.mode.ts b/spin2/client/src/providers/spin.editMode.mode.ts index 6be6bb3..7d4844a 100644 --- a/spin2/client/src/providers/spin.editMode.mode.ts +++ b/spin2/client/src/providers/spin.editMode.mode.ts @@ -1,19 +1,19 @@ -"use strict"; -import * as vscode from "vscode"; +'use strict'; +import * as vscode from 'vscode'; -import { editModeConfiguration } from "./spin.editMode.configuration"; +import { editModeConfiguration } from './spin.editMode.configuration'; export enum eEditMode { INSERT, OVERTYPE, - ALIGN, + ALIGN } const defaultMode = eEditMode.INSERT; const state = { global: defaultMode, - perEditor: new WeakMap(), + perEditor: new WeakMap() }; export const getMode = (textEditor: vscode.TextEditor) => { @@ -55,11 +55,11 @@ export function nextMode2State(oldMode: eEditMode): eEditMode { export function modeName(mode: eEditMode): string { switch (mode) { case eEditMode.INSERT: - return "Insert"; + return 'Insert'; case eEditMode.OVERTYPE: - return "Overtype"; + return 'Overtype'; case eEditMode.ALIGN: - return "Align"; + return 'Align'; default: return `ERROR?? (${mode})`; } diff --git a/spin2/client/src/providers/spin.editMode.statusBarItem.ts b/spin2/client/src/providers/spin.editMode.statusBarItem.ts index d65e82a..4039ec2 100644 --- a/spin2/client/src/providers/spin.editMode.statusBarItem.ts +++ b/spin2/client/src/providers/spin.editMode.statusBarItem.ts @@ -1,8 +1,8 @@ -"use strict"; -import * as vscode from "vscode"; +'use strict'; +import * as vscode from 'vscode'; -import { editModeConfiguration } from "./spin.editMode.configuration"; -import { eEditMode } from "./spin.editMode.mode"; +import { editModeConfiguration } from './spin.editMode.configuration'; +import { eEditMode } from './spin.editMode.mode'; let statusBarItem: vscode.StatusBarItem | null; @@ -12,8 +12,8 @@ export const createStatusBarItem = () => { } statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); - statusBarItem.command = "spinExtension.insertMode.rotate"; - statusBarItem.text = "?NEED-VALUE?"; // testing + statusBarItem.command = 'spinExtension.insertMode.rotate'; + statusBarItem.text = '?NEED-VALUE?'; // testing statusBarItem.show(); updateStatusBarItem(null); // hide status bar content @@ -33,8 +33,8 @@ export const destroyStatusBarItem = () => { export const updateStatusBarItem = (insertMode: eEditMode | null) => { if (statusBarItem != null) { if (insertMode == null) { - statusBarItem.text = ""; - statusBarItem.tooltip = ""; + statusBarItem.text = ''; + statusBarItem.tooltip = ''; statusBarItem.hide(); } else { @@ -42,15 +42,15 @@ export const updateStatusBarItem = (insertMode: eEditMode | null) => { if (insertMode == eEditMode.OVERTYPE) { sbiText = editModeConfiguration.labelOvertypeMode; - statusBarItem.tooltip = "Overtype Mode, click to change to Align Mode (if enabled) or Insert Mode"; + statusBarItem.tooltip = 'Overtype Mode, click to change to Align Mode (if enabled) or Insert Mode'; } else if (insertMode == eEditMode.INSERT) { sbiText = editModeConfiguration.labelInsertMode; - statusBarItem.tooltip = "Insert Mode, click to change to Overtype Mode"; + statusBarItem.tooltip = 'Insert Mode, click to change to Overtype Mode'; } else if (insertMode == eEditMode.ALIGN) { sbiText = editModeConfiguration.labelAlignMode; - statusBarItem.tooltip = "Align Mode, click to change to Insert Mode"; + statusBarItem.tooltip = 'Align Mode, click to change to Insert Mode'; } - if (sbiText === undefined || sbiText == null) sbiText = ""; + if (sbiText === undefined || sbiText == null) sbiText = ''; // preparation for https://github.com/DrMerfy/vscode-overtype/issues/2 // if (editModeConfiguration.showCapsLockState && capsLockOn) { diff --git a/spin2/client/src/providers/spin.tabFormatter.configuration.ts b/spin2/client/src/providers/spin.tabFormatter.configuration.ts index de5e659..ef999bf 100644 --- a/spin2/client/src/providers/spin.tabFormatter.configuration.ts +++ b/spin2/client/src/providers/spin.tabFormatter.configuration.ts @@ -1,5 +1,6 @@ -"use strict"; -import * as vscode from "vscode"; +/* eslint-disable @typescript-eslint/no-unused-vars */ +'use strict'; +import * as vscode from 'vscode'; /** * @@ -23,27 +24,27 @@ export interface Blocks { } const loadTabConfiguration = () => { - const tabFormatterConfiguration = vscode.workspace.getConfiguration("spinExtension.ElasticTabstops"); + const tabFormatterConfiguration = vscode.workspace.getConfiguration('spinExtension.elasticTabstops'); - const tabset: string = tabFormatterConfiguration.get("choice")!; + const tabset: string = tabFormatterConfiguration.get('choice')!; const tabsUserSelection: string = `blocks.${tabset}`; - const blocks = tabFormatterConfiguration.get(tabsUserSelection)!; + //const blocks = tabFormatterConfiguration.get(tabsUserSelection)!; //const blocksConfig = tabFormatterConfiguration.inspect("blocks"); - const tabSize = tabFormatterConfiguration.get("editor.tabSize"); + //const tabSize = tabFormatterConfiguration.get('editor.tabSize'); //const useTabStops = tabFormatterConfiguration.get("editor.useTabStops"); - const enable = tabFormatterConfiguration.get("enable"); + //const enable = tabFormatterConfiguration.get('enable'); //const timeout = tabFormatterConfiguration.get("timeout"); //const maxLineCount = tabFormatterConfiguration.get("maxLineCount"); //const maxLineLength = tabFormatterConfiguration.get("maxLineLength"); return { - enable: tabFormatterConfiguration.get("enable"), - tabSet: tabFormatterConfiguration.get("choice")!, + enable: tabFormatterConfiguration.get('enable'), + tabSet: tabFormatterConfiguration.get('choice')!, blocks: tabFormatterConfiguration.get(tabsUserSelection)!, - tabSize: tabFormatterConfiguration.get("editor.tabSize"), + tabSize: tabFormatterConfiguration.get('editor.tabSize') }; }; @@ -53,7 +54,11 @@ export const reloadTabConfiguration = () => { const newTabConfiguration = loadTabConfiguration(); // bail out if nothing changed - if (tabConfiguration.enable === newTabConfiguration.enable && tabConfiguration.tabSet === newTabConfiguration.tabSet && tabConfiguration.tabSize === newTabConfiguration.tabSize) { + if ( + tabConfiguration.enable === newTabConfiguration.enable && + tabConfiguration.tabSet === newTabConfiguration.tabSet && + tabConfiguration.tabSize === newTabConfiguration.tabSize + ) { return false; } diff --git a/spin2/client/src/providers/spin.tabFormatter.ts b/spin2/client/src/providers/spin.tabFormatter.ts index 9e3d44e..49cbbaf 100644 --- a/spin2/client/src/providers/spin.tabFormatter.ts +++ b/spin2/client/src/providers/spin.tabFormatter.ts @@ -1,12 +1,13 @@ -"use strict"; +/* eslint-disable @typescript-eslint/no-unused-vars */ +'use strict'; // https://typescript.hotexamples.com/examples/vscode/window/createTextEditorDecorationType/typescript-window-createtexteditordecorationtype-method-examples.html -import * as vscode from "vscode"; -import { EndOfLine } from "vscode"; +import * as vscode from 'vscode'; +import { EndOfLine } from 'vscode'; -import { getMode, eEditMode, modeName } from "./spin.editMode.mode"; -import { tabConfiguration, reloadTabConfiguration } from "./spin.tabFormatter.configuration"; +import { getMode, eEditMode, modeName } from './spin.editMode.mode'; +import { tabConfiguration, reloadTabConfiguration } from './spin.tabFormatter.configuration'; // ---------------------------------------------------------------------------- // this file contains routines for tabbing the code: ==> or <== @@ -39,29 +40,30 @@ export interface Blocks { // This is the object that does our tab formatting // CLASS Formatter export class Formatter { + private rawElasticTabstopsConfiguration: vscode.WorkspaceConfiguration; private config = tabConfiguration; - private tabset: string = tabConfiguration.tabSet; + private tabset: string = this.config.tabSet; //readonly selectedSet: string = this.tabset == "PropellerTool" ? "default" : this.tabset; //readonly tabsSelection: string = `blocks.${this.selectedSet}`; - private blocks = tabConfiguration.blocks; + private blocks = this.config.blocks; //readonly blocksConfig = this.config.inspect("blocks"); - private tabSize = tabConfiguration.tabSize; + private tabSize = this.config.tabSize; //readonly useTabStops = this.config.get("editor.useTabStops"); - private enable = tabConfiguration.enable; + private enable = this.config.enable; //readonly timeout = this.config.get("timeout"); //readonly maxLineCount = this.config.get("maxLineCount"); //readonly maxLineLength = this.config.get("maxLineLength"); - readonly blockIdentifierREgEx1 = /^(?(con|var|obj|pub|pri|dat))\s+/; - readonly blockIdentifierREgEx2 = /^(?(con|var|obj|pub|pri|dat))$/; - readonly orgIdentifierREgEx1 = /^(?\s*(org|orgf|asm))\s+/; - readonly orgIdentifierREgEx2 = /^(?\s*(org|orgf|asm))$/; - readonly endIdentifierREgEx1 = /^(?\s*(end|endasm))\s+/; - readonly endIdentifierREgEx2 = /^(?\s*(end|endasm))$/; + readonly blockIdentifierREgEx1 = /^(?^(con|var|obj|pub|pri|dat))[\s{']/i; + readonly blockIdentifierREgEx2 = /^(?^(con|var|obj|pub|pri|dat))$/i; + readonly orgIdentifierREgEx1 = /^(?\s*(org|orgf|asm))\s+/i; + readonly orgIdentifierREgEx2 = /^(?\s*(org|orgf|asm))$/i; + readonly endIdentifierREgEx1 = /^(?\s*(end|endasm))\s+/i; + readonly endIdentifierREgEx2 = /^(?\s*(end|endasm))$/i; private tabbingDebugLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit private tabbingOutputChannel: vscode.OutputChannel | undefined = undefined; @@ -77,11 +79,14 @@ export class Formatter { if (this.tabbingDebugLogEnabled) { if (this.tabbingOutputChannel === undefined) { //Create output channel - this.tabbingOutputChannel = vscode.window.createOutputChannel("Spin/Spin2 Format DEBUG"); - this.logMessage("Spin/Spin2 Format log started."); + this.tabbingOutputChannel = vscode.window.createOutputChannel('Spin/Spin2 Format DEBUG'); + this.logMessage('Spin/Spin2 Format log started.'); } else { - this.logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this.logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } + + this.rawElasticTabstopsConfiguration = vscode.workspace.getConfiguration('spinExtension.elasticTabstops'); + this.logMessage(`- (DBG) rawElasticTabstopsConfiguration=[${JSON.stringify(this.rawElasticTabstopsConfiguration)}]`); } //const jsonConfig: string = JSON.stringify(this.config, null, 4); @@ -103,7 +108,7 @@ export class Formatter { /** * write message to formatting log (when log enabled) * - * @param the message to be written + * @param message to be written * @returns nothing */ public logMessage(message: string): void { @@ -128,14 +133,15 @@ export class Formatter { this.logMessage(`+ (DBG) updateTabConfiguration() DID reload!`); this.config = tabConfiguration; - this.tabset = tabConfiguration.tabSet; + this.tabset = this.config.tabSet; - this.blocks = tabConfiguration.blocks; + this.blocks = this.config.blocks; - this.tabSize = tabConfiguration.tabSize; + this.tabSize = this.config.tabSize; - this.enable = tabConfiguration.enable; + this.enable = this.config.enable; } + this.logMessage(`+ (DBG) tabConfiguration=[${JSON.stringify(this.config)}]`); } /** @@ -146,7 +152,7 @@ export class Formatter { */ getPreviousTabStop(blockName: string, character: number): number { if (!blockName) { - blockName = "con"; + blockName = 'con'; } const block = this.blocks[blockName.toLowerCase()]; @@ -179,7 +185,7 @@ export class Formatter { */ getCurrentTabStop(blockName: string, character: number): number { if (!blockName) { - blockName = "con"; + blockName = 'con'; } const block = this.blocks[blockName.toLowerCase()]; @@ -209,7 +215,7 @@ export class Formatter { */ getNextTabStop(blockName: string, character: number): number { if (!blockName) { - blockName = "con"; + blockName = 'con'; } const block = this.blocks[blockName.toLowerCase()]; @@ -247,12 +253,13 @@ export class Formatter { // on way to finding PUB or PRI. // if we find one of the ORGs and NOT END then we return DAT so as to use // DAT tabs in the PUB section for inline PASM - let blockName: string = ""; + let blockName: string = ''; let bBelowOrg: boolean = false; let bAboveEnd: boolean = true; let matchOrg: RegExpMatchArray | null = null; let matchEnd: RegExpMatchArray | null = null; - let bottomLine: number = selection.end.line; + const bottomLine: number = selection.end.line; + let lineWithMatch: number = -1; for (let lineIndex = selection.anchor.line; lineIndex >= 0; lineIndex--) { const line = document.lineAt(lineIndex); if (line.text.length < 3) { @@ -272,7 +279,7 @@ export class Formatter { bBelowOrg = false; } } - //this.logMessage(` -- matchOrg-[${matchOrg}]`); + this.logMessage(` -- Ln#${lineIndex + 1} matchOrg-[${matchOrg}]`); } if (matchEnd == null) { @@ -283,28 +290,35 @@ export class Formatter { if (matchEnd) { bAboveEnd = false; } - //this.logMessage(` -- matchEnd-[${matchEnd}]`); + this.logMessage(` -- Ln#${lineIndex + 1} matchEnd-[${matchEnd}]`); } let match = line.text.toLowerCase().match(this.blockIdentifierREgEx1); if (!match) { match = line.text.toLowerCase().match(this.blockIdentifierREgEx2); } + this.logMessage(` -- Ln#${lineIndex + 1} matchBlock-[${match}]`); if (match) { - this.logMessage(` -- match-[${match}], bBelowOrg=[${bBelowOrg}], bAboveEnd=[${bAboveEnd}]`); - blockName = match.groups?.block ?? ""; + this.logMessage(` -- match-[${match}](${match.length}), bBelowOrg=[${bBelowOrg}], bAboveEnd=[${bAboveEnd}]`); + for (let index = 0; index < match.length; index++) { + const element = match[index]; + this.logMessage(` -- item-${index + 1} element=[${element}]`); + } + blockName = match.groups?.block ?? ''; if (blockName.length > 0) { - if (bBelowOrg && bAboveEnd && (blockName.toUpperCase() == "PUB" || blockName.toUpperCase() == "PRI")) { - blockName = "dat"; + if (bBelowOrg && bAboveEnd && (blockName.toUpperCase() == 'PUB' || blockName.toUpperCase() == 'PRI')) { + blockName = 'dat'; } } - + lineWithMatch = lineIndex; break; } } blockName = blockName.toUpperCase(); - this.logMessage(`getBlockName() s,e-[${selection.start.line}:${selection.start.character} - ${selection.end.line}:${selection.end.character}] BLOK-[${blockName}]`); + this.logMessage( + `getBlockName() s,e-[${lineWithMatch},${selection.start.character} - ${selection.end.line},${selection.end.character}] BLOK-[${blockName}]` + ); return blockName; } @@ -313,7 +327,7 @@ export class Formatter { if (offset < 0) { offset = 0; } - for (var idx: number = offset; idx < textString.length; idx++) { + for (let idx: number = offset; idx < textString.length; idx++) { if (this.isCharWhiteAt(textString, idx)) { break; } @@ -328,7 +342,7 @@ export class Formatter { offset = 0; } if (offset > 1) { - for (var idx: number = offset - 1; idx >= 0; idx--) { + for (let idx: number = offset - 1; idx >= 0; idx--) { if (!this.isCharWhiteAt(textString, idx)) { if (nbrWhiteSpaceChars > 0) { nbrWhiteSpaceChars--; @@ -343,7 +357,7 @@ export class Formatter { isCharWhiteAt(text: string, index: number): boolean { let isCharWhiteAtStatus: boolean = false; - if (text.charAt(index) == " " || text.charAt(index) == "\t") { + if (text.charAt(index) == ' ' || text.charAt(index) == '\t') { isCharWhiteAtStatus = true; } //this.logMessage(` - isCharWhiteAt() char-[${text.charAt(index)}](${index}) is white?: [${isCharWhiteAtStatus}]`); @@ -351,8 +365,8 @@ export class Formatter { } isTextAllWhite(text: string): { bNotAllWhite: boolean; nonWhiteIndex: number } { - var bNotAllWhite: boolean = false; - var nonWhiteIndex: number = 0; + let bNotAllWhite: boolean = false; + let nonWhiteIndex: number = 0; for (nonWhiteIndex = 0; nonWhiteIndex < text.length; nonWhiteIndex++) { const bThisIsWhite: boolean = this.isCharWhiteAt(text, nonWhiteIndex); if (bThisIsWhite == false) { @@ -368,7 +382,7 @@ export class Formatter { // this extra space is defined as two or more spaces. So find the location of two spaces to // right of the given position let leftMostDoubleWhitePos: vscode.Position = cursorPos.with(0, 0); - for (var idx: number = cursorPos.character; idx < currLineText.length - 1; idx++) { + for (let idx: number = cursorPos.character; idx < currLineText.length - 1; idx++) { if (this.isCharWhiteAt(currLineText, idx) == true && this.isCharWhiteAt(currLineText, idx + 1) == true) { leftMostDoubleWhitePos = cursorPos.with(cursorPos.line, idx); break; @@ -384,13 +398,15 @@ export class Formatter { // for Align Mode we are going to add or remove spaces in the extra space // area right of the cursor postion, let's count how many spaces we have there let nbrWhiteChars: number = 0; - for (var idx: number = cursorPos.character; idx < currLineText.length; idx++) { + for (let idx: number = cursorPos.character; idx < currLineText.length; idx++) { if (this.isCharWhiteAt(currLineText, idx) == false) { break; } nbrWhiteChars++; } - this.logMessage(` - (DBG) countOfWhiteChars() txt-[${currLineText}](${currLineText.length}) cursor-[${cursorPos.line}:${cursorPos.character}] => whiteLength is (${nbrWhiteChars}) spaces`); + this.logMessage( + ` - (DBG) countOfWhiteChars() txt-[${currLineText}](${currLineText.length}) cursor-[${cursorPos.line}:${cursorPos.character}] => whiteLength is (${nbrWhiteChars}) spaces` + ); return nbrWhiteChars; } @@ -404,7 +420,7 @@ export class Formatter { if (this.isCharWhiteAt(currLineText, cursorPos.character)) { // at whitespace, look right to next non-whitespace... let bFoundNonWhite = false; - for (var idx: number = cursorPos.character + 1; idx < currLineText.length; idx++) { + for (let idx: number = cursorPos.character + 1; idx < currLineText.length; idx++) { if (this.isCharWhiteAt(currLineText, idx) == false) { leftMostNonWhitePos = cursorPos.with(cursorPos.line, idx); bFoundNonWhite = true; @@ -419,7 +435,7 @@ export class Formatter { } else { // at non-whitespace, look left to next whitespace then back one... let bFoundWhite = false; - for (var idx: number = cursorPos.character - 1; idx >= 0; idx--) { + for (let idx: number = cursorPos.character - 1; idx >= 0; idx--) { if (this.isCharWhiteAt(currLineText, idx)) { leftMostNonWhitePos = cursorPos.with(cursorPos.line, idx + 1); bFoundWhite = true; @@ -438,7 +454,7 @@ export class Formatter { getNonwiteFromSelectedText(selectedText: string): string { // there is non-white text in (selectedText}, return it and everything else to the right of it - let nonWhiteRightEdge: string = ""; + let nonWhiteRightEdge: string = ''; if (!this.isCharWhiteAt(selectedText, 0)) { const startPos: vscode.Position = new vscode.Position(0, 0); const nonWhiteCharPos = this.locateLeftTextEdge(selectedText, startPos); @@ -469,7 +485,7 @@ export class Formatter { firstLine = selection.start.line; lastLine = selection.end.line; //this.logMessage(` - (DBG) ${lineCount} lines: fm,to=[${firstLine}, ${lastLine}], allSelectedText=[${allSelectedText}](${allSelectedText.length}), lines=[${lines}](${lines.length})`); - for (var currLineIdx: number = 0; currLineIdx < lines.length; currLineIdx++) { + for (let currLineIdx: number = 0; currLineIdx < lines.length; currLineIdx++) { if (lines[currLineIdx].length == 0) { if (currLineIdx == lines.length - 1) { lastLine--; @@ -492,12 +508,12 @@ export class Formatter { calculateLeftEdge(document: vscode.TextDocument, firstLine: number, lastLine: number): number { // return column-number of left-most non-white character in set of lines let leftMostNonWhiteColumn: number = 999999; - for (var currLine: number = firstLine; currLine <= lastLine; currLine++) { - let currLineText: string = document.lineAt(currLine).text; + for (let currLine: number = firstLine; currLine <= lastLine; currLine++) { + const currLineText: string = document.lineAt(currLine).text; // if empty line, don't count this when locating left edge if (currLineText.length > 0) { - let cursorPos: vscode.Position = new vscode.Position(currLine, 0); - let nonWhitePos: vscode.Position = this.locateLeftTextEdge(currLineText, cursorPos); + const cursorPos: vscode.Position = new vscode.Position(currLine, 0); + const nonWhitePos: vscode.Position = this.locateLeftTextEdge(currLineText, cursorPos); if (nonWhitePos.character < leftMostNonWhiteColumn) { leftMostNonWhiteColumn = nonWhitePos.character; } @@ -513,12 +529,12 @@ export class Formatter { calculateRightEdge(document: vscode.TextDocument, firstLine: number, lastLine: number): number { // return column-number of right-most non-white left-edge character in set of lines let rightMostNonWhiteColumn: number = 0; - for (var currLine: number = firstLine; currLine <= lastLine; currLine++) { - let currLineText: string = document.lineAt(currLine).text; + for (let currLine: number = firstLine; currLine <= lastLine; currLine++) { + const currLineText: string = document.lineAt(currLine).text; // if empty line, don't count this when locating left edge if (currLineText.length > 0) { - let cursorPos: vscode.Position = new vscode.Position(currLine, 0); - let nonWhitePos: vscode.Position = this.locateLeftTextEdge(currLineText, cursorPos); + const cursorPos: vscode.Position = new vscode.Position(currLine, 0); + const nonWhitePos: vscode.Position = this.locateLeftTextEdge(currLineText, cursorPos); if (nonWhitePos.character > rightMostNonWhiteColumn) { rightMostNonWhiteColumn = nonWhitePos.character; } @@ -536,7 +552,7 @@ export class Formatter { insertTabStopsComment(document: vscode.TextDocument, selections: readonly vscode.Selection[]): vscode.ProviderResult { return selections .map((selection) => { - let results: vscode.ProviderResult = []; + const results: vscode.ProviderResult = []; const block = this.getBlockName(document, selection); this.logMessage( `* iCm enabled=[${this.enable}], selection(isSingle-[${selection.isSingleLine}] BLOK-[${block}] isEmpty-[${selection.isEmpty}] s,e-[${selection.start.line}:${selection.start.character} - ${selection.end.line}:${selection.end.character}] activ-[${selection.active.character}] anchor-[${selection.anchor.character}])` @@ -553,15 +569,15 @@ export class Formatter { let tabNumber: number = 1; do { currTabstop = this.getNextTabStop(block, currTabstop); - let distance: number = currTabstop - priorTabstop - 1; - const horizStr: string = "-".repeat(distance); + const distance: number = currTabstop - priorTabstop - 1; + const horizStr: string = '-'.repeat(distance); priorTabstop = currTabstop; charactersToInsert = `${charactersToInsert}${horizStr}+`; //this.logMessage(` --tab#${tabNumber} curr=(${currTabstop}) dist=(${distance})`); tabNumber++; } while (charactersToInsert.length < 80); - let endOfLineStr: string = document.eol == EndOfLine.CRLF ? "\r\n" : "\n"; + const endOfLineStr: string = document.eol == EndOfLine.CRLF ? '\r\n' : '\n'; // insert a "template tab-column comment line" above the line upon which our cursor sits results.push(vscode.TextEdit.insert(cursorPos, `${charactersToInsert}${endOfLineStr}`)); @@ -597,12 +613,12 @@ export class Formatter { */ indentTabStop(document: vscode.TextDocument, editor: vscode.TextEditor): vscode.ProviderResult { const selections: readonly vscode.Selection[] = editor.selections; - let finalSelections: vscode.Selection[] = []; + //const finalSelections: vscode.Selection[] = []; this.bFinalTabSelectionValid = false; let selectionsProcessed: number = 0; const editResult: vscode.ProviderResult = selections .map((selection) => { - let results: vscode.ProviderResult = []; + const results: vscode.ProviderResult = []; const block = this.getBlockName(document, selection); this.logMessage( `* inD enabled=[${this.enable}], selection(isSingle-[${selection.isSingleLine}] BLOK-[${block}] isEmpty-[${selection.isEmpty}] s,e-[${selection.start.line}:${selection.start.character} - ${selection.end.line}:${selection.end.character}] activ-[${selection.active.character}] anchor-[${selection.anchor.character}])` @@ -623,7 +639,7 @@ export class Formatter { // if selection left char is white get tab from left edge of selection // else get tab from left edge of text - let { firstLine, lastLine, lineCount } = this.lineNumbersFromSelection(document, selection); + const { firstLine, lastLine, lineCount } = this.lineNumbersFromSelection(document, selection); const bWholeLines: boolean = firstLine != lastLine; // this will be used to find our tab column in multi-line case @@ -638,16 +654,18 @@ export class Formatter { if (bWholeLines) { initialCursorPos = cursorPos.with(cursorPos.line, 0); } - this.logMessage(` - (DBG)BLOK-[${block}], wholeLines=(${bWholeLines}), lines fm,to=[${firstLine}, ${lastLine}], cursor-[${cursorPos.line}:${cursorPos.character}]`); + this.logMessage( + ` - (DBG)BLOK-[${block}], wholeLines=(${bWholeLines}), lines fm,to=[${firstLine}, ${lastLine}], cursor-[${cursorPos.line}:${cursorPos.character}]` + ); - for (var currLine: number = firstLine; currLine <= lastLine; currLine++) { + for (let currLine: number = firstLine; currLine <= lastLine; currLine++) { // now use selection to skip whitespace to right of cursor cursorPos = cursorPos.with(currLine, initialCursorPos.character); // grab the text of the current selected line - let currLineText: string = document.lineAt(currLine).text; + const currLineText: string = document.lineAt(currLine).text; - let selectedText: string = ""; // non-empty if we have text within the selection + let selectedText: string = ''; // non-empty if we have text within the selection // if we found text to adjust... if (currLineText.length > 0 || bWholeLines) { @@ -692,7 +710,7 @@ export class Formatter { } // lastly move non-white chars from cusor to next tabstop to right - let nextTabstop: number = this.getNextTabStop(block, cursorPos.character); + const nextTabstop: number = this.getNextTabStop(block, cursorPos.character); this.logMessage( ` - line#${currLine} cursor-[${cursorPos.line}:${cursorPos.character}], leftEdge=[${textLeftEdgePos.line}:${textLeftEdgePos.character}], nextTabstop=[${nextTabstop}], selectedText-[${selectedText}], text-[${currLineText}]` ); @@ -769,7 +787,9 @@ export class Formatter { const deleteEndPos: vscode.Position = deleteStartPos.with(deleteStartPos.line, deleteStartPos.character + nbrSpacesToRemove); const deleteRange: vscode.Range = new vscode.Range(deleteStartPos, deleteEndPos); this.logMessage( - ` line#${currLine} pushed DELETE ${deleteRange.end.character - deleteRange.start.character} spaces at [${deleteStartPos.line}:${deleteStartPos.character}-${deleteEndPos.character}]` + ` line#${currLine} pushed DELETE ${deleteRange.end.character - deleteRange.start.character} spaces at [${deleteStartPos.line}:${ + deleteStartPos.character + }-${deleteEndPos.character}]` ); results.push(vscode.TextEdit.delete(deleteRange)); cursorPos = cursorPos.with(textLeftEdgePos.line, textLeftEdgePos.character - nbrSpacesToRemove); @@ -778,19 +798,21 @@ export class Formatter { // if we are in align mode, let's count this change if (getMode(editor) == eEditMode.ALIGN) { // see if we have double-white-space to manipulate... - let doubleWhitePos: vscode.Position = this.locateDoubleWhiteLeftEdge(currLineText, textLeftEdgePos); + const doubleWhitePos: vscode.Position = this.locateDoubleWhiteLeftEdge(currLineText, textLeftEdgePos); if (doubleWhitePos.line != 0 && doubleWhitePos.character != 0) { // yes we do! // insert length of spaces we removed but at this doubleWhite location - const charactersToInsert: string = " ".repeat(deleteRange.end.character - deleteRange.start.character); - this.logMessage(` line#${currLine} pushed AlignMode INSERT ${charactersToInsert.length} spaces before [${doubleWhitePos.line}:${doubleWhitePos.character}]`); + const charactersToInsert: string = ' '.repeat(deleteRange.end.character - deleteRange.start.character); + this.logMessage( + ` line#${currLine} pushed AlignMode INSERT ${charactersToInsert.length} spaces before [${doubleWhitePos.line}:${doubleWhitePos.character}]` + ); results.push(vscode.TextEdit.insert(doubleWhitePos, charactersToInsert)); } } } if (nbrSpacesToInsert > 0) { // insert spaces to left of cursor - const charactersToInsert: string = " ".repeat(nbrSpacesToInsert); + const charactersToInsert: string = ' '.repeat(nbrSpacesToInsert); results.push(vscode.TextEdit.insert(cursorPos, charactersToInsert)); this.logMessage(` line#${currLine} pushed INSERT ${charactersToInsert.length} spaces at [${cursorPos.line}:${cursorPos.character}]`); //cursorPos = cursorPos.with(currLine, cursorPos.character + nbrSpacesToInsert); @@ -798,19 +820,19 @@ export class Formatter { // if we are in align mode, let's count this change if (getMode(editor) == eEditMode.ALIGN) { // see if we have double-white-space to manipulate... - let doubleWhitePos: vscode.Position = this.locateDoubleWhiteLeftEdge(currLineText, textLeftEdgePos); + const doubleWhitePos: vscode.Position = this.locateDoubleWhiteLeftEdge(currLineText, textLeftEdgePos); if (doubleWhitePos.line != 0 && doubleWhitePos.character != 0) { // yes we do! // delete length of spaces we inserted but from this doubleWhite location - let doubleWhiteLength: number = this.countOfWhiteChars(currLineText, doubleWhitePos) - 1; + const doubleWhiteLength: number = this.countOfWhiteChars(currLineText, doubleWhitePos) - 1; const deleteLength: number = doubleWhiteLength < nbrSpacesToInsert ? doubleWhiteLength : nbrSpacesToInsert; const deleteStartPos: vscode.Position = doubleWhitePos; const deleteEndPos: vscode.Position = deleteStartPos.with(deleteStartPos.line, deleteStartPos.character + deleteLength); const deleteRange: vscode.Range = new vscode.Range(deleteStartPos, deleteEndPos); this.logMessage( - ` line#${currLine} pushed AlignMode DELETE ${deleteRange.end.character - deleteRange.start.character} spaces at [${deleteRange.start.line}:${deleteRange.start.character}-${ - deleteRange.end.character - }]` + ` line#${currLine} pushed AlignMode DELETE ${deleteRange.end.character - deleteRange.start.character} spaces at [${ + deleteRange.start.line + }:${deleteRange.start.character}-${deleteRange.end.character}]` ); results.push(vscode.TextEdit.delete(deleteRange)); } @@ -831,8 +853,10 @@ export class Formatter { // have insert point, insert spaces to left of cursor cursorPos = cursorPos.with(cursorPos.line, 0); const nextTabstop: number = this.getNextTabStop(block, cursorPos.character); - const charactersToInsert: string = " ".repeat(nextTabstop); - this.logMessage(` line#${currLine} pushed blank-line INSERT ${charactersToInsert.length} spaces before [${cursorPos.line}:${cursorPos.character}]`); + const charactersToInsert: string = ' '.repeat(nextTabstop); + this.logMessage( + ` line#${currLine} pushed blank-line INSERT ${charactersToInsert.length} spaces before [${cursorPos.line}:${cursorPos.character}]` + ); results.push(vscode.TextEdit.insert(this.leftOfCursor(cursorPos), charactersToInsert)); // NOTE: nothing to do for Align Mode in this empty-line case! } @@ -871,7 +895,7 @@ export class Formatter { let selectionsProcessed: number = 0; return selections .map((selection) => { - let results: vscode.ProviderResult = []; + const results: vscode.ProviderResult = []; const block = this.getBlockName(document, selection); this.logMessage( `* outD enabled=[${this.enable}], selection(isSingle-[${selection.isSingleLine}] BLOK-[${block}] isEmpty-[${selection.isEmpty}] s,e-[${selection.start.line}:${selection.start.character} - ${selection.end.line}:${selection.end.character}] activ-[${selection.active.character}] anchor-[${selection.anchor.character}])` @@ -889,27 +913,29 @@ export class Formatter { // SPECIAL: multiLine lineA and lineA+1 both at char pos 0 is really single line selection of lineA // CURSOR POS is always .anchor! if SPECIAL case anchor is conveniently ZERO already! // COLUMN MODE is really multiple single-line selections! - let { firstLine, lastLine, lineCount } = this.lineNumbersFromSelection(document, selection); + const { firstLine, lastLine, lineCount } = this.lineNumbersFromSelection(document, selection); const bWholeLines: boolean = firstLine != lastLine; // this will be used to find our new tab column in multi-line case this.logMessage(` - (DBG) ${lineCount} lines: fm,to=[${firstLine}, ${lastLine}], bWholeLines=(${bWholeLines})`); // set initial position to right edge of selection - let initialCursorPos: vscode.Position = selection.end; + const initialCursorPos: vscode.Position = selection.end; let cursorPos: vscode.Position = initialCursorPos; // if we have multi-line selection reset cursor to first char of all lines if (bWholeLines) { cursorPos = cursorPos.with(cursorPos.line, 0); } - this.logMessage(` - finding: BLOK-[${block}], wholeLines=(${bWholeLines}), lines fm,to=[${firstLine}, ${lastLine}], cursor-[${cursorPos.line}:${cursorPos.character}]`); + this.logMessage( + ` - finding: BLOK-[${block}], wholeLines=(${bWholeLines}), lines fm,to=[${firstLine}, ${lastLine}], cursor-[${cursorPos.line}:${cursorPos.character}]` + ); - for (var currLine: number = firstLine; currLine <= lastLine; currLine++) { + for (let currLine: number = firstLine; currLine <= lastLine; currLine++) { // now use selection to skip whitespace to right of cursor cursorPos = cursorPos.with(currLine, initialCursorPos.character); // grab the text of the current selected line - let currLineText: string = document.lineAt(currLine).text; + const currLineText: string = document.lineAt(currLine).text; // if we found text to adjust... if (currLineText.length > 0 || bWholeLines) { @@ -933,17 +959,21 @@ export class Formatter { this.logMessage(` - line#${currLine} ltEdge-[${cursorPos.line}:${cursorPos.character}], text-[${currLineText}]`); // we'd like to outdent to prev tab-stop but let's only go as far a to leave 1 space before prior text - let nextTabStopToLeft: number = this.getPreviousTabStop(block, cursorPos.character); - let whiteSpaceToLeftCt: number = this.countLeftWhiteSpace(currLineText, cursorPos.character); + const nextTabStopToLeft: number = this.getPreviousTabStop(block, cursorPos.character); + const whiteSpaceToLeftCt: number = this.countLeftWhiteSpace(currLineText, cursorPos.character); let nbrCharsToDelete: number = cursorPos.character - nextTabStopToLeft; - this.logMessage(` - line#${currLine} tabStop=(${nextTabStopToLeft}), spacesToLeft=(${whiteSpaceToLeftCt}), nbrCharsToDelete=(${nbrCharsToDelete})`); + this.logMessage( + ` - line#${currLine} tabStop=(${nextTabStopToLeft}), spacesToLeft=(${whiteSpaceToLeftCt}), nbrCharsToDelete=(${nbrCharsToDelete})` + ); if (nbrCharsToDelete > whiteSpaceToLeftCt) { nbrCharsToDelete = whiteSpaceToLeftCt; } const deleteStart: vscode.Position = cursorPos.with(cursorPos.line, cursorPos.character - nbrCharsToDelete); const deleteEnd: vscode.Position = deleteStart.with(deleteStart.line, deleteStart.character + nbrCharsToDelete); const range = selection.with({ start: deleteStart, end: deleteEnd }); - this.logMessage(` line#${currLine} pushed DELETE spaces [${range.start.line}:${range.start.character} - ${range.end.line}:${range.end.character}], tabStop: ${nextTabStopToLeft})`); + this.logMessage( + ` line#${currLine} pushed DELETE spaces [${range.start.line}:${range.start.character} - ${range.end.line}:${range.end.character}], tabStop: ${nextTabStopToLeft})` + ); results.push(vscode.TextEdit.delete(range)); // if we are in align mode, let's count this change const currMode: eEditMode = getMode(editor); @@ -961,8 +991,10 @@ export class Formatter { if (doubleWhitePos.line != 0 && doubleWhitePos.character != 0) { // yes we do! // insert length of spaces we removed but at this doubleWhite location - const charactersToInsert: string = " ".repeat(range.end.character - range.start.character); - this.logMessage(` line#${currLine} pushed AlignMode INSERT ${charactersToInsert.length} spaces before [${doubleWhitePos.line}:${doubleWhitePos.character}]`); + const charactersToInsert: string = ' '.repeat(range.end.character - range.start.character); + this.logMessage( + ` line#${currLine} pushed AlignMode INSERT ${charactersToInsert.length} spaces before [${doubleWhitePos.line}:${doubleWhitePos.character}]` + ); results.push(vscode.TextEdit.insert(doubleWhitePos, charactersToInsert)); } } @@ -989,15 +1021,15 @@ export class Formatter { */ alignBeforeType(editor: vscode.TextEditor, text: string, undoStop: boolean) { // skip overtype behavior when enter is pressed - if (text === "\r" || text === "\n" || text === "\r\n") { - vscode.commands.executeCommand("default:type", { text: text }); + if (text === '\r' || text === '\n' || text === '\r\n') { + vscode.commands.executeCommand('default:type', { text: text }); return; } if (getMode(editor) != eEditMode.ALIGN) { this.logMessage(`* alnBT ABORT, not in Align mode`); return; // bail if not in Align Mode! } - if (text.indexOf(" ") !== -1) undoStop = true; + if (text.indexOf(' ') !== -1) undoStop = true; editor .edit( @@ -1008,31 +1040,31 @@ export class Formatter { ); const cursorPosition = selection.start; const lineEndPosition = editor.document.lineAt(cursorPosition).range.end; - let typeSel = selection; + const typeSel = selection; // handle alignment if (typeSel.isSingleLine) { - let typeSize: number = editor.document.offsetAt(typeSel.end) - editor.document.offsetAt(typeSel.start); + const typeSize: number = editor.document.offsetAt(typeSel.end) - editor.document.offsetAt(typeSel.start); if (typeSize > 1) undoStop = true; if (typeSize != text.length) { - let spaceDiff: number = text.length - typeSize; + const spaceDiff: number = text.length - typeSize; let currWord: vscode.Range | undefined = editor.document.getWordRangeAtPosition(typeSel.end, this.alignWordExpr); if (!currWord) currWord = editor.document.getWordRangeAtPosition(typeSel.end.translate(0, +1), this.alignWordExpr); let spacesAfter: vscode.Range | undefined = undefined; if (currWord && !currWord.end.isEqual(lineEndPosition)) { spacesAfter = editor.document.getWordRangeAtPosition(currWord.end, / {2,}/); } else if (!typeSel.end.isEqual(lineEndPosition)) { - if (editor.document.getText(new vscode.Range(typeSel.end, typeSel.end.translate(0, +2))) === " ") { + if (editor.document.getText(new vscode.Range(typeSel.end, typeSel.end.translate(0, +2))) === ' ') { spacesAfter = editor.document.getWordRangeAtPosition(typeSel.end, / {2,}/); } } if (spacesAfter && typeSize < text.length) { // remove spaces if possible - let spaceCount: number = editor.document.offsetAt(spacesAfter.end) - editor.document.offsetAt(spacesAfter.start); + const spaceCount: number = editor.document.offsetAt(spacesAfter.end) - editor.document.offsetAt(spacesAfter.start); edit.delete(new vscode.Range(spacesAfter.end.translate(0, -Math.min(spaceDiff, spaceCount - 1)), spacesAfter.end)); } else if (spacesAfter && typeSize > text.length) { // Add spaces - edit.insert(spacesAfter.end, " ".repeat(typeSize - text.length)); + edit.insert(spacesAfter.end, ' '.repeat(typeSize - text.length)); } } } else { @@ -1075,7 +1107,7 @@ export class Formatter { // insert point in spaces // selection within single line - let { firstLine, lastLine, lineCount } = this.lineNumbersFromSelection(editor.document, selection); + const { firstLine, lastLine, lineCount } = this.lineNumbersFromSelection(editor.document, selection); const bWholeLines: boolean = firstLine != lastLine; this.logMessage(` -- firstLine=[${firstLine}], lastLine=[${lastLine}], lineCount-[${lineCount}]`); const lastLineText: string = editor.document.lineAt(lastLine).text; @@ -1142,10 +1174,12 @@ export class Formatter { if (doubleWhitePos.line != 0 && doubleWhitePos.character != 0) { this.logMessage(`* INSERT ' '(${replaceLen}) at=[${doubleWhitePos.line}:${doubleWhitePos.character}]`); - edit.insert(doubleWhitePos, " ".repeat(replaceLen)); + edit.insert(doubleWhitePos, ' '.repeat(replaceLen)); } } - this.logMessage(`* CURSOR range=[${cursorRange.start.line}:${cursorRange.start.character} - ${cursorRange.end.line}:${cursorRange.end.character}](${rngLen})`); + this.logMessage( + `* CURSOR range=[${cursorRange.start.line}:${cursorRange.start.character} - ${cursorRange.end.line}:${cursorRange.end.character}](${rngLen})` + ); return new vscode.Selection(cursorRange.start, cursorRange.start); }); }); diff --git a/spin2/client/src/spin.clientBehavior.configuration.ts b/spin2/client/src/spin.clientBehavior.configuration.ts index e17eeac..78ad5c5 100644 --- a/spin2/client/src/spin.clientBehavior.configuration.ts +++ b/spin2/client/src/spin.clientBehavior.configuration.ts @@ -1,14 +1,14 @@ -"use strict"; +'use strict'; // client/src/spin.clientBehavior.configuration.ts -import * as vscode from "vscode"; +import * as vscode from 'vscode'; const loadEditorConfiguration = () => { - const editorConfiguration = vscode.workspace.getConfiguration("spinExtension.ClientBehavior"); + const editorConfiguration = vscode.workspace.getConfiguration('spinExtension.ClientBehavior'); return { - colorBackground: editorConfiguration.get("colorEditorBackground"), - backgroundApha: editorConfiguration.get("editorBackgroundAlpha"), + colorBackground: editorConfiguration.get('colorEditorBackground'), + backgroundApha: editorConfiguration.get('editorBackgroundAlpha') }; }; @@ -18,7 +18,10 @@ export const reloadEditorConfiguration = () => { const newEditorConfiguration = loadEditorConfiguration(); // bail out if nothing changed - if (editorConfiguration.colorBackground === newEditorConfiguration.colorBackground && editorConfiguration.backgroundApha === newEditorConfiguration.backgroundApha) { + if ( + editorConfiguration.colorBackground === newEditorConfiguration.colorBackground && + editorConfiguration.backgroundApha === newEditorConfiguration.backgroundApha + ) { return false; } diff --git a/spin2/client/src/spin.code.utils.ts b/spin2/client/src/spin.code.utils.ts index 5c8e405..4b2581b 100644 --- a/spin2/client/src/spin.code.utils.ts +++ b/spin2/client/src/spin.code.utils.ts @@ -1,6 +1,6 @@ -"use strict"; +'use strict'; // client/src/spin.code.utils.ts -import * as vscode from "vscode"; +import * as vscode from 'vscode'; export enum eParseState { Unknown = 0, @@ -14,7 +14,7 @@ export enum eParseState { inDatPAsm, inMultiLineComment, inMultiLineDocComment, - inNothing, + inNothing } export class SpinCodeUtils { @@ -36,47 +36,59 @@ export class SpinCodeUtils { } public isFlexspinPreprocessorDirective(name: string): boolean { - const flexspinDirectiveOfNote: string[] = ["#define", "#ifdef", "#ifndef", "#else", "#elseifdef", "#elseifndef", "#endif", "#error", "#include", "#warn", "#undef"]; + const flexspinDirectiveOfNote: string[] = [ + '#define', + '#ifdef', + '#ifndef', + '#else', + '#elseifdef', + '#elseifndef', + '#endif', + '#error', + '#include', + '#warn', + '#undef' + ]; const reservedStatus: boolean = flexspinDirectiveOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public nameForParseState(state: eParseState): string { - let desiredInterp: string = "?unknown?"; + let desiredInterp: string = '?unknown?'; switch (state) { case eParseState.inCon: - desiredInterp = "CON"; + desiredInterp = 'CON'; break; case eParseState.inDat: - desiredInterp = "DAT"; + desiredInterp = 'DAT'; break; case eParseState.inDatPAsm: - desiredInterp = "DATpasm"; + desiredInterp = 'DATpasm'; break; case eParseState.inObj: - desiredInterp = "OBJ"; + desiredInterp = 'OBJ'; break; case eParseState.inPri: - desiredInterp = "PRI"; + desiredInterp = 'PRI'; break; case eParseState.inPub: - desiredInterp = "PUB"; + desiredInterp = 'PUB'; break; case eParseState.inMultiLineComment: - desiredInterp = "mlCmt"; + desiredInterp = 'mlCmt'; break; case eParseState.inMultiLineDocComment: - desiredInterp = "mlDocCmt"; + desiredInterp = 'mlDocCmt'; break; case eParseState.inPAsmInline: - desiredInterp = "Pasm-in-line"; + desiredInterp = 'Pasm-in-line'; break; case eParseState.inVar: - desiredInterp = "VAR"; + desiredInterp = 'VAR'; break; default: - desiredInterp = "?unk-case?"; + desiredInterp = '?unk-case?'; break; } return desiredInterp; @@ -91,20 +103,20 @@ export class SpinCodeUtils { let inProgressState: eParseState = eParseState.Unknown; if (line.length > 2) { const sectionName: string = line.substring(0, 3).toUpperCase(); - const nextChar: string = line.length > 3 ? line.substring(3, 4) : " "; - if (nextChar.charAt(0).match(/[ \t'\{]/)) { + const nextChar: string = line.length > 3 ? line.substring(3, 4) : ' '; + if (nextChar.charAt(0).match(/[ \t'{]/)) { startStatus = true; - if (sectionName === "CON") { + if (sectionName === 'CON') { inProgressState = eParseState.inCon; - } else if (sectionName === "DAT") { + } else if (sectionName === 'DAT') { inProgressState = eParseState.inDat; - } else if (sectionName === "OBJ") { + } else if (sectionName === 'OBJ') { inProgressState = eParseState.inObj; - } else if (sectionName === "PUB") { + } else if (sectionName === 'PUB') { inProgressState = eParseState.inPub; - } else if (sectionName === "PRI") { + } else if (sectionName === 'PRI') { inProgressState = eParseState.inPri; - } else if (sectionName === "VAR") { + } else if (sectionName === 'VAR') { inProgressState = eParseState.inVar; } else { startStatus = false; @@ -116,7 +128,7 @@ export class SpinCodeUtils { } return { isSectionStart: startStatus, - inProgressStatus: inProgressState, + inProgressStatus: inProgressState }; } @@ -126,7 +138,7 @@ export class SpinCodeUtils { // TODO: UNDONE make this into loop to find first ' not in string if (line.length - startingOffset > 0) { //this.logMessage('- gnclr startingOffset=[' + startingOffset + '], startingOffset=[' + line + ']'); - let currentOffset: number = this._skipWhite(line, startingOffset); + const currentOffset: number = this._skipWhite(line, startingOffset); // get line parts - we only care about first one let beginCommentOffset: number = line.indexOf("'", currentOffset); if (beginCommentOffset != -1) { @@ -138,23 +150,26 @@ export class SpinCodeUtils { } } if (beginCommentOffset === -1) { - beginCommentOffset = line.indexOf("{", currentOffset); + beginCommentOffset = line.indexOf('{', currentOffset); } const nonCommentEOL: number = beginCommentOffset != -1 ? beginCommentOffset - 1 : line.length - 1; //this.logMessage('- gnclr startingOffset=[' + startingOffset + '], currentOffset=[' + currentOffset + ']'); nonCommentRHSStr = line.substr(currentOffset, nonCommentEOL - currentOffset + 1).trim(); //this.logMessage('- gnclr nonCommentRHSStr=[' + startingOffset + ']'); - const singleLineMultiBeginOffset: number = nonCommentRHSStr.indexOf("{", currentOffset); + const singleLineMultiBeginOffset: number = nonCommentRHSStr.indexOf('{', currentOffset); if (singleLineMultiBeginOffset != -1) { - const singleLineMultiEndOffset: number = nonCommentRHSStr.indexOf("}", singleLineMultiBeginOffset); + const singleLineMultiEndOffset: number = nonCommentRHSStr.indexOf('}', singleLineMultiBeginOffset); if (singleLineMultiEndOffset != -1) { - const oneLineMultiComment: string = nonCommentRHSStr.substr(singleLineMultiBeginOffset, singleLineMultiEndOffset - singleLineMultiBeginOffset + 1); - nonCommentRHSStr = nonCommentRHSStr.replace(oneLineMultiComment, "").trim(); + const oneLineMultiComment: string = nonCommentRHSStr.substr( + singleLineMultiBeginOffset, + singleLineMultiEndOffset - singleLineMultiBeginOffset + 1 + ); + nonCommentRHSStr = nonCommentRHSStr.replace(oneLineMultiComment, '').trim(); } } } else if (line.length - startingOffset == 0) { - nonCommentRHSStr = ""; + nonCommentRHSStr = ''; } //if (line.substr(startingOffset).length != nonCommentRHSStr.length) { // this.logMessage(' -- NCLR line [' + line.substr(startingOffset) + ']'); @@ -166,7 +181,7 @@ export class SpinCodeUtils { private _skipWhite(line: string, currentOffset: number): number { let firstNonWhiteIndex: number = currentOffset; for (let index = currentOffset; index < line.length; index++) { - if (line.substr(index, 1) != " " && line.substr(index, 1) != "\t") { + if (line.substr(index, 1) != ' ' && line.substr(index, 1) != '\t') { firstNonWhiteIndex = index; break; } @@ -174,21 +189,22 @@ export class SpinCodeUtils { return firstNonWhiteIndex; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public removeDoubleQuotedStrings(line: string, showDebug: boolean = true): string { //this.logMessage('- RQS line [' + line + ']'); let trimmedLine: string = line; //this.logMessage('- RQS line [' + line + ']'); const doubleQuote: string = '"'; let quoteStartOffset: number = 0; // value doesn't matter - let didRemove: boolean = false; + //let didRemove: boolean = false; while ((quoteStartOffset = trimmedLine.indexOf(doubleQuote)) != -1) { const quoteEndOffset: number = trimmedLine.indexOf(doubleQuote, quoteStartOffset + 1); //this.logMessage(' -- quoteStartOffset=[' + quoteStartOffset + '] quoteEndOffset=[' + quoteEndOffset + ']'); if (quoteEndOffset != -1) { const badElement = trimmedLine.substr(quoteStartOffset, quoteEndOffset - quoteStartOffset + 1); //this.logMessage(' -- badElement=[' + badElement + ']'); - trimmedLine = trimmedLine.replace(badElement, "#".repeat(badElement.length)); - didRemove = showDebug ? true : false; + trimmedLine = trimmedLine.replace(badElement, '#'.repeat(badElement.length)); + //didRemove = showDebug ? true : false; //this.logMessage('- post[' + trimmedLine + ']'); } else { break; // we don't handle a single double-quote @@ -208,20 +224,20 @@ export class SpinCodeUtils { // public containsSpinLanguageSpec(line: string): boolean { // return T/F where T means {Spin2_v##} was found in given string - const languageVersionRegEx = /\{Spin2\_v/i; // our version specification (just look for left edge) + const languageVersionRegEx = /\{Spin2_v/i; // our version specification (just look for left edge) return languageVersionRegEx.test(line); } public versionFromSpinLanguageSpec(line: string): number { // return T/F where T means {Spin2_v##} was found in given string let decodedVersion: number = 0; // return no version by default - const languageVersionRegEx = /\{Spin2\_v[0-9][0-9]\}/i; // our version specification - well formatted 0-99 - const languageVersionThousandsRegEx = /\{Spin2\_v[0-9][0-9][0-9]\}/i; // our version specification - well formatted 0-999 + const languageVersionRegEx = /\{Spin2_v[0-9][0-9]\}/i; // our version specification - well formatted 0-99 + const languageVersionThousandsRegEx = /\{Spin2_v[0-9][0-9][0-9]\}/i; // our version specification - well formatted 0-999 const is3digit: boolean = languageVersionThousandsRegEx.test(line); // if have fully formatted version if (languageVersionRegEx.test(line) || is3digit) { if (this.containsSpinLanguageSpec(line)) { - const matchText: string = "{Spin2_v".toLowerCase(); + const matchText: string = '{Spin2_v'.toLowerCase(); const verOffset: number = line.toLowerCase().indexOf(matchText); if (verOffset != -1) { if (is3digit) { diff --git a/spin2/client/src/spin.object.dependencies.ts b/spin2/client/src/spin.object.dependencies.ts index 520784e..b813d35 100644 --- a/spin2/client/src/spin.object.dependencies.ts +++ b/spin2/client/src/spin.object.dependencies.ts @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; // https://code.visualstudio.com/api/ux-guidelines/views // https://code.visualstudio.com/api/extension-guides/tree-view#treeview @@ -6,18 +6,19 @@ // icons // https://code.visualstudio.com/api/references/icons-in-labels -import * as vscode from "vscode"; -import * as path from "path"; -import * as fs from "fs"; +import * as vscode from 'vscode'; +import * as path from 'path'; +import * as fs from 'fs'; //import * as ic from "iconv"; -import { SpinCodeUtils, eParseState } from "./spin.code.utils"; -import { isSpinFile } from "./spin.vscode.utils"; +import { SpinCodeUtils, eParseState } from './spin.code.utils'; +import { isSpinFile } from './spin.vscode.utils'; export class ObjectTreeProvider implements vscode.TreeDataProvider { - private rootPath: string | undefined = vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined; + private rootPath: string | undefined = + vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined; private bFixHierToTopLevel: boolean = false; - private topLevelFSpec: string = ""; - private topLevelFName: string = ""; + private topLevelFSpec: string = ''; + private topLevelFName: string = ''; private objTreeDebugLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit private objTreeOutputChannel: vscode.OutputChannel | undefined = undefined; @@ -26,31 +27,33 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { private spinCodeUtils: SpinCodeUtils = new SpinCodeUtils(); // https://code.visualstudio.com/api/extension-guides/tree-view#view-container - private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); + private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter< + Dependency | undefined | null | void + >(); readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; constructor() { if (this.objTreeDebugLogEnabled) { if (this.objTreeOutputChannel === undefined) { //Create output channel - this.objTreeOutputChannel = vscode.window.createOutputChannel("Spin/Spin2 ObjTree DEBUG"); - this.logMessage("Spin/Spin2 ObjTree log started."); + this.objTreeOutputChannel = vscode.window.createOutputChannel('Spin/Spin2 ObjTree DEBUG'); + this.logMessage('Spin/Spin2 ObjTree log started.'); } else { - this.logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this.logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } // add subscriptions vscode.window.onDidChangeActiveTextEditor(() => this.onActiveEditorChanged()); //vscode.workspace.onDidChangeTextDocument(e => this.onDocumentChanged(e)); if (!this.rootPath) { - this.logMessage("+ (DBG) ObjDep: no root path!"); + this.logMessage('+ (DBG) ObjDep: no root path!'); } else { let topFileBaseName: string | undefined = undefined; const fullConfiguration = vscode.workspace.getConfiguration(); //this.logMessage(`+ (DBG) fullConfiguration=${JSON.stringify(fullConfiguration)}`); this.logMessage(`+ (DBG) fullConfiguration=${fullConfiguration}`); - if (fullConfiguration.has("topLevel")) { - topFileBaseName = vscode.workspace.getConfiguration().get("topLevel"); // this worked! + if (fullConfiguration.has('topLevel')) { + topFileBaseName = vscode.workspace.getConfiguration().get('topLevel'); // this worked! } else { this.logMessage(`+ (DBG) topLevel key NOT present!`); } @@ -104,13 +107,13 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { getChildren(element?: Dependency): Thenable { if (!this.rootPath) { - vscode.window.showInformationMessage("No dependency in empty workspace"); - let noDep = new Dependency("No object references in empty workspace", "", vscode.TreeItemCollapsibleState.None); + vscode.window.showInformationMessage('No dependency in empty workspace'); + const noDep = new Dependency('No object references in empty workspace', '', vscode.TreeItemCollapsibleState.None); noDep.removeIcon(); // this is message, don't show icon return Promise.resolve([noDep]); } - let subDeps: Dependency[] = []; + const subDeps: Dependency[] = []; if (element) { this.logMessage(`+ (DBG) ObjDep: getChildren() element=[${element?.label}]`); // get for underlying file @@ -118,7 +121,7 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { const fileSpec = path.join(this.rootPath, fileBasename); if (!this._fileExists(fileSpec)) { this.logMessage(`+ (DBG) ObjDep: getChildren() element=[${fileBasename}] has (???) deps - MISSING FILE`); - let topState: vscode.TreeItemCollapsibleState = this._stateForDependCount(0); + const topState: vscode.TreeItemCollapsibleState = this._stateForDependCount(0); const subDep = new Dependency(element.label, element.descriptionString, topState); subDep.setFileMissing(); subDeps.push(subDep); @@ -130,11 +133,11 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { // huh, is this if really needed? if (this._fileExists(depFileSpec)) { const subSpinDeps = this._getDepsFromSpinFile(depFileSpec); - let topState: vscode.TreeItemCollapsibleState = this._stateForDependCount(subSpinDeps.length); + const topState: vscode.TreeItemCollapsibleState = this._stateForDependCount(subSpinDeps.length); const subDep = new Dependency(depency.baseName, depency.knownAs, topState); subDeps.push(subDep); } else { - let topState: vscode.TreeItemCollapsibleState = this._stateForDependCount(0); + const topState: vscode.TreeItemCollapsibleState = this._stateForDependCount(0); const subDep = new Dependency(depency.baseName, depency.knownAs, topState); subDep.setFileMissing(); subDeps.push(subDep); @@ -146,7 +149,7 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { // get for project top level file let spinDeps = []; if (this.isDocument) { - let textEditor = vscode.window.activeTextEditor; + const textEditor = vscode.window.activeTextEditor; if (textEditor) { spinDeps = this._getDepsFromDocument(textEditor.document); } @@ -159,12 +162,12 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { topState = vscode.TreeItemCollapsibleState.Expanded; // always leave top-level expanded? } if (spinDeps.length > 0) { - let topDep = new Dependency(this.topLevelFName, "(top-file)", topState); + const topDep = new Dependency(this.topLevelFName, '(top-file)', topState); subDeps.push(topDep); } else { //vscode.window.showInformationMessage("Workspace has no package.json"); - let emptyMessage: string = "No object references found in `" + `${this.topLevelFName}` + "`"; - let emptyDep = new Dependency(emptyMessage, "", vscode.TreeItemCollapsibleState.None); + const emptyMessage: string = 'No object references found in `' + `${this.topLevelFName}` + '`'; + const emptyDep = new Dependency(emptyMessage, '', vscode.TreeItemCollapsibleState.None); emptyDep.removeIcon(); // this is message, don't show icon subDeps.push(emptyDep); } @@ -185,13 +188,13 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { //} refresh(): void { - this.logMessage("+ (DBG) ObjDep: refresh()"); + this.logMessage('+ (DBG) ObjDep: refresh()'); this._onDidChangeTreeData.fire(); } private async _showDocument(fileFSpec: string) { this.logMessage(`+ (DBG) ObjDep: _showDocument() [${fileFSpec}]`); - let textDocument = await vscode.workspace.openTextDocument(fileFSpec); + const textDocument = await vscode.workspace.openTextDocument(fileFSpec); await vscode.window.showTextDocument(textDocument, { preview: false }); } @@ -199,9 +202,9 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { const bHasFileType: boolean = isSpinFile(filename) ? true : false; // matches .spin and .spin2! (not .spin3, etc.) let desiredName: string = filename; if (!bHasFileType) { - desiredName = filename + ".spin"; + desiredName = filename + '.spin'; if (!this._fileExists(desiredName)) { - desiredName = filename + ".spin2"; + desiredName = filename + '.spin2'; } } return desiredName; @@ -213,7 +216,7 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { if (!this.bFixHierToTopLevel) { const fileFSpec: string = this._getActiveSpinFile(); const enabled: boolean = isSpinFile(fileFSpec) ? true : false; // matches .spin and .spin2 - vscode.commands.executeCommand("setContext", "spinExtension.objectDeps.enabled", enabled); + vscode.commands.executeCommand('setContext', 'spinExtension.objectDeps.enabled', enabled); if (enabled) { // set new file top this.topLevelFSpec = fileFSpec; @@ -224,22 +227,22 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { } } else { // we have topLevel for this workspace, stay enabled - vscode.commands.executeCommand("setContext", "spinExtension.objectDeps.enabled", true); + vscode.commands.executeCommand('setContext', 'spinExtension.objectDeps.enabled', true); } } else { - vscode.commands.executeCommand("setContext", "spinExtension.objectDeps.enabled", false); + vscode.commands.executeCommand('setContext', 'spinExtension.objectDeps.enabled', false); } } private _getActiveSpinFile(): string { const textEditor = vscode.window.activeTextEditor; - let foundFSpec: string = ""; + let foundFSpec: string = ''; if (textEditor) { - if (textEditor.document.uri.scheme === "file") { + if (textEditor.document.uri.scheme === 'file') { this.isDocument = true; // we're loading initial deps from current tab, not file! - var currentlyOpenTabFSpec = textEditor.document.uri.fsPath; + const currentlyOpenTabFSpec = textEditor.document.uri.fsPath; //var currentlyOpenTabfolderName = path.dirname(currentlyOpenTabFSpec); - var currentlyOpenTabfileName = path.basename(currentlyOpenTabFSpec); + const currentlyOpenTabfileName = path.basename(currentlyOpenTabFSpec); //this.logMessage(`+ (DBG) ObjDep: fsPath-(${currentlyOpenTabFSpec})`); //this.logMessage(`+ (DBG) ObjDep: folder-(${currentlyOpenTabfolderName})`); this.logMessage(`+ (DBG) ObjDep: filename-(${currentlyOpenTabfileName})`); @@ -270,17 +273,17 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { this.logMessage(`+ (DBG) ObjDep: _getDepsFromDocument()`); let currState: eParseState = eParseState.inCon; // compiler defaults to CON at start! let priorState: eParseState = currState; - let deps = []; + const deps = []; for (let i = 0; i < activeEditDocument.lineCount; i++) { - let line = activeEditDocument.lineAt(i); - const trimmedLine: string = line.text.replace(/\s+$/, ""); + const line = activeEditDocument.lineAt(i); + const trimmedLine: string = line.text.replace(/\s+$/, ''); if (trimmedLine.length == 0) { continue; // skip blank lines } // skip all {{ --- }} multi-line doc comments if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = line.text.indexOf("}}"); + const closingOffset = line.text.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -288,28 +291,28 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { continue; } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit - let closingOffset = trimmedLine.indexOf("}"); + const closingOffset = trimmedLine.indexOf('}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; } // DO NOTHING continue; - } else if (trimmedLine.startsWith("{{")) { + } else if (trimmedLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = line.text.indexOf("{{"); - const closingOffset = line.text.indexOf("}}", openingOffset + 2); + const openingOffset = line.text.indexOf('{{'); + const closingOffset = line.text.indexOf('}}', openingOffset + 2); if (closingOffset == -1) { // is open of multiline comment priorState = currState; currState = eParseState.inMultiLineDocComment; } continue; - } else if (trimmedLine.startsWith("{")) { + } else if (trimmedLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedLine.indexOf("{"); - const closingOffset = trimmedLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedLine.indexOf('{'); + const closingOffset = trimmedLine.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment wihtout close priorState = currState; @@ -330,7 +333,7 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { currState = sectionStatus.inProgressStatus; } //this.logMessage(`+ (DBG) ObjDep: _getDepsFromSpinFile() eval trimmedLine=[${trimmedLine}]`); - if (currState == eParseState.inObj && nonCommentLineRemainder.includes(":")) { + if (currState == eParseState.inObj && nonCommentLineRemainder.includes(':')) { const spinObj = this._spinDepFromObjectLine(nonCommentLineRemainder); if (spinObj) { this.logMessage(`+ (DBG) ObjDep: _getDepsFromSpinFile() basename=[${spinObj.baseName}] known as (${spinObj.knownAs})`); @@ -354,29 +357,29 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { } private _getDepsFromSpinFile(fileSpec: string): SpinObject[] { - let deps = []; + const deps = []; this.logMessage(`+ (DBG) ObjDep: _getDepsFromSpinFile(${fileSpec})`); if (this._fileExists(fileSpec)) { const spinFileContent = this._loadFileAsString(fileSpec); // handles utf8/utf-16 - let lines = spinFileContent.split("\r\n"); + let lines = spinFileContent.split('\r\n'); if (lines.length == 1) { // file not CRLF is LF only! - lines = spinFileContent.split("\n"); + lines = spinFileContent.split('\n'); } this.logMessage(`+ (DBG) ObjDep: file has (${lines.length}) lines`); let currState: eParseState = eParseState.inCon; // compiler defaults to CON at start! let priorState: eParseState = currState; for (let i = 0; i < lines.length; i++) { - let text = lines[i]; - const trimmedLine = text.replace(/\s+$/, ""); + const text = lines[i]; + const trimmedLine = text.replace(/\s+$/, ''); if (trimmedLine.length == 0) { continue; // skip blank lines } // skip all {{ --- }} multi-line doc comments if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = text.indexOf("}}"); + const closingOffset = text.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -384,27 +387,27 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { continue; } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit - let closingOffset = trimmedLine.indexOf("}"); + const closingOffset = trimmedLine.indexOf('}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; } continue; - } else if (trimmedLine.startsWith("{{")) { + } else if (trimmedLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = text.indexOf("{{"); - const closingOffset = text.indexOf("}}", openingOffset + 2); + const openingOffset = text.indexOf('{{'); + const closingOffset = text.indexOf('}}', openingOffset + 2); if (closingOffset == -1) { // is open of multiline comment priorState = currState; currState = eParseState.inMultiLineDocComment; } continue; - } else if (trimmedLine.startsWith("{")) { + } else if (trimmedLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedLine.indexOf("{"); - const closingOffset = trimmedLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedLine.indexOf('{'); + const closingOffset = trimmedLine.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment priorState = currState; @@ -425,7 +428,7 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { currState = sectionStatus.inProgressStatus; } //this.logMessage(`+ (DBG) ObjDep: _getDepsFromSpinFile() eval trimmedLine=[${trimmedLine}]`); - if (currState == eParseState.inObj && nonCommentLineRemainder.includes(":")) { + if (currState == eParseState.inObj && nonCommentLineRemainder.includes(':')) { const spinObj = this._spinDepFromObjectLine(nonCommentLineRemainder); if (spinObj) { this.logMessage(`+ (DBG) ObjDep: _getDepsFromSpinFile() basename=[${spinObj.baseName}] known as (${spinObj.knownAs})`); @@ -444,22 +447,22 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { private _spinDepFromObjectLine(objLine: string): SpinObject | undefined { let desiredSpinObj = undefined; - const conOverrideLocn: number = objLine.indexOf("|"); + const conOverrideLocn: number = objLine.indexOf('|'); const usefullObjLine: string = conOverrideLocn != -1 ? objLine.substring(0, conOverrideLocn) : objLine; - const lineParts = usefullObjLine.split(/[ \t\"]/).filter(Boolean); + const lineParts = usefullObjLine.split(/[ \t"]/).filter(Boolean); this.logMessage(`+ (DBG) ObjDep: _spinDepFromObjectLine() lineParts=[${lineParts}](${lineParts.length}) line=[${objLine}]`); - let objName: string = ""; - let filename: string = ""; + let objName: string = ''; + let filename: string = ''; if (lineParts.length >= 2) { // the first colon tells us where things are so locate it... for (let index = 0; index < lineParts.length; index++) { const part = lineParts[index]; - if (part == ":") { + if (part == ':') { objName = lineParts[index - 1]; filename = lineParts[index + 1]; break; - } else if (part.endsWith(":")) { - objName = part.replace(":", ""); + } else if (part.endsWith(':')) { + objName = part.replace(':', ''); filename = lineParts[index + 1]; break; } @@ -471,13 +474,13 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { } private _loadFileAsString(fspec: string): string { - let fileContent: string = ""; + let fileContent: string = ''; if (fs.existsSync(fspec)) { this.logMessage(`* loadFileAsString() attempt load of [${fspec}]`); try { - fileContent = fs.readFileSync(fspec, "utf-8"); - if (fileContent.includes("\x00")) { - fileContent = fs.readFileSync(fspec, "utf16le"); + fileContent = fs.readFileSync(fspec, 'utf-8'); + if (fileContent.includes('\x00')) { + fileContent = fs.readFileSync(fspec, 'utf16le'); } } catch (err) { this.logMessage(`* loadFileAsString() EXCEPTION: err=[${err}]`); @@ -500,10 +503,13 @@ export class ObjectTreeProvider implements vscode.TreeDataProvider { // class ProviderResult: Dependency | undefined | null | Thenable class SpinObject { - public readonly baseName: string = ""; - public readonly knownAs: string = ""; + public readonly baseName: string = ''; + public readonly knownAs: string = ''; - constructor(public readonly fileBaseName: string, public objName: string) { + constructor( + public readonly fileBaseName: string, + public objName: string + ) { this.baseName = fileBaseName; this.knownAs = objName; } @@ -514,21 +520,25 @@ export class Dependency extends vscode.TreeItem { //private icon: vscode.ThemeIcon = new vscode.ThemeIcon("symbol-field"); // hrmf... blue //private icon: vscode.ThemeIcon = new vscode.ThemeIcon("symbol-enum"); // nice, orange! //private icon: vscode.ThemeIcon = new vscode.ThemeIcon("symbol-structure"); // hrmf, no color (white) - private icon: vscode.ThemeIcon = new vscode.ThemeIcon("symbol-class"); // nice, orange! - private basename: string = ""; - public readonly descriptionString: string = ""; + private icon: vscode.ThemeIcon = new vscode.ThemeIcon('symbol-class'); // nice, orange! + private basename: string = ''; + public readonly descriptionString: string = ''; private fileMissing: boolean = false; // map our fields to underlying TreeItem - constructor(public readonly label: string, private objName: string, public readonly collapsibleState: vscode.TreeItemCollapsibleState) { + constructor( + public readonly label: string, + private objName: string, + public readonly collapsibleState: vscode.TreeItemCollapsibleState + ) { // element label is filebasename // element description is object name in containing file // element tooltip is filename (object name) super(label, collapsibleState); this.description = this.objName; this.descriptionString = this.objName; - this.basename = label.replace(".spin2", ""); - this.basename = this.basename.replace(".spin", ""); - if (objName.includes("top-file")) { + this.basename = label.replace('.spin2', ''); + this.basename = this.basename.replace('.spin', ''); + if (objName.includes('top-file')) { this.tooltip = `This is the project top-most file`; } else { this.tooltip = `An instance of ${this.basename} known as ${this.objName}`; @@ -537,8 +547,13 @@ export class Dependency extends vscode.TreeItem { //this.resourceUri = new vscode.ThemeIcon('file-code'). //this.icon = new vscode.ThemeIcon("file-code"); // nope!! this.iconPath = this.icon; - this.contextValue = "dependency"; - this.command = { command: "spinExtension.objectDependencies.activateFile", title: "open file", tooltip: "click to open file", arguments: [this] }; + this.contextValue = 'dependency'; + this.command = { + command: 'spinExtension.objectDependencies.activateFile', + title: 'open file', + tooltip: 'click to open file', + arguments: [this] + }; } isFileMissing(): boolean { diff --git a/spin2/client/src/spin.vscode.utils.ts b/spin2/client/src/spin.vscode.utils.ts index 96d6f59..4ec8504 100644 --- a/spin2/client/src/spin.vscode.utils.ts +++ b/spin2/client/src/spin.vscode.utils.ts @@ -1,19 +1,19 @@ -"use strict"; +/* eslint-disable @typescript-eslint/no-unused-vars */ +'use strict'; // src/spin.vscode.utils.ts -import * as vscode from "vscode"; +import * as vscode from 'vscode'; export function activeFilespec(activeEditor?: vscode.TextEditor) { - let desiredFilespec: string; if (activeEditor == null || activeEditor === undefined) { activeEditor = vscode.window.activeTextEditor; } - desiredFilespec = activeEditor!.document.fileName; + const desiredFilespec: string = activeEditor!.document.fileName; return desiredFilespec; } export function activeSpinEditors(): vscode.TextEditor[] { - let desiredEditors: vscode.TextEditor[] = []; + const desiredEditors: vscode.TextEditor[] = []; const editors = vscode.window.visibleTextEditors!; if (editors.length > 0) { for (let index = 0; index < editors.length; index++) { @@ -42,7 +42,7 @@ export function editorForFilespec(filespec: string): vscode.TextEditor { } export function isCurrentDocumentSpin1(): boolean { - const editor = vscode?.window.activeTextEditor!; + const editor = vscode?.window.activeTextEditor; const document = editor ? editor.document : undefined; let spin1DocStatus: boolean = false; if (document) { @@ -76,30 +76,30 @@ export function isSpin1Document(document: vscode.TextDocument): boolean { } export function isSpinOrPasmFile(fileSpec: string): boolean { - let spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec) || isPasmFile(fileSpec); + const spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec) || isPasmFile(fileSpec); return spinDocumentStatus; } function isPasmFile(fileSpec: string): boolean { - let spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith(".p2asm"); + const spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith('.p2asm'); return spinDocumentStatus; } export function isSpinFile(fileSpec: string): boolean { - let spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec); + const spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec); return spinDocumentStatus; } export function isSpin1File(fileSpec: string): boolean { - let spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith(".spin"); + const spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith('.spin'); return spinDocumentStatus; } export function isSpin2File(fileSpec: string): boolean { - let spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith(".spin2"); + const spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith('.spin2'); return spinDocumentStatus; } function isSpin2ORPasm(fileSpec: string): boolean { - let spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith(".spin2") || fileSpec.toLowerCase().endsWith(".p2asm"); + const spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith('.spin2') || fileSpec.toLowerCase().endsWith('.p2asm'); return spinDocumentStatus; } diff --git a/spin2/client/src/test/completion.test.ts b/spin2/client/src/test/completion.test.ts index 9e24e03..4b59758 100644 --- a/spin2/client/src/test/completion.test.ts +++ b/spin2/client/src/test/completion.test.ts @@ -3,28 +3,36 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import * as vscode from "vscode"; -import * as assert from "assert"; -import { getDocUri, activate } from "./helper"; +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { getDocUri, activate } from './helper'; -suite("Should do completion", () => { - const docUri = getDocUri("completion.spin2"); +suite('Should do completion', () => { + const docUri = getDocUri('completion.spin2'); - test("Completes JS/TS in txt file", async () => { + test('Completes JS/TS in txt file', async () => { await testCompletion(docUri, new vscode.Position(0, 0), { items: [ - { label: "JavaScript", kind: vscode.CompletionItemKind.Text }, - { label: "TypeScript", kind: vscode.CompletionItemKind.Text }, - ], + { label: 'JavaScript', kind: vscode.CompletionItemKind.Text }, + { label: 'TypeScript', kind: vscode.CompletionItemKind.Text } + ] }); }); }); -async function testCompletion(docUri: vscode.Uri, position: vscode.Position, expectedCompletionList: vscode.CompletionList) { +async function testCompletion( + docUri: vscode.Uri, + position: vscode.Position, + expectedCompletionList: vscode.CompletionList +) { await activate(docUri); // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion - const actualCompletionList = (await vscode.commands.executeCommand("vscode.executeCompletionItemProvider", docUri, position)) as vscode.CompletionList; + const actualCompletionList = (await vscode.commands.executeCommand( + 'vscode.executeCompletionItemProvider', + docUri, + position + )) as vscode.CompletionList; assert.ok(actualCompletionList.items.length >= 2); expectedCompletionList.items.forEach((expectedItem, i) => { diff --git a/spin2/client/src/test/diagnostics.test.ts b/spin2/client/src/test/diagnostics.test.ts index 1fe2552..db259eb 100644 --- a/spin2/client/src/test/diagnostics.test.ts +++ b/spin2/client/src/test/diagnostics.test.ts @@ -3,18 +3,33 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import * as vscode from "vscode"; -import * as assert from "assert"; -import { getDocUri, activate } from "./helper"; +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { getDocUri, activate } from './helper'; -suite("Should get diagnostics", () => { - const docUri = getDocUri("diagnostics.spin2"); +suite('Should get diagnostics', () => { + const docUri = getDocUri('diagnostics.spin2'); - test("Diagnoses uppercase texts", async () => { + test('Diagnoses uppercase texts', async () => { await testDiagnostics(docUri, [ - { message: "ANY is all uppercase.", range: toRange(0, 0, 0, 3), severity: vscode.DiagnosticSeverity.Warning, source: "ex" }, - { message: "ANY is all uppercase.", range: toRange(0, 14, 0, 17), severity: vscode.DiagnosticSeverity.Warning, source: "ex" }, - { message: "OS is all uppercase.", range: toRange(0, 18, 0, 20), severity: vscode.DiagnosticSeverity.Warning, source: "ex" }, + { + message: 'ANY is all uppercase.', + range: toRange(0, 0, 0, 3), + severity: vscode.DiagnosticSeverity.Warning, + source: 'ex' + }, + { + message: 'ANY is all uppercase.', + range: toRange(0, 14, 0, 17), + severity: vscode.DiagnosticSeverity.Warning, + source: 'ex' + }, + { + message: 'OS is all uppercase.', + range: toRange(0, 18, 0, 20), + severity: vscode.DiagnosticSeverity.Warning, + source: 'ex' + } ]); }); }); diff --git a/spin2/client/src/test/docs-pub-pri-blocks.test.ts b/spin2/client/src/test/docs-pub-pri-blocks.test.ts index 779d0b4..4d36eab 100644 --- a/spin2/client/src/test/docs-pub-pri-blocks.test.ts +++ b/spin2/client/src/test/docs-pub-pri-blocks.test.ts @@ -3,16 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import * as vscode from "vscode"; -import * as assert from "assert"; -import { getDocUri, activate, showObject } from "./helper"; -import { SemanticTokens } from "vscode-languageclient/node"; -import { types } from "util"; +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { getDocUri, activate, showObject } from './helper'; +import { SemanticTokens } from 'vscode-languageclient/node'; +import { types } from 'util'; -suite("Should do Spin2 PUB/PRI Highlight display", () => { - const docSpin2Uri = getDocUri("docs-pub-pri-blocks.spin2"); +suite('Should do Spin2 PUB/PRI Highlight display', () => { + const docSpin2Uri = getDocUri('docs-pub-pri-blocks.spin2'); type numberMap = { [key: string]: number }; - test("Get PUB/PRI SemanticTokens from spin2 file", async () => { + test('Get PUB/PRI SemanticTokens from spin2 file', async () => { await testSemanticTokens(docSpin2Uri, { data: [] }); }); }); @@ -21,14 +21,17 @@ async function testSemanticTokens(docUri: vscode.Uri, expectedSemanticTokenList: await activate(docUri); // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion - const actualSemanticTokenList = (await vscode.commands.executeCommand("vscode.provideDocumentSemanticTokens", docUri)) as SemanticTokens; + const actualSemanticTokenList = (await vscode.commands.executeCommand( + 'vscode.provideDocumentSemanticTokens', + docUri + )) as SemanticTokens; //console.log(`spin2-actualSemanticTokenList is ${JSON.stringify(actualSemanticTokenList)})`); //console.log(`spin2-actualSemanticTokenList is ${JSON.stringify(actualSemanticTokenList)})`); console.log(`* EXPECT expectedSemanticTokenList is [${showObject(expectedSemanticTokenList)}]`); console.log(`* ACTUAL actualSemanticTokenList is [${showObject(actualSemanticTokenList)}]`); - const expectedValueSet = expectedSemanticTokenList["data"]; - const actualValueSet = actualSemanticTokenList["data"]; + const expectedValueSet = expectedSemanticTokenList['data']; + const actualValueSet = actualSemanticTokenList['data']; //assert.ok(expectedValueSet.length == actualValueSet.length); expectedValueSet.forEach((expectedItem, i) => { const actualItem = actualValueSet[i]; diff --git a/spin2/client/src/test/helper.ts b/spin2/client/src/test/helper.ts index 3738dbe..556cda7 100644 --- a/spin2/client/src/test/helper.ts +++ b/spin2/client/src/test/helper.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import * as vscode from "vscode"; -import * as path from "path"; +import * as vscode from 'vscode'; +import * as path from 'path'; export let doc: vscode.TextDocument; export let editor: vscode.TextEditor; @@ -16,7 +16,7 @@ export let platformEol: string; */ export async function activate(docUri: vscode.Uri) { // The extensionId is `publisher.name` from package.json - const ext = vscode.extensions.getExtension("IronSheepProductionsLLC.spin2")!; + const ext = vscode.extensions.getExtension('IronSheepProductionsLLC.spin2')!; await ext.activate(); try { doc = await vscode.workspace.openTextDocument(docUri); @@ -32,7 +32,7 @@ async function sleep(ms: number) { } export const getDocPath = (p: string) => { - return path.resolve(__dirname, "../../testFixture", p); + return path.resolve(__dirname, '../../testFixture', p); }; export const getDocUri = (p: string) => { return vscode.Uri.file(getDocPath(p)); @@ -65,7 +65,7 @@ export function isHash(possHash: any): boolean { export function showObject(responseObject: any, level: number = 0, idString: string = undefined): string { const answerStrings: string[] = []; - const padding: string = " ".repeat(level * 2); + const padding: string = ' '.repeat(level * 2); const bIsTopeLevel: boolean = idString == undefined; const typeString: string = objectTypeString(responseObject); if (bIsTopeLevel) { @@ -86,46 +86,46 @@ export function showObject(responseObject: any, level: number = 0, idString: str if (bIsTopeLevel) { answerStrings.push(``); } - return answerStrings.join("\n"); + return answerStrings.join('\n'); } function objectTypeString(possObject: any): string { - let typeString: string = isArray(possObject) ? "array[]" : "object??"; + let typeString: string = isArray(possObject) ? 'array[]' : 'object??'; if (isMap(possObject)) { - typeString = "map"; + typeString = 'map'; } else if (isHash(possObject)) { - typeString = "hash{}"; + typeString = 'hash{}'; } else if (isNumber(possObject)) { - typeString = "Number"; + typeString = 'Number'; } else if (isString(possObject)) { - typeString = "String"; + typeString = 'String'; } return typeString; } function describeArray(array: [], level: number): string { const answerStrings: string[] = []; - const padding = " ".repeat(level * 2); + const padding = ' '.repeat(level * 2); answerStrings.push(`${padding} - array of ${array.length} elements`); for (let index = 0; index < array.length; index++) { const element = array[index]; answerStrings.push(showObject(element, level + 1, index.toString())); } - return answerStrings.join("\n"); + return answerStrings.join('\n'); } function describeMap(mapObject: Map, level: number): string { const answerStrings: string[] = []; - const padding = " ".repeat(level * 2); + const padding = ' '.repeat(level * 2); answerStrings.push(`${padding} - Map of ${mapObject.size} objects`); - return answerStrings.join("\n"); + return answerStrings.join('\n'); } function describeHash(hashObject: {}, level: number): string { const answerStrings: string[] = []; - const padding = " ".repeat(level * 2); + const padding = ' '.repeat(level * 2); let keyCount = 0; - for (let key in hashObject) { + for (const key in hashObject) { keyCount++; - let value = hashObject[key]; + const value = hashObject[key]; const typeString: string = objectTypeString(value); if (isArray(value)) { answerStrings.push(`${padding} -- key [${key}] of [${typeString}] w/${value.length} Entries`); @@ -137,5 +137,5 @@ function describeHash(hashObject: {}, level: number): string { } // Use `key` and `value` } - return answerStrings.join("\n"); + return answerStrings.join('\n'); } diff --git a/spin2/client/src/test/index.ts b/spin2/client/src/test/index.ts index 196b62f..3ac1cbf 100644 --- a/spin2/client/src/test/index.ts +++ b/spin2/client/src/test/index.ts @@ -2,22 +2,22 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import * as path from "path"; -import * as Mocha from "mocha"; -import * as glob from "glob"; +import * as path from 'path'; +import * as Mocha from 'mocha'; +import * as glob from 'glob'; export function run(): Promise { // Create the mocha test const mocha = new Mocha({ - ui: "tdd", - color: true, + ui: 'tdd', + color: true }); mocha.timeout(100000); const testsRoot = __dirname; return new Promise((resolve, reject) => { - glob("**.test.js", { cwd: testsRoot }, (err, files) => { + glob('**.test.js', { cwd: testsRoot }, (err, files) => { if (err) { return reject(err); } diff --git a/spin2/client/src/test/outline.spin2.test.ts b/spin2/client/src/test/outline.spin2.test.ts index 958825c..6106e6e 100644 --- a/spin2/client/src/test/outline.spin2.test.ts +++ b/spin2/client/src/test/outline.spin2.test.ts @@ -3,270 +3,270 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import * as vscode from "vscode"; -import * as assert from "assert"; -import { getDocUri, activate, showObject } from "./helper"; -import { DocumentSymbol } from "vscode-languageclient/node"; +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { getDocUri, activate, showObject } from './helper'; +import { DocumentSymbol } from 'vscode-languageclient/node'; -suite("Should do Spin2 outline display", () => { - const docSpin2Uri = getDocUri("outline.spin2"); +suite('Should do Spin2 outline display', () => { + const docSpin2Uri = getDocUri('outline.spin2'); - test("Get documentSymbols from spin2 file", async () => { + test('Get documentSymbols from spin2 file', async () => { await testDocumentSymbols(docSpin2Uri, [ { - name: "CON { app io pins }", - detail: "", + name: 'CON { app io pins }', + detail: '', kind: 8, range: { start: { line: 3, - character: 0, + character: 0 }, end: { line: 3, - character: 18, - }, + character: 18 + } }, selectionRange: { start: { line: 3, - character: 0, + character: 0 }, end: { line: 3, - character: 18, - }, - }, + character: 18 + } + } }, { name: "VAR ' instance variables", - detail: "", + detail: '', kind: 8, range: { start: { line: 7, - character: 0, + character: 0 }, end: { line: 7, - character: 23, - }, + character: 23 + } }, selectionRange: { start: { line: 7, - character: 0, + character: 0 }, end: { line: 7, - character: 23, - }, - }, + character: 23 + } + } }, { - name: "PUB Main(): ok", - detail: "Public", + name: 'PUB Main(): ok', + detail: 'Public', kind: 6, range: { start: { line: 10, - character: 0, + character: 0 }, end: { line: 10, - character: 24, - }, + character: 24 + } }, selectionRange: { start: { line: 10, - character: 0, + character: 0 }, end: { line: 10, - character: 24, - }, - }, + character: 24 + } + } }, { - name: "PRI KillSwitch(): abortCode, bdidKill", - detail: "Private", + name: 'PRI KillSwitch(): abortCode, bdidKill', + detail: 'Private', kind: 6, range: { start: { line: 14, - character: 0, + character: 0 }, end: { line: 14, - character: 36, - }, + character: 36 + } }, selectionRange: { start: { line: 14, - character: 0, + character: 0 }, end: { line: 14, - character: 36, - }, - }, + character: 36 + } + } }, { name: "VAR ' instance variables", - detail: "", + detail: '', kind: 8, range: { start: { line: 19, - character: 0, + character: 0 }, end: { line: 19, - character: 23, - }, + character: 23 + } }, selectionRange: { start: { line: 19, - character: 0, + character: 0 }, end: { line: 19, - character: 23, - }, - }, + character: 23 + } + } }, { name: "DAT ' class variables", - detail: "", + detail: '', kind: 8, range: { start: { line: 22, - character: 0, + character: 0 }, end: { line: 22, - character: 20, - }, + character: 20 + } }, selectionRange: { start: { line: 22, - character: 0, + character: 0 }, end: { line: 22, - character: 20, - }, + character: 20 + } }, children: [ { - name: "char8_loop", - detail: "", + name: 'char8_loop', + detail: '', kind: 14, range: { start: { line: 28, - character: 0, + character: 0 }, end: { line: 28, - character: 9, - }, + character: 9 + } }, selectionRange: { start: { line: 28, - character: 0, + character: 0 }, end: { line: 28, - character: 9, - }, - }, - }, - ], + character: 9 + } + } + } + ] }, { - name: "DAT ", - detail: "", + name: 'DAT ', + detail: '', kind: 8, range: { start: { line: 30, - character: 0, + character: 0 }, end: { line: 30, - character: 12, - }, + character: 12 + } }, selectionRange: { start: { line: 30, - character: 0, + character: 0 }, end: { line: 30, - character: 12, - }, + character: 12 + } }, children: [ { - name: "read_args", - detail: "", + name: 'read_args', + detail: '', kind: 14, range: { start: { line: 30, - character: 0, + character: 0 }, end: { line: 30, - character: 12, - }, + character: 12 + } }, selectionRange: { start: { line: 30, - character: 0, + character: 0 }, end: { line: 30, - character: 12, - }, - }, + character: 12 + } + } }, { - name: "adpcm_buffers", - detail: "", + name: 'adpcm_buffers', + detail: '', kind: 14, range: { start: { line: 40, - character: 0, + character: 0 }, end: { line: 40, - character: 12, - }, + character: 12 + } }, selectionRange: { start: { line: 40, - character: 0, + character: 0 }, end: { line: 40, - character: 12, - }, - }, - }, - ], - }, + character: 12 + } + } + } + ] + } ]); }); }); @@ -275,7 +275,10 @@ async function testDocumentSymbols(docUri: vscode.Uri, expectedDocumentSymbolsLi await activate(docUri); // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion - const actualDocumentSymbolsList = (await vscode.commands.executeCommand("vscode.executeDocumentSymbolProvider", docUri)) as Array; + const actualDocumentSymbolsList = (await vscode.commands.executeCommand( + 'vscode.executeDocumentSymbolProvider', + docUri + )) as Array; console.log(`spin2-actualCompletionList is ${showObject(actualDocumentSymbolsList)})`); console.log(`spin2-expectedDocumentSymbolsList is ${showObject(expectedDocumentSymbolsList)})`); diff --git a/spin2/client/src/test/runTest.ts b/spin2/client/src/test/runTest.ts index c6e0b56..339afee 100644 --- a/spin2/client/src/test/runTest.ts +++ b/spin2/client/src/test/runTest.ts @@ -1,27 +1,27 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -import * as path from "path"; - -import { runTests } from "@vscode/test-electron"; - -async function main() { - try { - // The folder containing the Extension Manifest package.json - // Passed to `--extensionDevelopmentPath` - const extensionDevelopmentPath = path.resolve(__dirname, "../../../"); - - // The path to test runner - // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, "./index"); - - // Download VS Code, unzip it and run the integration test - await runTests({ extensionDevelopmentPath, extensionTestsPath }); - } catch (err) { - console.error("Failed to run tests"); - process.exit(1); - } -} - -main(); +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import * as path from 'path'; + +import { runTests } from '@vscode/test-electron'; + +async function main() { + try { + // The folder containing the Extension Manifest package.json + // Passed to `--extensionDevelopmentPath` + const extensionDevelopmentPath = path.resolve(__dirname, '../../../'); + + // The path to test runner + // Passed to --extensionTestsPath + const extensionTestsPath = path.resolve(__dirname, './index'); + + // Download VS Code, unzip it and run the integration test + await runTests({ extensionDevelopmentPath, extensionTestsPath }); + } catch (err) { + console.error('Failed to run tests'); + process.exit(1); + } +} + +main(); diff --git a/spin2/copyright b/spin2/copyright index 9895d68..a9f5ea0 100644 --- a/spin2/copyright +++ b/spin2/copyright @@ -11,7 +11,7 @@ Copyright: The overall P2 VSCcode Language Server Extension project is - Copyright © 2023 Iron Sheep Productions, LLC + Copyright © 2024 Iron Sheep Productions, LLC LICENSE @@ -35,7 +35,7 @@ LICENSE This project is: - Copyright © 2023 Iron Sheep Productions, LLC + Copyright © 2024 Iron Sheep Productions, LLC and is licensed under the MIT License. diff --git a/spin2/package-lock.json b/spin2/package-lock.json index e5277c6..f84ee01 100644 --- a/spin2/package-lock.json +++ b/spin2/package-lock.json @@ -1,21 +1,27 @@ { "name": "spin2", - "version": "2.0.4", + "version": "2.2.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "spin2", - "version": "2.0.4", + "version": "2.2.13", "hasInstallScript": true, "license": "MIT", "devDependencies": { "@types/mocha": "^9.1.0", "@types/node": "^16.18.34", - "@typescript-eslint/eslint-plugin": "^5.54.0", - "@typescript-eslint/parser": "^5.54.0", - "esbuild": "^0.19.5", - "eslint": "^8.35.0", + "@typescript-eslint/eslint-plugin": "^6.17.0", + "@typescript-eslint/parser": "^6.17.0", + "esbuild": "^0.19.11", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-config-standard-with-typescript": "^43.0.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-n": "^16.6.1", + "eslint-plugin-prettier": "^5.1.2", + "eslint-plugin-promise": "^6.1.1", "mocha": "^9.2.1", "typescript": "^5.1.3" }, @@ -32,10 +38,26 @@ "node": ">=0.10.0" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.11.tgz", + "integrity": "sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@esbuild/android-arm": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz", - "integrity": "sha512-bhvbzWFF3CwMs5tbjf3ObfGqbl/17ict2/uwOSfr3wmxDE6VdS2GqY/FuzIPe0q0bdhj65zQsvqfArI9MY6+AA==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.11.tgz", + "integrity": "sha512-5OVapq0ClabvKvQ58Bws8+wkLCV+Rxg7tUVbo9xu034Nm536QTII4YzhaFriQ7rMrorfnFKUsArD2lqKbFY4vw==", "cpu": [ "arm" ], @@ -49,9 +71,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.5.tgz", - "integrity": "sha512-5d1OkoJxnYQfmC+Zd8NBFjkhyCNYwM4n9ODrycTFY6Jk1IGiZ+tjVJDDSwDt77nK+tfpGP4T50iMtVi4dEGzhQ==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.11.tgz", + "integrity": "sha512-aiu7K/5JnLj//KOnOfEZ0D90obUkRzDMyqd/wNAUQ34m4YUPVhRZpnqKV9uqDGxT7cToSDnIHsGooyIczu9T+Q==", "cpu": [ "arm64" ], @@ -65,9 +87,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.5.tgz", - "integrity": "sha512-9t+28jHGL7uBdkBjL90QFxe7DVA+KGqWlHCF8ChTKyaKO//VLuoBricQCgwhOjA1/qOczsw843Fy4cbs4H3DVA==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.11.tgz", + "integrity": "sha512-eccxjlfGw43WYoY9QgB82SgGgDbibcqyDTlk3l3C0jOVHKxrjdc9CTwDUQd0vkvYg5um0OH+GpxYvp39r+IPOg==", "cpu": [ "x64" ], @@ -81,9 +103,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.5.tgz", - "integrity": "sha512-mvXGcKqqIqyKoxq26qEDPHJuBYUA5KizJncKOAf9eJQez+L9O+KfvNFu6nl7SCZ/gFb2QPaRqqmG0doSWlgkqw==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.11.tgz", + "integrity": "sha512-ETp87DRWuSt9KdDVkqSoKoLFHYTrkyz2+65fj9nfXsaV3bMhTCjtQfw3y+um88vGRKRiF7erPrh/ZuIdLUIVxQ==", "cpu": [ "arm64" ], @@ -97,9 +119,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.5.tgz", - "integrity": "sha512-Ly8cn6fGLNet19s0X4unjcniX24I0RqjPv+kurpXabZYSXGM4Pwpmf85WHJN3lAgB8GSth7s5A0r856S+4DyiA==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.11.tgz", + "integrity": "sha512-fkFUiS6IUK9WYUO/+22omwetaSNl5/A8giXvQlcinLIjVkxwTLSktbF5f/kJMftM2MJp9+fXqZ5ezS7+SALp4g==", "cpu": [ "x64" ], @@ -113,9 +135,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.5.tgz", - "integrity": "sha512-GGDNnPWTmWE+DMchq1W8Sd0mUkL+APvJg3b11klSGUDvRXh70JqLAO56tubmq1s2cgpVCSKYywEiKBfju8JztQ==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.11.tgz", + "integrity": "sha512-lhoSp5K6bxKRNdXUtHoNc5HhbXVCS8V0iZmDvyWvYq9S5WSfTIHU2UGjcGt7UeS6iEYp9eeymIl5mJBn0yiuxA==", "cpu": [ "arm64" ], @@ -129,9 +151,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.5.tgz", - "integrity": "sha512-1CCwDHnSSoA0HNwdfoNY0jLfJpd7ygaLAp5EHFos3VWJCRX9DMwWODf96s9TSse39Br7oOTLryRVmBoFwXbuuQ==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.11.tgz", + "integrity": "sha512-JkUqn44AffGXitVI6/AbQdoYAq0TEullFdqcMY/PCUZ36xJ9ZJRtQabzMA+Vi7r78+25ZIBosLTOKnUXBSi1Kw==", "cpu": [ "x64" ], @@ -145,9 +167,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.5.tgz", - "integrity": "sha512-lrWXLY/vJBzCPC51QN0HM71uWgIEpGSjSZZADQhq7DKhPcI6NH1IdzjfHkDQws2oNpJKpR13kv7/pFHBbDQDwQ==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.11.tgz", + "integrity": "sha512-3CRkr9+vCV2XJbjwgzjPtO8T0SZUmRZla+UL1jw+XqHZPkPgZiyWvbDvl9rqAN8Zl7qJF0O/9ycMtjU67HN9/Q==", "cpu": [ "arm" ], @@ -161,9 +183,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.5.tgz", - "integrity": "sha512-o3vYippBmSrjjQUCEEiTZ2l+4yC0pVJD/Dl57WfPwwlvFkrxoSO7rmBZFii6kQB3Wrn/6GwJUPLU5t52eq2meA==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.11.tgz", + "integrity": "sha512-LneLg3ypEeveBSMuoa0kwMpCGmpu8XQUh+mL8XXwoYZ6Be2qBnVtcDI5azSvh7vioMDhoJFZzp9GWp9IWpYoUg==", "cpu": [ "arm64" ], @@ -177,9 +199,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.5.tgz", - "integrity": "sha512-MkjHXS03AXAkNp1KKkhSKPOCYztRtK+KXDNkBa6P78F8Bw0ynknCSClO/ztGszILZtyO/lVKpa7MolbBZ6oJtQ==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.11.tgz", + "integrity": "sha512-caHy++CsD8Bgq2V5CodbJjFPEiDPq8JJmBdeyZ8GWVQMjRD0sU548nNdwPNvKjVpamYYVL40AORekgfIubwHoA==", "cpu": [ "ia32" ], @@ -193,9 +215,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.5.tgz", - "integrity": "sha512-42GwZMm5oYOD/JHqHska3Jg0r+XFb/fdZRX+WjADm3nLWLcIsN27YKtqxzQmGNJgu0AyXg4HtcSK9HuOk3v1Dw==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.11.tgz", + "integrity": "sha512-ppZSSLVpPrwHccvC6nQVZaSHlFsvCQyjnvirnVjbKSHuE5N24Yl8F3UwYUUR1UEPaFObGD2tSvVKbvR+uT1Nrg==", "cpu": [ "loong64" ], @@ -209,9 +231,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.5.tgz", - "integrity": "sha512-kcjndCSMitUuPJobWCnwQ9lLjiLZUR3QLQmlgaBfMX23UEa7ZOrtufnRds+6WZtIS9HdTXqND4yH8NLoVVIkcg==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.11.tgz", + "integrity": "sha512-B5x9j0OgjG+v1dF2DkH34lr+7Gmv0kzX6/V0afF41FkPMMqaQ77pH7CrhWeR22aEeHKaeZVtZ6yFwlxOKPVFyg==", "cpu": [ "mips64el" ], @@ -225,9 +247,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.5.tgz", - "integrity": "sha512-yJAxJfHVm0ZbsiljbtFFP1BQKLc8kUF6+17tjQ78QjqjAQDnhULWiTA6u0FCDmYT1oOKS9PzZ2z0aBI+Mcyj7Q==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.11.tgz", + "integrity": "sha512-MHrZYLeCG8vXblMetWyttkdVRjQlQUb/oMgBNurVEnhj4YWOr4G5lmBfZjHYQHHN0g6yDmCAQRR8MUHldvvRDA==", "cpu": [ "ppc64" ], @@ -241,9 +263,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.5.tgz", - "integrity": "sha512-5u8cIR/t3gaD6ad3wNt1MNRstAZO+aNyBxu2We8X31bA8XUNyamTVQwLDA1SLoPCUehNCymhBhK3Qim1433Zag==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.11.tgz", + "integrity": "sha512-f3DY++t94uVg141dozDu4CCUkYW+09rWtaWfnb3bqe4w5NqmZd6nPVBm+qbz7WaHZCoqXqHz5p6CM6qv3qnSSQ==", "cpu": [ "riscv64" ], @@ -257,9 +279,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.5.tgz", - "integrity": "sha512-Z6JrMyEw/EmZBD/OFEFpb+gao9xJ59ATsoTNlj39jVBbXqoZm4Xntu6wVmGPB/OATi1uk/DB+yeDPv2E8PqZGw==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.11.tgz", + "integrity": "sha512-A5xdUoyWJHMMlcSMcPGVLzYzpcY8QP1RtYzX5/bS4dvjBGVxdhuiYyFwp7z74ocV7WDc0n1harxmpq2ePOjI0Q==", "cpu": [ "s390x" ], @@ -273,9 +295,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.5.tgz", - "integrity": "sha512-psagl+2RlK1z8zWZOmVdImisMtrUxvwereIdyJTmtmHahJTKb64pAcqoPlx6CewPdvGvUKe2Jw+0Z/0qhSbG1A==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.11.tgz", + "integrity": "sha512-grbyMlVCvJSfxFQUndw5mCtWs5LO1gUlwP4CDi4iJBbVpZcqLVT29FxgGuBJGSzyOxotFG4LoO5X+M1350zmPA==", "cpu": [ "x64" ], @@ -289,9 +311,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.5.tgz", - "integrity": "sha512-kL2l+xScnAy/E/3119OggX8SrWyBEcqAh8aOY1gr4gPvw76la2GlD4Ymf832UCVbmuWeTf2adkZDK+h0Z/fB4g==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.11.tgz", + "integrity": "sha512-13jvrQZJc3P230OhU8xgwUnDeuC/9egsjTkXN49b3GcS5BKvJqZn86aGM8W9pd14Kd+u7HuFBMVtrNGhh6fHEQ==", "cpu": [ "x64" ], @@ -305,9 +327,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.5.tgz", - "integrity": "sha512-sPOfhtzFufQfTBgRnE1DIJjzsXukKSvZxloZbkJDG383q0awVAq600pc1nfqBcl0ice/WN9p4qLc39WhBShRTA==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.11.tgz", + "integrity": "sha512-ysyOGZuTp6SNKPE11INDUeFVVQFrhcNDVUgSQVDzqsqX38DjhPEPATpid04LCoUr2WXhQTEZ8ct/EgJCUDpyNw==", "cpu": [ "x64" ], @@ -321,9 +343,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.5.tgz", - "integrity": "sha512-dGZkBXaafuKLpDSjKcB0ax0FL36YXCvJNnztjKV+6CO82tTYVDSH2lifitJ29jxRMoUhgkg9a+VA/B03WK5lcg==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.11.tgz", + "integrity": "sha512-Hf+Sad9nVwvtxy4DXCZQqLpgmRTQqyFyhT3bZ4F2XlJCjxGmRFF0Shwn9rzhOYRB61w9VMXUkxlBy56dk9JJiQ==", "cpu": [ "x64" ], @@ -337,9 +359,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.5.tgz", - "integrity": "sha512-dWVjD9y03ilhdRQ6Xig1NWNgfLtf2o/STKTS+eZuF90fI2BhbwD6WlaiCGKptlqXlURVB5AUOxUj09LuwKGDTg==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.11.tgz", + "integrity": "sha512-0P58Sbi0LctOMOQbpEOvOL44Ne0sqbS0XWHMvvrg6NE5jQ1xguCSSw9jQeUk2lfrXYsKDdOe6K+oZiwKPilYPQ==", "cpu": [ "arm64" ], @@ -353,9 +375,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.5.tgz", - "integrity": "sha512-4liggWIA4oDgUxqpZwrDhmEfAH4d0iljanDOK7AnVU89T6CzHon/ony8C5LeOdfgx60x5cnQJFZwEydVlYx4iw==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.11.tgz", + "integrity": "sha512-6YOrWS+sDJDmshdBIQU+Uoyh7pQKrdykdefC1avn76ss5c+RN6gut3LZA4E2cH5xUEp5/cA0+YxRaVtRAb0xBg==", "cpu": [ "ia32" ], @@ -369,9 +391,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.5.tgz", - "integrity": "sha512-czTrygUsB/jlM8qEW5MD8bgYU2Xg14lo6kBDXW6HdxKjh8M5PzETGiSHaz9MtbXBYDloHNUAUW2tMiKW4KM9Mw==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.11.tgz", + "integrity": "sha512-vfkhltrjCAb603XaFhqhAF4LGDi2M4OrCRrFusyQ+iTLQ/o60QQXxc9cZC/FFpihBI9N1Grn6SMKVJ4KP7Fuiw==", "cpu": [ "x64" ], @@ -409,9 +431,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", - "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -431,29 +453,73 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@eslint/js": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", - "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", + "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.13", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", - "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^2.0.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -468,9 +534,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", - "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "node_modules/@nodelib/fs.scandir": { @@ -508,10 +574,28 @@ "node": ">= 8" } }, + "node_modules/@pkgr/core": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.0.tgz", + "integrity": "sha512-Zwq5OCzuwJC2jwqmpEQt7Ds1DTi6BWSwoGkbb1n9pO3hzb35BoJELx7c0T23iDkBGkh2e7tvOtjF3tr3OaQHDQ==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@types/json-schema": { - "version": "7.0.14", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.14.tgz", - "integrity": "sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==", + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, "node_modules/@types/mocha": { @@ -521,44 +605,45 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.18.59", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.59.tgz", - "integrity": "sha512-PJ1w2cNeKUEdey4LiPra0ZuxZFOGvetswE8qHRriV/sUkL5Al4tTmPV9D2+Y/TPIxTHHgxTfRjZVKWhPw/ORhQ==", + "version": "16.18.70", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.70.tgz", + "integrity": "sha512-8eIk20G5VVVQNZNouHjLA2b8utE2NvGybLjMaF4lyhA9uhGwnmXF8o+icdXKGSQSNANJewXva/sFUoZLwAaYAg==", "dev": true }, "node_modules/@types/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==", + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", + "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", - "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz", + "integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==", "dev": true, "dependencies": { - "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/type-utils": "5.62.0", - "@typescript-eslint/utils": "5.62.0", + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/type-utils": "6.18.1", + "@typescript-eslint/utils": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "graphemer": "^1.4.0", - "ignore": "^5.2.0", - "natural-compare-lite": "^1.4.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -567,25 +652,26 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", - "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.1.tgz", + "integrity": "sha512-zct/MdJnVaRRNy9e84XnVtRv9Vf91/qqe+hZJtKanjojud4wAVy/7lXxJmMyX6X6J+xc6c//YEWvpeif8cAhWA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/typescript-estree": "5.62.0", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -594,16 +680,16 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", - "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", + "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/visitor-keys": "5.62.0" + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -611,25 +697,25 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz", - "integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz", + "integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.62.0", - "@typescript-eslint/utils": "5.62.0", + "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/utils": "6.18.1", "debug": "^4.3.4", - "tsutils": "^3.21.0" + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "*" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -638,12 +724,12 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", - "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", + "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", "dev": true, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -651,21 +737,22 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", - "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", + "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/visitor-keys": "5.62.0", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -678,42 +765,41 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", - "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", + "integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==", "dev": true, "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@types/json-schema": "^7.0.9", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/typescript-estree": "5.62.0", - "eslint-scope": "^5.1.1", - "semver": "^7.3.7" + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/typescript-estree": "6.18.1", + "semver": "^7.5.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", - "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", + "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.62.0", - "eslint-visitor-keys": "^3.3.0" + "@typescript-eslint/types": "6.18.1", + "eslint-visitor-keys": "^3.4.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -733,9 +819,9 @@ "dev": true }, "node_modules/acorn": { - "version": "8.11.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.1.tgz", - "integrity": "sha512-IJTNCJMRHfRfb8un89z1QtS0x890C2QUrUxFMK8zy+RizcId6mfnqOf68Bu9YkDgpLYuvCm6aYbwDatXVZPjMQ==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -821,6 +907,38 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", + "integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "is-array-buffer": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-includes": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.7.tgz", + "integrity": "sha512-dlcsNBIiWhPkHdOEEKnehA+RNUWDc4UqFtnIXU4uuYDPtA4LDkr7qip2p0VvFAEXNDr0yWZ9PJyIRiGjRLQzwQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -830,6 +948,94 @@ "node": ">=8" } }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.3.tgz", + "integrity": "sha512-LzLoiOMAxvy+Gd3BAq3B7VeIgPdo+Q8hthvKtXybMvRV0jrXfJM/t8mw7nNlpEcVlVUnCnM2KSX4XU5HmpodOA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0", + "get-intrinsic": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flat": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", + "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flatmap": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", + "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.2.tgz", + "integrity": "sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-array-buffer": "^3.0.2", + "is-shared-array-buffer": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -846,13 +1052,12 @@ } }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, "node_modules/braces": { @@ -873,6 +1078,41 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/builtins": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz", + "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==", + "dev": true, + "dependencies": { + "semver": "^7.0.0" + } + }, + "node_modules/call-bind": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", + "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -1033,6 +1273,37 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/define-data-property": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", + "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -1072,10 +1343,103 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, + "node_modules/es-abstract": { + "version": "1.22.3", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.22.3.tgz", + "integrity": "sha512-eiiY8HQeYfYH2Con2berK+To6GrK2RxbPawDkGq4UiCQQfZHb6wX9qQqkbpPqaxQFcl8d9QzZqo0tGE0VcrdwA==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "arraybuffer.prototype.slice": "^1.0.2", + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.5", + "es-set-tostringtag": "^2.0.1", + "es-to-primitive": "^1.2.1", + "function.prototype.name": "^1.1.6", + "get-intrinsic": "^1.2.2", + "get-symbol-description": "^1.0.0", + "globalthis": "^1.0.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0", + "internal-slot": "^1.0.5", + "is-array-buffer": "^3.0.2", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-typed-array": "^1.1.12", + "is-weakref": "^1.0.2", + "object-inspect": "^1.13.1", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.1", + "safe-array-concat": "^1.0.1", + "safe-regex-test": "^1.0.0", + "string.prototype.trim": "^1.2.8", + "string.prototype.trimend": "^1.0.7", + "string.prototype.trimstart": "^1.0.7", + "typed-array-buffer": "^1.0.0", + "typed-array-byte-length": "^1.0.0", + "typed-array-byte-offset": "^1.0.0", + "typed-array-length": "^1.0.4", + "unbox-primitive": "^1.0.2", + "which-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.2.tgz", + "integrity": "sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2", + "has-tostringtag": "^1.0.0", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-shim-unscopables": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", + "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", + "dev": true, + "dependencies": { + "hasown": "^2.0.0" + } + }, + "node_modules/es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/esbuild": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz", - "integrity": "sha512-bUxalY7b1g8vNhQKdB24QDmHeY4V4tw/s6Ak5z+jJX9laP5MoQseTOMemAr0gxssjNcH0MCViG8ONI2kksvfFQ==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.11.tgz", + "integrity": "sha512-HJ96Hev2hX/6i5cDVwcqiJBBtuo9+FeIJOtZ9W1kA5M6AMJRHUZlpYZ1/SbEwtO0ioNAW8rUooVpC/WehY2SfA==", "dev": true, "hasInstallScript": true, "bin": { @@ -1085,28 +1449,29 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/android-arm": "0.19.5", - "@esbuild/android-arm64": "0.19.5", - "@esbuild/android-x64": "0.19.5", - "@esbuild/darwin-arm64": "0.19.5", - "@esbuild/darwin-x64": "0.19.5", - "@esbuild/freebsd-arm64": "0.19.5", - "@esbuild/freebsd-x64": "0.19.5", - "@esbuild/linux-arm": "0.19.5", - "@esbuild/linux-arm64": "0.19.5", - "@esbuild/linux-ia32": "0.19.5", - "@esbuild/linux-loong64": "0.19.5", - "@esbuild/linux-mips64el": "0.19.5", - "@esbuild/linux-ppc64": "0.19.5", - "@esbuild/linux-riscv64": "0.19.5", - "@esbuild/linux-s390x": "0.19.5", - "@esbuild/linux-x64": "0.19.5", - "@esbuild/netbsd-x64": "0.19.5", - "@esbuild/openbsd-x64": "0.19.5", - "@esbuild/sunos-x64": "0.19.5", - "@esbuild/win32-arm64": "0.19.5", - "@esbuild/win32-ia32": "0.19.5", - "@esbuild/win32-x64": "0.19.5" + "@esbuild/aix-ppc64": "0.19.11", + "@esbuild/android-arm": "0.19.11", + "@esbuild/android-arm64": "0.19.11", + "@esbuild/android-x64": "0.19.11", + "@esbuild/darwin-arm64": "0.19.11", + "@esbuild/darwin-x64": "0.19.11", + "@esbuild/freebsd-arm64": "0.19.11", + "@esbuild/freebsd-x64": "0.19.11", + "@esbuild/linux-arm": "0.19.11", + "@esbuild/linux-arm64": "0.19.11", + "@esbuild/linux-ia32": "0.19.11", + "@esbuild/linux-loong64": "0.19.11", + "@esbuild/linux-mips64el": "0.19.11", + "@esbuild/linux-ppc64": "0.19.11", + "@esbuild/linux-riscv64": "0.19.11", + "@esbuild/linux-s390x": "0.19.11", + "@esbuild/linux-x64": "0.19.11", + "@esbuild/netbsd-x64": "0.19.11", + "@esbuild/openbsd-x64": "0.19.11", + "@esbuild/sunos-x64": "0.19.11", + "@esbuild/win32-arm64": "0.19.11", + "@esbuild/win32-ia32": "0.19.11", + "@esbuild/win32-x64": "0.19.11" } }, "node_modules/escalade": { @@ -1131,15 +1496,15 @@ } }, "node_modules/eslint": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", - "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", + "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.52.0", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.56.0", "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -1185,60 +1550,372 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "node_modules/eslint-compat-utils": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.1.2.tgz", + "integrity": "sha512-Jia4JDldWnFNIru1Ehx1H5s9/yxiRHY/TimCuUc0jNexew3cF1gI6CYZil1ociakfWO3rRqFjl1mskBblB3RYg==", "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, "engines": { - "node": ">=8.0.0" + "node": ">=12" + }, + "peerDependencies": { + "eslint": ">=6.0.0" } }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "bin": { + "eslint-config-prettier": "bin/cli.js" }, - "funding": { - "url": "https://opencollective.com/eslint" + "peerDependencies": { + "eslint": ">=7.0.0" } }, - "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "node_modules/eslint-config-standard": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz", + "integrity": "sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==", "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": ">=12.0.0" }, - "funding": { - "url": "https://opencollective.com/eslint" + "peerDependencies": { + "eslint": "^8.0.1", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise": "^6.0.0" } }, - "node_modules/eslint/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "node_modules/eslint-config-standard-with-typescript": { + "version": "43.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-43.0.0.tgz", + "integrity": "sha512-AT0qK01M5bmsWiE3UZvaQO5da1y1n6uQckAKqGNe6zPW5IOzgMLXZxw77nnFm+C11nxAZXsCPrbsgJhSrGfX6Q==", "dev": true, - "engines": { - "node": ">=4.0" + "dependencies": { + "@typescript-eslint/parser": "^6.4.0", + "eslint-config-standard": "17.1.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.4.0", + "eslint": "^8.0.1", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise": "^6.0.0", + "typescript": "*" } }, - "node_modules/espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", + "integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==", + "dev": true, + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-es-x": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.5.0.tgz", + "integrity": "sha512-ODswlDSO0HJDzXU0XvgZ3lF3lS3XAZEossh15Q2UHjwrJggWeBoKqqEsLTZLXl+dh5eOAozG0zRcYtuE35oTuQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.1.2", + "@eslint-community/regexpp": "^4.6.0", + "eslint-compat-utils": "^0.1.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "eslint": ">=8" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", + "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", + "dev": true, + "dependencies": { + "array-includes": "^3.1.7", + "array.prototype.findlastindex": "^1.2.3", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.8.0", + "hasown": "^2.0.0", + "is-core-module": "^2.13.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.7", + "object.groupby": "^1.0.1", + "object.values": "^1.1.7", + "semver": "^6.3.1", + "tsconfig-paths": "^3.15.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + } + }, + "node_modules/eslint-plugin-import/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-n": { + "version": "16.6.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-16.6.2.tgz", + "integrity": "sha512-6TyDmZ1HXoFQXnhCTUjVFULReoBPOAjpuiKELMkeP40yffI/1ZRO+d9ug/VC6fqISo2WkuIBk3cvuRPALaWlOQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "builtins": "^5.0.1", + "eslint-plugin-es-x": "^7.5.0", + "get-tsconfig": "^4.7.0", + "globals": "^13.24.0", + "ignore": "^5.2.4", + "is-builtin-module": "^3.2.1", + "is-core-module": "^2.12.1", + "minimatch": "^3.1.2", + "resolve": "^1.22.2", + "semver": "^7.5.3" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-n/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-n/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz", + "integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.8.6" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-promise": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz", + "integrity": "sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "dependencies": { "acorn": "^8.9.0", @@ -1264,15 +1941,6 @@ "node": ">=0.10" } }, - "node_modules/esquery/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", @@ -1285,7 +1953,7 @@ "node": ">=4.0" } }, - "node_modules/esrecurse/node_modules/estraverse": { + "node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", @@ -1294,15 +1962,6 @@ "node": ">=4.0" } }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -1318,10 +1977,16 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "node_modules/fast-glob": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", - "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -1359,9 +2024,9 @@ "dev": true }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", + "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -1417,9 +2082,9 @@ } }, "node_modules/flat-cache": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.1.tgz", - "integrity": "sha512-/qM2b3LUIaIgviBQovTLvijfyOQXPtSRnRK26ksj2J7rzPIecePUIpJsZ4T02Qg+xiAEKIs5K8dsHEd+VaKa/Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", "dev": true, "dependencies": { "flatted": "^3.2.9", @@ -1427,7 +2092,7 @@ "rimraf": "^3.0.2" }, "engines": { - "node": ">=12.0.0" + "node": "^10.12.0 || >=12.0.0" } }, "node_modules/flatted": { @@ -1436,6 +2101,15 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1456,6 +2130,42 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function.prototype.name": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.6.tgz", + "integrity": "sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "functions-have-names": "^1.2.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -1465,6 +2175,49 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-intrinsic": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", + "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-tsconfig": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.2.tgz", + "integrity": "sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -1497,10 +2250,32 @@ "node": ">=10.13.0" } }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/globals": { - "version": "13.23.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", - "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1512,6 +2287,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -1532,6 +2322,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -1547,6 +2349,15 @@ "node": ">=4.x" } }, + "node_modules/has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -1556,6 +2367,69 @@ "node": ">=8" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -1566,9 +2440,9 @@ } }, "node_modules/ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", "dev": true, "engines": { "node": ">= 4" @@ -1615,6 +2489,46 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "node_modules/internal-slot": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.6.tgz", + "integrity": "sha512-Xj6dv+PsbtwyPpEflsejS+oIZxmMlV44zAhG479uYu89MsjcYOhCFnNyKrkJrihbsiasQyY0afoCl/9BLR65bg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2", + "hasown": "^2.0.0", + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", + "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "is-typed-array": "^1.1.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "dependencies": { + "has-bigints": "^1.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -1627,6 +2541,76 @@ "node": ">=8" } }, + "node_modules/is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dev": true, + "dependencies": { + "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -1657,6 +2641,18 @@ "node": ">=0.10.0" } }, + "node_modules/is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -1666,6 +2662,21 @@ "node": ">=0.12.0" } }, + "node_modules/is-number-object": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -1684,6 +2695,79 @@ "node": ">=8" } }, + "node_modules/is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.12.tgz", + "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", + "dev": true, + "dependencies": { + "which-typed-array": "^1.1.11" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", @@ -1696,6 +2780,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -1732,6 +2834,18 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, + "node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -1826,15 +2940,27 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "dev": true, "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/mocha": { @@ -1880,6 +3006,16 @@ "url": "https://opencollective.com/mochajs" } }, + "node_modules/mocha/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/mocha/node_modules/debug": { "version": "4.3.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", @@ -1960,12 +3096,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", - "dev": true - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -1975,6 +3105,88 @@ "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", + "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.5", + "define-properties": "^1.2.1", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.fromentries": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.7.tgz", + "integrity": "sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.groupby": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.1.tgz", + "integrity": "sha512-HqaQtqLnp/8Bn4GL16cj+CUYbnpe1bh0TtEaWvybszDG4tgxCJuRpV8VGuvNaI1fAnI4lUJzDG55MXcOH4JZcQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1" + } + }, + "node_modules/object.values": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.7.tgz", + "integrity": "sha512-aU6xnDFYT3x17e/f0IiiwlGPTy2jzMySGfUB4fq6z7CV8l85CWHDk5ErhyhpfDHhrOMwGFhSQkhMGHaIotA6Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2070,6 +3282,12 @@ "node": ">=8" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -2100,10 +3318,38 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "dev": true, + "peer": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" @@ -2150,6 +3396,23 @@ "node": ">=8.10.0" } }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.1.tgz", + "integrity": "sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "set-function-name": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2159,6 +3422,23 @@ "node": ">=0.10.0" } }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -2168,6 +3448,15 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -2216,6 +3505,24 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/safe-array-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.1.tgz", + "integrity": "sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "has-symbols": "^1.0.3", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -2236,6 +3543,23 @@ } ] }, + "node_modules/safe-regex-test": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.1.tgz", + "integrity": "sha512-Y5NejJTTliTyY4H7sipGqY+RX5P87i3F7c4Rcepy72nq+mNLhIsD0W4c7kEmduMDQCSqtPsXPlSTsFhh2LQv+g==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.5", + "get-intrinsic": "^1.2.2", + "is-regex": "^1.1.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", @@ -2260,6 +3584,35 @@ "randombytes": "^2.1.0" } }, + "node_modules/set-function-length": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", + "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "dev": true, + "dependencies": { + "define-data-property": "^1.1.1", + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.1.tgz", + "integrity": "sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==", + "dev": true, + "dependencies": { + "define-data-property": "^1.0.1", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -2281,6 +3634,20 @@ "node": ">=8" } }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -2304,6 +3671,51 @@ "node": ">=8" } }, + "node_modules/string.prototype.trim": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.8.tgz", + "integrity": "sha512-lfjY4HcixfQXOfaqCvcBuOIapyaroTXhbkfJN3gcB1OtyupngWK4sEET9Knd0cXd28kTUqu/kHoV4HKSJdnjiQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.7.tgz", + "integrity": "sha512-Ni79DqeB72ZFq1uH/L6zJ+DKZTkOtPIHovb3YZHQViE+HDouuU4mBrLOLDn5Dde3RF8qw5qVETEjhu9locMLvA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.7.tgz", + "integrity": "sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2316,6 +3728,15 @@ "node": ">=8" } }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -2340,6 +3761,34 @@ "node": ">=8" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/synckit": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz", + "integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==", + "dev": true, + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -2358,27 +3807,36 @@ "node": ">=8.0" } }, - "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, - "node_modules/tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "node_modules/ts-api-utils": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", + "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", "dev": true, - "dependencies": { - "tslib": "^1.8.1" - }, "engines": { - "node": ">= 6" + "node": ">=16.13.0" }, "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + "typescript": ">=4.2.0" + } + }, + "node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" } }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "dev": true + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -2403,10 +3861,75 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typed-array-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz", + "integrity": "sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz", + "integrity": "sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz", + "integrity": "sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz", + "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "is-typed-array": "^1.1.9" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -2416,6 +3939,21 @@ "node": ">=14.17" } }, + "node_modules/unbox-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", + "which-boxed-primitive": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -2440,6 +3978,41 @@ "node": ">= 8" } }, + "node_modules/which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "dependencies": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.13.tgz", + "integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.4", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/workerpool": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", diff --git a/spin2/package.json b/spin2/package.json index c59c015..aa5333d 100644 --- a/spin2/package.json +++ b/spin2/package.json @@ -5,7 +5,7 @@ "icon": "images/Propeller.ico", "author": "IronSheep", "license": "MIT", - "version": "2.2.13", + "version": "2.2.14", "repository": { "type": "git", "url": "https://github.com/ironsheep/P2-vscode-langserv-extension" @@ -47,15 +47,15 @@ "title": "Spin2: Generate documentation file from spin source" }, { - "command": "spinExtension.indentTabStop", + "command": "spinExtension.elasticTabstops.indentTabStop", "title": "Spin2: Indent tab stop" }, { - "command": "spinExtension.outdentTabStop", + "command": "spinExtension.elasticTabstops.outdentTabStop", "title": "Spin2: Outdent tab stop" }, { - "command": "spinExtension.generate.tabStops.comment", + "command": "spinExtension.elasticTabstops.generate.tabStops.comment", "title": "Spin2: Generate and insert tab stop comment" }, { @@ -93,6 +93,7 @@ "scope": "resource", "type": "number", "default": 100, + "minimum": 0, "description": "Controls the maximum number of issues reported by the spin2 server (for each file.)" }, "spinExtension.trace.server": { @@ -128,12 +129,12 @@ { "title": "Spin/Spin2 Editor Tabstops", "properties": { - "spinExtension.ElasticTabstops.enable": { + "spinExtension.elasticTabstops.enable": { "type": "boolean", "default": false, "description": "Enable the use of Spin2 Tabstops along with [Insert|Overtype|Align] insert modes." }, - "spinExtension.ElasticTabstops.choice": { + "spinExtension.elasticTabstops.choice": { "type": "string", "default": "PropellerTool", "enum": [ @@ -143,7 +144,7 @@ ], "description": "Select the set of Tabstops you wish to use." }, - "spinExtension.ElasticTabstops.blocks.PropellerTool": { + "spinExtension.elasticTabstops.blocks.PropellerTool": { "type": "object", "properties": { "type": "array", @@ -229,7 +230,7 @@ } } }, - "spinExtension.ElasticTabstops.blocks.IronSheep": { + "spinExtension.elasticTabstops.blocks.IronSheep": { "type": "object", "properties": { "type": "array", @@ -324,7 +325,7 @@ } } }, - "spinExtension.ElasticTabstops.blocks.User1": { + "spinExtension.elasticTabstops.blocks.User1": { "type": "object", "properties": { "type": "array", @@ -417,22 +418,22 @@ { "title": "Spin/Spin2 TabStop Insert Mode Configuration", "properties": { - "spinExtension.InsertMode.overtypePaste": { + "spinExtension.insertMode.overtypePaste": { "type": "boolean", "default": false, "description": "Enable use of overtype behavior when pasting text while in \"Overtype\" Mode." }, - "spinExtension.InsertMode.perEditor": { + "spinExtension.insertMode.perEditor": { "type": "boolean", "default": false, "description": "Enable the setting of insert/overtype/align mode \"per editor\"." }, - "spinExtension.InsertMode.enableAlign": { + "spinExtension.insertMode.enableAlign": { "type": "boolean", "default": true, "description": "Enable Editor \"Align\" behavior." }, - "spinExtension.InsertMode.secondaryCursorStyle": { + "spinExtension.insertMode.secondaryCursorStyle": { "type": "string", "default": "block", "enum": [ @@ -445,7 +446,7 @@ ], "description": "Select the \"Overtype\" Mode cursor style." }, - "spinExtension.InsertMode.ternaryCursorStyle": { + "spinExtension.insertMode.ternaryCursorStyle": { "type": "string", "default": "underline", "enum": [ @@ -458,17 +459,17 @@ ], "description": "Select the \"Align\" Mode cursor style." }, - "spinExtension.InsertMode.labelInsertMode": { + "spinExtension.insertMode.labelInsertMode": { "type": "string", "default": "Insert", "description": "Label text in the status bar shown during \"Insert\" Mode (may be empty to hide the status.)" }, - "spinExtension.InsertMode.labelOvertypeMode": { + "spinExtension.insertMode.labelOvertypeMode": { "type": "string", "default": "Overtype", "description": "Label text in the status bar shown during \"Overtype\" Mode (may be empty to hide the status.)" }, - "spinExtension.InsertMode.labelAlignMode": { + "spinExtension.insertMode.labelAlignMode": { "type": "string", "default": "Align", "description": "Label text in the status bar shown during \"Align\" Mode (may be empty to hide the status.)" @@ -489,40 +490,40 @@ }, { "key": "tab", - "command": "spinExtension.indentTabStop", - "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !editorHoverFocused && !editorHoverVisible && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.indentTabStop", + "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !editorHoverFocused && !editorHoverVisible && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "key": "Shift+tab", - "command": "spinExtension.outdentTabStop", - "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.outdentTabStop", + "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "key": "Ctrl+Alt+tab", - "command": "spinExtension.generate.tabStops.comment", - "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.generate.tabStops.comment", + "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.rotate", "key": "insert", "mac": "F13", - "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.deleteLeft", "key": "backspace", - "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.deleteRight", "key": "delete", - "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.toggle", "key": "Ctrl+Shift+i", "mac": "Cmd+Shift+i", - "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" } ], "menus": { @@ -703,13 +704,20 @@ "test-compile": "tsc -p ./", "test": "sh ./scripts/e2e.sh" }, + "dependencies": {}, "devDependencies": { "@types/mocha": "^9.1.0", "@types/node": "^16.18.34", - "@typescript-eslint/eslint-plugin": "^5.54.0", - "@typescript-eslint/parser": "^5.54.0", - "esbuild": "^0.19.5", - "eslint": "^8.35.0", + "@typescript-eslint/eslint-plugin": "^6.17.0", + "@typescript-eslint/parser": "^6.17.0", + "esbuild": "^0.19.11", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-config-standard-with-typescript": "^43.0.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-n": "^16.6.1", + "eslint-plugin-prettier": "^5.1.2", + "eslint-plugin-promise": "^6.1.1", "mocha": "^9.2.1", "typescript": "^5.1.3" } diff --git a/spin2/scripts/LIVE-package.json b/spin2/scripts/LIVE-package.json index c59c015..aa5333d 100644 --- a/spin2/scripts/LIVE-package.json +++ b/spin2/scripts/LIVE-package.json @@ -5,7 +5,7 @@ "icon": "images/Propeller.ico", "author": "IronSheep", "license": "MIT", - "version": "2.2.13", + "version": "2.2.14", "repository": { "type": "git", "url": "https://github.com/ironsheep/P2-vscode-langserv-extension" @@ -47,15 +47,15 @@ "title": "Spin2: Generate documentation file from spin source" }, { - "command": "spinExtension.indentTabStop", + "command": "spinExtension.elasticTabstops.indentTabStop", "title": "Spin2: Indent tab stop" }, { - "command": "spinExtension.outdentTabStop", + "command": "spinExtension.elasticTabstops.outdentTabStop", "title": "Spin2: Outdent tab stop" }, { - "command": "spinExtension.generate.tabStops.comment", + "command": "spinExtension.elasticTabstops.generate.tabStops.comment", "title": "Spin2: Generate and insert tab stop comment" }, { @@ -93,6 +93,7 @@ "scope": "resource", "type": "number", "default": 100, + "minimum": 0, "description": "Controls the maximum number of issues reported by the spin2 server (for each file.)" }, "spinExtension.trace.server": { @@ -128,12 +129,12 @@ { "title": "Spin/Spin2 Editor Tabstops", "properties": { - "spinExtension.ElasticTabstops.enable": { + "spinExtension.elasticTabstops.enable": { "type": "boolean", "default": false, "description": "Enable the use of Spin2 Tabstops along with [Insert|Overtype|Align] insert modes." }, - "spinExtension.ElasticTabstops.choice": { + "spinExtension.elasticTabstops.choice": { "type": "string", "default": "PropellerTool", "enum": [ @@ -143,7 +144,7 @@ ], "description": "Select the set of Tabstops you wish to use." }, - "spinExtension.ElasticTabstops.blocks.PropellerTool": { + "spinExtension.elasticTabstops.blocks.PropellerTool": { "type": "object", "properties": { "type": "array", @@ -229,7 +230,7 @@ } } }, - "spinExtension.ElasticTabstops.blocks.IronSheep": { + "spinExtension.elasticTabstops.blocks.IronSheep": { "type": "object", "properties": { "type": "array", @@ -324,7 +325,7 @@ } } }, - "spinExtension.ElasticTabstops.blocks.User1": { + "spinExtension.elasticTabstops.blocks.User1": { "type": "object", "properties": { "type": "array", @@ -417,22 +418,22 @@ { "title": "Spin/Spin2 TabStop Insert Mode Configuration", "properties": { - "spinExtension.InsertMode.overtypePaste": { + "spinExtension.insertMode.overtypePaste": { "type": "boolean", "default": false, "description": "Enable use of overtype behavior when pasting text while in \"Overtype\" Mode." }, - "spinExtension.InsertMode.perEditor": { + "spinExtension.insertMode.perEditor": { "type": "boolean", "default": false, "description": "Enable the setting of insert/overtype/align mode \"per editor\"." }, - "spinExtension.InsertMode.enableAlign": { + "spinExtension.insertMode.enableAlign": { "type": "boolean", "default": true, "description": "Enable Editor \"Align\" behavior." }, - "spinExtension.InsertMode.secondaryCursorStyle": { + "spinExtension.insertMode.secondaryCursorStyle": { "type": "string", "default": "block", "enum": [ @@ -445,7 +446,7 @@ ], "description": "Select the \"Overtype\" Mode cursor style." }, - "spinExtension.InsertMode.ternaryCursorStyle": { + "spinExtension.insertMode.ternaryCursorStyle": { "type": "string", "default": "underline", "enum": [ @@ -458,17 +459,17 @@ ], "description": "Select the \"Align\" Mode cursor style." }, - "spinExtension.InsertMode.labelInsertMode": { + "spinExtension.insertMode.labelInsertMode": { "type": "string", "default": "Insert", "description": "Label text in the status bar shown during \"Insert\" Mode (may be empty to hide the status.)" }, - "spinExtension.InsertMode.labelOvertypeMode": { + "spinExtension.insertMode.labelOvertypeMode": { "type": "string", "default": "Overtype", "description": "Label text in the status bar shown during \"Overtype\" Mode (may be empty to hide the status.)" }, - "spinExtension.InsertMode.labelAlignMode": { + "spinExtension.insertMode.labelAlignMode": { "type": "string", "default": "Align", "description": "Label text in the status bar shown during \"Align\" Mode (may be empty to hide the status.)" @@ -489,40 +490,40 @@ }, { "key": "tab", - "command": "spinExtension.indentTabStop", - "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !editorHoverFocused && !editorHoverVisible && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.indentTabStop", + "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !editorHoverFocused && !editorHoverVisible && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "key": "Shift+tab", - "command": "spinExtension.outdentTabStop", - "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.outdentTabStop", + "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "key": "Ctrl+Alt+tab", - "command": "spinExtension.generate.tabStops.comment", - "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.generate.tabStops.comment", + "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.rotate", "key": "insert", "mac": "F13", - "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.deleteLeft", "key": "backspace", - "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.deleteRight", "key": "delete", - "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.toggle", "key": "Ctrl+Shift+i", "mac": "Cmd+Shift+i", - "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" } ], "menus": { @@ -703,13 +704,20 @@ "test-compile": "tsc -p ./", "test": "sh ./scripts/e2e.sh" }, + "dependencies": {}, "devDependencies": { "@types/mocha": "^9.1.0", "@types/node": "^16.18.34", - "@typescript-eslint/eslint-plugin": "^5.54.0", - "@typescript-eslint/parser": "^5.54.0", - "esbuild": "^0.19.5", - "eslint": "^8.35.0", + "@typescript-eslint/eslint-plugin": "^6.17.0", + "@typescript-eslint/parser": "^6.17.0", + "esbuild": "^0.19.11", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-config-standard-with-typescript": "^43.0.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-n": "^16.6.1", + "eslint-plugin-prettier": "^5.1.2", + "eslint-plugin-promise": "^6.1.1", "mocha": "^9.2.1", "typescript": "^5.1.3" } diff --git a/spin2/scripts/TEST-package.json b/spin2/scripts/TEST-package.json index a215009..06aa003 100644 --- a/spin2/scripts/TEST-package.json +++ b/spin2/scripts/TEST-package.json @@ -4,7 +4,7 @@ "description": "P1 and P2 Spin/Pasm Syntax/Semantic Highlighting w/Code Outline, Object Outline and Custom tabbing support", "author": "IronSheep", "license": "MIT", - "version": "2.2.13", + "version": "2.2.14", "repository": { "type": "git", "url": "https://github.com/ironsheep/P2-vscode-langserv-extension" @@ -41,15 +41,15 @@ "title": "Spin2: Generate documentation file from spin source" }, { - "command": "spinExtension.indentTabStop", + "command": "spinExtension.elasticTabstops.indentTabStop", "title": "Spin2: Indent tab stop" }, { - "command": "spinExtension.outdentTabStop", + "command": "spinExtension.elasticTabstops.outdentTabStop", "title": "Spin2: Outdent tab stop" }, { - "command": "spinExtension.generate.tabStops.comment", + "command": "spinExtension.elasticTabstops.generate.tabStops.comment", "title": "Spin2: Generate and insert tab stop comment" }, { @@ -123,12 +123,12 @@ { "title": "Spin/Spin2 Editor Tabstops", "properties": { - "spinExtension.ElasticTabstops.enable": { + "spinExtension.elasticTabstops.enable": { "type": "boolean", "default": false, "description": "Enable the use of Spin2 Tabstops along with [Insert|Overtype|Align] insert modes." }, - "spinExtension.ElasticTabstops.choice": { + "spinExtension.elasticTabstops.choice": { "type": "string", "default": "PropellerTool", "enum": [ @@ -138,7 +138,7 @@ ], "description": "Select the set of Tabstops you wish to use." }, - "spinExtension.ElasticTabstops.blocks.PropellerTool": { + "spinExtension.elasticTabstops.blocks.PropellerTool": { "type": "object", "properties": { "type": "array", @@ -224,7 +224,7 @@ } } }, - "spinExtension.ElasticTabstops.blocks.IronSheep": { + "spinExtension.elasticTabstops.blocks.IronSheep": { "type": "object", "properties": { "type": "array", @@ -319,7 +319,7 @@ } } }, - "spinExtension.ElasticTabstops.blocks.User1": { + "spinExtension.elasticTabstops.blocks.User1": { "type": "object", "properties": { "type": "array", @@ -412,22 +412,22 @@ { "title": "Spin/Spin2 TabStop Insert Mode Configuration", "properties": { - "spinExtension.InsertMode.overtypePaste": { + "spinExtension.insertMode.overtypePaste": { "type": "boolean", "default": false, "description": "Enable use of overtype behavior when pasting text while in \"Overtype\" Mode." }, - "spinExtension.InsertMode.perEditor": { + "spinExtension.insertMode.perEditor": { "type": "boolean", "default": false, "description": "Enable the setting of insert/overtype/align mode \"per editor\"." }, - "spinExtension.InsertMode.enableAlign": { + "spinExtension.insertMode.enableAlign": { "type": "boolean", "default": true, "description": "Enable Editor \"Align\" behavior." }, - "spinExtension.InsertMode.secondaryCursorStyle": { + "spinExtension.insertMode.secondaryCursorStyle": { "type": "string", "default": "block", "enum": [ @@ -440,7 +440,7 @@ ], "description": "Select the \"Overtype\" Mode cursor style." }, - "spinExtension.InsertMode.ternaryCursorStyle": { + "spinExtension.insertMode.ternaryCursorStyle": { "type": "string", "default": "underline", "enum": [ @@ -453,17 +453,17 @@ ], "description": "Select the \"Align\" Mode cursor style." }, - "spinExtension.InsertMode.labelInsertMode": { + "spinExtension.insertMode.labelInsertMode": { "type": "string", "default": "Insert", "description": "Label text in the status bar shown during \"Insert\" Mode (may be empty to hide the status.)" }, - "spinExtension.InsertMode.labelOvertypeMode": { + "spinExtension.insertMode.labelOvertypeMode": { "type": "string", "default": "Overtype", "description": "Label text in the status bar shown during \"Overtype\" Mode (may be empty to hide the status.)" }, - "spinExtension.InsertMode.labelAlignMode": { + "spinExtension.insertMode.labelAlignMode": { "type": "string", "default": "Align", "description": "Label text in the status bar shown during \"Align\" Mode (may be empty to hide the status.)" @@ -484,40 +484,40 @@ }, { "key": "tab", - "command": "spinExtension.indentTabStop", - "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !editorHoverFocused && !editorHoverVisible && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.indentTabStop", + "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !editorHoverFocused && !editorHoverVisible && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "key": "Shift+tab", - "command": "spinExtension.outdentTabStop", - "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.outdentTabStop", + "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "key": "Ctrl+Alt+tab", - "command": "spinExtension.generate.tabStops.comment", - "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "command": "spinExtension.elasticTabstops.generate.tabStops.comment", + "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.rotate", "key": "insert", "mac": "F13", - "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.deleteLeft", "key": "backspace", - "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.deleteRight", "key": "delete", - "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorTextFocus && !editorReadonly && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" }, { "command": "spinExtension.insertMode.toggle", "key": "Ctrl+Shift+i", "mac": "Cmd+Shift+i", - "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.ElasticTabstops.enable == true" + "when": "editorFocus && (editorLangId == spin || editorLangId == spin2) && config.spinExtension.elasticTabstops.enable == true" } ], "menus": { @@ -697,9 +697,15 @@ "devDependencies": { "@types/mocha": "^9.1.0", "@types/node": "^16.18.34", - "@typescript-eslint/eslint-plugin": "^5.54.0", - "@typescript-eslint/parser": "^5.54.0", - "eslint": "^8.35.0", + "@typescript-eslint/eslint-plugin": "^6.17.0", + "@typescript-eslint/parser": "^6.17.0", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-config-standard-with-typescript": "^43.0.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-n": "^16.6.1", + "eslint-plugin-prettier": "^5.1.2", + "eslint-plugin-promise": "^6.1.1", "mocha": "^9.2.1", "typescript": "^5.1.3" } diff --git a/spin2/server/src/DocumentProcessor.ts b/spin2/server/src/DocumentProcessor.ts index 6893e88..f5d46d9 100644 --- a/spin2/server/src/DocumentProcessor.ts +++ b/spin2/server/src/DocumentProcessor.ts @@ -1,19 +1,19 @@ -"use strict"; +'use strict'; // server/src/spin.serverBehavior.configuration.ts //import * as lsp from "vscode-languageserver"; -import { TextDocument } from "vscode-languageserver-textdocument"; +import { TextDocument } from 'vscode-languageserver-textdocument'; -import { readDocumentFromUri, resolveReferencedIncludes } from "./files"; -import { Context } from "./context"; -import { DocumentFindings } from "./parser/spin.semantic.findings"; -import { Spin1DocumentSymbolParser } from "./parser/spin1.documentSymbolParser"; -import { Spin2DocumentSymbolParser } from "./parser/spin2.documentSymbolParser"; -import { Spin1DocumentSemanticParser } from "./parser/spin1.documentSemanticParser"; -import { Spin2DocumentSemanticParser } from "./parser/spin2.documentSemanticParser"; -import { Spin2ObjectReferenceParser } from "./parser/spin.objectReferenceParser"; -import { isSpin1File, fileSpecFromURI } from "./parser/lang.utils"; -import * as path from "path"; +import { readDocumentFromUri, resolveReferencedIncludes } from './files'; +import { Context } from './context'; +import { DocumentFindings } from './parser/spin.semantic.findings'; +import { Spin1DocumentSymbolParser } from './parser/spin1.documentSymbolParser'; +import { Spin2DocumentSymbolParser } from './parser/spin2.documentSymbolParser'; +import { Spin1DocumentSemanticParser } from './parser/spin1.documentSemanticParser'; +import { Spin2DocumentSemanticParser } from './parser/spin2.documentSemanticParser'; +import { Spin2ObjectReferenceParser } from './parser/spin.objectReferenceParser'; +import { isSpin1File, fileSpecFromURI } from './parser/lang.utils'; +import * as path from 'path'; // ---------------------------------------------------------------------------- // Tracking an OPEN document @@ -57,7 +57,7 @@ export class ProcessedDocument { } public referencedFileSpec(fsIndex: number): string { - let desiredFSpec: string = ""; + let desiredFSpec: string = ''; if (fsIndex >= 0 && fsIndex <= this.includeFileSpecs.length) { desiredFSpec = this.includeFileSpecs[fsIndex]; } @@ -120,7 +120,7 @@ export default class DocumentProcessor { } if (didUpdate) { this.ctx.logger.log(`TRC: DP.reparseAllDocs() updating open files`); - const SEMANTIC_SYMBOLS_REFRESH_REQUEST: string = "workspace/semanticTokens/refresh"; + const SEMANTIC_SYMBOLS_REFRESH_REQUEST: string = 'workspace/semanticTokens/refresh'; await this.ctx.connection.sendRequest(SEMANTIC_SYMBOLS_REFRESH_REQUEST); } } @@ -142,20 +142,20 @@ export default class DocumentProcessor { } if (didUpdate) { this.ctx.logger.log(`TRC: DP.reparseAllDocs() updating open files`); - const SEMANTIC_SYMBOLS_REFRESH_REQUEST: string = "workspace/semanticTokens/refresh"; + const SEMANTIC_SYMBOLS_REFRESH_REQUEST: string = 'workspace/semanticTokens/refresh'; await this.ctx.connection.sendRequest(SEMANTIC_SYMBOLS_REFRESH_REQUEST); } } async processEnclosing(includeUri: string): Promise { - const includedFilename: string = path.basename(includeUri); + //const includedFilename: string = path.basename(includeUri); const includeFSpec: string = fileSpecFromURI(includeUri); this.ctx.logger.log(`TRC: DP.processEnclosing() search includeFSpec=[${includeFSpec}]`); - let bDidUpdates: boolean = false; + //let bDidUpdates: boolean = false; const updatedEnclsingUris: string[] = []; for (const [docUri, processedDocument] of this.ctx.docsByFSpec) { - const enclosingFilename: string = path.basename(docUri); - const enclosingFSpec: string = fileSpecFromURI(docUri); + //const enclosingFilename: string = path.basename(docUri); + //const enclosingFSpec: string = fileSpecFromURI(docUri); this.ctx.logger.log(`TRC: DP.processEnclosing() CHECKING [${docUri}]`); this.ctx.logger.log(`TRC: DP ------------------ included files: [${JSON.stringify(processedDocument.referencedFileSpecs)}]`); for (let index = 0; index < processedDocument.referencedFileSpecsCount; index++) { @@ -166,13 +166,13 @@ export default class DocumentProcessor { updatedEnclsingUris.push(processedDocument.document.uri); // process parent after include file change [using isInclude:false, skipIncludeScan:true] await this.process(processedDocument.document, false, true); - bDidUpdates = true; + //bDidUpdates = true; } } } // if we just updated underlying documents an parent, send refresh request to client //if (bDidUpdates) { - const SEMANTIC_SYMBOLS_REFRESH_REQUEST: string = "workspace/semanticTokens/refresh"; + const SEMANTIC_SYMBOLS_REFRESH_REQUEST: string = 'workspace/semanticTokens/refresh'; //const DIAGNOTICS_REFRESH_REQUEST: string = "workspace/codeLens/refresh"; //await this.ctx.connection.sendRequest(DIAGNOTICS_REFRESH_REQUEST); await this.ctx.connection.sendRequest(SEMANTIC_SYMBOLS_REFRESH_REQUEST); @@ -183,14 +183,14 @@ export default class DocumentProcessor { async updateFindings(docUri: string) { this.ctx.logger.log(`TRC: DP.updateFindings(${docUri})`); const docFSpec: string = fileSpecFromURI(docUri); - let tmpFindingsForDocument: DocumentFindings | undefined = this.ctx.findingsByFSpec.get(docFSpec); + const tmpFindingsForDocument: DocumentFindings | undefined = this.ctx.findingsByFSpec.get(docFSpec); if (!tmpFindingsForDocument) { return; } const currDocumentFindings: DocumentFindings = tmpFindingsForDocument; const processedDoc = this.ctx.docsByFSpec.get(docFSpec); if (processedDoc) { - await this._parseDocument(processedDoc, "Update-Parse", currDocumentFindings); + await this._parseDocument(processedDoc, 'Update-Parse', currDocumentFindings); } } @@ -227,7 +227,7 @@ export default class DocumentProcessor { if (skipIncludeScan == false) { // do first pass parse to fill in DocumentFindings with list of object references (includes) - const languageId: string = isSpin1File(docFSpec) ? "Spin1" : "Spin2"; + const languageId: string = isSpin1File(docFSpec) ? 'Spin1' : 'Spin2'; this.ctx.logger.log(`TRC: Object Scan of ${languageId} Document: ${docFSpec}`); this.spin2ObjectReferenceParser.locatReferencedObjects(document, currDocumentFindings); // for objects included } @@ -273,20 +273,29 @@ export default class DocumentProcessor { // add included documents to our map // this.ctx.logger.log(`TRC: -- STEP incorporate included docs into maps ...`); - const objectReferences: Map = skipIncludeScan == false ? currDocumentFindings.includeObjectNamesByFilename() : new Map(); - this.ctx.logger.log(`TRC: [${currDocumentFindings.instanceName()}] nameHashKeys=[${Array.from(objectReferences.keys())}], nameHashValues=[${Array.from(objectReferences.values())}]`); + const objectReferences: Map = + skipIncludeScan == false ? currDocumentFindings.includeObjectNamesByFilename() : new Map(); + this.ctx.logger.log( + `TRC: [${currDocumentFindings.instanceName()}] nameHashKeys=[${Array.from(objectReferences.keys())}], nameHashValues=[${Array.from( + objectReferences.values() + )}]` + ); const objectNames: string[] = Array.from(objectReferences.keys()); const objectFileNames: string[] = Array.from(objectReferences.values()); this.ctx.logger.log( - `TRC: DP.process() hook-in includes for [${currDocumentFindings.instanceName()}] objectNames=[${Array.from(objectNames)}] objectFileNames=[${Array.from(objectFileNames)}]` + `TRC: DP.process() hook-in includes for [${currDocumentFindings.instanceName()}] objectNames=[${Array.from( + objectNames + )}] objectFileNames=[${Array.from(objectFileNames)}]` ); currDocumentFindings.clear(this.PARM_ALL_BUT_INCLUDES); // now clear it out for reload after we have includes - this.ctx.logger.log(`TRC: [${currDocumentFindings.instanceName()}] clear() previous findings but NOT include info so can load included documents`); + this.ctx.logger.log( + `TRC: [${currDocumentFindings.instanceName()}] clear() previous findings but NOT include info so can load included documents` + ); for (let index = 0; index < objectNames.length; index++) { const objectName = objectNames[index]; const objectSpinFilename = objectFileNames[index]; let matchFilename: string = objectSpinFilename.toLowerCase(); - if (!matchFilename?.toLowerCase().includes(".spin")) { + if (!matchFilename?.toLowerCase().includes('.spin')) { matchFilename = `${matchFilename}.`.toLowerCase(); } this.ctx.logger.log(`TRC: MATCHING objectName=[${objectName}], matchFilename=[${matchFilename}]`); @@ -298,7 +307,9 @@ export default class DocumentProcessor { // located, now add parse results for include to this document map of includes const processedInclude = this.ctx.docsByFSpec.get(fSpec); if (processedInclude) { - this.ctx.logger.log(`TRC: registering [${objectName}]: [${processedInclude.parseResult.instanceName()}]: with=[${currDocumentFindings.instanceName()}]`); + this.ctx.logger.log( + `TRC: registering [${objectName}]: [${processedInclude.parseResult.instanceName()}]: with=[${currDocumentFindings.instanceName()}]` + ); currDocumentFindings.enableLogging(this.ctx, true); currDocumentFindings.setFindingsForNamespace(objectName, processedInclude.parseResult); currDocumentFindings.enableLogging(this.ctx, false); @@ -317,7 +328,7 @@ export default class DocumentProcessor { } // do actual parse to fill in DocumentFindings - const parseReason: string = skipIncludeScan == false ? "Actual-Parse" : "Reload(includes-updated)"; + const parseReason: string = skipIncludeScan == false ? 'Actual-Parse' : 'Reload(includes-updated)'; await this._parseDocument(currDocumentInProcess, parseReason, currDocumentFindings); this.ctx.logger.log(`TRC: DP.process() DONE processing [${currDocumentFindings.instanceName()}]`); diff --git a/spin2/server/src/context.ts b/spin2/server/src/context.ts index 7be7e65..29f269b 100644 --- a/spin2/server/src/context.ts +++ b/spin2/server/src/context.ts @@ -1,8 +1,8 @@ -"use strict"; +'use strict'; // src/context.ts -import * as lsp from "vscode-languageserver"; -import { ProcessedDocumentByFSpec, DocumentFindingsByFSpec, TopDocsByFSpec } from "./DocumentProcessor"; +import * as lsp from 'vscode-languageserver'; +import { ProcessedDocumentByFSpec, DocumentFindingsByFSpec, TopDocsByFSpec } from './DocumentProcessor'; //import Parser from "web-tree-sitter"; //import path from "path"; @@ -33,7 +33,7 @@ export interface Context { editorConfig: EditorConfiguration; } -let language: string = "spin2"; +const language: string = 'spin2'; export async function createContext(workspaceFolders: lsp.WorkspaceFolder[], logger: lsp.Logger, connection: lsp.Connection): Promise { /* @@ -62,6 +62,6 @@ export async function createContext(workspaceFolders: lsp.WorkspaceFolder[], log logger, connection, parserConfig: new ServerBehaviorConfiguration(), - editorConfig: new EditorConfiguration(), + editorConfig: new EditorConfiguration() }; } diff --git a/spin2/server/src/files.ts b/spin2/server/src/files.ts index 92ecce3..17e709d 100644 --- a/spin2/server/src/files.ts +++ b/spin2/server/src/files.ts @@ -1,16 +1,16 @@ -"use strict"; +'use strict'; // server/src/files.ts -import { TextDocument } from "vscode-languageserver-textdocument"; +import { TextDocument } from 'vscode-languageserver-textdocument'; //import { constants, promises as fsp, fs } from "fs"; //import { extname, resolve, dirname } from "path"; -import * as fs from "fs"; -import * as path from "path"; +import * as fs from 'fs'; +import * as path from 'path'; //import * as ic from "iconv"; -import { fileURLToPath } from "url"; -import { Context } from "./context"; +import { fileURLToPath } from 'url'; +import { Context } from './context'; -const { readFile, access } = fs.promises; +const { access } = fs.promises; export async function exists(filePath: string): Promise { return access(filePath).then( @@ -20,16 +20,16 @@ export async function exists(filePath: string): Promise { } export function isSpin1File(fileSpec: string): boolean { - let spinFileStatus: boolean = fileSpec.toLowerCase().endsWith(".spin"); + const spinFileStatus: boolean = fileSpec.toLowerCase().endsWith('.spin'); return spinFileStatus; } export function readDocumentFromUri(uri: string, ctx: Context): TextDocument | null { let content: string; - const url = new URL(uri, "file://"); + const url = new URL(uri, 'file://'); ctx.logger.log(`TRC: readDocumentFromUri() url=[${url}]`); - const languageId = isSpin1File(uri) ? "Spin" : "Spin2"; + const languageId = isSpin1File(uri) ? 'Spin' : 'Spin2'; const fspec: string = fileURLToPath(url); ctx.logger.log(`TRC: readDocumentFromUri() fspec=[${fspec}]`); @@ -44,7 +44,7 @@ export function readDocumentFromUri(uri: string, ctx: Context): TextDocument | n return TextDocument.create(uri, languageId, 0, content); } -type ResolveContext = Pick; +//type ResolveContext = Pick; /** * convert list of filenames (possibly without type) to filespecs @@ -52,7 +52,7 @@ type ResolveContext = Pick; export function resolveReferencedIncludes(includedFiles: string[], rootDirSpec: string, ctx: Context): string[] { //const roots = ctx.workspaceFolders.map((f) => URI.parse(f.uri).fsPath); - const rootDir = ctx.workspaceFolders[0]; + //const rootDir = ctx.workspaceFolders[0]; const matchedFiles: string[] = []; ctx.logger.log(`TRC: resolveReferencedIncludes(includedFiles=[${includedFiles}], rootDirSpec=[${rootDirSpec}])`); @@ -61,13 +61,13 @@ export function resolveReferencedIncludes(includedFiles: string[], rootDirSpec: for (let index = 0; index < includedFiles.length; index++) { const fileBaseName = includedFiles[index]; let matchFilename: string = fileBaseName.toLowerCase(); - if (!fileBaseName.toLowerCase().includes(".spin")) { + if (!fileBaseName.toLowerCase().includes('.spin')) { matchFilename = `${fileBaseName}.`.toLowerCase(); } //ctx.logger.log(`TRC: looking for matchFilename=[${matchFilename}]`); for (let index = 0; index < fileSpecs.length; index++) { const fileSpec: string = fileSpecs[index]; - const pathParts: string[] = fileSpec.split("/"); + const pathParts: string[] = fileSpec.split('/'); const fileName = pathParts[pathParts.length - 1].toLowerCase(); //ctx.logger.log(`TRC: checking fileSpec=[${fileSpec}]`); if (fileName.startsWith(matchFilename)) { @@ -124,13 +124,13 @@ export function loadFileAsStringzzz(fspec: string, ctx: Context): string { */ export function loadFileAsString(fspec: string, ctx: Context): string { - let fileContent: string = ""; + let fileContent: string = ''; if (fs.existsSync(fspec)) { ctx.logger.log(`TRC: loadFileAsString() attempt load of [${fspec}]`); try { - fileContent = fs.readFileSync(fspec, "utf-8"); - if (fileContent.includes("\x00")) { - fileContent = fs.readFileSync(fspec, "utf16le"); + fileContent = fs.readFileSync(fspec, 'utf-8'); + if (fileContent.includes('\x00')) { + fileContent = fs.readFileSync(fspec, 'utf16le'); } } catch (err) { ctx.logger.log(`TRC: loadFileAsString() EXCEPTION: err=[${err}]`); @@ -145,7 +145,7 @@ export function loadFileAsString(fspec: string, ctx: Context): string { * Check whether file extension is SPIN source file */ export function isSpinExt(filename: string): boolean { - return [".spin", ".spin2", ".p2asm"].includes(path.extname(filename).toLowerCase()); + return ['.spin', '.spin2', '.p2asm'].includes(path.extname(filename).toLowerCase()); } export function spin1FileExists(dirSpec: string, fileName: string): boolean { @@ -153,7 +153,7 @@ export function spin1FileExists(dirSpec: string, fileName: string): boolean { if (dirSpec.length > 0) { // NOTE: dirSpec.length can be zero if caller not yet set up correctly let desiredFilename: string = fileName; - if (!fileName.toLowerCase().includes(".spin")) { + if (!fileName.toLowerCase().includes('.spin')) { desiredFilename = `${fileName}.spin`; } existsStatus = fileInDirExists(dirSpec, desiredFilename); @@ -166,7 +166,7 @@ export function spin2FileExists(dirSpec: string, fileName: string): boolean { if (dirSpec.length > 0) { // NOTE: dirSpec.length can be zero if caller not yet set up correctly let desiredFilename: string = fileName; - if (!fileName.toLowerCase().includes(".spin2")) { + if (!fileName.toLowerCase().includes('.spin2')) { desiredFilename = `${fileName}.spin2`; } existsStatus = fileInDirExists(dirSpec, desiredFilename); @@ -176,7 +176,7 @@ export function spin2FileExists(dirSpec: string, fileName: string): boolean { export function fileInDirExists(dirSpec: string, fileName: string, ctx: Context | undefined = undefined): boolean { let existsStatus: boolean = false; - const url = new URL(path.join(dirSpec, fileName), "file://"); + const url = new URL(path.join(dirSpec, fileName), 'file://'); const fspec: string = fileURLToPath(url); if (fileExists(fspec)) { // File exists in path @@ -199,7 +199,7 @@ export function fileExists(pathSpec: string): boolean { export function getSpinFilesInDirSync(dirSpec: string, ctx: Context): string[] { const resultList: string[] = []; - const url = new URL(dirSpec, "file://"); + const url = new URL(dirSpec, 'file://'); //const pathSpec = fileURLToPath(dirSpec); if (fs.existsSync(url)) { // Dir exists ... @@ -220,7 +220,7 @@ export function getSpinFilesInDirSync(dirSpec: string, ctx: Context): string[] { */ export async function getSpinFilesInDir(dirSpec: string): Promise { const result: string[] = []; - const url = new URL(dirSpec, "file://"); + const url = new URL(dirSpec, 'file://'); try { await fs.promises.access(url, fs.constants.R_OK); diff --git a/spin2/server/src/geometry.ts b/spin2/server/src/geometry.ts index 093d984..4736b4e 100644 --- a/spin2/server/src/geometry.ts +++ b/spin2/server/src/geometry.ts @@ -1,4 +1,4 @@ -import * as lsp from "vscode-languageserver"; +import * as lsp from 'vscode-languageserver'; //import type Parser from "web-tree-sitter"; /** diff --git a/spin2/server/src/parser/lang.utils.ts b/spin2/server/src/parser/lang.utils.ts index b8c338f..6c00e06 100644 --- a/spin2/server/src/parser/lang.utils.ts +++ b/spin2/server/src/parser/lang.utils.ts @@ -1,37 +1,37 @@ -"use strict"; +'use strict'; // server/src/parser/lang.utils.ts export function isSpinOrPasmFile(fileSpec: string): boolean { - let spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec) || isPasmFile(fileSpec); + const spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec) || isPasmFile(fileSpec); return spinDocumentStatus; } function isPasmFile(fileSpec: string): boolean { - let spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith(".p2asm"); + const spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith('.p2asm'); return spinDocumentStatus; } export function isSpinFile(fileSpec: string): boolean { - let spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec); + const spinDocumentStatus: boolean = isSpin1File(fileSpec) || isSpin2File(fileSpec); return spinDocumentStatus; } export function isSpin1File(fileSpec: string): boolean { - let spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith(".spin"); + const spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith('.spin'); return spinDocumentStatus; } export function isSpin2File(fileSpec: string): boolean { - let spinDocumentStatus: boolean = isSpin2ORPasm(fileSpec); + const spinDocumentStatus: boolean = isSpin2ORPasm(fileSpec); return spinDocumentStatus; } function isSpin2ORPasm(fileSpec: string): boolean { - let spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith(".spin2") || fileSpec.toLowerCase().endsWith(".p2asm"); + const spinDocumentStatus: boolean = fileSpec.toLowerCase().endsWith('.spin2') || fileSpec.toLowerCase().endsWith('.p2asm'); return spinDocumentStatus; } export function fileSpecFromURI(docUri: string): string { - const spaceRegEx = /\%20/g; // we are globally replacing %20 markers + const spaceRegEx = /%20/g; // we are globally replacing %20 markers const fileRegEx = /^file:\/\//i; // remove leading "file://", case-insensative - return docUri.replace(fileRegEx, "").replace(spaceRegEx, " "); + return docUri.replace(fileRegEx, '').replace(spaceRegEx, ' '); } diff --git a/spin2/server/src/parser/lsp.textDocument.utils.ts b/spin2/server/src/parser/lsp.textDocument.utils.ts index 5f9013d..f47cc7a 100644 --- a/spin2/server/src/parser/lsp.textDocument.utils.ts +++ b/spin2/server/src/parser/lsp.textDocument.utils.ts @@ -1,15 +1,15 @@ -"use strict"; +'use strict'; // src/parser/spin2.utils.ts -import * as lsp from "vscode-languageserver"; -import { TextDocument } from "vscode-languageserver-textdocument"; +import * as lsp from 'vscode-languageserver'; +import { TextDocument } from 'vscode-languageserver-textdocument'; export function GetWordRangeAtPosition(lineText: string, position: lsp.Position, isSpin1File: boolean = false): lsp.Range { // return rage of word found at position let startIndex: number = position.character; let endIndex: number = position.character; - const wordEndCharacterSetP1: string = "\"'[](){}<> |^&@\t,+-*/\\="; - const wordEndCharacterSetP2: string = "\"'[](){}<> |^&#@\t,+-*/\\=:"; + const wordEndCharacterSetP1: string = '"\'[](){}<> |^&@\t,+-*/\\='; + const wordEndCharacterSetP2: string = '"\'[](){}<> |^&#@\t,+-*/\\=:'; const checkCharSet: string = isSpin1File ? wordEndCharacterSetP1 : wordEndCharacterSetP2; // back up to start of word, mark start @@ -39,7 +39,10 @@ export function GetWordRangeAtPosition(lineText: string, position: lsp.Position, } // returning findings - let wordRange: lsp.Range = { start: { line: position.line, character: startIndex }, end: { line: position.line, character: endIndex } }; + const wordRange: lsp.Range = { + start: { line: position.line, character: startIndex }, + end: { line: position.line, character: endIndex } + }; return wordRange; } @@ -55,13 +58,19 @@ export function PositionIsAfter(lhPosition: lsp.Position, rhPosition: lsp.Positi export function PositionTranslate(position: lsp.Position, lineOffset: number, charOffset: number): lsp.Position { // return position adjusted by offsets - let adjustedPostion: lsp.Position = { line: position.line + lineOffset, character: position.character + charOffset }; + const adjustedPostion: lsp.Position = { + line: position.line + lineOffset, + character: position.character + charOffset + }; return adjustedPostion; } export function DocumentLineAt(document: TextDocument, position: lsp.Position): string { // return the full line at given document position - const desiredLineRange: lsp.Range = { start: { line: position.line, character: 0 }, end: { line: position.line, character: Number.MAX_VALUE } }; + const desiredLineRange: lsp.Range = { + start: { line: position.line, character: 0 }, + end: { line: position.line, character: Number.MAX_VALUE } + }; const lineText = document.getText(desiredLineRange); return lineText; } diff --git a/spin2/server/src/parser/spin.common.ts b/spin2/server/src/parser/spin.common.ts index 348ef12..adf177f 100644 --- a/spin2/server/src/parser/spin.common.ts +++ b/spin2/server/src/parser/spin.common.ts @@ -1,9 +1,9 @@ -"use strict"; +'use strict'; // server/src/parser/spin.semantic.findings.ts -import { Position } from "vscode-languageserver-types"; -import { Context } from "../context"; -import { timeStamp } from "console"; +import { Position } from 'vscode-languageserver-types'; +import { Context } from '../context'; +//import { timeStamp } from 'console'; //import { listenerCount } from "process"; export enum eDebugDisplayType { @@ -16,7 +16,7 @@ export enum eDebugDisplayType { ddtPlot, ddtTerm, ddtBitmap, - ddtMidi, + ddtMidi } export enum eBuiltInType { @@ -31,7 +31,7 @@ export enum eBuiltInType { BIT_PASM_DIRECTIVE, BIT_SYMBOL, BIT_TYPE, - BIT_VARIABLE, + BIT_VARIABLE } export enum eParseState { @@ -46,7 +46,7 @@ export enum eParseState { inDatPAsm, inMultiLineComment, inMultiLineDocComment, - inNothing, + inNothing } export enum eControlFlowType { @@ -54,7 +54,7 @@ export enum eControlFlowType { inCase, inCaseFast, inRepeat, - inIf, + inIf } export interface ICurrControlStatement { @@ -89,22 +89,27 @@ export function isMethodCall(line: string): boolean { return methodOpenRegEx.test(line); } +export function isMethodCallEmptyParens(line: string): boolean { + const methodOpenRegEx = /^\s*\(\)/; // match zero or more whitespace before '()' from left edge of string + return methodOpenRegEx.test(line); +} + export function containsSpinLanguageSpec(line: string): boolean { // return T/F where T means {Spin2_v##} was found in given string - const languageVersionRegEx = /\{Spin2\_v/i; // our version specification (just look for left edge) + const languageVersionRegEx = /\{Spin2_v/i; // our version specification (just look for left edge) return languageVersionRegEx.test(line); } export function versionFromSpinLanguageSpec(line: string): number { // return T/F where T means {Spin2_v##} was found in given string let decodedVersion: number = 0; // return no version by default - const languageVersionRegEx = /\{Spin2\_v[0-9][0-9]\}/i; // our version specification - well formatted 0-99 - const languageVersionThousandsRegEx = /\{Spin2\_v[0-9][0-9][0-9]\}/i; // our version specification - well formatted 0-999 + const languageVersionRegEx = /\{Spin2_v[0-9][0-9]\}/i; // our version specification - well formatted 0-99 + const languageVersionThousandsRegEx = /\{Spin2_v[0-9][0-9][0-9]\}/i; // our version specification - well formatted 0-999 const is3digit: boolean = languageVersionThousandsRegEx.test(line); // if have fully formatted version if (languageVersionRegEx.test(line) || is3digit) { if (containsSpinLanguageSpec(line)) { - const matchText: string = "{Spin2_v".toLowerCase(); + const matchText: string = '{Spin2_v'.toLowerCase(); const verOffset: number = line.toLowerCase().indexOf(matchText); if (verOffset != -1) { if (is3digit) { @@ -158,7 +163,11 @@ export class SpinControlFlowTracker { public startControlFlow(name: string, startLineCharOffset: number, startLineIdx: number) { // record start of possible nest flow control statements this._logMessage(`- SFlowCtrl: start([${name}], ofs=${startLineCharOffset}, Ln#${startLineIdx + 1})`); - const flowItem: ICurrControlStatement = { startLineIdx: startLineIdx, startLineCharOffset: startLineCharOffset, type: this.typeForControlFlowName(name) }; + const flowItem: ICurrControlStatement = { + startLineIdx: startLineIdx, + startLineCharOffset: startLineCharOffset, + type: this.typeForControlFlowName(name) + }; this.flowStatementStack.push(flowItem); } @@ -174,7 +183,10 @@ export class SpinControlFlowTracker { if (this.flowStatementStack.length > 0) { do { const currStatement: ICurrControlStatement = this.flowStatementStack[this.flowStatementStack.length - 1]; - const newClosedSpan: ICurrControlSpan = { startLineIdx: currStatement.startLineIdx, endLineIdx: endLineIdx }; + const newClosedSpan: ICurrControlSpan = { + startLineIdx: currStatement.startLineIdx, + endLineIdx: endLineIdx + }; closedFlowSpans.push(newClosedSpan); this.flowStatementStack.pop(); } while (this.flowStatementStack.length > 0); @@ -204,7 +216,10 @@ export class SpinControlFlowTracker { endThisNesting = delayClose ? false : true; } if (endThisNesting) { - const newClosedSpan: ICurrControlSpan = { startLineIdx: currStatement.startLineIdx, endLineIdx: endLineIdx - 1 }; + const newClosedSpan: ICurrControlSpan = { + startLineIdx: currStatement.startLineIdx, + endLineIdx: endLineIdx - 1 + }; this._logMessage(`- SFlowCtrl: - close [Ln#${newClosedSpan.startLineIdx + 1} - ${newClosedSpan.endLineIdx + 1}]`); closedFlowSpans.push(newClosedSpan); this.flowStatementStack.pop(); @@ -223,9 +238,9 @@ export class SpinControlFlowTracker { private delayClose(name: string, type: eControlFlowType): boolean { let shouldDelay: boolean = false; if (type == eControlFlowType.inRepeat) { - if (name.toLowerCase() === "while") { + if (name.toLowerCase() === 'while') { shouldDelay = true; - } else if (name.toLowerCase() === "until") { + } else if (name.toLowerCase() === 'until') { shouldDelay = true; } } @@ -234,21 +249,21 @@ export class SpinControlFlowTracker { private typeForControlFlowName(name: string): eControlFlowType { let desiredType: eControlFlowType = eControlFlowType.Unknown; - if (name.toLowerCase() === "if") { + if (name.toLowerCase() === 'if') { desiredType = eControlFlowType.inIf; - } else if (name.toLowerCase() === "ifnot") { + } else if (name.toLowerCase() === 'ifnot') { desiredType = eControlFlowType.inIf; - } else if (name.toLowerCase() === "elseif") { + } else if (name.toLowerCase() === 'elseif') { desiredType = eControlFlowType.inIf; - } else if (name.toLowerCase() === "else") { + } else if (name.toLowerCase() === 'else') { desiredType = eControlFlowType.inIf; - } else if (name.toLowerCase() === "elseifnot") { + } else if (name.toLowerCase() === 'elseifnot') { desiredType = eControlFlowType.inIf; - } else if (name.toLowerCase() === "repeat") { + } else if (name.toLowerCase() === 'repeat') { desiredType = eControlFlowType.inRepeat; - } else if (name.toLowerCase() === "case") { + } else if (name.toLowerCase() === 'case') { desiredType = eControlFlowType.inCase; - } else if (name.toLowerCase() === "case_fast") { + } else if (name.toLowerCase() === 'case_fast') { desiredType = eControlFlowType.inCaseFast; } return desiredType; @@ -258,7 +273,7 @@ export class SpinControlFlowTracker { export class ContinuedLines { private rawLines: string[] = []; private rawLineIdxs: number[] = []; - private singleLine: string = ""; + private singleLine: string = ''; private haveAllLines: boolean = false; private isActive: boolean = false; private linesLogEnabled: boolean = false; @@ -275,7 +290,7 @@ export class ContinuedLines { //this._logMessage(` --- ContLn: Clear()`); this.rawLineIdxs = []; this.rawLines = []; - this.singleLine = ""; + this.singleLine = ''; this.haveAllLines = false; this.isActive = false; } @@ -287,7 +302,7 @@ export class ContinuedLines { if (!this.isActive) { this.isActive = true; } - if (!nextLine.endsWith("...")) { + if (!nextLine.endsWith('...')) { this.haveAllLines = true; this._finishLine(); } @@ -342,7 +357,7 @@ export class ContinuedLines { public lineAt(desiredLineIdx: number): string { // return all lines concatenated so we can parse it - let desiredLine: string = "{-CntLn-lineAt-ERROR-}"; + let desiredLine: string = '{-CntLn-lineAt-ERROR-}'; for (let index = 0; index < this.rawLineIdxs.length; index++) { const currlineIdx = this.rawLineIdxs[index]; if (currlineIdx == desiredLineIdx) { @@ -359,13 +374,12 @@ export class ContinuedLines { if (symbolPosition.line != -1 && symbolPosition.character != -1) { // work our way to the offset desiredOffset = 0; - let bFoundLine: boolean = false; let foundLineWhiteSpaceLength: number = 0; let foundIndex: number = 0; for (let index = 0; index < this.rawLines.length; index++) { const currLine = this.rawLines[index]; const currIdx = this.rawLineIdxs[index]; - const isLineContinued: boolean = currLine.endsWith("..."); + const isLineContinued: boolean = currLine.endsWith('...'); foundLineWhiteSpaceLength = this._skipWhite(currLine, 0); const currLineLength: number = isLineContinued ? this._lengthWithoutContinuation(currLine) + 1 : currLine.trim().length; // +1 is for concatenating " " // if the first line, don't take out the leading whitespace @@ -376,7 +390,6 @@ export class ContinuedLines { }), foundLineWhiteSpaceLength=(${foundLineWhiteSpaceLength}), desiredOffset=(${desiredOffset}), isLineContinued=(${isLineContinued})` ); if (currIdx == symbolPosition.line) { - bFoundLine = true; foundIndex = index; break; } @@ -384,7 +397,9 @@ export class ContinuedLines { } desiredOffset += foundIndex == 0 ? symbolPosition.character : symbolPosition.character - foundLineWhiteSpaceLength; } - this._logMessage(` --- ContLn: offsetIntoLineForPosition([line=(${symbolPosition.line}), char=(${symbolPosition.character})]) -> (${desiredOffset})`); + this._logMessage( + ` --- ContLn: offsetIntoLineForPosition([line=(${symbolPosition.line}), char=(${symbolPosition.character})]) -> (${desiredOffset})` + ); if (desiredOffset == -1) { this._logMessage(` --- ContLn: ERROR bad position given`); } @@ -397,17 +412,20 @@ export class ContinuedLines { let remainingOffset: number = offset; // subtract earlier line lengths from remainder to locate line our symbol is on this._logMessage( - ` --- ContLn: ENTRY locateSymbol([${symbolName}], srtOfs=(${offset})) - rawLines=(${this.rawLines.length}), Ln#${this.lineStartIdx + 1}-${this.lineStartIdx + this.rawLines.length}` + ` --- ContLn: ENTRY locateSymbol([${symbolName}], srtOfs=(${offset})) - rawLines=(${this.rawLines.length}), Ln#${this.lineStartIdx + 1}-${ + this.lineStartIdx + this.rawLines.length + }` ); for (let index = 0; index < this.rawLines.length; index++) { const rawPossContLine: string = this.rawLines[index]; - const isLineContinued: boolean = rawPossContLine.endsWith("..."); + const isLineContinued: boolean = rawPossContLine.endsWith('...'); const currLineLength: number = isLineContinued ? this._lengthWithoutContinuation(rawPossContLine) + 1 : rawPossContLine.trim().length; const foundLineWhiteSpaceLength = this._skipWhite(rawPossContLine, 0); // if the first line, don't take out the leading whitespace const accumLength = index == 0 ? foundLineWhiteSpaceLength + currLineLength : currLineLength; const trimmedLineContentOnly: string = isLineContinued ? rawPossContLine.slice(0, -3).trimEnd() : rawPossContLine.trimEnd(); - const remainingString: string = index == 0 ? trimmedLineContentOnly.substring(remainingOffset) : trimmedLineContentOnly.trimStart().substring(remainingOffset); + const remainingString: string = + index == 0 ? trimmedLineContentOnly.substring(remainingOffset) : trimmedLineContentOnly.trimStart().substring(remainingOffset); /* this._logMessage(` --- ContLn: ls() - CHECKING rawIdx=(${rawIdx}), remainingOffset=(${remainingOffset}), currLineLength=(${currLineLength}), isLineContinued=(${isLineContinued})`); this._logMessage(` --- ContLn: ls() - CHECKING continuedLine=[${rawPossContLine}](${rawPossContLine.length})`); @@ -457,7 +475,7 @@ export class ContinuedLines { private _skipWhite(line: string, currentOffset: number): number { let firstNonWhiteIndex: number = currentOffset; for (let index = currentOffset; index < line.length; index++) { - if (line.substr(index, 1) != " " && line.substr(index, 1) != "\t") { + if (line.substr(index, 1) != ' ' && line.substr(index, 1) != '\t') { firstNonWhiteIndex = index; break; } @@ -468,7 +486,7 @@ export class ContinuedLines { private _lengthWithoutContinuation(line: string): number { // remove leading white-space and trailing spaces so we only have 1 between ea. after lines joined let desiredLength: number = line.trim().length; - if (line.endsWith("...")) { + if (line.endsWith('...')) { const tempLine: string = line.slice(0, -3); desiredLength = tempLine.trim().length; } @@ -479,7 +497,7 @@ export class ContinuedLines { const nonContinusedStrings: string[] = []; for (let index = 0; index < this.rawLines.length; index++) { const continuedLine: string = this.rawLines[index]; - if (continuedLine.endsWith("...")) { + if (continuedLine.endsWith('...')) { if (index == 0) { // first line we don't left-trim nonContinusedStrings.push(continuedLine.slice(0, -3).trimEnd()); // removing "..." as we go @@ -492,7 +510,7 @@ export class ContinuedLines { nonContinusedStrings.push(continuedLine.trim()); } } - this.singleLine = nonContinusedStrings.join(" "); + this.singleLine = nonContinusedStrings.join(' '); } private _logMessage(message: string): void { diff --git a/spin2/server/src/parser/spin.extension.utils.ts b/spin2/server/src/parser/spin.extension.utils.ts index 7a0ac2e..ca9a173 100644 --- a/spin2/server/src/parser/spin.extension.utils.ts +++ b/spin2/server/src/parser/spin.extension.utils.ts @@ -1,12 +1,12 @@ -"use strict"; +'use strict'; // src/parser/spin2.utils.ts -import * as lsp from "vscode-languageserver"; -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Context } from "../context"; -import { GetWordRangeAtPosition, DocumentLineAt, PositionIsEqual, PositionIsAfter, PositionTranslate } from "./lsp.textDocument.utils"; -import { isSpin1File } from "./lang.utils"; -import { eParseState } from "./spin.common"; +import * as lsp from 'vscode-languageserver'; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Context } from '../context'; +import { GetWordRangeAtPosition, DocumentLineAt, PositionIsEqual, PositionIsAfter, PositionTranslate } from './lsp.textDocument.utils'; +import { isSpin1File } from './lang.utils'; +import { eParseState } from './spin.common'; export interface IPairs { start: number; @@ -36,8 +36,43 @@ export class ExtensionUtils { private bLogEnabled: boolean = false; private ctx: Context; - private spin1ControlFlowKeywords: string[] = ["if", "ifnot", "elseif", "elseifnot", "else", "while", "repeat", "until", "from", "to", "step", "next", "quit", "case", "other", "abort", "return"]; - private spin2ControlFlowKeywords: string[] = ["if", "ifnot", "elseif", "elseifnot", "else", "case", "case_fast", "repeat", "with", "from", "to", "step", "while", "until", "next", "quit"]; + private spin1ControlFlowKeywords: string[] = [ + 'if', + 'ifnot', + 'elseif', + 'elseifnot', + 'else', + 'while', + 'repeat', + 'until', + 'from', + 'to', + 'step', + 'next', + 'quit', + 'case', + 'other', + 'abort', + 'return' + ]; + private spin2ControlFlowKeywords: string[] = [ + 'if', + 'ifnot', + 'elseif', + 'elseifnot', + 'else', + 'case', + 'case_fast', + 'repeat', + 'with', + 'from', + 'to', + 'step', + 'while', + 'until', + 'next', + 'quit' + ]; public constructor(ctx: Context, isLogging: boolean) { this.ctx = ctx; @@ -57,20 +92,20 @@ export class ExtensionUtils { let inProgressState: eParseState = eParseState.Unknown; if (line.length > 2) { const sectionName: string = line.substring(0, 3).toUpperCase(); - const nextChar: string = line.length > 3 ? line.substring(3, 4) : " "; - if (nextChar.charAt(0).match(/[ \t'\{]/)) { + const nextChar: string = line.length > 3 ? line.substring(3, 4) : ' '; + if (nextChar.charAt(0).match(/[ \t'{]/)) { startStatus = true; - if (sectionName === "CON") { + if (sectionName === 'CON') { inProgressState = eParseState.inCon; - } else if (sectionName === "DAT") { + } else if (sectionName === 'DAT') { inProgressState = eParseState.inDat; - } else if (sectionName === "OBJ") { + } else if (sectionName === 'OBJ') { inProgressState = eParseState.inObj; - } else if (sectionName === "PUB") { + } else if (sectionName === 'PUB') { inProgressState = eParseState.inPub; - } else if (sectionName === "PRI") { + } else if (sectionName === 'PRI') { inProgressState = eParseState.inPri; - } else if (sectionName === "VAR") { + } else if (sectionName === 'VAR') { inProgressState = eParseState.inVar; } else { startStatus = false; @@ -82,7 +117,7 @@ export class ExtensionUtils { } return { isSectionStart: startStatus, - inProgressStatus: inProgressState, + inProgressStatus: inProgressState }; } @@ -94,8 +129,8 @@ export class ExtensionUtils { inPasmCodeStatus: boolean ): [boolean, string, string, lsp.Position, lsp.Position] { const lineText = DocumentLineAt(document, wordPosition).trimEnd(); - const P2_LOCAL_LABEL_PREFIX: string = "."; - const P1_LOCAL_LABEL_PREFIX: string = ":"; + const P2_LOCAL_LABEL_PREFIX: string = '.'; + const P1_LOCAL_LABEL_PREFIX: string = ':'; const spin1File: boolean = isSpin1File(document.uri); const localPasmLablePrefix: string = spin1File ? P1_LOCAL_LABEL_PREFIX : P2_LOCAL_LABEL_PREFIX; const spinControlFlowKeywords: string[] = spin1File ? this.spin1ControlFlowKeywords : this.spin2ControlFlowKeywords; @@ -104,42 +139,47 @@ export class ExtensionUtils { // do fixup for Spin2 pasm local labels if (wordRange?.start.character > 0 && lineText.charAt(wordRange.start.character - 1) == localPasmLablePrefix) { const newStart: lsp.Position = PositionTranslate(wordRange.start, 0, -1); - wordRange = { start: { line: newStart.line, character: newStart.character }, end: { line: wordRange?.end.line, character: wordRange?.end.character } }; + wordRange = { + start: { line: newStart.line, character: newStart.character }, + end: { line: wordRange?.end.line, character: wordRange?.end.character } + }; } } - const tmpWord: string = wordRange ? document.getText(wordRange) : ""; // trim() shouldn't be needed!!! - this._logMessage(`+ sp2Utils: adjustWordPosition([${wordPosition.line},${wordPosition.character}]) orig tmpWord=[${tmpWord}](${tmpWord.length}), isInBlockComment=(${isInBlockComment})`); + const tmpWord: string = wordRange ? document.getText(wordRange) : ''; // trim() shouldn't be needed!!! + this._logMessage( + `+ sp2Utils: adjustWordPosition([${wordPosition.line},${wordPosition.character}]) orig tmpWord=[${tmpWord}](${tmpWord.length}), isInBlockComment=(${isInBlockComment})` + ); let lineParts: string[] = [tmpWord]; let rangeDots: boolean = false; if (!tmpWord.charAt(0).match(/[a-zA-Z_]/) && !tmpWord.startsWith(localPasmLablePrefix)) { lineParts = []; } else { - if (tmpWord.includes("..")) { - lineParts = tmpWord.split(".."); + if (tmpWord.includes('..')) { + lineParts = tmpWord.split('..'); rangeDots = true; - } else if (tmpWord.includes(".") && !tmpWord.startsWith(".")) { - lineParts = tmpWord.split("."); - } else if (tmpWord.includes(",")) { - lineParts = tmpWord.split(","); + } else if (tmpWord.includes('.') && !tmpWord.startsWith('.')) { + lineParts = tmpWord.split('.'); + } else if (tmpWord.includes(',')) { + lineParts = tmpWord.split(','); } else if (spin1File) { - if (tmpWord.includes("#")) { - lineParts = tmpWord.split("#"); // in spin1 this is an object constant reference + if (tmpWord.includes('#')) { + lineParts = tmpWord.split('#'); // in spin1 this is an object constant reference } } else { - if (tmpWord.startsWith("#")) { + if (tmpWord.startsWith('#')) { lineParts = [tmpWord.substring(1)]; // remove leading "#" } } } // bazarre fixup of trailing whitespace - if (lineParts.length > 0 && (lineParts[0].endsWith(" ") || lineParts[0].endsWith("\t"))) { + if (lineParts.length > 0 && (lineParts[0].endsWith(' ') || lineParts[0].endsWith('\t'))) { lineParts[0] = lineParts[0].trimEnd(); } this._logMessage(`+ sp2Utils: adjustWordPosition() tmpWord=[${tmpWord}](${tmpWord.length}), lineParts=[${lineParts}](${lineParts.length})`); - let word: string = ""; - let objectRef: string = ""; + let word: string = ''; + let objectRef: string = ''; switch (lineParts.length) { case 0: break; @@ -155,11 +195,13 @@ export class ExtensionUtils { // one dot or more ... we take only last two items, unless user wants just first word word = lineParts[lineParts.length - 1]; objectRef = lineParts[lineParts.length - 2]; - this._logMessage(`+ sp2Utils: adjustWordPosition() cursor=(${cursorPosition.character}), start=(${wordRange.start.character}), obj=[${objectRef}](${objectRef.length}), word=[${word}]`); + this._logMessage( + `+ sp2Utils: adjustWordPosition() cursor=(${cursorPosition.character}), start=(${wordRange.start.character}), obj=[${objectRef}](${objectRef.length}), word=[${word}]` + ); // if our cursor is in the object name part then return object name as our word if (cursorPosition.character < wordRange.start.character + objectRef.length + 1) { word = objectRef; - objectRef = ""; + objectRef = ''; } this._logMessage(`+ sp2Utils: adjustWordPosition() obj=[${objectRef}], word=[${word}]`); } @@ -178,7 +220,13 @@ export class ExtensionUtils { bPositionInComment = isInBlockComment; this._logMessage(`+ sp2Utils: adjustWordPosition() (post-block): bPositionInComment=${bPositionInComment}`); } - if (!wordRange || this.isPositionInString(lineText, wordPosition, stringsFound, ticVarsFound) || bPositionInComment || word.match(/^\d+.?\d+$/) || spinControlFlowKeywords.indexOf(word) > 0) { + if ( + !wordRange || + this.isPositionInString(lineText, wordPosition, stringsFound, ticVarsFound) || + bPositionInComment || + word.match(/^\d+.?\d+$/) || + spinControlFlowKeywords.indexOf(word) > 0 + ) { this._logMessage(`+ sp2Utils: adjustWordPosition() EXIT false`); return [false, null!, null!, null!, null!]; } @@ -220,10 +268,10 @@ export class ExtensionUtils { public isPositionInComment(lineText: string, position: lsp.Position, stringsInLine: IPairs[]): boolean { let inCommentStatus: boolean = false; - let inString: boolean = false; + //const inString: boolean = false; // if entire line is comment this._logMessage(`+ sp2Utils: isPositionInComment() lineText=[${lineText}](${lineText.length})`); - if (lineText.startsWith("'") || lineText.startsWith("{")) { + if (lineText.startsWith("'") || lineText.startsWith('{')) { inCommentStatus = true; } else { // if text is within trailing comment @@ -232,13 +280,15 @@ export class ExtensionUtils { // searfch for comment only past all strings trailingCommentStartSearchPos = stringsInLine[stringsInLine.length - 1].end + 1; } - let firstTickMatchLocn: number = lineText.indexOf("'", trailingCommentStartSearchPos); - let firstBraceMatchLocn: number = lineText.indexOf("{", trailingCommentStartSearchPos); + const firstTickMatchLocn: number = lineText.indexOf("'", trailingCommentStartSearchPos); + const firstBraceMatchLocn: number = lineText.indexOf('{', trailingCommentStartSearchPos); let firstMatchLocn = firstTickMatchLocn < firstBraceMatchLocn && firstTickMatchLocn != -1 ? firstTickMatchLocn : firstBraceMatchLocn; if (firstBraceMatchLocn == -1) { firstMatchLocn = firstTickMatchLocn; } - this._logMessage(`+ sp2Utils: isPositionInComment() pos=[${position.character}], tik=[${firstTickMatchLocn}], brc=[${firstBraceMatchLocn}], mtch=[${firstMatchLocn}]`); + this._logMessage( + `+ sp2Utils: isPositionInComment() pos=[${position.character}], tik=[${firstTickMatchLocn}], brc=[${firstBraceMatchLocn}], mtch=[${firstMatchLocn}]` + ); if (firstMatchLocn != -1 && position.character > firstMatchLocn) { inCommentStatus = true; } @@ -248,12 +298,12 @@ export class ExtensionUtils { } public getStringPairOffsets(line: string): IPairs[] { - let findings: IPairs[] = this._getPairOffsetsOfChar(line, '"'); + const findings: IPairs[] = this._getPairOffsetsOfChar(line, '"'); this._showPairsForChar(findings, '"'); - let sglQuoStrPairs: IPairs[] = this._getPairOffsetsOfChar(line, "'"); + const sglQuoStrPairs: IPairs[] = this._getPairOffsetsOfChar(line, "'"); if (sglQuoStrPairs.length > 0) { // this._logMessage(`+ sp2Utils: _getStringPairOffsets([${line}](${line.length}))`); - let dblQuotedStrings: IPairs[] = findings; + const dblQuotedStrings: IPairs[] = findings; if (sglQuoStrPairs.length > 0) { for (let sglIdx = 0; sglIdx < sglQuoStrPairs.length; sglIdx++) { const currFinding: IPairs = sglQuoStrPairs[sglIdx]; @@ -284,17 +334,17 @@ export class ExtensionUtils { } public getPairOffsetsOfTicVarWraps(line: string): IPairs[] { - let findings: IPairs[] = []; + const findings: IPairs[] = []; // hunting for "`(variable)" sets // return location of each one found - let endIdx: number = line.length - 3; + const endIdx: number = line.length - 3; let currTicWrapOffset: number = 0; do { - currTicWrapOffset = line.indexOf("`(", currTicWrapOffset); + currTicWrapOffset = line.indexOf('`(', currTicWrapOffset); if (currTicWrapOffset == -1) { break; // not wrap, stop hunting } - let currTicWrapEndOffset: number = line.indexOf(")", currTicWrapOffset); + const currTicWrapEndOffset: number = line.indexOf(')', currTicWrapOffset); if (currTicWrapEndOffset == -1) { break; // not wrap, stop hunting } @@ -302,7 +352,7 @@ export class ExtensionUtils { findings.push(newPair); currTicWrapOffset = currTicWrapEndOffset + 1; } while (currTicWrapOffset < endIdx); - this._showPairsForChar(findings, "`()"); + this._showPairsForChar(findings, '`()'); return findings; } @@ -319,11 +369,11 @@ export class ExtensionUtils { } private _getPairOffsetsOfChar(line: string, searchChar: string): IPairs[] { - let findings: IPairs[] = []; + const findings: IPairs[] = []; let startPos: number = -1; let endPos: number = -1; let seachOffset: number = 0; - let endIdx: number = line.length - 2; + const endIdx: number = line.length - 2; //this._logMessage(`+ --- _getPairOffsetsOfChar([${line}](${line.length}), [${searchChar}])`); if (line.length > 0) { while (seachOffset < endIdx) { @@ -372,7 +422,7 @@ export class ExtensionUtils { } private _testAndReportFindings(text: string) { - let pairs: IPairs[] = this.getStringPairOffsets(text); + const pairs: IPairs[] = this.getStringPairOffsets(text); this._logMessage(`+ _testAndReportFindings([${text}](${text.length})) found ${pairs.length} pair(s)`); if (pairs.length > 0) { for (let pairIdx = 0; pairIdx < pairs.length; pairIdx++) { diff --git a/spin2/server/src/parser/spin.objectReferenceParser.ts b/spin2/server/src/parser/spin.objectReferenceParser.ts index c4e4397..c48a8d4 100644 --- a/spin2/server/src/parser/spin.objectReferenceParser.ts +++ b/spin2/server/src/parser/spin.objectReferenceParser.ts @@ -1,21 +1,21 @@ -"use strict"; +'use strict'; // server/src/parser/spin.objectReferenceParser.ts -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Context } from "../context"; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Context } from '../context'; //import { semanticConfiguration, reloadSemanticConfiguration } from "./spin2.extension.configuration"; -import { DocumentFindings, RememberedComment, RememberedToken } from "./spin.semantic.findings"; -import { Spin2ParseUtils } from "./spin2.utils"; -import { isSpin1File } from "./lang.utils"; -import { eParseState } from "./spin.common"; -import { ExtensionUtils } from "../parser/spin.extension.utils"; +import { DocumentFindings, RememberedToken } from './spin.semantic.findings'; +import { Spin2ParseUtils } from './spin2.utils'; +import { isSpin1File } from './lang.utils'; +import { eParseState } from './spin.common'; +import { ExtensionUtils } from '../parser/spin.extension.utils'; // ---------------------------------------------------------------------------- // Semantic Highlighting Provider // -const tokenTypes = new Map(); -const tokenModifiers = new Map(); +//const tokenTypes = new Map(); +//const tokenModifiers = new Map(); interface IParsedToken { line: number; @@ -38,7 +38,7 @@ export class Spin2ObjectReferenceParser { private showState: boolean = true; private logTokenDiscover: boolean = true; private semanticFindings: DocumentFindings = new DocumentFindings(); // this gets replaced - private currentFilespec: string = ""; + private currentFilespec: string = ''; private isSpin1Document: boolean = false; public constructor(protected readonly ctx: Context) { @@ -47,9 +47,9 @@ export class Spin2ObjectReferenceParser { if (this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin2 Object log started."); + this._logMessage('Spin2 Object log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } @@ -69,7 +69,7 @@ export class Spin2ObjectReferenceParser { this.currentFilespec = document.uri; this._logMessage(`* locatReferencedObjects(${this.currentFilespec})`); - const allTokens = this._parseText(document.getText()); + this._parseText(document.getText()); } private _parseText(text: string): IParsedToken[] { @@ -77,11 +77,11 @@ export class Spin2ObjectReferenceParser { const lines = text.split(/\r\n|\r|\n/); let currState: eParseState = eParseState.inCon; // compiler defaults to CON at start let priorState: eParseState = currState; - let prePAsmState: eParseState = currState; + //const prePAsmState: eParseState = currState; // track block comments - let currBlockComment: RememberedComment | undefined = undefined; - let currSingleLineBlockComment: RememberedComment | undefined = undefined; + //const currBlockComment: RememberedComment | undefined = undefined; + //const currSingleLineBlockComment: RememberedComment | undefined = undefined; const tokenSet: IParsedToken[] = []; @@ -92,15 +92,15 @@ export class Spin2ObjectReferenceParser { // -------------------- PRE-PARSE just locating symbol names -------------------- // also track and record block comments (both braces and tic's!) // let's also track prior single line and trailing comment on same line - this._logMessage("---> Pre SCAN"); + this._logMessage('---> Pre SCAN'); for (let i = 0; i < lines.length; i++) { const line = lines[i]; const trimmedLine = line.trim(); const trimmedNonCommentLine = this.parseUtils.getNonCommentLineRemainder(0, line); - const offSet: number = trimmedNonCommentLine.length > 0 ? line.indexOf(trimmedNonCommentLine) + 1 : line.indexOf(trimmedLine) + 1; - const tempComment = line.substring(trimmedNonCommentLine.length + offSet).trim(); + //const offSet: number = trimmedNonCommentLine.length > 0 ? line.indexOf(trimmedNonCommentLine) + 1 : line.indexOf(trimmedLine) + 1; + //const tempComment = line.substring(trimmedNonCommentLine.length + offSet).trim(); const sectionStatus = this.extensionUtils.isSectionStartLine(line); - const lineParts: string[] = trimmedNonCommentLine.split(/[ \t]/).filter(Boolean); + //const lineParts: string[] = trimmedNonCommentLine.split(/[ \t]/).filter(Boolean); // now start our processing if (currState == eParseState.inMultiLineComment) { @@ -111,11 +111,11 @@ export class Spin2ObjectReferenceParser { let currOffset: number = 0; let bFoundOpenClosePair: boolean = false; do { - nestedOpeningOffset = trimmedLine.indexOf("{", currOffset); + nestedOpeningOffset = trimmedLine.indexOf('{', currOffset); if (nestedOpeningOffset != -1) { bFoundOpenClosePair = false; // we have an opening { - closingOffset = trimmedLine.indexOf("}", nestedOpeningOffset); + closingOffset = trimmedLine.indexOf('}', nestedOpeningOffset); if (closingOffset != -1) { // and we have a closing, ignore this see if we have next currOffset = closingOffset + 1; @@ -125,7 +125,7 @@ export class Spin2ObjectReferenceParser { } } } while (nestedOpeningOffset != -1 && bFoundOpenClosePair); - closingOffset = trimmedLine.indexOf("}", currOffset); + closingOffset = trimmedLine.indexOf('}', currOffset); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -134,7 +134,7 @@ export class Spin2ObjectReferenceParser { continue; } else if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = line.indexOf("}}"); + const closingOffset = line.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -144,10 +144,10 @@ export class Spin2ObjectReferenceParser { } else if (trimmedLine.length == 0) { // a blank line clears pending single line comments continue; - } else if (trimmedLine.startsWith("{{")) { + } else if (trimmedLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = line.indexOf("{{"); - const closingOffset = line.indexOf("}}", openingOffset + 2); + const openingOffset = line.indexOf('{{'); + const closingOffset = line.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this // record new single-line comment @@ -158,11 +158,11 @@ export class Spin2ObjectReferenceParser { // DO NOTHING Let Syntax highlighting do this } continue; - } else if (trimmedLine.startsWith("{")) { + } else if (trimmedLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = line.indexOf("{"); - const closingOffset = line.indexOf("}", openingOffset + 1); + const openingOffset = line.indexOf('{'); + const closingOffset = line.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line comment... } else { @@ -188,7 +188,7 @@ export class Spin2ObjectReferenceParser { // process PUB/PRI method signature } else if (currState == eParseState.inCon) { // process a constant line - this._logState("- scan Ln#" + (i + 1) + " currState=[" + currState + "]"); + this._logState('- scan Ln#' + (i + 1) + ' currState=[' + currState + ']'); if (trimmedNonCommentLine.length > 3) { this._getCON_Declaration(3, i + 1, line); } @@ -196,7 +196,7 @@ export class Spin2ObjectReferenceParser { // process a class(static) variable line } else if (currState == eParseState.inObj) { // process an object line - this._logState("- scan Ln#" + (i + 1) + " currState=[" + currState + "]"); + this._logState('- scan Ln#' + (i + 1) + ' currState=[' + currState + ']'); if (trimmedNonCommentLine.length > 3) { this._getOBJ_Declaration(3, i + 1, line); } @@ -226,7 +226,7 @@ export class Spin2ObjectReferenceParser { } // -------------------- End of PRE-PARSE -------------------- - this._logMessage("---- Object Reference Parse DONE ----\n"); + this._logMessage('---- Object Reference Parse DONE ----\n'); return tokenSet; } @@ -238,20 +238,20 @@ export class Spin2ObjectReferenceParser { //skip Past Whitespace let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const nonCommentConstantLine = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); - this._logCON(" - Ln#" + lineNbr + " GetCONDecl nonCommentConstantLine=[" + nonCommentConstantLine + "]"); + this._logCON(` - Ln#${lineNbr} GetCONDecl nonCommentConstantLine=[${nonCommentConstantLine}]`); - const haveEnumDeclaration: boolean = nonCommentConstantLine.startsWith("#"); - const containsMultiAssignments: boolean = nonCommentConstantLine.indexOf(",") != -1; + const haveEnumDeclaration: boolean = nonCommentConstantLine.startsWith('#'); + const containsMultiAssignments: boolean = nonCommentConstantLine.indexOf(',') != -1; let statements: string[] = [nonCommentConstantLine]; if (!haveEnumDeclaration && containsMultiAssignments) { - statements = nonCommentConstantLine.split(","); + statements = nonCommentConstantLine.split(','); } - this._logCON(" -- statements=[" + statements + "]"); + this._logCON(' -- statements=[' + statements + ']'); for (let index = 0; index < statements.length; index++) { const conDeclarationLine: string = statements[index].trim(); - this._logCON(" -- conDeclarationLine=[" + conDeclarationLine + "]"); + this._logCON(' -- conDeclarationLine=[' + conDeclarationLine + ']'); currentOffset = line.indexOf(conDeclarationLine, currentOffset); - const assignmentOffset: number = conDeclarationLine.indexOf("="); + const assignmentOffset: number = conDeclarationLine.indexOf('='); if (assignmentOffset != -1) { // recognize constant name getting initialized via assignment // get line parts - we only care about first one @@ -261,22 +261,24 @@ export class Spin2ObjectReferenceParser { .filter(Boolean); const newName = lineParts[0]; if (newName.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- GLBL GetCONDecl newName=[" + newName + "]"); + this._logCON(' -- GLBL GetCONDecl newName=[' + newName + ']'); // remember this object name so we can annotate a call to it } - const containsObjectReferences: boolean = nonCommentConstantLine.indexOf(".") != -1; + const containsObjectReferences: boolean = nonCommentConstantLine.indexOf('.') != -1; if (containsObjectReferences) { const assignmentRHS = nonCommentConstantLine.substring(assignmentOffset + 1).trim(); - this._logCON(" -- GLBL GetCONDecl assignmentRHS=[" + assignmentRHS + "]"); + this._logCON(' -- GLBL GetCONDecl assignmentRHS=[' + assignmentRHS + ']'); const lineParts: string[] = assignmentRHS.split(/[ \t]/).filter(Boolean); - this._logCON(" -- GLBL GetCONDecl lineParts=[" + lineParts + "]"); + this._logCON(' -- GLBL GetCONDecl lineParts=[' + lineParts + ']'); for (let partIdx = 0; partIdx < lineParts.length; partIdx++) { const nameForEval: string = lineParts[partIdx]; - if (nameForEval.includes(".")) { + if (nameForEval.includes('.')) { // SPIN1 have object.constant reference - const refParts: string[] = nameForEval.split("."); + const refParts: string[] = nameForEval.split('.'); if (refParts.length == 2) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const objName = refParts[0]; + // eslint-disable-next-line @typescript-eslint/no-unused-vars const childConstantName = refParts[1]; } } @@ -289,15 +291,15 @@ export class Spin2ObjectReferenceParser { for (let index = 0; index < lineParts.length; index++) { let enumConstant: string = lineParts[index]; // our enum name can have a step offset - if (enumConstant.includes("[")) { + if (enumConstant.includes('[')) { // it does, isolate name from offset - const enumNameParts: string[] = enumConstant.split("["); + const enumNameParts: string[] = enumConstant.split('['); enumConstant = enumNameParts[0]; } if (enumConstant.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- GLBL enumConstant=[" + enumConstant + "]"); + this._logCON(' -- GLBL enumConstant=[' + enumConstant + ']'); const nameOffset = line.indexOf(enumConstant, currentOffset); // FIXME: UNDONE, do we have to dial this in? - this.semanticFindings.setGlobalToken(enumConstant, new RememberedToken("enumMember", lineNbr - 1, nameOffset, ["readonly"]), undefined); + this.semanticFindings.setGlobalToken(enumConstant, new RememberedToken('enumMember', lineNbr - 1, nameOffset, ['readonly']), undefined); } } } @@ -312,23 +314,23 @@ export class Spin2ObjectReferenceParser { // -or- segments[7] : "isp_hub75_segment" | BUFF_SIZE = 2 // //skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); //this._logOBJ('- RptObjDecl remainingNonCommentLineStr=[' + remainingNonCommentLineStr + ']'); - if (remainingNonCommentLineStr.length > 5 && remainingNonCommentLineStr.includes(":") && remainingNonCommentLineStr.includes('"')) { + if (remainingNonCommentLineStr.length > 5 && remainingNonCommentLineStr.includes(':') && remainingNonCommentLineStr.includes('"')) { // get line parts - we only care about first one - const overrideParts: string[] = remainingNonCommentLineStr.split("|").filter(Boolean); - const lineParts: string[] = overrideParts[0].split(":").filter(Boolean); - this._logOBJ(" -- GLBL GetOBJDecl lineParts=[" + lineParts + "]"); + const overrideParts: string[] = remainingNonCommentLineStr.split('|').filter(Boolean); + const lineParts: string[] = overrideParts[0].split(':').filter(Boolean); + this._logOBJ(' -- GLBL GetOBJDecl lineParts=[' + lineParts + ']'); let instanceNamePart = lineParts[0].trim(); // if we have instance array declaration, then remove it - if (instanceNamePart.includes("[")) { - const nameParts = instanceNamePart.split(/[\[\]]/).filter(Boolean); + if (instanceNamePart.includes('[')) { + const nameParts = instanceNamePart.split(/[[\]]/).filter(Boolean); instanceNamePart = nameParts[0]; } this._logOBJ(` -- GLBL GetOBJDecl newInstanceName=[${instanceNamePart}]`); // remember this object name so we can annotate a call to it - const filenamePart = lineParts.length > 1 ? lineParts[1].trim().replace(/[\"]/g, "") : ""; + const filenamePart = lineParts.length > 1 ? lineParts[1].trim().replace(/["]/g, '') : ''; this._logOBJ(` -- GLBL GetOBJDecl newFileName=[${filenamePart}]`); if (filenamePart.length > 0) { this.semanticFindings.recordObjectImport(instanceNamePart, filenamePart); diff --git a/spin2/server/src/parser/spin.semantic.findings.ts b/spin2/server/src/parser/spin.semantic.findings.ts index f351b70..3ee43eb 100644 --- a/spin2/server/src/parser/spin.semantic.findings.ts +++ b/spin2/server/src/parser/spin.semantic.findings.ts @@ -1,12 +1,12 @@ -"use strict"; +'use strict'; // server/src/parser/spin.semantic.findings.ts -import { Range, DiagnosticSeverity, SymbolKind, Diagnostic } from "vscode-languageserver-types"; -import { displayEnumByTypeName } from "./spin2.utils"; -import { eDebugDisplayType } from "./spin.common"; -import { Context } from "../context"; -import { Position } from "vscode-languageserver-textdocument"; -import { PortMessageReader } from "vscode-languageserver/node"; +import { Range, DiagnosticSeverity, SymbolKind, Diagnostic } from 'vscode-languageserver-types'; +import { displayEnumByTypeName } from './spin2.utils'; +import { eDebugDisplayType } from './spin.common'; +import { Context } from '../context'; +import { Position } from 'vscode-languageserver-textdocument'; +//import { PortMessageReader } from 'vscode-languageserver/node'; // ============================================================================ // this file contains objects we use in tracking symbol use and declaration @@ -18,7 +18,7 @@ export enum eBLockType { isVar, isObj, isPub, - isPri, + isPri } export enum eSeverity { @@ -27,7 +27,7 @@ export enum eSeverity { Error, Warning, Information, - Hint, + Hint } export enum eDefinitionType { @@ -35,7 +35,7 @@ export enum eDefinitionType { Unknown = 0, LocalLabel, GlobalLabel, - NonLabel, + NonLabel } // search comment type: non-doc only, doc-only, or mixed @@ -43,7 +43,7 @@ enum eCommentFilter { Unknown = 0, docCommentOnly, nondocCommentOnly, - allComments, + allComments } export interface ILocationOfToken { @@ -130,7 +130,7 @@ export enum eFoldSpanType { Comment, CodeBlock, PasmCodeBlock, - InlinePasmCodeBlock, + InlinePasmCodeBlock } export interface IFoldSpan { @@ -156,7 +156,7 @@ export class DocumentFindings { private currMethodStartLineNbr: number = 0; private objectParseResultByObjectName = new Map(); private diagnosticMessages: DiagnosticReport[] = []; - private declarationLineCache = new Map(); + private declarationLineCache = new Map(); private declarationGlobalLabelListCache: number[] = []; private declarationLocalLabelLineCache = new Map(); // line numbers by localLabelName @@ -183,7 +183,7 @@ export class DocumentFindings { // tracking includes private objectFilenameByInstanceName = new Map(); private ctx: Context | undefined; - private docUri: string = "--uri-not-set--"; + private docUri: string = '--uri-not-set--'; public constructor(documentUri: string | undefined = undefined) { if (documentUri) { @@ -193,19 +193,19 @@ export class DocumentFindings { if (this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin2 SemanticFindings log started."); + this._logMessage('Spin2 SemanticFindings log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } this._logMessage("* Global, Local, MethodScoped Token repo's ready"); - this.globalTokens = new TokenSet("gloTOK"); - this.methodLocalTokens = new NameScopedTokenSet("methLocTOK"); + this.globalTokens = new TokenSet('gloTOK'); + this.methodLocalTokens = new NameScopedTokenSet('methLocTOK'); this.declarationInfoByGlobalTokenName = new Map(); this.declarationInfoByLocalTokenName = new Map(); // and for P2 - this.methodLocalPasmTokens = new NameScopedTokenSet("methPasmTOK"); + this.methodLocalPasmTokens = new NameScopedTokenSet('methPasmTOK'); } public get uri(): string { @@ -217,11 +217,11 @@ export class DocumentFindings { // append filespec to our instance number const orignalId: string = this.instanceId; let priorId: string = this.instanceId; - if (priorId.includes("-")) { - const idParts: string[] = priorId.split("-"); + if (priorId.includes('-')) { + const idParts: string[] = priorId.split('-'); priorId = idParts[0]; } - const basename = filespec.split("/").reverse()[0]; + const basename = filespec.split('/').reverse()[0]; this.instanceId = `${priorId}-${basename}`; this._logMessage(`DocumentFindings: [${orignalId}] -> [${this.instanceId}]`); } @@ -275,9 +275,9 @@ export class DocumentFindings { if (this.findingsLogEnabled && this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin2 SemanticFindings log started."); + this._logMessage('Spin2 SemanticFindings log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } @@ -329,8 +329,8 @@ export class DocumentFindings { private _deDupeReports(diagMessages: DiagnosticReport[], messageCountMax: number): DiagnosticReport[] { // remove duplicates in report so we still report relevent content - let reducedSet: DiagnosticReport[] = []; - let messagesWeveSeen: string[] = []; + const reducedSet: DiagnosticReport[] = []; + const messagesWeveSeen: string[] = []; for (let index = 0; index < diagMessages.length; index++) { const report = diagMessages[index]; if (!messagesWeveSeen.includes(report.message())) { @@ -346,23 +346,23 @@ export class DocumentFindings { public pushDiagnosticMessage(lineIdx: number, startChar: number, endChar: number, severity: eSeverity, message: string): void { // record a new diagnostic message - let severityStr: string = "??severity??"; + let severityStr: string = '??severity??'; if (this.findingsLogEnabled) { switch (severity) { case eSeverity.Error: { - severityStr = "ERROR"; + severityStr = 'ERROR'; break; } case eSeverity.Warning: { - severityStr = "WARNING"; + severityStr = 'WARNING'; break; } case eSeverity.Hint: { - severityStr = "HINT"; + severityStr = 'HINT'; break; } case eSeverity.Information: { - severityStr = "INFORMATION"; + severityStr = 'INFORMATION'; break; } } @@ -389,7 +389,11 @@ export class DocumentFindings { const blockSpans = this.blockSpans(); for (let index = 0; index < blockSpans.length; index++) { const blockSpan = blockSpans[index]; - const nextSpan: IFoldSpan = { foldstart: { line: blockSpan.startLineIdx, character: 0 }, foldEnd: { line: blockSpan.endLineIdx, character: Number.MAX_VALUE }, type: eFoldSpanType.CodeBlock }; + const nextSpan: IFoldSpan = { + foldstart: { line: blockSpan.startLineIdx, character: 0 }, + foldEnd: { line: blockSpan.endLineIdx, character: Number.MAX_VALUE }, + type: eFoldSpanType.CodeBlock + }; foldingCodeSpans.push(nextSpan); } // doc comment ranges @@ -398,9 +402,13 @@ export class DocumentFindings { // NOTE: 2 or more lines can fold if (blockComment.lineCount > 1) { const commentLines: string[] = blockComment.lines; - const commentString: string = `\n------->>>>>>>>>-------\n${commentLines.join("\n")}\n-------<<<<<<<<<-------\n`; + const commentString: string = `\n------->>>>>>>>>-------\n${commentLines.join('\n')}\n-------<<<<<<<<<-------\n`; this._logMessage(` -- CMT block Ln#${blockComment.firstLine + 1}-${blockComment.lastLine + 1}(${blockComment.lineSpan}): [${commentString}]`); - const nextSpan: IFoldSpan = { foldstart: { line: blockComment.firstLine, character: 0 }, foldEnd: { line: blockComment.lastLine, character: Number.MAX_VALUE }, type: eFoldSpanType.Comment }; + const nextSpan: IFoldSpan = { + foldstart: { line: blockComment.firstLine, character: 0 }, + foldEnd: { line: blockComment.lastLine, character: Number.MAX_VALUE }, + type: eFoldSpanType.Comment + }; foldingCodeSpans.push(nextSpan); } } @@ -412,7 +420,7 @@ export class DocumentFindings { const nextSpan: IFoldSpan = { foldstart: { line: pasmCodeSpan.startLineIdx, character: 0 }, foldEnd: { line: pasmCodeSpan.endLineIdx, character: Number.MAX_VALUE }, - type: spanType, + type: spanType }; foldingCodeSpans.push(nextSpan); } @@ -423,7 +431,7 @@ export class DocumentFindings { const nextSpan: IFoldSpan = { foldstart: { line: continuedLineSpan.startLineIdx, character: 0 }, foldEnd: { line: continuedLineSpan.endLineIdx, character: Number.MAX_VALUE }, - type: eFoldSpanType.CodeBlock, + type: eFoldSpanType.CodeBlock }; foldingCodeSpans.push(nextSpan); } @@ -434,7 +442,7 @@ export class DocumentFindings { const nextSpan: IFoldSpan = { foldstart: { line: spinFlowSpan.startLineIdx, character: 0 }, foldEnd: { line: spinFlowSpan.endLineIdx, character: Number.MAX_VALUE }, - type: eFoldSpanType.CodeBlock, + type: eFoldSpanType.CodeBlock }; foldingCodeSpans.push(nextSpan); } @@ -449,7 +457,7 @@ export class DocumentFindings { // return the complete set of Semantic tokens found in our document // and yes, in language server we need to do the sorting before returning these // otherwise some things don't get colored! - var sortedArray: IParsedToken[] = this.semanticTokens.sort((n1, n2) => { + const sortedArray: IParsedToken[] = this.semanticTokens.sort((n1, n2) => { if (n1.line > n2.line) { return 1; } @@ -498,7 +506,9 @@ export class DocumentFindings { const namespaceKey: string = namespace.toLowerCase(); if (!this.objectParseResultByObjectName.has(namespaceKey)) { this.objectParseResultByObjectName.set(namespaceKey, symbolsInNamespace); - this._logMessage(`* setFindingsForNamespace(${this.instanceName()}) ADD findings for [${namespace}] which is [${symbolsInNamespace.instanceName()}]`); + this._logMessage( + `* setFindingsForNamespace(${this.instanceName()}) ADD findings for [${namespace}] which is [${symbolsInNamespace.instanceName()}]` + ); } else { this._logMessage(`* setFindingsForNamespace(${this.instanceName()}) ERROR: SKIP ADD, duplicate [${namespace}]`); } @@ -517,7 +527,9 @@ export class DocumentFindings { if (this.objectParseResultByObjectName.has(namespaceKey)) { symbolsInNamespace = this.objectParseResultByObjectName.get(namespaceKey); if (symbolsInNamespace) { - this._logMessage(`* getFindingsForNamespace(${this.instanceName()}) returns [${namespace}]=[${symbolsInNamespace}] which is [${symbolsInNamespace.instanceName()}]`); + this._logMessage( + `* getFindingsForNamespace(${this.instanceName()}) returns [${namespace}]=[${symbolsInNamespace}] which is [${symbolsInNamespace.instanceName()}]` + ); } else { this._logMessage(`* getFindingsForNamespace(${this.instanceName()}) ERROR: [-failed-get-] NO findings for [${namespace}]`); } @@ -536,7 +548,7 @@ export class DocumentFindings { public locationsOfToken(tokenName: string, postion: Position): ILocationOfToken[] { // NOTE: position is cursor position in doc at location of request const desiredLocations: ILocationOfToken[] = []; - this.appendLocationsOfToken(tokenName, desiredLocations, "top", postion); + this.appendLocationsOfToken(tokenName, desiredLocations, 'top', postion); this._logMessage(` -- locationsOfToken() id=[${this.instanceId}] returns ${desiredLocations.length} tokens`); return desiredLocations; } @@ -546,21 +558,28 @@ export class DocumentFindings { // we use this to determine if request is scoped to a method // if it is, we limit responses to findings within the method let referenceDetails: RememberedToken | undefined = undefined; - const desiredTokenKey: string = tokenName.toLowerCase(); + //const desiredTokenKey: string = tokenName.toLowerCase(); let findCount: number = 0; - const isPossibleLocalLabel: boolean = tokenName.startsWith(".") || tokenName.startsWith(":"); + const isPossibleLocalLabel: boolean = tokenName.startsWith('.') || tokenName.startsWith(':'); // get global token from this objects let tokenPosition: Position = { line: -1, character: -1 }; if (this.isGlobalToken(tokenName)) { referenceDetails = this.getGlobalToken(tokenName); if (referenceDetails) { - if (isPossibleLocalLabel && referenceDetails.type === "label") { + if (isPossibleLocalLabel && referenceDetails.type === 'label') { tokenPosition = this._getBestLocalLabelPostionForPosition(postion, tokenName); } else { - tokenPosition = { line: referenceDetails.lineIndex, character: referenceDetails.charIndex }; + tokenPosition = { + line: referenceDetails.lineIndex, + character: referenceDetails.charIndex + }; } if (tokenPosition.line != -1 && tokenPosition.character != -1) { - const tokenRef: ILocationOfToken = { uri: this.uri, objectName: objectName, position: tokenPosition }; + const tokenRef: ILocationOfToken = { + uri: this.uri, + objectName: objectName, + position: tokenPosition + }; locationsSoFar.push(tokenRef); findCount++; } @@ -584,13 +603,20 @@ export class DocumentFindings { } } if (referenceDetails) { - if (isPossibleLocalLabel && referenceDetails.type === "label") { + if (isPossibleLocalLabel && referenceDetails.type === 'label') { tokenPosition = this._getBestLocalLabelPostionForPosition(postion, tokenName); } else { - tokenPosition = { line: referenceDetails.lineIndex, character: referenceDetails.charIndex }; + tokenPosition = { + line: referenceDetails.lineIndex, + character: referenceDetails.charIndex + }; } if (tokenPosition.line != -1 && tokenPosition.character != -1) { - const tokenRef: ILocationOfToken = { uri: this.uri, objectName: objectName, position: tokenPosition }; + const tokenRef: ILocationOfToken = { + uri: this.uri, + objectName: objectName, + position: tokenPosition + }; locationsSoFar.push(tokenRef); findCount++; } @@ -603,8 +629,15 @@ export class DocumentFindings { for (let index = 0; index < referenceSet.length; index++) { referenceDetails = referenceSet[index]; if (referenceDetails) { - const tokenPosition: Position = { line: referenceDetails.lineIndex, character: referenceDetails.charIndex }; - const tokenRef: ILocationOfToken = { uri: this.uri, objectName: objectName, position: tokenPosition }; + const tokenPosition: Position = { + line: referenceDetails.lineIndex, + character: referenceDetails.charIndex + }; + const tokenRef: ILocationOfToken = { + uri: this.uri, + objectName: objectName, + position: tokenPosition + }; locationsSoFar.push(tokenRef); findCount++; this._logMessage(` -- appLoc-Token FOUND local token=[${tokenName}]`); @@ -666,15 +699,17 @@ export class DocumentFindings { this.priorInstanceCount = 1; } else { // we are starting a later block, lets finish prior then start the new - const isFirstOfThisType: boolean = this.priorBlockType != eCurrBlockType ? false : true; + //const isFirstOfThisType: boolean = this.priorBlockType != eCurrBlockType ? false : true; const newBlockSpan: IBlockSpan = { blockType: this.priorBlockType, sequenceNbr: this.priorInstanceCount, startLineIdx: this.priorBlockStartLineIdx, - endLineIdx: currLineIdx - 1, // ends at prior line + endLineIdx: currLineIdx - 1 // ends at prior line }; this.codeBlockSpans.push(newBlockSpan); - this._logMessage(` -- FND-RCD-ADD sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]`); + this._logMessage( + ` -- FND-RCD-ADD sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]` + ); this.priorInstanceCount = this.priorBlockType == eCurrBlockType ? this.priorInstanceCount + 1 : 1; this.priorBlockStartLineIdx = currLineIdx; this.priorBlockType = eCurrBlockType; @@ -689,9 +724,11 @@ export class DocumentFindings { blockType: this.priorBlockType, sequenceNbr: this.priorInstanceCount, startLineIdx: this.priorBlockStartLineIdx, - endLineIdx: finalLineIdx, // ends at the last line of the file + endLineIdx: finalLineIdx // ends at the last line of the file }; - this._logMessage(` -- FND-RCD-ADD LAST sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]`); + this._logMessage( + ` -- FND-RCD-ADD LAST sequenceNbr=[${newBlockSpan.sequenceNbr}], blockType=[${newBlockSpan.blockType}], span=[${newBlockSpan.startLineIdx} - ${newBlockSpan.endLineIdx}]` + ); this.codeBlockSpans.push(newBlockSpan); } } @@ -731,7 +768,11 @@ export class DocumentFindings { public recordPasmEnd(lineIdx: number) { // finish the pasm span record and record it if (this.pasmStartLineIdx != -1) { - const newSpan: IPasmCodeSpan = { startLineIdx: this.pasmStartLineIdx, endLineIdx: lineIdx, isInline: this.pasmIsInline }; + const newSpan: IPasmCodeSpan = { + startLineIdx: this.pasmStartLineIdx, + endLineIdx: lineIdx, + isInline: this.pasmIsInline + }; this.pasmCodeSpans.push(newSpan); this.pasmStartLineIdx = -1; // used this one! this._logMessage(` -- FND-PASM-ADD RANGE range=[${this.pasmStartLineIdx}-${lineIdx}], isInline=[${this.pasmIsInline}]`); @@ -747,7 +788,9 @@ export class DocumentFindings { const pasmSpan: IPasmCodeSpan = this.pasmCodeSpans[index]; if (lineIndex >= pasmSpan.startLineIdx && lineIndex <= pasmSpan.endLineIdx) { inPasmCodeStatus = true; - this._logMessage(` -- FND-PASM range=[${pasmSpan.startLineIdx}-${pasmSpan.endLineIdx}], isInline=[${pasmSpan.isInline}] our symbol is IN PASM BLOCK`); + this._logMessage( + ` -- FND-PASM range=[${pasmSpan.startLineIdx}-${pasmSpan.endLineIdx}], isInline=[${pasmSpan.isInline}] our symbol is IN PASM BLOCK` + ); break; } } @@ -773,7 +816,8 @@ export class DocumentFindings { public includeFilenames(): string[] { // return the list of filenames of included objects - let filenames: string[] = []; + const filenames: string[] = []; + // eslint-disable-next-line @typescript-eslint/no-unused-vars for (const [name, filename] of this.objectFilenameByInstanceName) { filenames.push(filename); } @@ -807,7 +851,7 @@ export class DocumentFindings { public isLineInBlockComment(lineNumber: number): boolean { let inCommentStatus: boolean = false; if (this.blockComments.length > 0) { - for (let docComment of this.blockComments) { + for (const docComment of this.blockComments) { if (docComment.includesLine(lineNumber)) { inCommentStatus = true; break; @@ -820,7 +864,7 @@ export class DocumentFindings { public isLineInFakeComment(lineIdx: number): boolean { let inCommentStatus: boolean = false; if (this.fakeComments.length > 0) { - for (let fakeComment of this.fakeComments) { + for (const fakeComment of this.fakeComments) { if (fakeComment.includesLine(lineIdx)) { inCommentStatus = true; break; @@ -832,13 +876,13 @@ export class DocumentFindings { private logBlockComment(comment: RememberedComment) { const decription: string[] = comment.desribeComment(); - this._logMessage(`${decription.join("\n")}`); + this._logMessage(`${decription.join('\n')}`); } public blockCommentMDFromLine(lineIdx: number, eFilter: eCommentFilter): string | undefined { let desiredComment: string | undefined = undefined; if (this.blockComments.length > 0) { - for (let blockComment of this.blockComments) { + for (const blockComment of this.blockComments) { // only one will match... this.logBlockComment(blockComment); if (blockComment.includesLine(lineIdx)) { @@ -857,7 +901,7 @@ export class DocumentFindings { public fakeCommentMDFromLine(lineIdx: number, eFilter: eCommentFilter): string | undefined { let desiredComment: string | undefined = undefined; if (this.fakeComments.length > 0) { - for (let fakeComment of this.fakeComments) { + for (const fakeComment of this.fakeComments) { if (fakeComment.includesLine(lineIdx)) { const canUseThisComment: boolean = this._isUsableComment(fakeComment.isDocComment, eFilter); if (canUseThisComment) { @@ -910,13 +954,13 @@ export class DocumentFindings { } public getDebugTokenWithDescription(tokenName: string): ITokenDescription { - let findings: ITokenDescription = { + const findings: ITokenDescription = { found: false, - tokenRawInterp: "", + tokenRawInterp: '', isGoodInterp: false, token: undefined, - scope: "", - interpretation: "", + scope: '', + interpretation: '', adjustedName: tokenName, declarationLineIdx: 0, declarationLine: undefined, @@ -924,7 +968,7 @@ export class DocumentFindings { signature: undefined, relatedFilename: undefined, relatedObjectName: undefined, - relatedMethodName: undefined, + relatedMethodName: undefined }; // do we have a token?? let declInfo: RememberedTokenDeclarationInfo | undefined = undefined; @@ -935,11 +979,14 @@ export class DocumentFindings { if (displayInfo.eDisplayType != eDebugDisplayType.Unknown) { // we have a debug display type! const fakeCharOffset: number = 0; - findings.token = new RememberedToken("debugDisplay", displayInfo.lineNbr - 1, fakeCharOffset, [displayInfo.displayTypeString]); - findings.scope = "Global"; - findings.tokenRawInterp = "Global: " + this._rememberdTokenString(tokenName, findings.token); + findings.token = new RememberedToken('debugDisplay', displayInfo.lineNbr - 1, fakeCharOffset, [displayInfo.displayTypeString]); + findings.scope = 'Global'; + findings.tokenRawInterp = 'Global: ' + this._rememberdTokenString(tokenName, findings.token); const termType: string = displayInfo.displayTypeString.toUpperCase(); - declInfo = new RememberedTokenDeclarationInfo(displayInfo.lineNbr, `Debug Output: User name for an instance of ${termType}
- Write output to the \`${tokenName}\` window`); + declInfo = new RememberedTokenDeclarationInfo( + displayInfo.lineNbr, + `Debug Output: User name for an instance of ${termType}
- Write output to the \`${tokenName}\` window` + ); } } this._fillInFindings(tokenName, findings, declInfo); @@ -949,11 +996,11 @@ export class DocumentFindings { public getPublicTokenWithDescription(tokenName: string, lineNbr: number): ITokenDescription { let findings: ITokenDescription = { found: false, - tokenRawInterp: "", + tokenRawInterp: '', isGoodInterp: false, token: undefined, - scope: "", - interpretation: "", + scope: '', + interpretation: '', adjustedName: tokenName, declarationLineIdx: 0, declarationLine: undefined, @@ -961,7 +1008,7 @@ export class DocumentFindings { signature: undefined, relatedFilename: undefined, relatedObjectName: undefined, - relatedMethodName: undefined, + relatedMethodName: undefined }; // do we have a token?? if (this.isPublicToken(tokenName)) { @@ -971,13 +1018,13 @@ export class DocumentFindings { } public getTokenWithDescription(tokenName: string, lineNbr: number): ITokenDescription { - let findings: ITokenDescription = { + const findings: ITokenDescription = { found: false, - tokenRawInterp: "", + tokenRawInterp: '', isGoodInterp: false, token: undefined, - scope: "", - interpretation: "", + scope: '', + interpretation: '', adjustedName: tokenName, declarationLineIdx: 0, declarationLine: undefined, @@ -985,7 +1032,7 @@ export class DocumentFindings { signature: undefined, relatedFilename: undefined, relatedObjectName: undefined, - relatedMethodName: undefined, + relatedMethodName: undefined }; // do we have a token?? let declInfo: RememberedTokenDeclarationInfo | undefined = undefined; @@ -996,8 +1043,8 @@ export class DocumentFindings { findings.token = this.getGlobalToken(tokenName); if (findings.token) { // we have a GLOBAL token! - findings.tokenRawInterp = "Global: " + this._rememberdTokenString(tokenName, findings.token); - findings.scope = "Global"; + findings.tokenRawInterp = 'Global: ' + this._rememberdTokenString(tokenName, findings.token); + findings.scope = 'Global'; // and get additional info for token declInfo = this.declarationInfoByGlobalTokenName.get(desiredTokenKey); } else { @@ -1005,8 +1052,8 @@ export class DocumentFindings { findings.token = this.getLocalTokenForLine(tokenName, lineNbr); if (findings.token) { // we have a LOCAL token! - findings.tokenRawInterp = "Local: " + this._rememberdTokenString(tokenName, findings.token); - findings.scope = "Local"; + findings.tokenRawInterp = 'Local: ' + this._rememberdTokenString(tokenName, findings.token); + findings.scope = 'Local'; // and get additional info for token declInfo = this.declarationInfoByLocalTokenName.get(desiredTokenKey); } else { @@ -1014,12 +1061,12 @@ export class DocumentFindings { findings.token = this.methodLocalPasmTokens.getToken(tokenName); findings.relatedMethodName = this.methodLocalPasmTokens.getMethodNameForToken(tokenName); if (findings.relatedMethodName) { - findings.relatedMethodName = findings.relatedMethodName + "()"; + findings.relatedMethodName = findings.relatedMethodName + '()'; } if (findings.token) { // we have a LOCAL token! - findings.tokenRawInterp = "Method-local: " + this._rememberdTokenString(tokenName, findings.token); - findings.scope = "Local"; + findings.tokenRawInterp = 'Method-local: ' + this._rememberdTokenString(tokenName, findings.token); + findings.scope = 'Local'; // and get additional info for token declInfo = this.declarationInfoByLocalTokenName.get(desiredTokenKey); } @@ -1033,7 +1080,7 @@ export class DocumentFindings { private _locateNonBlankLineAfter(lineIdx: number): number { let desiredLineIdx: number = lineIdx; if (this.blockComments.length > 0) { - for (let blockComment of this.blockComments) { + for (const blockComment of this.blockComments) { // only one comment will match... either or both of the line indexes if (blockComment.includesLine(lineIdx) || blockComment.includesLine(lineIdx + 1)) { desiredLineIdx = blockComment.firstLine; @@ -1045,69 +1092,81 @@ export class DocumentFindings { return desiredLineIdx; } - private _interpretToken(token: RememberedToken, scope: string, name: string, declInfo: RememberedTokenDeclarationInfo | undefined): ITokenInterpretation { - this._logMessage(` -- _interpretToken() scope=[${scope}], name=[${name}], line#=[${declInfo?.lineIndex}]` + this._rememberdTokenString(name, token)); - let desiredInterp: ITokenInterpretation = { interpretation: "", scope: scope.toLowerCase(), name: name, isGoodInterp: true }; - desiredInterp.interpretation = "--type??"; - if (token?.type == "variable" && token?.modifiers.includes("readonly") && !declInfo?.isObjectReference) { + private _interpretToken( + token: RememberedToken, + scope: string, + name: string, + declInfo: RememberedTokenDeclarationInfo | undefined + ): ITokenInterpretation { + this._logMessage( + ` -- _interpretToken() scope=[${scope}], name=[${name}], line#=[${declInfo?.lineIndex}]` + this._rememberdTokenString(name, token) + ); + const desiredInterp: ITokenInterpretation = { + interpretation: '', + scope: scope.toLowerCase(), + name: name, + isGoodInterp: true + }; + desiredInterp.interpretation = '--type??'; + if (token?.type == 'variable' && token?.modifiers.includes('readonly') && !declInfo?.isObjectReference) { // have non object reference - desiredInterp.scope = "object public"; // not just global - desiredInterp.interpretation = "32-bit constant"; - } else if (token?.type == "variable" && token?.modifiers.includes("readonly") && declInfo?.isObjectReference) { + desiredInterp.scope = 'object public'; // not just global + desiredInterp.interpretation = '32-bit constant'; + } else if (token?.type == 'variable' && token?.modifiers.includes('readonly') && declInfo?.isObjectReference) { // have object interface constant - desiredInterp.scope = "object interface"; // not just global - desiredInterp.interpretation = "32-bit constant"; - } else if (token?.type == "debugDisplay") { - desiredInterp.scope = "object"; // ignore for this (or move `object` here?) - desiredInterp.interpretation = "user debug display"; - } else if (token?.type == "namespace") { - desiredInterp.scope = "object"; // ignore for this (or move `object` here?) - desiredInterp.interpretation = "named instance"; - } else if (token?.type == "variable") { - desiredInterp.interpretation = "variable"; - if (token?.modifiers.includes("pasmInline")) { - desiredInterp.scope = "method-local"; // ignore for this (or move `object` here?) - desiredInterp.interpretation = "inline-pasm variable"; - } else if (token?.modifiers.includes("local")) { - desiredInterp.scope = "method"; // ignore for this (or move `object` here?) - desiredInterp.interpretation = "local variable"; - } else if (token?.modifiers.includes("instance")) { - desiredInterp.scope = "object private"; // ignore for this (or move `object` here?) - desiredInterp.interpretation = "instance " + desiredInterp.interpretation + " -VAR"; + desiredInterp.scope = 'object interface'; // not just global + desiredInterp.interpretation = '32-bit constant'; + } else if (token?.type == 'debugDisplay') { + desiredInterp.scope = 'object'; // ignore for this (or move `object` here?) + desiredInterp.interpretation = 'user debug display'; + } else if (token?.type == 'namespace') { + desiredInterp.scope = 'object'; // ignore for this (or move `object` here?) + desiredInterp.interpretation = 'named instance'; + } else if (token?.type == 'variable') { + desiredInterp.interpretation = 'variable'; + if (token?.modifiers.includes('pasmInline')) { + desiredInterp.scope = 'method-local'; // ignore for this (or move `object` here?) + desiredInterp.interpretation = 'inline-pasm variable'; + } else if (token?.modifiers.includes('local')) { + desiredInterp.scope = 'method'; // ignore for this (or move `object` here?) + desiredInterp.interpretation = 'local variable'; + } else if (token?.modifiers.includes('instance')) { + desiredInterp.scope = 'object private'; // ignore for this (or move `object` here?) + desiredInterp.interpretation = 'instance ' + desiredInterp.interpretation + ' -VAR'; } else { - desiredInterp.scope = "object private"; // ignore for this (or move `object` here?) - desiredInterp.interpretation = "shared " + desiredInterp.interpretation + " -DAT"; + desiredInterp.scope = 'object private'; // ignore for this (or move `object` here?) + desiredInterp.interpretation = 'shared ' + desiredInterp.interpretation + ' -DAT'; } - } else if (token?.type == "label") { - if (token?.modifiers.includes("pasmInline")) { - desiredInterp.scope = "method-local"; // ignore for this (or move `object` here?) - desiredInterp.interpretation = "inline-pasm label"; + } else if (token?.type == 'label') { + if (token?.modifiers.includes('pasmInline')) { + desiredInterp.scope = 'method-local'; // ignore for this (or move `object` here?) + desiredInterp.interpretation = 'inline-pasm label'; } else { - desiredInterp.scope = "object private"; // not just global - if (token?.modifiers.includes("static")) { - desiredInterp.interpretation = "local pasm label"; + desiredInterp.scope = 'object private'; // not just global + if (token?.modifiers.includes('static')) { + desiredInterp.interpretation = 'local pasm label'; } else { - desiredInterp.interpretation = "pasm label"; + desiredInterp.interpretation = 'pasm label'; } } - } else if (token?.type == "returnValue") { - desiredInterp.scope = "method"; // ignore for this (or method?) - desiredInterp.interpretation = "return value"; - } else if (token?.type == "parameter") { - desiredInterp.scope = "method"; // ignore for this (or method?) - desiredInterp.interpretation = "parameter"; - } else if (token?.type == "enumMember") { - desiredInterp.interpretation = "enum value"; - } else if (token?.type == "method") { - desiredInterp.name = name + "()"; - desiredInterp.scope = "object"; - if (token?.modifiers.includes("static")) { - desiredInterp.interpretation = "private method"; + } else if (token?.type == 'returnValue') { + desiredInterp.scope = 'method'; // ignore for this (or method?) + desiredInterp.interpretation = 'return value'; + } else if (token?.type == 'parameter') { + desiredInterp.scope = 'method'; // ignore for this (or method?) + desiredInterp.interpretation = 'parameter'; + } else if (token?.type == 'enumMember') { + desiredInterp.interpretation = 'enum value'; + } else if (token?.type == 'method') { + desiredInterp.name = name + '()'; + desiredInterp.scope = 'object'; + if (token?.modifiers.includes('static')) { + desiredInterp.interpretation = 'private method'; } else { if (declInfo?.isObjectReference) { - desiredInterp.scope = "object interface"; // not just global + desiredInterp.scope = 'object interface'; // not just global } - desiredInterp.interpretation = "public method"; + desiredInterp.interpretation = 'public method'; } } else { desiredInterp.isGoodInterp = false; @@ -1117,12 +1176,12 @@ export class DocumentFindings { private _fillInFindings(tokenName: string, findings: ITokenDescription, declInfo: RememberedTokenDeclarationInfo | undefined) { if (findings.token) { - let details: ITokenInterpretation = this._interpretToken(findings.token, findings.scope, tokenName, declInfo); + const details: ITokenInterpretation = this._interpretToken(findings.token, findings.scope, tokenName, declInfo); findings.isGoodInterp = details.isGoodInterp; findings.interpretation = details.interpretation; findings.scope = details.scope; findings.adjustedName = details.name; - const bIsMethod: boolean = findings.token.type == "method"; + const bIsMethod: boolean = findings.token.type == 'method'; if (declInfo) { // and decorate with declaration line number findings.declarationLineIdx = declInfo.lineIndex; @@ -1138,7 +1197,7 @@ export class DocumentFindings { findings.relatedObjectName = declInfo.reference; } } - const bIsPublic: boolean = findings.token.modifiers.includes("static") ? false : true; + const bIsPublic: boolean = findings.token.modifiers.includes('static') ? false : true; if (bIsMethod) { const commentType: eCommentFilter = bIsPublic ? eCommentFilter.docCommentOnly : eCommentFilter.nondocCommentOnly; const nonBlankLineIdx: number = this._locateNonBlankLineAfter(findings.declarationLineIdx + 1); // +1 is line after signature @@ -1154,13 +1213,13 @@ export class DocumentFindings { findings.declarationComment = declInfo.comment; } // NOTE: use fake signature comment instead when there Are params and declInfo doesn't describe them - const haveDeclParams: boolean = findings.declarationComment && findings.declarationComment?.includes("@param") ? true : false; + const haveDeclParams: boolean = findings.declarationComment && findings.declarationComment?.includes('@param') ? true : false; this._logMessage(` -- FND-xxxTOK haveDeclParams=(${haveDeclParams})`); if (!haveDeclParams) { - let fakeComment: string | undefined = this.fakeCommentMDFromLine(nonBlankLineIdx, commentType); + const fakeComment: string | undefined = this.fakeCommentMDFromLine(nonBlankLineIdx, commentType); if (fakeComment) { if (findings.declarationComment) { - findings.declarationComment = findings.declarationComment + "

" + fakeComment; + findings.declarationComment = findings.declarationComment + '

' + fakeComment; } else { findings.declarationComment = fakeComment; } @@ -1194,7 +1253,7 @@ export class DocumentFindings { // (this is global name above and below currLine) const tokenKey: string = labelTokenName.toLowerCase(); let localLabelPosn: Position = { line: -1, character: -1 }; - let tokenDeclLines: number[] | undefined = this.declarationLocalLabelLineCache.get(tokenKey); + const tokenDeclLines: number[] | undefined = this.declarationLocalLabelLineCache.get(tokenKey); if (tokenDeclLines) { if (tokenDeclLines.length > 1) { //this._logMessage(` -- gBLLPFP local=[${tokenDeclLines}](${tokenDeclLines.length})`); @@ -1241,7 +1300,9 @@ export class DocumentFindings { } else { this._logMessage(` -- gBLLPFP ERROR no decl lines for tok=[${labelTokenName}]`); } - this._logMessage(` -- gBLLPFP posn=[${position.line}, ${position.character}], tok=[${labelTokenName}] -> posn=[${localLabelPosn.line}, ${localLabelPosn.character}}]`); + this._logMessage( + ` -- gBLLPFP posn=[${position.line}, ${position.character}], tok=[${labelTokenName}] -> posn=[${localLabelPosn.line}, ${localLabelPosn.character}}]` + ); return localLabelPosn; } @@ -1249,7 +1310,7 @@ export class DocumentFindings { public recordDeclarationLine(line: string, lineNbr: number, declType: eDefinitionType = eDefinitionType.NonLabel) { // remember our declaration line for later use // (first one in, wins) - const lineIdx: Number = lineNbr - 1; + const lineIdx: number = lineNbr - 1; if (!this.declarationLineCache.has(lineIdx)) { this.declarationLineCache.set(lineIdx, line); } @@ -1269,7 +1330,7 @@ export class DocumentFindings { } public TEST_dumpLineCache() { - const lineNbrKeys: Number[] = Array.from(this.declarationLineCache.keys()); + const lineNbrKeys: number[] = Array.from(this.declarationLineCache.keys()); this._logMessage(` -- FND-LineCache -------------------------`); for (let index = 0; index < lineNbrKeys.length; index++) { const lineIdx = lineNbrKeys[index]; @@ -1283,9 +1344,13 @@ export class DocumentFindings { public setGlobalToken(tokenName: string, token: RememberedToken, declarationComment: string | undefined, reference?: string | undefined): void { // FIXME: TODO: UNDONE - this needs to allow multiple .tokenName's or :tokenName's and keep line numbers for each. // this allows go-to to get to nearest earlier than right-mouse line - const isLocalLabel: boolean = (tokenName.startsWith(".") || tokenName.startsWith(":")) && token.type === "label"; + const isLocalLabel: boolean = (tokenName.startsWith('.') || tokenName.startsWith(':')) && token.type === 'label'; if (!this.isGlobalToken(tokenName)) { - this._logMessage(" -- NEW-gloTOK " + this._rememberdTokenString(tokenName, token) + `, ln#${token.lineIndex + 1}, cmt=[${declarationComment}], ref=[${reference}]`); + this._logMessage( + ' -- NEW-gloTOK ' + + this._rememberdTokenString(tokenName, token) + + `, ln#${token.lineIndex + 1}, cmt=[${declarationComment}], ref=[${reference}]` + ); this.globalTokens.setToken(tokenName, token); // and remember declataion line# for this token const newDescription: RememberedTokenDeclarationInfo = new RememberedTokenDeclarationInfo(token.lineIndex, declarationComment, reference); @@ -1315,13 +1380,13 @@ export class DocumentFindings { } public getGlobalToken(tokenName: string): RememberedToken | undefined { - var desiredToken: RememberedToken | undefined = this.globalTokens.getToken(tokenName); + let desiredToken: RememberedToken | undefined = this.globalTokens.getToken(tokenName); if (desiredToken != undefined) { // let's never return a declaration modifier! (somehow declaration creeps in to our list!??) //let modifiersNoDecl: string[] = this._modifiersWithout(desiredToken.modifiers, "declaration"); - let modifiersNoDecl: string[] = desiredToken.modifiersWithout("declaration"); + const modifiersNoDecl: string[] = desiredToken.modifiersWithout('declaration'); desiredToken = new RememberedToken(desiredToken.type, desiredToken.lineIndex, desiredToken.charIndex, modifiersNoDecl); - this._logMessage(" -- FND-gloTOK " + this._rememberdTokenString(tokenName, desiredToken)); + this._logMessage(' -- FND-gloTOK ' + this._rememberdTokenString(tokenName, desiredToken)); } return desiredToken; } @@ -1354,7 +1419,11 @@ export class DocumentFindings { public setLocalTokenForMethod(methodName: string, tokenName: string, token: RememberedToken, declarationComment: string | undefined): void { if (!this.isLocalTokenForMethod(methodName, tokenName)) { - this._logMessage(` -- NEW-locTOK ln#${token.lineIndex + 1} method=[${methodName}], ` + this._rememberdTokenString(tokenName, token) + `, cmt=[${declarationComment}]`); + this._logMessage( + ` -- NEW-locTOK ln#${token.lineIndex + 1} method=[${methodName}], ` + + this._rememberdTokenString(tokenName, token) + + `, cmt=[${declarationComment}]` + ); this.methodLocalTokens.setTokenForMethod(methodName, tokenName, token); // and remember declataion line# for this token const desiredTokenKey: string = tokenName.toLowerCase(); @@ -1398,12 +1467,19 @@ export class DocumentFindings { public endPossibleMethod(lineNbr: number): void { // possibly ending a method if one was started, end it, else ignore this if (this.currMethodName) { - const spanInfo: IMethodSpan = { startLineIdx: this.currMethodStartLineNbr, endLineIdx: lineNbr }; + const spanInfo: IMethodSpan = { + startLineIdx: this.currMethodStartLineNbr, + endLineIdx: lineNbr + }; if (!this.spanInfoByMethodName.has(this.currMethodName)) { this.spanInfoByMethodName.set(this.currMethodName, spanInfo); - this._logMessage(` -- END-Method SPAN Ln#${lineNbr} method=[${this.currMethodName}], span=[${spanInfo.startLineIdx}, ${spanInfo.endLineIdx}]`); + this._logMessage( + ` -- END-Method SPAN Ln#${lineNbr} method=[${this.currMethodName}], span=[${spanInfo.startLineIdx}, ${spanInfo.endLineIdx}]` + ); } else { - this._logMessage(` -- DUPE!! SPAN Ln#${lineNbr} method=[${this.currMethodName}], span=[${spanInfo.startLineIdx}, ${spanInfo.endLineIdx}] IGNORED!`); + this._logMessage( + ` -- DUPE!! SPAN Ln#${lineNbr} method=[${this.currMethodName}], span=[${spanInfo.startLineIdx}, ${spanInfo.endLineIdx}] IGNORED!` + ); } } // now clear in progress @@ -1439,19 +1515,19 @@ export class DocumentFindings { } public hasLocalPasmToken(tokenName: string): boolean { - let tokenExistsStatus: boolean = this.methodLocalPasmTokens.hasToken(tokenName); + const tokenExistsStatus: boolean = this.methodLocalPasmTokens.hasToken(tokenName); return tokenExistsStatus; } public hasLocalPAsmTokenForMethod(methodName: string, tokenName: string): boolean { - let foundStatus: boolean = this.methodLocalPasmTokens.hasTokenForMethod(methodName, tokenName); + const foundStatus: boolean = this.methodLocalPasmTokens.hasTokenForMethod(methodName, tokenName); return foundStatus; } public setLocalPAsmTokenForMethod(methodName: string, tokenName: string, token: RememberedToken, declarationComment: string | undefined): void { // FIXME: TODO: UNDONE - this needs to allow multiple .tokenName's or :tokenName's and keep line numbers for each. // this allows go-to to get to nearest earlier than right-mouse line - const isLocalLabel: boolean = (tokenName.startsWith(".") || tokenName.startsWith(":")) && token.type === "label"; + const isLocalLabel: boolean = (tokenName.startsWith('.') || tokenName.startsWith(':')) && token.type === 'label'; if (this.hasLocalPAsmTokenForMethod(methodName, tokenName)) { // locals can appear many times... if (!isLocalLabel) { @@ -1466,7 +1542,7 @@ export class DocumentFindings { this.declarationInfoByLocalTokenName.set(desiredTokenKey, new RememberedTokenDeclarationInfo(token.lineIndex, declarationComment)); const newToken = this.methodLocalPasmTokens.getTokenForMethod(methodName, tokenName); if (newToken) { - this._logMessage(" -- NEW-lpTOK method=" + methodName + ": " + this._rememberdTokenString(tokenName, newToken)); + this._logMessage(' -- NEW-lpTOK method=' + methodName + ': ' + this._rememberdTokenString(tokenName, newToken)); } } if (isLocalLabel) { @@ -1476,9 +1552,9 @@ export class DocumentFindings { } public getLocalPAsmTokenForMethod(methodName: string, tokenName: string): RememberedToken | undefined { - let desiredToken: RememberedToken | undefined = this.methodLocalPasmTokens.getTokenForMethod(methodName, tokenName); + const desiredToken: RememberedToken | undefined = this.methodLocalPasmTokens.getTokenForMethod(methodName, tokenName); if (desiredToken) { - this._logMessage(" -- FND-lpTOK method=" + methodName + ": " + this._rememberdTokenString(tokenName, desiredToken)); + this._logMessage(' -- FND-lpTOK method=' + methodName + ': ' + this._rememberdTokenString(tokenName, desiredToken)); } return desiredToken; } @@ -1489,7 +1565,7 @@ export class DocumentFindings { if (localMethodName) { desiredToken = this.methodLocalPasmTokens.getTokenForMethod(localMethodName, tokenName); if (desiredToken) { - this._logMessage(" -- GET-lpTOK method=" + localMethodName + ": " + this._rememberdTokenString(tokenName, desiredToken)); + this._logMessage(' -- GET-lpTOK method=' + localMethodName + ': ' + this._rememberdTokenString(tokenName, desiredToken)); } } return desiredToken; @@ -1508,9 +1584,9 @@ export class DocumentFindings { } private _rememberdTokenString(tokenName: string, aToken: RememberedToken | undefined): string { - let desiredInterp: string = " -- token=[len:" + tokenName.length + " [" + tokenName + "](undefined)"; + let desiredInterp: string = ' -- token=[len:' + tokenName.length + ' [' + tokenName + '](undefined)'; if (aToken != undefined) { - desiredInterp = " -- token=[len:" + tokenName.length + " [" + tokenName + "](" + aToken.type + "[" + aToken.modifiers + "])]"; + desiredInterp = ' -- token=[len:' + tokenName.length + ' [' + tokenName + '](' + aToken.type + '[' + aToken.modifiers + '])]'; } return desiredInterp; } @@ -1534,20 +1610,27 @@ export class DocumentFindings { const possibleType: eDebugDisplayType | undefined = displayEnumByTypeName.get(typeName.toLowerCase()); desiredType = possibleType || eDebugDisplayType.Unknown; } - this._logMessage(" DDsply getDebugDisplayEnumForType(" + typeName + ") = enum(" + desiredType + "), " + this.getNameForDebugDisplayEnum(desiredType)); + this._logMessage( + ' DDsply getDebugDisplayEnumForType(' + typeName + ') = enum(' + desiredType + '), ' + this.getNameForDebugDisplayEnum(desiredType) + ); return desiredType; } public setUserDebugDisplay(typeName: string, userName: string, lineNbr: number): void { const nameKey: string = userName.toLowerCase(); - this._logMessage(" DDsply _setUserDebugDisplay(" + typeName + ", " + userName + ", li#" + lineNbr + ")"); + this._logMessage(' DDsply _setUserDebugDisplay(' + typeName + ', ' + userName + ', li#' + lineNbr + ')'); if (!this.isKnownDebugDisplay(userName)) { - let eType: eDebugDisplayType = this.getDebugDisplayEnumForType(typeName); - let displayInfo: IDebugDisplayInfo = { displayTypeString: typeName, userName: userName, lineNbr: lineNbr, eDisplayType: eType }; + const eType: eDebugDisplayType = this.getDebugDisplayEnumForType(typeName); + const displayInfo: IDebugDisplayInfo = { + displayTypeString: typeName, + userName: userName, + lineNbr: lineNbr, + eDisplayType: eType + }; this.displayInfoByDebugDisplayName.set(nameKey, displayInfo); //this._logMessage(" -- DDsply " + userName.toLowerCase() + "=[" + eDisplayType + " : " + typeName.toLowerCase() + "]"); } else { - this._logMessage("ERROR: DDsply setUserDebugDisplay() display exists [" + userName + "]"); + this._logMessage('ERROR: DDsply setUserDebugDisplay() display exists [' + userName + ']'); } } @@ -1565,7 +1648,12 @@ export class DocumentFindings { public getDebugDisplayInfoForUserName(possibleUserName: string): IDebugDisplayInfo { const nameKey: string = possibleUserName.toLowerCase(); - let possibleInfo: IDebugDisplayInfo = { displayTypeString: "", userName: "", lineNbr: 0, eDisplayType: eDebugDisplayType.Unknown }; + let possibleInfo: IDebugDisplayInfo = { + displayTypeString: '', + userName: '', + lineNbr: 0, + eDisplayType: eDebugDisplayType.Unknown + }; if (this.isKnownDebugDisplay(possibleUserName)) { const infoFound: IDebugDisplayInfo | undefined = this.displayInfoByDebugDisplayName.get(nameKey); if (infoFound) { @@ -1576,21 +1664,21 @@ export class DocumentFindings { } public getNameForDebugDisplayEnum(eDisplayType: eDebugDisplayType): string { - let desiredName: string = "?no-value-in-map?"; - for (let [idString, eValue] of displayEnumByTypeName.entries()) { + let desiredName: string = '?no-value-in-map?'; + for (const [idString, eValue] of displayEnumByTypeName.entries()) { if (eValue === eDisplayType) { desiredName = idString; break; } } - this._logMessage(" DDsply getNameForDebugDisplayEnum(enum: " + eDisplayType + ") = " + desiredName); + this._logMessage(' DDsply getNameForDebugDisplayEnum(enum: ' + eDisplayType + ') = ' + desiredName); return desiredName; } public isKnownDebugDisplay(possibleUserName: string): boolean { const nameKey: string = possibleUserName.toLowerCase(); const foundStatus: boolean = this.displayInfoByDebugDisplayName.has(nameKey); - this._logMessage(" DDsply _isKnownDebugDisplay(" + possibleUserName + ") = " + foundStatus); + this._logMessage(' DDsply _isKnownDebugDisplay(' + possibleUserName + ') = ' + foundStatus); return foundStatus; } @@ -1621,7 +1709,7 @@ export class TokenSet { this._logMessage(`* ${this.id} ready`); } - private id: string = ""; + private id: string = ''; private rememberedTokenByName = new Map(); private ctx: Context | undefined = undefined; private bLogEnabled: boolean = false; @@ -1650,7 +1738,7 @@ export class TokenSet { public clear(): void { this.rememberedTokenByName.clear(); - this._logMessage(`* ${this.id} clear() now ` + this.length() + " tokens"); + this._logMessage(`* ${this.id} clear() now ` + this.length() + ' tokens'); } public length(): number { @@ -1693,11 +1781,11 @@ export class TokenSet { public getToken(tokenName: string): RememberedToken | undefined { const desiredTokenKey: string = tokenName.toLowerCase(); - var desiredToken: RememberedToken | undefined = this.rememberedTokenByName.get(desiredTokenKey); + let desiredToken: RememberedToken | undefined = this.rememberedTokenByName.get(desiredTokenKey); if (desiredToken != undefined) { // let's never return a declaration modifier! (somehow "declaration" creeps in to our list!??) //let modifiersNoDecl: string[] = this._modifiersWithout(desiredToken.modifiers, "declaration"); - let modifiersNoDecl: string[] = desiredToken.modifiersWithout("declaration"); + const modifiersNoDecl: string[] = desiredToken.modifiersWithout('declaration'); desiredToken = new RememberedToken(desiredToken.type, desiredToken.lineIndex, desiredToken.charIndex, modifiersNoDecl); } return desiredToken; @@ -1709,7 +1797,7 @@ export class TokenSet { // CLASS NameScopedTokenSet // export class NameScopedTokenSet { - private id: string = ""; + private id: string = ''; private methodScopedTokenSetByMethodKey = new Map(); private origMethodNamebyMethodKey = new Map(); private ctx: Context | undefined = undefined; @@ -1751,15 +1839,15 @@ export class NameScopedTokenSet { public clear(): void { this.methodScopedTokenSetByMethodKey.clear(); this.origMethodNamebyMethodKey.clear(); - this._logMessage(`* ${this.id} clear() now ` + this.length() + " tokens"); + this._logMessage(`* ${this.id} clear() now ` + this.length() + ' tokens'); } public clearForMethod(methodName: string) { const desiredMethodKey = methodName.toLowerCase(); - let methodTokenSet = this._getMapForMethod(desiredMethodKey); + const methodTokenSet = this._getMapForMethod(desiredMethodKey); if (methodTokenSet) { methodTokenSet.clear(); - this._logMessage(`* ${this.id} clearForMethod(${desiredMethodKey}) now ` + methodTokenSet.length() + " tokens"); + this._logMessage(`* ${this.id} clearForMethod(${desiredMethodKey}) now ` + methodTokenSet.length() + ' tokens'); } } @@ -1821,10 +1909,12 @@ export class NameScopedTokenSet { methodTokenSet = this._getMapForMethod(desiredMethodKey); } if (methodTokenSet && methodTokenSet.hasToken(desiredTokenKey)) { - this._logMessage(`ERROR attempt to redefine ${desiredTokenKey} in method ${desiredMethodKey} as: ` + this._rememberdTokenString(tokenName, token)); + this._logMessage( + `ERROR attempt to redefine ${desiredTokenKey} in method ${desiredMethodKey} as: ` + this._rememberdTokenString(tokenName, token) + ); } else { if (methodTokenSet) { - this._logMessage(" -- NEW-lpTOK " + desiredTokenKey + "=[" + token.type + "[" + token.modifiers + "]]"); + this._logMessage(' -- NEW-lpTOK ' + desiredTokenKey + '=[' + token.type + '[' + token.modifiers + ']]'); methodTokenSet.setToken(desiredTokenKey, token); } } @@ -1833,7 +1923,6 @@ export class NameScopedTokenSet { public getToken(tokenName: string): RememberedToken | undefined { let desiredToken: RememberedToken | undefined = undefined; const desiredTokenKey = tokenName.toLowerCase(); - let tokenExistsStatus: boolean = false; for (const methodKey of this.methodScopedTokenSetByMethodKey.keys()) { if (this.hasTokenForMethod(methodKey, desiredTokenKey)) { desiredToken = this.getTokenForMethod(methodKey, desiredTokenKey); @@ -1846,7 +1935,7 @@ export class NameScopedTokenSet { public getMethodNameForToken(tokenName: string): string | undefined { const desiredTokenKey = tokenName.toLowerCase(); let desiredMethodName: string | undefined = undefined; - for (let methodKey of this.methodScopedTokenSetByMethodKey.keys()) { + for (const methodKey of this.methodScopedTokenSetByMethodKey.keys()) { if (this.hasTokenForMethod(methodKey, desiredTokenKey)) { desiredMethodName = methodKey; if (this.origMethodNamebyMethodKey.has(methodKey)) { @@ -1867,7 +1956,7 @@ export class NameScopedTokenSet { if (methodLocalsTokenSet) { desiredToken = methodLocalsTokenSet.getToken(desiredTokenKey); if (desiredToken) { - this._logMessage(" -- FND-lpTOK " + this._rememberdTokenString(tokenName, desiredToken)); + this._logMessage(' -- FND-lpTOK ' + this._rememberdTokenString(tokenName, desiredToken)); } } else { this._logMessage(` -- FND - lpTOK gtfm() no such nethodName = [${methodName}]`); @@ -1879,9 +1968,9 @@ export class NameScopedTokenSet { } private _rememberdTokenString(tokenName: string, aToken: RememberedToken | undefined): string { - let desiredInterp: string = " -- LP token=[len:" + tokenName.length + " [" + tokenName + "](undefined)"; + let desiredInterp: string = ' -- LP token=[len:' + tokenName.length + ' [' + tokenName + '](undefined)'; if (aToken != undefined) { - desiredInterp = " -- LP token=[len:" + tokenName.length + " [" + tokenName + "](" + aToken.type + "[" + aToken.modifiers + "])]"; + desiredInterp = ' -- LP token=[len:' + tokenName.length + ' [' + tokenName + '](' + aToken.type + '[' + aToken.modifiers + '])]'; } return desiredInterp; } @@ -1934,11 +2023,11 @@ export class RememberedToken { public isPublic(): boolean { // is symbol from CON section or is PUB method? let publicStatus: boolean = false; - if (this._type === "variable" && this._modifiers.includes("readonly")) { + if (this._type === 'variable' && this._modifiers.includes('readonly')) { publicStatus = true; - } else if (this._type === "enumMember") { + } else if (this._type === 'enumMember') { publicStatus = true; - } else if (this._type === "method" && !this._modifiers.includes("static")) { + } else if (this._type === 'method' && !this._modifiers.includes('static')) { publicStatus = true; } return publicStatus; @@ -1948,7 +2037,7 @@ export class RememberedToken { public modifiersWith(newModifier: string): string[] { // add modification attribute - var updatedModifiers: string[] = this._modifiers; + const updatedModifiers: string[] = this._modifiers; if (!updatedModifiers.includes(newModifier)) { updatedModifiers.push(newModifier); } @@ -1957,9 +2046,9 @@ export class RememberedToken { public modifiersWithout(unwantedModifier: string): string[] { // remove modification attribute - var updatedModifiers: string[] = []; - for (var idx = 0; idx < this._modifiers.length; idx++) { - var possModifier: string = this._modifiers[idx]; + const updatedModifiers: string[] = []; + for (let idx = 0; idx < this._modifiers.length; idx++) { + const possModifier: string = this._modifiers[idx]; if (possModifier !== unwantedModifier) { updatedModifiers.push(possModifier); } @@ -1990,7 +2079,7 @@ export class RememberedTokenDeclarationInfo { this._declcomment = declarationComment.trim(); } } - if (typeof reference !== "undefined" && reference != undefined) { + if (typeof reference !== 'undefined' && reference != undefined) { this._reference = reference; } } @@ -2037,7 +2126,7 @@ export enum eCommentType { singleLineComment, singleLineDocComment, multiLineComment, - multiLineDocComment, + multiLineDocComment } export class RememberedComment { @@ -2053,11 +2142,11 @@ export class RememberedComment { // remove comment from first line let trimmedLine: string = firstLine; if (this._type == eCommentType.multiLineDocComment) { - if (trimmedLine.startsWith("{{")) { + if (trimmedLine.startsWith('{{')) { trimmedLine = trimmedLine.substring(2); } } else if (this._type == eCommentType.multiLineComment) { - if (trimmedLine.startsWith("{")) { + if (trimmedLine.startsWith('{')) { trimmedLine = trimmedLine.substring(1); } } @@ -2098,22 +2187,22 @@ export class RememberedComment { public commentAsMarkDown(): string | undefined { // Return the markdown for this block comment let linesAsComment: string | undefined = undefined; - let tempLines: string[] = []; + const tempLines: string[] = []; // if keywords are found in comment then specially wrap the word following each keyword if (this.lineCount > 0) { for (let idx = 0; idx < this.lines.length; idx++) { const currLine = this.lines[idx]; - const lineParts = currLine.split(" "); - let findIndex = lineParts.indexOf("@param"); + const lineParts = currLine.split(' '); + let findIndex = lineParts.indexOf('@param'); let nameItem: string | undefined = undefined; if (findIndex != -1 && findIndex < lineParts.length - 1) { nameItem = lineParts[findIndex + 1]; } else { - findIndex = lineParts.indexOf("@returns"); + findIndex = lineParts.indexOf('@returns'); if (findIndex != -1 && findIndex < lineParts.length - 1) { nameItem = lineParts[findIndex + 1]; } else { - findIndex = lineParts.indexOf("@local"); + findIndex = lineParts.indexOf('@local'); if (findIndex != -1 && findIndex < lineParts.length - 1) { nameItem = lineParts[findIndex + 1]; } @@ -2122,14 +2211,14 @@ export class RememberedComment { if (nameItem) { // now wrap the name in single back ticks const originameItem: string = nameItem; - nameItem = nameItem.replace("`", "").replace("`", ""); - const finishedLine: string = currLine.replace(originameItem, "`" + nameItem + "`"); + nameItem = nameItem.replace('`', '').replace('`', ''); + const finishedLine: string = currLine.replace(originameItem, '`' + nameItem + '`'); tempLines[idx] = finishedLine; } else { tempLines[idx] = currLine; } } - linesAsComment = tempLines.join("
"); + linesAsComment = tempLines.join('
'); } return linesAsComment; } @@ -2144,7 +2233,10 @@ export class RememberedComment { public span(): Range { // return the recorded line indexes (start,end) - span of the comment block - return { start: { line: this._1stLineIdx, character: 0 }, end: { line: this._lastLineIdx, character: Number.MAX_VALUE } }; + return { + start: { line: this._1stLineIdx, character: 0 }, + end: { line: this._lastLineIdx, character: Number.MAX_VALUE } + }; } public appendLine(line: string) { @@ -2158,7 +2250,7 @@ export class RememberedComment { let trimmedLine: string = line; let matchLocn: number = 0; if (this._type == eCommentType.multiLineDocComment) { - matchLocn = trimmedLine.indexOf("}}"); + matchLocn = trimmedLine.indexOf('}}'); if (matchLocn != -1) { if (matchLocn == 0) { trimmedLine = trimmedLine.substring(2); @@ -2173,7 +2265,7 @@ export class RememberedComment { // WHOA, missing our comment close but expecting it } } else if (this._type == eCommentType.multiLineComment) { - matchLocn = trimmedLine.indexOf("}"); + matchLocn = trimmedLine.indexOf('}'); if (matchLocn != -1) { if (matchLocn == 0) { trimmedLine = trimmedLine.substring(2); @@ -2227,7 +2319,7 @@ export class RememberedComment { let trimmedLine: string = this._lines[0]; let matchLocn: number = 0; if (this._type == eCommentType.multiLineDocComment) { - matchLocn = trimmedLine.indexOf("}}"); + matchLocn = trimmedLine.indexOf('}}'); if (matchLocn != -1) { if (matchLocn == 0) { trimmedLine = trimmedLine.substring(2); @@ -2237,7 +2329,7 @@ export class RememberedComment { } } } else if (this._type == eCommentType.multiLineComment) { - matchLocn = trimmedLine.indexOf("}"); + matchLocn = trimmedLine.indexOf('}'); if (matchLocn != -1) { if (matchLocn == 0) { trimmedLine = trimmedLine.substring(2); @@ -2266,15 +2358,15 @@ export class RememberedComment { const commentSpan: Range = this.span(); const startLine = commentSpan.start.line + 1; const endLine = commentSpan.end.line + 1; - let typeString: string = "??BlockComment??"; + let typeString: string = '??BlockComment??'; if (this._type == eCommentType.singleLineComment) { - typeString = "singleLineCommentBlock"; + typeString = 'singleLineCommentBlock'; } else if (this._type == eCommentType.singleLineDocComment) { - typeString = "singleLineDocCommentBlock"; + typeString = 'singleLineDocCommentBlock'; } else if (this._type == eCommentType.multiLineComment) { - typeString = "multiLineCommentBlock"; + typeString = 'multiLineCommentBlock'; } else if (this._type == eCommentType.multiLineDocComment) { - typeString = "multiLineDocCommentBlock"; + typeString = 'multiLineDocCommentBlock'; } const lineRef: string = startLine == endLine ? `Ln#${startLine}` : `Ln#${startLine}-${endLine}`; const interpString: string = `[${typeString}] ${lineRef}`; @@ -2283,13 +2375,13 @@ export class RememberedComment { public desribeComment(): string[] { const decriptionLines: string[] = []; - decriptionLines.push("-" + this.spanString()); - decriptionLines.push(" /-- --- ---"); + decriptionLines.push('-' + this.spanString()); + decriptionLines.push(' /-- --- ---'); for (let index = 0; index < this._lines.length; index++) { const line = this._lines[index]; decriptionLines.push(line); } - decriptionLines.push(" \\-- --- ---"); + decriptionLines.push(' \\-- --- ---'); return decriptionLines; } @@ -2297,7 +2389,7 @@ export class RememberedComment { // emtpy our line aray if it's really nothing worthwhile let bHaveNonBlank: boolean = false; for (let idx = 0; idx < this._lines.length; idx++) { - let currLine = this._lines[idx]; + const currLine = this._lines[idx]; if (currLine.length > 0) { bHaveNonBlank = true; break; diff --git a/spin2/server/src/parser/spin1.documentSemanticParser.ts b/spin2/server/src/parser/spin1.documentSemanticParser.ts index 9e7d9b1..4aabb74 100644 --- a/spin2/server/src/parser/spin1.documentSemanticParser.ts +++ b/spin2/server/src/parser/spin1.documentSemanticParser.ts @@ -1,15 +1,15 @@ -"use strict"; +'use strict'; // src/spin2.documentSemanticParser.ts -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Context, ServerBehaviorConfiguration, EditorConfiguration } from "../context"; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Context, ServerBehaviorConfiguration, EditorConfiguration } from '../context'; -import { DocumentFindings, RememberedComment, eCommentType, RememberedToken, eBLockType, eSeverity, eDefinitionType } from "./spin.semantic.findings"; -import { Spin1ParseUtils } from "./spin1.utils"; -import { isSpin1File } from "./lang.utils"; -import { eParseState, SpinControlFlowTracker, ICurrControlSpan } from "./spin.common"; -import { fileInDirExists } from "../files"; -import { ExtensionUtils } from "../parser/spin.extension.utils"; +import { DocumentFindings, RememberedComment, eCommentType, RememberedToken, eBLockType, eSeverity, eDefinitionType } from './spin.semantic.findings'; +import { Spin1ParseUtils } from './spin1.utils'; +import { isSpin1File } from './lang.utils'; +import { eParseState, SpinControlFlowTracker, ICurrControlSpan } from './spin.common'; +import { fileInDirExists } from '../files'; +import { ExtensionUtils } from '../parser/spin.extension.utils'; // ---------------------------------------------------------------------------- // Semantic Highlighting Provider @@ -53,12 +53,12 @@ export class Spin1DocumentSemanticParser { private configuration: ServerBehaviorConfiguration; private editorConfiguration: EditorConfiguration; - private currentMethodName: string = ""; - private currentFilespec: string = ""; + private currentMethodName: string = ''; + private currentFilespec: string = ''; private isSpin1Document: boolean = false; private bRecordTrailingComments: boolean = false; // initially, we don't generate tokens for trailing comments on lines - private directory: string = ""; + private directory: string = ''; public constructor(protected readonly ctx: Context) { this.extensionUtils = new ExtensionUtils(ctx, this.spin1DebugLogEnabled); @@ -68,9 +68,9 @@ export class Spin1DocumentSemanticParser { if (this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin1 semantic log started."); + this._logMessage('Spin1 semantic log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } @@ -137,7 +137,7 @@ export class Spin1DocumentSemanticParser { // -------------------- PRE-PARSE just locating symbol names -------------------- // also track and record block comments (both braces and tic's!) // let's also track prior single line and trailing comment on same line - this._logMessage("---> Pre SCAN"); + this._logMessage('---> Pre SCAN'); let bBuildingSingleLineCmtBlock: boolean = false; let bBuildingSingleLineDocCmtBlock: boolean = false; this.spinControlFlowTracker.reset(); @@ -148,7 +148,9 @@ export class Spin1DocumentSemanticParser { const trimmedLine = line.trim(); const lineWOutInlineComments: string = this.parseUtils.getLineWithoutInlineComments(line); const bHaveLineToProcess: boolean = lineWOutInlineComments.length > 0; - var trimmedNonCommentLine: string = bHaveLineToProcess ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments).trimStart() : ""; + let trimmedNonCommentLine: string = bHaveLineToProcess + ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments).trimStart() + : ''; const offSet: number = trimmedNonCommentLine.length > 0 ? line.indexOf(trimmedNonCommentLine) + 1 : line.indexOf(trimmedLine) + 1; const tempComment = line.substring(trimmedNonCommentLine.length + offSet).trim(); this.rightEdgeComment = tempComment.length > 0 ? tempComment : undefined; @@ -166,7 +168,7 @@ export class Spin1DocumentSemanticParser { if (currSingleLineBlockComment) { currSingleLineBlockComment.closeAsSingleLineBlock(i - 1); // NOTE: single line doc comments can be 1 line long!!! (unlike single line non-doc comments) - this._logMessage(" -- found comment " + currSingleLineBlockComment.spanString()); + this._logMessage(' -- found comment ' + currSingleLineBlockComment.spanString()); this.semanticFindings.recordComment(currSingleLineBlockComment); currSingleLineBlockComment = undefined; } @@ -178,7 +180,7 @@ export class Spin1DocumentSemanticParser { // NOTE: single line non-doc comments must be 2 or more lines long!!! (unlike single line doc comments) if (currSingleLineBlockComment.lineCount > 1) { currSingleLineBlockComment.closeAsSingleLineBlock(i - 1); - this._logMessage(" -- found comment " + currSingleLineBlockComment.spanString()); + this._logMessage(' -- found comment ' + currSingleLineBlockComment.spanString()); this.semanticFindings.recordComment(currSingleLineBlockComment); } currSingleLineBlockComment = undefined; @@ -188,7 +190,7 @@ export class Spin1DocumentSemanticParser { // now start our processing if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = lineWOutInlineComments.indexOf("}}"); + const closingOffset = lineWOutInlineComments.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended // end the comment recording @@ -196,7 +198,7 @@ export class Spin1DocumentSemanticParser { // record new comment if (currBlockComment) { this.semanticFindings.recordComment(currBlockComment); - this._logMessage(" -- found comment " + currBlockComment.spanString()); + this._logMessage(' -- found comment ' + currBlockComment.spanString()); currBlockComment = undefined; } currState = priorState; @@ -210,7 +212,7 @@ export class Spin1DocumentSemanticParser { } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit // ALLOW {...} on same line without closing! - const closingOffset: number = lineWOutInlineComments.indexOf("}"); + const closingOffset: number = lineWOutInlineComments.indexOf('}'); if (closingOffset != -1) { // have close, comment ended // end the comment recording @@ -218,7 +220,7 @@ export class Spin1DocumentSemanticParser { // record new comment if (currBlockComment) { this.semanticFindings.recordComment(currBlockComment); - this._logMessage(" -- found comment " + currBlockComment.spanString()); + this._logMessage(' -- found comment ' + currBlockComment.spanString()); currBlockComment = undefined; } currState = priorState; @@ -268,18 +270,18 @@ export class Spin1DocumentSemanticParser { currSingleLineBlockComment = new RememberedComment(eCommentType.singleLineComment, i, line); } continue; - } else if (trimmedNonCommentLine.startsWith("{{")) { + } else if (trimmedNonCommentLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line {{comment}}, just ignore it Let Syntax highlighting do this // record new single-line comment - let oneLineComment = new RememberedComment(eCommentType.multiLineDocComment, i, line); + const oneLineComment = new RememberedComment(eCommentType.multiLineDocComment, i, line); oneLineComment.closeAsSingleLine(); if (!oneLineComment.isBlankLine) { this.semanticFindings.recordComment(oneLineComment); - this._logMessage(" -- found comment " + oneLineComment.spanString()); + this._logMessage(' -- found comment ' + oneLineComment.spanString()); } currBlockComment = undefined; // just making sure... } else { @@ -292,11 +294,11 @@ export class Spin1DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this continue; // only SKIP if we don't have closing marker } - } else if (trimmedNonCommentLine.startsWith("{")) { + } else if (trimmedNonCommentLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line comment... } else { @@ -309,10 +311,10 @@ export class Spin1DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this continue; // only SKIP if we don't have closing marker } - } else if (trimmedNonCommentLine.includes("{{")) { + } else if (trimmedNonCommentLine.includes('{{')) { // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset == -1) { // is open of multiline comment without CLOSE priorState = currState; @@ -323,12 +325,12 @@ export class Spin1DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this continue; // only SKIP if we don't have closing marker } - } else if (trimmedNonCommentLine.includes("{")) { + } else if (trimmedNonCommentLine.includes('{')) { /// FIXME: TODO: this needs to be searching in non-string-containing line // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment priorState = currState; @@ -349,7 +351,7 @@ export class Spin1DocumentSemanticParser { if (currState == eParseState.inDatPAsm) { this.semanticFindings.recordPasmEnd(i - 1); currState = prePAsmState; - this._logState("- scan Ln#" + lineNbr + " POP currState=[" + currState + "]"); + this._logState('- scan Ln#' + lineNbr + ' POP currState=[' + currState + ']'); } if (currState == eParseState.inPub || currState == eParseState.inPri) { @@ -381,7 +383,7 @@ export class Spin1DocumentSemanticParser { } this.semanticFindings.recordBlockStart(newBlockType, i); // start new one which ends prior - this._logState("- scan Ln#" + lineNbr + " currState=[" + currState + "]"); + this._logState('- scan Ln#' + lineNbr + ' currState=[' + currState + ']'); // ID the remainder of the line if (currState == eParseState.inPub || currState == eParseState.inPri) { // process PUB/PRI method signature @@ -392,7 +394,7 @@ export class Spin1DocumentSemanticParser { if (docComment.type != eCommentType.Unknown) { this.semanticFindings.recordFakeComment(docComment); } else { - this._logState("- scan Ln#" + lineNbr + " no FAKE doc comment for this signature"); + this._logState('- scan Ln#' + lineNbr + ' no FAKE doc comment for this signature'); } } } else if (currState == eParseState.inCon) { @@ -402,12 +404,12 @@ export class Spin1DocumentSemanticParser { } } else if (currState == eParseState.inDat) { // process a class(static) variable line - if (trimmedNonCommentLine.length > 6 && trimmedNonCommentLine.toUpperCase().includes("ORG")) { + if (trimmedNonCommentLine.length > 6 && trimmedNonCommentLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH // record start of PASM code NOT inline const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedNonCommentLine); - if (nonStringLine.toUpperCase().includes("ORG")) { - this._logPASM("- Ln#" + lineNbr + " pre-scan DAT line trimmedLine=[" + trimmedLine + "] now Dat PASM"); + if (nonStringLine.toUpperCase().includes('ORG')) { + this._logPASM('- Ln#' + lineNbr + ' pre-scan DAT line trimmedLine=[' + trimmedLine + '] now Dat PASM'); // record start of PASM code NOT inline this.semanticFindings.recordPasmStart(i, false); prePAsmState = currState; @@ -440,12 +442,12 @@ export class Spin1DocumentSemanticParser { // process a data line if (bHaveLineToProcess) { if (trimmedLine.length > 6) { - if (trimmedLine.toUpperCase().includes("ORG")) { + if (trimmedLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH // record start of PASM code NOT inline const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedLine); - if (nonStringLine.toUpperCase().includes("ORG")) { - this._logPASM("- Ln#" + lineNbr + " pre-scan DAT line trimmedLine=[" + trimmedLine + "] now Dat PASM"); + if (nonStringLine.toUpperCase().includes('ORG')) { + this._logPASM('- Ln#' + lineNbr + ' pre-scan DAT line trimmedLine=[' + trimmedLine + '] now Dat PASM'); prePAsmState = currState; // record start of PASM code NOT inline this.semanticFindings.recordPasmStart(i, false); @@ -500,8 +502,8 @@ export class Spin1DocumentSemanticParser { this.semanticFindings.finishFinalBlock(lines.length - 1); // mark end of final block in file // -------------------- End of PRE-PARSE -------------------- - this._logMessage("---> <---"); - this._logMessage("---> Actual SCAN"); + this._logMessage('---> <---'); + this._logMessage('---> Actual SCAN'); this.bRecordTrailingComments = true; // from here forward generate tokens for trailing comments on lines @@ -519,7 +521,9 @@ export class Spin1DocumentSemanticParser { const trimmedLine = line.trim(); const lineWOutInlineComments: string = this.parseUtils.getLineWithoutInlineComments(line); const bHaveLineToProcess: boolean = lineWOutInlineComments.length > 0; - let trimmedNonCommentLine: string = bHaveLineToProcess ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments).trimStart() : ""; + let trimmedNonCommentLine: string = bHaveLineToProcess + ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments).trimStart() + : ''; const sectionStatus = this.extensionUtils.isSectionStartLine(line); if (sectionStatus.isSectionStart) { trimmedNonCommentLine = trimmedNonCommentLine.substring(3); @@ -530,7 +534,7 @@ export class Spin1DocumentSemanticParser { // in multi-line doc-comment, hunt for end '}}' to exit // ALLOW {cmt}, {{cmt}} on same line without closing! //this._logMessage(` hunt for '}}' Ln#${lineNbr} trimmedNonCommentLine=[${trimmedNonCommentLine}]`); - let closingOffset = trimmedNonCommentLine.indexOf("}}"); + const closingOffset = trimmedNonCommentLine.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -543,7 +547,7 @@ export class Spin1DocumentSemanticParser { // in multi-line non-doc-comment, hunt for end '}' to exit // ALLOW {...} on same line without closing! //this._logMessage(` hunt for '}' Ln#${lineNbr} lineWOutInlineComments=[${lineWOutInlineComments}]`); - const closingOffset: number = lineWOutInlineComments.indexOf("}"); + const closingOffset: number = lineWOutInlineComments.indexOf('}'); if (closingOffset != -1) { // have close, comment ended this._logMessage(` FOUND '}' Ln#${lineNbr} trimmedLine=[${trimmedLine}]`); @@ -555,7 +559,7 @@ export class Spin1DocumentSemanticParser { } else if (lineParts.length > 0 && this.parseUtils.isFlexspinPreprocessorDirective(lineParts[0])) { const partialTokenSet: IParsedToken[] = this._reportFlexspinPreProcessorLine(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logPreProc("=> PreProc: " + this._tokenString(newToken, line)); + this._logPreProc('=> PreProc: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); continue; @@ -565,10 +569,10 @@ export class Spin1DocumentSemanticParser { } else if (trimmedLine.startsWith("'")) { // process single line non-doc comment // DO NOTHING Let Syntax highlighting do this - } else if (trimmedNonCommentLine.startsWith("{{")) { + } else if (trimmedNonCommentLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single-line {{comment}}, just ignore it Let Syntax highlighting do this } else { @@ -579,11 +583,11 @@ export class Spin1DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this } continue; - } else if (trimmedNonCommentLine.startsWith("{")) { + } else if (trimmedNonCommentLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line {comment}, just ignore it Let Syntax highlighting do this } else { @@ -594,10 +598,10 @@ export class Spin1DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this } continue; - } else if (trimmedNonCommentLine.includes("{{")) { + } else if (trimmedNonCommentLine.includes('{{')) { // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line {{comment}}, just ignore it Let Syntax highlighting do this } else { @@ -608,11 +612,11 @@ export class Spin1DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this } // don't continue there might be some text to process before the {{ - } else if (trimmedNonCommentLine.includes("{")) { + } else if (trimmedNonCommentLine.includes('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this } else { @@ -625,7 +629,7 @@ export class Spin1DocumentSemanticParser { // don't continue there might be some text to process before the {{ } else if (sectionStatus.isSectionStart) { currState = sectionStatus.inProgressStatus; - this._logState(" -- Ln#" + lineNbr + " currState=[" + currState + "]"); + this._logState(' -- Ln#' + lineNbr + ' currState=[' + currState + ']'); // ID the section name // DON'T mark the section literal, Syntax highlighting does this well! @@ -644,7 +648,7 @@ export class Spin1DocumentSemanticParser { if (line.length > 3) { const partialTokenSet: IParsedToken[] = this._reportCON_DeclarationLine(i, 3, line); partialTokenSet.forEach((newToken) => { - this._logCON("=> CON: " + this._tokenString(newToken, line)); + this._logCON('=> CON: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } @@ -653,13 +657,13 @@ export class Spin1DocumentSemanticParser { if (line.length > 3) { if (trimmedLine.length > 6) { const nonCommentLineRemainder: string = this.parseUtils.getNonCommentLineRemainder(0, trimmedLine); - let orgStr: string = "ORGH"; + let orgStr: string = 'ORGH'; let orgOffset: number = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGH if (orgOffset == -1) { - orgStr = "ORGF"; + orgStr = 'ORGF'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGF if (orgOffset == -1) { - orgStr = "ORG"; + orgStr = 'ORG'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORG } } @@ -669,13 +673,20 @@ export class Spin1DocumentSemanticParser { orgOffset = nonStringLine.toUpperCase().indexOf(orgStr); // ORG, ORGF, ORGH } if (orgOffset != -1) { - this._logPASM("- Ln#" + lineNbr + " scan DAT line nonCommentLineRemainder=[" + nonCommentLineRemainder + "]"); + this._logPASM('- Ln#' + lineNbr + ' scan DAT line nonCommentLineRemainder=[' + nonCommentLineRemainder + ']'); // process remainder of ORG line const nonCommentOffset = line.indexOf(nonCommentLineRemainder, 0); // lineNumber, currentOffset, line, allowLocalVarStatus, this.showPAsmCode const allowLocalVarStatus: boolean = false; const IN_DAT_PASM: boolean = true; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(i, nonCommentOffset + orgOffset + orgStr.length, line, allowLocalVarStatus, this.showDAT, IN_DAT_PASM); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + i, + nonCommentOffset + orgOffset + orgStr.length, + line, + allowLocalVarStatus, + this.showDAT, + IN_DAT_PASM + ); partialTokenSet.forEach((newToken) => { tokenSet.push(newToken); }); @@ -696,7 +707,7 @@ export class Spin1DocumentSemanticParser { if (line.length > 3) { const partialTokenSet: IParsedToken[] = this._reportOBJ_DeclarationLine(i, 3, line); partialTokenSet.forEach((newToken) => { - this._logOBJ("=> OBJ: " + this._tokenString(newToken, line)); + this._logOBJ('=> OBJ: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } @@ -712,25 +723,25 @@ export class Spin1DocumentSemanticParser { } else if (currState == eParseState.inCon) { // process a line in a constant section if (bHaveLineToProcess) { - this._logCON("- process CON lineLn#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logCON('- process CON lineLn#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); const partialTokenSet: IParsedToken[] = this._reportCON_DeclarationLine(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logCON("=> CON: " + this._tokenString(newToken, line)); + this._logCON('=> CON: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } } else if (currState == eParseState.inDat) { // process a line in a data section if (bHaveLineToProcess) { - this._logDAT("- process DAT lineLn#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logDAT('- process DAT lineLn#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); const nonCommentLineRemainder: string = this.parseUtils.getNonCommentLineRemainder(0, trimmedLine); - let orgStr: string = "ORGH"; + let orgStr: string = 'ORGH'; let orgOffset: number = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGH if (orgOffset == -1) { - orgStr = "ORGF"; + orgStr = 'ORGF'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGF if (orgOffset == -1) { - orgStr = "ORG"; + orgStr = 'ORG'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORG } } @@ -743,7 +754,7 @@ export class Spin1DocumentSemanticParser { // process ORG line allowing label to be present const partialTokenSet: IParsedToken[] = this._reportDAT_DeclarationLine(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logOBJ("=> ORG: " + this._tokenString(newToken, line)); + this._logOBJ('=> ORG: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); @@ -753,7 +764,7 @@ export class Spin1DocumentSemanticParser { } else { const partialTokenSet: IParsedToken[] = this._reportDAT_DeclarationLine(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logDAT("=> DAT: " + this._tokenString(newToken, line)); + this._logDAT('=> DAT: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } @@ -761,42 +772,42 @@ export class Spin1DocumentSemanticParser { } else if (currState == eParseState.inVar) { // process a line in a variable data section if (bHaveLineToProcess) { - this._logVAR("- process VAR lineLn#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logVAR('- process VAR lineLn#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); const partialTokenSet: IParsedToken[] = this._reportVAR_DeclarationLine(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logVAR("=> VAR: " + this._tokenString(newToken, line)); + this._logVAR('=> VAR: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } } else if (currState == eParseState.inObj) { // process a line in an object section if (bHaveLineToProcess) { - this._logOBJ("- process OBJ lineLn#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logOBJ('- process OBJ lineLn#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); const partialTokenSet: IParsedToken[] = this._reportOBJ_DeclarationLine(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logOBJ("=> OBJ: " + this._tokenString(newToken, line)); + this._logOBJ('=> OBJ: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } } else if (currState == eParseState.inDatPAsm) { // process DAT section pasm (assembly) lines if (bHaveLineToProcess) { - this._logPASM("- process DAT PASM lineLn#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logPASM('- process DAT PASM lineLn#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); // in DAT sections we end with FIT or just next section const partialTokenSet: IParsedToken[] = this._reportDAT_PAsmCode(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logPASM("=> DAT: " + this._tokenString(newToken, line)); + this._logPASM('=> DAT: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } } else if (currState == eParseState.inPub || currState == eParseState.inPri) { // process a method def'n line if (bHaveLineToProcess) { - this._logSPIN("- process SPIN2 lineLn#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); - const lineParts: string[] = trimmedLine.split(/[ \t]/).filter(Boolean); + this._logSPIN('- process SPIN2 lineLn#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); + //const lineParts: string[] = trimmedLine.split(/[ \t]/).filter(Boolean); const partialTokenSet: IParsedToken[] = this._reportSPIN_Code(i, 0, line); partialTokenSet.forEach((newToken) => { - this._logSPIN("=> SPIN: " + this._tokenString(newToken, line)); + this._logSPIN('=> SPIN: ' + this._tokenString(newToken, line)); tokenSet.push(newToken); }); } @@ -808,21 +819,25 @@ export class Spin1DocumentSemanticParser { private _getPreProcessor_Declaration(startingOffset: number, lineNbr: number, line: string): void { if (this.configuration.highlightFlexspinDirectives) { - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const nonCommentConstantLine = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (nonCommentConstantLine.length > 0) { // get line parts - we only care about first one const lineParts: string[] = nonCommentConstantLine.split(/[ \t=]/).filter(Boolean); - this._logPreProc(" - Ln#" + lineNbr + " GetPreProcDecl lineParts=[" + lineParts + "]"); + this._logPreProc(' - Ln#' + lineNbr + ' GetPreProcDecl lineParts=[' + lineParts + ']'); const directive: string = lineParts[0]; const symbolName: string | undefined = lineParts.length > 1 ? lineParts[1] : undefined; if (this.parseUtils.isFlexspinPreprocessorDirective(directive)) { // check a valid preprocessor line for a declaration - if (symbolName != undefined && directive.toLowerCase() == "#define") { - this._logPreProc(" -- new PreProc Symbol=[" + symbolName + "]"); + if (symbolName != undefined && directive.toLowerCase() == '#define') { + this._logPreProc(' -- new PreProc Symbol=[' + symbolName + ']'); const nameOffset = line.indexOf(symbolName, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(symbolName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + symbolName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['readonly']), + this._declarationComment() + ); } } } @@ -844,40 +859,44 @@ export class Spin1DocumentSemanticParser { if (nonCommentConstantLine.length == 0) { this.conEnumInProgress = false; // if we have a blank line after removing comment then weve ended the enum set } else { - this._logCON(" - Ln#" + lineNbr + " GetCONDecl nonCommentConstantLine=[" + nonCommentConstantLine + "]"); - const haveEnumDeclaration: boolean = nonCommentConstantLine.trim().startsWith("#"); - const isAssignment: boolean = nonCommentConstantLine.indexOf("=") != -1; + this._logCON(' - Ln#' + lineNbr + ' GetCONDecl nonCommentConstantLine=[' + nonCommentConstantLine + ']'); + const haveEnumDeclaration: boolean = nonCommentConstantLine.trim().startsWith('#'); + const isAssignment: boolean = nonCommentConstantLine.indexOf('=') != -1; if (!haveEnumDeclaration && isAssignment) { this.conEnumInProgress = false; } else { this.conEnumInProgress = this.conEnumInProgress || haveEnumDeclaration; } if (!haveEnumDeclaration && !this.conEnumInProgress) { - const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(",") != -1; - this._logCON(" -- declNotEnum containsMultiStatements=[" + containsMultiStatements + "]"); + const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(',') != -1; + this._logCON(' -- declNotEnum containsMultiStatements=[' + containsMultiStatements + ']'); let statements: string[] = [nonCommentConstantLine]; if (containsMultiStatements) { - statements = nonCommentConstantLine.split(","); + statements = nonCommentConstantLine.split(','); } - this._logCON(" -- statements=[" + statements + "]"); + this._logCON(' -- statements=[' + statements + ']'); for (let index = 0; index < statements.length; index++) { const conDeclarationLine: string = statements[index].trim(); - this._logCON(" -- GetCONDecl conDeclarationLine=[" + conDeclarationLine + "]"); + this._logCON(' -- GetCONDecl conDeclarationLine=[' + conDeclarationLine + ']'); currentOffset = line.indexOf(conDeclarationLine, 0); - const assignmentOffset: number = conDeclarationLine.indexOf("="); + const assignmentOffset: number = conDeclarationLine.indexOf('='); if (assignmentOffset != -1) { // recognize constant name getting initialized via assignment // get line parts - we only care about first one const lineParts: string[] = conDeclarationLine.split(/[ \t=]/).filter(Boolean); - this._logCON(" -- GetCONDecl assign lineParts=[" + lineParts + "](" + lineParts.length + ")"); + this._logCON(' -- GetCONDecl assign lineParts=[' + lineParts + '](' + lineParts.length + ')'); const newName = lineParts[0]; if (newName.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- GLBL GetCONDecl newName=[" + newName + "]"); + this._logCON(' -- GLBL GetCONDecl newName=[' + newName + ']'); // remember this object name so we can annotate a call to it const nameOffset = line.indexOf(newName, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(newName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + newName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['readonly']), + this._declarationComment() + ); } } } @@ -888,16 +907,20 @@ export class Spin1DocumentSemanticParser { for (let index = 0; index < lineParts.length; index++) { let enumConstant: string = lineParts[index]; // our enum name can have a step offset - if (enumConstant.includes("[")) { + if (enumConstant.includes('[')) { // it does, isolate name from offset - const enumNameParts: string[] = enumConstant.split("["); + const enumNameParts: string[] = enumConstant.split('['); enumConstant = enumNameParts[0]; } if (enumConstant.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- GLBL enumConstant=[" + enumConstant + "]"); + this._logCON(' -- GLBL enumConstant=[' + enumConstant + ']'); const nameOffset = line.indexOf(enumConstant, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(enumConstant, new RememberedToken("enumMember", lineNbr - 1, nameOffset, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + enumConstant, + new RememberedToken('enumMember', lineNbr - 1, nameOffset, ['readonly']), + this._declarationComment() + ); } } } @@ -911,12 +934,12 @@ export class Spin1DocumentSemanticParser { // HAVE bGammaEnable BYTE TRUE ' comment // didShow byte FALSE[256] // byte FALSE[256] - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const dataDeclNonCommentStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); - let lineParts: string[] = this.parseUtils.getNonWhiteLineParts(dataDeclNonCommentStr); - this._logDAT("- GetDatDecl() lineParts=[" + lineParts + "](" + lineParts.length + ")"); - let isDatDeclLine: boolean = lineParts.length >= 1 && lineParts[0].toUpperCase() == "DAT" ? true : false; + const lineParts: string[] = this.parseUtils.getNonWhiteLineParts(dataDeclNonCommentStr); + this._logDAT('- GetDatDecl() lineParts=[' + lineParts + '](' + lineParts.length + ')'); + const isDatDeclLine: boolean = lineParts.length >= 1 && lineParts[0].toUpperCase() == 'DAT' ? true : false; if ((isDatDeclLine && lineParts.length >= 2) || (!isDatDeclLine && lineParts.length > 0)) { // remember this object name so we can annotate a call to it const nameIndex: number = isDatDeclLine ? 1 : 0; @@ -925,7 +948,7 @@ export class Spin1DocumentSemanticParser { const possLabel: string | undefined = lineParts.length > nameIndex ? lineParts[nameIndex] : undefined; const haveLabel: boolean = possLabel && possLabel.length > 0 ? this.parseUtils.isDatOrPAsmLabel(possLabel) : false; //this._logDAT(` -- GetDatDecl point 1: nameIndex=(${nameIndex}), typeIndex=(${typeIndex}), maxParts=(${maxParts})`); - const dataType: string = lineParts.length > typeIndex ? lineParts[typeIndex] : ""; + const dataType: string = lineParts.length > typeIndex ? lineParts[typeIndex] : ''; //this._logDAT(` -- GetDatDecl point 2: dataType=[${dataType}](${dataType.length})`); const haveDataType: boolean = dataType.length > 0 ? true : false; // is RES, BYTE, WORD, LONG const haveStorageType: boolean = haveDataType ? this.parseUtils.isDatStorageType(dataType) : false; // is RES, BYTE, WORD, LONG @@ -934,78 +957,107 @@ export class Spin1DocumentSemanticParser { //this._logDAT(" -- GetDatDecl point 3"); const isDataDeclarationLine: boolean = haveStorageType ? true : false; - const lblFlag: string = haveLabel ? "T" : "F"; - const dataDeclFlag: string = isDataDeclarationLine ? "T" : "F"; + const lblFlag: string = haveLabel ? 'T' : 'F'; + const dataDeclFlag: string = isDataDeclarationLine ? 'T' : 'F'; - this._logDAT("- GetDatDecl prcss lineParts=[" + lineParts + "](" + lineParts.length + ") label=" + lblFlag + ", daDecl=" + dataDeclFlag); + this._logDAT('- GetDatDecl prcss lineParts=[' + lineParts + '](' + lineParts.length + ') label=' + lblFlag + ', daDecl=' + dataDeclFlag); if (haveLabel) { - const newName: string = lineParts.length > nameIndex ? lineParts[nameIndex] : ""; - let nameOffset: number = line.indexOf(newName, currentOffset); + const newName: string = lineParts.length > nameIndex ? lineParts[nameIndex] : ''; + const nameOffset: number = line.indexOf(newName, currentOffset); if (newName.length > 0) { const notOKSpin2Word: boolean = this.parseUtils.isSpin2ReservedWords(newName) && !this.parseUtils.isSpin2ButOKReservedWords(newName); if (!this.parseUtils.isSpinReservedWord(newName) && !this.parseUtils.isBuiltinReservedWord(newName) && !notOKSpin2Word) { - const nameType: string = isDataDeclarationLine ? "variable" : "label"; - var labelModifiers: string[] = ["declaration"]; + const nameType: string = isDataDeclarationLine ? 'variable' : 'label'; + let labelModifiers: string[] = ['declaration']; if (!isDataDeclarationLine) { - if (newName.startsWith(".")) { - labelModifiers = ["illegalUse", "declaration", "static"]; + if (newName.startsWith('.')) { + labelModifiers = ['illegalUse', 'declaration', 'static']; const offset: number = line.indexOf(newName, startingOffset); - this.semanticFindings.pushDiagnosticMessage(lineNbr - 1, offset, offset + newName.length, eSeverity.Error, `P2 pasm local name [${newName}] not supported in P1 pasm`); - } else if (newName.startsWith(":")) { - labelModifiers = ["declaration", "static"]; + this.semanticFindings.pushDiagnosticMessage( + lineNbr - 1, + offset, + offset + newName.length, + eSeverity.Error, + `P2 pasm local name [${newName}] not supported in P1 pasm` + ); + } else if (newName.startsWith(':')) { + labelModifiers = ['declaration', 'static']; } } - this._logDAT(" -- GLBL gddcl newName=[" + newName + "](" + nameType + ")"); - const bIsFileLine: boolean = dataType.length > 0 && dataType.toLowerCase() == "file" ? true : false; - const fileName: string | undefined = isNamedDataDeclarationLine && bIsFileLine && lineParts.length > maxParts ? lineParts[maxParts] : undefined; - this._logDAT(" -- GLBL gddcl fileName=[" + fileName + "]"); + this._logDAT(' -- GLBL gddcl newName=[' + newName + '](' + nameType + ')'); + const bIsFileLine: boolean = dataType.length > 0 && dataType.toLowerCase() == 'file' ? true : false; + const fileName: string | undefined = + isNamedDataDeclarationLine && bIsFileLine && lineParts.length > maxParts ? lineParts[maxParts] : undefined; + this._logDAT(' -- GLBL gddcl fileName=[' + fileName + ']'); this._ensureDataFileExists(fileName, lineNbr - 1, line, startingOffset); const nameOffset = line.indexOf(newName, currentOffset); // FIXME: UNDONE, do we have to dial this in? // LABEL-TODO add record of global, start or local extra line number let declType: eDefinitionType = eDefinitionType.NonLabel; if (!isNamedDataDeclarationLine) { // we have a label which type is it? - declType = newName.startsWith(":") ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; + declType = newName.startsWith(':') ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; } this.semanticFindings.recordDeclarationLine(line, lineNbr, declType); - this.semanticFindings.setGlobalToken(newName, new RememberedToken(nameType, lineNbr - 1, nameOffset, labelModifiers), this._declarationComment(), fileName); + this.semanticFindings.setGlobalToken( + newName, + new RememberedToken(nameType, lineNbr - 1, nameOffset, labelModifiers), + this._declarationComment(), + fileName + ); } else if (notOKSpin2Word) { - this.semanticFindings.pushDiagnosticMessage(lineNbr - 1, nameOffset, nameOffset + newName.length, eSeverity.Information, `Possible use of P2 Spin reserved word [${newName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineNbr - 1, + nameOffset, + nameOffset + newName.length, + eSeverity.Information, + `Possible use of P2 Spin reserved word [${newName}]` + ); } } } // check for names in value declaration const dataTypeOffset: number = haveStorageType ? dataDeclNonCommentStr.indexOf(dataType) : 0; - const valueDeclNonCommentStr: string = isDataDeclarationLine && dataTypeOffset != -1 ? dataDeclNonCommentStr.substring(dataTypeOffset + dataType.length).trim() : ""; - this._logDAT(" -- GetDatDecl valueDeclNonCommentStr=[" + valueDeclNonCommentStr + "]"); + const valueDeclNonCommentStr: string = + isDataDeclarationLine && dataTypeOffset != -1 ? dataDeclNonCommentStr.substring(dataTypeOffset + dataType.length).trim() : ''; + this._logDAT(' -- GetDatDecl valueDeclNonCommentStr=[' + valueDeclNonCommentStr + ']'); if (valueDeclNonCommentStr.length > 0) { //let possObjRef: string | undefined = haveObjectRef ? lineParts[firstValueIndex] : undefined; const bISMethod: boolean = false; // SPIN1 we can't tell if method or constant (so force constant in DAT for now) - const valueParts: string[] = valueDeclNonCommentStr.split(/[ \t\(\[\]\+\-\*\/]/).filter(Boolean); - this._logDAT(" -- GetDatDecl valueParts=[" + valueParts + "](" + valueParts.length + ")"); + const valueParts: string[] = valueDeclNonCommentStr.split(/[ \t([\]+\-*/]/).filter(Boolean); + this._logDAT(' -- GetDatDecl valueParts=[' + valueParts + '](' + valueParts.length + ')'); if (valueParts.length > 1) { // for all name parts see if we want to report any to global tables... for (let index = 0; index < valueParts.length; index++) { const currNamePart = valueParts[index]; // do we have name not number? if (currNamePart.charAt(0).match(/[a-zA-Z_]/)) { - const haveObjectRef: boolean = currNamePart.indexOf(".") != -1; + const haveObjectRef: boolean = currNamePart.indexOf('.') != -1; if (haveObjectRef) { - const objRefParts: string[] = currNamePart.split("."); + const objRefParts: string[] = currNamePart.split('.'); const objName: string = objRefParts[0]; const objRef: string = objRefParts[1]; // if both parts are names... if (objName.charAt(0).match(/[a-zA-Z_]/) && objRef.charAt(0).match(/[a-zA-Z_]/)) { - this._logDAT(" -- GetDatDecl objRefParts=[" + objRefParts + "](" + objRefParts.length + ")"); + this._logDAT(' -- GetDatDecl objRefParts=[' + objRefParts + '](' + objRefParts.length + ')'); // remember this object name so we can annotate a call to it - this._logDAT(" -- GetDatDecl objName=[" + objName + "], objRef=[" + objRef + "]"); + this._logDAT(' -- GetDatDecl objName=[' + objName + '], objRef=[' + objRef + ']'); // record expectation of object public interface this.semanticFindings.recordDeclarationLine(line, lineNbr); const nameOffset = line.indexOf(objRef, currentOffset); // FIXME: UNDONE, do we have to dial this in? if (bISMethod) { - this.semanticFindings.setGlobalToken(objRef, new RememberedToken("method", lineNbr - 1, nameOffset, []), this._declarationComment(), objName); + this.semanticFindings.setGlobalToken( + objRef, + new RememberedToken('method', lineNbr - 1, nameOffset, []), + this._declarationComment(), + objName + ); } else { - this.semanticFindings.setGlobalToken(objRef, new RememberedToken("variable", lineNbr - 1, nameOffset, ["readonly"]), this._declarationComment(), objName); + this.semanticFindings.setGlobalToken( + objRef, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['readonly']), + this._declarationComment(), + objName + ); } } } @@ -1014,51 +1066,62 @@ export class Spin1DocumentSemanticParser { } } } else { - this._logDAT("- GetDatDecl SKIP dataDeclNonCommentStr=[" + dataDeclNonCommentStr + "]"); + this._logDAT('- GetDatDecl SKIP dataDeclNonCommentStr=[' + dataDeclNonCommentStr + ']'); } } private _getDAT_PAsmDeclaration(startingOffset: number, lineNbr: number, line: string): void { // HAVE bGammaEnable BYTE TRUE ' comment // didShow byte FALSE[256] - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const datPAsmRHSStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (datPAsmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhiteLineParts(datPAsmRHSStr); //this._logPASM('- GetDATPAsmDecl lineParts=[' + lineParts + ']'); // handle name in 1 column - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); const isDataDeclarationLine: boolean = lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1]) ? true : false; - const isFileDeclarationLine: boolean = lineParts.length > 1 && haveLabel && lineParts[1].toLowerCase() == "file" ? true : false; + const isFileDeclarationLine: boolean = lineParts.length > 1 && haveLabel && lineParts[1].toLowerCase() == 'file' ? true : false; if (haveLabel) { const labelName: string = lineParts[0]; - if (!this.parseUtils.isP1AsmReservedSymbols(labelName) && !labelName.toUpperCase().startsWith("IF_")) { + if (!this.parseUtils.isP1AsmReservedSymbols(labelName) && !labelName.toUpperCase().startsWith('IF_')) { // org in first column is not label name, nor is if_ conditional - const labelType: string = isDataDeclarationLine ? "variable" : "label"; - var labelModifiers: string[] = ["declaration"]; + const labelType: string = isDataDeclarationLine ? 'variable' : 'label'; + let labelModifiers: string[] = ['declaration']; if (!isDataDeclarationLine) { - if (labelName.startsWith(".")) { - labelModifiers = ["illegalUse", "declaration", "static"]; + if (labelName.startsWith('.')) { + labelModifiers = ['illegalUse', 'declaration', 'static']; const offset: number = line.indexOf(labelName, startingOffset); - this.semanticFindings.pushDiagnosticMessage(lineNbr - 1, offset, offset + labelName.length, eSeverity.Error, `P2 pasm local name [${labelName}] not supported in P1 pasm`); - } else if (labelName.startsWith(":")) { - labelModifiers = ["declaration", "static"]; + this.semanticFindings.pushDiagnosticMessage( + lineNbr - 1, + offset, + offset + labelName.length, + eSeverity.Error, + `P2 pasm local name [${labelName}] not supported in P1 pasm` + ); + } else if (labelName.startsWith(':')) { + labelModifiers = ['declaration', 'static']; } } - this._logPASM(" -- DAT PASM GLBL labelName=[" + labelName + "(" + labelType + ")]"); + this._logPASM(' -- DAT PASM GLBL labelName=[' + labelName + '(' + labelType + ')]'); const fileName: string | undefined = isFileDeclarationLine && lineParts.length > 2 ? lineParts[2] : undefined; - this._logPASM(" -- DAT PASM label-ref fileName=[" + fileName + "]"); + this._logPASM(' -- DAT PASM label-ref fileName=[' + fileName + ']'); this._ensureDataFileExists(fileName, lineNbr - 1, line, startingOffset); const nameOffset = line.indexOf(labelName, currentOffset); // FIXME: UNDONE, do we have to dial this in? // LABEL-TODO add record of global, start or local extra line number let declType: eDefinitionType = eDefinitionType.NonLabel; if (!isDataDeclarationLine) { // we have a label which type is it? - declType = labelName.startsWith(":") ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; + declType = labelName.startsWith(':') ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; } this.semanticFindings.recordDeclarationLine(line, lineNbr, declType); - this.semanticFindings.setGlobalToken(labelName, new RememberedToken(labelType, lineNbr - 1, nameOffset, labelModifiers), this._declarationComment(), fileName); + this.semanticFindings.setGlobalToken( + labelName, + new RememberedToken(labelType, lineNbr - 1, nameOffset, labelModifiers), + this._declarationComment(), + fileName + ); } } } @@ -1066,33 +1129,57 @@ export class Spin1DocumentSemanticParser { private _ensureDataFileExists(fileName: string | undefined, lineIdx: number, line: string, startingOffset: number) { if (fileName) { - const filenameNoQuotes: string = fileName.replace(/\"/g, ""); - const searchFilename: string = `\"${filenameNoQuotes}`; - const hasPathSep: boolean = filenameNoQuotes.includes("/"); + const filenameNoQuotes: string = fileName.replace(/"/g, ''); + const searchFilename: string = `"${filenameNoQuotes}`; + const hasPathSep: boolean = filenameNoQuotes.includes('/'); const nameOffset: number = line.indexOf(searchFilename, startingOffset); const logCtx: Context | undefined = this.spin1DebugLogEnabled ? this.ctx : undefined; if (hasPathSep) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + filenameNoQuotes.length, eSeverity.Error, `P1 spin Invalid filename character "/" in [${filenameNoQuotes}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + filenameNoQuotes.length, + eSeverity.Error, + `P1 spin Invalid filename character "/" in [${filenameNoQuotes}]` + ); } else if (!fileInDirExists(this.directory, filenameNoQuotes, logCtx)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + fileName.length, eSeverity.Error, `Missing P1 Data file [${fileName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + fileName.length, + eSeverity.Error, + `Missing P1 Data file [${fileName}]` + ); } } } private _ensureObjectFileExists(fileName: string | undefined, lineIdx: number, line: string, startingOffset: number) { if (fileName) { - const filenameNoQuotes: string = fileName.replace(/\"/g, ""); - const hasSuffix: boolean = filenameNoQuotes.endsWith(".spin"); - const hasPathSep: boolean = filenameNoQuotes.includes("/"); + const filenameNoQuotes: string = fileName.replace(/"/g, ''); + const hasSuffix: boolean = filenameNoQuotes.endsWith('.spin'); + const hasPathSep: boolean = filenameNoQuotes.includes('/'); const fileWithExt = `${filenameNoQuotes}.spin`; const nameOffset: number = line.indexOf(filenameNoQuotes, startingOffset); const logCtx: Context | undefined = this.spin1DebugLogEnabled ? this.ctx : undefined; const checkFilename: string = hasSuffix ? filenameNoQuotes : fileWithExt; if (hasPathSep) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + filenameNoQuotes.length, eSeverity.Error, `P1 spin Invalid filename character "/" in [${filenameNoQuotes}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + filenameNoQuotes.length, + eSeverity.Error, + `P1 spin Invalid filename character "/" in [${filenameNoQuotes}]` + ); } else if (!fileInDirExists(this.directory, checkFilename, logCtx)) { const displayName: string = hasSuffix ? filenameNoQuotes : `${filenameNoQuotes}.spin`; - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + filenameNoQuotes.length, eSeverity.Error, `Missing P1 Object file [${displayName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + filenameNoQuotes.length, + eSeverity.Error, + `Missing P1 Object file [${displayName}]` + ); } } } @@ -1103,34 +1190,39 @@ export class Spin1DocumentSemanticParser { // -or- segments[7] : "isp_hub75_segment" // //skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); - const trimmedNonCommentLineStr: string = remainingNonCommentLineStr.trim(); - const remainingOffset: number = trimmedNonCommentLineStr.length > 0 ? line.indexOf(trimmedNonCommentLineStr, startingOffset) : 0; + //const trimmedNonCommentLineStr: string = remainingNonCommentLineStr.trim(); + //const remainingOffset: number = trimmedNonCommentLineStr.length > 0 ? line.indexOf(trimmedNonCommentLineStr, startingOffset) : 0; //this._logOBJ('- RptObjDecl remainingNonCommentLineStr=[' + remainingNonCommentLineStr + ']'); let badObjectLine: boolean = false; if (remainingNonCommentLineStr.length >= 5) { // c:"x" is minimm object decl len=5! - if (remainingNonCommentLineStr.includes(":") && remainingNonCommentLineStr.includes('"')) { + if (remainingNonCommentLineStr.includes(':') && remainingNonCommentLineStr.includes('"')) { // get line parts - we only care about first one - const lineParts: string[] = remainingNonCommentLineStr.split(":").filter(Boolean); + const lineParts: string[] = remainingNonCommentLineStr.split(':').filter(Boolean); this._logOBJ(` -- GLBL GetOBJDecl lineParts=[${lineParts}]${lineParts.length}`); if (lineParts.length < 2) { badObjectLine = true; } else { let instanceNamePart = lineParts[0].trim(); // if we have instance array declaration, then remove it - if (instanceNamePart.includes("[")) { - const nameParts = instanceNamePart.split(/[\[\]]/).filter(Boolean); + if (instanceNamePart.includes('[')) { + const nameParts = instanceNamePart.split(/[[\]]/).filter(Boolean); instanceNamePart = nameParts[0]; } this._logOBJ(` -- GLBL GetOBJDecl newInstanceName=[${instanceNamePart}]`); // remember this object name so we can annotate a call to it - const filenamePart = lineParts.length > 1 ? lineParts[1].trim().replace(/[\"]/g, "") : "--error-no-name-parsed--"; + const filenamePart = lineParts.length > 1 ? lineParts[1].trim().replace(/["]/g, '') : '--error-no-name-parsed--'; this._logOBJ(` -- GLBL GetOBJDecl newFileName=[${filenamePart}]`); const nameOffset = line.indexOf(instanceNamePart, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(instanceNamePart, new RememberedToken("namespace", lineNbr - 1, nameOffset, []), this._declarationComment(), filenamePart); // pass filename, too + this.semanticFindings.setGlobalToken( + instanceNamePart, + new RememberedToken('namespace', lineNbr - 1, nameOffset, []), + this._declarationComment(), + filenamePart + ); // pass filename, too this.semanticFindings.recordObjectImport(instanceNamePart, filenamePart); this._ensureObjectFileExists(filenamePart, lineNbr - 1, line, startingOffset); } @@ -1154,19 +1246,19 @@ export class Spin1DocumentSemanticParser { private _getPUB_PRI_Name(startingOffset: number, lineNbr: number, line: string): void { const methodType = line.substr(0, 3).toUpperCase(); // reset our list of local variables - const isPrivate = methodType.indexOf("PRI") != -1; + const isPrivate = methodType.indexOf('PRI') != -1; //skip Past Whitespace let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this.parseUtils.getNonCommentLineRemainder(0, line); const startNameOffset = currentOffset; // find open paren - currentOffset = remainingNonCommentLineStr.indexOf("(", startNameOffset); // in spin1 ()'s are optional! + currentOffset = remainingNonCommentLineStr.indexOf('(', startNameOffset); // in spin1 ()'s are optional! if (currentOffset == -1) { - currentOffset = remainingNonCommentLineStr.indexOf(":", startNameOffset); + currentOffset = remainingNonCommentLineStr.indexOf(':', startNameOffset); if (currentOffset == -1) { - currentOffset = remainingNonCommentLineStr.indexOf("|", startNameOffset); + currentOffset = remainingNonCommentLineStr.indexOf('|', startNameOffset); if (currentOffset == -1) { - currentOffset = remainingNonCommentLineStr.indexOf(" ", startNameOffset); + currentOffset = remainingNonCommentLineStr.indexOf(' ', startNameOffset); if (currentOffset == -1) { currentOffset = remainingNonCommentLineStr.indexOf("'", startNameOffset); // if nothing found... @@ -1178,15 +1270,25 @@ export class Spin1DocumentSemanticParser { } } - let nameLength = currentOffset - startNameOffset; + const nameLength = currentOffset - startNameOffset; const methodName = line.substr(startNameOffset, nameLength).trim(); - const nameType: string = isPrivate ? "private" : "public"; - this._logSPIN(" -- GLBL GetMethodDecl newName=[" + methodName + "](" + methodName.length + "), type=[" + methodType + "], currentOffset=[" + currentOffset + "]"); + //const nameType: string = isPrivate ? 'private' : 'public'; + this._logSPIN( + ' -- GLBL GetMethodDecl newName=[' + + methodName + + '](' + + methodName.length + + '), type=[' + + methodType + + '], currentOffset=[' + + currentOffset + + ']' + ); this.currentMethodName = methodName; // notify of latest method name so we can track inLine PASM symbols let methodExists: boolean = false; const referenceDetails: RememberedToken | undefined = this.semanticFindings.getGlobalToken(methodName); - if (referenceDetails && referenceDetails.type === "method") { + if (referenceDetails && referenceDetails.type === 'method') { methodExists = true; this._logSPIN(` -- _gPUB_PRI_Name() ERROR: have duplicate method [${methodName}]`); } @@ -1195,19 +1297,23 @@ export class Spin1DocumentSemanticParser { this.semanticFindings.startMethod(methodName, lineNbr); // remember this method name so we can annotate a call to it - const refModifiers: string[] = isPrivate ? ["static"] : []; + const refModifiers: string[] = isPrivate ? ['static'] : []; // record ACTUAL object public/private interface // FIXME: post non-blank line after const nameOffset = line.indexOf(methodName, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(methodName, new RememberedToken("method", lineNbr - 1, nameOffset, refModifiers), this._declarationComment()); + this.semanticFindings.setGlobalToken( + methodName, + new RememberedToken('method', lineNbr - 1, nameOffset, refModifiers), + this._declarationComment() + ); // reset our list of local variables this.semanticFindings.clearLocalPAsmTokensForMethod(methodName); const methodNamewithParens: string = `${methodName}()`; const methodNamewithSpaceParens: string = `${methodName} ()`; // FIXME: TODO: UNDONE this should be match with name-infWhiteSpace-openParen! - const methodPrefix: string = isPrivate ? "PRI" : "PUB"; + const methodPrefix: string = isPrivate ? 'PRI' : 'PUB'; if (line.includes(methodNamewithParens) || line.includes(methodNamewithSpaceParens)) { this.semanticFindings.pushDiagnosticMessage( lineNbr - 1, @@ -1219,7 +1325,7 @@ export class Spin1DocumentSemanticParser { } } else { //const declarationLineIdx;number = referenceDetails. - const methodPrefix: string = referenceDetails?.modifiers.includes("static") ? "PRI" : "PUB"; + const methodPrefix: string = referenceDetails?.modifiers.includes('static') ? 'PRI' : 'PUB'; this.semanticFindings.pushDiagnosticMessage( lineNbr - 1, startNameOffset, @@ -1228,21 +1334,21 @@ export class Spin1DocumentSemanticParser { `P1 Spin Duplicate method Declaration: found earlier [${methodPrefix} ${methodName}]` ); } - this._logSPIN(" -- _gPUB_PRI_Name() exit"); + this._logSPIN(' -- _gPUB_PRI_Name() exit'); } private _getVAR_Declaration(startingOffset: number, lineNbr: number, line: string): void { // HAVE long demoPausePeriod ' comment // //skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (remainingNonCommentLineStr.length > 0) { - this._logVAR("- GetVarDecl remainingNonCommentLineStr=[" + remainingNonCommentLineStr + "]"); - const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(","); - let lineParts: string[] = this.parseUtils.getNonWhiteDataInitLineParts(remainingNonCommentLineStr); + this._logVAR('- GetVarDecl remainingNonCommentLineStr=[' + remainingNonCommentLineStr + ']'); + const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(','); + const lineParts: string[] = this.parseUtils.getNonWhiteDataInitLineParts(remainingNonCommentLineStr); const hasGoodType: boolean = this.parseUtils.isStorageType(lineParts[0]); - this._logVAR(" -- lineParts=[" + lineParts + "]"); + this._logVAR(' -- lineParts=[' + lineParts + ']'); let nameSet: string[] = []; if (hasGoodType && lineParts.length > 1) { if (!isMultiDeclaration) { @@ -1259,20 +1365,28 @@ export class Spin1DocumentSemanticParser { // remove array suffix and comma delim. from name const newName = nameSet[index]; // .replace(/[\[,]/, ''); if (newName.charAt(0).match(/[a-zA-Z_]/)) { - this._logVAR(" -- GLBL GetVarDecl newName=[" + newName + "]"); + this._logVAR(' -- GLBL GetVarDecl newName=[' + newName + ']'); const nameOffset = line.indexOf(newName, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(newName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["instance"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + newName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['instance']), + this._declarationComment() + ); } } } else if (!hasGoodType && lineParts.length > 0) { for (let index = 0; index < lineParts.length; index++) { const longVarName = lineParts[index]; if (longVarName.charAt(0).match(/[a-zA-Z_]/)) { - this._logVAR(" -- GLBL GetVarDecl newName=[" + longVarName + "]"); + this._logVAR(' -- GLBL GetVarDecl newName=[' + longVarName + ']'); const nameOffset = line.indexOf(longVarName, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(longVarName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["instance"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + longVarName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['instance']), + this._declarationComment() + ); } } } @@ -1283,12 +1397,12 @@ export class Spin1DocumentSemanticParser { const tokenSet: IParsedToken[] = []; // skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const nonCommentConstantLine = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); if (nonCommentConstantLine.length > 0) { // get line parts - we only care about first one const lineParts: string[] = nonCommentConstantLine.split(/[ \t=]/).filter(Boolean); - this._logPreProc(" - Ln#" + lineIdx + " reportPreProc lineParts=[" + lineParts + "]"); + this._logPreProc(' - Ln#' + lineIdx + ' reportPreProc lineParts=[' + lineParts + ']'); const directive: string = lineParts[0]; const symbolName: string | undefined = lineParts.length > 1 ? lineParts[1] : undefined; if (this.configuration.highlightFlexspinDirectives) { @@ -1298,32 +1412,33 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: 0, length: directive.length, - ptTokenType: "keyword", - ptTokenModifiers: ["control", "directive"], + ptTokenType: 'keyword', + ptTokenModifiers: ['control', 'directive'] }); const hasSymbol: boolean = - directive.toLowerCase() == "#define" || - directive.toLowerCase() == "#ifdef" || - directive.toLowerCase() == "#ifndef" || - directive.toLowerCase() == "#elseifdef" || - directive.toLowerCase() == "#elseifndef"; + directive.toLowerCase() == '#define' || + directive.toLowerCase() == '#ifdef' || + directive.toLowerCase() == '#ifndef' || + directive.toLowerCase() == '#elseifdef' || + directive.toLowerCase() == '#elseifndef'; if (hasSymbol && symbolName != undefined) { const nameOffset = line.indexOf(symbolName, currentOffset); - this._logPreProc(" -- GLBL symbolName=[" + symbolName + "]"); + this._logPreProc(' -- GLBL symbolName=[' + symbolName + ']'); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(symbolName)) { referenceDetails = this.semanticFindings.getGlobalToken(symbolName); - this._logPreProc(" -- FOUND preProc global " + this._rememberdTokenString(symbolName, referenceDetails)); + this._logPreProc(' -- FOUND preProc global ' + this._rememberdTokenString(symbolName, referenceDetails)); } if (referenceDetails != undefined) { // record a constant declaration! - const updatedModificationSet: string[] = directive.toLowerCase() == "#define" ? referenceDetails.modifiersWith("declaration") : referenceDetails.modifiers; + const updatedModificationSet: string[] = + directive.toLowerCase() == '#define' ? referenceDetails.modifiersWith('declaration') : referenceDetails.modifiers; this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: symbolName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: updatedModificationSet, + ptTokenModifiers: updatedModificationSet }); } else if (this.parseUtils.isFlexspinReservedWord(symbolName)) { // record a constant reference @@ -1331,8 +1446,8 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: symbolName.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly'] }); } else { // record an unknown name @@ -1340,8 +1455,8 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: symbolName.length, - ptTokenType: "comment", - ptTokenModifiers: ["line"], + ptTokenType: 'comment', + ptTokenModifiers: ['line'] }); } } @@ -1352,10 +1467,16 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: 0, length: lineParts[0].length, - ptTokenType: "macro", - ptTokenModifiers: ["directive", "illegalUse"], + ptTokenType: 'macro', + ptTokenModifiers: ['directive', 'illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, 0, 0 + lineParts[0].length, eSeverity.Error, `P1 Spin - PreProcessor Directive [${lineParts[0]}] not supported!`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + 0, + 0 + lineParts[0].length, + eSeverity.Error, + `P1 Spin - PreProcessor Directive [${lineParts[0]}] not supported!` + ); } } @@ -1368,67 +1489,81 @@ export class Spin1DocumentSemanticParser { let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const nonCommentConstantLine = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); - const haveEnumDeclaration: boolean = nonCommentConstantLine.startsWith("#"); - const containsMultiAssignments: boolean = nonCommentConstantLine.indexOf(",") != -1; - this._logCON("- reportConstant haveEnum=(" + haveEnumDeclaration + "), containsMulti=(" + containsMultiAssignments + "), nonCommentConstantLine=[" + nonCommentConstantLine + "]"); + const haveEnumDeclaration: boolean = nonCommentConstantLine.startsWith('#'); + const containsMultiAssignments: boolean = nonCommentConstantLine.indexOf(',') != -1; + this._logCON( + '- reportConstant haveEnum=(' + + haveEnumDeclaration + + '), containsMulti=(' + + containsMultiAssignments + + '), nonCommentConstantLine=[' + + nonCommentConstantLine + + ']' + ); let statements: string[] = [nonCommentConstantLine]; if (!haveEnumDeclaration && containsMultiAssignments) { - statements = nonCommentConstantLine.split(","); + statements = nonCommentConstantLine.split(','); } - this._logCON(" -- statements=[" + statements + "]"); + this._logCON(' -- statements=[' + statements + ']'); if (nonCommentConstantLine.length > 0) { for (let index = 0; index < statements.length; index++) { const conDeclarationLine: string = statements[index].trim(); - this._logCON(" -- conDeclarationLine=[" + conDeclarationLine + "]"); + this._logCON(' -- conDeclarationLine=[' + conDeclarationLine + ']'); currentOffset = line.indexOf(conDeclarationLine, currentOffset); // locate key indicators of line style - const isAssignment: boolean = conDeclarationLine.indexOf("=") != -1; + const isAssignment: boolean = conDeclarationLine.indexOf('=') != -1; if (isAssignment && !haveEnumDeclaration) { // ------------------------------------------- // have line assigning value to new constant // ------------------------------------------- - const assignmentParts: string[] = conDeclarationLine.split("="); + const assignmentParts: string[] = conDeclarationLine.split('='); const lhsConstantName = assignmentParts[0].trim(); let nameOffset: number = line.indexOf(lhsConstantName, currentOffset); - this._logCON(" -- GLBL lhsConstantName=[" + lhsConstantName + "]"); + this._logCON(' -- GLBL lhsConstantName=[' + lhsConstantName + ']'); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(lhsConstantName)) { referenceDetails = this.semanticFindings.getGlobalToken(lhsConstantName); - this._logCON(" -- FOUND rcdl lhs global " + this._rememberdTokenString(lhsConstantName, referenceDetails)); + this._logCON(' -- FOUND rcdl lhs global ' + this._rememberdTokenString(lhsConstantName, referenceDetails)); } if (referenceDetails != undefined) { // this is a constant declaration! - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: lhsConstantName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); } else { - this._logCON(" -- CON ERROR[CODE] missed recording declaration! name=[" + lhsConstantName + "]"); + this._logCON(' -- CON ERROR[CODE] missed recording declaration! name=[' + lhsConstantName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: lhsConstantName.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + lhsConstantName.length, eSeverity.Error, `Missing Variable Declaration [${lhsConstantName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + lhsConstantName.length, + eSeverity.Error, + `Missing Variable Declaration [${lhsConstantName}]` + ); } // remove front LHS of assignment and process remainder - const fistEqualOffset: number = conDeclarationLine.indexOf("="); + const fistEqualOffset: number = conDeclarationLine.indexOf('='); const assignmentRHSStr = conDeclarationLine.substring(fistEqualOffset + 1).trim(); currentOffset = line.indexOf(assignmentRHSStr); // skip to RHS of assignment - this._logCON(" -- CON assignmentRHSStr=[" + assignmentRHSStr + "]"); + this._logCON(' -- CON assignmentRHSStr=[' + assignmentRHSStr + ']'); const possNames: string[] = this.parseUtils.getNonWhiteCONLineParts(assignmentRHSStr); - this._logCON(" -- possNames=[" + possNames + "]"); - let namePart: string = ""; + this._logCON(' -- possNames=[' + possNames + ']'); + let namePart: string = ''; for (let index = 0; index < possNames.length; index++) { namePart = possNames[index]; - const currPossibleLen = namePart.length; + //const currPossibleLen = namePart.length; nameOffset = line.indexOf(namePart, currentOffset); // skip to RHS of assignment if (namePart.charAt(0).match(/[a-zA-Z_]/)) { // does name contain a namespace reference? @@ -1439,25 +1574,25 @@ export class Spin1DocumentSemanticParser { continue; } } - let refChar: string = ""; + let refChar: string = ''; let possibleNameSet: string[] = [namePart]; - if (namePart.includes(".") && !namePart.startsWith(".")) { - refChar = "."; - possibleNameSet = namePart.split(".").filter(Boolean); - this._logSPIN(" -- . possibleNameSet=[" + possibleNameSet + "]"); - } else if (namePart.includes("#")) { - refChar = "#"; - possibleNameSet = namePart.split("#").filter(Boolean); - this._logSPIN(" -- # possibleNameSet=[" + possibleNameSet + "]"); + if (namePart.includes('.') && !namePart.startsWith('.')) { + refChar = '.'; + possibleNameSet = namePart.split('.').filter(Boolean); + this._logSPIN(' -- . possibleNameSet=[' + possibleNameSet + ']'); + } else if (namePart.includes('#')) { + refChar = '#'; + possibleNameSet = namePart.split('#').filter(Boolean); + this._logSPIN(' -- # possibleNameSet=[' + possibleNameSet + ']'); } namePart = possibleNameSet[0]; const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : possibleNameSet[0] + refChar + possibleNameSet[1]; let referenceDetails: RememberedToken | undefined = undefined; nameOffset = line.indexOf(searchString, currentOffset); - this._logCON(" -- namePart=[" + namePart + "], ofs=(" + nameOffset + ")"); + this._logCON(' -- namePart=[' + namePart + '], ofs=(' + nameOffset + ')'); if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); - this._logCON(" -- FOUND rcds rhs global " + this._rememberdTokenString(namePart, referenceDetails)); + this._logCON(' -- FOUND rcds rhs global ' + this._rememberdTokenString(namePart, referenceDetails)); } if (referenceDetails != undefined) { // this is a constant reference! @@ -1466,7 +1601,7 @@ export class Spin1DocumentSemanticParser { startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { if ( @@ -1476,15 +1611,21 @@ export class Spin1DocumentSemanticParser { !this.parseUtils.isSpinBuiltInConstant(namePart) && !this.parseUtils.isP1AsmReservedWord(namePart) ) { - this._logCON(" -- CON MISSING name=[" + namePart + "]"); + this._logCON(' -- CON MISSING name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `Missing Constant Declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `Missing Constant Declaration [${namePart}]` + ); } } } @@ -1495,44 +1636,44 @@ export class Spin1DocumentSemanticParser { // have line creating one or more of enum constants // ------------------------------------------------- // recognize enum values getting initialized - const lineParts: string[] = conDeclarationLine.split(","); + const lineParts: string[] = conDeclarationLine.split(','); //this._logCON(' -- lineParts=[' + lineParts + ']'); let nameOffset: number = 0; for (let index = 0; index < lineParts.length; index++) { let enumConstant = lineParts[index].trim(); // our enum name can have a step offset: name[step] - if (enumConstant.includes("[")) { + if (enumConstant.includes('[')) { // it does, isolate name from offset - const enumNameParts: string[] = enumConstant.split("["); + const enumNameParts: string[] = enumConstant.split('['); enumConstant = enumNameParts[0]; } - if (enumConstant.includes("=")) { - const enumAssignmentParts: string[] = enumConstant.split("="); + if (enumConstant.includes('=')) { + const enumAssignmentParts: string[] = enumConstant.split('='); enumConstant = enumAssignmentParts[0].trim(); const enumExistingName: string = enumAssignmentParts[1].trim(); if (enumExistingName.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- GLBL enumConstant=[" + enumConstant + "]"); + this._logCON(' -- GLBL enumConstant=[' + enumConstant + ']'); // our enum name can have a step offset nameOffset = line.indexOf(enumExistingName, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: enumExistingName.length, - ptTokenType: "enumMember", - ptTokenModifiers: ["readonly"], + ptTokenType: 'enumMember', + ptTokenModifiers: ['readonly'] }); } } if (enumConstant.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- GLBL enumConstant=[" + enumConstant + "]"); + this._logCON(' -- GLBL enumConstant=[' + enumConstant + ']'); // our enum name can have a step offset nameOffset = line.indexOf(enumConstant, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: enumConstant.length, - ptTokenType: "enumMember", - ptTokenModifiers: ["declaration", "readonly"], + ptTokenType: 'enumMember', + ptTokenModifiers: ['declaration', 'readonly'] }); } currentOffset = nameOffset + enumConstant.length; @@ -1549,23 +1690,30 @@ export class Spin1DocumentSemanticParser { let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const dataDeclNonCommentStr = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); - let lineParts: string[] = this.parseUtils.getNonWhiteLineParts(dataDeclNonCommentStr); - this._logVAR("- rptDataDeclLn lineParts=[" + lineParts + "](" + lineParts.length + ")"); + const lineParts: string[] = this.parseUtils.getNonWhiteLineParts(dataDeclNonCommentStr); + this._logVAR('- rptDataDeclLn lineParts=[' + lineParts + '](' + lineParts.length + ')'); // remember this object name so we can annotate a call to it if (lineParts.length > 0) { - if (this.parseUtils.isStorageType(lineParts[0]) || lineParts[0].toUpperCase() == "FILE" || lineParts[0].toUpperCase() == "ORG") { + if (this.parseUtils.isStorageType(lineParts[0]) || lineParts[0].toUpperCase() == 'FILE' || lineParts[0].toUpperCase() == 'ORG') { // if we start with storage type (or FILE, or ORG), not name, process rest of line for symbols currentOffset = line.indexOf(lineParts[0], currentOffset); const allowLocalVarStatus: boolean = false; const NOT_DAT_PASM: boolean = false; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(lineIdx, startingOffset, line, allowLocalVarStatus, this.showDAT, NOT_DAT_PASM); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + lineIdx, + startingOffset, + line, + allowLocalVarStatus, + this.showDAT, + NOT_DAT_PASM + ); partialTokenSet.forEach((newToken) => { tokenSet.push(newToken); }); } else { // this is line with name storageType and initial value - this._logDAT(" -- rptDatDecl lineParts=[" + lineParts + "]"); - let newName = lineParts[0]; + this._logDAT(' -- rptDatDecl lineParts=[' + lineParts + ']'); + const newName = lineParts[0]; const nameOffset: number = line.indexOf(newName, currentOffset); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(newName)) { @@ -1574,13 +1722,13 @@ export class Spin1DocumentSemanticParser { } if (referenceDetails != undefined) { // add back in our declaration flag - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); } else if ( !this.parseUtils.isP1AsmReservedSymbols(newName) && @@ -1589,24 +1737,37 @@ export class Spin1DocumentSemanticParser { !this.parseUtils.isDatStorageType(newName) && !this.parseUtils.isBuiltinReservedWord(newName) && !this.parseUtils.isSpinReservedWord(newName) && - !newName.toUpperCase().startsWith("IF_") + !newName.toUpperCase().startsWith('IF_') ) { - this._logDAT(" -- DAT rDdl MISSING name=[" + newName + "]"); + this._logDAT(' -- DAT rDdl MISSING name=[' + newName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, currentOffset, currentOffset + newName.length, eSeverity.Error, `P1 Spin DAT missing declaration [${newName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + currentOffset, + currentOffset + newName.length, + eSeverity.Error, + `P1 Spin DAT missing declaration [${newName}]` + ); } // process remainder of line currentOffset = line.indexOf(lineParts[1], nameOffset + newName.length); const allowLocalVarStatus: boolean = false; const IN_DAT_PASM: boolean = true; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(lineIdx, startingOffset, line, allowLocalVarStatus, this.showDAT, IN_DAT_PASM); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + lineIdx, + startingOffset, + line, + allowLocalVarStatus, + this.showDAT, + IN_DAT_PASM + ); partialTokenSet.forEach((newToken) => { tokenSet.push(newToken); }); @@ -1617,7 +1778,14 @@ export class Spin1DocumentSemanticParser { return tokenSet; } - private _reportDAT_ValueDeclarationCode(lineIdx: number, startingOffset: number, line: string, allowLocal: boolean, showDebug: boolean, isDatPAsm: boolean): IParsedToken[] { + private _reportDAT_ValueDeclarationCode( + lineIdx: number, + startingOffset: number, + line: string, + allowLocal: boolean, + showDebug: boolean, + isDatPAsm: boolean + ): IParsedToken[] { // process line that starts with storage type (or FILE, or ORG), not name, process rest of line for symbols const tokenSet: IParsedToken[] = []; const lineNbr: number = lineIdx + 1; @@ -1630,7 +1798,7 @@ export class Spin1DocumentSemanticParser { if (dataValueInitStr.length > 0) { this._logDAT(` -- reportDataValueInit dataValueInitStr=[${dataValueInitStr}]`); - let lineParts: string[] = this.parseUtils.getNonWhiteDataInitLineParts(dataValueInitStr); + const lineParts: string[] = this.parseUtils.getNonWhiteDataInitLineParts(dataValueInitStr); const argumentStartIndex: number = lineParts.length > 0 && this.parseUtils.isDatStorageType(lineParts[0]) ? 1 : 0; this._logDAT(` -- lineParts=[${lineParts}], argumentStartIndex=[${argumentStartIndex}]`); @@ -1640,9 +1808,9 @@ export class Spin1DocumentSemanticParser { } if (lineParts.length > 1) { let nameOffset: number = 0; - let namePart: string = ""; + let namePart: string = ''; for (let index = argumentStartIndex; index < lineParts.length; index++) { - const possibleName = lineParts[index].replace(/[\(\)\@]/, ""); + const possibleName = lineParts[index].replace(/[()@]/, ''); //if (showDebug) { // this._logMessage(' -- possibleName=[' + possibleName + ']'); //} @@ -1653,31 +1821,31 @@ export class Spin1DocumentSemanticParser { // the following allows '.' in names but only when in DAT PASM code, not spin! if ( possibleName.charAt(0).match(/[a-zA-Z_]/) || - (isDatPAsm && possibleName.charAt(0).match(/[a-zA-Z_\:]/)) || - (isDatPAsm && possibleName.charAt(0) == "#" && possibleName.charAt(1).match(/[a-zA-Z_\:]/)) + (isDatPAsm && possibleName.charAt(0).match(/[a-zA-Z_:]/)) || + (isDatPAsm && possibleName.charAt(0) == '#' && possibleName.charAt(1).match(/[a-zA-Z_:]/)) ) { if (showDebug) { this._logDAT(` -- possibleName=[${possibleName}]`); } // does name contain a namespace reference? nameOffset = line.indexOf(possibleName, currentOffset); - if (possibleName.includes(".") && this._isPossibleObjectReference(possibleName)) { + if (possibleName.includes('.') && this._isPossibleObjectReference(possibleName)) { const bHaveObjReference = this._reportObjectReference(possibleName, lineIdx, nameOffset, line, tokenSet); if (bHaveObjReference) { currentOffset = nameOffset + possibleName.length; continue; } } - let refChar: string = ""; + let refChar: string = ''; let possibleNameSet: string[] = [possibleName]; - if (possibleName.includes(".") && !namePart.startsWith(".")) { - refChar = "."; - possibleNameSet = possibleName.split(".").filter(Boolean); - this._logDAT(" -- . possibleNameSet=[" + possibleNameSet + "]"); - } else if (possibleName.includes("#")) { - refChar = "#"; - possibleNameSet = possibleName.split("#").filter(Boolean); - this._logDAT(" -- # possibleNameSet=[" + possibleNameSet + "]"); + if (possibleName.includes('.') && !namePart.startsWith('.')) { + refChar = '.'; + possibleNameSet = possibleName.split('.').filter(Boolean); + this._logDAT(' -- . possibleNameSet=[' + possibleNameSet + ']'); + } else if (possibleName.includes('#')) { + refChar = '#'; + possibleNameSet = possibleName.split('#').filter(Boolean); + this._logDAT(' -- # possibleNameSet=[' + possibleNameSet + ']'); } namePart = possibleNameSet[0]; const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : possibleNameSet[0] + refChar + possibleNameSet[1]; @@ -1686,12 +1854,12 @@ export class Spin1DocumentSemanticParser { if (allowLocal && this.semanticFindings.isLocalToken(namePart)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(namePart, lineNbr); if (showDebug) { - this._logDAT(" -- FOUND DAT value local name=[" + namePart + "]"); + this._logDAT(' -- FOUND DAT value local name=[' + namePart + ']'); } } else if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); if (showDebug) { - this._logDAT(" -- FOUND DAT value global name=[" + namePart + "]"); + this._logDAT(' -- FOUND DAT value global name=[' + namePart + ']'); } } if (referenceDetails != undefined) { @@ -1700,7 +1868,7 @@ export class Spin1DocumentSemanticParser { startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { if ( @@ -1715,16 +1883,22 @@ export class Spin1DocumentSemanticParser { !this.parseUtils.isP1AsmConditional(namePart) ) { if (showDebug) { - this._logDAT(" -- DAT rDvdc MISSING name=[" + namePart + "]"); + this._logDAT(' -- DAT rDvdc MISSING name=[' + namePart + ']'); } this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 Spin DAT missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 Spin DAT missing declaration [${namePart}]` + ); } } } @@ -1744,12 +1918,13 @@ export class Spin1DocumentSemanticParser { if (inLinePAsmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhitePAsmLineParts(inLinePAsmRHSStr); //currentOffset = line.indexOf(inLinePAsmRHSStr, currentOffset); - this._logPASM(" -- reportDATPAsmDecl lineParts=[" + lineParts + "]"); + this._logPASM(' -- reportDATPAsmDecl lineParts=[' + lineParts + ']'); // handle name in 1 column let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); - let isDataDeclarationLine: boolean = - (lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1])) || (lineParts.length > 0 && !haveLabel && this.parseUtils.isDatStorageType(lineParts[0])); + const isDataDeclarationLine: boolean = + (lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1])) || + (lineParts.length > 0 && !haveLabel && this.parseUtils.isDatStorageType(lineParts[0])); // TODO: REWRITE this to handle "non-label" line with unknown op-code! if (haveLabel) { @@ -1765,35 +1940,41 @@ export class Spin1DocumentSemanticParser { if (referenceDetails != undefined) { const nameOffset = line.indexOf(labelName, currentOffset); this._logPASM(` -- DAT PAsm ${referenceDetails.type}=[${labelName}], ofs=(${nameOffset})`); - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: labelName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); haveLabel = true; } else { // NO Label // hrmf... no global type???? this should be a label? - this._logPASM(" -- DAT PAsm ERROR NOT A label=[" + labelName + "](" + (0 + 1) + ")"); + this._logPASM(' -- DAT PAsm ERROR NOT A label=[' + labelName + '](' + (0 + 1) + ')'); const nameOffset = line.indexOf(labelName, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: labelName.length, - ptTokenType: "variable", // color this offender! - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', // color this offender! + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + labelName.length, eSeverity.Error, `Not a legal P1 pasm label [${labelName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + labelName.length, + eSeverity.Error, + `Not a legal P1 pasm label [${labelName}]` + ); haveLabel = true; } } // no label... if (!isDataDeclarationLine) { // process assembly code - NOT data declaration - this._logPASM(" -- reportDATPAsmDecl NOT Decl lineParts=[" + lineParts + "]"); + this._logPASM(' -- reportDATPAsmDecl NOT Decl lineParts=[' + lineParts + ']'); let argumentOffset = 0; if (lineParts.length > 1) { let minNonLabelParts: number = 1; @@ -1802,7 +1983,7 @@ export class Spin1DocumentSemanticParser { argumentOffset++; minNonLabelParts++; } - if (lineParts[argumentOffset].toUpperCase().startsWith("IF_")) { + if (lineParts[argumentOffset].toUpperCase().startsWith('IF_')) { // skip our conditional argumentOffset++; minNonLabelParts++; @@ -1811,31 +1992,31 @@ export class Spin1DocumentSemanticParser { // have at least instruction name const likelyInstructionName: string = lineParts[minNonLabelParts - 1]; currentOffset = line.indexOf(likelyInstructionName, currentOffset); - this._logPASM(" -- DAT PASM likelyInstructionName=[" + likelyInstructionName + "], currentOffset=(" + currentOffset + ")"); + this._logPASM(' -- DAT PASM likelyInstructionName=[' + likelyInstructionName + '], currentOffset=(' + currentOffset + ')'); currentOffset += likelyInstructionName.length + 1; let nameOffset: number = 0; - let namePart: string = ""; + let namePart: string = ''; for (let index = minNonLabelParts; index < lineParts.length; index++) { - namePart = lineParts[index].replace(/[@#]/, ""); - this._logPASM(" -- DAT PASM checking namePart=[" + namePart + "], currentOffset=(" + currentOffset + ")"); + namePart = lineParts[index].replace(/[@#]/, ''); + this._logPASM(' -- DAT PASM checking namePart=[' + namePart + '], currentOffset=(' + currentOffset + ')'); if (namePart.length < 1) { // skip empty operand continue; } if (index == lineParts.length - 1 && this.parseUtils.isP1AsmEffect(namePart)) { // conditional flag-set spec. - this._logPASM(" -- SKIP namePart=[" + namePart + "]"); + this._logPASM(' -- SKIP namePart=[' + namePart + ']'); continue; } - const argHasArrayRereference: boolean = namePart.includes("["); + const argHasArrayRereference: boolean = namePart.includes('['); if (argHasArrayRereference) { - const nameParts: string[] = namePart.split("["); + const nameParts: string[] = namePart.split('['); namePart = nameParts[0]; } - if (namePart.charAt(0).match(/[a-zA-Z_\.\:]/)) { + if (namePart.charAt(0).match(/[a-zA-Z_.:]/)) { // does name contain a namespace reference? nameOffset = line.indexOf(namePart, currentOffset); - this._logPASM(" -- namePart=[" + namePart + "]"); + this._logPASM(' -- namePart=[' + namePart + ']'); if (this._isPossibleObjectReference(namePart)) { const bHaveObjReference = this._reportObjectReference(namePart, lineIdx, nameOffset, line, tokenSet); if (bHaveObjReference) { @@ -1843,34 +2024,34 @@ export class Spin1DocumentSemanticParser { continue; } } - let refChar: string = ""; + let refChar: string = ''; let possibleNameSet: string[] = [namePart]; - if (namePart.includes(".") && !namePart.startsWith(".")) { - refChar = "."; - possibleNameSet = namePart.split(".").filter(Boolean); - this._logSPIN(" -- . possibleNameSet=[" + possibleNameSet + "]"); - } else if (namePart.includes("#")) { - refChar = "#"; - possibleNameSet = namePart.split("#").filter(Boolean); - this._logSPIN(" -- # possibleNameSet=[" + possibleNameSet + "]"); + if (namePart.includes('.') && !namePart.startsWith('.')) { + refChar = '.'; + possibleNameSet = namePart.split('.').filter(Boolean); + this._logSPIN(' -- . possibleNameSet=[' + possibleNameSet + ']'); + } else if (namePart.includes('#')) { + refChar = '#'; + possibleNameSet = namePart.split('#').filter(Boolean); + this._logSPIN(' -- # possibleNameSet=[' + possibleNameSet + ']'); } namePart = possibleNameSet[0]; const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : possibleNameSet[0] + refChar + possibleNameSet[1]; nameOffset = line.indexOf(searchString, currentOffset); - this._logPASM(" -- DAT PAsm searchString=[" + searchString + "](" + (nameOffset + 1) + ")"); + this._logPASM(' -- DAT PAsm searchString=[' + searchString + '](' + (nameOffset + 1) + ')'); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); - this._logPASM(" -- FOUND DATpasm global name=[" + namePart + "]"); + this._logPASM(' -- FOUND DATpasm global name=[' + namePart + ']'); } if (referenceDetails != undefined) { - this._logPASM(" -- DAT PAsm name=[" + namePart + "](" + (nameOffset + 1) + ")"); + this._logPASM(' -- DAT PAsm name=[' + namePart + '](' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { if ( @@ -1880,15 +2061,21 @@ export class Spin1DocumentSemanticParser { !this.parseUtils.isBinaryOperator(namePart) && !this.parseUtils.isBuiltinReservedWord(namePart) ) { - this._logPASM(" -- DAT PAsm MISSING name=[" + namePart + "](" + (nameOffset + 1) + ")"); + this._logPASM(' -- DAT PAsm MISSING name=[' + namePart + '](' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `Missing P1 pasm name [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `Missing P1 pasm name [${namePart}]` + ); } } } @@ -1897,16 +2084,22 @@ export class Spin1DocumentSemanticParser { } } else if (this.parseUtils.isSpin2ReservedWords(lineParts[0]) && !this.parseUtils.isSpin2ButOKReservedWords(lineParts[0])) { const namePart: string = lineParts[argumentOffset]; - let nameOffset: number = line.indexOf(namePart, currentOffset); - this._logPASM(" -- DAT PAsm ILLEGAL use of PAsm2 name=[" + namePart + "], ofs=(" + (nameOffset + 1) + ")"); + const nameOffset: number = line.indexOf(namePart, currentOffset); + this._logPASM(' -- DAT PAsm ILLEGAL use of PAsm2 name=[' + namePart + '], ofs=(' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 pasm local name [${namePart}] not supported in P1 pasm`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 pasm local name [${namePart}] not supported in P1 pasm` + ); } } else { // process data declaration NOT assembly code @@ -1918,7 +2111,14 @@ export class Spin1DocumentSemanticParser { } const allowLocalVarStatus: boolean = false; const IS_DAT_PASM: boolean = true; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(lineIdx, startingOffset, line, allowLocalVarStatus, this.showPAsmCode, IS_DAT_PASM); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + lineIdx, + startingOffset, + line, + allowLocalVarStatus, + this.showPAsmCode, + IS_DAT_PASM + ); partialTokenSet.forEach((newToken) => { tokenSet.push(newToken); }); @@ -1932,26 +2132,25 @@ export class Spin1DocumentSemanticParser { const lineNbr: number = lineIdx + 1; const tokenSet: IParsedToken[] = []; const methodType: string = line.substr(0, 3).toUpperCase(); - const isPrivate = methodType.indexOf("PRI") != -1; + const isPrivate = methodType.indexOf('PRI') != -1; //skip Past Whitespace let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const spineDeclarationLHSStr = this._getNonCommentLineReturnComment(0, lineIdx, line, tokenSet); - if (spineDeclarationLHSStr) { - } // we don't use this string, we called this to record our rhs comment! + // ----------------------------------- // Method Name // const startNameOffset: number = currentOffset; // find open paren - skipping past method name - currentOffset = spineDeclarationLHSStr.indexOf("(", startNameOffset); // in spin1 ()'s are optional! + currentOffset = spineDeclarationLHSStr.indexOf('(', startNameOffset); // in spin1 ()'s are optional! const openParenOffset: number = currentOffset; if (currentOffset == -1) { - currentOffset = spineDeclarationLHSStr.indexOf(":", startNameOffset); + currentOffset = spineDeclarationLHSStr.indexOf(':', startNameOffset); if (currentOffset == -1) { - currentOffset = spineDeclarationLHSStr.indexOf("|", startNameOffset); + currentOffset = spineDeclarationLHSStr.indexOf('|', startNameOffset); if (currentOffset == -1) { - currentOffset = spineDeclarationLHSStr.indexOf(" ", startNameOffset); + currentOffset = spineDeclarationLHSStr.indexOf(' ', startNameOffset); if (currentOffset == -1) { currentOffset = spineDeclarationLHSStr.indexOf("'", startNameOffset); if (currentOffset == -1) { @@ -1964,28 +2163,28 @@ export class Spin1DocumentSemanticParser { const methodName: string = line.substr(startNameOffset, currentOffset - startNameOffset).trim(); this.currentMethodName = methodName; // notify of latest method name so we can track inLine PASM symbols // record definition of method - const declModifiers: string[] = isPrivate ? ["declaration", "static"] : ["declaration"]; + const declModifiers: string[] = isPrivate ? ['declaration', 'static'] : ['declaration']; this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: startNameOffset, length: methodName.length, - ptTokenType: "method", - ptTokenModifiers: declModifiers, + ptTokenType: 'method', + ptTokenModifiers: declModifiers }); - this._logSPIN("-reportPubPriSig: methodName=[" + methodName + "](" + startNameOffset + ")"); + this._logSPIN('-reportPubPriSig: methodName=[' + methodName + '](' + startNameOffset + ')'); // ----------------------------------- // Parameters // // find close paren - so we can study parameters if (openParenOffset != -1) { - const closeParenOffset = line.indexOf(")", openParenOffset); + const closeParenOffset = line.indexOf(')', openParenOffset); if (closeParenOffset != -1 && currentOffset + 1 != closeParenOffset) { // we have parameter(s)! const parameterStr = line.substr(currentOffset + 1, closeParenOffset - currentOffset - 1).trim(); let parameterNames: string[] = []; - if (parameterStr.includes(",")) { + if (parameterStr.includes(',')) { // we have multiple parameters - parameterNames = parameterStr.split(","); + parameterNames = parameterStr.split(','); } else { // we have one parameter parameterNames = [parameterStr]; @@ -1993,27 +2192,38 @@ export class Spin1DocumentSemanticParser { for (let index = 0; index < parameterNames.length; index++) { const paramName = parameterNames[index].trim(); const nameOffset = line.indexOf(paramName, currentOffset); - this._logSPIN(" -- paramName=[" + paramName + "](" + nameOffset + ")"); + this._logSPIN(' -- paramName=[' + paramName + '](' + nameOffset + ')'); if (this._hidesGlobalVariable(paramName)) { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: paramName.length, - ptTokenType: "parameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'parameter', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + paramName.length, eSeverity.Error, `P1 Spin parameter [${paramName}] hides global variable of same name`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + paramName.length, + eSeverity.Error, + `P1 Spin parameter [${paramName}] hides global variable of same name` + ); } else { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: paramName.length, - ptTokenType: "parameter", - ptTokenModifiers: ["declaration", "readonly", "local"], + ptTokenType: 'parameter', + ptTokenModifiers: ['declaration', 'readonly', 'local'] }); } // remember so we can ID references - this.semanticFindings.setLocalTokenForMethod(methodName, paramName, new RememberedToken("parameter", lineNbr - 1, nameOffset, ["readonly", "local"]), this._declarationComment()); // TOKEN SET in _report() + this.semanticFindings.setLocalTokenForMethod( + methodName, + paramName, + new RememberedToken('parameter', lineNbr - 1, nameOffset, ['readonly', 'local']), + this._declarationComment() + ); // TOKEN SET in _report() currentOffset = nameOffset + paramName.length; } } @@ -2022,11 +2232,11 @@ export class Spin1DocumentSemanticParser { // Return Variable(s) // // find return vars - const returnValueSep: number = line.indexOf(":", currentOffset); - const localVarsSep: number = line.indexOf("|", currentOffset); + const returnValueSep: number = line.indexOf(':', currentOffset); + const localVarsSep: number = line.indexOf('|', currentOffset); let beginCommentOffset: number = line.indexOf("'", currentOffset); if (beginCommentOffset === -1) { - beginCommentOffset = line.indexOf("{", currentOffset); + beginCommentOffset = line.indexOf('{', currentOffset); } const nonCommentEOL: number = beginCommentOffset != -1 ? beginCommentOffset - 1 : line.length - 1; const returnVarsEnd: number = localVarsSep != -1 ? localVarsSep - 1 : nonCommentEOL; @@ -2036,9 +2246,9 @@ export class Spin1DocumentSemanticParser { // we move currentOffset along so we don't falsely find short variable names earlier in string! currentOffset = returnValueSep + 1; const varNameStr = line.substr(returnValueSep + 1, returnVarsEnd - returnValueSep).trim(); - if (varNameStr.indexOf(",")) { + if (varNameStr.indexOf(',')) { // have multiple return value names - returnValueNames = varNameStr.split(","); + returnValueNames = varNameStr.split(','); } else { // have a single return value name returnValueNames = [varNameStr]; @@ -2046,15 +2256,15 @@ export class Spin1DocumentSemanticParser { for (let index = 0; index < returnValueNames.length; index++) { const returnValueName = returnValueNames[index].trim(); const nameOffset = line.indexOf(returnValueName, currentOffset); - this._logSPIN(" -- returnValueName=[" + returnValueName + "](" + nameOffset + ")"); + this._logSPIN(' -- returnValueName=[' + returnValueName + '](' + nameOffset + ')'); // check to see if return name is hiding global variable if (this._hidesGlobalVariable(returnValueName)) { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: returnValueName.length, - ptTokenType: "returnValue", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'returnValue', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -2068,12 +2278,17 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: returnValueName.length, - ptTokenType: "returnValue", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'returnValue', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references - this.semanticFindings.setLocalTokenForMethod(methodName, returnValueName, new RememberedToken("returnValue", lineNbr - 1, nameOffset, ["local"]), this._declarationComment()); // TOKEN SET in _report() + this.semanticFindings.setLocalTokenForMethod( + methodName, + returnValueName, + new RememberedToken('returnValue', lineNbr - 1, nameOffset, ['local']), + this._declarationComment() + ); // TOKEN SET in _report() currentOffset = nameOffset + returnValueName.length; } } @@ -2087,33 +2302,33 @@ export class Spin1DocumentSemanticParser { // we move currentOffset along so we don't falsely find short variable names earlier in string! currentOffset = localVarsSep + 1; let localVarNames: string[] = []; - if (localVarStr.indexOf(",")) { + if (localVarStr.indexOf(',')) { // have multiple return value names - localVarNames = localVarStr.split(","); + localVarNames = localVarStr.split(','); } else { // have a single return value name localVarNames = [localVarStr]; } - this._logSPIN(" -- localVarNames=[" + localVarNames + "]"); + this._logSPIN(' -- localVarNames=[' + localVarNames + ']'); for (let index = 0; index < localVarNames.length; index++) { const localVariableName = localVarNames[index].trim(); const localVariableOffset = line.indexOf(localVariableName, currentOffset); let nameParts: string[] = []; - if (localVariableName.includes(" ")) { + if (localVariableName.includes(' ')) { // have name with storage and/or alignment operators - nameParts = localVariableName.split(" "); + nameParts = localVariableName.split(' '); } else { // have single name nameParts = [localVariableName]; } - this._logSPIN(" -- nameParts=[" + nameParts + "]"); + this._logSPIN(' -- nameParts=[' + nameParts + ']'); for (let index = 0; index < nameParts.length; index++) { let localName = nameParts[index]; // have name similar to scratch[12]? - if (localName.includes("[")) { + if (localName.includes('[')) { // yes remove array suffix const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(localName); - let localNameParts: string[] = lineInfo.lineParts; + const localNameParts: string[] = lineInfo.lineParts; localName = localNameParts[0]; for (let index = 1; index < localNameParts.length; index++) { const namedIndexPart = localNameParts[index]; @@ -2122,30 +2337,34 @@ export class Spin1DocumentSemanticParser { let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isLocalToken(namedIndexPart)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(namedIndexPart, lineNbr); - this._logSPIN(" -- FOUND local name=[" + namedIndexPart + "]"); + this._logSPIN(' -- FOUND local name=[' + namedIndexPart + ']'); } else if (this.semanticFindings.isGlobalToken(namedIndexPart)) { referenceDetails = this.semanticFindings.getGlobalToken(namedIndexPart); - this._logSPIN(" -- FOUND PUB/PRI global name=[" + namedIndexPart + "]"); + this._logSPIN(' -- FOUND PUB/PRI global name=[' + namedIndexPart + ']'); } if (referenceDetails != undefined) { - this._logSPIN(" -- lcl-idx variableName=[" + namedIndexPart + "](" + (nameOffset + 1) + ")"); + this._logSPIN(' -- lcl-idx variableName=[' + namedIndexPart + '](' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namedIndexPart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { - if (!this.parseUtils.isSpinReservedWord(namedIndexPart) && !this.parseUtils.isSpinBuiltinMethod(namedIndexPart) && !this.parseUtils.isBuiltinReservedWord(namedIndexPart)) { + if ( + !this.parseUtils.isSpinReservedWord(namedIndexPart) && + !this.parseUtils.isSpinBuiltinMethod(namedIndexPart) && + !this.parseUtils.isBuiltinReservedWord(namedIndexPart) + ) { // we don't have name registered so just mark it - this._logSPIN(" -- SPIN MISSING varname=[" + namedIndexPart + "](" + (nameOffset + 1) + ")"); + this._logSPIN(' -- SPIN MISSING varname=[' + namedIndexPart + '](' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namedIndexPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); if (this.parseUtils.isP2SpinMethod(namedIndexPart)) { this.semanticFindings.pushDiagnosticMessage( @@ -2156,7 +2375,13 @@ export class Spin1DocumentSemanticParser { `Possible use of P2 Spin reserved word [${namedIndexPart}]` ); } else { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namedIndexPart.length, eSeverity.Error, `P1 Spin A missing declaration [${namedIndexPart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namedIndexPart.length, + eSeverity.Error, + `P1 Spin A missing declaration [${namedIndexPart}]` + ); } } } @@ -2165,7 +2390,7 @@ export class Spin1DocumentSemanticParser { } } const nameOffset = line.indexOf(localName, localVariableOffset); - this._logSPIN(" -- localName=[" + localName + "](" + nameOffset + ")"); + this._logSPIN(' -- localName=[' + localName + '](' + nameOffset + ')'); if (index == nameParts.length - 1) { // have name // check to see if local name is hiding global variable @@ -2174,21 +2399,32 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: localName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + localName.length, eSeverity.Error, `P1 Spin local [${localName}] hides global variable of same name`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + localName.length, + eSeverity.Error, + `P1 Spin local [${localName}] hides global variable of same name` + ); } else { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: localName.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references - this.semanticFindings.setLocalTokenForMethod(methodName, localName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["local"]), this._declarationComment()); // TOKEN SET in _report() + this.semanticFindings.setLocalTokenForMethod( + methodName, + localName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['local']), + this._declarationComment() + ); // TOKEN SET in _report() } else { // have modifier! if (this.parseUtils.isStorageType(localName)) { @@ -2196,8 +2432,8 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: localName.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } } @@ -2211,7 +2447,7 @@ export class Spin1DocumentSemanticParser { private _hidesGlobalVariable(variableName: string): boolean { let hideStatus: boolean = false; - let referenceDetails: RememberedToken | undefined = undefined; + //const referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(variableName)) { hideStatus = true; } @@ -2228,21 +2464,27 @@ export class Spin1DocumentSemanticParser { this._logCON(`- reportSPIN nonCommentSpinLine=[${nonCommentSpinLine}] remainingLength=${remainingLength}`); if (remainingLength > 0) { // special early error case - if (nonCommentSpinLine.toLowerCase().includes("else if")) { - const nameOffset = line.toLowerCase().indexOf("else if", currentOffset); + if (nonCommentSpinLine.toLowerCase().includes('else if')) { + const nameOffset = line.toLowerCase().indexOf('else if', currentOffset); this._logSPIN(` -- Illegal ELSE-IF [${nonCommentSpinLine}]`); - const tokenLength: number = "else if".length; + const tokenLength: number = 'else if'.length; this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: tokenLength, - ptTokenType: "keyword", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'keyword', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + tokenLength, eSeverity.Error, 'Illegal "else if" form for P1 Spin'); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + tokenLength, + eSeverity.Error, + 'Illegal "else if" form for P1 Spin' + ); } // locate key indicators of line style - let assignmentOffset: number = nonCommentSpinLine.includes(":=") ? line.indexOf(":=", currentOffset) : -1; + const assignmentOffset: number = nonCommentSpinLine.includes(':=') ? line.indexOf(':=', currentOffset) : -1; if (assignmentOffset != -1) { // ------------------------------------------- // have line assigning value to variable(s) @@ -2251,16 +2493,16 @@ export class Spin1DocumentSemanticParser { const possibleVariableName = line.substr(currentOffset, assignmentOffset - currentOffset).trim(); this._logSPIN(` -- LHS: possibleVariableName=[${possibleVariableName}]`); let varNameList: string[] = [possibleVariableName]; - if (possibleVariableName.includes(",")) { - varNameList = possibleVariableName.split(","); - } else if (possibleVariableName.includes(" ") || possibleVariableName.includes("..")) { + if (possibleVariableName.includes(',')) { + varNameList = possibleVariableName.split(','); + } else if (possibleVariableName.includes(' ') || possibleVariableName.includes('..')) { // force special case range chars to be removed // Ex: RESP_OVER..RESP_NOT_FOUND : error_code.byte[3] := mod // change .. to : so it is removed by getNonWhite... - const filteredLine: string = possibleVariableName.replace("..", ":"); + const filteredLine: string = possibleVariableName.replace('..', ':'); const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(filteredLine); varNameList = lineInfo.lineParts; - } else if (possibleVariableName.includes("(")) { + } else if (possibleVariableName.includes('(')) { const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(possibleVariableName); varNameList = lineInfo.lineParts; } @@ -2268,21 +2510,21 @@ export class Spin1DocumentSemanticParser { for (let index = 0; index < varNameList.length; index++) { let nameOffset: number = currentOffset; let variableName: string = varNameList[index]; - const variableNameLen: number = variableName.length; - if (variableName.includes("[")) { + //const variableNameLen: number = variableName.length; + if (variableName.includes('[')) { // NOTE this handles code: byte[pColor][2] := {value} //outa[D7..D4] := %0011 P1 OBEX:LCD SPIN driver - 2x16.spin (315) // have complex target name, parse in loop (remove our range specifier '..') - if (variableName.includes("..")) { - variableName = variableName.replace("..", " "); + if (variableName.includes('..')) { + variableName = variableName.replace('..', ' '); } - const variableNameParts: string[] = variableName.split(/[ \t\[\]\/\*\+\-\(\)\<\>]/).filter(Boolean); + const variableNameParts: string[] = variableName.split(/[ \t[\]/*+\-()<>]/).filter(Boolean); this._logSPIN(` -- LHS: [] variableNameParts=[${variableNameParts}]`); for (let index = 0; index < variableNameParts.length; index++) { - let variableNamePart = variableNameParts[index].replace("@", ""); + let variableNamePart = variableNameParts[index].replace('@', ''); // secial case handle datar.[i] which leaves var name as 'darar.' - if (variableNamePart.endsWith(".")) { + if (variableNamePart.endsWith('.')) { variableNamePart = variableNamePart.substr(0, variableNamePart.length - 1); } nameOffset = line.indexOf(variableNamePart, currentOffset); @@ -2294,8 +2536,8 @@ export class Spin1DocumentSemanticParser { continue; } } - if (variableNamePart.includes(".")) { - const varNameParts: string[] = variableNamePart.split("."); + if (variableNamePart.includes('.')) { + const varNameParts: string[] = variableNamePart.split('.'); if (this.parseUtils.isDatStorageType(varNameParts[1])) { variableNamePart = varNameParts[0]; // just use first part of name } @@ -2306,8 +2548,8 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: variableNamePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } else { let referenceDetails: RememberedToken | undefined = undefined; @@ -2319,27 +2561,37 @@ export class Spin1DocumentSemanticParser { this._logSPIN(` -- FOUND SPIN global name=[${variableNamePart}]`); } if (referenceDetails != undefined) { - const modificationArray: string[] = referenceDetails.modifiersWith("modification"); + const modificationArray: string[] = referenceDetails.modifiersWith('modification'); this._logSPIN(` -- SPIN variableName=[${variableNamePart}], ofs=(${nameOffset})`); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: variableNamePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modificationArray, + ptTokenModifiers: modificationArray }); } else { - if (!this.parseUtils.isSpinReservedWord(variableNamePart) && !this.parseUtils.isBuiltinReservedWord(variableNamePart) && !this.parseUtils.isSpinBuiltinMethod(variableNamePart)) { + if ( + !this.parseUtils.isSpinReservedWord(variableNamePart) && + !this.parseUtils.isBuiltinReservedWord(variableNamePart) && + !this.parseUtils.isSpinBuiltinMethod(variableNamePart) + ) { // we don't have name registered so just mark it this._logSPIN(` -- SPIN MISSING varname=[${variableNamePart}], ofs=(${nameOffset})`); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: variableNamePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + variableNamePart.length, eSeverity.Error, `P1 Spin B missing declaration [${variableNamePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + variableNamePart.length, + eSeverity.Error, + `P1 Spin B missing declaration [${variableNamePart}]` + ); } } } @@ -2348,7 +2600,7 @@ export class Spin1DocumentSemanticParser { } } else { // have simple target name, no [] - let cleanedVariableName: string = variableName.replace(/[ \t\(\)]/, ""); + let cleanedVariableName: string = variableName.replace(/[ \t()]/, ''); nameOffset = line.indexOf(cleanedVariableName, currentOffset); if (cleanedVariableName.charAt(0).match(/[a-zA-Z_]/) && !this.parseUtils.isStorageType(cleanedVariableName)) { this._logSPIN(` -- SPIN cleanedVariableName=[${cleanedVariableName}], ofs=(${nameOffset})`); @@ -2359,8 +2611,8 @@ export class Spin1DocumentSemanticParser { continue; } } - if (cleanedVariableName.includes(".")) { - const varNameParts: string[] = cleanedVariableName.split("."); + if (cleanedVariableName.includes('.')) { + const varNameParts: string[] = cleanedVariableName.split('.'); if (this.parseUtils.isDatStorageType(varNameParts[1])) { cleanedVariableName = varNameParts[0]; // just use first part of name } @@ -2374,23 +2626,23 @@ export class Spin1DocumentSemanticParser { this._logSPIN(` -- FOUND globel name=[${cleanedVariableName}]`); } if (referenceDetails != undefined) { - const modificationArray: string[] = referenceDetails.modifiersWith("modification"); + const modificationArray: string[] = referenceDetails.modifiersWith('modification'); this._logSPIN(` -- spin: simple variableName=[${cleanedVariableName}], ofs=(${nameOffset})`); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: cleanedVariableName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modificationArray, + ptTokenModifiers: modificationArray }); - } else if (cleanedVariableName == "_") { + } else if (cleanedVariableName == '_') { this._logSPIN(` -- built-in=[${cleanedVariableName}], ofs=(${nameOffset})`); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: cleanedVariableName.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "defaultLibrary"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'defaultLibrary'] }); } else { // we don't have name registered so just mark it @@ -2404,8 +2656,8 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: cleanedVariableName.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'missingDeclaration'] }); if (this.parseUtils.isP2SpinMethod(cleanedVariableName)) { this.semanticFindings.pushDiagnosticMessage( @@ -2437,36 +2689,42 @@ export class Spin1DocumentSemanticParser { // ------------------------------------------- const rhsOffset: number = assignmentOffset != -1 ? assignmentOffset + 2 : currentOffset; const assignmentRHSStr: string = this._getNonCommentLineReturnComment(rhsOffset, lineIdx, line, tokenSet); - const preCleanAssignmentRHSStr = this.parseUtils.getNonInlineCommentLine(assignmentRHSStr).replace("..", " "); - this._logSPIN(" -- SPIN assignmentRHSStr=[" + assignmentRHSStr + "]"); + const preCleanAssignmentRHSStr = this.parseUtils.getNonInlineCommentLine(assignmentRHSStr).replace('..', ' '); + this._logSPIN(' -- SPIN assignmentRHSStr=[' + assignmentRHSStr + ']'); const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(preCleanAssignmentRHSStr); - let possNames: string[] = lineInfo.lineParts; + const possNames: string[] = lineInfo.lineParts; const nonStringAssignmentRHSStr: string = lineInfo.lineNoQuotes; - this._logSPIN(" -- possNames=[" + possNames + "]"); + this._logSPIN(' -- possNames=[' + possNames + ']'); let nameOffset: number = 0; let nameLen: number = 0; for (let index = 0; index < possNames.length; index++) { let possibleName = possNames[index]; // special code to handle case of var.[bitfield] leaving name a 'var.' - if (possibleName.endsWith(".")) { + if (possibleName.endsWith('.')) { possibleName = possibleName.substr(0, possibleName.length - 1); } - const currNonStringNameLen: number = possNames[index].length; + //const currNonStringNameLen: number = possNames[index].length; if (possibleName.charAt(0).match(/[a-zA-Z_]/)) { - this._logSPIN(" -- possibleName=[" + possibleName + "]"); + this._logSPIN(' -- possibleName=[' + possibleName + ']'); // EXCEPTION processing for P2 use of inline pasm // in P1 remind us that it's illegal - if (possibleName.toLowerCase() === "org" || possibleName.toLowerCase() === "org") { + if (possibleName.toLowerCase() === 'org' || possibleName.toLowerCase() === 'org') { nameOffset = line.indexOf(possibleName, 0); - this._logSPIN(" -- SPIN ILLEGAL in-line use name=[" + possibleName + "](" + (nameOffset + 1) + ")"); + this._logSPIN(' -- SPIN ILLEGAL in-line use name=[' + possibleName + '](' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: possibleName.length, - ptTokenType: "built-in", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'built-in', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + possibleName.length, eSeverity.Error, `In-line Pasm not allowed in P1 Spin [${possibleName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + possibleName.length, + eSeverity.Error, + `In-line Pasm not allowed in P1 Spin [${possibleName}]` + ); return tokenSet; } @@ -2479,60 +2737,60 @@ export class Spin1DocumentSemanticParser { continue; } } - let refChar: string = ""; + let refChar: string = ''; let possibleNameSet: string[] = [possibleName]; - if (possibleName.includes(".") && !possibleName.startsWith(".")) { - refChar = "."; - possibleNameSet = possibleName.split(".").filter(Boolean); - this._logSPIN(" -- . possibleNameSet=[" + possibleNameSet + "]"); - } else if (possibleName.includes("#")) { - refChar = "#"; - possibleNameSet = possibleName.split("#").filter(Boolean); - this._logSPIN(" -- # possibleNameSet=[" + possibleNameSet + "]"); + if (possibleName.includes('.') && !possibleName.startsWith('.')) { + refChar = '.'; + possibleNameSet = possibleName.split('.').filter(Boolean); + this._logSPIN(' -- . possibleNameSet=[' + possibleNameSet + ']'); + } else if (possibleName.includes('#')) { + refChar = '#'; + possibleNameSet = possibleName.split('#').filter(Boolean); + this._logSPIN(' -- # possibleNameSet=[' + possibleNameSet + ']'); } const namePart = possibleNameSet[0]; const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : possibleNameSet[0] + refChar + possibleNameSet[1]; nameOffset = line.indexOf(searchString, currentOffset); nameLen = namePart.length; - this._logSPIN(" -- SPIN RHS nonStringAssignmentRHSStr=[" + nonStringAssignmentRHSStr + "]"); - this._logSPIN(" -- SPIN RHS searchString=[" + searchString + "], namePart=[" + namePart + "]"); - this._logSPIN(" -- SPIN RHS nameOffset=(" + nameOffset + "), currentOffset=(" + currentOffset + ")"); + this._logSPIN(' -- SPIN RHS nonStringAssignmentRHSStr=[' + nonStringAssignmentRHSStr + ']'); + this._logSPIN(' -- SPIN RHS searchString=[' + searchString + '], namePart=[' + namePart + ']'); + this._logSPIN(' -- SPIN RHS nameOffset=(' + nameOffset + '), currentOffset=(' + currentOffset + ')'); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isLocalToken(namePart)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(namePart, lineNbr); - this._logSPIN(" -- FOUND spinRHS local name=[" + namePart + "]"); + this._logSPIN(' -- FOUND spinRHS local name=[' + namePart + ']'); } else if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); - this._logSPIN(" -- FOUND spinRHS global name=[" + namePart + "]"); + this._logSPIN(' -- FOUND spinRHS global name=[' + namePart + ']'); } if (referenceDetails != undefined) { - this._logSPIN(" -- SPIN RHS name=[" + namePart + "](" + (nameOffset + 1) + ")"); + this._logSPIN(' -- SPIN RHS name=[' + namePart + '](' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // have unknown name!? is storage type spec? if (this.parseUtils.isStorageType(namePart)) { - this._logSPIN(" -- SPIN RHS storageType=[" + namePart + "]"); + this._logSPIN(' -- SPIN RHS storageType=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } else if (this.parseUtils.isSpinBuiltInConstant(namePart)) { - this._logSPIN(" -- SPIN RHS builtin constant=[" + namePart + "]"); + this._logSPIN(' -- SPIN RHS builtin constant=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly", "defaultLibrary"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly', 'defaultLibrary'] }); } else if ( !this.parseUtils.isSpinReservedWord(namePart) && @@ -2540,34 +2798,49 @@ export class Spin1DocumentSemanticParser { !this.parseUtils.isSpinBuiltInVariable(namePart) && !this.parseUtils.isBuiltinReservedWord(namePart) ) { - this._logSPIN(" -- SPIN MISSING rhs name=[" + namePart + "]"); + this._logSPIN(' -- SPIN MISSING rhs name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - if (this.parseUtils.isP2SpinMethod(namePart) || (this.parseUtils.isSpin2ReservedWords(namePart) && !this.parseUtils.isSpin2ButOKReservedWords(namePart))) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Information, `Possible use of P2 Spin reserved word [${namePart}]`); + if ( + this.parseUtils.isP2SpinMethod(namePart) || + (this.parseUtils.isSpin2ReservedWords(namePart) && !this.parseUtils.isSpin2ButOKReservedWords(namePart)) + ) { + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Information, + `Possible use of P2 Spin reserved word [${namePart}]` + ); } else { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 Spin D missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 Spin D missing declaration [${namePart}]` + ); } } else { this._logSPIN(` -- SPIN ??? What to do with: rhs name=[${namePart}], ofs=(${nameOffset})`); } } - } else if (possibleName.startsWith(".")) { - const externalMethodName: string = possibleName.replace(".", ""); + } else if (possibleName.startsWith('.')) { + const externalMethodName: string = possibleName.replace('.', ''); nameOffset = line.indexOf(externalMethodName, currentOffset); nameLen = externalMethodName.length; - this._logSPIN(" -- SPIN rhs externalMethodName=[" + externalMethodName + "](" + (nameOffset + 1) + ")"); + this._logSPIN(' -- SPIN rhs externalMethodName=[' + externalMethodName + '](' + (nameOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: externalMethodName.length, - ptTokenType: "method", - ptTokenModifiers: [], + ptTokenType: 'method', + ptTokenModifiers: [] }); } currentOffset = nameOffset + nameLen + 1; @@ -2579,14 +2852,14 @@ export class Spin1DocumentSemanticParser { private _reportOBJ_DeclarationLine(lineIdx: number, startingOffset: number, line: string): IParsedToken[] { const tokenSet: IParsedToken[] = []; //skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); //this._logOBJ('- RptObjDecl remainingNonCommentLineStr=[' + remainingNonCommentLineStr + ']'); const remainingLength: number = remainingNonCommentLineStr.length; if (remainingLength > 0) { // get line parts - initially, we only care about first one - const lineParts: string[] = remainingNonCommentLineStr.split(/[ \t\:\[]/).filter(Boolean); - this._logOBJ(" -- OBJ lineParts=[" + lineParts + "]"); + const lineParts: string[] = remainingNonCommentLineStr.split(/[ \t:[]/).filter(Boolean); + this._logOBJ(' -- OBJ lineParts=[' + lineParts + ']'); const objectName = lineParts[0]; // object name token must be offset into full line for token const nameOffset: number = line.indexOf(objectName, currentOffset); @@ -2594,22 +2867,22 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: objectName.length, - ptTokenType: "namespace", - ptTokenModifiers: ["declaration"], + ptTokenType: 'namespace', + ptTokenModifiers: ['declaration'] }); - const objArrayOpen: number = remainingNonCommentLineStr.indexOf("["); + const objArrayOpen: number = remainingNonCommentLineStr.indexOf('['); if (objArrayOpen != -1) { // we have an array of objects, study the index value for possible named reference(s) - const objArrayClose: number = remainingNonCommentLineStr.indexOf("]"); + const objArrayClose: number = remainingNonCommentLineStr.indexOf(']'); if (objArrayClose != -1) { const elemCountStr: string = remainingNonCommentLineStr.substr(objArrayOpen + 1, objArrayClose - objArrayOpen - 1); // if we have a variable name... if (elemCountStr.charAt(0).match(/[a-zA-Z_]/)) { let possibleNameSet: string[] = []; - const hasOpenParen: boolean = elemCountStr.indexOf("(") != -1; // should never be, but must check + const hasOpenParen: boolean = elemCountStr.indexOf('(') != -1; // should never be, but must check // is it a namespace reference? - if (elemCountStr.includes(".")) { - possibleNameSet = elemCountStr.split("."); + if (elemCountStr.includes('.')) { + possibleNameSet = elemCountStr.split('.'); } else { possibleNameSet = [elemCountStr]; } @@ -2621,39 +2894,45 @@ export class Spin1DocumentSemanticParser { const nameOffset = line.indexOf(nameReference, currentOffset); if (referenceDetails != undefined) { //const updatedModificationSet: string[] = this._modifiersWithout(referenceDetails.modifiers, "declaration"); - this._logOBJ(" -- FOUND OBJ global name=[" + nameReference + "]"); + this._logOBJ(' -- FOUND OBJ global name=[' + nameReference + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: nameReference.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } } else { // have possible dotted reference with name in other object. if has to be a constant if (!hasOpenParen) { - this._logOBJ(" -- OBJ Constant in external object name=[" + nameReference + "]"); + this._logOBJ(' -- OBJ Constant in external object name=[' + nameReference + ']'); const nameOffset = line.indexOf(nameReference, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: nameReference.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly'] }); } // we don't have name registered so just mark it else if (!this.parseUtils.isSpinReservedWord(nameReference) && !this.parseUtils.isBuiltinReservedWord(nameReference)) { - this._logOBJ(" -- OBJ MISSING name=[" + nameReference + "]"); + this._logOBJ(' -- OBJ MISSING name=[' + nameReference + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: nameReference.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + nameReference.length, eSeverity.Error, `P1 Spin E missing declaration [${nameReference}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + nameReference.length, + eSeverity.Error, + `P1 Spin E missing declaration [${nameReference}]` + ); } } } @@ -2671,26 +2950,26 @@ export class Spin1DocumentSemanticParser { const remainingNonCommentLineStr: string = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); if (remainingNonCommentLineStr.length > 0) { // get line parts - we only care about first one - let lineParts: string[] = this.parseUtils.getCommaDelimitedNonWhiteLineParts(remainingNonCommentLineStr); - this._logVAR(" -- rptVarDecl lineParts=[" + lineParts + "]"); + const lineParts: string[] = this.parseUtils.getCommaDelimitedNonWhiteLineParts(remainingNonCommentLineStr); + this._logVAR(' -- rptVarDecl lineParts=[' + lineParts + ']'); // remember this object name so we can annotate a call to it - const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(","); + //const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(','); const hasStorageType: boolean = this.parseUtils.isStorageType(lineParts[0]); if (lineParts.length > 1) { const startIndex: number = hasStorageType ? 1 : 0; for (let index = startIndex; index < lineParts.length; index++) { let newName = lineParts[index]; - const hasArrayReference: boolean = newName.indexOf("[") != -1; + const hasArrayReference: boolean = newName.indexOf('[') != -1; let nameOffset: number = 0; if (hasArrayReference) { // remove array suffix from name - if (newName.includes("[")) { - const nameParts: string[] = newName.split("["); + if (newName.includes('[')) { + const nameParts: string[] = newName.split('['); newName = nameParts[0]; } } // in the following, let's not register a name with a trailing ']' this is part of an array size calculation! - if (newName.charAt(0).match(/[a-zA-Z_]/) && newName.indexOf("]") == -1) { + if (newName.charAt(0).match(/[a-zA-Z_]/) && newName.indexOf(']') == -1) { nameOffset = line.indexOf(newName, currentOffset); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(newName)) { @@ -2700,36 +2979,42 @@ export class Spin1DocumentSemanticParser { this._logMessage(` -- rObjRef MISSING global name=[${newName}]`); } if (referenceDetails != undefined) { - this._logVAR(" -- GLBL found rvdl newName=[" + newName + "]"); + this._logVAR(' -- GLBL found rvdl newName=[' + newName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "instance"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'instance'] }); } else { - this._logVAR(" -- VAR Add MISSING name=[" + newName + "]"); + this._logVAR(' -- VAR Add MISSING name=[' + newName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + newName.length, eSeverity.Error, `P1 Spin F missing declaration [${newName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + newName.length, + eSeverity.Error, + `P1 Spin F missing declaration [${newName}]` + ); } currentOffset = nameOffset + newName.length; } if (hasArrayReference) { // process name with array length value - const arrayOpenOffset: number = line.indexOf("[", currentOffset); - const arrayCloseOffset: number = line.indexOf("]", currentOffset); + const arrayOpenOffset: number = line.indexOf('[', currentOffset); + const arrayCloseOffset: number = line.indexOf(']', currentOffset); const arrayReference: string = line.substr(arrayOpenOffset + 1, arrayCloseOffset - arrayOpenOffset - 1); - const arrayReferenceParts: string[] = arrayReference.split(/[ \t\/\*\+\<\>]/).filter(Boolean); + const arrayReferenceParts: string[] = arrayReference.split(/[ \t/*+<>]/).filter(Boolean); this._logVAR(` -- arrayReferenceParts=[${arrayReferenceParts}}](${arrayReferenceParts.length})`); let nameOffset: number = 0; - let namePart: string = ""; + let namePart: string = ''; for (let index = 0; index < arrayReferenceParts.length; index++) { namePart = arrayReferenceParts[index]; if (namePart.charAt(0).match(/[a-zA-Z_]/)) { @@ -2741,34 +3026,40 @@ export class Spin1DocumentSemanticParser { continue; } } - let possibleNameSet: string[] = [namePart]; - this._logVAR(" -- possibleNameSet=[" + possibleNameSet + "](" + possibleNameSet.length + ")"); + const possibleNameSet: string[] = [namePart]; + this._logVAR(' -- possibleNameSet=[' + possibleNameSet + '](' + possibleNameSet.length + ')'); namePart = possibleNameSet[0]; if (this.semanticFindings.isGlobalToken(namePart)) { const referenceDetails: RememberedToken | undefined = this.semanticFindings.getGlobalToken(namePart); - const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : possibleNameSet[0] + "#" + possibleNameSet[1]; + const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : possibleNameSet[0] + '#' + possibleNameSet[1]; nameOffset = line.indexOf(searchString, currentOffset); if (referenceDetails != undefined) { - this._logVAR(" -- FOUND VAR global name=[" + namePart + "]"); + this._logVAR(' -- FOUND VAR global name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // we don't have name registered so just mark it if (!this.parseUtils.isSpinReservedWord(namePart) && !this.parseUtils.isBuiltinReservedWord(namePart)) { - this._logVAR(" -- VAR Add MISSING name=[" + namePart + "]"); + this._logVAR(' -- VAR Add MISSING name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 Spin G missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 Spin G missing declaration [${namePart}]` + ); } } } @@ -2779,16 +3070,16 @@ export class Spin1DocumentSemanticParser { } } else { // have single declaration per line - let newName = lineParts[0]; + const newName = lineParts[0]; if (newName.charAt(0).match(/[a-zA-Z_]/)) { - this._logVAR(" -- GLBL rvdl2 newName=[" + newName + "]"); + this._logVAR(' -- GLBL rvdl2 newName=[' + newName + ']'); const nameOffset: number = line.indexOf(newName, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "instance"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'instance'] }); } } @@ -2800,10 +3091,10 @@ export class Spin1DocumentSemanticParser { // could be objectInstance.method or objectInstance#constant or objectInstance.method() // but can NOT be ".name" const dottedSymbolRegex = /[a-zA-Z0-9_]\.[a-zA-Z_]/; - const hashedSymbolRegex = /[a-zA-Z0-9_]\#[a-zA-Z_]/; + const hashedSymbolRegex = /[a-zA-Z0-9_]#[a-zA-Z_]/; const hasSymbolDotSymbol: boolean = dottedSymbolRegex.test(possibleRef); const hasSymbolHashSymbol: boolean = hashedSymbolRegex.test(possibleRef); - return !possibleRef.startsWith(".") && (hasSymbolDotSymbol || hasSymbolHashSymbol); + return !possibleRef.startsWith('.') && (hasSymbolDotSymbol || hasSymbolHashSymbol); } private _reportObjectReference(dotReference: string, lineIdx: number, startingOffset: number, line: string, tokenSet: IParsedToken[]): boolean { @@ -2812,10 +3103,10 @@ export class Spin1DocumentSemanticParser { this._logMessage(`- reportObjectReference() line(${lineIdx + 1}):[${dotReference}], ofs=(${startingOffset})`); let possibleNameSet: string[] = []; let bGeneratedReference: boolean = false; - const isObjectConstantRef: boolean = dotReference.includes("#"); - if (dotReference.includes(".") || isObjectConstantRef) { + const isObjectConstantRef: boolean = dotReference.includes('#'); + if (dotReference.includes('.') || isObjectConstantRef) { const symbolOffset: number = line.indexOf(dotReference, startingOffset); // walk this past each - possibleNameSet = dotReference.split(/[\.#]/).filter(Boolean); + possibleNameSet = dotReference.split(/[.#]/).filter(Boolean); this._logMessage(` -- rObjRef possibleNameSet=[${possibleNameSet}](${possibleNameSet.length})`); const objInstanceName = possibleNameSet[0]; if (this.semanticFindings.isNameSpace(objInstanceName)) { @@ -2834,14 +3125,14 @@ export class Spin1DocumentSemanticParser { startCharacter: symbolOffset, length: objInstanceName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); if (possibleNameSet.length > 1) { // we have .constant namespace suffix // determine if this is method has '(' or constant name const objReferencedName = possibleNameSet[1]; const referenceOffset = line.indexOf(objReferencedName, symbolOffset + objInstanceName.length); - let isMethod: boolean = !isObjectConstantRef; + const isMethod: boolean = !isObjectConstantRef; referenceDetails = undefined; const extObjFindings: DocumentFindings | undefined = this.semanticFindings.getFindingsForNamespace(objInstanceName); @@ -2851,12 +3142,12 @@ export class Spin1DocumentSemanticParser { } if (referenceDetails != undefined) { // have matching external reference, now validate it - const tokenTypeID: string = isMethod ? "method" : "variable"; + const tokenTypeID: string = isMethod ? 'method' : 'variable'; let referenceTypeID: string = referenceDetails.type; - if (referenceTypeID === "enumMember") { - referenceTypeID = "variable"; + if (referenceTypeID === 'enumMember') { + referenceTypeID = 'variable'; } - const tokenModifiers: string[] = isMethod ? [] : ["readonly"]; + const tokenModifiers: string[] = isMethod ? [] : ['readonly']; const haveExpectedType: boolean = referenceTypeID === tokenTypeID; if (haveExpectedType) { this._logMessage(` -- rObjRef rhs constant=[${objReferencedName}], ofs=(${referenceOffset}) (${tokenTypeID})`); @@ -2865,7 +3156,7 @@ export class Spin1DocumentSemanticParser { startCharacter: referenceOffset, length: objReferencedName.length, ptTokenType: tokenTypeID, - ptTokenModifiers: tokenModifiers, + ptTokenModifiers: tokenModifiers }); } else { this._recordToken(tokenSet, line, { @@ -2873,11 +3164,11 @@ export class Spin1DocumentSemanticParser { startCharacter: referenceOffset, length: objReferencedName.length, ptTokenType: tokenTypeID, - ptTokenModifiers: ["illegalUse"], + ptTokenModifiers: ['illegalUse'] }); - const expectedType: string = isMethod ? "METHOD Name" : "Constant Name"; - const recievedType: string = isMethod ? "Constant Name" : "METHOD Name"; - const joinString: string = isMethod ? "." : "#"; + const expectedType: string = isMethod ? 'METHOD Name' : 'Constant Name'; + const recievedType: string = isMethod ? 'Constant Name' : 'METHOD Name'; + const joinString: string = isMethod ? '.' : '#'; this.semanticFindings.pushDiagnosticMessage( lineIdx, referenceOffset, @@ -2892,10 +3183,10 @@ export class Spin1DocumentSemanticParser { line: lineIdx, startCharacter: referenceOffset, length: objReferencedName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - const refType: string = isMethod ? "Method" : "Constant"; + const refType: string = isMethod ? 'Method' : 'Constant'; const adjustedName: string = isMethod ? `${objReferencedName}()` : objReferencedName; this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -2925,16 +3216,16 @@ export class Spin1DocumentSemanticParser { bGeneratedReference = true; const referenceOffset = line.indexOf(referencePart, symbolOffset + objInstanceName.length + 1); let isMethod: boolean = false; - if (!isObjectConstantRef && line.substr(referenceOffset + referencePart.length, 1) == "(") { + if (!isObjectConstantRef && line.substr(referenceOffset + referencePart.length, 1) == '(') { isMethod = true; } - this._logMessage(" -- rObjRef MISSING instance declaration=[" + objInstanceName + "]"); + this._logMessage(' -- rObjRef MISSING instance declaration=[' + objInstanceName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: objInstanceName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -2943,15 +3234,15 @@ export class Spin1DocumentSemanticParser { eSeverity.Error, `P1 Spin Missing object instance declaration [${objInstanceName}]` ); - this._logMessage(" -- rObjRef Error refPart=[" + referencePart + "](" + (referenceOffset + 1) + ")"); + this._logMessage(' -- rObjRef Error refPart=[' + referencePart + '](' + (referenceOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: referenceOffset, length: referencePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - const refType: string = isMethod ? "Method" : "Constant"; + const refType: string = isMethod ? 'Method' : 'Constant'; const adjustedName: string = isMethod ? `${referencePart}()` : referencePart; this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -2973,38 +3264,42 @@ export class Spin1DocumentSemanticParser { if (newToken.line != -1 && newToken.startCharacter != -1) { tokenSet.push(newToken); } else { - const tokenInterp: string = `token(${newToken.line + 1},${newToken.startCharacter})=[len:${newToken.length}](${newToken.ptTokenType}[${newToken.ptTokenModifiers}])]`; + const tokenInterp: string = `token(${newToken.line + 1},${newToken.startCharacter})=[len:${newToken.length}](${newToken.ptTokenType}[${ + newToken.ptTokenModifiers + }])]`; this._logMessage(`** ERROR: BAD token nextString=[${tokenInterp}]`); } } - private _generateFakeCommentForSignature(startingOffset: number, lineNbr: number, line: string): RememberedComment { - if (startingOffset) { - } // kill warning - let desiredComment: RememberedComment = new RememberedComment(eCommentType.Unknown, -1, ""); + private _generateFakeCommentForSignature(_startingOffset: number, lineNbr: number, line: string): RememberedComment { + let desiredComment: RememberedComment = new RememberedComment(eCommentType.Unknown, -1, ''); const linePrefix: string = line.substring(0, 3).toLowerCase(); - const isSignature: boolean = linePrefix == "pub" || linePrefix == "pri" ? true : false; - const isPri: boolean = linePrefix == "pri" ? true : false; - this._logSPIN(" -- gfcfs linePrefix=[" + linePrefix + "](" + linePrefix.length + ")" + `, isSignature=${isSignature}, isPri=${isPri}`); + const isSignature: boolean = linePrefix == 'pub' || linePrefix == 'pri' ? true : false; + const isPri: boolean = linePrefix == 'pri' ? true : false; + this._logSPIN(' -- gfcfs linePrefix=[' + linePrefix + '](' + linePrefix.length + ')' + `, isSignature=${isSignature}, isPri=${isPri}`); if (isSignature) { const cmtType: eCommentType = isPri ? eCommentType.multiLineComment : eCommentType.multiLineDocComment; - let tmpDesiredComment: RememberedComment = new RememberedComment(cmtType, lineNbr, "NOTE: insert comment template by pressing Ctrl+Alt+C on PRI signature line, then fill it in."); + const tmpDesiredComment: RememberedComment = new RememberedComment( + cmtType, + lineNbr, + 'NOTE: insert comment template by pressing Ctrl+Alt+C on PRI signature line, then fill it in.' + ); const signatureComment: string[] = this._generateDocCommentForSignature(line, this.isSpin1Document); if (signatureComment && signatureComment.length > 0) { let lineCount: number = 1; // count our comment line on creation for (let cmtIdx = 0; cmtIdx < signatureComment.length; cmtIdx++) { const currCmtLine: string = signatureComment[cmtIdx]; - if (currCmtLine.includes("@param")) { - tmpDesiredComment.appendLine(currCmtLine + "no parameter comment found"); + if (currCmtLine.includes('@param')) { + tmpDesiredComment.appendLine(currCmtLine + 'no parameter comment found'); lineCount++; // count this line, too } } tmpDesiredComment.closeAsSingleLineBlock(lineNbr + lineCount - 1); if (lineCount > 1) { desiredComment = tmpDesiredComment; // only return this if we have params! - this._logSPIN("=> SPIN: generated signature comment: sig=[" + line + "]"); + this._logSPIN('=> SPIN: generated signature comment: sig=[' + line + ']'); } else { - this._logSPIN("=> SPIN: SKIPped generation of signature comment: sig=[" + line + "]"); + this._logSPIN('=> SPIN: SKIPped generation of signature comment: sig=[' + line + ']'); } } } @@ -3012,17 +3307,17 @@ export class Spin1DocumentSemanticParser { } private _generateDocCommentForSignature(signatureLine: string, isSpin1Method: boolean): string[] { - let desiredDocComment: string[] = []; + const desiredDocComment: string[] = []; this._logMessage(`* iDc SKIP - generateDocCommentForSignature([${signatureLine}], isSpin1=${isSpin1Method})`); - const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ""; - const isSignature: boolean = linePrefix.startsWith("pub") || linePrefix.startsWith("pri"); - const isPRI: boolean = linePrefix.startsWith("pri"); + const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ''; + const isSignature: boolean = linePrefix.startsWith('pub') || linePrefix.startsWith('pri'); + const isPRI: boolean = linePrefix.startsWith('pri'); if (isSignature) { const commentPrefix = isPRI ? "'" : "''"; - desiredDocComment.push(commentPrefix + " ..."); // for description - desiredDocComment.push(commentPrefix + " "); // blank line - const posOpenParen = signatureLine.indexOf("("); - const posCloseParen = signatureLine.indexOf(")"); + desiredDocComment.push(commentPrefix + ' ...'); // for description + desiredDocComment.push(commentPrefix + ' '); // blank line + const posOpenParen = signatureLine.indexOf('('); + const posCloseParen = signatureLine.indexOf(')'); // if we have name() it's spin1 or spin2 if (posOpenParen != -1 && posCloseParen != -1) { const bHasParameters: boolean = posCloseParen - posOpenParen > 1 ? true : false; @@ -3035,11 +3330,11 @@ export class Spin1DocumentSemanticParser { desiredDocComment.push(commentPrefix + ` @param ${paramNames[paramIdx]} - `); // blank line } } - const bHasReturnValues: boolean = signatureLine.includes(":") ? true : false; - const bHasLocalVariables: boolean = signatureLine.includes("|") ? true : false; + const bHasReturnValues: boolean = signatureLine.includes(':') ? true : false; + const bHasLocalVariables: boolean = signatureLine.includes('|') ? true : false; if (bHasReturnValues) { - const posStartReturn = signatureLine.indexOf(":") + 1; - const posEndReturn = bHasLocalVariables ? signatureLine.indexOf("|") - 1 : signatureLine.length; + const posStartReturn = signatureLine.indexOf(':') + 1; + const posEndReturn = bHasLocalVariables ? signatureLine.indexOf('|') - 1 : signatureLine.length; const returnsString: string = signatureLine.substring(posStartReturn, posEndReturn); const numberReturns: number = (returnsString.match(/,/g) || []).length + 1; const returnNames = returnsString.split(/[ \t,]/).filter(Boolean); @@ -3050,17 +3345,17 @@ export class Spin1DocumentSemanticParser { } let posTrailingComment = signatureLine.indexOf("'"); if (posTrailingComment == -1) { - posTrailingComment = signatureLine.indexOf("{"); + posTrailingComment = signatureLine.indexOf('{'); } if (bHasLocalVariables) { // locals are always non-doc single-line comments - const posStartLocal = signatureLine.indexOf("|") + 1; + const posStartLocal = signatureLine.indexOf('|') + 1; const posEndLocal = posTrailingComment != -1 ? posTrailingComment : signatureLine.length; const localsString: string = signatureLine.substring(posStartLocal, posEndLocal); const numberLocals: number = (localsString.match(/,/g) || []).length + 1; const localsNames = localsString.split(/[ \t,]/).filter(Boolean); this._logMessage(`* gDClocalsString=[${localsString}], localsNames=[${localsNames}]`); - desiredDocComment.push(""); // empty line so following is not shown in comments for method + desiredDocComment.push(''); // empty line so following is not shown in comments for method desiredDocComment.push("' Local Variables:"); // blank line for (let localIdx = 0; localIdx < numberLocals; localIdx++) { desiredDocComment.push("'" + ` @local ${localsNames[localIdx]} - `); // blank line @@ -3068,11 +3363,11 @@ export class Spin1DocumentSemanticParser { } } else if (isSpin1Method) { // spin1 methods don't need parens when no parameters are specified - const bHasReturnValues: boolean = signatureLine.includes(":") ? true : false; - const bHasLocalVariables: boolean = signatureLine.includes("|") ? true : false; + const bHasReturnValues: boolean = signatureLine.includes(':') ? true : false; + const bHasLocalVariables: boolean = signatureLine.includes('|') ? true : false; if (bHasReturnValues) { - const posStartReturn = signatureLine.indexOf(":") + 1; - const posEndReturn = bHasLocalVariables ? signatureLine.indexOf("|") - 1 : signatureLine.length; + const posStartReturn = signatureLine.indexOf(':') + 1; + const posEndReturn = bHasLocalVariables ? signatureLine.indexOf('|') - 1 : signatureLine.length; const returnsString: string = signatureLine.substring(posStartReturn, posEndReturn); // spin1 only allows 1 return variable const returnNames = returnsString.split(/[ \t,]/).filter(Boolean); @@ -3081,17 +3376,17 @@ export class Spin1DocumentSemanticParser { } let posTrailingComment = signatureLine.indexOf("'"); if (posTrailingComment == -1) { - posTrailingComment = signatureLine.indexOf("{"); + posTrailingComment = signatureLine.indexOf('{'); } if (bHasLocalVariables) { // locals are always non-doc single-line comments - const posStartLocal = signatureLine.indexOf("|") + 1; + const posStartLocal = signatureLine.indexOf('|') + 1; const posEndLocal = posTrailingComment != -1 ? posTrailingComment : signatureLine.length; const localsString: string = signatureLine.substring(posStartLocal, posEndLocal); const numberLocals: number = (localsString.match(/,/g) || []).length + 1; const localsNames = localsString.split(/[ \t,]/).filter(Boolean); this._logMessage(`* gDClocalsString=[${localsString}], localsNames=[${localsNames}]`); - desiredDocComment.push(""); // empty line so following is not shown in comments for method + desiredDocComment.push(''); // empty line so following is not shown in comments for method desiredDocComment.push("' Local Variables:"); // blank line for (let localIdx = 0; localIdx < numberLocals; localIdx++) { desiredDocComment.push("'" + ` @local ${localsNames[localIdx]} - `); // blank line @@ -3103,34 +3398,34 @@ export class Spin1DocumentSemanticParser { } private _getSingleQuotedString(currentOffset: number, searchText: string): string { - let nextString: string = ""; + let nextString: string = ''; const stringStartOffset: number = searchText.indexOf("'", currentOffset); if (stringStartOffset != -1) { - this._logDEBUG(" -- _getSingleQuotedString(" + currentOffset + ", [" + searchText + "])"); + this._logDEBUG(' -- _getSingleQuotedString(' + currentOffset + ', [' + searchText + '])'); const stringEndOffset: number = searchText.indexOf("'", stringStartOffset + 1); if (stringEndOffset != -1) { nextString = searchText.substring(stringStartOffset, stringEndOffset + 1); } } if (nextString.length > 0) { - this._logDEBUG(" -- gsqs nextString=[" + nextString + "](" + nextString.length + ")"); + this._logDEBUG(' -- gsqs nextString=[' + nextString + '](' + nextString.length + ')'); } return nextString; } private _getDoubleQuotedString(currentOffset: number, searchText: string): string { - let nextString: string = ""; + let nextString: string = ''; const chrDoubleQuote: string = '"'; const stringStartOffset: number = searchText.indexOf(chrDoubleQuote, currentOffset); if (stringStartOffset != -1) { - this._logDEBUG(" -- _getDoubleQuotedString(" + currentOffset + ", [" + searchText + "])"); + this._logDEBUG(' -- _getDoubleQuotedString(' + currentOffset + ', [' + searchText + '])'); const stringEndOffset: number = searchText.indexOf(chrDoubleQuote, stringStartOffset + 1); if (stringEndOffset != -1) { nextString = searchText.substring(stringStartOffset, stringEndOffset + 1); } } if (nextString.length > 0) { - this._logDEBUG(" -- gdqs nextString=[" + nextString + "](" + nextString.length + ")"); + this._logDEBUG(' -- gdqs nextString=[' + nextString + '](' + nextString.length + ')'); } return nextString; } @@ -3205,19 +3500,19 @@ export class Spin1DocumentSemanticParser { private _getNonWhiteSpinLineParts(line: string): IFilteredStrings { // split(/[ \t\-\:\,\+\[\]\@\(\)\!\*\=\<\>\&\|\?\\\~\#\^\/]/); const nonEqualsLine: string = this.parseUtils.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\-\:\,\+\[\]\@\(\)\!\*\=\<\>\&\|\?\\\~\^\/\}]+/g); + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\-:,+[\]@()!*=<>&|?\\~^/}]+/g); let reducedLineParts: string[] = []; if (lineParts == null) { reducedLineParts = []; } else { for (let index = 0; index < lineParts.length; index++) { const name = lineParts[index]; - if (name === "#") { + if (name === '#') { continue; } - if (name.startsWith("#")) { + if (name.startsWith('#')) { reducedLineParts.push(name.substring(1)); // remvoe first char - } else if (name.endsWith("#")) { + } else if (name.endsWith('#')) { reducedLineParts.push(name.slice(0, -1)); // remove last char } else { reducedLineParts.push(name); @@ -3226,13 +3521,13 @@ export class Spin1DocumentSemanticParser { } return { lineNoQuotes: nonEqualsLine, - lineParts: reducedLineParts, + lineParts: reducedLineParts }; } private _getNonCommentLineReturnComment(startingOffset: number, lineIdx: number, line: string, tokenSet: IParsedToken[]): string { // skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); this._logMessage(` -- Ln#${lineIdx + 1} gNCL-RC startingOffset=(${startingOffset}), line=[${line}](${line.length})`); const nonCommentStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); // now record the comment if we have one @@ -3242,11 +3537,21 @@ export class Spin1DocumentSemanticParser { this._logMessage(` -- gNCL-RC filtLine=[${filtLine}](${filtLine.length})`); const commentRHSStrOffset: number = nonCommentStr.length; const commentOffset: number = this.parseUtils.getTrailingCommentOffset(commentRHSStrOffset, line); - const bHaveBlockComment: boolean = filtLine.indexOf("{", commentOffset) != -1 || filtLine.indexOf("}", commentOffset) != -1; - const bHaveDocComment: boolean = filtLine.indexOf("''", commentOffset) != -1 || filtLine.indexOf("{{", commentOffset) != -1 || filtLine.indexOf("}}", commentOffset) != -1; - this._logMessage(` -- gNCL-RC commentOffset=(${commentOffset}), bHvBlockComment=(${bHaveBlockComment}), bHvDocComment=(${bHaveDocComment}), filtLine=[${filtLine}](${filtLine.length})`); + const bHaveBlockComment: boolean = filtLine.indexOf('{', commentOffset) != -1 || filtLine.indexOf('}', commentOffset) != -1; + const bHaveDocComment: boolean = + filtLine.indexOf("''", commentOffset) != -1 || filtLine.indexOf('{{', commentOffset) != -1 || filtLine.indexOf('}}', commentOffset) != -1; + this._logMessage( + ` -- gNCL-RC commentOffset=(${commentOffset}), bHvBlockComment=(${bHaveBlockComment}), bHvDocComment=(${bHaveDocComment}), filtLine=[${filtLine}](${filtLine.length})` + ); if (commentOffset != -1) { - const newToken: IParsedToken | undefined = this._generateComentToken(lineIdx, commentOffset, line.length - commentOffset + 1, bHaveBlockComment, bHaveDocComment, line); + const newToken: IParsedToken | undefined = this._generateComentToken( + lineIdx, + commentOffset, + line.length - commentOffset + 1, + bHaveBlockComment, + bHaveDocComment, + line + ); if (newToken) { //this._logMessage("=> CMT: " + this._tokenString(newToken, line)); tokenSet.push(newToken); @@ -3259,48 +3564,71 @@ export class Spin1DocumentSemanticParser { return nonCommentStr; } - private _generateComentToken(lineIdx: number, startIdx: number, commentLength: number, bHaveBlockComment: boolean, bHaveDocComment: boolean, line: string): IParsedToken | undefined { + private _generateComentToken( + lineIdx: number, + startIdx: number, + commentLength: number, + bHaveBlockComment: boolean, + bHaveDocComment: boolean, + line: string + ): IParsedToken | undefined { //this._logMessage(" -- gNCL-RC commentOffset=(" + commentOffset + "), bHaveDocComment=[" + bHaveDocComment + "], line=[" + line + "]"); let desiredToken: IParsedToken | undefined = undefined; if (line.length > 0) { //const commentDocModifiers: string[] = bHaveBlockComment ? ["block", "documentation"] : ["line", "documentation"]; // A NO - const commentDocModifiers: string[] = bHaveBlockComment ? ["documentation", "block"] : ["documentation", "line"]; // B NO - const commentModifiers: string[] = bHaveBlockComment ? ["block"] : ["line"]; + const commentDocModifiers: string[] = bHaveBlockComment ? ['documentation', 'block'] : ['documentation', 'line']; // B NO + const commentModifiers: string[] = bHaveBlockComment ? ['block'] : ['line']; desiredToken = { line: lineIdx, startCharacter: startIdx, length: commentLength, - ptTokenType: "comment", - ptTokenModifiers: bHaveDocComment ? commentDocModifiers : commentModifiers, + ptTokenType: 'comment', + ptTokenModifiers: bHaveDocComment ? commentDocModifiers : commentModifiers }; const comment: string = line.substring(startIdx, startIdx + commentLength); - this._logMessage(` -- Ln#${lineIdx + 1} genCT Recorded Comment [${comment}](${comment.length}) (${desiredToken.ptTokenType}[${desiredToken.ptTokenModifiers}])`); + this._logMessage( + ` -- Ln#${lineIdx + 1} genCT Recorded Comment [${comment}](${comment.length}) (${desiredToken.ptTokenType}[${ + desiredToken.ptTokenModifiers + }])` + ); } return desiredToken; } private _tokenString(aToken: IParsedToken, line: string): string { - let varName: string = line.substr(aToken.startCharacter, aToken.length); - let desiredInterp: string = - " -- token=[Ln#" + (aToken.line + 1) + ",ofs:" + aToken.startCharacter + ",len:" + aToken.length + " [" + varName + "](" + aToken.ptTokenType + "[" + aToken.ptTokenModifiers + "])]"; + const varName: string = line.substr(aToken.startCharacter, aToken.length); + const desiredInterp: string = + ' -- token=[Ln#' + + (aToken.line + 1) + + ',ofs:' + + aToken.startCharacter + + ',len:' + + aToken.length + + ' [' + + varName + + '](' + + aToken.ptTokenType + + '[' + + aToken.ptTokenModifiers + + '])]'; return desiredInterp; } private _rememberdTokenString(tokenName: string, aToken: RememberedToken | undefined): string { - let desiredInterp: string = " -- token=[len:" + tokenName.length + " [" + tokenName + "](undefined)"; + let desiredInterp: string = ' -- token=[len:' + tokenName.length + ' [' + tokenName + '](undefined)'; if (aToken != undefined) { - desiredInterp = " -- token=[len:" + tokenName.length + " [" + tokenName + "](" + aToken.type + "[" + aToken.modifiers + "])]"; + desiredInterp = ' -- token=[len:' + tokenName.length + ' [' + tokenName + '](' + aToken.type + '[' + aToken.modifiers + '])]'; } return desiredInterp; } private _checkTokenSet(tokenSet: IParsedToken[]): void { - this._logMessage("\n---- Checking " + tokenSet.length + " tokens. ----"); + this._logMessage('\n---- Checking ' + tokenSet.length + ' tokens. ----'); tokenSet.forEach((parsedToken) => { if (parsedToken.length == undefined || parsedToken.startCharacter == undefined) { - this._logMessage("- BAD Token=[" + parsedToken + "]"); + this._logMessage('- BAD Token=[' + parsedToken + ']'); } }); - this._logMessage("---- Check DONE ----\n"); + this._logMessage('---- Check DONE ----\n'); } } diff --git a/spin2/server/src/parser/spin1.documentSymbolParser.ts b/spin2/server/src/parser/spin1.documentSymbolParser.ts index a145ce8..50640de 100644 --- a/spin2/server/src/parser/spin1.documentSymbolParser.ts +++ b/spin2/server/src/parser/spin1.documentSymbolParser.ts @@ -1,13 +1,13 @@ -"use strict"; +'use strict'; // src/parser/spin1.documentSymbolParser.ts -import * as lsp from "vscode-languageserver"; -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Spin1ParseUtils } from "./spin1.utils"; -import { OutLineSymbol, DocumentFindings } from "./spin.semantic.findings"; -import { Context } from "../context"; -import { eParseState } from "./spin.common"; -import { ExtensionUtils } from "../parser/spin.extension.utils"; +import * as lsp from 'vscode-languageserver'; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Spin1ParseUtils } from './spin1.utils'; +import { OutLineSymbol, DocumentFindings } from './spin.semantic.findings'; +import { Context } from '../context'; +import { eParseState } from './spin.common'; +import { ExtensionUtils } from '../parser/spin.extension.utils'; // ---------------------------------------------------------------------------- // OUTLINE Provider @@ -30,9 +30,9 @@ export class Spin1DocumentSymbolParser { if (this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin1 Outline log started."); + this._logMessage('Spin1 Outline log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -47,10 +47,16 @@ export class Spin1DocumentSymbolParser { } for (let i = 0; i < document.lineCount; i++) { - const desiredLineRange: lsp.Range = { start: { line: i, character: 0 }, end: { line: i, character: Number.MAX_VALUE } }; + const desiredLineRange: lsp.Range = { + start: { line: i, character: 0 }, + end: { line: i, character: Number.MAX_VALUE } + }; //let line = document.lineAt(i); - const line = document.getText(desiredLineRange).replace(/\s+$/, ""); - const lineRange: lsp.Range = { start: { line: i, character: 0 }, end: { line: i, character: line.length - 1 } }; + const line = document.getText(desiredLineRange).replace(/\s+$/, ''); + const lineRange: lsp.Range = { + start: { line: i, character: 0 }, + end: { line: i, character: line.length - 1 } + }; const trimmedLine = line.trim(); let nonCommentLine = this.parseUtils.getRemainderWOutTrailingTicComment(0, line); if (nonCommentLine.length == 0) { @@ -75,9 +81,9 @@ export class Spin1DocumentSymbolParser { // skip all {{ --- }} multi-line doc comments if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - const openingOffset = nonCommentLine.indexOf("{{"); + const openingOffset = nonCommentLine.indexOf('{{'); const searchOffset: number = openingOffset != -1 ? openingOffset + 2 : 0; - const closingOffset = nonCommentLine.indexOf("}}", searchOffset); + const closingOffset = nonCommentLine.indexOf('}}', searchOffset); const haveInlineCmt: boolean = openingOffset != -1 && closingOffset != -1 && openingOffset < closingOffset; if (!haveInlineCmt && closingOffset != -1) { // have close, comment ended @@ -87,15 +93,15 @@ export class Spin1DocumentSymbolParser { continue; } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit - const openingOffset = nonCommentLine.indexOf("{"); - const closingOffset = nonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = nonCommentLine.indexOf('{'); + const closingOffset = nonCommentLine.indexOf('}', openingOffset + 1); const haveInlineCmt: boolean = openingOffset != -1 && closingOffset != -1 && openingOffset < closingOffset; if (!haveInlineCmt && closingOffset != -1) { // have close, comment ended currState = priorState; } // no more processing for this line - const cmtState: string = currState != eParseState.inMultiLineComment ? "LAST " : ""; + const cmtState: string = currState != eParseState.inMultiLineComment ? 'LAST ' : ''; this._logMessage(`* SKIP ${cmtState}BlockCmt Ln#${i + 1} nonCommentLine=[${nonCommentLine}]`); continue; } else if (nonCommentLine.startsWith("''")) { @@ -104,11 +110,11 @@ export class Spin1DocumentSymbolParser { } else if (nonCommentLine.startsWith("'")) { // no more processing for this line continue; - } else if (nonCommentLine.trim().startsWith("{{")) { + } else if (nonCommentLine.trim().startsWith('{{')) { // process multi-line doc comment - const openingOffset = nonCommentLine.indexOf("{{"); + const openingOffset = nonCommentLine.indexOf('{{'); const searchOffset: number = openingOffset != -1 ? openingOffset + 2 : 0; - const closingOffset = nonCommentLine.indexOf("}}", searchOffset); + const closingOffset = nonCommentLine.indexOf('}}', searchOffset); if (closingOffset != -1) { // is single line comment, just ignore it } else { @@ -118,11 +124,11 @@ export class Spin1DocumentSymbolParser { // no more processing for this line } continue; - } else if (nonCommentLine.trim().startsWith("{")) { + } else if (nonCommentLine.trim().startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - const openingOffset = nonCommentLine.indexOf("{"); - const closingOffset = nonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = nonCommentLine.indexOf('{'); + const closingOffset = nonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment priorState = currState; @@ -138,15 +144,15 @@ export class Spin1DocumentSymbolParser { } if (line.length > 2) { - const lineParts: string[] = linePrefix.split(/[ \t\{\']/).filter(Boolean); - linePrefix = lineParts.length > 0 ? lineParts[0].toUpperCase() : ""; + const lineParts: string[] = linePrefix.split(/[ \t{']/).filter(Boolean); + linePrefix = lineParts.length > 0 ? lineParts[0].toUpperCase() : ''; // the only form of comment we care about here is block comment after section name (e.g., "CON { text }") // NEW and let's add the use of ' comment too - const openBraceOffset: number = line.indexOf("{"); + const openBraceOffset: number = line.indexOf('{'); const singleQuoteOffset: number = line.indexOf("'"); if (openBraceOffset != -1) { commentOffset = openBraceOffset; - const closeBraceOffset: number = line.indexOf("}", openBraceOffset + 1); + const closeBraceOffset: number = line.indexOf('}', openBraceOffset + 1); if (closeBraceOffset != -1) { lineHasComment = true; commentLength = closeBraceOffset - openBraceOffset + 1; @@ -159,20 +165,20 @@ export class Spin1DocumentSymbolParser { } if (sectionStatus.isSectionStart) { - if (linePrefix == "CON" || linePrefix == "DAT" || linePrefix == "VAR" || linePrefix == "OBJ") { + if (linePrefix == 'CON' || linePrefix == 'DAT' || linePrefix == 'VAR' || linePrefix == 'OBJ') { // start CON/VAR/OBJ/DAT - let sectionComment = lineHasComment ? line.substr(commentOffset, commentLength) : ""; - const blockSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + " " + sectionComment, "", lsp.SymbolKind.Field, lineRange); + const sectionComment = lineHasComment ? line.substr(commentOffset, commentLength) : ''; + const blockSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + ' ' + sectionComment, '', lsp.SymbolKind.Field, lineRange); this.setContainerSymbol(blockSymbol); // HANDLE label declaration on DAT line! - if (linePrefix == "DAT") { + if (linePrefix == 'DAT') { const lineParts: string[] = nonCommentLine.split(/[ \t]/).filter(Boolean); let posssibleLabel: string | undefined = undefined; if (lineParts.length >= 2) { // possibly have label, report it if we do posssibleLabel = lineParts[1]; if ( - posssibleLabel.toUpperCase().startsWith("ORG") || + posssibleLabel.toUpperCase().startsWith('ORG') || this.parseUtils.isP1AsmEffect(posssibleLabel) || this.parseUtils.isP1AsmInstruction(posssibleLabel) || this.parseUtils.isP1AsmReservedSymbols(posssibleLabel) @@ -182,38 +188,38 @@ export class Spin1DocumentSymbolParser { posssibleLabel = undefined; // Nope! } if (posssibleLabel) { - const labelSymbol: OutLineSymbol = new OutLineSymbol(lineParts[1], "", lsp.SymbolKind.Constant, lineRange); + const labelSymbol: OutLineSymbol = new OutLineSymbol(lineParts[1], '', lsp.SymbolKind.Constant, lineRange); if (this.containerDocSymbol) { this.containerDocSymbol.addChild(labelSymbol); } } } } - } else if (linePrefix == "PUB" || linePrefix == "PRI") { + } else if (linePrefix == 'PUB' || linePrefix == 'PRI') { // start PUB/PRI - let methodScope: string = "Public"; - if (line.startsWith("PRI")) { - methodScope = "Private"; - } + //let methodScope: string = 'Public'; + //if (line.startsWith('PRI')) { + // methodScope = 'Private'; + //} let methodName: string = line.substr(3).trim(); if (methodName.includes("'")) { // remove tic-single-line-comment const lineParts: string[] = methodName.split("'"); methodName = lineParts[0].trim(); } - if (methodName.includes("{")) { + if (methodName.includes('{')) { // remove brace-wrapped-comment - const lineParts: string[] = methodName.split("{"); + const lineParts: string[] = methodName.split('{'); methodName = lineParts[0].trim(); } - if (methodName.includes("|")) { + if (methodName.includes('|')) { // remove local vars - const lineParts: string[] = methodName.split("|"); + const lineParts: string[] = methodName.split('|'); methodName = lineParts[0].trim(); } // NOTE this changed to METHOD when we added global labels which are to be Functions! - const methodSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + " " + methodName, "", lsp.SymbolKind.Method, lineRange); + const methodSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + ' ' + methodName, '', lsp.SymbolKind.Method, lineRange); this.setContainerSymbol(methodSymbol); } } else { @@ -228,15 +234,15 @@ export class Spin1DocumentSymbolParser { global_label = this._getDAT_PasmDeclaration(0, line); // let's get possible label on this ORG statement } } else if (currState == eParseState.inDat) { - this._logMessage(" scan inDat Ln#" + (i + 1) + " nonCommentLine=[" + nonCommentLine + "]"); - if (nonCommentLine.length > 6 && nonCommentLine.toUpperCase().includes("ORG")) { + this._logMessage(' scan inDat Ln#' + (i + 1) + ' nonCommentLine=[' + nonCommentLine + ']'); + if (nonCommentLine.length > 6 && nonCommentLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(nonCommentLine); - if (nonStringLine.toUpperCase().includes("ORG")) { - this._logMessage(" - pre-scan DAT line trimmedLine=[" + trimmedLine + "] now Dat PASM"); + if (nonStringLine.toUpperCase().includes('ORG')) { + this._logMessage(' - pre-scan DAT line trimmedLine=[' + trimmedLine + '] now Dat PASM'); prePasmState = currState; currState = eParseState.inDatPAsm; - this._logMessage(" scan START DATPasm Ln#" + (i + 1) + " PUSH currState=[" + prePasmState + "]"); + this._logMessage(' scan START DATPasm Ln#' + (i + 1) + ' PUSH currState=[' + prePasmState + ']'); // and ignore rest of this line global_label = this._getDAT_PasmDeclaration(0, line); // let's get possible label on this ORG statement } @@ -247,7 +253,7 @@ export class Spin1DocumentSymbolParser { if (global_label) { // was Variable: sorta OK (image good, color bad) // was Constant: sorta OK (image good, color bad) SAME - const labelSymbol: OutLineSymbol = new OutLineSymbol(global_label, "", lsp.SymbolKind.Constant, lineRange); + const labelSymbol: OutLineSymbol = new OutLineSymbol(global_label, '', lsp.SymbolKind.Constant, lineRange); if (this.containerDocSymbol) { this.containerDocSymbol.addChild(labelSymbol); } else { @@ -285,39 +291,40 @@ export class Spin1DocumentSymbolParser { // didShow byte FALSE[256] // byte FALSE[256] let newGlobalLabel: string | undefined = undefined; - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const dataDeclNonCommentStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); - let lineParts: string[] = this.parseUtils.getNonWhiteNParenLineParts(dataDeclNonCommentStr); + const lineParts: string[] = this.parseUtils.getNonWhiteNParenLineParts(dataDeclNonCommentStr); this._logMessage(`- Oln GetDatDecl lineParts=[${lineParts}](${lineParts.length})`); - let haveMoreThanDat: boolean = lineParts.length > 1 && lineParts[0].toUpperCase() == "DAT"; - if (haveMoreThanDat || (lineParts.length > 0 && lineParts[0].toUpperCase() != "DAT")) { + const haveMoreThanDat: boolean = lineParts.length > 1 && lineParts[0].toUpperCase() == 'DAT'; + if (haveMoreThanDat || (lineParts.length > 0 && lineParts[0].toUpperCase() != 'DAT')) { // remember this object name so we can annotate a call to it let nameIndex: number = 0; let typeIndex: number = 1; let maxParts: number = 2; - if (lineParts[0].toUpperCase() == "DAT") { + if (lineParts[0].toUpperCase() == 'DAT') { nameIndex = 1; typeIndex = 2; maxParts = 3; } - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[nameIndex]); - const isDataDeclarationLine: boolean = lineParts.length > maxParts - 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[typeIndex]) ? true : false; - let lblFlag: string = haveLabel ? "T" : "F"; - let dataDeclFlag: string = isDataDeclarationLine ? "T" : "F"; - this._logMessage("- Oln GetDatDecl lineParts=[" + lineParts + "](" + lineParts.length + ") label=" + lblFlag + ", daDecl=" + dataDeclFlag); + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[nameIndex]); + const isDataDeclarationLine: boolean = + lineParts.length > maxParts - 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[typeIndex]) ? true : false; + const lblFlag: string = haveLabel ? 'T' : 'F'; + const dataDeclFlag: string = isDataDeclarationLine ? 'T' : 'F'; + this._logMessage('- Oln GetDatDecl lineParts=[' + lineParts + '](' + lineParts.length + ') label=' + lblFlag + ', daDecl=' + dataDeclFlag); if (haveLabel) { - let newName = lineParts[nameIndex]; + const newName = lineParts[nameIndex]; if ( - !newName.toLowerCase().startsWith("debug") && + !newName.toLowerCase().startsWith('debug') && !this.parseUtils.isP1AsmReservedWord(newName) && !this.parseUtils.isSpinReservedWord(newName) && !this.parseUtils.isSpinBuiltInVariable(newName) && !this.parseUtils.isBuiltinReservedWord(newName) ) { - if (!isDataDeclarationLine && !newName.startsWith(".") && !newName.startsWith(":") && !newName.includes("#")) { + if (!isDataDeclarationLine && !newName.startsWith('.') && !newName.startsWith(':') && !newName.includes('#')) { newGlobalLabel = newName; - this._logMessage(" -- Oln GLBL gddcl newName=[" + newGlobalLabel + "]"); + this._logMessage(' -- Oln GLBL gddcl newName=[' + newGlobalLabel + ']'); } } } @@ -329,26 +336,26 @@ export class Spin1DocumentSymbolParser { // HAVE bGammaEnable BYTE TRUE ' comment // didShow byte FALSE[256] let newGlobalLabel: string | undefined = undefined; - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const datPasmRHSStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (datPasmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhiteNParenLineParts(datPasmRHSStr); - this._logMessage("- Oln GetPasmDatDecl lineParts=[" + lineParts + "](" + lineParts.length + ")"); + this._logMessage('- Oln GetPasmDatDecl lineParts=[' + lineParts + '](' + lineParts.length + ')'); // handle name in 1 column - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); const isDataDeclarationLine: boolean = lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1]) ? true : false; - if (haveLabel && !isDataDeclarationLine && !lineParts[0].startsWith(".") && !lineParts[0].startsWith(":") && !lineParts[0].includes("#")) { + if (haveLabel && !isDataDeclarationLine && !lineParts[0].startsWith('.') && !lineParts[0].startsWith(':') && !lineParts[0].includes('#')) { const labelName: string = lineParts[0]; if ( !this.parseUtils.isP1AsmReservedSymbols(labelName) && - !labelName.toUpperCase().startsWith("IF_") && - !labelName.toUpperCase().startsWith("_RET_") && - !labelName.toUpperCase().startsWith("DEBUG") + !labelName.toUpperCase().startsWith('IF_') && + !labelName.toUpperCase().startsWith('_RET_') && + !labelName.toUpperCase().startsWith('DEBUG') ) { // org in first column is not label name, nor is if_ conditional newGlobalLabel = labelName; - this._logMessage(" -- DAT Oln PASM GLBL newGlobalLabel=[" + newGlobalLabel + "]"); + this._logMessage(' -- DAT Oln PASM GLBL newGlobalLabel=[' + newGlobalLabel + ']'); } } } diff --git a/spin2/server/src/parser/spin1.utils.ts b/spin2/server/src/parser/spin1.utils.ts index 4729785..27fe98e 100644 --- a/spin2/server/src/parser/spin1.utils.ts +++ b/spin2/server/src/parser/spin1.utils.ts @@ -1,8 +1,8 @@ -"use strict"; +'use strict'; // src/spin1.utils.ts -import { eBuiltInType, eDebugDisplayType, IBuiltinDescription } from "./spin.common"; -import { Context } from "../context"; +import { eBuiltInType, eDebugDisplayType, IBuiltinDescription } from './spin.common'; +import { Context } from '../context'; // this is how we decribe our methods with parameters in our tables... type TMethodTuple = readonly [signature: string, description: string, parameters: string[], returns?: string[] | undefined]; @@ -29,24 +29,24 @@ export class Spin1ParseUtils { // NEW remove {comment} and {{comment}} single-line elements too let nonInlineCommentStr: string = line; // TODO: UNDONE make this into loop to find all single line {} or {{}} comments - const startDoubleBraceOffset: number = nonInlineCommentStr.indexOf("{{"); + const startDoubleBraceOffset: number = nonInlineCommentStr.indexOf('{{'); if (startDoubleBraceOffset != -1) { - const endDoubleBraceOffset: number = nonInlineCommentStr.indexOf("}}", startDoubleBraceOffset + 2); + const endDoubleBraceOffset: number = nonInlineCommentStr.indexOf('}}', startDoubleBraceOffset + 2); if (endDoubleBraceOffset != -1) { // remove this comment const badElement = nonInlineCommentStr.substr(startDoubleBraceOffset, endDoubleBraceOffset - startDoubleBraceOffset + 1); //this._logMessage(' -- badElement=[' + badElement + ']'); - nonInlineCommentStr = nonInlineCommentStr.replace(badElement, " ".repeat(badElement.length)); + nonInlineCommentStr = nonInlineCommentStr.replace(badElement, ' '.repeat(badElement.length)); } } - const startSingleBraceOffset: number = nonInlineCommentStr.indexOf("{"); + const startSingleBraceOffset: number = nonInlineCommentStr.indexOf('{'); if (startSingleBraceOffset != -1) { - const endSingleBraceOffset: number = nonInlineCommentStr.indexOf("}", startSingleBraceOffset + 1); + const endSingleBraceOffset: number = nonInlineCommentStr.indexOf('}', startSingleBraceOffset + 1); if (endSingleBraceOffset != -1) { // remove this comment const badElement = nonInlineCommentStr.substr(startSingleBraceOffset, endSingleBraceOffset - startSingleBraceOffset + 1); //this._logMessage(' -- badElement=[' + badElement + ']'); - nonInlineCommentStr = nonInlineCommentStr.replace(badElement, " ".repeat(badElement.length)); + nonInlineCommentStr = nonInlineCommentStr.replace(badElement, ' '.repeat(badElement.length)); } } //if (nonInlineCommentStr.length != line.length) { @@ -60,21 +60,21 @@ export class Spin1ParseUtils { // if we have {comment} in line remove it let cleanedLine: string = line; if (!line.trim().startsWith("'")) { - let didReplace: boolean = false; + //let didReplace: boolean = false; // if we have quoted string hide them for now... const startDoubleQuoteOffset: number = cleanedLine.indexOf('"'); - let checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; + const checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; // REPLACE {{...}} when found, all occurrences //do { - const doubleBraceBeginOffset: number = checkLine.indexOf("{{"); + const doubleBraceBeginOffset: number = checkLine.indexOf('{{'); if (doubleBraceBeginOffset != -1) { - const doubleBraceEndOffset: number = checkLine.indexOf("}}", doubleBraceBeginOffset); + const doubleBraceEndOffset: number = checkLine.indexOf('}}', doubleBraceBeginOffset); if (doubleBraceEndOffset != -1) { const inLineComment: string = cleanedLine.substring(doubleBraceBeginOffset, doubleBraceEndOffset + 2); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt {{cmt}} [${cleanedLine}]`); } } @@ -82,20 +82,20 @@ export class Spin1ParseUtils { // REPLACE {...} when found, all occurrences //do { - const singleBraceBeginOffset: number = checkLine.indexOf("{"); + const singleBraceBeginOffset: number = checkLine.indexOf('{'); if (singleBraceBeginOffset != -1) { - const singleBraceEndOffset: number = checkLine.indexOf("}", singleBraceBeginOffset); + const singleBraceEndOffset: number = checkLine.indexOf('}', singleBraceBeginOffset); if (singleBraceEndOffset != -1) { const inLineComment: string = cleanedLine.substring(singleBraceBeginOffset, singleBraceEndOffset + 1); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt {cmt} [${cleanedLine}]`); } } //} while (cleanedLine.indexOf("{") != -1); if (cleanedLine.trim().length == 0) { - cleanedLine = ""; - didReplace = true; + cleanedLine = ''; + //didReplace = true; } //if (didReplace) { @@ -111,12 +111,12 @@ export class Spin1ParseUtils { let cleanedLine: string = line; if (!line.trim().startsWith("'")) { - let didReplace: boolean = false; + //let didReplace: boolean = false; if (startingOffset > 0) { - const prefixToStart: string = " ".repeat(startingOffset); + const prefixToStart: string = ' '.repeat(startingOffset); cleanedLine = `${prefixToStart}${line.substring(startingOffset)}`; - didReplace = true; + //didReplace = true; } // REPLACE {{...}} when found @@ -136,12 +136,12 @@ export class Spin1ParseUtils { let cleanedLine: string = line; if (!line.trim().startsWith("'")) { - let didReplace: boolean = false; + //let didReplace: boolean = false; if (startingOffset > 0) { - const prefixToStart: string = " ".repeat(startingOffset); + const prefixToStart: string = ' '.repeat(startingOffset); cleanedLine = `${prefixToStart}${line.substring(startingOffset)}`; - didReplace = true; + //didReplace = true; } // REPLACE {{...}} when found @@ -150,25 +150,25 @@ export class Spin1ParseUtils { // if we have quoted string hide them for now... const startDoubleQuoteOffset: number = cleanedLine.indexOf('"'); - let checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; + const checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; // REPLACE ^...}} when NO {{ before it on start of line (unless there's an earlier ' comment) const tickOffset: number = checkLine.indexOf("'", startingOffset); - const doubleBraceEndOffset: number = checkLine.indexOf("}}", startingOffset); + const doubleBraceEndOffset: number = checkLine.indexOf('}}', startingOffset); let isInComment: boolean = doubleBraceEndOffset != -1 && tickOffset != -1 && tickOffset < doubleBraceEndOffset; if (doubleBraceEndOffset != -1 && !isInComment) { const inLineComment: string = cleanedLine.substring(0, doubleBraceEndOffset + 2); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt ^cmt}} [${cleanedLine}]`); } // REPLACE ^...} when NO { before it on start of line (unless there's an earlier ' comment) - const singleBraceEndOffset: number = checkLine.indexOf("}", startingOffset); + const singleBraceEndOffset: number = checkLine.indexOf('}', startingOffset); isInComment = singleBraceEndOffset != -1 && tickOffset != -1 && tickOffset < singleBraceEndOffset; if (singleBraceEndOffset != -1 && !isInComment) { const inLineComment: string = cleanedLine.substring(0, singleBraceEndOffset + 1); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt ^cmt} [${cleanedLine}]`); } @@ -183,10 +183,10 @@ export class Spin1ParseUtils { public getTrailingCommentOffset(startingOffset: number, line: string): number { let desiredOffset: number = -1; // ensure we have unique { and {{ offsets if possible - const doubleBraceOffset: number = line.indexOf("{{", startingOffset); - let singleBraceOffset: number = line.indexOf("{", startingOffset); + const doubleBraceOffset: number = line.indexOf('{{', startingOffset); + let singleBraceOffset: number = line.indexOf('{', startingOffset); if (doubleBraceOffset != -1 && doubleBraceOffset == singleBraceOffset) { - singleBraceOffset = line.indexOf("{", doubleBraceOffset + 2); + singleBraceOffset = line.indexOf('{', doubleBraceOffset + 2); } const singleTicOffset: number = line.indexOf("'", startingOffset); // now return the earliest of the offsets (or -1 if none found) @@ -216,7 +216,7 @@ export class Spin1ParseUtils { // find comment at end of line and remove there to end of line // ( where comment is ' or '' or unpaired {{ or { ) // return 0 len line if trim() removes all after removing/replacing comments - let lineWithoutTrailingCommentStr: string = ""; + let lineWithoutTrailingCommentStr: string = ''; // TODO: UNDONE make this into loop to find first ' not in string if (line.length - startingOffset > 0) { // get line parts - we only care about first one @@ -224,7 +224,7 @@ export class Spin1ParseUtils { let beginCommentOffset: number = lineWithoutTrailingCommentStr.indexOf("'"); if (beginCommentOffset != -1) { // have single quote, is it within quoted string? - let currentOffset: number = this.skipWhite(line, startingOffset); + const currentOffset: number = this.skipWhite(line, startingOffset); // if we have quited string hide them for now... const startDoubleQuoteOffset: number = line.indexOf('"', currentOffset); if (startDoubleQuoteOffset != -1) { @@ -242,7 +242,7 @@ export class Spin1ParseUtils { lineWithoutTrailingCommentStr = lineWithoutTrailingCommentStr.substring(0, nonCommentEOL).trimEnd(); //this._logMessage('- gnclr lineWithoutTrailingCommentStr=[' + startingOffset + ']'); if (lineWithoutTrailingCommentStr.trim().length == 0) { - lineWithoutTrailingCommentStr = ""; + lineWithoutTrailingCommentStr = ''; //this._logMessage(` -- gRWoTTC line forced to EMPTY`); } //if (line.substr(startingOffset) !== lineWithoutTrailingCommentStr) { @@ -266,7 +266,7 @@ export class Spin1ParseUtils { // find comment at end of line and remove there to end of line // ( where comment is ' or '' or unpaired {{ or { ) // return 0 len line if trim() removes all after removing/replacing comments - let lineWithoutTrailingCommentStr: string = ""; + let lineWithoutTrailingCommentStr: string = ''; // TODO: UNDONE make this into loop to find first ' not in string if (line.length - startingOffset > 0) { // get line parts - we only care about first one @@ -274,7 +274,7 @@ export class Spin1ParseUtils { let beginCommentOffset: number = lineWithoutTrailingCommentStr.indexOf("'"); if (beginCommentOffset != -1) { // have single quote, is it within quoted string? - let currentOffset: number = this.skipWhite(line, startingOffset); + const currentOffset: number = this.skipWhite(line, startingOffset); // if we have quited string hide them for now... const startDoubleQuoteOffset: number = line.indexOf('"', currentOffset); if (startDoubleQuoteOffset != -1) { @@ -292,7 +292,7 @@ export class Spin1ParseUtils { lineWithoutTrailingCommentStr = lineWithoutTrailingCommentStr.substring(0, nonCommentEOL).trimEnd(); //this._logMessage('- gnclr lineWithoutTrailingCommentStr=[' + startingOffset + ']'); if (lineWithoutTrailingCommentStr.trim().length == 0) { - lineWithoutTrailingCommentStr = ""; + lineWithoutTrailingCommentStr = ''; //this._logMessage(` -- gNCLR line forced to EMPTY`); } //if (line.substr(startingOffset) !== lineWithoutTrailingCommentStr) { @@ -314,10 +314,10 @@ export class Spin1ParseUtils { for (let index = 0; index < line.length; index++) { const char = line.charAt(index); switch (char) { - case " ": + case ' ': insetCount++; break; - case "\t": + case '\t': insetCount += tabWidth - (insetCount % tabWidth); break; default: @@ -336,9 +336,9 @@ export class Spin1ParseUtils { let desiredCloseOffset: number = -1; let nestingDepth: number = 1; for (let offset = openParenOffset + 1; offset < line.length; offset++) { - if (line.substring(offset, offset + 1) == "(") { + if (line.substring(offset, offset + 1) == '(') { nestingDepth++; - } else if (line.substring(offset, offset + 1) == ")") { + } else if (line.substring(offset, offset + 1) == ')') { nestingDepth--; if (nestingDepth == 0) { // we closed the inital open @@ -362,16 +362,19 @@ export class Spin1ParseUtils { nonDocCommentRHSStr = line.substr(startingOffset, nonCommentEOL - startingOffset + 1).trim(); //this._logMessage('- gnclr nonCommentRHSStr=[' + startingOffset + ']'); - const singleLineMultiBeginOffset: number = nonDocCommentRHSStr.indexOf("{", startingOffset); + const singleLineMultiBeginOffset: number = nonDocCommentRHSStr.indexOf('{', startingOffset); if (singleLineMultiBeginOffset != -1) { - const singleLineMultiEndOffset: number = nonDocCommentRHSStr.indexOf("}", singleLineMultiBeginOffset); + const singleLineMultiEndOffset: number = nonDocCommentRHSStr.indexOf('}', singleLineMultiBeginOffset); if (singleLineMultiEndOffset != -1) { - const oneLineMultiComment: string = nonDocCommentRHSStr.substr(singleLineMultiBeginOffset, singleLineMultiEndOffset - singleLineMultiBeginOffset + 1); - nonDocCommentRHSStr = nonDocCommentRHSStr.replace(oneLineMultiComment, "").trim(); + const oneLineMultiComment: string = nonDocCommentRHSStr.substr( + singleLineMultiBeginOffset, + singleLineMultiEndOffset - singleLineMultiBeginOffset + 1 + ); + nonDocCommentRHSStr = nonDocCommentRHSStr.replace(oneLineMultiComment, '').trim(); } } } else if (line.length - startingOffset == 0) { - nonDocCommentRHSStr = ""; + nonDocCommentRHSStr = ''; } //if (line.substr(startingOffset).length != nonCommentRHSStr.length) { // this._logMessage(' -- NCLR line [' + line.substr(startingOffset) + ']'); @@ -382,8 +385,8 @@ export class Spin1ParseUtils { public getNonWhiteDataInitLineParts(line: string): string[] { const nonEqualsLine: string = this.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\,\[\]\(\)\+\-\/\<\>\|\&\*\^\@]+/g); - let filterParts: string[] = []; + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t,[\]()+\-/<>|&*^@]+/g); + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -398,8 +401,8 @@ export class Spin1ParseUtils { public getNonWhiteCONLineParts(line: string): string[] { const nonEqualsLine: string = this.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\(\)\|\*\+\-\/\>\<\=]+/g); - let filterParts: string[] = []; + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t()|*+\-/><=]+/g); + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -414,19 +417,19 @@ export class Spin1ParseUtils { public getNonWhitePAsmLineParts(line: string): string[] { const nonEqualsLine: string = this.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\,\(\)\[\]\<\>\=\?\!\^\+\*\&\|\-\\\@\/]+/g); + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t,()[\]<>=?!^+*&|\-\\@/]+/g); let reducedLineParts: string[] = []; if (lineParts == null) { reducedLineParts = []; } else { for (let index = 0; index < lineParts.length; index++) { const name = lineParts[index]; - if (name === "#") { + if (name === '#') { continue; } - if (name.startsWith("#")) { + if (name.startsWith('#')) { reducedLineParts.push(name.substring(1)); // remvoe first char - } else if (name.endsWith("#")) { + } else if (name.endsWith('#')) { reducedLineParts.push(name.slice(0, -1)); // remove last char } else { reducedLineParts.push(name); @@ -436,34 +439,35 @@ export class Spin1ParseUtils { return reducedLineParts; } - public removeDoubleQuotedStrings(line: string, showDebug: boolean = true): string { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public removeDoubleQuotedStrings(line: string, _showDebug: boolean = true): string { //this._logMessage("- RQS line [" + line + "]"); let trimmedLine: string = line; const doubleQuote: string = '"'; let quoteStartOffset: number = 0; // value doesn't matter - let didRemove: boolean = false; + //let didRemove: boolean = false; while ((quoteStartOffset = trimmedLine.indexOf(doubleQuote)) != -1) { const quoteEndOffset: number = trimmedLine.indexOf(doubleQuote, quoteStartOffset + 1); if (quoteEndOffset != -1) { const badElement = trimmedLine.substr(quoteStartOffset, quoteEndOffset - quoteStartOffset + 1); //this._logMessage(' -- badElement=[' + badElement + ']'); - trimmedLine = trimmedLine.replace(badElement, "#".repeat(badElement.length)); - didRemove = showDebug ? true : false; + trimmedLine = trimmedLine.replace(badElement, '#'.repeat(badElement.length)); + //didRemove = showDebug ? true : false; } else { break; // we don't handle a single double-quote } } // NEW also remove {text} strings - const braceStartChar: string = "{"; - const braceEndChar: string = "}"; + const braceStartChar: string = '{'; + const braceEndChar: string = '}'; let braceStartOffset: number = 0; // value doesn't matter while ((braceStartOffset = trimmedLine.indexOf(braceStartChar)) != -1) { const braceEndOffset: number = trimmedLine.indexOf(braceEndChar, braceStartOffset + 1); if (braceEndOffset != -1) { const badElement = trimmedLine.substr(braceStartOffset, braceEndOffset - braceStartOffset + 1); - trimmedLine = trimmedLine.replace(badElement, " ".repeat(badElement.length)); - didRemove = showDebug ? true : false; + trimmedLine = trimmedLine.replace(badElement, ' '.repeat(badElement.length)); + //didRemove = showDebug ? true : false; } else { break; // we don't handle a single brace (of multi-line) } @@ -479,7 +483,7 @@ export class Spin1ParseUtils { public getNonWhiteLineParts(line: string): string[] { const lineParts: string[] | null = line.match(/[^ \t]+/g); - let filterParts: string[] = []; + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -492,19 +496,19 @@ export class Spin1ParseUtils { } public getNonWhiteNParenLineParts(line: string): string[] { - let lineParts: string[] | null = line.match(/[^ \t\()]+/g); + const lineParts: string[] | null = line.match(/[^ \t()]+/g); return lineParts == null ? [] : lineParts; } public getCommaDelimitedNonWhiteLineParts(line: string): string[] { - let lineParts: string[] | null = line.match(/[^ \t,]+/g); + const lineParts: string[] | null = line.match(/[^ \t,]+/g); return lineParts == null ? [] : lineParts; } public skipWhite(line: string, currentOffset: number): number { let firstNonWhiteIndex: number = currentOffset; for (let index = currentOffset; index < line.length; index++) { - if (line.substr(index, 1) != " " && line.substr(index, 1) != "\t") { + if (line.substr(index, 1) != ' ' && line.substr(index, 1) != '\t') { firstNonWhiteIndex = index; break; } @@ -513,20 +517,26 @@ export class Spin1ParseUtils { } public docTextForBuiltIn(name: string): IBuiltinDescription { - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + let desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; desiredDocText = this._docTextForSpinBuiltInLanguagePart(name); if (desiredDocText.found) { - if (desiredDocText.category.includes("Method")) { + if (desiredDocText.category.includes('Method')) { desiredDocText.type = eBuiltInType.BIT_METHOD; - } else if (desiredDocText.category.includes("Variable")) { + } else if (desiredDocText.category.includes('Variable')) { desiredDocText.type = eBuiltInType.BIT_VARIABLE; - } else if (desiredDocText.category.includes("Constant")) { + } else if (desiredDocText.category.includes('Constant')) { desiredDocText.type = eBuiltInType.BIT_CONSTANT; - } else if (desiredDocText.category.includes("Float Conversions")) { + } else if (desiredDocText.category.includes('Float Conversions')) { desiredDocText.type = eBuiltInType.BIT_METHOD; - } else if (desiredDocText.category.includes("DAT Special")) { + } else if (desiredDocText.category.includes('DAT Special')) { desiredDocText.type = eBuiltInType.BIT_PASM_DIRECTIVE; // special for res/file - } else if (desiredDocText.category.includes("Directive")) { + } else if (desiredDocText.category.includes('Directive')) { desiredDocText.type = eBuiltInType.BIT_PASM_DIRECTIVE; // special for org/fit } else { desiredDocText.type = eBuiltInType.BIT_LANG_PART; @@ -540,59 +550,65 @@ export class Spin1ParseUtils { private _docTextForSpinBuiltInLanguagePart(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; - let methodDescr: TMethodTuple = ["", "", []]; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; + let methodDescr: TMethodTuple = ['', '', []]; let protoWDescr: string[] = []; if (nameKey in this._tableSpinBlockNames) { - desiredDocText.category = "Block Name"; + desiredDocText.category = 'Block Name'; desiredDocText.description = this._tableSpinBlockNames[nameKey]; } else if (nameKey in this._tableSpinFloatConversions) { - desiredDocText.category = "Float Conversions"; + desiredDocText.category = 'Float Conversions'; methodDescr = this._tableSpinFloatConversions[nameKey]; } else if (nameKey in this._tableSpin1ClkModeConstantNames) { - desiredDocText.category = "_CLKMODE Constant"; + desiredDocText.category = '_CLKMODE Constant'; desiredDocText.description = this._tableSpin1ClkModeConstantNames[nameKey]; } else if (nameKey in this._tableSpin1ConfigurationROVariableNames) { - desiredDocText.category = "Application R/O Variable"; + desiredDocText.category = 'Application R/O Variable'; desiredDocText.description = this._tableSpin1ConfigurationROVariableNames[nameKey]; } else if (nameKey in this._tableSpin1ConstantNames) { - desiredDocText.category = "Spin Constant"; + desiredDocText.category = 'Spin Constant'; desiredDocText.description = this._tableSpin1ConstantNames[nameKey]; } else if (nameKey in this._tableSpin1ConfigurationVariableNames) { - desiredDocText.category = "Spin Variable"; + desiredDocText.category = 'Spin Variable'; desiredDocText.description = this._tableSpin1ConfigurationVariableNames[nameKey]; } else if (nameKey in this._tableSpin1VariableNames) { - desiredDocText.category = "Spin Variable"; + desiredDocText.category = 'Spin Variable'; desiredDocText.description = this._tableSpin1VariableNames[nameKey]; } else if (nameKey in this._tableSpinDirectives) { - desiredDocText.category = "Spin Directives"; + desiredDocText.category = 'Spin Directives'; desiredDocText.description = this._tableSpinDirectives[nameKey]; } else if (nameKey in this._tableSpinStorageTypes) { - desiredDocText.category = "Storage Types"; + desiredDocText.category = 'Storage Types'; desiredDocText.description = this._tableSpinStorageTypes[nameKey]; } else if (nameKey in this._tableSpinStorageSpecials) { - desiredDocText.category = "DAT Special"; + desiredDocText.category = 'DAT Special'; protoWDescr = this._tableSpinStorageSpecials[nameKey]; } else if (nameKey in this._tableSpinRegisters) { - desiredDocText.category = "Registers"; + desiredDocText.category = 'Registers'; desiredDocText.description = this._tableSpinRegisters[nameKey]; } else if (nameKey in this._tableSpinStringMethods) { - desiredDocText.category = "String Method"; + desiredDocText.category = 'String Method'; methodDescr = this._tableSpinStringMethods[nameKey]; } else if (nameKey in this._tableSpinMemoryMethods) { - desiredDocText.category = "Memory Method"; + desiredDocText.category = 'Memory Method'; methodDescr = this._tableSpinMemoryMethods[nameKey]; } else if (nameKey in this._tableSpinIndexValueMethods) { - desiredDocText.category = "Memory Method"; + desiredDocText.category = 'Memory Method'; protoWDescr = this._tableSpinIndexValueMethods[nameKey]; } else if (nameKey in this._tableSpinProcessControlMethods) { - desiredDocText.category = "Process Control Method"; + desiredDocText.category = 'Process Control Method'; methodDescr = this._tableSpinProcessControlMethods[nameKey]; } else if (nameKey in this._tableSpinCogControlMethods) { - desiredDocText.category = "COG Control Method"; + desiredDocText.category = 'COG Control Method'; methodDescr = this._tableSpinCogControlMethods[nameKey]; } else if (nameKey in this._tableSpinP1AsmLangParts) { - desiredDocText.category = "P1Asm Directive"; + desiredDocText.category = 'P1Asm Directive'; protoWDescr = this._tableSpinP1AsmLangParts[nameKey]; } @@ -620,30 +636,45 @@ export class Spin1ParseUtils { // Built-in SPIN variables P1 // private _tableSpinBlockNames: { [Identifier: string]: string } = { - con: "32-bit Constant declarations
*(NOTE: CON is the initial/default block type)*", - obj: "Referenced object instantiations
*(objects manipulated by this object)*", - var: "Object Instance variable declarations", - pub: "Public method for use by the parent object and within this object", - pri: "Private method for use within this object", - dat: "Object Shared variable declarations and/or PASM code", + con: '32-bit Constant declarations
*(NOTE: CON is the initial/default block type)*', + obj: 'Referenced object instantiations
*(objects manipulated by this object)*', + var: 'Object Instance variable declarations', + pub: 'Public method for use by the parent object and within this object', + pri: 'Private method for use within this object', + dat: 'Object Shared variable declarations and/or PASM code' }; private _tableSpinP1AsmLangParts: { [Identifier: string]: string[] } = { // DAT cogexec org: [ - "ORG
", - "Adjust compile-time assembly pointer
@param `Address` - an optional Cog RAM address (0-495) to assemble the following assembly code with. If Address is not given, the value 0 is used", + 'ORG
', + 'Adjust compile-time assembly pointer
@param `Address` - an optional Cog RAM address (0-495) to assemble the following assembly code with. If Address is not given, the value 0 is used' ], fit: [ - "FIT
", - "Validate that previous instructions/data fit entirely below a specific address
@param `Address` - an optional Cog RAM address (0-$1F0) for which prior assembly code should not reach. If Address is not given, the value $1F0 is used (the address of the first special purpose register)", - ], + 'FIT
', + 'Validate that previous instructions/data fit entirely below a specific address
@param `Address` - an optional Cog RAM address (0-$1F0) for which prior assembly code should not reach. If Address is not given, the value $1F0 is used (the address of the first special purpose register)' + ] }; private _tableSpinFloatConversions: { [Identifier: string]: TMethodTuple } = { - float: ["FLOAT(x): floatValue", "Convert integer x to float", ["x - integer value to be converted"], ["floatValue - x-value represented as float"]], - trunc: ["TRUNC(x): integerValue", "Convert float x to truncated integer", ["x - float value to be converted (remove all after decimal)"], ["integerValue - result of truncation operation"]], - round: ["ROUND(x): integerValue", "Convert float x to rounded integer", ["x - float value to be converted (round to nearest integer)"], ["integerValue - result of rounding operation"]], + float: [ + 'FLOAT(x): floatValue', + 'Convert integer x to float', + ['x - integer value to be converted'], + ['floatValue - x-value represented as float'] + ], + trunc: [ + 'TRUNC(x): integerValue', + 'Convert float x to truncated integer', + ['x - float value to be converted (remove all after decimal)'], + ['integerValue - result of truncation operation'] + ], + round: [ + 'ROUND(x): integerValue', + 'Convert float x to rounded integer', + ['x - float value to be converted (round to nearest integer)'], + ['integerValue - result of rounding operation'] + ] }; public isFloatConversion(name: string): boolean { @@ -653,14 +684,14 @@ export class Spin1ParseUtils { } private _tableSpinStorageTypes: { [Identifier: string]: string } = { - byte: "8-bit storage", - word: "16-bit storage", - long: "32-bit storage", + byte: '8-bit storage', + word: '16-bit storage', + long: '32-bit storage' }; private _tableSpinStorageSpecials: { [Identifier: string]: string[] } = { - res: ["symbol RES n", "Reserve next 'n' long(s) for symbol"], - file: ['FileDat FILE "Filename"', 'include binary file, "FileDat" is a BYTE symbol that points to file'], + res: ['symbol RES n', "Reserve next 'n' long(s) for symbol"], + file: ['FileDat FILE "Filename"', 'include binary file, "FileDat" is a BYTE symbol that points to file'] }; public isDatNFileStorageType(name: string): boolean { @@ -676,7 +707,7 @@ export class Spin1ParseUtils { const nameKey: string = name.toLowerCase(); let reservedStatus: boolean = nameKey in this._tableSpinStorageTypes; if (!reservedStatus) { - reservedStatus = nameKey == "res" ? nameKey in this._tableSpinStorageSpecials : false; + reservedStatus = nameKey == 'res' ? nameKey in this._tableSpinStorageSpecials : false; } return reservedStatus; } @@ -688,28 +719,28 @@ export class Spin1ParseUtils { } private _tableSpinDirectives: { [Identifier: string]: string } = { - string: "Declare in-line string expression; resolved at compile time", - constant: "Declare in-line constant expression; resolved at compile time", + string: 'Declare in-line string expression; resolved at compile time', + constant: 'Declare in-line constant expression; resolved at compile time' }; private _tableSpinRegisters: { [Identifier: string]: string } = { - dira: "Direction Register for 32-bit port A (P0-P31)", - dirb: "Direction Register for 32-bit port B (P32-P63, future use)", - ina: "Input Register for 32-bit port A (P0-P31, read only)", - inb: "Input Register for 32-bit port B (P32-P63, read only, future use)", - outa: "Output Register for 32-bit port A (P0-P31)", - outb: "Output Register for 32-bit port B (P32-P63, future use)", - cnt: "32-bit System Counter Register (read only)", - ctra: "Counter A Control Register", - ctrb: "Counter B Control Register", - frqa: "Counter A Frequency Register", - frqb: "Counter B Frequency Register", - phsa: "Counter A Phase-Locked Loop (PLL) Register", - phsb: "Counter B Phase-Locked Loop (PLL) Register", - vcfg: "Video Configuration Register", - vscl: "Video Scale Register", - par: "Cog Boot Parameter Register (read only)", - spr: "Special-Purpose Register array; indirect cog register access", + dira: 'Direction Register for 32-bit port A (P0-P31)', + dirb: 'Direction Register for 32-bit port B (P32-P63, future use)', + ina: 'Input Register for 32-bit port A (P0-P31, read only)', + inb: 'Input Register for 32-bit port B (P32-P63, read only, future use)', + outa: 'Output Register for 32-bit port A (P0-P31)', + outb: 'Output Register for 32-bit port B (P32-P63, future use)', + cnt: '32-bit System Counter Register (read only)', + ctra: 'Counter A Control Register', + ctrb: 'Counter B Control Register', + frqa: 'Counter A Frequency Register', + frqb: 'Counter B Frequency Register', + phsa: 'Counter A Phase-Locked Loop (PLL) Register', + phsb: 'Counter B Phase-Locked Loop (PLL) Register', + vcfg: 'Video Configuration Register', + vscl: 'Video Scale Register', + par: 'Cog Boot Parameter Register (read only)', + spr: 'Special-Purpose Register array; indirect cog register access' }; // ------------------------------------------------------------------------- @@ -722,46 +753,46 @@ export class Spin1ParseUtils { } private _tableSpin1ConstantNames: { [Identifier: string]: string } = { - true: "Logical true: -1 ($FFFF_FFFF)", - false: "Logical false: 0 ($0000_0000)", - posx: "Maximum positive integer: 2,147,483,647 ($7FFF_FFFF)", - negx: "Maximum negative integer: -2,147,483,648 ($8000_0000)", - pi: "Floating-point value for PI: ~3.141593 ($4049_0FDB)", + true: 'Logical true: -1 ($FFFF_FFFF)', + false: 'Logical false: 0 ($0000_0000)', + posx: 'Maximum positive integer: 2,147,483,647 ($7FFF_FFFF)', + negx: 'Maximum negative integer: -2,147,483,648 ($8000_0000)', + pi: 'Floating-point value for PI: ~3.141593 ($4049_0FDB)' }; private _tableSpin1ClkModeConstantNames: { [Identifier: string]: string } = { - rcfast: "internal fast oscillator. No external parts. May range from 8 MHz to 20 MHz.", - rcslow: "internal slow oscillator. Very low power. No external parts. May range from 13 kHz to 33 kHz.", - xinput: "external clock/osc (XI pin). DC to 80 MHz Input", - xtal1: "external low-speed crystal. 4 to 16 MHz Crystal/Resonator", - xtal2: "external medium-speed crystal. 8 to 32 MHz Crystal/Resonator", - xtal3: "external high-speed crystal. 20 to 60 MHz Crystal/Resonator", - pll1x: "external frequency times 1", - pll2x: "external frequency times 2", - pll4x: "external frequency times 4", - pll8x: "external frequency times 8", - pll16x: "external frequency times 16", + rcfast: 'internal fast oscillator. No external parts. May range from 8 MHz to 20 MHz.', + rcslow: 'internal slow oscillator. Very low power. No external parts. May range from 13 kHz to 33 kHz.', + xinput: 'external clock/osc (XI pin). DC to 80 MHz Input', + xtal1: 'external low-speed crystal. 4 to 16 MHz Crystal/Resonator', + xtal2: 'external medium-speed crystal. 8 to 32 MHz Crystal/Resonator', + xtal3: 'external high-speed crystal. 20 to 60 MHz Crystal/Resonator', + pll1x: 'external frequency times 1', + pll2x: 'external frequency times 2', + pll4x: 'external frequency times 4', + pll8x: 'external frequency times 8', + pll16x: 'external frequency times 16' }; private _tableSpin1ConfigurationROVariableNames: { [Identifier: string]: string } = { - _clkmode: "Application-defined clock mode (read-only)", - _clkfreq: "Application-defined clock frequency (read-only)", - _xinfreq: "Application-defined external clock frequency (read-only)", - _stack: "Application-defined stack space to reserve (read-only)", - _free: "Application-defined free space to reserve (read-only)", - chipver: "Propeller chip version number (read-only)", - cogid: "Current cog’s ID number (0-7) (read-only)", - cnt: "Current 32-bit System Counter value (read-only)", + _clkmode: 'Application-defined clock mode (read-only)', + _clkfreq: 'Application-defined clock frequency (read-only)', + _xinfreq: 'Application-defined external clock frequency (read-only)', + _stack: 'Application-defined stack space to reserve (read-only)', + _free: 'Application-defined free space to reserve (read-only)', + chipver: 'Propeller chip version number (read-only)', + cogid: 'Current cog’s ID number (0-7) (read-only)', + cnt: 'Current 32-bit System Counter value (read-only)' }; private _tableSpin1ConfigurationVariableNames: { [Identifier: string]: string } = { - clkmode: "Current clock mode setting", - clkfreq: "Current clock frequency", - clkset: "Set clock mode and clock frequency", + clkmode: 'Current clock mode setting', + clkfreq: 'Current clock frequency', + clkset: 'Set clock mode and clock frequency' }; private _tableSpin1VariableNames: { [Identifier: string]: string } = { - result: "The return value variable for methods", + result: 'The return value variable for methods' }; public isSpinBuiltInConstant(name: string): boolean { @@ -780,14 +811,32 @@ export class Spin1ParseUtils { reservedStatus = nameKey in this._tableSpin1ConfigurationROVariableNames; } if (!reservedStatus) { - reservedStatus = nameKey == "result"; // yes, this is built-in! + reservedStatus = nameKey == 'result'; // yes, this is built-in! } return reservedStatus; } public isSpinReservedWord(name: string): boolean { const nameKey: string = name.toLowerCase(); - const spin1FlowControl: string[] = ["if", "ifnot", "elseif", "elseifnot", "else", "while", "repeat", "until", "from", "to", "step", "next", "quit", "case", "other", "abort", "return"]; + const spin1FlowControl: string[] = [ + 'if', + 'ifnot', + 'elseif', + 'elseifnot', + 'else', + 'while', + 'repeat', + 'until', + 'from', + 'to', + 'step', + 'next', + 'quit', + 'case', + 'other', + 'abort', + 'return' + ]; let reservedStatus: boolean = spin1FlowControl.indexOf(nameKey) != -1; if (reservedStatus == false) { reservedStatus = this.isBinaryOperator(name); @@ -818,158 +867,193 @@ export class Spin1ParseUtils { private _tableSpinMemoryMethods: { [Identifier: string]: TMethodTuple } = { bytemove: [ - "BYTEMOVE(Destination, Source, Count)", - "Move Count bytes from Source to Destination", - ["Destination - address of BYTE array to receive values", "Source - address of BYTE array to be copied", "Count - the number of BYTEs to be copied"], + 'BYTEMOVE(Destination, Source, Count)', + 'Move Count bytes from Source to Destination', + [ + 'Destination - address of BYTE array to receive values', + 'Source - address of BYTE array to be copied', + 'Count - the number of BYTEs to be copied' + ] ], wordmove: [ - "WORDMOVE(Destination, Source, Count)", - "Move Count words from Source to Destination", - ["Destination - address of WORD array to receive values", "Source - address of WORD array to be copied", "Count - the number of WORDs to be copied"], + 'WORDMOVE(Destination, Source, Count)', + 'Move Count words from Source to Destination', + [ + 'Destination - address of WORD array to receive values', + 'Source - address of WORD array to be copied', + 'Count - the number of WORDs to be copied' + ] ], longmove: [ - "LONGMOVE(Destination, Source, Count)", - "Move Count longs from Source to Destination", - ["Destination - address of LONG array to receive values", "Source - address of LONG array to be copied", "Count - the number of LONGs to be copied"], + 'LONGMOVE(Destination, Source, Count)', + 'Move Count longs from Source to Destination', + [ + 'Destination - address of LONG array to receive values', + 'Source - address of LONG array to be copied', + 'Count - the number of LONGs to be copied' + ] ], bytefill: [ - "BYTEFILL(Destination, Value, Count)", - "Fill Count bytes starting at Destination with Value", - ["Destination - address of BYTE array to receive values", "Value - 8-bit value", "Count - the number of BYTEs to be filled"], + 'BYTEFILL(Destination, Value, Count)', + 'Fill Count bytes starting at Destination with Value', + ['Destination - address of BYTE array to receive values', 'Value - 8-bit value', 'Count - the number of BYTEs to be filled'] ], wordfill: [ - "WORDFILL(Destination, Value, Count)", - "Fill Count words starting at Destination with Value", - ["Destination - address of WORD array to receive values", "Value - 16-bit value", "Count - the number of WORDs to be filled"], + 'WORDFILL(Destination, Value, Count)', + 'Fill Count words starting at Destination with Value', + ['Destination - address of WORD array to receive values', 'Value - 16-bit value', 'Count - the number of WORDs to be filled'] ], longfill: [ - "LONGFILL(Destination, Value, Count)", - "Fill Count longs starting at Destination with Value", - ["Destination - address of LONG array to receive values", "Value - 32-bit value", "Count - the number of LONGs to be filled"], - ], + 'LONGFILL(Destination, Value, Count)', + 'Fill Count longs starting at Destination with Value', + ['Destination - address of LONG array to receive values', 'Value - 32-bit value', 'Count - the number of LONGs to be filled'] + ] }; private _tableSpinIndexValueMethods: { [Identifier: string]: string[] } = { // NOTE: this does NOT support signature help! (paramaters are not highlighted for signature help due to ':' being param separater) lookup: [ - "LOOKUP(Index: ExpressionList) : Value", - "Lookup value (values and ranges allowed) using 1-based index, return value (0 if index out of range)

" + - "@param `Index` - an expression indicating the position of the desired value in ExpressionList
" + - "@param `ExpressionList` - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Value` - the value found (or 0 if index out of range)
", + 'LOOKUP(Index: ExpressionList) : Value', + 'Lookup value (values and ranges allowed) using 1-based index, return value (0 if index out of range)

' + + '@param `Index` - an expression indicating the position of the desired value in ExpressionList
' + + '@param `ExpressionList` - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
' + + '@returns `Value` - the value found (or 0 if index out of range)
' ], lookupz: [ - "LOOKUPZ(Index: ExpressionList) : Value", - "Lookup value (values and ranges allowed) using 0-based index, return value (0 if index out of range)

" + + 'LOOKUPZ(Index: ExpressionList) : Value', + 'Lookup value (values and ranges allowed) using 0-based index, return value (0 if index out of range)

' + "@param `Index' - is an expression indicating the position of the desired value in ExpressionList
" + "@param `ExpressionList' - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Value` - the value found (or 0 if index out of range)
", + '@returns `Value` - the value found (or 0 if index out of range)
' ], lookdown: [ - "LOOKDOWN(Value: ExpressionList) : Index", - "Determine 1-based index of matching value (values and ranges allowed), return index (0 if no match)

" + + 'LOOKDOWN(Value: ExpressionList) : Index', + 'Determine 1-based index of matching value (values and ranges allowed), return index (0 if no match)

' + "@param `Value' - is an expression indicating the value to find in ExpressionList
" + "@param `ExpressionList' - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Index` - the index found (or 0 if no match for value in list)
", + '@returns `Index` - the index found (or 0 if no match for value in list)
' ], lookdownz: [ - "LOOKDOWNZ(Value: ExpressionList) : Index", - "Determine 0-based index of matching value (values and ranges allowed), return index (0 if no match)

" + + 'LOOKDOWNZ(Value: ExpressionList) : Index', + 'Determine 0-based index of matching value (values and ranges allowed), return index (0 if no match)

' + "@param `Value' - is an expression indicating the value to find in ExpressionList
" + "@param `ExpressionList' - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Index` - the index found (or 0 if no match for value in list)
", - ], + '@returns `Index` - the index found (or 0 if no match for value in list)
' + ] }; private _tableSpinStringMethods: { [Identifier: string]: TMethodTuple } = { - strsize: ["STRSIZE(Addr) : Size", "Count bytes of zero-terminated string at Addr", ["Addr - address of zero-terminated string"], ["Size - the string length, not including the zero"]], - strcomp: [ - "STRCOMP(AddrA,AddrB) : Match", - "Compare zero-terminated strings at AddrA and AddrB", - ["AddrA - address of zero-terminated string", "AddrB - address of zero-terminated string"], - ["Match - return TRUE (-1) if match or FALSE (0) if not"], + strsize: [ + 'STRSIZE(Addr) : Size', + 'Count bytes of zero-terminated string at Addr', + ['Addr - address of zero-terminated string'], + ['Size - the string length, not including the zero'] ], + strcomp: [ + 'STRCOMP(AddrA,AddrB) : Match', + 'Compare zero-terminated strings at AddrA and AddrB', + ['AddrA - address of zero-terminated string', 'AddrB - address of zero-terminated string'], + ['Match - return TRUE (-1) if match or FALSE (0) if not'] + ] }; private _tableSpinProcessControlMethods: { [Identifier: string]: TMethodTuple } = { - locknew: ["LOCKNEW : ID", "Check out a new lock returning its ID", [], ["ID - the ID number (0–7) of the lock checked out (or -1 is none were available)"]], - lockret: ["LOCKRET(ID)", "Release lock back to lock pool, making it available for future LOCKNEW requests", ["ID - is the ID number (0–7) of the lock"]], - lockset: ["LOCKSET(ID) : prevState", "Set lock to true returning its previous state", ["ID - is the ID number (0–7) of the lock to set"], ["prevState - state of the lock before it was set"]], + locknew: [ + 'LOCKNEW : ID', + 'Check out a new lock returning its ID', + [], + ['ID - the ID number (0–7) of the lock checked out (or -1 is none were available)'] + ], + lockret: [ + 'LOCKRET(ID)', + 'Release lock back to lock pool, making it available for future LOCKNEW requests', + ['ID - is the ID number (0–7) of the lock'] + ], + lockset: [ + 'LOCKSET(ID) : prevState', + 'Set lock to true returning its previous state', + ['ID - is the ID number (0–7) of the lock to set'], + ['prevState - state of the lock before it was set'] + ], lockclr: [ - "LOCKCLR(ID) : prevState", - "Clear lock to false returning its previous state", - ["ID - is the ID number (0–7) of the lock to clear"], - ["prevState - state of the lock before it was cleared"], + 'LOCKCLR(ID) : prevState', + 'Clear lock to false returning its previous state', + ['ID - is the ID number (0–7) of the lock to clear'], + ['prevState - state of the lock before it was cleared'] + ], + waitcnt: [ + 'WAITCNT(value)', + 'Wait for System Counter, pausing a cog’s execution temporarily', + ['value - the desired 32-bit System Counter value to wait for'] ], - waitcnt: ["WAITCNT(value)", "Wait for System Counter, pausing a cog’s execution temporarily", ["value - the desired 32-bit System Counter value to wait for"]], waitpeq: [ - "WAITPEQ(State, Mask, Port)", - "Pause a cog’s execution until I/O pin(s) match designated state(s)", + 'WAITPEQ(State, Mask, Port)', + 'Pause a cog’s execution until I/O pin(s) match designated state(s)', [ - "State - the logic state(s) to compare the pin(s) against. It is a 32-bit value that indicates the high or low states of up to 32 I/O pins. State is compared against either (INA & Mask), or (INB & Mask), depending on Port.", - "Mask - the desired pin(s) to monitor. Mask is a 32-bit value that contains high (1) bits for every I/O pin that should be monitored; low (0) bits indicate pins that should be ignored. Mask is bitwised-ANDed with the 32-bit port’s input states and the resulting value is compared against the entire State value", - "Port - is a 1-bit value indicating the I/O port to monitor; 0 = Port A, 1 = Port B. Only Port A exists on current (P8X32A) Propeller chips", - ], + 'State - the logic state(s) to compare the pin(s) against. It is a 32-bit value that indicates the high or low states of up to 32 I/O pins. State is compared against either (INA & Mask), or (INB & Mask), depending on Port.', + 'Mask - the desired pin(s) to monitor. Mask is a 32-bit value that contains high (1) bits for every I/O pin that should be monitored; low (0) bits indicate pins that should be ignored. Mask is bitwised-ANDed with the 32-bit port’s input states and the resulting value is compared against the entire State value', + 'Port - is a 1-bit value indicating the I/O port to monitor; 0 = Port A, 1 = Port B. Only Port A exists on current (P8X32A) Propeller chips' + ] ], waitpne: [ - "WAITPNE(State, Mask, Port )", - "Pause a cog’s execution until I/O pin(s) do not match designated state(s)", + 'WAITPNE(State, Mask, Port )', + 'Pause a cog’s execution until I/O pin(s) do not match designated state(s)', [ - "State - the logic state(s) to compare the pin(s) against. It is a 32-bit value that indicates the high or low states of up to 32 I/O pins. State is compared against either (INA & Mask), or (INB & Mask), depending on Port.", - "Mask - the desired pin(s) to monitor. Mask is a 32-bit value that contains high (1) bits for every I/O pin that should be monitored; low (0) bits indicate pins that should be ignored. Mask is bitwised-ANDed with the 32-bit port’s input states and the resulting value is compared against the entire State value", - "Port - is a 1-bit value indicating the I/O port to monitor; 0 = Port A, 1 = Port B. Only Port A exists on current (P8X32A) Propeller chips", - ], + 'State - the logic state(s) to compare the pin(s) against. It is a 32-bit value that indicates the high or low states of up to 32 I/O pins. State is compared against either (INA & Mask), or (INB & Mask), depending on Port.', + 'Mask - the desired pin(s) to monitor. Mask is a 32-bit value that contains high (1) bits for every I/O pin that should be monitored; low (0) bits indicate pins that should be ignored. Mask is bitwised-ANDed with the 32-bit port’s input states and the resulting value is compared against the entire State value', + 'Port - is a 1-bit value indicating the I/O port to monitor; 0 = Port A, 1 = Port B. Only Port A exists on current (P8X32A) Propeller chips' + ] ], waitvid: [ - "WAITVID(Colors, Pixels)", - "Pause a cog’s execution until its Video Generator is available to take pixel data", + 'WAITVID(Colors, Pixels)', + 'Pause a cog’s execution until its Video Generator is available to take pixel data', [ - "Colors - a long containing four byte-sized color values, each describing the four possible colors of the pixel patterns in Pixels", - "Pixels - the next 16-pixel by 2-bit (or 32-pixel by 1-bit) pixel pattern to display", - ], - ], + 'Colors - a long containing four byte-sized color values, each describing the four possible colors of the pixel patterns in Pixels', + 'Pixels - the next 16-pixel by 2-bit (or 32-pixel by 1-bit) pixel pattern to display' + ] + ] }; private _tableSpinCogControlMethods: { [Identifier: string]: TMethodTuple } = { coginit: [ - "(run SPIN) COGINIT(CogID, SpinMethod(ParameterList), StackPointer)\r\n\t\t\t\t (run PASM) COGINIT(CogID, AsmAddress, Parameter)", - "Start or restart a cog by ID to run Spin code or Propeller Assembly code", + '(run SPIN) COGINIT(CogID, SpinMethod(ParameterList), StackPointer)\r\n\t\t\t\t (run PASM) COGINIT(CogID, AsmAddress, Parameter)', + 'Start or restart a cog by ID to run Spin code or Propeller Assembly code', [ // WARNING don't use '-' in non-parameter lines! - "(when SPIN):", - "CogID - the ID (0 - 7) of the cog to start, or restart. A CogID value of 8 - 15 results in the next available cog being started, if possible", - "SpinMethod - the Spin method that the affected cog should run. Optionally, it can be followed by a parameter list enclosed in parentheses", - "StackPointer - a pointer to memory, such as a long array, reserved for stack space for the affected cog. The affected cog uses this space to store temporary data during further calls and expression evaluations. If insufficient space is allocated, either the application will fail to run or it will run with strange results", - "", - "(when PASM):", - "CogID - the ID (0 - 7) of the cog to start, or restart. A CogID value of 8 - 15 results in the next available cog being started, if possible", - "AsmAddress - the address of a Propeller Assembly (pasm) routine from a DAT block", - "Parameter - used to optionally pass a value to the new cog. This value ends up in the new cog's read-only Cog Boot Parameter (PAR) register. Parameter can be used to pass a either a single 14-bit value or the address of a block of memory to be used by the assembly routine", - ], + '(when SPIN):', + 'CogID - the ID (0 - 7) of the cog to start, or restart. A CogID value of 8 - 15 results in the next available cog being started, if possible', + 'SpinMethod - the Spin method that the affected cog should run. Optionally, it can be followed by a parameter list enclosed in parentheses', + 'StackPointer - a pointer to memory, such as a long array, reserved for stack space for the affected cog. The affected cog uses this space to store temporary data during further calls and expression evaluations. If insufficient space is allocated, either the application will fail to run or it will run with strange results', + '', + '(when PASM):', + 'CogID - the ID (0 - 7) of the cog to start, or restart. A CogID value of 8 - 15 results in the next available cog being started, if possible', + 'AsmAddress - the address of a Propeller Assembly (pasm) routine from a DAT block', + "Parameter - used to optionally pass a value to the new cog. This value ends up in the new cog's read-only Cog Boot Parameter (PAR) register. Parameter can be used to pass a either a single 14-bit value or the address of a block of memory to be used by the assembly routine" + ] ], cognew: [ - "(run SPIN) COGNEW(SpinMethod(ParameterList), StackPointer) : CogID\r\n\t\t\t\t (run PASM) COGNEW(AsmAddress, Parameter): CogID", - "Start the next available cog to run Spin code or Propeller Assembly code", + '(run SPIN) COGNEW(SpinMethod(ParameterList), StackPointer) : CogID\r\n\t\t\t\t (run PASM) COGNEW(AsmAddress, Parameter): CogID', + 'Start the next available cog to run Spin code or Propeller Assembly code', [ // WARNING don't use '-' in non-parameter lines! - "(when SPIN):", - "SpinMethod - the Spin method that the affected cog should run. Optionally, it can be followed by a parameter list enclosed in parentheses", - "StackPointer - a pointer to memory, such as a long array, reserved for stack space for the affected cog. The affected cog uses this space to store temporary data during further calls and expression evaluations. If insufficient space is allocated, either the application will fail to run or it will run with strange results", - "", - "(when PASM):", - "AsmAddress - the address of a Propeller Assembly (pasm) routine, from a DAT block", + '(when SPIN):', + 'SpinMethod - the Spin method that the affected cog should run. Optionally, it can be followed by a parameter list enclosed in parentheses', + 'StackPointer - a pointer to memory, such as a long array, reserved for stack space for the affected cog. The affected cog uses this space to store temporary data during further calls and expression evaluations. If insufficient space is allocated, either the application will fail to run or it will run with strange results', + '', + '(when PASM):', + 'AsmAddress - the address of a Propeller Assembly (pasm) routine, from a DAT block', "Parameter - used to optionally pass a value to the new cog. This value ends up in the new cog's read-only Cog Boot Parameter (PAR) register. Parameter can be used to pass a either a single 14-bit value or the address of a block of memory to be used by the assembly routine", - "", // provide separation from @returns + '' // provide separation from @returns ], - ["CogID - The ID of the newly started cog (0-7) if successful, or -1 otherwise"], + ['CogID - The ID of the newly started cog (0-7) if successful, or -1 otherwise'] ], - cogstop: ["COGSTOP(CogID)", "Stop cog by its ID", ["CogID - theID(0-7) of the cog to stop"]], - reboot: ["REBOOT", "Reset the Propeller chip", []], + cogstop: ['COGSTOP(CogID)', 'Stop cog by its ID', ['CogID - theID(0-7) of the cog to stop']], + reboot: ['REBOOT', 'Reset the Propeller chip', []] }; public isSpinBuiltinMethod(name: string): boolean { const nameKey: string = name.toLowerCase(); - const spinMethodNames: string[] = ["call", "clkset"]; + const spinMethodNames: string[] = ['call', 'clkset']; let reservedStatus: boolean = spinMethodNames.indexOf(nameKey) != -1; if (!reservedStatus) { reservedStatus = nameKey in this._tableSpinMemoryMethods; @@ -993,692 +1077,733 @@ export class Spin1ParseUtils { } public isSpin2ButOKReservedWords(name: string): boolean { - const spin2OKInstructionsOfNote: string[] = ["crcbit", "getbyte", "getword", "pop", "push", "setbyte", "skip", "zerox", "pb", "pa", "bmask", "decod"]; + const spin2OKInstructionsOfNote: string[] = [ + 'crcbit', + 'getbyte', + 'getword', + 'pop', + 'push', + 'setbyte', + 'skip', + 'zerox', + 'pb', + 'pa', + 'bmask', + 'decod' + ]; const reservedStatus: boolean = spin2OKInstructionsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isSpin2ReservedWords(name: string): boolean { const spin2InstructionsOfNote: string[] = [ - "alignl", - "alignw", - "orgf", - "orgh", - "pr0", - "pr1", - "pr2", - "pr3", - "pr4", - "pr5", - "pr6", - "pr7", - "ijmp1", - "ijmp2", - "ijmp3", - "iret1", - "iret2", - "iret3", - "pa", - "pb", - "ptra", - "ptrb", - "addct1", - "addct2", - "addct3", - "addpix", - "akpin", - "allowi", - "altb", - "altd", - "altgb", - "altgn", - "altgw", - "alti", - "altr", - "alts", - "altsb", - "altsn", - "altsw", - "augd", - "augs", - "bitc", - "bith", - "bitl", - "bitnc", - "bitnot", - "bitnz", - "bitrnd", - "bitz", - "blnpix", - "bmask", - "brk", - "calla", - "callb", - "calld", - "callpa", - "callpb", - "cmpm", - "cmpr", - "cogatn", - "cogbrk", - "crcbit", - "crcnib", - "decmod", - "decod", - "dirc", - "dirh", - "dirl", - "dirnc", - "dirnot", - "dirnz", - "dirrnd", - "dirz", - "djf", - "djnf", - "djz", - "drvc", - "drvh", - "drvl", - "drvnc", - "drvnot", - "drvnz", - "drvrnd", - "drvz", - "encod", - "execf", - "fblock", - "fge", - "fges", - "fle", - "fles", - "fltc", - "flth", - "fltl", - "fltnc", - "fltnot", - "fltnz", - "fltrnd", - "fltz", - "getbrk", - "getbyte", - "getct", - "getnib", - "getptr", - "getqx", - "getqy", - "getrnd", - "getrnd", - "getscp", - "getword", - "getxacc", - "hubset", - "ijnz", - "ijz", - "incmod", - "jatn", - "jct1", - "jct2", - "jct3", - "jfbw", - "jint", - "jmprel", - "jnatn", - "jnct1", - "jnct2", - "jnct3", - "jnfbw", - "jnint", - "jnpat", - "jnqmt", - "jnse1", - "jnse2", - "jnse3", - "jnse4", - "jnxfi", - "jnxmt", - "jnxrl", - "jnxro", - "jpat", - "jqmt", - "jse1", - "jse2", - "jse3", - "jse4", - "jxfi", - "jxmt", - "jxrl", - "jxro", - "loc", - "lockrel", - "locktry", - "mergeb", - "mergew", - "mixpix", - "modc", - "modcz", - "modz", - "movbyts", - "mul", - "mulpix", - "muls", - "muxnibs", - "muxnits", - "muxq", - "nixint1", - "nixint2", - "nixint3", - "outc", - "outh", - "outl", - "outnc", - "outnot", - "outnz", - "outrnd", - "outz", - "pollatn", - "pollct1", - "pollct2", - "pollct3", - "pollfbw", - "pollint", - "pollpat", - "pollqmt", - "pollse1", - "pollse2", - "pollse3", - "pollse4", - "pollxfi", - "pollxmt", - "pollxrl", - "pollxro", - "pop", - "popa", - "popb", - "push", - "pusha", - "pushb", - "qdiv", - "qexp", - "qfrac", - "qlog", - "qmul", - "qrotate", - "qsqrt", - "qvector", - "rczl", - "rczr", - "rdfast", - "rdlut", - "rdpin", - "rep", - "resi0", - "resi1", - "resi2", - "resi3", - "reta", - "retb", - "reti0", - "reti1", - "reti2", - "reti3", - "rfbyte", - "rflong", - "rfvar", - "rfvars", - "rfword", - "rgbexp", - "rgbsqz", - "rolbyte", - "rolbyte", - "rolnib", - "rolword", - "rolword", - "rqpin", - "sal", - "sca", - "scas", - "setbyte", - "setcfrq", - "setci", - "setcmod", - "setcq", - "setcy", - "setd", - "setdacs", - "setint1", - "setint2", - "setint3", - "setluts", - "setnib", - "setpat", - "setpiv", - "setpix", - "setq", - "setq2", - "setr", - "sets", - "setscp", - "setse1", - "setse2", - "setse3", - "setse4", - "setword", - "setxfrq", - "seussf", - "seussr", - "signx", - "skip", - "skipf", - "splitb", - "splitw", - "stalli", - "subr", - "testb", - "testbn", - "testp", - "testpn", - "tjf", - "tjnf", - "tjns", - "tjs", - "tjv", - "trgint1", - "trgint2", - "trgint3", - "waitatn", - "waitct1", - "waitct2", - "waitct3", - "waitfbw", - "waitint", - "waitpat", - "waitse1", - "waitse2", - "waitse3", - "waitse4", - "waitx", - "waitxfi", - "waitxmt", - "waitxrl", - "waitxro", - "wfbyte", - "wflong", - "wfword", - "wmlong", - "wrc", - "wrfast", - "wrlut", - "wrnc", - "wrnz", - "wrpin", - "wrz", - "wxpin", - "wypin", - "xcont", - "xinit", - "xoro32", - "xstop", - "xzero", - "zerox", - "wcz", - "xorc", - "xorz", - "orc", - "orz", - "andc", - "andz", - "_ret_", - "if_00", - "if_01", - "if_0x", - "if_10", - "if_x0", - "if_diff", - "if_not_11", - "if_11", - "if_same", - "if_x1", - "if_not_10", - "if_1x", - "if_not_01", - "if_not_00", - "if_le", - "if_lt", - "if_ge", - "if_gt", - "p_adc", - "p_adc_100x", - "p_adc_10x", - "p_adc_1x", - "p_adc_30x", - "p_adc_3x", - "p_adc_ext", - "p_adc_float", - "p_adc_gio", - "p_adc_scope", - "p_adc_vio", - "p_async_io", - "p_async_rx", - "p_async_tx", - "p_bitdac", - "p_channel", - "p_compare_ab", - "p_compare_ab_fb", - "p_counter_highs", - "p_counter_periods", - "p_counter_ticks", - "p_count_highs", - "p_count_rises", - "p_dac_124r_3v", - "p_dac_600r_2v", - "p_dac_75r_2v", - "p_dac_990r_3v", - "p_dac_dither_pwm", - "p_dac_dither_rnd", - "p_dac_noise", - "p_events_ticks", - "p_high_100ua", - "p_high_10ua", - "p_high_150k", - "p_high_15k", - "p_high_1k5", - "p_high_1ma", - "p_high_fast", - "p_high_float", - "p_high_ticks", - "p_invert_a", - "p_invert_b", - "p_invert_in", - "p_invert_output", - "p_level_a", - "p_level_a_fbn", - "p_level_b_fbp", - "p_level_b_fbn", - "p_local_a", - "p_local_b", - "p_logic_a", - "p_logic_a_fb", - "p_logic_b_fb", - "p_low_100ua", - "p_low_10ua", - "p_low_150k", - "p_low_15k", - "p_low_1k5", - "p_low_1ma", - "p_low_fast", - "p_low_float", - "p_minus1_a", - "p_minus1_b", - "p_minus2_a", - "p_minus2_b", - "p_minus3_a", - "p_minus3_b", - "p_nco_duty", - "p_nco_freq", - "p_normal", - "p_oe", - "p_outbit_a", - "p_outbit_b", - "p_periods_highs", - "p_periods_ticks", - "p_plus1_a", - "p_plus1_b", - "p_plus2_a", - "p_plus2_b", - "p_plus3_a", - "p_plus3_b", - "p_pulse", - "p_pwm_sawtooth", - "p_pwm_smps", - "p_pwm_triangle", - "p_quadrature", - "p_reg_down", - "p_reg_up", - "p_repository", - "p_schmitt_a", - "p_schmitt_a_fb", - "p_schmitt_b_fb", - "p_state_ticks", - "p_sync_io", - "p_sync_rx", - "p_sync_tx", - "p_transition", - "p_true_a", - "p_true_b", - "p_true_in", - "p_true_output", - "p_tt_00", - "p_tt_01", - "p_tt_10", - "p_tt_11", - "p_usb_pair", - "x_16p_2dac8_wfword", - "x_16p_4dac4_wfword", - "x_1adc8_0p_1dac8_wfbyte", - "x_1adc8_8p_2dac8_wfword", - "x_1p_1dac1_wfbyte", - "x_2adc8_0p_2dac8_wfword", - "x_2adc8_16p_4dac8_wflong", - "x_2p_1dac2_wfbyte", - "x_2p_2dac1_wfbyte", - "x_32p_4dac8_wflong", - "x_4adc8_0p_4dac8_wflong", - "x_4p_1dac4_wfbyte", - "x_4p_2dac2_wfbyte", - "x_4p_4dac1_wfbyte", - "x_8p_1dac8_wfbyte", - "x_8p_2dac4_wfbyte", - "x_8p_4dac2_wfbyte", - "x_alt_off", - "x_alt_on", - "x_dacs_0n0_0n0", - "x_dacs_0n0_x_x", - "x_dacs_0_0_0_0", - "x_dacs_0_0_x_x", - "x_dacs_0_x_x_x", - "x_dacs_1n1_0n0", - "x_dacs_1_0_1_0", - "x_dacs_1_0_x_x", - "x_dacs_3_2_1_0", - "x_dacs_off", - "x_dacs_x_0_x_x", - "x_dacs_x_x_0n0", - "x_dacs_x_x_0_0", - "x_dacs_x_x_0_x", - "x_dacs_x_x_1_0", - "x_dacs_x_x_x_0", - "x_dds_goertzel_sinc1", - "x_dds_goertzel_sinc2", - "x_imm_16x2_1dac2", - "x_imm_16x2_2dac1", - "x_imm_16x2_lut", - "x_imm_1x32_4dac8", - "x_imm_2x16_2dac8", - "x_imm_2x16_4dac4", - "x_imm_32x1_1dac1", - "x_imm_32x1_lut", - "x_imm_4x8_1dac8", - "x_imm_4x8_2dac4", - "x_imm_4x8_4dac2", - "x_imm_4x8_lut", - "x_imm_8x4_1dac4", - "x_imm_8x4_2dac2", - "x_imm_8x4_4dac1", - "x_imm_8x4_lut", - "x_pins_off", - "x_pins_on", - "x_rfbyte_1p_1dac1", - "x_rfbyte_2p_1dac2", - "x_rfbyte_2p_2dac1", - "x_rfbyte_4p_1dac4", - "x_rfbyte_4p_2dac2", - "x_rfbyte_4p_4dac1", - "x_rfbyte_8p_1dac8", - "x_rfbyte_8p_2dac4", - "x_rfbyte_8p_4dac2", - "x_rfbyte_luma8", - "x_rfbyte_rgb8", - "x_rfbyte_rgbi8", - "x_rflong_16x2_lut", - "x_rflong_32p_4dac8", - "x_rflong_32x1_lut", - "x_rflong_4x8_lut", - "x_rflong_8x4_lut", - "x_rflong_rgb24", - "x_rfword_16p_2dac8", - "x_rfword_16p_4dac4", - "x_rfword_rgb16", - "x_write_off", - "x_write_on", + 'alignl', + 'alignw', + 'orgf', + 'orgh', + 'pr0', + 'pr1', + 'pr2', + 'pr3', + 'pr4', + 'pr5', + 'pr6', + 'pr7', + 'ijmp1', + 'ijmp2', + 'ijmp3', + 'iret1', + 'iret2', + 'iret3', + 'pa', + 'pb', + 'ptra', + 'ptrb', + 'addct1', + 'addct2', + 'addct3', + 'addpix', + 'akpin', + 'allowi', + 'altb', + 'altd', + 'altgb', + 'altgn', + 'altgw', + 'alti', + 'altr', + 'alts', + 'altsb', + 'altsn', + 'altsw', + 'augd', + 'augs', + 'bitc', + 'bith', + 'bitl', + 'bitnc', + 'bitnot', + 'bitnz', + 'bitrnd', + 'bitz', + 'blnpix', + 'bmask', + 'brk', + 'calla', + 'callb', + 'calld', + 'callpa', + 'callpb', + 'cmpm', + 'cmpr', + 'cogatn', + 'cogbrk', + 'crcbit', + 'crcnib', + 'decmod', + 'decod', + 'dirc', + 'dirh', + 'dirl', + 'dirnc', + 'dirnot', + 'dirnz', + 'dirrnd', + 'dirz', + 'djf', + 'djnf', + 'djz', + 'drvc', + 'drvh', + 'drvl', + 'drvnc', + 'drvnot', + 'drvnz', + 'drvrnd', + 'drvz', + 'encod', + 'execf', + 'fblock', + 'fge', + 'fges', + 'fle', + 'fles', + 'fltc', + 'flth', + 'fltl', + 'fltnc', + 'fltnot', + 'fltnz', + 'fltrnd', + 'fltz', + 'getbrk', + 'getbyte', + 'getct', + 'getnib', + 'getptr', + 'getqx', + 'getqy', + 'getrnd', + 'getrnd', + 'getscp', + 'getword', + 'getxacc', + 'hubset', + 'ijnz', + 'ijz', + 'incmod', + 'jatn', + 'jct1', + 'jct2', + 'jct3', + 'jfbw', + 'jint', + 'jmprel', + 'jnatn', + 'jnct1', + 'jnct2', + 'jnct3', + 'jnfbw', + 'jnint', + 'jnpat', + 'jnqmt', + 'jnse1', + 'jnse2', + 'jnse3', + 'jnse4', + 'jnxfi', + 'jnxmt', + 'jnxrl', + 'jnxro', + 'jpat', + 'jqmt', + 'jse1', + 'jse2', + 'jse3', + 'jse4', + 'jxfi', + 'jxmt', + 'jxrl', + 'jxro', + 'loc', + 'lockrel', + 'locktry', + 'mergeb', + 'mergew', + 'mixpix', + 'modc', + 'modcz', + 'modz', + 'movbyts', + 'mul', + 'mulpix', + 'muls', + 'muxnibs', + 'muxnits', + 'muxq', + 'nixint1', + 'nixint2', + 'nixint3', + 'outc', + 'outh', + 'outl', + 'outnc', + 'outnot', + 'outnz', + 'outrnd', + 'outz', + 'pollatn', + 'pollct1', + 'pollct2', + 'pollct3', + 'pollfbw', + 'pollint', + 'pollpat', + 'pollqmt', + 'pollse1', + 'pollse2', + 'pollse3', + 'pollse4', + 'pollxfi', + 'pollxmt', + 'pollxrl', + 'pollxro', + 'pop', + 'popa', + 'popb', + 'push', + 'pusha', + 'pushb', + 'qdiv', + 'qexp', + 'qfrac', + 'qlog', + 'qmul', + 'qrotate', + 'qsqrt', + 'qvector', + 'rczl', + 'rczr', + 'rdfast', + 'rdlut', + 'rdpin', + 'rep', + 'resi0', + 'resi1', + 'resi2', + 'resi3', + 'reta', + 'retb', + 'reti0', + 'reti1', + 'reti2', + 'reti3', + 'rfbyte', + 'rflong', + 'rfvar', + 'rfvars', + 'rfword', + 'rgbexp', + 'rgbsqz', + 'rolbyte', + 'rolbyte', + 'rolnib', + 'rolword', + 'rolword', + 'rqpin', + 'sal', + 'sca', + 'scas', + 'setbyte', + 'setcfrq', + 'setci', + 'setcmod', + 'setcq', + 'setcy', + 'setd', + 'setdacs', + 'setint1', + 'setint2', + 'setint3', + 'setluts', + 'setnib', + 'setpat', + 'setpiv', + 'setpix', + 'setq', + 'setq2', + 'setr', + 'sets', + 'setscp', + 'setse1', + 'setse2', + 'setse3', + 'setse4', + 'setword', + 'setxfrq', + 'seussf', + 'seussr', + 'signx', + 'skip', + 'skipf', + 'splitb', + 'splitw', + 'stalli', + 'subr', + 'testb', + 'testbn', + 'testp', + 'testpn', + 'tjf', + 'tjnf', + 'tjns', + 'tjs', + 'tjv', + 'trgint1', + 'trgint2', + 'trgint3', + 'waitatn', + 'waitct1', + 'waitct2', + 'waitct3', + 'waitfbw', + 'waitint', + 'waitpat', + 'waitse1', + 'waitse2', + 'waitse3', + 'waitse4', + 'waitx', + 'waitxfi', + 'waitxmt', + 'waitxrl', + 'waitxro', + 'wfbyte', + 'wflong', + 'wfword', + 'wmlong', + 'wrc', + 'wrfast', + 'wrlut', + 'wrnc', + 'wrnz', + 'wrpin', + 'wrz', + 'wxpin', + 'wypin', + 'xcont', + 'xinit', + 'xoro32', + 'xstop', + 'xzero', + 'zerox', + 'wcz', + 'xorc', + 'xorz', + 'orc', + 'orz', + 'andc', + 'andz', + '_ret_', + 'if_00', + 'if_01', + 'if_0x', + 'if_10', + 'if_x0', + 'if_diff', + 'if_not_11', + 'if_11', + 'if_same', + 'if_x1', + 'if_not_10', + 'if_1x', + 'if_not_01', + 'if_not_00', + 'if_le', + 'if_lt', + 'if_ge', + 'if_gt', + 'p_adc', + 'p_adc_100x', + 'p_adc_10x', + 'p_adc_1x', + 'p_adc_30x', + 'p_adc_3x', + 'p_adc_ext', + 'p_adc_float', + 'p_adc_gio', + 'p_adc_scope', + 'p_adc_vio', + 'p_async_io', + 'p_async_rx', + 'p_async_tx', + 'p_bitdac', + 'p_channel', + 'p_compare_ab', + 'p_compare_ab_fb', + 'p_counter_highs', + 'p_counter_periods', + 'p_counter_ticks', + 'p_count_highs', + 'p_count_rises', + 'p_dac_124r_3v', + 'p_dac_600r_2v', + 'p_dac_75r_2v', + 'p_dac_990r_3v', + 'p_dac_dither_pwm', + 'p_dac_dither_rnd', + 'p_dac_noise', + 'p_events_ticks', + 'p_high_100ua', + 'p_high_10ua', + 'p_high_150k', + 'p_high_15k', + 'p_high_1k5', + 'p_high_1ma', + 'p_high_fast', + 'p_high_float', + 'p_high_ticks', + 'p_invert_a', + 'p_invert_b', + 'p_invert_in', + 'p_invert_output', + 'p_level_a', + 'p_level_a_fbn', + 'p_level_b_fbp', + 'p_level_b_fbn', + 'p_local_a', + 'p_local_b', + 'p_logic_a', + 'p_logic_a_fb', + 'p_logic_b_fb', + 'p_low_100ua', + 'p_low_10ua', + 'p_low_150k', + 'p_low_15k', + 'p_low_1k5', + 'p_low_1ma', + 'p_low_fast', + 'p_low_float', + 'p_minus1_a', + 'p_minus1_b', + 'p_minus2_a', + 'p_minus2_b', + 'p_minus3_a', + 'p_minus3_b', + 'p_nco_duty', + 'p_nco_freq', + 'p_normal', + 'p_oe', + 'p_outbit_a', + 'p_outbit_b', + 'p_periods_highs', + 'p_periods_ticks', + 'p_plus1_a', + 'p_plus1_b', + 'p_plus2_a', + 'p_plus2_b', + 'p_plus3_a', + 'p_plus3_b', + 'p_pulse', + 'p_pwm_sawtooth', + 'p_pwm_smps', + 'p_pwm_triangle', + 'p_quadrature', + 'p_reg_down', + 'p_reg_up', + 'p_repository', + 'p_schmitt_a', + 'p_schmitt_a_fb', + 'p_schmitt_b_fb', + 'p_state_ticks', + 'p_sync_io', + 'p_sync_rx', + 'p_sync_tx', + 'p_transition', + 'p_true_a', + 'p_true_b', + 'p_true_in', + 'p_true_output', + 'p_tt_00', + 'p_tt_01', + 'p_tt_10', + 'p_tt_11', + 'p_usb_pair', + 'x_16p_2dac8_wfword', + 'x_16p_4dac4_wfword', + 'x_1adc8_0p_1dac8_wfbyte', + 'x_1adc8_8p_2dac8_wfword', + 'x_1p_1dac1_wfbyte', + 'x_2adc8_0p_2dac8_wfword', + 'x_2adc8_16p_4dac8_wflong', + 'x_2p_1dac2_wfbyte', + 'x_2p_2dac1_wfbyte', + 'x_32p_4dac8_wflong', + 'x_4adc8_0p_4dac8_wflong', + 'x_4p_1dac4_wfbyte', + 'x_4p_2dac2_wfbyte', + 'x_4p_4dac1_wfbyte', + 'x_8p_1dac8_wfbyte', + 'x_8p_2dac4_wfbyte', + 'x_8p_4dac2_wfbyte', + 'x_alt_off', + 'x_alt_on', + 'x_dacs_0n0_0n0', + 'x_dacs_0n0_x_x', + 'x_dacs_0_0_0_0', + 'x_dacs_0_0_x_x', + 'x_dacs_0_x_x_x', + 'x_dacs_1n1_0n0', + 'x_dacs_1_0_1_0', + 'x_dacs_1_0_x_x', + 'x_dacs_3_2_1_0', + 'x_dacs_off', + 'x_dacs_x_0_x_x', + 'x_dacs_x_x_0n0', + 'x_dacs_x_x_0_0', + 'x_dacs_x_x_0_x', + 'x_dacs_x_x_1_0', + 'x_dacs_x_x_x_0', + 'x_dds_goertzel_sinc1', + 'x_dds_goertzel_sinc2', + 'x_imm_16x2_1dac2', + 'x_imm_16x2_2dac1', + 'x_imm_16x2_lut', + 'x_imm_1x32_4dac8', + 'x_imm_2x16_2dac8', + 'x_imm_2x16_4dac4', + 'x_imm_32x1_1dac1', + 'x_imm_32x1_lut', + 'x_imm_4x8_1dac8', + 'x_imm_4x8_2dac4', + 'x_imm_4x8_4dac2', + 'x_imm_4x8_lut', + 'x_imm_8x4_1dac4', + 'x_imm_8x4_2dac2', + 'x_imm_8x4_4dac1', + 'x_imm_8x4_lut', + 'x_pins_off', + 'x_pins_on', + 'x_rfbyte_1p_1dac1', + 'x_rfbyte_2p_1dac2', + 'x_rfbyte_2p_2dac1', + 'x_rfbyte_4p_1dac4', + 'x_rfbyte_4p_2dac2', + 'x_rfbyte_4p_4dac1', + 'x_rfbyte_8p_1dac8', + 'x_rfbyte_8p_2dac4', + 'x_rfbyte_8p_4dac2', + 'x_rfbyte_luma8', + 'x_rfbyte_rgb8', + 'x_rfbyte_rgbi8', + 'x_rflong_16x2_lut', + 'x_rflong_32p_4dac8', + 'x_rflong_32x1_lut', + 'x_rflong_4x8_lut', + 'x_rflong_8x4_lut', + 'x_rflong_rgb24', + 'x_rfword_16p_2dac8', + 'x_rfword_16p_4dac4', + 'x_rfword_rgb16', + 'x_write_off', + 'x_write_on' ]; const reservedStatus: boolean = spin2InstructionsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isBinaryOperator(name: string): boolean { - const binaryOperationsOfNote: string[] = ["and", "or"]; + const binaryOperationsOfNote: string[] = ['and', 'or']; const reservedStatus: boolean = binaryOperationsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isUnaryOperator(name: string): boolean { - const unaryOperationsOfNote: string[] = ["not"]; + const unaryOperationsOfNote: string[] = ['not']; const reservedStatus: boolean = unaryOperationsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isFlexspinPreprocessorDirective(name: string): boolean { - const flexspinDirectiveOfNote: string[] = ["#define", "#ifdef", "#ifndef", "#else", "#elseifdef", "#elseifndef", "#endif", "#error", "#include", "#warn", "#undef"]; + const flexspinDirectiveOfNote: string[] = [ + '#define', + '#ifdef', + '#ifndef', + '#else', + '#elseifdef', + '#elseifndef', + '#endif', + '#error', + '#include', + '#warn', + '#undef' + ]; const reservedStatus: boolean = flexspinDirectiveOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isFlexspinReservedWord(name: string): boolean { const flexspinReservedswordsOfNote: string[] = [ - "__propeller__", - "__propeller2__", - "__p2__", - "__flexspin__", - "__spincvt__", - "__spin2pasm__", - "__spin2cpp__", - "__have_fcache__", - "__cplusplus__", - "__date__", - "__file__", - "__line__", - "__time__", - "__version__", - "__debug__", - "__output_asm__", - "__output_bytecode__", - "__output_c__", - "__output_cpp__", + '__propeller__', + '__propeller2__', + '__p2__', + '__flexspin__', + '__spincvt__', + '__spin2pasm__', + '__spin2cpp__', + '__have_fcache__', + '__cplusplus__', + '__date__', + '__file__', + '__line__', + '__time__', + '__version__', + '__debug__', + '__output_asm__', + '__output_bytecode__', + '__output_c__', + '__output_cpp__' ]; const reservedStatus: boolean = flexspinReservedswordsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isP1AsmReservedSymbols(name: string): boolean { - const reservedP1AsmSymbolNames: string[] = ["org", "fit"]; + const reservedP1AsmSymbolNames: string[] = ['org', 'fit']; const reservedStatus: boolean = reservedP1AsmSymbolNames.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isP1AsmReservedWord(name: string): boolean { - const pasmReservedswordsOfNote: string[] = ["cnt", "scr", "_clkfreq", "_clkmode", "_xinfreq", "_stack", "_free", "round", "float", "trunc", "true", "false", "negx", "pi", "posx"]; + const pasmReservedswordsOfNote: string[] = [ + 'cnt', + 'scr', + '_clkfreq', + '_clkmode', + '_xinfreq', + '_stack', + '_free', + 'round', + 'float', + 'trunc', + 'true', + 'false', + 'negx', + 'pi', + 'posx' + ]; const reservedStatus: boolean = pasmReservedswordsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isP1AsmInstruction(name: string): boolean { const pasmInstructions: string[] = [ - "abs", - "absneg", - "add", - "addabs", - "adds", - "addsx", - "addx", - "and", - "andn", - "call", - "clkset", - "cmp", - "cmps", - "cmpsub", - "cmpsx", - "cmpx", - "cogid", - "coginit", - "cogstop", - "djnz", - "hubop", - "jmp", - "jmpret", - "lockclr", - "locknew", - "lockret", - "lockset", - "max", - "maxs", - "min", - "mins", - "mov", - "movd", - "movi", - "movs", - "muxc", - "muxnc", - "muxz", - "muxnz", - "neg", - "negc", - "negnc", - "negnz", - "negz", - "nop", - "or", - "rcl", - "rcr", - "rdbyte", - "rdlong", - "rdword", - "ret", - "rev", - "rol", - "ror", - "sar", - "shl", - "shr", - "sub", - "subabs", - "subs", - "subsx", - "subx", - "sumc", - "sumnc", - "sumnz", - "sumz", - "test", - "testn", - "tjnz", - "tjz", - "waitcnt", - "waitpeq", - "waitpne", - "waitvid", - "wrbyte", - "wrlong", - "wrword", - "xor", + 'abs', + 'absneg', + 'add', + 'addabs', + 'adds', + 'addsx', + 'addx', + 'and', + 'andn', + 'call', + 'clkset', + 'cmp', + 'cmps', + 'cmpsub', + 'cmpsx', + 'cmpx', + 'cogid', + 'coginit', + 'cogstop', + 'djnz', + 'hubop', + 'jmp', + 'jmpret', + 'lockclr', + 'locknew', + 'lockret', + 'lockset', + 'max', + 'maxs', + 'min', + 'mins', + 'mov', + 'movd', + 'movi', + 'movs', + 'muxc', + 'muxnc', + 'muxz', + 'muxnz', + 'neg', + 'negc', + 'negnc', + 'negnz', + 'negz', + 'nop', + 'or', + 'rcl', + 'rcr', + 'rdbyte', + 'rdlong', + 'rdword', + 'ret', + 'rev', + 'rol', + 'ror', + 'sar', + 'shl', + 'shr', + 'sub', + 'subabs', + 'subs', + 'subsx', + 'subx', + 'sumc', + 'sumnc', + 'sumnz', + 'sumz', + 'test', + 'testn', + 'tjnz', + 'tjz', + 'waitcnt', + 'waitpeq', + 'waitpne', + 'waitvid', + 'wrbyte', + 'wrlong', + 'wrword', + 'xor' ]; const instructionStatus: boolean = pasmInstructions.indexOf(name.toLowerCase()) != -1; return instructionStatus; } public isP1AsmNonArgumentInstruction(name: string): boolean { - const pasmNonArgumentInstructions: string[] = ["nop", "ret"]; + const pasmNonArgumentInstructions: string[] = ['nop', 'ret']; const instructionStatus: boolean = pasmNonArgumentInstructions.indexOf(name.toLowerCase()) != -1; return instructionStatus; } @@ -1686,38 +1811,38 @@ export class Spin1ParseUtils { public isP1AsmConditional(name: string): boolean { // mark these RED if seen in P2 code const p1AsmConditions: string[] = [ - "if_always", - "if_never", - "if_e", - "if_ne", - "if_a", - "if_b", - "if_ae", - "if_be", - "if_c", - "if_nc", - "if_z", - "if_nz", - "if_c_eq_z", - "if_c_ne_z", - "if_c_and_z", - "if_c_and_nz", - "if_nc_and_z", - "if_nc_and_nz", - "if_c_or_z", - "if_c_or_nz", - "if_nc_or_z", - "if_nc_or_nz", - "if_z_eq_c", - "if_z_ne_c", - "if_z_and_c", - "if_z_and_nc", - "if_nz_and_c", - "if_nz_and_nc", - "if_z_or_c", - "if_z_or_nc", - "if_nz_or_c", - "if_nz_or_nc", + 'if_always', + 'if_never', + 'if_e', + 'if_ne', + 'if_a', + 'if_b', + 'if_ae', + 'if_be', + 'if_c', + 'if_nc', + 'if_z', + 'if_nz', + 'if_c_eq_z', + 'if_c_ne_z', + 'if_c_and_z', + 'if_c_and_nz', + 'if_nc_and_z', + 'if_nc_and_nz', + 'if_c_or_z', + 'if_c_or_nz', + 'if_nc_or_z', + 'if_nc_or_nz', + 'if_z_eq_c', + 'if_z_ne_c', + 'if_z_and_c', + 'if_z_and_nc', + 'if_nz_and_c', + 'if_nz_and_nc', + 'if_z_or_c', + 'if_z_or_nc', + 'if_nz_or_c', + 'if_nz_or_nc' ]; const conditionStatus: boolean = p1AsmConditions.indexOf(name.toLowerCase()) != -1; return conditionStatus; @@ -1727,7 +1852,7 @@ export class Spin1ParseUtils { let returnStatus: boolean = false; if (name.length >= 2) { const checkType: string = name.toUpperCase(); - if (checkType == "WC" || checkType == "WZ" || checkType == "NR" || checkType == "WR") { + if (checkType == 'WC' || checkType == 'WZ' || checkType == 'NR' || checkType == 'WR') { returnStatus = true; } } @@ -1737,15 +1862,15 @@ export class Spin1ParseUtils { public isDatOrPAsmLabel(name: string): boolean { let haveLabelStatus: boolean = false; if (name.length > 0) { - haveLabelStatus = name.charAt(0).match(/[a-zA-Z_\.\:]/) ? true : false; + haveLabelStatus = name.charAt(0).match(/[a-zA-Z_.:]/) ? true : false; if (haveLabelStatus) { if (this.isDatNFileStorageType(name)) { haveLabelStatus = false; - } else if (name.toLowerCase() == "dat") { + } else if (name.toLowerCase() == 'dat') { haveLabelStatus = false; } else if (this.isP1AsmReservedSymbols(name)) { haveLabelStatus = false; - } else if (name.toUpperCase().startsWith("IF_")) { + } else if (name.toUpperCase().startsWith('IF_')) { haveLabelStatus = false; } else if (this.isP1AsmEffect(name)) { haveLabelStatus = false; @@ -1761,10 +1886,12 @@ export class Spin1ParseUtils { // compatibility methods always return false + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isP1AsmVariable(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isDebugInvocation(name: string): boolean { return false; } @@ -1772,126 +1899,142 @@ export class Spin1ParseUtils { public isP2SpinMethod(name: string): boolean { // mark these RED if seen in P2 code const p2spinMethods: string[] = [ - "hubset", - "clkset", - "cogspin", - "coginit", - "cogstop", - "cogchk", - "locktry", - "lockrel", - "lockchk", - "cogatn", - "pollatn", - "waitatn", - "send", - "recv", - "pinw", - "pinl", - "pinh", - "pint", - "pinf", - "pinr", - "pinwrite", - "pinlow", - "pinhigh", - "pintoggle", - "pinfloat", - "pinread", - "pinstart", - "pinclear", - "wrpin", - "wxpin", - "wypin", - "akpin", - "rdpin", - "rqpin", - "getct", - "getsec", - "getms", - "pollct", - "waitct", - "waitus", - "waitms", - "rotxy", - "polxy", - "xypol", - "qsin", - "qcos", - "muldiv64", - "getrnd", - "nan", - "getregs", - "setregs", - "getcrc", - "regload", - "regexec", - "strcopy", + 'hubset', + 'clkset', + 'cogspin', + 'coginit', + 'cogstop', + 'cogchk', + 'locktry', + 'lockrel', + 'lockchk', + 'cogatn', + 'pollatn', + 'waitatn', + 'send', + 'recv', + 'pinw', + 'pinl', + 'pinh', + 'pint', + 'pinf', + 'pinr', + 'pinwrite', + 'pinlow', + 'pinhigh', + 'pintoggle', + 'pinfloat', + 'pinread', + 'pinstart', + 'pinclear', + 'wrpin', + 'wxpin', + 'wypin', + 'akpin', + 'rdpin', + 'rqpin', + 'getct', + 'getsec', + 'getms', + 'pollct', + 'waitct', + 'waitus', + 'waitms', + 'rotxy', + 'polxy', + 'xypol', + 'qsin', + 'qcos', + 'muldiv64', + 'getrnd', + 'nan', + 'getregs', + 'setregs', + 'getcrc', + 'regload', + 'regexec', + 'strcopy' ]; const instructionStatus: boolean = p2spinMethods.indexOf(name.toLowerCase()) != -1; return instructionStatus; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isP2AsmReservedWord(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isP2AsmReservedSymbols(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isP2AsmInstruction(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isDebugDisplayType(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isDebugMethod(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isDebugControlSymbol(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isAlignType(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isP2AsmEffect(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isCoginitReservedSymbol(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isP2AsmModczOperand(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isSpinSpecialMethod(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isSpinNoparenMethod(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isIllegalInlinePAsmDirective(name: string): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isNameWithTypeInstantiation(newParameter: string, displayType: eDebugDisplayType): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isNameWithTypeFeed(newParameter: string, displayType: eDebugDisplayType): boolean { return false; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public isDebugColorName(name: string): boolean { return false; } @@ -1903,19 +2046,26 @@ export class Spin1ParseUtils { //this._logMessage(" -- gdnwlp nonDblStringLine=[" + nonDblStringLine + "]"); const nonSglStringLine: string = nonDblStringLine; // dummy for the following: this.removeDebugSingleQuotedStrings(nonDblStringLine, false); //this._logMessage(" -- gdnwlp nonSglStringLine=[" + nonSglStringLine + "]"); - let lineParts: string[] | null = nonSglStringLine.match(/[^ ,@\[\]\=\.\+\-\*\/\:\#\<\>\|\^\&\t\(\)\!\?\~]+/g); + const lineParts: string[] | null = nonSglStringLine.match(/[^ ,@[\]=.+\-*/:#<>|^&\t()!?~]+/g); //let lineParts: string[] | null = line.match(/[^ ,@\[\]\+\-\*\/\<\>\t\(\)]+/g); return lineParts == null ? [] : lineParts; } public getNonWhiteNOperatorLineParts(line: string): string[] { - let lineParts: string[] | null = line.match(/[^ \t\-\+\<\>]+/g); + const lineParts: string[] | null = line.match(/[^ \t\-+<>]+/g); return lineParts == null ? [] : lineParts; } // not used in spin1 + // eslint-disable-next-line @typescript-eslint/no-unused-vars public docTextForDebugBuiltIn(name: string): IBuiltinDescription { - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; return desiredDocText; } diff --git a/spin2/server/src/parser/spin2.documentSemanticParser.ts b/spin2/server/src/parser/spin2.documentSemanticParser.ts index 22dabbd..3edf95f 100644 --- a/spin2/server/src/parser/spin2.documentSemanticParser.ts +++ b/spin2/server/src/parser/spin2.documentSemanticParser.ts @@ -1,13 +1,22 @@ -"use strict"; +'use strict'; // src/spin2.documentSemanticParser.ts -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Position } from "vscode-languageserver-types"; -import { Context, ServerBehaviorConfiguration, EditorConfiguration } from "../context"; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Position } from 'vscode-languageserver-types'; +import { Context, ServerBehaviorConfiguration, EditorConfiguration } from '../context'; -import { DocumentFindings, RememberedComment, eCommentType, RememberedToken, eBLockType, IParsedToken, eSeverity, eDefinitionType } from "./spin.semantic.findings"; -import { Spin2ParseUtils } from "./spin2.utils"; -import { isSpin1File } from "./lang.utils"; +import { + DocumentFindings, + RememberedComment, + eCommentType, + RememberedToken, + eBLockType, + IParsedToken, + eSeverity, + eDefinitionType +} from './spin.semantic.findings'; +import { Spin2ParseUtils } from './spin2.utils'; +import { isSpin1File } from './lang.utils'; import { eParseState, eDebugDisplayType, @@ -18,27 +27,30 @@ import { isMethodCall, containsSpinLanguageSpec, versionFromSpinLanguageSpec, -} from "./spin.common"; -import { fileInDirExists } from "../files"; + isMethodCallEmptyParens +} from './spin.common'; +import { fileInDirExists } from '../files'; //import { PublishDiagnosticsNotification } from "vscode-languageserver"; -import { ExtensionUtils } from "../parser/spin.extension.utils"; +import { ExtensionUtils } from '../parser/spin.extension.utils'; //import { channel } from "diagnostics_channel"; // ---------------------------------------------------------------------------- // Semantic Highlighting Provider // -const tokenTypes = new Map(); -const tokenModifiers = new Map(); +//const tokenTypes = new Map(); +//const tokenModifiers = new Map(); interface IFilteredStrings { lineNoQuotes: string; lineParts: string[]; } +/* enum eSpin2Directive { Unknown = 0, - s2dDebugDisplayForLine, + s2dDebugDisplayForLine } +*/ interface ISpin2Directive { lineNumber: number; displayType: string; @@ -74,10 +86,10 @@ export class Spin2DocumentSemanticParser { private configuration: ServerBehaviorConfiguration; private editorConfiguration: EditorConfiguration; - private currentMethodName: string = ""; - private currentFilespec: string = ""; + private currentMethodName: string = ''; + private currentFilespec: string = ''; private isSpin1Document: boolean = false; - private directory: string = ""; + private directory: string = ''; private bRecordTrailingComments: boolean = false; // initially, we don't generate tokens for trailing comments on lines private bHuntingForVersion: boolean = true; // initially we re hunting for a {Spin2_v##} spec in file-top comments @@ -90,9 +102,9 @@ export class Spin2DocumentSemanticParser { if (this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin2 semantic log started."); + this._logMessage('Spin2 semantic log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -112,7 +124,7 @@ export class Spin2DocumentSemanticParser { } this.configuration = this.ctx.parserConfig; // ensure we have latest this.isSpin1Document = isSpin1File(document.uri); - this._logMessage("* Config: highlightFlexspinDirectives: [" + this.configuration.highlightFlexspinDirectives + "]"); + this._logMessage('* Config: highlightFlexspinDirectives: [' + this.configuration.highlightFlexspinDirectives + ']'); this.currentFilespec = document.uri; this._logMessage(`* reportDocumentSemanticTokens(${this.currentFilespec})`); this._logMessage(`* ------ into findings=[${findings.instanceName()}]`); @@ -178,7 +190,7 @@ export class Spin2DocumentSemanticParser { const DOC_COMMENT = true; const NONDOC_COMMENT = false; const BLOCK_COMMENT = true; - const LINE_COMMENT = false; + //const LINE_COMMENT = false; for (let i = 0; i < lines.length; i++) { const lineNbr: number = i + 1; @@ -201,8 +213,8 @@ export class Spin2DocumentSemanticParser { const lineWOutInlineComments: string = this.parseUtils.getLineWithoutInlineComments(line); const bHaveLineToProcess: boolean = lineWOutInlineComments.length > 0; //this._logMessage(` -- Ln#${lineNbr} bHaveLineToProcess=(${bHaveLineToProcess}), lineWOutInlineComments=[${lineWOutInlineComments}](${lineWOutInlineComments.length})`); - const nonCommentLine: string = bHaveLineToProcess ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments) : ""; - let trimmedNonCommentLine: string = bHaveLineToProcess ? nonCommentLine.trimStart() : ""; + const nonCommentLine: string = bHaveLineToProcess ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments) : ''; + let trimmedNonCommentLine: string = bHaveLineToProcess ? nonCommentLine.trimStart() : ''; //this._logMessage(` -- Ln#${lineNbr} CHK trimmedNonCommentLine=[${trimmedNonCommentLine}](${trimmedNonCommentLine.length})`); const offSet: number = trimmedNonCommentLine.length > 0 ? line.indexOf(trimmedNonCommentLine) + 1 : line.indexOf(trimmedLine) + 1; const tempComment: string = line.substring(trimmedNonCommentLine.length + offSet).trim(); @@ -245,7 +257,7 @@ export class Spin2DocumentSemanticParser { // now start our processing if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - let closingOffset = lineWOutInlineComments.indexOf("}}"); + const closingOffset = lineWOutInlineComments.indexOf('}}'); let commentLen: number = line.length; if (closingOffset != -1) { commentLen = closingOffset + 2; @@ -276,7 +288,7 @@ export class Spin2DocumentSemanticParser { } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit // ALLOW {...} on same line without closing! - const closingOffset: number = lineWOutInlineComments.indexOf("}"); + const closingOffset: number = lineWOutInlineComments.indexOf('}'); if (closingOffset != -1) { // have close, comment ended // end the comment recording @@ -334,15 +346,15 @@ export class Spin2DocumentSemanticParser { currSingleLineBlockComment = new RememberedComment(eCommentType.singleLineComment, i, line); } continue; - } else if (trimmedNonCommentLine.startsWith("{{")) { + } else if (trimmedNonCommentLine.startsWith('{{')) { // TODO: the second if clause confuses me... why did I do this? // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this // record new single-line comment - let oneLineComment = new RememberedComment(eCommentType.multiLineDocComment, i, line); + const oneLineComment = new RememberedComment(eCommentType.multiLineDocComment, i, line); oneLineComment.closeAsSingleLine(); if (!oneLineComment.isBlankLine) { this._logMessage(` -- found comment ${oneLineComment.spanString()}`); @@ -361,12 +373,12 @@ export class Spin2DocumentSemanticParser { //this._recordToken(tokenSet, line, this._generateComentToken(i, 0, line.length, BLOCK_COMMENT, DOC_COMMENT, line)); continue; // only SKIP if we don't have closing marker } - } else if (trimmedNonCommentLine.startsWith("{")) { + } else if (trimmedNonCommentLine.startsWith('{')) { // TODO: the second if clause confuses me... why did I do this? // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line comment, we can have Spin2 Directive in here this._getSpin2_Directive(0, lineNbr, line); @@ -382,10 +394,10 @@ export class Spin2DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this continue; // only SKIP if we don't have closing marker } - } else if (trimmedNonCommentLine.includes("{{")) { + } else if (trimmedNonCommentLine.includes('{{')) { // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset == -1) { // is open of multiline comment without CLOSE priorState = currState; @@ -395,15 +407,19 @@ export class Spin2DocumentSemanticParser { currBlockComment = new RememberedComment(eCommentType.multiLineDocComment, i, line); // DO NOTHING Let Syntax highlighting do this // Mark comment line - this._recordToken(tokenSet, line, this._generateComentToken(i, openingOffset, line.length - openingOffset, BLOCK_COMMENT, DOC_COMMENT, line)); + this._recordToken( + tokenSet, + line, + this._generateComentToken(i, openingOffset, line.length - openingOffset, BLOCK_COMMENT, DOC_COMMENT, line) + ); //continue; // DON'T SKIP, process rest of line } - } else if (trimmedNonCommentLine.includes("{") && !trimmedNonCommentLine.includes("{{")) { + } else if (trimmedNonCommentLine.includes('{') && !trimmedNonCommentLine.includes('{{')) { /// FIXME: TODO: this needs to be searching in non-string-containing line // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment (with NO closing) priorState = currState; @@ -425,7 +441,7 @@ export class Spin2DocumentSemanticParser { if (currState == eParseState.inDatPAsm) { this.semanticFindings.recordPasmEnd(i - 1); currState = prePAsmState; - this._logState("- scan Ln#" + lineNbr + " POP currState=[" + currState + "]"); + this._logState('- scan Ln#' + lineNbr + ' POP currState=[' + currState + ']'); } if (currState == eParseState.inPub || currState == eParseState.inPri) { @@ -463,17 +479,20 @@ export class Spin2DocumentSemanticParser { newBlockType = eBLockType.isPri; } this.semanticFindings.recordBlockStart(newBlockType, i); // start new one which ends prior - this._logState("- scan Ln#" + lineNbr + " currState=[" + currState + "]"); + this._logState('- scan Ln#' + lineNbr + ' currState=[' + currState + ']'); } // ---------------------------------------------- // gather our multi-line set if line is continued // ---------------------------------------------- // - const isContinued: boolean = trimmedNonCommentLine.length > 0 ? trimmedNonCommentLine.endsWith("...") : false; - let continuedSectionStatus = { isSectionStart: false, inProgressStatus: eParseState.Unknown }; + const isContinued: boolean = trimmedNonCommentLine.length > 0 ? trimmedNonCommentLine.endsWith('...') : false; + let continuedSectionStatus = { + isSectionStart: false, + inProgressStatus: eParseState.Unknown + }; if (isContinued || (continuedLineSet.isLoading && trimmedNonCommentLine.length > 0)) { - const lineOffset: number = line.indexOf(trimmedNonCommentLine); + //const lineOffset: number = line.indexOf(trimmedNonCommentLine); continuedLineSet.addLine(nonCommentLine, i); if (!continuedLineSet.hasAllLines) { continue; // need to gather next line too @@ -495,7 +514,7 @@ export class Spin2DocumentSemanticParser { if (docComment.type != eCommentType.Unknown) { this.semanticFindings.recordFakeComment(docComment); } else { - this._logState("- scan Ln#" + lineNbr + " no FAKE doc comment for this signature"); + this._logState('- scan Ln#' + lineNbr + ' no FAKE doc comment for this signature'); } } } else if (currState == eParseState.inCon) { @@ -506,11 +525,11 @@ export class Spin2DocumentSemanticParser { } else if (currState == eParseState.inDat) { // process a class(static) variable line this._logPASM(`- process DAT SECTION Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`); - if (trimmedNonCommentLine.length > 6 && trimmedNonCommentLine.toUpperCase().includes("ORG")) { + if (trimmedNonCommentLine.length > 6 && trimmedNonCommentLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedNonCommentLine); - if (nonStringLine.toUpperCase().includes("ORG")) { - this._logPASM("- Ln#" + lineNbr + " pre-scan DAT line trimmedLine=[" + trimmedLine + "] now Dat PASM"); + if (nonStringLine.toUpperCase().includes('ORG')) { + this._logPASM('- Ln#' + lineNbr + ' pre-scan DAT line trimmedLine=[' + trimmedLine + '] now Dat PASM'); // record start of PASM code NOT inline this.semanticFindings.recordPasmStart(i, false); prePAsmState = currState; @@ -548,7 +567,7 @@ export class Spin2DocumentSemanticParser { //this._logPASM(` -- parsingContinuedLineSet=(${parsingContinuedLineSet})`); if (currState == eParseState.inCon) { - const nonCommentLength: number = parsingContinuedLineSet ? continuedLineSet.line.length : trimmedNonCommentLine.length; + //const nonCommentLength: number = parsingContinuedLineSet ? continuedLineSet.line.length : trimmedNonCommentLine.length; // process a constant non-continued line if (parsingContinuedLineSet && continuedLineSet.line.length > 0) { const lineOffset: number = continuedSectionStatus.isSectionStart ? 3 : 0; @@ -560,10 +579,10 @@ export class Spin2DocumentSemanticParser { // process a data line this._logPASM(`- check DAT Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`); if (bHaveLineToProcess) { - if (trimmedLine.toUpperCase().includes("ORG")) { + if (trimmedLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedLine); - if (nonStringLine.toUpperCase().includes("ORG")) { + if (nonStringLine.toUpperCase().includes('ORG')) { this._logPASM(`- Ln#${lineNbr} pre-scan DAT line trimmedLine=[${trimmedLine}] now Dat PASM`); // record start of PASM code NOT inline this.semanticFindings.recordPasmStart(i, false); @@ -593,12 +612,12 @@ export class Spin2DocumentSemanticParser { // process pasm (assembly) lines if (bHaveLineToProcess) { const lineParts: string[] = trimmedLine.split(/[ \t]/).filter(Boolean); - if (lineParts.length > 0 && (lineParts[0].toUpperCase() == "END" || lineParts[0].toUpperCase() == "ENDASM")) { - this._logPASM("- Ln#" + lineNbr + " pre-scan SPIN PASM line trimmedLine=[" + trimmedLine + "]"); + if (lineParts.length > 0 && (lineParts[0].toUpperCase() == 'END' || lineParts[0].toUpperCase() == 'ENDASM')) { + this._logPASM('- Ln#' + lineNbr + ' pre-scan SPIN PASM line trimmedLine=[' + trimmedLine + ']'); // record start of PASM code inline this.semanticFindings.recordPasmEnd(i); currState = prePAsmState; - this._logState("- scan Ln#" + lineNbr + " POP currState=[" + currState + "]"); + this._logState('- scan Ln#' + lineNbr + ' POP currState=[' + currState + ']'); // and ignore rest of this line } else { this._getSPIN_PAsmDeclaration(0, lineNbr, line); @@ -628,7 +647,7 @@ export class Spin2DocumentSemanticParser { const trimmedLineToParse: string = parsingContinuedLineSet ? continuedLineSet.line : trimmedNonCommentLine; const isDebugLine: boolean = haveDebugLine(trimmedLineToParse); // trimmedNonCommentLine.toLowerCase().includes("debug("); const lineParts: string[] = trimmedLineToParse.split(/[ \t]/).filter(Boolean); - if (lineParts.length > 0 && (lineParts[0].toUpperCase() == "ORG" || lineParts[0].toUpperCase() == "ASM")) { + if (lineParts.length > 0 && (lineParts[0].toUpperCase() == 'ORG' || lineParts[0].toUpperCase() == 'ASM')) { // Only ORG, not ORGF or ORGH this._logPASM(`- Ln#${lineNbr} pre-scan PUB/PRI line trimmedLine=[${trimmedLineToParse}]`); // record start of PASM code NOT inline @@ -681,8 +700,8 @@ export class Spin2DocumentSemanticParser { this.semanticFindings.finalize(); // -------------------- End of PRE-PARSE -------------------- - this._logMessage("---> <---"); - this._logMessage("---> Actual SCAN"); + this._logMessage('---> <---'); + this._logMessage('---> Actual SCAN'); this.bRecordTrailingComments = true; // from here forward generate tokens for trailing comments on lines @@ -701,8 +720,8 @@ export class Spin2DocumentSemanticParser { const lineWOutInlineComments: string = this.parseUtils.getLineWithoutInlineComments(line); const bHaveLineToProcess: boolean = lineWOutInlineComments.length > 0; //this._logMessage(` -- Ln#${lineNbr} bHaveLineToProcess=(${bHaveLineToProcess}), lineWOutInlineComments=[${lineWOutInlineComments}](${lineWOutInlineComments.length})`); - const nonCommentLine: string = bHaveLineToProcess ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments) : ""; - let trimmedNonCommentLine: string = bHaveLineToProcess ? nonCommentLine.trimStart() : ""; + const nonCommentLine: string = bHaveLineToProcess ? this.parseUtils.getRemainderWOutTrailingTicComment(0, lineWOutInlineComments) : ''; + let trimmedNonCommentLine: string = bHaveLineToProcess ? nonCommentLine.trimStart() : ''; const sectionStatus = this.extensionUtils.isSectionStartLine(line); if (sectionStatus.isSectionStart) { trimmedNonCommentLine = trimmedNonCommentLine.substring(3); @@ -712,7 +731,7 @@ export class Spin2DocumentSemanticParser { if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit // ALLOW {cmt}, {{cmt}} on same line without closing! - let closingOffset = trimmedNonCommentLine.indexOf("}}"); + const closingOffset = trimmedNonCommentLine.indexOf('}}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -725,7 +744,7 @@ export class Spin2DocumentSemanticParser { } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit // ALLOW {cmt}, {{cmt}} on same line without closing! - const closingOffset: number = lineWOutInlineComments.indexOf("}"); + const closingOffset: number = lineWOutInlineComments.indexOf('}'); if (closingOffset != -1) { // have close, comment ended currState = priorState; @@ -737,7 +756,7 @@ export class Spin2DocumentSemanticParser { } } else if (singleLineParts.length > 0 && this.parseUtils.isFlexspinPreprocessorDirective(singleLineParts[0])) { const partialTokenSet: IParsedToken[] = this._reportFlexspinPreProcessorLine(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> PreProc: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> PreProc: ', line, tokenSet); continue; // only SKIP if we have FlexSpin directive } @@ -760,10 +779,13 @@ export class Spin2DocumentSemanticParser { // OR in SPIN code // ---------------------------------------------- // - const isContinued: boolean = trimmedNonCommentLine.length > 0 ? trimmedNonCommentLine.endsWith("...") : false; - let continuedSectionStatus = { isSectionStart: false, inProgressStatus: eParseState.Unknown }; + const isContinued: boolean = trimmedNonCommentLine.length > 0 ? trimmedNonCommentLine.endsWith('...') : false; + let continuedSectionStatus = { + isSectionStart: false, + inProgressStatus: eParseState.Unknown + }; if (isContinued || (continuedLineSet.isLoading && trimmedNonCommentLine.length > 0)) { - const lineOffset: number = line.indexOf(trimmedNonCommentLine); + //const lineOffset: number = line.indexOf(trimmedNonCommentLine); continuedLineSet.addLine(nonCommentLine, i); if (!continuedLineSet.hasAllLines) { //this._logState(` -- scan Ln#${lineNbr} CONT-LINE-BUILDER SKIP [${lineWithLeadingSpaces}]`); @@ -771,7 +793,10 @@ export class Spin2DocumentSemanticParser { } // now determine if this continued line set is a section start continuedSectionStatus = this.extensionUtils.isSectionStartLine(continuedLineSet.line); - this.semanticFindings.recordContinuedLineBlock(continuedLineSet.lineStartIdx, continuedLineSet.lineStartIdx + continuedLineSet.numberLines - 1); + this.semanticFindings.recordContinuedLineBlock( + continuedLineSet.lineStartIdx, + continuedLineSet.lineStartIdx + continuedLineSet.numberLines - 1 + ); } const parsingContinuedLineSet: boolean = !continuedLineSet.isEmpty; @@ -781,10 +806,10 @@ export class Spin2DocumentSemanticParser { } else if (trimmedLine.startsWith("'")) { // process single line non-doc comment // DO NOTHING Let Syntax highlighting do this - } else if (trimmedNonCommentLine.startsWith("{{")) { + } else if (trimmedNonCommentLine.startsWith('{{')) { // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this } else { @@ -795,11 +820,11 @@ export class Spin2DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this } continue; - } else if (trimmedNonCommentLine.startsWith("{")) { + } else if (trimmedNonCommentLine.startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this } else { @@ -810,10 +835,10 @@ export class Spin2DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this } continue; - } else if (trimmedNonCommentLine.includes("{{")) { + } else if (trimmedNonCommentLine.includes('{{')) { // process multi-line doc comment - let openingOffset = trimmedNonCommentLine.indexOf("{{"); - const closingOffset = trimmedNonCommentLine.indexOf("}}", openingOffset + 2); + const openingOffset = trimmedNonCommentLine.indexOf('{{'); + const closingOffset = trimmedNonCommentLine.indexOf('}}', openingOffset + 2); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this } else { @@ -824,11 +849,11 @@ export class Spin2DocumentSemanticParser { // DO NOTHING Let Syntax highlighting do this } // don't continue there might be some text to process before the {{ - } else if (trimmedNonCommentLine.includes("{") && !trimmedNonCommentLine.includes("{{")) { + } else if (trimmedNonCommentLine.includes('{') && !trimmedNonCommentLine.includes('{{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - let openingOffset = trimmedNonCommentLine.indexOf("{"); - const closingOffset = trimmedNonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = trimmedNonCommentLine.indexOf('{'); + const closingOffset = trimmedNonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset != -1) { // is single line comment, just ignore it Let Syntax highlighting do this } else { @@ -849,7 +874,7 @@ export class Spin2DocumentSemanticParser { if (trimmedLine.length > 3) { partialTokenSet = this._reportPUB_PRI_Signature(i, 3, line); } - this._reportNonDupeTokens(partialTokenSet, "=> PUB/PRI: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> PUB/PRI: ', line, tokenSet); } else if (currState == eParseState.inCon) { // process a possible constant use on the CON line itself! let partialTokenSet: IParsedToken[] = []; @@ -858,20 +883,20 @@ export class Spin2DocumentSemanticParser { } else { this.conEnumInProgress = false; // so we can tell in CON processor when to allow isolated names } - this._reportNonDupeTokens(partialTokenSet, "=> CON: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> CON: ', line, tokenSet); } else if (currState == eParseState.inDat) { // process a possible constant use on the DAT line itself! this._logPASM(`- process DAT SECTION Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`); if (line.length > 3) { if (trimmedLine.length > 6) { const nonCommentLineRemainder: string = this.parseUtils.getNonCommentLineRemainder(0, trimmedLine); - let orgStr: string = "ORGH"; + let orgStr: string = 'ORGH'; let orgOffset: number = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGH if (orgOffset == -1) { - orgStr = "ORGF"; + orgStr = 'ORGF'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGF if (orgOffset == -1) { - orgStr = "ORG"; + orgStr = 'ORG'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORG } } @@ -881,15 +906,22 @@ export class Spin2DocumentSemanticParser { orgOffset = nonStringLine.toUpperCase().indexOf(orgStr); // ORG, ORGF, ORGH } if (orgOffset != -1) { - this._logPASM("- Ln#" + lineNbr + " scan DAT line nonCommentLineRemainder=[" + nonCommentLineRemainder + "]"); + this._logPASM('- Ln#' + lineNbr + ' scan DAT line nonCommentLineRemainder=[' + nonCommentLineRemainder + ']'); // process remainder of ORG line const nonCommentOffset = line.indexOf(nonCommentLineRemainder, 0); // lineNumber, currentOffset, line, allowLocalVarStatus, this.showPAsmCode const allowLocalVarStatus: boolean = false; const NOT_DAT_PASM: boolean = false; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(i, nonCommentOffset + orgOffset + orgStr.length, line, allowLocalVarStatus, this.showDAT, NOT_DAT_PASM); - this._reportNonDupeTokens(partialTokenSet, "=> DAT: ", line, tokenSet); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + i, + nonCommentOffset + orgOffset + orgStr.length, + line, + allowLocalVarStatus, + this.showDAT, + NOT_DAT_PASM + ); + this._reportNonDupeTokens(partialTokenSet, '=> DAT: ', line, tokenSet); prePAsmState = currState; currState = eParseState.inDatPAsm; @@ -898,20 +930,20 @@ export class Spin2DocumentSemanticParser { } } const partialTokenSet: IParsedToken[] = this._reportDAT_DeclarationLine(i, 3, line); - this._reportNonDupeTokens(partialTokenSet, "=> DAT: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> DAT: ', line, tokenSet); } } else if (currState == eParseState.inObj) { // process a possible object overrides on the OBJ line itself! let partialTokenSet: IParsedToken[] = []; if (line.length > 3) { partialTokenSet = this._reportOBJ_DeclarationLine(i, 3, line); - this._reportNonDupeTokens(partialTokenSet, "=> OBJ: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> OBJ: ', line, tokenSet); } } else if (currState == eParseState.inVar) { // process a possible constant use on the CON line itself! if (line.length > 3) { const partialTokenSet: IParsedToken[] = this._reportVAR_DeclarationLine(i, 3, line); - this._reportNonDupeTokens(partialTokenSet, "=> VAR: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> VAR: ', line, tokenSet); } } continue; @@ -929,19 +961,19 @@ export class Spin2DocumentSemanticParser { } else if (bHaveLineToProcess) { partialTokenSet = this._reportCON_DeclarationLine(i, 0, line); } - this._reportNonDupeTokens(partialTokenSet, "=> CON: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> CON: ', line, tokenSet); } else if (currState == eParseState.inDat) { // process a line in a data section this._logPASM(`- process DAT Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`); if (bHaveLineToProcess) { const nonCommentLineRemainder: string = this.parseUtils.getNonCommentLineRemainder(0, trimmedLine); - let orgStr: string = "ORGH"; + let orgStr: string = 'ORGH'; let orgOffset: number = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGH if (orgOffset == -1) { - orgStr = "ORGF"; + orgStr = 'ORGF'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORGF if (orgOffset == -1) { - orgStr = "ORG"; + orgStr = 'ORG'; orgOffset = nonCommentLineRemainder.toUpperCase().indexOf(orgStr); // ORG } } @@ -953,22 +985,22 @@ export class Spin2DocumentSemanticParser { if (orgOffset != -1) { // process ORG line allowing label to be present const partialTokenSet: IParsedToken[] = this._reportDAT_DeclarationLine(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> DAT: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> DAT: ', line, tokenSet); prePAsmState = currState; currState = eParseState.inDatPAsm; // and ignore rest of this line } else { const partialTokenSet: IParsedToken[] = this._reportDAT_DeclarationLine(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> DAT: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> DAT: ', line, tokenSet); } } } else if (currState == eParseState.inVar) { // process a line in a variable data section if (bHaveLineToProcess) { - this._logVAR("- process VAR Ln#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logVAR('- process VAR Ln#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); const partialTokenSet: IParsedToken[] = this._reportVAR_DeclarationLine(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> VAR: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> VAR: ', line, tokenSet); } } else if (currState == eParseState.inObj) { // process a line in an object section @@ -983,7 +1015,7 @@ export class Spin2DocumentSemanticParser { this._logOBJ(`- process OBJ Ln#${lineNbr} line=[${line}](${line.length})`); partialTokenSet = this._reportOBJ_DeclarationLine(i, 0, line); } - this._reportNonDupeTokens(partialTokenSet, "=> OBJ: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> OBJ: ', line, tokenSet); } else if (currState == eParseState.inDatPAsm) { // process DAT section pasm (assembly) lines this._logPASM(`- process DAT PASM Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`); @@ -991,25 +1023,25 @@ export class Spin2DocumentSemanticParser { //this._logPASM("- process DAT PASM Ln#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); // in DAT sections we end with next section const partialTokenSet: IParsedToken[] = this._reportDAT_PAsmCode(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> DAT: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> DAT: ', line, tokenSet); } } else if (currState == eParseState.inPAsmInline) { // process pasm (assembly) lines if (bHaveLineToProcess) { - this._logPASM("- process SPIN2 PASM Ln#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logPASM('- process SPIN2 PASM Ln#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); const lineParts: string[] = trimmedLine.split(/[ \t]/).filter(Boolean); - if (lineParts.length > 0 && (lineParts[0].toUpperCase() == "END" || lineParts[0].toUpperCase() == "ENDASM")) { + if (lineParts.length > 0 && (lineParts[0].toUpperCase() == 'END' || lineParts[0].toUpperCase() == 'ENDASM')) { currState = prePAsmState; - this._logState("- scan Ln#" + lineNbr + " POP currState=[" + currState + "]"); - if (lineParts[0].toUpperCase() == "ENDASM" && !this.configuration.highlightFlexspinDirectives) { + this._logState('- scan Ln#' + lineNbr + ' POP currState=[' + currState + ']'); + if (lineParts[0].toUpperCase() == 'ENDASM' && !this.configuration.highlightFlexspinDirectives) { // report this unsupported line (FlexSpin) const nameOffset: number = line.indexOf(lineParts[0]); this._recordToken(tokenSet, line, { line: lineNbr - 1, startCharacter: nameOffset, length: lineParts[0].length, - ptTokenType: "macro", - ptTokenModifiers: ["directive", "illegalUse"], + ptTokenType: 'macro', + ptTokenModifiers: ['directive', 'illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( lineNbr - 1, @@ -1022,7 +1054,7 @@ export class Spin2DocumentSemanticParser { // and ignore rest of this line } else { const partialTokenSet: IParsedToken[] = this._reportSPIN_PAsmCode(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> inlinePASM: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> inlinePASM: ', line, tokenSet); } } } else if (currState == eParseState.inPub || currState == eParseState.inPri) { @@ -1031,26 +1063,26 @@ export class Spin2DocumentSemanticParser { let partialTokenSet: IParsedToken[] = []; //this._logState(`- Ln#${lineNbr} check pub/pri sig parsingContinuedLineSet=(${parsingContinuedLineSet}), lineLength=(${continuedLineSet.line.length})`); partialTokenSet = this._reportPUB_PRI_SignatureMultiLine(3, continuedLineSet); - this._reportNonDupeTokens(partialTokenSet, "=> PUB/PRI: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> PUB/PRI: ', line, tokenSet); } else if (parsingContinuedLineSet) { // process MULTI-LINE spin statement NOT PUB/PRI line! - this._logSPIN("- process SPIN2 Ln#" + lineNbr + " trimmedLine=[" + continuedLineSet.line + "]"); + this._logSPIN('- process SPIN2 Ln#' + lineNbr + ' trimmedLine=[' + continuedLineSet.line + ']'); const lineParts: string[] = continuedLineSet.line.split(/[ \t]/).filter(Boolean); - if (lineParts.length > 0 && (lineParts[0].toUpperCase() == "ORG" || lineParts[0].toUpperCase() == "ASM")) { + if (lineParts.length > 0 && (lineParts[0].toUpperCase() == 'ORG' || lineParts[0].toUpperCase() == 'ASM')) { // Only ORG not ORGF, ORGH prePAsmState = currState; currState = eParseState.inPAsmInline; // even tho' we are processsing it as if we know it we still flag it is FrexSpin NOT Enabled - if (lineParts[0].toUpperCase() == "ASM" && !this.configuration.highlightFlexspinDirectives) { + if (lineParts[0].toUpperCase() == 'ASM' && !this.configuration.highlightFlexspinDirectives) { // report this unsupported line (FlexSpin) const symbolPosition: Position = continuedLineSet.locateSymbol(lineParts[0], 0); - const nameOffset = continuedLineSet.offsetIntoLineForPosition(symbolPosition); + //const nameOffset = continuedLineSet.offsetIntoLineForPosition(symbolPosition); this._recordToken(tokenSet, continuedLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: lineParts[0].length, - ptTokenType: "macro", - ptTokenModifiers: ["directive", "illegalUse"], + ptTokenType: 'macro', + ptTokenModifiers: ['directive', 'illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -1064,29 +1096,29 @@ export class Spin2DocumentSemanticParser { } else if (haveDebugLine(continuedLineSet.line, true)) { //} else if (trimmedLine.toLowerCase().startsWith("debug(")) { const partialTokenSet: IParsedToken[] = this._reportDebugStatementMultiLine(0, continuedLineSet); - this._reportNonDupeTokens(partialTokenSet, "=> DEBUG: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> DEBUG: ', line, tokenSet); } else { const partialTokenSet: IParsedToken[] = this._reportSPIN_CodeMultiLine(0, continuedLineSet); - this._reportNonDupeTokens(partialTokenSet, "=> SPIN: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> SPIN: ', line, tokenSet); } } else if (bHaveLineToProcess) { // process a method def'n line - this._logSPIN("- process SPIN2 Ln#" + lineNbr + " trimmedLine=[" + trimmedLine + "]"); + this._logSPIN('- process SPIN2 Ln#' + lineNbr + ' trimmedLine=[' + trimmedLine + ']'); const lineParts: string[] = trimmedLine.split(/[ \t]/).filter(Boolean); - if (lineParts.length > 0 && (lineParts[0].toUpperCase() == "ORG" || lineParts[0].toUpperCase() == "ASM")) { + if (lineParts.length > 0 && (lineParts[0].toUpperCase() == 'ORG' || lineParts[0].toUpperCase() == 'ASM')) { // Only ORG not ORGF, ORGH prePAsmState = currState; currState = eParseState.inPAsmInline; // even tho' we are processsing it as if we know it we still flag it is FrexSpin NOT Enabled - if (lineParts[0].toUpperCase() == "ASM" && !this.configuration.highlightFlexspinDirectives) { + if (lineParts[0].toUpperCase() == 'ASM' && !this.configuration.highlightFlexspinDirectives) { // report this unsupported line (FlexSpin) const nameOffset: number = line.indexOf(lineParts[0]); this._recordToken(tokenSet, line, { line: lineNbr - 1, startCharacter: nameOffset, length: lineParts[0].length, - ptTokenType: "macro", - ptTokenModifiers: ["directive", "illegalUse"], + ptTokenType: 'macro', + ptTokenModifiers: ['directive', 'illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( lineNbr - 1, @@ -1100,10 +1132,10 @@ export class Spin2DocumentSemanticParser { } else if (haveDebugLine(trimmedLine, true)) { //} else if (trimmedLine.toLowerCase().startsWith("debug(")) { const partialTokenSet: IParsedToken[] = this._reportDebugStatement(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> DEBUG: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> DEBUG: ', line, tokenSet); } else { const partialTokenSet: IParsedToken[] = this._reportSPIN_Code(i, 0, line); - this._reportNonDupeTokens(partialTokenSet, "=> SPIN: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> SPIN: ', line, tokenSet); } } } @@ -1118,32 +1150,34 @@ export class Spin2DocumentSemanticParser { } private _generateFakeCommentForSignature(startingOffset: number, lineNbr: number, line: string): RememberedComment { - if (startingOffset) { - } // kill warning - let desiredComment: RememberedComment = new RememberedComment(eCommentType.Unknown, -1, ""); + let desiredComment: RememberedComment = new RememberedComment(eCommentType.Unknown, -1, ''); const linePrefix: string = line.substring(0, 3).toLowerCase(); - const isSignature: boolean = linePrefix == "pub" || linePrefix == "pri" ? true : false; - const isPri: boolean = linePrefix == "pri" ? true : false; - this._logSPIN(" -- gfcfs linePrefix=[" + linePrefix + "](" + linePrefix.length + ")" + `, isSignature=${isSignature}, isPri=${isPri}`); + const isSignature: boolean = linePrefix == 'pub' || linePrefix == 'pri' ? true : false; + const isPri: boolean = linePrefix == 'pri' ? true : false; + this._logSPIN(' -- gfcfs linePrefix=[' + linePrefix + '](' + linePrefix.length + ')' + `, isSignature=${isSignature}, isPri=${isPri}`); if (isSignature) { const cmtType: eCommentType = isPri ? eCommentType.multiLineComment : eCommentType.multiLineDocComment; - let tmpDesiredComment: RememberedComment = new RememberedComment(cmtType, lineNbr, "NOTE: insert comment template by pressing Ctrl+Alt+C on PRI signature line, then fill it in."); + const tmpDesiredComment: RememberedComment = new RememberedComment( + cmtType, + lineNbr, + 'NOTE: insert comment template by pressing Ctrl+Alt+C on PRI signature line, then fill it in.' + ); const signatureComment: string[] = this._generateDocCommentForSignature(line, this.isSpin1Document); if (signatureComment && signatureComment.length > 0) { let lineCount: number = 1; // count our comment line on creation for (let cmtIdx = 0; cmtIdx < signatureComment.length; cmtIdx++) { const currCmtLine: string = signatureComment[cmtIdx]; - if (currCmtLine.includes("@param")) { - tmpDesiredComment.appendLine(currCmtLine + "no parameter comment found"); + if (currCmtLine.includes('@param')) { + tmpDesiredComment.appendLine(currCmtLine + 'no parameter comment found'); lineCount++; // count this line, too } } tmpDesiredComment.closeAsSingleLineBlock(lineNbr + lineCount - 1); // FIXME: lineNbr - 1? if (lineCount > 1) { desiredComment = tmpDesiredComment; // only return this if we have params! - this._logSPIN("=> SPIN: generated signature comment: sig=[" + line + "]"); + this._logSPIN('=> SPIN: generated signature comment: sig=[' + line + ']'); } else { - this._logSPIN("=> SPIN: SKIPped generation of signature comment: sig=[" + line + "]"); + this._logSPIN('=> SPIN: SKIPped generation of signature comment: sig=[' + line + ']'); } } } @@ -1151,17 +1185,17 @@ export class Spin2DocumentSemanticParser { } private _generateDocCommentForSignature(signatureLine: string, isSpin1Method: boolean): string[] { - let desiredDocComment: string[] = []; + const desiredDocComment: string[] = []; this._logMessage(`* iDc SKIP - generateDocCommentForSignature([${signatureLine}], isSpin1=${isSpin1Method})`); - const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ""; - const isSignature: boolean = linePrefix.startsWith("pub") || linePrefix.startsWith("pri"); - const isPRI: boolean = linePrefix.startsWith("pri"); + const linePrefix = signatureLine.length > 3 ? signatureLine.substring(0, 3).toLowerCase() : ''; + const isSignature: boolean = linePrefix.startsWith('pub') || linePrefix.startsWith('pri'); + const isPRI: boolean = linePrefix.startsWith('pri'); if (isSignature) { const commentPrefix = isPRI ? "'" : "''"; - desiredDocComment.push(commentPrefix + " ..."); // for description - desiredDocComment.push(commentPrefix + " "); // blank line - const posOpenParen = signatureLine.indexOf("("); - const posCloseParen = signatureLine.indexOf(")"); + desiredDocComment.push(commentPrefix + ' ...'); // for description + desiredDocComment.push(commentPrefix + ' '); // blank line + const posOpenParen = signatureLine.indexOf('('); + const posCloseParen = signatureLine.indexOf(')'); // if we have name() it's spin1 or spin2 if (posOpenParen != -1 && posCloseParen != -1) { const bHasParameters: boolean = posCloseParen - posOpenParen > 1 ? true : false; @@ -1174,11 +1208,11 @@ export class Spin2DocumentSemanticParser { desiredDocComment.push(commentPrefix + ` @param ${paramNames[paramIdx]} - `); // blank line } } - const bHasReturnValues: boolean = signatureLine.includes(":") ? true : false; - const bHasLocalVariables: boolean = signatureLine.includes("|") ? true : false; + const bHasReturnValues: boolean = signatureLine.includes(':') ? true : false; + const bHasLocalVariables: boolean = signatureLine.includes('|') ? true : false; if (bHasReturnValues) { - const posStartReturn = signatureLine.indexOf(":") + 1; - const posEndReturn = bHasLocalVariables ? signatureLine.indexOf("|") - 1 : signatureLine.length; + const posStartReturn = signatureLine.indexOf(':') + 1; + const posEndReturn = bHasLocalVariables ? signatureLine.indexOf('|') - 1 : signatureLine.length; const returnsString: string = signatureLine.substring(posStartReturn, posEndReturn); const numberReturns: number = (returnsString.match(/,/g) || []).length + 1; const returnNames = returnsString.split(/[ \t,]/).filter(Boolean); @@ -1189,17 +1223,17 @@ export class Spin2DocumentSemanticParser { } let posTrailingComment = signatureLine.indexOf("'"); if (posTrailingComment == -1) { - posTrailingComment = signatureLine.indexOf("{"); + posTrailingComment = signatureLine.indexOf('{'); } if (bHasLocalVariables) { // locals are always non-doc single-line comments - const posStartLocal = signatureLine.indexOf("|") + 1; + const posStartLocal = signatureLine.indexOf('|') + 1; const posEndLocal = posTrailingComment != -1 ? posTrailingComment : signatureLine.length; const localsString: string = signatureLine.substring(posStartLocal, posEndLocal); const numberLocals: number = (localsString.match(/,/g) || []).length + 1; const localsNames = localsString.split(/[ \t,]/).filter(Boolean); this._logMessage(`* gDClocalsString=[${localsString}], localsNames=[${localsNames}]`); - desiredDocComment.push(""); // empty line so following is not shown in comments for method + desiredDocComment.push(''); // empty line so following is not shown in comments for method desiredDocComment.push("' Local Variables:"); // blank line for (let localIdx = 0; localIdx < numberLocals; localIdx++) { desiredDocComment.push("'" + ` @local ${localsNames[localIdx]} - `); // blank line @@ -1207,11 +1241,11 @@ export class Spin2DocumentSemanticParser { } } else if (isSpin1Method) { // spin1 methods don't need parens when no parameters are specified - const bHasReturnValues: boolean = signatureLine.includes(":") ? true : false; - const bHasLocalVariables: boolean = signatureLine.includes("|") ? true : false; + const bHasReturnValues: boolean = signatureLine.includes(':') ? true : false; + const bHasLocalVariables: boolean = signatureLine.includes('|') ? true : false; if (bHasReturnValues) { - const posStartReturn = signatureLine.indexOf(":") + 1; - const posEndReturn = bHasLocalVariables ? signatureLine.indexOf("|") - 1 : signatureLine.length; + const posStartReturn = signatureLine.indexOf(':') + 1; + const posEndReturn = bHasLocalVariables ? signatureLine.indexOf('|') - 1 : signatureLine.length; const returnsString: string = signatureLine.substring(posStartReturn, posEndReturn); // spin1 only allows 1 return variable const returnNames = returnsString.split(/[ \t,]/).filter(Boolean); @@ -1220,17 +1254,17 @@ export class Spin2DocumentSemanticParser { } let posTrailingComment = signatureLine.indexOf("'"); if (posTrailingComment == -1) { - posTrailingComment = signatureLine.indexOf("{"); + posTrailingComment = signatureLine.indexOf('{'); } if (bHasLocalVariables) { // locals are always non-doc single-line comments - const posStartLocal = signatureLine.indexOf("|") + 1; + const posStartLocal = signatureLine.indexOf('|') + 1; const posEndLocal = posTrailingComment != -1 ? posTrailingComment : signatureLine.length; const localsString: string = signatureLine.substring(posStartLocal, posEndLocal); const numberLocals: number = (localsString.match(/,/g) || []).length + 1; const localsNames = localsString.split(/[ \t,]/).filter(Boolean); this._logMessage(`* gDClocalsString=[${localsString}], localsNames=[${localsNames}]`); - desiredDocComment.push(""); // empty line so following is not shown in comments for method + desiredDocComment.push(''); // empty line so following is not shown in comments for method desiredDocComment.push("' Local Variables:"); // blank line for (let localIdx = 0; localIdx < numberLocals; localIdx++) { desiredDocComment.push("'" + ` @local ${localsNames[localIdx]} - `); // blank line @@ -1244,18 +1278,18 @@ export class Spin2DocumentSemanticParser { private _getSpin2_Directive(startingOffset: number, lineNbr: number, line: string): void { // HAVE {-* VSCode-Spin2: nextline debug()-display: bitmap *-} // (only this one so far) - if (line.toLowerCase().indexOf("{-* vscode-spin2:") != -1) { - this._logMessage("- _getSpin2_Directive: ofs:" + startingOffset + ", [" + line + "](" + line.length + ")"); + if (line.toLowerCase().indexOf('{-* vscode-spin2:') != -1) { + this._logMessage('- _getSpin2_Directive: ofs:' + startingOffset + ', [' + line + '](' + line.length + ')'); // have possible directive - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one - let lineParts: string[] = line + const lineParts: string[] = line .substring(currentOffset) .toLowerCase() .split(/[ \t,]/) .filter((element) => element); - this._logMessage(" -- lineParts=[" + lineParts + "](" + lineParts.length + ")"); - if (lineParts.length > 4 && lineParts[3] == "debug()-display:") { + this._logMessage(' -- lineParts=[' + lineParts + '](' + lineParts.length + ')'); + if (lineParts.length > 4 && lineParts[3] == 'debug()-display:') { for (let index = 4; index < lineParts.length - 1; index++) { const displayType: string = lineParts[index]; this._recordDisplayTypeForLine(displayType, lineNbr); @@ -1266,20 +1300,24 @@ export class Spin2DocumentSemanticParser { private _getFlexspinPreProcessor_Declaration(startingOffset: number, lineNbr: number, line: string): void { if (this.configuration.highlightFlexspinDirectives) { - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const nonCommentConstantLine = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (nonCommentConstantLine.length > 0) { // get line parts - we only care about first one const lineParts: string[] = nonCommentConstantLine.split(/[ \t=]/).filter(Boolean); - this._logPreProc(" - Ln#" + lineNbr + " GetPreProcDecl lineParts=[" + lineParts + "]"); + this._logPreProc(' - Ln#' + lineNbr + ' GetPreProcDecl lineParts=[' + lineParts + ']'); const directive: string = lineParts[0]; const symbolName: string | undefined = lineParts.length > 1 ? lineParts[1] : undefined; if (this.parseUtils.isFlexspinPreprocessorDirective(directive)) { // check a valid preprocessor line for a declaration - if (symbolName != undefined && directive.toLowerCase() == "#define") { - this._logPreProc(" -- new PreProc Symbol=[" + symbolName + "]"); + if (symbolName != undefined && directive.toLowerCase() == '#define') { + this._logPreProc(' -- new PreProc Symbol=[' + symbolName + ']'); this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(symbolName, new RememberedToken("variable", lineNbr - 1, 0, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + symbolName, + new RememberedToken('variable', lineNbr - 1, 0, ['readonly']), + this._declarationComment() + ); } } } @@ -1291,7 +1329,11 @@ export class Spin2DocumentSemanticParser { // -or- _clkfreq = CLK_FREQ ' set system clock // NEW: multi line enums with no punctuation, ends at blank line (uses this.conEnumInProgress) // - this._logCON(` - Ln#${multiLineSet.lineStartIdx + 1} GetCONDeclMulti startingOffset=(${startingOffset}), line=[${multiLineSet.line}](${multiLineSet.line.length})`); + this._logCON( + ` - Ln#${multiLineSet.lineStartIdx + 1} GetCONDeclMulti startingOffset=(${startingOffset}), line=[${multiLineSet.line}](${ + multiLineSet.line.length + })` + ); if (multiLineSet.line.substring(startingOffset).length > 1) { //skip Past Whitespace //let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); @@ -1302,7 +1344,7 @@ export class Spin2DocumentSemanticParser { } else { this._logCON(` -- GetCONDeclMulti nonCommentConstantLine=[${nonCommentConstantLine}](${nonCommentConstantLine.length})`); const haveEnumDeclaration: boolean = this._isEnumDeclarationLine(multiLineSet.lineStartIdx, 0, nonCommentConstantLine); - const isAssignment: boolean = nonCommentConstantLine.indexOf("=") != -1; + const isAssignment: boolean = nonCommentConstantLine.indexOf('=') != -1; if (!haveEnumDeclaration && isAssignment) { this.conEnumInProgress = false; } else { @@ -1310,33 +1352,37 @@ export class Spin2DocumentSemanticParser { } this._logCON(` -- GetCONDeclMulti conEnumInProgress=(${this.conEnumInProgress}), haveEnumDeclaration=(${haveEnumDeclaration})`); if (!haveEnumDeclaration && !this.conEnumInProgress) { - const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(",") != -1; - this._logCON(" -- declNotEnumMulti containsMultiStatements=[" + containsMultiStatements + "]"); + const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(',') != -1; + this._logCON(' -- declNotEnumMulti containsMultiStatements=[' + containsMultiStatements + ']'); let statements: string[] = [nonCommentConstantLine]; if (containsMultiStatements) { - statements = nonCommentConstantLine.split(",").filter(Boolean); + statements = nonCommentConstantLine.split(',').filter(Boolean); } this._logCON(` -- statements=[${statements}](${statements.length})`); for (let index = 0; index < statements.length; index++) { const conDeclarationLine: string = statements[index].trim(); - this._logCON(" -- GetCONDeclMulti conDeclarationLine=[" + conDeclarationLine + "]"); + this._logCON(' -- GetCONDeclMulti conDeclarationLine=[' + conDeclarationLine + ']'); currSingleLineOffset = multiLineSet.line.indexOf(conDeclarationLine, 0); - const assignmentOffset: number = conDeclarationLine.indexOf("="); + const assignmentOffset: number = conDeclarationLine.indexOf('='); if (assignmentOffset != -1) { // recognize constant name getting initialized via assignment // get line parts - we only care about first one const lineParts: string[] = conDeclarationLine.split(/[ \t=]/).filter(Boolean); - this._logCON(" -- GetCONDeclMulti assign lineParts=[" + lineParts + "](" + lineParts.length + ")"); + this._logCON(' -- GetCONDeclMulti assign lineParts=[' + lineParts + '](' + lineParts.length + ')'); const newName = lineParts[0]; if (newName.charAt(0).match(/[a-zA-Z_]/) && !this.parseUtils.isP1AsmVariable(newName)) { - this._logCON(" -- GLBL GetCONDeclMulti newName=[" + newName + "]"); + this._logCON(' -- GLBL GetCONDeclMulti newName=[' + newName + ']'); // remember this object name so we can annotate a call to it //const nameOffset = line.indexOf(newName, currSingleLineOffset); // FIXME: UNDONE, do we have to dial this in? const symbolPosition: Position = multiLineSet.locateSymbol(newName, currSingleLineOffset); - const nameOffset: number = multiLineSet.offsetIntoLineForPosition(symbolPosition); + //const nameOffset: number = multiLineSet.offsetIntoLineForPosition(symbolPosition); this.semanticFindings.recordDeclarationLine(multiLineSet.lineAt(symbolPosition.line), symbolPosition.line); - this.semanticFindings.setGlobalToken(newName, new RememberedToken("variable", symbolPosition.line + 1, symbolPosition.character, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + newName, + new RememberedToken('variable', symbolPosition.line + 1, symbolPosition.character, ['readonly']), + this._declarationComment() + ); } } } @@ -1359,9 +1405,9 @@ export class Spin2DocumentSemanticParser { continue; // yep this is not a constant } else { // our enum name can have a step offset - if (enumConstant.includes("[")) { + if (enumConstant.includes('[')) { // it does, isolate name from offset - const enumNameParts: string[] = enumConstant.split("["); + const enumNameParts: string[] = enumConstant.split('['); enumConstant = enumNameParts[0]; } if (enumConstant.charAt(0).match(/[a-zA-Z_]/)) { @@ -1370,7 +1416,11 @@ export class Spin2DocumentSemanticParser { const symbolPosition: Position = multiLineSet.locateSymbol(enumConstant, currSingleLineOffset); nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); this.semanticFindings.recordDeclarationLine(multiLineSet.lineAt(symbolPosition.line), symbolPosition.line + 1); - this.semanticFindings.setGlobalToken(enumConstant, new RememberedToken("enumMember", symbolPosition.line, symbolPosition.character, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + enumConstant, + new RememberedToken('enumMember', symbolPosition.line, symbolPosition.character, ['readonly']), + this._declarationComment() + ); } } currSingleLineOffset = nameOffset + enumConstant.length; @@ -1397,7 +1447,7 @@ export class Spin2DocumentSemanticParser { } else { this._logCON(` -- GetCONDecl nonCommentConstantLine=[${nonCommentConstantLine}](${nonCommentConstantLine.length})`); const haveEnumDeclaration: boolean = this._isEnumDeclarationLine(lineNbr - 1, 0, nonCommentConstantLine); - const isAssignment: boolean = nonCommentConstantLine.indexOf("=") != -1; + const isAssignment: boolean = nonCommentConstantLine.indexOf('=') != -1; if (!haveEnumDeclaration && isAssignment) { this.conEnumInProgress = false; } else { @@ -1405,35 +1455,45 @@ export class Spin2DocumentSemanticParser { } this._logCON(` -- GetCONDecl conEnumInProgress=(${this.conEnumInProgress}), haveEnumDeclaration=(${haveEnumDeclaration})`); if (!haveEnumDeclaration && !this.conEnumInProgress) { - const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(",") != -1; - this._logCON(" -- declNotEnum containsMultiStatements=[" + containsMultiStatements + "]"); + const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(',') != -1; + this._logCON(' -- declNotEnum containsMultiStatements=[' + containsMultiStatements + ']'); let statements: string[] = [nonCommentConstantLine]; if (containsMultiStatements) { - statements = nonCommentConstantLine.split(",").filter(Boolean); + statements = nonCommentConstantLine.split(',').filter(Boolean); } this._logCON(` -- statements=[${statements}](${statements.length})`); for (let index = 0; index < statements.length; index++) { const conDeclarationLine: string = statements[index].trim(); - this._logCON(" -- GetCONDecl conDeclarationLine=[" + conDeclarationLine + "]"); + this._logCON(' -- GetCONDecl conDeclarationLine=[' + conDeclarationLine + ']'); currentOffset = line.indexOf(conDeclarationLine, 0); - const assignmentOffset: number = conDeclarationLine.indexOf("="); + const assignmentOffset: number = conDeclarationLine.indexOf('='); if (assignmentOffset != -1) { // recognize constant name getting initialized via assignment // get line parts - we only care about first one const lineParts: string[] = conDeclarationLine.split(/[ \t=]/).filter(Boolean); - this._logCON(" -- GetCONDecl assign lineParts=[" + lineParts + "](" + lineParts.length + ")"); + this._logCON(' -- GetCONDecl assign lineParts=[' + lineParts + '](' + lineParts.length + ')'); const newName = lineParts[0]; if (newName.charAt(0).match(/[a-zA-Z_]/) && !this.parseUtils.isP1AsmVariable(newName)) { - this._logCON(" -- GLBL GetCONDecl newName=[" + newName + "]"); + this._logCON(' -- GLBL GetCONDecl newName=[' + newName + ']'); // remember this object name so we can annotate a call to it const nameOffset = line.indexOf(newName, currentOffset); // FIXME: UNDONE, do we have to dial this in? const referenceDetails: RememberedToken | undefined = this.semanticFindings.getGlobalToken(newName); if (referenceDetails) { - this.semanticFindings.pushDiagnosticMessage(lineNbr - 1, nameOffset, nameOffset + newName.length, eSeverity.Error, `P2 Spin Duplicate constant name [${newName}], already declared`); + this.semanticFindings.pushDiagnosticMessage( + lineNbr - 1, + nameOffset, + nameOffset + newName.length, + eSeverity.Error, + `P2 Spin Duplicate constant name [${newName}], already declared` + ); } else { this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(newName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + newName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['readonly']), + this._declarationComment() + ); } } } @@ -1456,16 +1516,20 @@ export class Spin2DocumentSemanticParser { continue; // yep this is not a constant } else { // our enum name can have a step offset - if (enumConstant.includes("[")) { + if (enumConstant.includes('[')) { // it does, isolate name from offset - const enumNameParts: string[] = enumConstant.split("["); + const enumNameParts: string[] = enumConstant.split('['); enumConstant = enumNameParts[0]; } if (enumConstant.charAt(0).match(/[a-zA-Z_]/)) { this._logCON(` -- C GLBL enumConstant=[${enumConstant}]`); const nameOffset = line.indexOf(enumConstant, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(enumConstant, new RememberedToken("enumMember", lineNbr - 1, nameOffset, ["readonly"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + enumConstant, + new RememberedToken('enumMember', lineNbr - 1, nameOffset, ['readonly']), + this._declarationComment() + ); } } } @@ -1480,12 +1544,12 @@ export class Spin2DocumentSemanticParser { // HAVE bGammaEnable BYTE TRUE ' comment // didShow byte FALSE[256] // byte FALSE[256] - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const dataDeclNonCommentStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); const lineParts: string[] = this.parseUtils.getNonWhiteNOperatorLineParts(dataDeclNonCommentStr); - this._logDAT(" - Ln#" + lineNbr + " GetDatDecl lineParts=[" + lineParts + "](" + lineParts.length + ")"); - const bHaveDatBlockId: boolean = lineParts.length > 0 && lineParts[0].toUpperCase() == "DAT"; + this._logDAT(` - Ln#${lineNbr} GetDatDecl lineParts=[${lineParts}](${lineParts.length})`); + const bHaveDatBlockId: boolean = lineParts.length > 0 && lineParts[0].toUpperCase() == 'DAT'; const minDecodeCount: number = bHaveDatBlockId ? 2 : 1; if (lineParts.length >= minDecodeCount) { const baseIndex: number = bHaveDatBlockId ? 1 : 0; @@ -1501,15 +1565,16 @@ export class Spin2DocumentSemanticParser { const isNamedDataDeclarationLine: boolean = haveLabel && haveStorageType ? true : false; const isDataDeclarationLine: boolean = haveStorageType ? true : false; - const lblFlag: string = haveLabel ? "T" : "F"; - const dataDeclFlag: string = isDataDeclarationLine ? "T" : "F"; - const newName = haveLabel ? lineParts[nameIndex] : ""; + const lblFlag: string = haveLabel ? 'T' : 'F'; + const dataDeclFlag: string = isDataDeclarationLine ? 'T' : 'F'; + const newName = haveLabel ? lineParts[nameIndex] : ''; const dataTypeOffset: number = dataType && haveStorageType ? dataDeclNonCommentStr.indexOf(dataType) : 0; - const valueDeclNonCommentStr: string = dataType && isDataDeclarationLine && dataTypeOffset != -1 ? dataDeclNonCommentStr.substring(dataTypeOffset + dataType.length).trim() : ""; - this._logDAT(" -- GetDatDecl valueDeclNonCommentStr=[" + valueDeclNonCommentStr + "](" + valueDeclNonCommentStr.length + ")"); - const bIsFileLine: boolean = dataType && dataType.toLowerCase() == "file" ? true : false; - this._logDAT(" -- GetDatDecl newName=[" + newName + "], label=" + lblFlag + ", daDecl=" + dataDeclFlag + ", dataType=[" + dataType + "]"); + const valueDeclNonCommentStr: string = + dataType && isDataDeclarationLine && dataTypeOffset != -1 ? dataDeclNonCommentStr.substring(dataTypeOffset + dataType.length).trim() : ''; + this._logDAT(' -- GetDatDecl valueDeclNonCommentStr=[' + valueDeclNonCommentStr + '](' + valueDeclNonCommentStr.length + ')'); + const bIsFileLine: boolean = dataType && dataType.toLowerCase() == 'file' ? true : false; + this._logDAT(' -- GetDatDecl newName=[' + newName + '], label=' + lblFlag + ', daDecl=' + dataDeclFlag + ', dataType=[' + dataType + ']'); if ( haveLabel && !this.parseUtils.isP2AsmReservedWord(newName) && @@ -1521,31 +1586,42 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isP1AsmVariable(newName) && !this.parseUtils.isBadP1AsmEffectOrConditional(newName) ) { - const nameType: string = isNamedDataDeclarationLine ? "variable" : "label"; - var labelModifiers: string[] = ["declaration"]; + const nameType: string = isNamedDataDeclarationLine ? 'variable' : 'label'; + let labelModifiers: string[] = ['declaration']; if (!isNamedDataDeclarationLine) { // have label... - if (newName.startsWith(":")) { + if (newName.startsWith(':')) { const offset: number = line.indexOf(newName, startingOffset); - labelModifiers = ["illegalUse", "declaration", "static"]; - this.semanticFindings.pushDiagnosticMessage(lineNbr - 1, offset, offset + newName.length, eSeverity.Error, `P1 pasm local name [${newName}] not supported in P2 pasm`); - } else if (newName.startsWith(".")) { - labelModifiers = ["declaration", "static"]; + labelModifiers = ['illegalUse', 'declaration', 'static']; + this.semanticFindings.pushDiagnosticMessage( + lineNbr - 1, + offset, + offset + newName.length, + eSeverity.Error, + `P1 pasm local name [${newName}] not supported in P2 pasm` + ); + } else if (newName.startsWith('.')) { + labelModifiers = ['declaration', 'static']; } } - this._logDAT(" -- GetDatDecl GLBL-newName=[" + newName + "](" + nameType + ")"); + this._logDAT(' -- GetDatDecl GLBL-newName=[' + newName + '](' + nameType + ')'); const fileName: string | undefined = bIsFileLine && lineParts.length > 2 ? lineParts[2] : undefined; this._ensureDataFileExists(fileName, lineNbr - 1, line, startingOffset); - this._logDAT(" -- GetDatDecl fileName=[" + fileName + "]"); + this._logDAT(' -- GetDatDecl fileName=[' + fileName + ']'); const nameOffset = line.indexOf(newName, currentOffset); // FIXME: UNDONE, do we have to dial this in? // LABEL-TODO add record of global, start or local extra line number let declType: eDefinitionType = eDefinitionType.NonLabel; if (!isNamedDataDeclarationLine) { // we have a label which type is it? - declType = newName.startsWith(".") ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; + declType = newName.startsWith('.') ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; } this.semanticFindings.recordDeclarationLine(line, lineNbr, declType); - this.semanticFindings.setGlobalToken(newName, new RememberedToken(nameType, lineNbr - 1, nameOffset, labelModifiers), this._declarationComment(), fileName); + this.semanticFindings.setGlobalToken( + newName, + new RememberedToken(nameType, lineNbr - 1, nameOffset, labelModifiers), + this._declarationComment(), + fileName + ); } } } @@ -1553,35 +1629,35 @@ export class Spin2DocumentSemanticParser { private _getDAT_PAsmDeclaration(startingOffset: number, lineNbr: number, line: string): void { // HAVE bGammaEnable BYTE TRUE ' comment // didShow byte FALSE[256] - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const datPAsmRHSStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (datPAsmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhiteLineParts(datPAsmRHSStr); this._logPASM(` - Ln#${lineNbr} GetDATPAsmDecl lineParts=[${lineParts}](${lineParts.length})`); // handle name in 1 column - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); - const bIsFileLine: boolean = haveLabel && lineParts.length > 1 && lineParts[1].toLowerCase() == "file"; + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); + const bIsFileLine: boolean = haveLabel && lineParts.length > 1 && lineParts[1].toLowerCase() == 'file'; const isDataDeclarationLine: boolean = lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1]) ? true : false; if (haveLabel) { const labelName: string = lineParts[0]; if ( !this.parseUtils.isP2AsmReservedSymbols(labelName) && !this.parseUtils.isP2AsmInstruction(labelName) && - !labelName.toUpperCase().startsWith("IF_") && - !labelName.toUpperCase().startsWith("_RET_") && - !labelName.startsWith(":") + !labelName.toUpperCase().startsWith('IF_') && + !labelName.toUpperCase().startsWith('_RET_') && + !labelName.startsWith(':') ) { // org in first column is not label name, nor is if_ conditional - const labelType: string = isDataDeclarationLine ? "variable" : "label"; - var labelModifiers: string[] = ["declaration"]; - if (!isDataDeclarationLine && labelName.startsWith(".")) { - labelModifiers = ["declaration", "static"]; + const labelType: string = isDataDeclarationLine ? 'variable' : 'label'; + let labelModifiers: string[] = ['declaration']; + if (!isDataDeclarationLine && labelName.startsWith('.')) { + labelModifiers = ['declaration', 'static']; } - this._logPASM(" -- DAT PASM GLBL labelName=[" + labelName + "(" + labelType + ")]"); + this._logPASM(' -- DAT PASM GLBL labelName=[' + labelName + '(' + labelType + ')]'); const fileName: string | undefined = bIsFileLine && lineParts.length > 2 ? lineParts[2] : undefined; if (fileName) { - this._logDAT(" -- DAT PASM GLBL fileName=[" + fileName + "]"); + this._logDAT(' -- DAT PASM GLBL fileName=[' + fileName + ']'); this._ensureDataFileExists(fileName, lineNbr - 1, line, startingOffset); } const nameOffset = line.indexOf(labelName, 0); // FIXME: UNDONE, do we have to dial this in? @@ -1589,10 +1665,15 @@ export class Spin2DocumentSemanticParser { let declType: eDefinitionType = eDefinitionType.NonLabel; if (!isDataDeclarationLine) { // we have a label which type is it? - declType = labelName.startsWith(".") ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; + declType = labelName.startsWith('.') ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; } this.semanticFindings.recordDeclarationLine(line, lineNbr, declType); - this.semanticFindings.setGlobalToken(labelName, new RememberedToken(labelType, lineNbr - 1, nameOffset, labelModifiers), this._declarationComment(), fileName); + this.semanticFindings.setGlobalToken( + labelName, + new RememberedToken(labelType, lineNbr - 1, nameOffset, labelModifiers), + this._declarationComment(), + fileName + ); } } } @@ -1600,34 +1681,58 @@ export class Spin2DocumentSemanticParser { private _ensureDataFileExists(fileName: string | undefined, lineIdx: number, line: string, startingOffset: number) { if (fileName) { - const filenameNoQuotes: string = fileName.replace(/\"/g, ""); - const searchFilename: string = `\"${filenameNoQuotes}`; + const filenameNoQuotes: string = fileName.replace(/"/g, ''); + const searchFilename: string = `"${filenameNoQuotes}`; const nameOffset: number = line.indexOf(searchFilename, startingOffset); - const hasPathSep: boolean = filenameNoQuotes.includes("/"); + const hasPathSep: boolean = filenameNoQuotes.includes('/'); this._logMessage(` -- looking for DataFile [${this.directory}/${filenameNoQuotes}]`); const logCtx: Context | undefined = this.spin2DebugLogEnabled ? this.ctx : undefined; if (hasPathSep) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + filenameNoQuotes.length, eSeverity.Error, `P2 spin Invalid filename character "/" in [${filenameNoQuotes}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + filenameNoQuotes.length, + eSeverity.Error, + `P2 spin Invalid filename character "/" in [${filenameNoQuotes}]` + ); } else if (!fileInDirExists(this.directory, filenameNoQuotes, logCtx)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + fileName.length, eSeverity.Error, `Missing P2 Data file [${fileName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + fileName.length, + eSeverity.Error, + `Missing P2 Data file [${fileName}]` + ); } } } private _ensureObjectFileExists(fileName: string | undefined, lineIdx: number, line: string, startingOffset: number) { if (fileName) { - const filenameNoQuotes: string = fileName.replace(/\"/g, ""); - const hasSuffix: boolean = filenameNoQuotes.endsWith(".spin2"); - const hasPathSep: boolean = filenameNoQuotes.includes("/"); + const filenameNoQuotes: string = fileName.replace(/"/g, ''); + const hasSuffix: boolean = filenameNoQuotes.endsWith('.spin2'); + const hasPathSep: boolean = filenameNoQuotes.includes('/'); const fileWithExt = `${filenameNoQuotes}.spin2`; const nameOffset: number = line.indexOf(filenameNoQuotes, startingOffset); const logCtx: Context | undefined = this.spin2DebugLogEnabled ? this.ctx : undefined; const checkFilename: string = hasSuffix ? filenameNoQuotes : fileWithExt; if (hasPathSep) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + filenameNoQuotes.length, eSeverity.Error, `P2 spin Invalid filename character "/" in [${filenameNoQuotes}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + filenameNoQuotes.length, + eSeverity.Error, + `P2 spin Invalid filename character "/" in [${filenameNoQuotes}]` + ); } else if (!fileInDirExists(this.directory, checkFilename, logCtx)) { const displayName: string = hasSuffix ? filenameNoQuotes : `${filenameNoQuotes}.spin2`; - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + filenameNoQuotes.length, eSeverity.Error, `Missing P2 Object file [${displayName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + filenameNoQuotes.length, + eSeverity.Error, + `Missing P2 Object file [${displayName}]` + ); } } } @@ -1641,32 +1746,37 @@ export class Spin2DocumentSemanticParser { //skip Past Whitespace const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); - const remainingOffset: number = line.indexOf(remainingNonCommentLineStr, startingOffset); + //const remainingOffset: number = line.indexOf(remainingNonCommentLineStr, startingOffset); this._logOBJ(`- Ln#${lineNbr} GetOBJDecl remainingNonCommentLineStr=[${remainingNonCommentLineStr}]`); let badObjectLine: boolean = false; if (remainingNonCommentLineStr.length >= 5) { // c:"x" is minimm object decl len=5! - if (remainingNonCommentLineStr.includes(":") && remainingNonCommentLineStr.includes('"') && !remainingNonCommentLineStr.endsWith(":")) { + if (remainingNonCommentLineStr.includes(':') && remainingNonCommentLineStr.includes('"') && !remainingNonCommentLineStr.endsWith(':')) { // get line parts - we only care about first one - const overrideParts: string[] = remainingNonCommentLineStr.split("|").filter(Boolean); - const lineParts: string[] = overrideParts[0].split(":").filter(Boolean); + const overrideParts: string[] = remainingNonCommentLineStr.split('|').filter(Boolean); + const lineParts: string[] = overrideParts[0].split(':').filter(Boolean); this._logOBJ(` -- GLBL GetOBJDecl lineParts=[${lineParts}]${lineParts.length}`); if (lineParts.length < 2) { badObjectLine = true; } else { let instanceNamePart = lineParts[0].trim(); // if we have instance array declaration, then remove it - if (instanceNamePart.includes("[")) { - const nameParts = instanceNamePart.split(/[\[\]]/).filter(Boolean); + if (instanceNamePart.includes('[')) { + const nameParts = instanceNamePart.split(/[[\]]/).filter(Boolean); instanceNamePart = nameParts[0]; } this._logOBJ(` -- GLBL GetOBJDecl newInstanceName=[${instanceNamePart}]`); // remember this object name so we can annotate a call to it - const filenamePart = lineParts.length > 1 ? lineParts[1].trim().replace(/[\"]/g, "") : "--error-no-name-parsed--"; + const filenamePart = lineParts.length > 1 ? lineParts[1].trim().replace(/["]/g, '') : '--error-no-name-parsed--'; this._logOBJ(` -- GLBL GetOBJDecl newFileName=[${filenamePart}]`); this.semanticFindings.recordDeclarationLine(line, lineNbr); const nameOffset = line.indexOf(instanceNamePart, currentOffset); // FIXME: UNDONE, do we have to dial this in? - this.semanticFindings.setGlobalToken(instanceNamePart, new RememberedToken("namespace", lineNbr - 1, nameOffset, []), this._declarationComment(), filenamePart); // pass filename, too + this.semanticFindings.setGlobalToken( + instanceNamePart, + new RememberedToken('namespace', lineNbr - 1, nameOffset, []), + this._declarationComment(), + filenamePart + ); // pass filename, too this.semanticFindings.recordObjectImport(instanceNamePart, filenamePart); this._ensureObjectFileExists(filenamePart, lineNbr - 1, line, startingOffset); } @@ -1690,7 +1800,7 @@ export class Spin2DocumentSemanticParser { private _getPUB_PRI_Name(startingOffset: number, lineNbr: number, line: string): void { const methodType = line.substr(0, 3).toUpperCase(); // reset our list of local variables - const isPrivate: boolean = methodType.indexOf("PRI") != -1; + const isPrivate: boolean = methodType.indexOf('PRI') != -1; //const matchIdx: number = methodType.indexOf("PRI"); //this._logSPIN(" - Ln#" + lineNbr + " GetMethodDecl methodType=[" + methodType + "], isPrivate(" + isPrivate + ")"); @@ -1700,13 +1810,13 @@ export class Spin2DocumentSemanticParser { const startNameOffset = currentOffset; // find open paren // find open paren - currentOffset = remainingNonCommentLineStr.indexOf("(", startNameOffset); // in spin1 ()'s are optional! + currentOffset = remainingNonCommentLineStr.indexOf('(', startNameOffset); // in spin1 ()'s are optional! if (currentOffset == -1) { - currentOffset = remainingNonCommentLineStr.indexOf(":", startNameOffset); + currentOffset = remainingNonCommentLineStr.indexOf(':', startNameOffset); if (currentOffset == -1) { - currentOffset = remainingNonCommentLineStr.indexOf("|", startNameOffset); + currentOffset = remainingNonCommentLineStr.indexOf('|', startNameOffset); if (currentOffset == -1) { - currentOffset = remainingNonCommentLineStr.indexOf(" ", startNameOffset); + currentOffset = remainingNonCommentLineStr.indexOf(' ', startNameOffset); if (currentOffset == -1) { currentOffset = remainingNonCommentLineStr.indexOf("'", startNameOffset); // if nothibng found... @@ -1718,15 +1828,15 @@ export class Spin2DocumentSemanticParser { } } - let nameLength = currentOffset - startNameOffset; + const nameLength = currentOffset - startNameOffset; const methodName = line.substr(startNameOffset, nameLength).trim(); - const nameType: string = isPrivate ? "private" : "public"; - this._logSPIN("- Ln#" + lineNbr + " _gPUB_PRI_Name() newName=[" + methodName + "](" + nameType + ")"); + const nameType: string = isPrivate ? 'private' : 'public'; + this._logSPIN('- Ln#' + lineNbr + ' _gPUB_PRI_Name() newName=[' + methodName + '](' + nameType + ')'); this.currentMethodName = methodName; // notify of latest method name so we can track inLine PASM symbols // mark start of method - we are learning span of lines this method covers let methodExists: boolean = false; const referenceDetails: RememberedToken | undefined = this.semanticFindings.getGlobalToken(methodName); - if (referenceDetails && referenceDetails.type === "method") { + if (referenceDetails && referenceDetails.type === 'method') { methodExists = true; this._logSPIN(` -- _gPUB_PRI_Name() ERROR: have duplicate method [${methodName}]`); } @@ -1734,15 +1844,19 @@ export class Spin2DocumentSemanticParser { this.semanticFindings.startMethod(methodName, lineNbr); // remember this method name so we can annotate a call to it - const refModifiers: string[] = isPrivate ? ["static"] : []; + const refModifiers: string[] = isPrivate ? ['static'] : []; // record ACTUAL object public/private interface const nameOffset = line.indexOf(methodName, currentOffset); // FIXME: UNDONE, do we have to dial this in? this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(methodName, new RememberedToken("method", lineNbr - 1, nameOffset, refModifiers), this._declarationComment()); + this.semanticFindings.setGlobalToken( + methodName, + new RememberedToken('method', lineNbr - 1, nameOffset, refModifiers), + this._declarationComment() + ); // reset our list of local variables this.semanticFindings.clearLocalPAsmTokensForMethod(methodName); } else { - const methodPrefix: string = referenceDetails?.modifiers.includes("static") ? "PRI" : "PUB"; + const methodPrefix: string = referenceDetails?.modifiers.includes('static') ? 'PRI' : 'PUB'; //const declarationLineIdx;number = referenceDetails. this.semanticFindings.pushDiagnosticMessage( lineNbr - 1, @@ -1752,42 +1866,49 @@ export class Spin2DocumentSemanticParser { `P2 Spin Duplicate method Declaration: found earlier [${methodPrefix} ${methodName}()]` ); } - this._logSPIN(" -- _gPUB_PRI_Name() exit"); + this._logSPIN(' -- _gPUB_PRI_Name() exit'); } private _getSPIN_PAsmDeclaration(startingOffset: number, lineNbr: number, line: string): void { // HAVE next8SLine ' or .nextLine in col 0 // nPhysLineIdx long 0 - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); - this._logPASM(`- Ln#${lineNbr} gSpinInLinePAsmDecl startingOffset=(${startingOffset}), currentOffset=(${currentOffset}), line=[${line}](${line.length})`); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + this._logPASM( + `- Ln#${lineNbr} gSpinInLinePAsmDecl startingOffset=(${startingOffset}), currentOffset=(${currentOffset}), line=[${line}](${line.length})` + ); // get line parts - we only care about first one const inLinePAsmRHSStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (inLinePAsmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhiteLineParts(inLinePAsmRHSStr); this._logPASM(` -- gSpinInLinePAsmDecl lineParts=[${lineParts}](${lineParts.length})`); // handle name in 1 column - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); - const isDebug: boolean = lineParts[0].toLowerCase().startsWith("debug"); + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); + const isDebug: boolean = lineParts[0].toLowerCase().startsWith('debug'); const isDataDeclarationLine: boolean = lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1]) ? true : false; if (haveLabel && !isDebug) { const labelName: string = lineParts[0]; - const labelType: string = isDataDeclarationLine ? "variable" : "label"; - var labelModifiers: string[] = []; + const labelType: string = isDataDeclarationLine ? 'variable' : 'label'; + let labelModifiers: string[] = []; if (!isDataDeclarationLine) { - labelModifiers = labelName.startsWith(".") ? ["pasmInline", "static"] : ["pasmInline"]; + labelModifiers = labelName.startsWith('.') ? ['pasmInline', 'static'] : ['pasmInline']; } else { - labelModifiers = ["pasmInline"]; + labelModifiers = ['pasmInline']; } - this._logPASM(" -- Inline PASM labelName=[" + labelName + "(" + labelType + ")[" + labelModifiers + "]]"); + this._logPASM(' -- Inline PASM labelName=[' + labelName + '(' + labelType + ')[' + labelModifiers + ']]'); const nameOffset = line.indexOf(this.currentMethodName, currentOffset); // FIXME: UNDONE, do we have to dial this in? // LABEL-TODO add record of global, start or local extra line number let declType: eDefinitionType = eDefinitionType.NonLabel; if (!isDataDeclarationLine) { // we have a label which type is it? - declType = labelName.startsWith(".") ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; + declType = labelName.startsWith('.') ? eDefinitionType.LocalLabel : eDefinitionType.GlobalLabel; } this.semanticFindings.recordDeclarationLine(line, lineNbr, declType); - this.semanticFindings.setLocalPAsmTokenForMethod(this.currentMethodName, labelName, new RememberedToken(labelType, lineNbr - 1, nameOffset, labelModifiers), this._declarationComment()); + this.semanticFindings.setLocalPAsmTokenForMethod( + this.currentMethodName, + labelName, + new RememberedToken(labelType, lineNbr - 1, nameOffset, labelModifiers), + this._declarationComment() + ); } } } @@ -1796,12 +1917,12 @@ export class Spin2DocumentSemanticParser { // HAVE long demoPausePeriod ' comment // //skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (remainingNonCommentLineStr.length > 0) { //this._logVAR(" - Ln#" + lineNbr + " GetVarDecl remainingNonCommentLineStr=[" + remainingNonCommentLineStr + "]"); - const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(","); - let lineParts: string[] = this.parseUtils.getNonWhiteDataDeclarationLineParts(remainingNonCommentLineStr); + const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(','); + const lineParts: string[] = this.parseUtils.getNonWhiteDataDeclarationLineParts(remainingNonCommentLineStr); const hasGoodType: boolean = lineParts.length > 0 && this.parseUtils.isStorageType(lineParts[0]); this._logVAR(` - Ln#${lineNbr} GetVarDecl lineParts=[${lineParts}](${lineParts.length})`); let nameSet: string[] = []; @@ -1819,26 +1940,31 @@ export class Spin2DocumentSemanticParser { for (let index = 1; index < nameSet.length; index++) { // remove array suffix and comma delim. from name let newName = nameSet[index]; // .replace(/[\[,]/, ''); - if (newName.includes("[")) { - const tempParts: string[] = newName.split(/[\[\]]/).filter(Boolean); + if (newName.includes('[')) { + const tempParts: string[] = newName.split(/[[\]]/).filter(Boolean); this._logVAR(` -- GLBL GetVarDecl adjust longVarName:[${newName}] -> [${tempParts[0]}]`); newName = tempParts[0]; } if (newName.charAt(0).match(/[a-zA-Z_]/)) { - this._logVAR(` -- GLBL GetVarDecl newName=[${newName}]`); + this._logVAR(` -- GLBL GetVarDecl w/type newName=[${newName}]`); const nameOffset = line.indexOf(newName, currentOffset); // FIXME: UNDONE, do we have to dial this in? const referenceDetails: RememberedToken | undefined = this.semanticFindings.getGlobalToken(newName); + // if we have a collision with a global we don't care if the global is a constant if (referenceDetails) { this.semanticFindings.pushDiagnosticMessage( lineNbr - 1, nameOffset, nameOffset + newName.length, eSeverity.Error, - `P2 Spin Duplicate global variable name [${newName}], already declared` + `P2 Spin Duplicate name [${newName}], global variable/constant already exists` ); } else { this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(newName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["instance"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + newName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['instance']), + this._declarationComment() + ); } } } @@ -1846,13 +1972,13 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < lineParts.length; index++) { let longVarName = lineParts[index]; // if name is array of values then only report name part - if (longVarName.includes("[")) { - const tempParts: string[] = longVarName.split(/[\[\]]/).filter(Boolean); + if (longVarName.includes('[')) { + const tempParts: string[] = longVarName.split(/[[\]]/).filter(Boolean); this._logVAR(` -- GLBL GetVarDecl adjust longVarName:[${longVarName}] -> [${tempParts[0]}]`); longVarName = tempParts[0]; } if (longVarName.charAt(0).match(/[a-zA-Z_]/)) { - this._logVAR(` -- GLBL GetVarDecl newName=[${longVarName}]`); + this._logVAR(` -- GLBL GetVarDecl w/o type newName=[${longVarName}]`); const nameOffset = line.indexOf(longVarName, currentOffset); // FIXME: UNDONE, do we have to dial this in? const referenceDetails: RememberedToken | undefined = this.semanticFindings.getGlobalToken(longVarName); if (referenceDetails) { @@ -1861,11 +1987,15 @@ export class Spin2DocumentSemanticParser { nameOffset, nameOffset + longVarName.length, eSeverity.Error, - `P2 Spin Duplicate global variable name [${longVarName}], already declared` + `P2 Spin Duplicate name [${longVarName}], global variable/constant already exists` ); } else { this.semanticFindings.recordDeclarationLine(line, lineNbr); - this.semanticFindings.setGlobalToken(longVarName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["instance"]), this._declarationComment()); + this.semanticFindings.setGlobalToken( + longVarName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['instance']), + this._declarationComment() + ); } } } @@ -1877,16 +2007,16 @@ export class Spin2DocumentSemanticParser { // locate and collect debug() display user names and types // // HAVE debug(`{displayType} {displayName} ......) ' comment - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const datPAsmStatementStr = this._getDebugStatement(currentOffset, line); if (datPAsmStatementStr.length > 0) { - this._logDEBUG(" -- rptDbg datPAsmStatementStr=[" + datPAsmStatementStr + "]"); - if (datPAsmStatementStr.toLowerCase().startsWith("debug(`")) { + this._logDEBUG(' -- rptDbg datPAsmStatementStr=[' + datPAsmStatementStr + ']'); + if (datPAsmStatementStr.toLowerCase().startsWith('debug(`')) { const lineParts: string[] = this.parseUtils.getDebugNonWhiteLineParts(datPAsmStatementStr); - this._logDEBUG(" -- gddd lineParts=[" + lineParts + "](" + lineParts.length + ")"); + this._logDEBUG(' -- gddd lineParts=[' + lineParts + '](' + lineParts.length + ')'); if (lineParts.length >= 3) { const displayType: string = lineParts[1]; - if (displayType.startsWith("`")) { + if (displayType.startsWith('`')) { const newDisplayType: string = displayType.substring(1, displayType.length); //this._logDEBUG(' --- debug(...) newDisplayType=[' + newDisplayType + ']'); if (this.parseUtils.isDebugDisplayType(newDisplayType)) { @@ -1905,12 +2035,12 @@ export class Spin2DocumentSemanticParser { const lineNbr: number = lineIdx + 1; // skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const nonCommentConstantLine = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); if (nonCommentConstantLine.length > 0) { // get line parts - we only care about first one const lineParts: string[] = nonCommentConstantLine.split(/[ \t=]/).filter(Boolean); - this._logPreProc(" - Ln#" + lineNbr + " reportPreProc lineParts=[" + lineParts + "]"); + this._logPreProc(' - Ln#' + lineNbr + ' reportPreProc lineParts=[' + lineParts + ']'); const directive: string = lineParts[0]; const symbolName: string | undefined = lineParts.length > 1 ? lineParts[1] : undefined; @@ -1921,32 +2051,33 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: 0, length: directive.length, - ptTokenType: "keyword", - ptTokenModifiers: ["control", "directive"], + ptTokenType: 'keyword', + ptTokenModifiers: ['control', 'directive'] }); const hasSymbol: boolean = - directive.toLowerCase() == "#define" || - directive.toLowerCase() == "#ifdef" || - directive.toLowerCase() == "#ifndef" || - directive.toLowerCase() == "#elseifdef" || - directive.toLowerCase() == "#elseifndef"; + directive.toLowerCase() == '#define' || + directive.toLowerCase() == '#ifdef' || + directive.toLowerCase() == '#ifndef' || + directive.toLowerCase() == '#elseifdef' || + directive.toLowerCase() == '#elseifndef'; if (hasSymbol && symbolName != undefined) { const nameOffset = line.indexOf(symbolName, currentOffset); - this._logPreProc(" -- GLBL symbolName=[" + symbolName + "]"); + this._logPreProc(' -- GLBL symbolName=[' + symbolName + ']'); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(symbolName)) { referenceDetails = this.semanticFindings.getGlobalToken(symbolName); - this._logPreProc(" -- FOUND preProc global " + this._rememberdTokenString(symbolName, referenceDetails)); + this._logPreProc(' -- FOUND preProc global ' + this._rememberdTokenString(symbolName, referenceDetails)); } if (referenceDetails != undefined) { // record a constant declaration! - const updatedModificationSet: string[] = directive.toLowerCase() == "#define" ? referenceDetails.modifiersWith("declaration") : referenceDetails.modifiers; + const updatedModificationSet: string[] = + directive.toLowerCase() == '#define' ? referenceDetails.modifiersWith('declaration') : referenceDetails.modifiers; this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: symbolName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: updatedModificationSet, + ptTokenModifiers: updatedModificationSet }); } else if (this.parseUtils.isFlexspinReservedWord(symbolName)) { // record a constant reference @@ -1954,8 +2085,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: symbolName.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly'] }); } else { // record an unknown name @@ -1963,8 +2094,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: symbolName.length, - ptTokenType: "comment", - ptTokenModifiers: ["line"], + ptTokenType: 'comment', + ptTokenModifiers: ['line'] }); } } @@ -1975,10 +2106,16 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: 0, length: lineParts[0].length, - ptTokenType: "macro", - ptTokenModifiers: ["directive", "illegalUse"], + ptTokenType: 'macro', + ptTokenModifiers: ['directive', 'illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, 0, 0 + lineParts[0].length, eSeverity.Error, `P2 Spin - FlexSpin PreProcessor Directive [${lineParts[0]}] not supported!`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + 0, + 0 + lineParts[0].length, + eSeverity.Error, + `P2 Spin - FlexSpin PreProcessor Directive [${lineParts[0]}] not supported!` + ); } } @@ -1987,23 +2124,23 @@ export class Spin2DocumentSemanticParser { private _isEnumDeclarationLine(lineIdx: number, startingOffset: number, line: string): boolean { // BOTH P1 and P2 determination: if CON line is start enum declaration - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const nonCommentConstantLine = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); - let enumDeclStatus: boolean = nonCommentConstantLine.trim().startsWith("#"); + let enumDeclStatus: boolean = nonCommentConstantLine.trim().startsWith('#'); // if not yet sure... if (enumDeclStatus == false) { // don't know what this line is, yet - const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(",") != -1; + const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(',') != -1; let statements: string[] = [nonCommentConstantLine]; let allStatementAreAssignment: boolean = true; if (containsMultiStatements) { - statements = nonCommentConstantLine.split(",").filter(Boolean); + statements = nonCommentConstantLine.split(',').filter(Boolean); } // if all statements are assignment then we still don't know if this is enum or list of assignements // however, if one has "no assignment" then we DO KNOW that this is an enum start for (let index = 0; index < statements.length; index++) { const singleStatement = statements[index]; - if (!singleStatement.includes("=")) { + if (!singleStatement.includes('=')) { allStatementAreAssignment = false; break; } @@ -2023,29 +2160,31 @@ export class Spin2DocumentSemanticParser { const nonCommentConstantLine = multiLineSet.line; if (nonCommentConstantLine.length > 0) { const haveEnumDeclaration: boolean = this._isEnumDeclarationLine(multiLineSet.lineStartIdx, 0, nonCommentConstantLine); - const isAssignment: boolean = nonCommentConstantLine.indexOf("=") != -1; + const isAssignment: boolean = nonCommentConstantLine.indexOf('=') != -1; if (!haveEnumDeclaration && isAssignment) { this.conEnumInProgress = false; } else { this.conEnumInProgress = this.conEnumInProgress || haveEnumDeclaration; } - const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(",") != -1; + const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(',') != -1; this._logCON( - `- Ln#${multiLineSet.lineStartIdx + 1} rptCDLMulti haveEnum=(${haveEnumDeclaration}), containsMulti=(${containsMultiStatements}), nonCommentConstantLine=[${nonCommentConstantLine}]` + `- Ln#${ + multiLineSet.lineStartIdx + 1 + } rptCDLMulti haveEnum=(${haveEnumDeclaration}), containsMulti=(${containsMultiStatements}), nonCommentConstantLine=[${nonCommentConstantLine}]` ); let statements: string[] = [nonCommentConstantLine]; if (!haveEnumDeclaration && !this.conEnumInProgress) { if (containsMultiStatements) { - statements = nonCommentConstantLine.split(",").filter(Boolean); + statements = nonCommentConstantLine.split(',').filter(Boolean); } this._logCON(` -- assignments statements=[${statements}](${statements.length})`); for (let index = 0; index < statements.length; index++) { const conDeclarationLine: string = statements[index].trim(); - this._logCON(" -- conDeclarationLine=[" + conDeclarationLine + "]"); + this._logCON(' -- conDeclarationLine=[' + conDeclarationLine + ']'); //currSingleLineOffset = line.indexOf(conDeclarationLine, currSingleLineOffset); const symbolPosition: Position = multiLineSet.locateSymbol(conDeclarationLine, currSingleLineOffset); // locate key indicators of line style - const isAssignment: boolean = conDeclarationLine.indexOf("=") != -1; + const isAssignment: boolean = conDeclarationLine.indexOf('=') != -1; if (!isAssignment) { if (!this.parseUtils.isDebugInvocation(conDeclarationLine)) { this.semanticFindings.pushDiagnosticMessage( @@ -2061,11 +2200,11 @@ export class Spin2DocumentSemanticParser { // have line assigning value to new constant // ------------------------------------------- // process LHS - const assignmentParts: string[] = conDeclarationLine.split("="); + const assignmentParts: string[] = conDeclarationLine.split('='); const lhsConstantName = assignmentParts[0].trim(); //const nameOffset = line.indexOf(lhsConstantName, currSingleLineOffset); - let symbolPosition: Position = multiLineSet.locateSymbol(lhsConstantName, currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + const symbolPosition: Position = multiLineSet.locateSymbol(lhsConstantName, currSingleLineOffset); + //const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); this._logCON(` -- GLBLMulti assign lhsConstantName=[${lhsConstantName}]`); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(lhsConstantName)) { @@ -2074,22 +2213,22 @@ export class Spin2DocumentSemanticParser { } if (referenceDetails != undefined) { // this is a constant declaration! - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: lhsConstantName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); } else { - this._logCON(" -- CON ERROR[CODE] missed recording declaration! name=[" + lhsConstantName + "]"); + this._logCON(' -- CON ERROR[CODE] missed recording declaration! name=[' + lhsConstantName + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: lhsConstantName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); if (this.parseUtils.isP1AsmVariable(lhsConstantName)) { this.semanticFindings.pushDiagnosticMessage( @@ -2111,7 +2250,7 @@ export class Spin2DocumentSemanticParser { } // remove front LHS of assignment and process remainder // process RHS - const fistEqualOffset: number = conDeclarationLine.indexOf("="); + const fistEqualOffset: number = conDeclarationLine.indexOf('='); const assignmentRHSStr = conDeclarationLine.substring(fistEqualOffset + 1).trim(); currSingleLineOffset = multiLineSet.line.indexOf(assignmentRHSStr, fistEqualOffset); // skip to RHS of assignment this._logCON(` -- GLBLMulti assignmentRHSStr=[${assignmentRHSStr}], ofs=(${currSingleLineOffset})`); @@ -2119,7 +2258,7 @@ export class Spin2DocumentSemanticParser { this._logCON(` -- CONMulti possNames=[${possNames}](${possNames.length})`); for (let index = 0; index < possNames.length; index++) { const possibleName = possNames[index]; - const currPossibleLen = possibleName.length; + //const currPossibleLen = possibleName.length; if (possibleName.charAt(0).match(/[a-zA-Z_]/)) { // does name contain a namespace reference? //let nameOffset: number = line.indexOf(possibleName, currSingleLineOffset); @@ -2127,12 +2266,18 @@ export class Spin2DocumentSemanticParser { let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); let possibleNameSet: string[] = [possibleName]; if (this._isPossibleObjectReference(possibleName)) { - const bHaveObjReference = this._reportObjectReference(possibleName, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet); + const bHaveObjReference = this._reportObjectReference( + possibleName, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ); if (bHaveObjReference) { currSingleLineOffset = nameOffset + possibleName.length; continue; } - possibleNameSet = possibleName.split("."); + possibleNameSet = possibleName.split('.'); } this._logCON(` -- possibleNameSet=[${possibleNameSet}](${possibleNameSet.length})`); const namePart: string = possibleNameSet[0]; @@ -2153,17 +2298,19 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolPosition.character, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { - if (this.parseUtils.isFloatConversion(namePart) && (assignmentRHSStr.indexOf(namePart + "(") == -1 || assignmentRHSStr.indexOf(namePart + "()") != -1)) { - this._logCON(" -- CON MISSING parens=[" + namePart + "]"); + const methodFollowString: string = multiLineSet.line.substring(nameOffset + namePart.length); + this._logSPIN(` -- CON func Paren chk methodFollowString=[${methodFollowString}](${methodFollowString.length})`); + if (this.parseUtils.isFloatConversion(namePart) && !isMethodCall(methodFollowString)) { + this._logCON(` -- CON MISSING parens=[${namePart}]`); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -2172,6 +2319,22 @@ export class Spin2DocumentSemanticParser { eSeverity.Error, `P2 Spin CON missing parens [${namePart}]` ); + } else if (this.parseUtils.isFloatConversion(namePart) && isMethodCallEmptyParens(methodFollowString)) { + this._logCON(` -- CON EMPTY parens=[${namePart}]`); + this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { + line: symbolPosition.line, + startCharacter: symbolPosition.character, + length: namePart.length, + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] + }); + this.semanticFindings.pushDiagnosticMessage( + symbolPosition.line, + symbolPosition.character, + symbolPosition.character + namePart.length, + eSeverity.Error, + `P2 Spin CON function w/empty parens [${namePart}]` + ); } else if ( !this.parseUtils.isSpinReservedWord(namePart) && !this.parseUtils.isBuiltinStreamerReservedWord(namePart) && @@ -2179,13 +2342,13 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isDebugControlSymbol(namePart) && !this.parseUtils.isUnaryOperator(namePart) ) { - this._logCON(" -- CON MISSING name=[" + namePart + "]"); + this._logCON(' -- CON MISSING name=[' + namePart + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); if (this.parseUtils.isP1AsmVariable(namePart)) { this.semanticFindings.pushDiagnosticMessage( @@ -2211,13 +2374,13 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isBinaryOperator(namePart) && !this.parseUtils.isSpinNumericSymbols(namePart) ) { - this._logCON(" -- CON MISSING declaration=[" + namePart + "]"); + this._logCON(' -- CON MISSING declaration=[' + namePart + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -2239,24 +2402,24 @@ export class Spin2DocumentSemanticParser { // have line creating one or more of enum constants // ------------------------------------------------- // recognize enum values getting initialized - const lineParts: string[] = nonCommentConstantLine.split(",").filter(Boolean); + const lineParts: string[] = nonCommentConstantLine.split(',').filter(Boolean); this._logCON(` -- enum lineParts=[${lineParts}](${lineParts.length})`); let nameOffset: number = 0; for (let index = 0; index < lineParts.length; index++) { let enumConstant = lineParts[index].trim(); // our enum name can have a step offset: name[step] - if (enumConstant.includes("[")) { + if (enumConstant.includes('[')) { // it does, isolate name from offset - const enumNameParts: string[] = enumConstant.split("["); + const enumNameParts: string[] = enumConstant.split('['); enumConstant = enumNameParts[0]; } - if (enumConstant.includes("=")) { + if (enumConstant.includes('=')) { // process LHS of '=' - const enumAssignmentParts: string[] = enumConstant.split("="); + const enumAssignmentParts: string[] = enumConstant.split('='); enumConstant = enumAssignmentParts[0].trim(); const enumExistingName: string = enumAssignmentParts[1].trim(); if (enumExistingName.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- A GLBL enumExistingName=[" + enumExistingName + "]"); + this._logCON(' -- A GLBL enumExistingName=[' + enumExistingName + ']'); // our enum name can have a step offset //nameOffset = line.indexOf(enumExistingName, currSingleLineOffset); const symbolPosition: Position = multiLineSet.locateSymbol(enumExistingName, currSingleLineOffset); @@ -2265,8 +2428,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: nameOffset, length: enumExistingName.length, - ptTokenType: "enumMember", - ptTokenModifiers: ["readonly"], + ptTokenType: 'enumMember', + ptTokenModifiers: ['readonly'] }); } currSingleLineOffset = nameOffset + enumExistingName.length; @@ -2275,26 +2438,26 @@ export class Spin2DocumentSemanticParser { const symbolPosition: Position = multiLineSet.locateSymbol(enumConstant, currSingleLineOffset); nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); if (!this.parseUtils.isDebugInvocation(enumConstant) && !this.parseUtils.isP1AsmVariable(enumConstant)) { - this._logCON(" -- B GLBLMulti enumConstant=[" + enumConstant + "]"); + this._logCON(' -- B GLBLMulti enumConstant=[' + enumConstant + ']'); // our enum name can have a step offset //nameOffset = line.indexOf(enumConstant, currSingleLineOffset); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: enumConstant.length, - ptTokenType: "enumMember", - ptTokenModifiers: ["declaration", "readonly"], + ptTokenType: 'enumMember', + ptTokenModifiers: ['declaration', 'readonly'] }); } else if (this.parseUtils.isP1AsmVariable(enumConstant)) { // our SPIN1 name - this._logCON(" -- B GLBL bad SPIN1=[" + enumConstant + "]"); + this._logCON(' -- B GLBL bad SPIN1=[' + enumConstant + ']'); //nameOffset = line.indexOf(enumConstant, currSingleLineOffset); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: enumConstant.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -2323,26 +2486,28 @@ export class Spin2DocumentSemanticParser { const nonCommentConstantLine = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); if (nonCommentConstantLine.length > 0) { const haveEnumDeclaration: boolean = this._isEnumDeclarationLine(lineIdx, 0, nonCommentConstantLine); - const isAssignment: boolean = nonCommentConstantLine.indexOf("=") != -1; + const isAssignment: boolean = nonCommentConstantLine.indexOf('=') != -1; if (!haveEnumDeclaration && isAssignment) { this.conEnumInProgress = false; } else { this.conEnumInProgress = this.conEnumInProgress || haveEnumDeclaration; } - const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(",") != -1; - this._logCON(`- reportConstant haveEnum=(${haveEnumDeclaration}), containsMulti=(${containsMultiStatements}), nonCommentConstantLine=[${nonCommentConstantLine}]`); + const containsMultiStatements: boolean = nonCommentConstantLine.indexOf(',') != -1; + this._logCON( + `- reportConstant haveEnum=(${haveEnumDeclaration}), containsMulti=(${containsMultiStatements}), nonCommentConstantLine=[${nonCommentConstantLine}]` + ); let statements: string[] = [nonCommentConstantLine]; if (!haveEnumDeclaration && !this.conEnumInProgress) { if (containsMultiStatements) { - statements = nonCommentConstantLine.split(",").filter(Boolean); + statements = nonCommentConstantLine.split(',').filter(Boolean); } this._logCON(` -- assignments statements=[${statements}](${statements.length})`); for (let index = 0; index < statements.length; index++) { const conDeclarationLine: string = statements[index].trim(); - this._logCON(" -- conDeclarationLine=[" + conDeclarationLine + "]"); + this._logCON(' -- conDeclarationLine=[' + conDeclarationLine + ']'); currentOffset = line.indexOf(conDeclarationLine, currentOffset); // locate key indicators of line style - const isAssignment: boolean = conDeclarationLine.indexOf("=") != -1; + const isAssignment: boolean = conDeclarationLine.indexOf('=') != -1; if (!isAssignment) { if (!this.parseUtils.isDebugInvocation(conDeclarationLine)) { this.semanticFindings.pushDiagnosticMessage( @@ -2358,51 +2523,63 @@ export class Spin2DocumentSemanticParser { // have line assigning value to new constant // ------------------------------------------- // process LHS - const assignmentParts: string[] = conDeclarationLine.split("="); + const assignmentParts: string[] = conDeclarationLine.split('='); const lhsConstantName = assignmentParts[0].trim(); const nameOffset = line.indexOf(lhsConstantName, currentOffset); - this._logCON(" -- GLBL assign lhsConstantName=[" + lhsConstantName + "]"); + this._logCON(' -- GLBL assign lhsConstantName=[' + lhsConstantName + ']'); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(lhsConstantName)) { referenceDetails = this.semanticFindings.getGlobalToken(lhsConstantName); - this._logCON(" -- FOUND rcdl lhs global " + this._rememberdTokenString(lhsConstantName, referenceDetails)); + this._logCON(' -- FOUND rcdl lhs global ' + this._rememberdTokenString(lhsConstantName, referenceDetails)); } if (referenceDetails != undefined) { // this is a constant declaration! - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: lhsConstantName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); } else { - this._logCON(" -- CON ERROR[CODE] missed recording declaration! name=[" + lhsConstantName + "]"); + this._logCON(' -- CON ERROR[CODE] missed recording declaration! name=[' + lhsConstantName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: lhsConstantName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); if (this.parseUtils.isP1AsmVariable(lhsConstantName)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + lhsConstantName.length, eSeverity.Error, `P1 pasm variable [${lhsConstantName}] not allowed in P2 spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + lhsConstantName.length, + eSeverity.Error, + `P1 pasm variable [${lhsConstantName}] not allowed in P2 spin` + ); } else { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + lhsConstantName.length, eSeverity.Error, `Missing Variable Declaration [${lhsConstantName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + lhsConstantName.length, + eSeverity.Error, + `Missing Variable Declaration [${lhsConstantName}]` + ); } } // remove front LHS of assignment and process remainder // process RHS - const fistEqualOffset: number = conDeclarationLine.indexOf("="); + const fistEqualOffset: number = conDeclarationLine.indexOf('='); const assignmentRHSStr = conDeclarationLine.substring(fistEqualOffset + 1).trim(); currentOffset = line.indexOf(assignmentRHSStr, fistEqualOffset); // skip to RHS of assignment - this._logCON(" -- CON assignmentRHSStr=[" + assignmentRHSStr + "]"); + this._logCON(' -- CON assignmentRHSStr=[' + assignmentRHSStr + ']'); const possNames: string[] = this.parseUtils.getNonWhiteCONLineParts(assignmentRHSStr); this._logCON(` -- CON possNames=[${possNames}](${possNames.length})`); for (let index = 0; index < possNames.length; index++) { const possibleName = possNames[index]; - const currPossibleLen = possibleName.length; + //const currPossibleLen = possibleName.length; if (possibleName.charAt(0).match(/[a-zA-Z_]/)) { // does name contain a namespace reference? let nameOffset: number = line.indexOf(possibleName, currentOffset); @@ -2413,7 +2590,7 @@ export class Spin2DocumentSemanticParser { currentOffset = nameOffset + possibleName.length; continue; } - possibleNameSet = possibleName.split("."); + possibleNameSet = possibleName.split('.'); } this._logCON(` -- possibleNameSet=[${possibleNameSet}](${possibleNameSet.length})`); const namePart: string = possibleNameSet[0]; @@ -2423,7 +2600,7 @@ export class Spin2DocumentSemanticParser { this._logCON(` -- namePart=[${namePart}], ofs=(${nameOffset})`); if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); - this._logCON(" -- FOUND rcds rhs global " + this._rememberdTokenString(namePart, referenceDetails)); + this._logCON(' -- FOUND rcds rhs global ' + this._rememberdTokenString(namePart, referenceDetails)); } if (referenceDetails != undefined) { // this is a constant reference! @@ -2432,19 +2609,43 @@ export class Spin2DocumentSemanticParser { startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { - if (this.parseUtils.isFloatConversion(namePart) && (assignmentRHSStr.indexOf(namePart + "(") == -1 || assignmentRHSStr.indexOf(namePart + "()") != -1)) { - this._logCON(" -- CON MISSING parens=[" + namePart + "]"); + const methodFollowString: string = line.substring(nameOffset + namePart.length); + this._logSPIN(` -- CON func Paren chk methodFollowString=[${methodFollowString}](${methodFollowString.length})`); + if (this.parseUtils.isFloatConversion(namePart) && !isMethodCall(methodFollowString)) { + this._logCON(` -- CON MISSING parens=[${namePart}]`); + this._recordToken(tokenSet, line, { + line: lineIdx, + startCharacter: nameOffset, + length: namePart.length, + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] + }); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin CON missing parens [${namePart}]` + ); + } else if (this.parseUtils.isFloatConversion(namePart) && isMethodCallEmptyParens(methodFollowString)) { + this._logCON(` -- CON EMPTY parens=[${namePart}]`); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin CON missing parens [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin CON function w/empty parens [${namePart}]` + ); } else if ( !this.parseUtils.isSpinReservedWord(namePart) && !this.parseUtils.isBuiltinStreamerReservedWord(namePart) && @@ -2452,18 +2653,30 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isDebugControlSymbol(namePart) && !this.parseUtils.isUnaryOperator(namePart) ) { - this._logCON(" -- CON MISSING name=[" + namePart + "]"); + this._logCON(' -- CON MISSING name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); if (this.parseUtils.isP1AsmVariable(namePart)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 pasm variable [${namePart}] in not allowed P2 spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 pasm variable [${namePart}] in not allowed P2 spin` + ); } else { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `Missing Constant Declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `Missing Constant Declaration [${namePart}]` + ); } } else { if ( @@ -2472,15 +2685,21 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isBinaryOperator(namePart) && !this.parseUtils.isSpinNumericSymbols(namePart) ) { - this._logCON(" -- CON MISSING declaration=[" + namePart + "]"); + this._logCON(' -- CON MISSING declaration=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin CON missing Declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin CON missing Declaration [${namePart}]` + ); } } } @@ -2494,60 +2713,70 @@ export class Spin2DocumentSemanticParser { // have line creating one or more of enum constants // ------------------------------------------------- // recognize enum values getting initialized - const lineParts: string[] = nonCommentConstantLine.split(",").filter(Boolean); + const lineParts: string[] = nonCommentConstantLine.split(',').filter(Boolean); this._logCON(` -- enum lineParts=[${lineParts}](${lineParts.length})`); let nameOffset: number = 0; let nameLen: number = 0; for (let index = 0; index < lineParts.length; index++) { let enumConstant = lineParts[index].trim(); // our enum name can have a step offset: name[step] - if (enumConstant.includes("[")) { + if (enumConstant.includes('[')) { // it does, isolate name from offset - const enumNameParts: string[] = enumConstant.split("["); + const enumNameParts: string[] = enumConstant.split('['); enumConstant = enumNameParts[0]; } nameLen = enumConstant.length; - if (enumConstant.includes("=")) { - const enumAssignmentParts: string[] = enumConstant.split("="); + if (enumConstant.includes('=')) { + const enumAssignmentParts: string[] = enumConstant.split('='); enumConstant = enumAssignmentParts[0].trim(); const enumExistingName: string = enumAssignmentParts[1].trim(); nameLen = enumExistingName.length; // len changed assign again... if (enumExistingName.charAt(0).match(/[a-zA-Z_]/)) { - this._logCON(" -- A GLBL enumExistingName=[" + enumExistingName + "]"); + this._logCON(' -- A GLBL enumExistingName=[' + enumExistingName + ']'); // our enum name can have a step offset nameOffset = line.indexOf(enumExistingName, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: enumExistingName.length, - ptTokenType: "enumMember", - ptTokenModifiers: ["readonly"], + ptTokenType: 'enumMember', + ptTokenModifiers: ['readonly'] }); } } - if (enumConstant.charAt(0).match(/[a-zA-Z_]/) && !this.parseUtils.isDebugInvocation(enumConstant) && !this.parseUtils.isP1AsmVariable(enumConstant)) { - this._logCON(" -- B GLBL enumConstant=[" + enumConstant + "]"); + if ( + enumConstant.charAt(0).match(/[a-zA-Z_]/) && + !this.parseUtils.isDebugInvocation(enumConstant) && + !this.parseUtils.isP1AsmVariable(enumConstant) + ) { + this._logCON(' -- B GLBL enumConstant=[' + enumConstant + ']'); // our enum name can have a step offset nameOffset = line.indexOf(enumConstant, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: enumConstant.length, - ptTokenType: "enumMember", - ptTokenModifiers: ["declaration", "readonly"], + ptTokenType: 'enumMember', + ptTokenModifiers: ['declaration', 'readonly'] }); } else if (this.parseUtils.isP1AsmVariable(enumConstant)) { // our SPIN1 name - this._logCON(" -- B GLBL bad SPIN1=[" + enumConstant + "]"); + this._logCON(' -- B GLBL bad SPIN1=[' + enumConstant + ']'); nameOffset = line.indexOf(enumConstant, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: enumConstant.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + enumConstant.length, eSeverity.Error, `P1 Spin constant [${enumConstant}] not allowed in P2 Spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + enumConstant.length, + eSeverity.Error, + `P1 Spin constant [${enumConstant}] not allowed in P2 Spin` + ); } currentOffset = nameOffset + nameLen; } @@ -2564,94 +2793,131 @@ export class Spin2DocumentSemanticParser { let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const dataDeclNonCommentStr = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); - let lineParts: string[] = this.parseUtils.getNonWhiteLineParts(dataDeclNonCommentStr); + const lineParts: string[] = this.parseUtils.getNonWhiteLineParts(dataDeclNonCommentStr); this._logDAT(`- rptDataDeclLn lineParts=[${lineParts}](${lineParts.length})`); // remember this object name so we can annotate a call to it if (lineParts.length > 1) { - if (this.parseUtils.isStorageType(lineParts[0]) || lineParts[0].toUpperCase() == "FILE" || lineParts[0].toUpperCase() == "ORG") { + if (this.parseUtils.isStorageType(lineParts[0]) || lineParts[0].toUpperCase() == 'FILE' || lineParts[0].toUpperCase() == 'ORG') { // if we start with storage type (or FILE, or ORG), not name, process rest of line for symbols currentOffset = line.indexOf(lineParts[0], currentOffset); const allowLocalVarStatus: boolean = false; const NOT_DAT_PASM: boolean = false; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(lineIdx, startingOffset, line, allowLocalVarStatus, this.showDAT, NOT_DAT_PASM); - this._reportNonDupeTokens(partialTokenSet, "=> DATvalue: ", line, tokenSet); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + lineIdx, + startingOffset, + line, + allowLocalVarStatus, + this.showDAT, + NOT_DAT_PASM + ); + this._reportNonDupeTokens(partialTokenSet, '=> DATvalue: ', line, tokenSet); } else { // this is line with name, storageType, and initial value - this._logDAT(" -- rptDatDecl lineParts=[" + lineParts + "]"); - let newName = lineParts[0]; + this._logDAT(' -- rptDatDecl lineParts=[' + lineParts + ']'); + const newName = lineParts[0]; const nameOffset: number = line.indexOf(newName, currentOffset); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(newName)) { referenceDetails = this.semanticFindings.getGlobalToken(newName); - this._logMessage(" -- FOUND rddl global name=[" + newName + "]"); + this._logMessage(' -- FOUND rddl global name=[' + newName + ']'); } if (referenceDetails != undefined) { // add back in our declaration flag - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); } else if (!this.parseUtils.isP2AsmReservedSymbols(newName) && !this.parseUtils.isP2AsmInstruction(newName)) { - this._logDAT(" -- DAT rDdl MISSING name=[" + newName + "]"); + this._logDAT(' -- DAT rDdl MISSING name=[' + newName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + newName.length, eSeverity.Error, `P2 Spin A missing declaration [${newName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + newName.length, + eSeverity.Error, + `P2 Spin A missing declaration [${newName}]` + ); } // process remainder of line currentOffset = line.indexOf(lineParts[1], nameOffset + newName.length); const allowLocalVarStatus: boolean = false; const NOT_DAT_PASM: boolean = false; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(lineIdx, startingOffset, line, allowLocalVarStatus, this.showDAT, NOT_DAT_PASM); - this._reportNonDupeTokens(partialTokenSet, "=> DATvalue: ", line, tokenSet); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + lineIdx, + startingOffset, + line, + allowLocalVarStatus, + this.showDAT, + NOT_DAT_PASM + ); + this._reportNonDupeTokens(partialTokenSet, '=> DATvalue: ', line, tokenSet); } } else if (lineParts.length == 1) { // handle name declaration only line: [name 'comment] - let newName = lineParts[0]; + const newName = lineParts[0]; if (!this.parseUtils.isAlignType(newName)) { let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(newName)) { referenceDetails = this.semanticFindings.getGlobalToken(newName); - this._logMessage(" -- FOUND global name=[" + newName + "]"); + this._logMessage(' -- FOUND global name=[' + newName + ']'); } if (referenceDetails != undefined) { // add back in our declaration flag - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: currentOffset, length: newName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); - } else if (this.parseUtils.isP1AsmInstruction(newName) || this.parseUtils.isBadP1AsmEffectOrConditional(newName) || this.parseUtils.isP1AsmVariable(newName)) { - this._logMessage(" -- ERROR p1asm name=[" + newName + "]"); + } else if ( + this.parseUtils.isP1AsmInstruction(newName) || + this.parseUtils.isBadP1AsmEffectOrConditional(newName) || + this.parseUtils.isP1AsmVariable(newName) + ) { + this._logMessage(' -- ERROR p1asm name=[' + newName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: currentOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, currentOffset, currentOffset + newName.length, eSeverity.Error, `P1 pasm name [${newName}] not allowed in P2 Spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + currentOffset, + currentOffset + newName.length, + eSeverity.Error, + `P1 pasm name [${newName}] not allowed in P2 Spin` + ); } } } else { - this._logDAT(" -- DAT SKIPPED: lineParts=[" + lineParts + "]"); + this._logDAT(' -- DAT SKIPPED: lineParts=[' + lineParts + ']'); } return tokenSet; } - private _reportDAT_ValueDeclarationCode(lineIdx: number, startingOffset: number, line: string, allowLocal: boolean, showDebug: boolean, isDatPAsm: boolean): IParsedToken[] { + private _reportDAT_ValueDeclarationCode( + lineIdx: number, + startingOffset: number, + line: string, + allowLocal: boolean, + showDebug: boolean, + isDatPAsm: boolean + ): IParsedToken[] { // process line that starts with possible name then storage type (or FILE, or ORG), if not name, process rest of line for symbols const lineNbr: number = lineIdx + 1; const tokenSet: IParsedToken[] = []; @@ -2662,8 +2928,10 @@ export class Spin2DocumentSemanticParser { let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const dataValueInitStr: string = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (dataValueInitStr.length > 0) { - this._logMessage(` -- reportDataValueInit dataValueInitStr=[${dataValueInitStr}](${dataValueInitStr.length}), currentOffset=(${currentOffset})`); - let lineParts: string[] = this.parseUtils.getNonWhiteDataInitLineParts(dataValueInitStr); + this._logMessage( + ` -- reportDataValueInit dataValueInitStr=[${dataValueInitStr}](${dataValueInitStr.length}), currentOffset=(${currentOffset})` + ); + const lineParts: string[] = this.parseUtils.getNonWhiteDataInitLineParts(dataValueInitStr); let haveStorageType: boolean = false; this._logMessage(` -- lineParts=[${lineParts}](${lineParts.length})`); // process remainder of line @@ -2672,45 +2940,49 @@ export class Spin2DocumentSemanticParser { } if (lineParts.length > 1) { let nameOffset: number = 0; - let namePart: string = ""; + let namePart: string = ''; + let namePartLength: number = 0; + this._logMessage(` -- DATval loop start currentOffset=(${currentOffset})`); for (let index = 0; index < lineParts.length; index++) { - const possibleName = lineParts[index].replace(/[\(\)\@]/, ""); + const possibleName = lineParts[index].replace(/[()@]/, ''); + const possibleNameLength = possibleName.length; //if (showDebug) { // this._logMessage(' -- possibleName=[' + possibleName + ']'); //} - const currPossibleLen = possibleName.length; - if (currPossibleLen < 1) { + if (possibleNameLength < 1) { continue; } if (!haveStorageType && this.parseUtils.isDatStorageType(possibleName)) { haveStorageType = true; // only skip 1st storage type, more is error + this._logMessage(` -- DATval skipping past storage type currentOffset=(${currentOffset}) -> (${currentOffset + possibleNameLength})`); + currentOffset += possibleNameLength; continue; } // the following allows '.' in names but only when in DAT PASM code, not spin! - if (possibleName.charAt(0).match(/[a-zA-Z_]/) || (isDatPAsm && possibleName.charAt(0).match(/[a-zA-Z_\.]/))) { + if (possibleName.charAt(0).match(/[a-zA-Z_]/) || (isDatPAsm && possibleName.charAt(0).match(/[a-zA-Z_.]/))) { nameOffset = line.indexOf(possibleName, currentOffset); - if (showDebug) { - this._logMessage(` -- DATval possibleName=[${possibleName}]`); - } + this._logMessage(` -- DATval possibleName=[${possibleName}], ofs=(${nameOffset}), currentOffset=(${currentOffset})`); // does name contain a namespace reference? let possibleNameSet: string[] = [possibleName]; if (this._isPossibleObjectReference(possibleName)) { const bHaveObjReference = this._reportObjectReference(possibleName, lineIdx, nameOffset, line, tokenSet); if (bHaveObjReference) { - currentOffset = nameOffset + possibleName.length; + this._logMessage(` -- DATval skipping past objRef currentOffset=(${currentOffset}) -> (${nameOffset + possibleNameLength})`); + currentOffset = nameOffset + possibleNameLength; continue; } } - if (possibleName.includes(".") && !possibleName.startsWith(".")) { - possibleNameSet = possibleName.split("."); + if (possibleName.includes('.') && !possibleName.startsWith('.')) { + possibleNameSet = possibleName.split('.'); } if (showDebug) { this._logMessage(` -- possibleNameSet=[${possibleNameSet}](${possibleNameSet.length})`); } namePart = possibleNameSet[0]; + namePartLength = namePart.length; const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : `${possibleNameSet[0]}.${possibleNameSet[1]}`; nameOffset = line.indexOf(searchString, currentOffset); - this._logMessage(` -- searchString=[${searchString}], ofs=(${nameOffset})`); + this._logMessage(` -- DATval searchString=[${searchString}], ofs=(${nameOffset}), currentOffset=(${currentOffset})`); let referenceDetails: RememberedToken | undefined = undefined; if (allowLocal) { referenceDetails = this.semanticFindings.getLocalTokenForLine(namePart, lineNbr); @@ -2734,9 +3006,9 @@ export class Spin2DocumentSemanticParser { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, - length: namePart.length, + length: namePartLength, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { if ( @@ -2750,20 +3022,27 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isBuiltinStreamerReservedWord(namePart) ) { if (showDebug) { - this._logMessage(" -- DAT rDvdc MISSING name=[" + namePart + "]"); + this._logMessage(' -- DAT rDvdc MISSING name=[' + namePart + ']'); } this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, - length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + length: namePartLength, + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin DAT missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePartLength, + eSeverity.Error, + `P2 Spin DAT missing declaration [${namePart}]` + ); } } + this._logMessage(` -- DATval loop-bottom currentOffset=(${currentOffset}) -> (${nameOffset + namePartLength})`); + currentOffset = nameOffset + namePartLength; } - currentOffset = nameOffset + namePart.length; } } } @@ -2779,13 +3058,15 @@ export class Spin2DocumentSemanticParser { const inLinePAsmRHSStr: string = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); if (inLinePAsmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhitePAsmLineParts(inLinePAsmRHSStr); - this._logPASM(` -- DAT PAsm lineParts=[${lineParts}](${lineParts.length}), inLinePAsmRHSStr=[${inLinePAsmRHSStr}](${inLinePAsmRHSStr.length})`); + this._logPASM( + ` -- DAT PAsm lineParts=[${lineParts}](${lineParts.length}), inLinePAsmRHSStr=[${inLinePAsmRHSStr}](${inLinePAsmRHSStr.length})` + ); currentOffset = line.indexOf(inLinePAsmRHSStr.trim(), currentOffset); // handle name in 1 column const bIsAlsoDebugLine: boolean = haveDebugLine(inLinePAsmRHSStr); // inLinePAsmRHSStr.toLowerCase().indexOf("debug(") != -1 ? true : false; if (bIsAlsoDebugLine) { const partialTokenSet: IParsedToken[] = this._reportDebugStatement(lineIdx, startingOffset, line); - this._reportNonDupeTokens(partialTokenSet, "=> DATpasm: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> DATpasm: ', line, tokenSet); } // specials for detecting and failing FLexSpin'isms // @@ -2798,7 +3079,7 @@ export class Spin2DocumentSemanticParser { // end // const checkWord: string | undefined = lineParts.length > 0 ? lineParts[0].toLowerCase() : undefined; - if (checkWord && !this.configuration.highlightFlexspinDirectives && (checkWord === "if" || checkWord === "else" || checkWord === "end")) { + if (checkWord && !this.configuration.highlightFlexspinDirectives && (checkWord === 'if' || checkWord === 'else' || checkWord === 'end')) { // fail FlexSpin IF: if NUMLOCK_DEFAULT_STATE && RPI_KEYBOARD_NUMLOCK_HACK // fail FlexSpin else: else // fail FlexSpin end: end @@ -2807,10 +3088,16 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: currentOffset, length: inLinePAsmRHSStr.length, - ptTokenType: "variable", // mark this offender! - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', // mark this offender! + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, currentOffset, currentOffset + inLinePAsmRHSStr.length, eSeverity.Error, `FlexSpin if/else/end not conditional supported in P2 pasm`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + currentOffset, + currentOffset + inLinePAsmRHSStr.length, + eSeverity.Error, + `FlexSpin if/else/end not conditional supported in P2 pasm` + ); return tokenSet; } let haveLabel: boolean = lineParts.length > 0 && this.parseUtils.isDatOrPAsmLabel(lineParts[0]); @@ -2830,38 +3117,50 @@ export class Spin2DocumentSemanticParser { } if (referenceDetails != undefined) { this._logPASM(` -- DAT PAsm ${referenceDetails.type}=[${labelName}](${nameOffset})`); - const modifiersWDecl: string[] = referenceDetails.modifiersWith("declaration"); + const modifiersWDecl: string[] = referenceDetails.modifiersWith('declaration'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: labelName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modifiersWDecl, + ptTokenModifiers: modifiersWDecl }); haveLabel = true; - } else if (labelName.startsWith(":")) { + } else if (labelName.startsWith(':')) { // hrmf... no global type???? this should be a label? this._logPASM(` -- DAT PAsm ERROR Spin1 label=[${labelName}](${0 + 1})`); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: labelName.length, - ptTokenType: "variable", // color this offender! - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', // color this offender! + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + labelName.length, eSeverity.Error, `P1 pasm local name [${labelName}] not supported in P2 pasm`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + labelName.length, + eSeverity.Error, + `P1 pasm local name [${labelName}] not supported in P2 pasm` + ); haveLabel = true; - } else if (labelName.toLowerCase() != "debug" && bIsAlsoDebugLine) { + } else if (labelName.toLowerCase() != 'debug' && bIsAlsoDebugLine) { // hrmf... no global type???? this should be a label? this._logPASM(` -- DAT PAsm ERROR NOT A label=[${labelName}](${0 + 1})`); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: labelName.length, - ptTokenType: "variable", // color this offender! - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', // color this offender! + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + labelName.length, eSeverity.Error, `Not a legal P2 pasm label [${labelName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + labelName.length, + eSeverity.Error, + `Not a legal P2 pasm label [${labelName}]` + ); haveLabel = true; } else if (this.parseUtils.isP1AsmInstruction(labelName)) { // hrmf... no global type???? this should be a label? @@ -2870,10 +3169,16 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: labelName.length, - ptTokenType: "variable", // color this offender! - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', // color this offender! + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + labelName.length, eSeverity.Error, "Not a legal P2 pasm label"); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + labelName.length, + eSeverity.Error, + 'Not a legal P2 pasm label' + ); haveLabel = true; } currentOffset = nameOffset + labelName.length; @@ -2888,8 +3193,10 @@ export class Spin2DocumentSemanticParser { argumentOffset++; minNonLabelParts++; } - this._logPASM(` -- DAT PASM !dataDecl lineParts=[${lineParts}](${lineParts.length}), argumentOffset=(${argumentOffset}), minNonLabelParts=(${minNonLabelParts})`); - if (lineParts[argumentOffset].toUpperCase().startsWith("IF_") || lineParts[argumentOffset].toUpperCase().startsWith("_RET_")) { + this._logPASM( + ` -- DAT PASM !dataDecl lineParts=[${lineParts}](${lineParts.length}), argumentOffset=(${argumentOffset}), minNonLabelParts=(${minNonLabelParts})` + ); + if (lineParts[argumentOffset].toUpperCase().startsWith('IF_') || lineParts[argumentOffset].toUpperCase().startsWith('_RET_')) { // skip our conditional argumentOffset++; minNonLabelParts++; @@ -2901,22 +3208,22 @@ export class Spin2DocumentSemanticParser { this._logPASM(` -- DAT PASM likelyInstructionName=[${likelyInstructionName}], nameOffset=(${nameOffset})`); currentOffset = nameOffset + likelyInstructionName.length; // move past the instruction for (let index = minNonLabelParts; index < lineParts.length; index++) { - let argumentName = lineParts[index].replace(/[@#]/, ""); - if (argumentName.length < 1 || argumentName === ":") { + let argumentName = lineParts[index].replace(/[@#]/, ''); + if (argumentName.length < 1 || argumentName === ':') { // skip empty operand or ":" left by splitter continue; } if (index == lineParts.length - 1 && this.parseUtils.isP2AsmEffect(argumentName)) { // conditional flag-set spec. - this._logPASM(" -- SKIP argumentName=[" + argumentName + "]"); + this._logPASM(' -- SKIP argumentName=[' + argumentName + ']'); continue; } - const argHasArrayRereference: boolean = argumentName.includes("["); + const argHasArrayRereference: boolean = argumentName.includes('['); if (argHasArrayRereference) { - const nameParts: string[] = argumentName.split("["); + const nameParts: string[] = argumentName.split('['); argumentName = nameParts[0]; } - if (argumentName.charAt(0).match(/[a-zA-Z_\.\:]/)) { + if (argumentName.charAt(0).match(/[a-zA-Z_.:]/)) { // does name contain a namespace reference? this._logPASM(` -- argumentName=[${argumentName}]`); let possibleNameSet: string[] = [argumentName]; @@ -2927,8 +3234,8 @@ export class Spin2DocumentSemanticParser { currentOffset = currentOffset + argumentName.length; continue; } - if (!argumentName.startsWith(".")) { - possibleNameSet = argumentName.split("."); + if (!argumentName.startsWith('.')) { + possibleNameSet = argumentName.split('.'); } } this._logPASM(` -- possibleNameSet=[${possibleNameSet}]`); @@ -2948,7 +3255,7 @@ export class Spin2DocumentSemanticParser { startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // we use bIsDebugLine in next line so we don't flag debug() arguments! @@ -2964,20 +3271,38 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isStorageType(namePart) && !bIsAlsoDebugLine ) { - this._logPASM(" -- DAT PAsm MISSING name=[" + namePart + "], ofs=(" + nameOffset + ")"); + this._logPASM(' -- DAT PAsm MISSING name=[' + namePart + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - if (namePart.startsWith(":")) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 pasm local name [${namePart}] not supported in P2 pasm`); + if (namePart.startsWith(':')) { + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 pasm local name [${namePart}] not supported in P2 pasm` + ); } else if (this.parseUtils.isP1AsmVariable(namePart)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 pasm variable [${namePart}] not allowed in P2 pasm`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 pasm variable [${namePart}] not allowed in P2 pasm` + ); } else { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `Missing P2 pasm name [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `Missing P2 pasm name [${namePart}]` + ); } } } @@ -2986,13 +3311,13 @@ export class Spin2DocumentSemanticParser { } if (this.parseUtils.isP1AsmInstruction(likelyInstructionName)) { const nameOffset: number = line.indexOf(likelyInstructionName, 0); - this._logPASM(" -- DAT A P1asm BAD instru=[" + likelyInstructionName + "], ofs=(" + nameOffset + ")"); + this._logPASM(' -- DAT A P1asm BAD instru=[' + likelyInstructionName + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: likelyInstructionName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -3006,13 +3331,13 @@ export class Spin2DocumentSemanticParser { } else if (lineParts.length == 1 && this.parseUtils.isP1AsmInstruction(lineParts[0])) { const likelyInstructionName: string = lineParts[0]; const nameOffset: number = line.indexOf(likelyInstructionName, 0); - this._logPASM(" -- DAT B P1asm BAD instru=[" + likelyInstructionName + "], ofs=(" + nameOffset + ")"); + this._logPASM(' -- DAT B P1asm BAD instru=[' + likelyInstructionName + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: likelyInstructionName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -3032,8 +3357,15 @@ export class Spin2DocumentSemanticParser { } const allowLocalVarStatus: boolean = false; const IS_DAT_PASM: boolean = true; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(lineIdx, startingOffset, line, allowLocalVarStatus, this.showPAsmCode, IS_DAT_PASM); - this._reportNonDupeTokens(partialTokenSet, "=> DATvalue: ", line, tokenSet); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + lineIdx, + startingOffset, + line, + allowLocalVarStatus, + this.showPAsmCode, + IS_DAT_PASM + ); + this._reportNonDupeTokens(partialTokenSet, '=> DATvalue: ', line, tokenSet); } } return tokenSet; @@ -3045,7 +3377,7 @@ export class Spin2DocumentSemanticParser { // FIXME: TODO: UNDONE - maybe we need to highlight comments which are NOT captured yet in multi-line set const remainingNonCommentLineStr: string = multiLineSet.line; const methodType = remainingNonCommentLineStr.substr(0, 3).toUpperCase(); - const isPrivate = methodType.indexOf("PRI") != -1; + const isPrivate = methodType.indexOf('PRI') != -1; this._logOBJ( `- reportPubPriSigMulti Ln#${ multiLineSet.lineStartIdx + 1 @@ -3057,16 +3389,16 @@ export class Spin2DocumentSemanticParser { // const startNameOffset = currSingleLineOffset; // find open paren - skipping past method name - const returnValueSep = remainingNonCommentLineStr.indexOf(":", currSingleLineOffset); - const localVarsSep = remainingNonCommentLineStr.indexOf("|", returnValueSep != -1 ? returnValueSep : currSingleLineOffset); - currSingleLineOffset = remainingNonCommentLineStr.indexOf("(", startNameOffset); // in spin1 ()'s are optional! - const openParenOffset: number = currSingleLineOffset; + const returnValueSep = remainingNonCommentLineStr.indexOf(':', currSingleLineOffset); + const localVarsSep = remainingNonCommentLineStr.indexOf('|', returnValueSep != -1 ? returnValueSep : currSingleLineOffset); + currSingleLineOffset = remainingNonCommentLineStr.indexOf('(', startNameOffset); // in spin1 ()'s are optional! + //const openParenOffset: number = currSingleLineOffset; if (currSingleLineOffset == -1) { currSingleLineOffset = returnValueSep; // ":" if (currSingleLineOffset == -1) { currSingleLineOffset = localVarsSep; // "|" if (currSingleLineOffset == -1) { - currSingleLineOffset = remainingNonCommentLineStr.indexOf(" ", startNameOffset); + currSingleLineOffset = remainingNonCommentLineStr.indexOf(' ', startNameOffset); if (currSingleLineOffset == -1) { currSingleLineOffset = remainingNonCommentLineStr.indexOf("'", startNameOffset); if (currSingleLineOffset == -1) { @@ -3083,10 +3415,10 @@ export class Spin2DocumentSemanticParser { } currSingleLineOffset = startingOffset; // reset to beginnning of line this.currentMethodName = methodName; // notify of latest method name so we can track inLine PASM symbols - const spin2MethodName: string = methodName + "("; - const spin2MethodNameWithSpace: string = methodName + " ("; - // FIXME: TODO: UNDONE this should be match with name-infWhiteSpace-openParen! - this._logSPIN("-reportPubPriSig: spin2MethodName=[" + spin2MethodName + "], startNameOffset=(" + startNameOffset + ")"); + const spin2MethodName: string = methodName + '('; + const spin2MethodNameWithSpace: string = methodName + ' ('; + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' + this._logSPIN('-reportPubPriSig: spin2MethodName=[' + spin2MethodName + '], startNameOffset=(' + startNameOffset + ')'); let bHaveSpin2Method: boolean = false; let symbolPosition: Position = multiLineSet.locateSymbol(spin2MethodName, currSingleLineOffset); bHaveSpin2Method = symbolPosition.character != -1; @@ -3096,27 +3428,27 @@ export class Spin2DocumentSemanticParser { } const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); if (bHaveSpin2Method) { - const declModifiers: string[] = isPrivate ? ["declaration", "static"] : ["declaration"]; + const declModifiers: string[] = isPrivate ? ['declaration', 'static'] : ['declaration']; this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: methodName.length, - ptTokenType: "method", - ptTokenModifiers: declModifiers, + ptTokenType: 'method', + ptTokenModifiers: declModifiers }); - this._logSPIN("-reportPubPriSig: methodName=[" + methodName + "], startNameOffset=(" + startNameOffset + ")"); + this._logSPIN('-reportPubPriSig: methodName=[' + methodName + '], startNameOffset=(' + startNameOffset + ')'); } else { // have a P1 style method declaration, flag it! - const declModifiers: string[] = isPrivate ? ["declaration", "static", "illegalUse"] : ["declaration", "illegalUse"]; + const declModifiers: string[] = isPrivate ? ['declaration', 'static', 'illegalUse'] : ['declaration', 'illegalUse']; symbolPosition = multiLineSet.locateSymbol(methodName, currSingleLineOffset); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: methodName.length, - ptTokenType: "method", - ptTokenModifiers: declModifiers, + ptTokenType: 'method', + ptTokenModifiers: declModifiers }); - const methodPrefix: string = isPrivate ? "PRI" : "PUB"; + const methodPrefix: string = isPrivate ? 'PRI' : 'PUB'; this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, symbolPosition.character, @@ -3124,7 +3456,7 @@ export class Spin2DocumentSemanticParser { eSeverity.Error, `P1 Spin style declaration [${methodPrefix} ${methodName}] (without paren's) not allowed in P2 Spin` ); - this._logSPIN("-reportPubPriSig: SPIN1 methodName=[" + methodName + "], startNameOffset=(" + startNameOffset + ")"); + this._logSPIN('-reportPubPriSig: SPIN1 methodName=[' + methodName + '], startNameOffset=(' + startNameOffset + ')'); } currSingleLineOffset = nameOffset + methodName.length; @@ -3135,15 +3467,15 @@ export class Spin2DocumentSemanticParser { // find close paren - so we can study parameters let closeParenOffset: number = -1; if (bHaveSpin2Method) { - closeParenOffset = remainingNonCommentLineStr.indexOf(")", currSingleLineOffset); + closeParenOffset = remainingNonCommentLineStr.indexOf(')', currSingleLineOffset); } if (closeParenOffset != -1 && currSingleLineOffset + 1 != closeParenOffset) { // we have parameter(s)! const parameterStr = remainingNonCommentLineStr.substr(currSingleLineOffset + 1, closeParenOffset - currSingleLineOffset - 1).trim(); let parameterNames: string[] = []; - if (parameterStr.includes(",")) { + if (parameterStr.includes(',')) { // we have multiple parameters - parameterNames = parameterStr.split(","); + parameterNames = parameterStr.split(','); } else { // we have one parameter parameterNames = [parameterStr]; @@ -3151,12 +3483,12 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < parameterNames.length; index++) { const paramNameRaw: string = parameterNames[index].trim(); let paramName: string = paramNameRaw; - const hasFlexSpinDefaultValue: boolean = paramName.includes("="); + const hasFlexSpinDefaultValue: boolean = paramName.includes('='); //const nameOffset = remainingNonCommentLineStr.indexOf(paramName, currSingleLineOffset); const symbolPosition: Position = multiLineSet.locateSymbol(paramName, currSingleLineOffset); const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); if (hasFlexSpinDefaultValue) { - const assignmentParts: string[] = paramName.split("="); + const assignmentParts: string[] = paramName.split('='); paramName = assignmentParts[0].trim(); } this._logSPIN(` -- paramName=[${paramName}], ofs=(${nameOffset})`); @@ -3166,8 +3498,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: paramName.length, - ptTokenType: "parameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'parameter', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -3181,15 +3513,15 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: paramName.length, - ptTokenType: "parameter", - ptTokenModifiers: ["declaration", "readonly", "local"], + ptTokenType: 'parameter', + ptTokenModifiers: ['declaration', 'readonly', 'local'] }); } // remember so we can ID references this.semanticFindings.setLocalTokenForMethod( methodName, paramName, - new RememberedToken("parameter", symbolPosition.line, symbolPosition.character, ["readonly", "local"]), + new RememberedToken('parameter', symbolPosition.line, symbolPosition.character, ['readonly', 'local']), this._declarationComment() ); // TOKEN SET in _report() @@ -3211,7 +3543,7 @@ export class Spin2DocumentSemanticParser { // find return vars let beginCommentOffset = remainingNonCommentLineStr.indexOf("'", currSingleLineOffset); if (beginCommentOffset === -1) { - beginCommentOffset = remainingNonCommentLineStr.indexOf("{", currSingleLineOffset); + beginCommentOffset = remainingNonCommentLineStr.indexOf('{', currSingleLineOffset); } const nonCommentEOL = beginCommentOffset != -1 ? beginCommentOffset - 1 : remainingNonCommentLineStr.length - 1; const returnVarsEnd = localVarsSep != -1 ? localVarsSep - 1 : nonCommentEOL; @@ -3221,9 +3553,9 @@ export class Spin2DocumentSemanticParser { // we move currSingleLineOffset along so we don't falsely find short variable names earlier in string! currSingleLineOffset = returnValueSep + 1; const varNameStr = remainingNonCommentLineStr.substr(returnValueSep + 1, returnVarsEnd - returnValueSep).trim(); - if (varNameStr.indexOf(",")) { + if (varNameStr.indexOf(',')) { // have multiple return value names - returnValueNames = varNameStr.split(","); + returnValueNames = varNameStr.split(','); } else { // have a single return value name returnValueNames = [varNameStr]; @@ -3240,8 +3572,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: returnValueName.length, - ptTokenType: "returnValue", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'returnValue', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -3255,15 +3587,15 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: returnValueName.length, - ptTokenType: "returnValue", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'returnValue', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references this.semanticFindings.setLocalTokenForMethod( methodName, returnValueName, - new RememberedToken("returnValue", symbolPosition.line, symbolPosition.character, ["local"]), + new RememberedToken('returnValue', symbolPosition.line, symbolPosition.character, ['local']), this._declarationComment() ); // TOKEN SET in _report() @@ -3280,9 +3612,9 @@ export class Spin2DocumentSemanticParser { // we move currSingleLineOffset along so we don't falsely find short variable names earlier in string! currSingleLineOffset = localVarsSep; let localVarNames: string[] = []; - if (localVarStr.indexOf(",")) { + if (localVarStr.indexOf(',')) { // have multiple return value names - localVarNames = localVarStr.split(","); + localVarNames = localVarStr.split(','); } else { // have a single return value name localVarNames = [localVarStr]; @@ -3290,12 +3622,12 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- localVarNames=[${localVarNames}](${localVarNames.length})`); for (let index = 0; index < localVarNames.length; index++) { const localVariableName = localVarNames[index].trim(); - const localVariableOffset = remainingNonCommentLineStr.indexOf(localVariableName, currSingleLineOffset); - this._logSPIN(" -- processing localVariableName=[" + localVariableName + "]"); + //const localVariableOffset = remainingNonCommentLineStr.indexOf(localVariableName, currSingleLineOffset); + this._logSPIN(' -- processing localVariableName=[' + localVariableName + ']'); let nameParts: string[] = []; - if (localVariableName.includes(" ")) { + if (localVariableName.includes(' ')) { // have name with storage and/or alignment operators - nameParts = localVariableName.split(" "); + nameParts = localVariableName.split(' '); } else { // have single name nameParts = [localVariableName]; @@ -3306,10 +3638,10 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < nameParts.length; index++) { let localName = nameParts[index]; // have name similar to scratch[12]? - if (localName.includes("[") || localName.includes("]")) { + if (localName.includes('[') || localName.includes(']')) { // yes remove array suffix const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(localName); - let localNameParts: string[] = lineInfo.lineParts; + const localNameParts: string[] = lineInfo.lineParts; this._logSPIN(` -- post[] localNameParts=[${localNameParts}](${localNameParts.length})`); localName = localNameParts[0]; nameOffset = 0; @@ -3319,10 +3651,18 @@ export class Spin2DocumentSemanticParser { if (namedIndexPart.charAt(0).match(/[a-zA-Z_]/)) { symbolPosition = multiLineSet.locateSymbol(namedIndexPart, currSingleLineOffset); nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); - this._logSPIN(` -- checking Multi namedIndexPart=[${localName}], posn={${symbolPosition.line}, ${symbolPosition.character}}, nameOffset=(${nameOffset})`); + this._logSPIN( + ` -- checking Multi namedIndexPart=[${localName}], posn={${symbolPosition.line}, ${symbolPosition.character}}, nameOffset=(${nameOffset})` + ); if (this._isPossibleObjectReference(namedIndexPart)) { // go register object reference! - const bHaveObjReference = this._reportObjectReference(namedIndexPart, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet); + const bHaveObjReference = this._reportObjectReference( + namedIndexPart, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ); if (bHaveObjReference) { currSingleLineOffset = nameOffset + namedIndexPart.length; continue; @@ -3343,7 +3683,7 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolPosition.character, length: namedIndexPart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { if ( @@ -3361,8 +3701,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namedIndexPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -3376,15 +3716,15 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namedIndexPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references this.semanticFindings.setLocalTokenForMethod( methodName, namedIndexPart, - new RememberedToken("variable", symbolPosition.line, symbolPosition.character, ["local"]), + new RememberedToken('variable', symbolPosition.line, symbolPosition.character, ['local']), this._declarationComment() ); // TOKEN SET in _report() } @@ -3405,8 +3745,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: localName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -3420,15 +3760,15 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: localName.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references this.semanticFindings.setLocalTokenForMethod( methodName, localName, - new RememberedToken("variable", symbolPosition.line, symbolPosition.character, ["local"]), + new RememberedToken('variable', symbolPosition.line, symbolPosition.character, ['local']), this._declarationComment() ); // TOKEN SET in _report() } else { @@ -3438,16 +3778,16 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: localName.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } else if (this.parseUtils.isAlignType(localName)) { this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: localName.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } } @@ -3463,12 +3803,10 @@ export class Spin2DocumentSemanticParser { const tokenSet: IParsedToken[] = []; const lineNbr: number = lineIdx + 1; const methodType = line.substr(0, 3).toUpperCase(); - const isPrivate = methodType.indexOf("PRI") != -1; + const isPrivate = methodType.indexOf('PRI') != -1; //skip Past Whitespace let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const spineDeclarationLHSStr = this._getNonCommentLineReturnComment(0, lineIdx, line, tokenSet); - if (spineDeclarationLHSStr) { - } // we don't use this string, we called this to record our rhs comment! this._logSPIN(`- Ln#${lineIdx + 1} reportPubPriSig line=[${line}](${line.length})`); // ----------------------------------- @@ -3476,14 +3814,14 @@ export class Spin2DocumentSemanticParser { // const startNameOffset = currentOffset; // find open paren - skipping past method name - currentOffset = spineDeclarationLHSStr.indexOf("(", startNameOffset); // in spin1 ()'s are optional! - const openParenOffset: number = currentOffset; + currentOffset = spineDeclarationLHSStr.indexOf('(', startNameOffset); // in spin1 ()'s are optional! + //const openParenOffset: number = currentOffset; if (currentOffset == -1) { - currentOffset = spineDeclarationLHSStr.indexOf(":", startNameOffset); + currentOffset = spineDeclarationLHSStr.indexOf(':', startNameOffset); if (currentOffset == -1) { - currentOffset = spineDeclarationLHSStr.indexOf("|", startNameOffset); + currentOffset = spineDeclarationLHSStr.indexOf('|', startNameOffset); if (currentOffset == -1) { - currentOffset = spineDeclarationLHSStr.indexOf(" ", startNameOffset); + currentOffset = spineDeclarationLHSStr.indexOf(' ', startNameOffset); if (currentOffset == -1) { currentOffset = spineDeclarationLHSStr.indexOf("'", startNameOffset); if (currentOffset == -1) { @@ -3500,35 +3838,37 @@ export class Spin2DocumentSemanticParser { } this.currentMethodName = methodName; // notify of latest method name so we can track inLine PASM symbols - const spin2MethodName: string = methodName + "("; - const spin2MethodNameWithSpace: string = methodName + " ("; - // FIXME: TODO: UNDONE this should be match with name-infWhiteSpace-openParen! + const spin2MethodName: string = methodName + '('; + const spin2MethodNameWithSpace: string = methodName + ' ('; + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' //const myExpression: string = `${methodName}\s\(`; //const methodNameRegEx = new RegExp(myExpression, "i"); // case-insensative method name with arbitrary whitespace before open paren const bHaveSpin2Method: boolean = line.includes(spin2MethodName) || line.includes(spin2MethodNameWithSpace); const bHaveSpin2Method2: boolean = false; // methodNameRegEx.test(line); - this._logSPIN(`-reportPubPriSig: spin2MethodName=[${spin2MethodName}], startNameOffset=(${startNameOffset}), bHaveSpin2Method=(${bHaveSpin2Method}), bHaveSpin2Method2=(${bHaveSpin2Method2})`); + this._logSPIN( + `-reportPubPriSig: spin2MethodName=[${spin2MethodName}], startNameOffset=(${startNameOffset}), bHaveSpin2Method=(${bHaveSpin2Method}), bHaveSpin2Method2=(${bHaveSpin2Method2})` + ); if (bHaveSpin2Method) { - const declModifiers: string[] = isPrivate ? ["declaration", "static"] : ["declaration"]; + const declModifiers: string[] = isPrivate ? ['declaration', 'static'] : ['declaration']; this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: startNameOffset, length: methodName.length, - ptTokenType: "method", - ptTokenModifiers: declModifiers, + ptTokenType: 'method', + ptTokenModifiers: declModifiers }); - this._logSPIN("-reportPubPriSig: methodName=[" + methodName + "], startNameOffset=(" + startNameOffset + ")"); + this._logSPIN('-reportPubPriSig: methodName=[' + methodName + '], startNameOffset=(' + startNameOffset + ')'); } else { // have a P1 style method declaration, flag it! - const declModifiers: string[] = isPrivate ? ["declaration", "static", "illegalUse"] : ["declaration", "illegalUse"]; + const declModifiers: string[] = isPrivate ? ['declaration', 'static', 'illegalUse'] : ['declaration', 'illegalUse']; this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: startNameOffset, length: methodName.length, - ptTokenType: "method", - ptTokenModifiers: declModifiers, + ptTokenType: 'method', + ptTokenModifiers: declModifiers }); - const methodPrefix: string = isPrivate ? "PRI" : "PUB"; + const methodPrefix: string = isPrivate ? 'PRI' : 'PUB'; this.semanticFindings.pushDiagnosticMessage( lineIdx, startNameOffset, @@ -3536,7 +3876,7 @@ export class Spin2DocumentSemanticParser { eSeverity.Error, `P1 Spin style declaration [${methodPrefix} ${methodName}] (without paren's) not allowed in P2 Spin` ); - this._logSPIN("-reportPubPriSig: SPIN1 methodName=[" + methodName + "], startNameOffset=(" + startNameOffset + ")"); + this._logSPIN('-reportPubPriSig: SPIN1 methodName=[' + methodName + '], startNameOffset=(' + startNameOffset + ')'); } // record definition of method // ----------------------------------- @@ -3545,15 +3885,15 @@ export class Spin2DocumentSemanticParser { // find close paren - so we can study parameters let closeParenOffset: number = -1; if (bHaveSpin2Method) { - closeParenOffset = line.indexOf(")", currentOffset); + closeParenOffset = line.indexOf(')', currentOffset); } if (closeParenOffset != -1 && currentOffset + 1 != closeParenOffset) { // we have parameter(s)! const parameterStr = line.substr(currentOffset + 1, closeParenOffset - currentOffset - 1).trim(); let parameterNames: string[] = []; - if (parameterStr.includes(",")) { + if (parameterStr.includes(',')) { // we have multiple parameters - parameterNames = parameterStr.split(","); + parameterNames = parameterStr.split(','); } else { // we have one parameter parameterNames = [parameterStr]; @@ -3561,10 +3901,10 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < parameterNames.length; index++) { const paramNameRaw: string = parameterNames[index].trim(); let paramName: string = paramNameRaw; - const hasFlexSpinDefaultValue: boolean = paramName.includes("="); + const hasFlexSpinDefaultValue: boolean = paramName.includes('='); const nameOffset = line.indexOf(paramName, currentOffset); if (hasFlexSpinDefaultValue) { - const assignmentParts: string[] = paramName.split("="); + const assignmentParts: string[] = paramName.split('='); paramName = assignmentParts[0].trim(); } this._logSPIN(` -- paramName=[${paramName}], ofs=(${nameOffset})`); @@ -3574,24 +3914,41 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: paramName.length, - ptTokenType: "parameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'parameter', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + paramName.length, eSeverity.Error, `P2 Spin parameter [${paramName}] hides global variable of same name`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + paramName.length, + eSeverity.Error, + `P2 Spin parameter [${paramName}] hides global variable of same name` + ); } else { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: paramName.length, - ptTokenType: "parameter", - ptTokenModifiers: ["declaration", "readonly", "local"], + ptTokenType: 'parameter', + ptTokenModifiers: ['declaration', 'readonly', 'local'] }); } // remember so we can ID references - this.semanticFindings.setLocalTokenForMethod(methodName, paramName, new RememberedToken("parameter", lineNbr - 1, nameOffset, ["readonly", "local"]), this._declarationComment()); // TOKEN SET in _report() + this.semanticFindings.setLocalTokenForMethod( + methodName, + paramName, + new RememberedToken('parameter', lineNbr - 1, nameOffset, ['readonly', 'local']), + this._declarationComment() + ); // TOKEN SET in _report() if (hasFlexSpinDefaultValue) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + paramNameRaw.length, eSeverity.Error, `Parameter default value [${paramNameRaw}] not allowed in P2 Spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + paramNameRaw.length, + eSeverity.Error, + `Parameter default value [${paramNameRaw}] not allowed in P2 Spin` + ); } currentOffset = nameOffset + paramName.length; } @@ -3600,11 +3957,11 @@ export class Spin2DocumentSemanticParser { // Return Variable(s) // // find return vars - const returnValueSep = line.indexOf(":", currentOffset); - const localVarsSep = line.indexOf("|", currentOffset); + const returnValueSep = line.indexOf(':', currentOffset); + const localVarsSep = line.indexOf('|', currentOffset); let beginCommentOffset = line.indexOf("'", currentOffset); if (beginCommentOffset === -1) { - beginCommentOffset = line.indexOf("{", currentOffset); + beginCommentOffset = line.indexOf('{', currentOffset); } const nonCommentEOL = beginCommentOffset != -1 ? beginCommentOffset - 1 : line.length - 1; const returnVarsEnd = localVarsSep != -1 ? localVarsSep - 1 : nonCommentEOL; @@ -3614,9 +3971,9 @@ export class Spin2DocumentSemanticParser { // we move currentOffset along so we don't falsely find short variable names earlier in string! currentOffset = returnValueSep + 1; const varNameStr = line.substr(returnValueSep + 1, returnVarsEnd - returnValueSep).trim(); - if (varNameStr.indexOf(",")) { + if (varNameStr.indexOf(',')) { // have multiple return value names - returnValueNames = varNameStr.split(","); + returnValueNames = varNameStr.split(','); } else { // have a single return value name returnValueNames = [varNameStr]; @@ -3624,15 +3981,15 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < returnValueNames.length; index++) { const returnValueName = returnValueNames[index].trim(); const nameOffset = line.indexOf(returnValueName, currentOffset); - this._logSPIN(" -- returnValueName=[" + returnValueName + "], ofs=(" + nameOffset + ")"); + this._logSPIN(' -- returnValueName=[' + returnValueName + '], ofs=(' + nameOffset + ')'); // check to see if return name is hiding global variable if (this._hidesGlobalVariable(returnValueName)) { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: returnValueName.length, - ptTokenType: "returnValue", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'returnValue', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -3646,12 +4003,17 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: returnValueName.length, - ptTokenType: "returnValue", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'returnValue', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references - this.semanticFindings.setLocalTokenForMethod(methodName, returnValueName, new RememberedToken("returnValue", lineNbr - 1, nameOffset, ["local"]), this._declarationComment()); // TOKEN SET in _report() + this.semanticFindings.setLocalTokenForMethod( + methodName, + returnValueName, + new RememberedToken('returnValue', lineNbr - 1, nameOffset, ['local']), + this._declarationComment() + ); // TOKEN SET in _report() currentOffset = nameOffset + returnValueName.length; } } @@ -3665,36 +4027,36 @@ export class Spin2DocumentSemanticParser { // we move currentOffset along so we don't falsely find short variable names earlier in string! currentOffset = localVarsSep + 1; let localVarNames: string[] = []; - if (localVarStr.indexOf(",")) { + if (localVarStr.indexOf(',')) { // have multiple return value names - localVarNames = localVarStr.split(","); + localVarNames = localVarStr.split(','); } else { // have a single return value name localVarNames = [localVarStr]; } - this._logSPIN(" -- localVarNames=[" + localVarNames + "]"); + this._logSPIN(' -- localVarNames=[' + localVarNames + ']'); for (let index = 0; index < localVarNames.length; index++) { const localVariableName = localVarNames[index].trim(); const localVariableOffset = line.indexOf(localVariableName, currentOffset); - this._logSPIN(" -- processing localVariableName=[" + localVariableName + "]"); + this._logSPIN(' -- processing localVariableName=[' + localVariableName + ']'); let nameParts: string[] = []; - if (localVariableName.includes(" ")) { + if (localVariableName.includes(' ')) { // have name with storage and/or alignment operators - nameParts = localVariableName.split(" "); + nameParts = localVariableName.split(' '); } else { // have single name nameParts = [localVariableName]; } - this._logSPIN(" -- nameParts=[" + nameParts + "]"); + this._logSPIN(' -- nameParts=[' + nameParts + ']'); let nameOffset: number = 0; for (let index = 0; index < nameParts.length; index++) { let localName = nameParts[index]; // have name similar to scratch[12]? - if (localName.includes("[") || localName.includes("]")) { + if (localName.includes('[') || localName.includes(']')) { // yes remove array suffix const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(localName); - let localNameParts: string[] = lineInfo.lineParts; - this._logSPIN(" -- post[] localNameParts=[" + localNameParts + "]"); + const localNameParts: string[] = lineInfo.lineParts; + this._logSPIN(' -- post[] localNameParts=[' + localNameParts + ']'); localName = localNameParts[0]; for (let index = 0; index < localNameParts.length; index++) { const namedIndexPart = localNameParts[index]; @@ -3718,13 +4080,13 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- FOUND global name=[${namedIndexPart}] found: ${referenceDetails != undefined}`); } if (referenceDetails != undefined) { - this._logSPIN(" -- lcl-idx variableName=[" + namedIndexPart + "], ofs=(" + nameOffset + ")"); + this._logSPIN(' -- lcl-idx variableName=[' + namedIndexPart + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namedIndexPart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { if ( @@ -3735,15 +4097,15 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isDebugControlSymbol(namedIndexPart) ) { // found new local variable name, register it - this._logSPIN(" -- SPIN NEW local varname=[" + namedIndexPart + "], ofs=(" + nameOffset + ")"); + this._logSPIN(' -- SPIN NEW local varname=[' + namedIndexPart + '], ofs=(' + nameOffset + ')'); // check to see if local name is hiding global variable if (this._hidesGlobalVariable(namedIndexPart)) { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namedIndexPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -3757,12 +4119,17 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: namedIndexPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references - this.semanticFindings.setLocalTokenForMethod(methodName, namedIndexPart, new RememberedToken("variable", lineNbr - 1, nameOffset, ["local"]), this._declarationComment()); // TOKEN SET in _report() + this.semanticFindings.setLocalTokenForMethod( + methodName, + namedIndexPart, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['local']), + this._declarationComment() + ); // TOKEN SET in _report() } } } @@ -3770,7 +4137,7 @@ export class Spin2DocumentSemanticParser { } } else { nameOffset = line.indexOf(localName, localVariableOffset); - this._logSPIN(" -- localName=[" + localName + "], ofs=(" + nameOffset + ")"); + this._logSPIN(' -- localName=[' + localName + '], ofs=(' + nameOffset + ')'); if (index == nameParts.length - 1) { // have name // check to see if local name is hiding global variable @@ -3779,21 +4146,32 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: localName.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + localName.length, eSeverity.Error, `P2 Spin local [${localName}] hides global variable of same name`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + localName.length, + eSeverity.Error, + `P2 Spin local [${localName}] hides global variable of same name` + ); } else { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: localName.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "local"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'local'] }); } // remember so we can ID references - this.semanticFindings.setLocalTokenForMethod(methodName, localName, new RememberedToken("variable", lineNbr - 1, nameOffset, ["local"]), this._declarationComment()); // TOKEN SET in _report() + this.semanticFindings.setLocalTokenForMethod( + methodName, + localName, + new RememberedToken('variable', lineNbr - 1, nameOffset, ['local']), + this._declarationComment() + ); // TOKEN SET in _report() } else { // have modifier! if (this.parseUtils.isStorageType(localName)) { @@ -3801,16 +4179,16 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: localName.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } else if (this.parseUtils.isAlignType(localName)) { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: localName.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } } @@ -3824,7 +4202,7 @@ export class Spin2DocumentSemanticParser { private _hidesGlobalVariable(variableName: string): boolean { let hideStatus: boolean = false; - let referenceDetails: RememberedToken | undefined = undefined; + //const referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(variableName)) { hideStatus = true; } @@ -3840,26 +4218,32 @@ export class Spin2DocumentSemanticParser { this._logSPIN(`- Ln#${multiLineSet.lineStartIdx + 1} reportSPINMulti nonCommentSpinLine=[${nonCommentSpinLine}](${remainingLength})`); if (remainingLength > 0) { // special early error case - let symbolPosition: Position = multiLineSet.locateSymbol("else if", currSingleLineOffset); + let symbolPosition: Position = multiLineSet.locateSymbol('else if', currSingleLineOffset); if (symbolPosition.character != -1) { this._logSPIN(` -- Illegal ELSE-IF [${nonCommentSpinLine}]`); - const tokenLength: number = "else if".length; + const tokenLength: number = 'else if'.length; this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: tokenLength, - ptTokenType: "keyword", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'keyword', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(symbolPosition.line, symbolPosition.character, symbolPosition.character + tokenLength, eSeverity.Error, 'Illegal "else if" form for P2 Spin'); + this.semanticFindings.pushDiagnosticMessage( + symbolPosition.line, + symbolPosition.character, + symbolPosition.character + tokenLength, + eSeverity.Error, + 'Illegal "else if" form for P2 Spin' + ); } // FIXME: TODO: unwrap inline method calls withing method calls // locate key indicators of line style - symbolPosition = multiLineSet.locateSymbol(":=", currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); - let assignmentOffset: number = nameOffset; + symbolPosition = multiLineSet.locateSymbol(':=', currSingleLineOffset); + const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + const assignmentOffset: number = nameOffset; if (assignmentOffset != -1) { // ------------------------------------------- // have line assigning value to variable(s) @@ -3868,46 +4252,52 @@ export class Spin2DocumentSemanticParser { const possibleVariableName = multiLineSet.line.substring(0, assignmentOffset).trim(); this._logSPIN(` -- LHS: possibleVariableName=[${possibleVariableName}](${possibleVariableName.length})`); let varNameList: string[] = [possibleVariableName]; - if (possibleVariableName.includes(",")) { - varNameList = possibleVariableName.split(","); + if (possibleVariableName.includes(',')) { + varNameList = possibleVariableName.split(','); } - if (possibleVariableName.includes(" ")) { + if (possibleVariableName.includes(' ')) { // force special case range chars to be removed // Ex: RESP_OVER..RESP_NOT_FOUND : error_code.byte[3] := mod // change .. to : so it is removed by getNonWhite... - const filteredLine: string = possibleVariableName.replace("..", ":"); + const filteredLine: string = possibleVariableName.replace('..', ':'); const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(filteredLine); varNameList = lineInfo.lineParts; } this._logSPIN(` -- LHS: varNameList=[${varNameList}]`); for (let index = 0; index < varNameList.length; index++) { const variableName: string = varNameList[index]; - if (variableName.includes("[")) { + if (variableName.includes('[')) { // NOTE this handles code: byte[pColor][2] := {value} // NOTE2 this handles code: result.byte[3] := {value} P2 OBEX: jm_apa102c.spin2 (139) // have complex target name, parse in loop - const variableNameParts: string[] = variableName.split(/[ \t\[\]\/\*\+\-\(\)\<\>]/); + const variableNameParts: string[] = variableName.split(/[ \t[\]/*+\-()<>]/); this._logSPIN(` -- LHS: [] variableNameParts=[${variableNameParts}]`); for (let index = 0; index < variableNameParts.length; index++) { - let variableNamePart = variableNameParts[index].replace("@", ""); + let variableNamePart = variableNameParts[index].replace('@', ''); // secial case handle datar.[i] which leaves var name as 'darar.' - if (variableNamePart.endsWith(".")) { + if (variableNamePart.endsWith('.')) { variableNamePart = variableNamePart.substr(0, variableNamePart.length - 1); } if (variableNamePart.charAt(0).match(/[a-zA-Z_]/)) { //const nameOffset = line.indexOf(variableNamePart, currSingleLineOffset); symbolPosition = multiLineSet.locateSymbol(variableNamePart, currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); if (this._isPossibleObjectReference(variableNamePart)) { // go register object reference! - const bHaveObjReference = this._reportObjectReference(variableNamePart, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet); + const bHaveObjReference = this._reportObjectReference( + variableNamePart, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ); if (bHaveObjReference) { currSingleLineOffset = nameOffset + variableNamePart.length; continue; } } - if (variableNamePart.includes(".")) { - const varNameParts: string[] = variableNamePart.split("."); + if (variableNamePart.includes('.')) { + const varNameParts: string[] = variableNamePart.split('.'); if (this.parseUtils.isDatStorageType(varNameParts[1])) { variableNamePart = varNameParts[0]; // just use first part of name } @@ -3918,8 +4308,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: variableNamePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } else { let referenceDetails: RememberedToken | undefined = undefined; @@ -3931,14 +4321,14 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- FOUND global name=[${variableNamePart}], referenceDetails=(${referenceDetails})`); } if (referenceDetails != undefined) { - const modificationArray: string[] = referenceDetails.modifiersWith("modification"); + const modificationArray: string[] = referenceDetails.modifiersWith('modification'); this._logSPIN(` -- SPIN variableName=[${variableNamePart}], ofs=(${nameOffset})`); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: variableNamePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modificationArray, + ptTokenModifiers: modificationArray }); } else { if ( @@ -3954,8 +4344,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: nameOffset, length: variableNamePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -3972,26 +4362,36 @@ export class Spin2DocumentSemanticParser { } } else { // have simple target name, no [] - let cleanedVariableName: string = variableName.replace(/[ \t\(\)]/, ""); + let cleanedVariableName: string = variableName.replace(/[ \t()]/, ''); //let nameOffset = line.indexOf(cleanedVariableName, currSingleLineOffset); - let symbolPosition: Position = multiLineSet.locateSymbol(cleanedVariableName, currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); - if (cleanedVariableName.charAt(0).match(/[a-zA-Z_]/) && !this.parseUtils.isStorageType(cleanedVariableName) && !this.parseUtils.isSpinSpecialMethod(cleanedVariableName)) { + const symbolPosition: Position = multiLineSet.locateSymbol(cleanedVariableName, currSingleLineOffset); + const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + if ( + cleanedVariableName.charAt(0).match(/[a-zA-Z_]/) && + !this.parseUtils.isStorageType(cleanedVariableName) && + !this.parseUtils.isSpinSpecialMethod(cleanedVariableName) + ) { this._logSPIN(` -- SPIN cleanedVariableName=[${cleanedVariableName}], ofs=(${nameOffset})`); // does name contain a namespace reference? if (this._isPossibleObjectReference(cleanedVariableName)) { - let bHaveObjReference: boolean = this._reportObjectReference(cleanedVariableName, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet); + const bHaveObjReference: boolean = this._reportObjectReference( + cleanedVariableName, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ); if (!bHaveObjReference) { - let varNameParts: string[] = cleanedVariableName.split("."); + let varNameParts: string[] = cleanedVariableName.split('.'); this._logSPIN(` -- varNameParts=[${varNameParts}]`); if (varNameParts.length > 1 && this.parseUtils.isDatStorageType(varNameParts[1])) { varNameParts = [varNameParts[0]]; // just use first part of name } - let namePart = varNameParts[0]; - const searchString: string = varNameParts.length == 1 ? varNameParts[0] : varNameParts[0] + "." + varNameParts[1]; + const namePart = varNameParts[0]; + const searchString: string = varNameParts.length == 1 ? varNameParts[0] : varNameParts[0] + '.' + varNameParts[1]; //nameOffset = line.indexOf(searchString, currSingleLineOffset); - let symbolPosition: Position = multiLineSet.locateSymbol(searchString, currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + const symbolPosition: Position = multiLineSet.locateSymbol(searchString, currSingleLineOffset); + const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); this._logSPIN(` -- SPIN LHS searchString=[${searchString}]`); this._logSPIN(` -- SPIN LHS nameOffset=(${nameOffset}), currSingleLineOffset=(${currSingleLineOffset})`); let referenceDetails: RememberedToken | undefined = undefined; @@ -4001,11 +4401,10 @@ export class Spin2DocumentSemanticParser { } else if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); this._logSPIN(` -- FOUND global name=[${namePart}], referenceDetails=(${referenceDetails})`); - if (referenceDetails != undefined && referenceDetails?.type == "method") { + if (referenceDetails != undefined && referenceDetails?.type == 'method') { const addressOf = `@${namePart}`; - // FIXME: TODO: need better whitespace detection before parens! // if it's not a legit method call, kill the reference - const searchSpace: string = multiLineSet.line.substring(nameOffset); + //const searchSpace: string = multiLineSet.line.substring(nameOffset); const methodFollowString: string = multiLineSet.line.substring(nameOffset + namePart.length); this._logSPIN(` -- methodFollowString=[${methodFollowString}](${methodFollowString.length})`); if (!isMethodCall(methodFollowString) && !searchString.includes(addressOf)) { @@ -4021,11 +4420,11 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolPosition.character, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { - const searchKey: string = namePart.toLowerCase(); - const isMethodNoParen: boolean = searchKey == "return" || searchKey == "abort"; + //const searchKey: string = namePart.toLowerCase(); + //const isMethodNoParen: boolean = searchKey == 'return' || searchKey == 'abort'; // have unknown name!? is storage type spec? if (this.parseUtils.isStorageType(namePart)) { this._logSPIN(` -- SPIN RHS storageType=[${namePart}]`); @@ -4033,17 +4432,22 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); - } else if (this.parseUtils.isSpinBuiltinMethod(namePart) && !searchString.includes(namePart + "(") && !this.parseUtils.isSpinNoparenMethod(namePart)) { + } else if ( + this.parseUtils.isSpinBuiltinMethod(namePart) && + !searchString.includes(namePart + '(') && + !this.parseUtils.isSpinNoparenMethod(namePart) + ) { + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' this._logSPIN(` -- SPIN MISSING PARENS name=[${namePart}]`); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -4072,8 +4476,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -4089,10 +4493,10 @@ export class Spin2DocumentSemanticParser { } else { let referenceDetails: RememberedToken | undefined = undefined; //nameOffset = line.indexOf(cleanedVariableName, currSingleLineOffset); - let symbolPosition: Position = multiLineSet.locateSymbol(cleanedVariableName, currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + const symbolPosition: Position = multiLineSet.locateSymbol(cleanedVariableName, currSingleLineOffset); + const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); // handle "got." form of name... - cleanedVariableName = cleanedVariableName.endsWith(".") ? cleanedVariableName.slice(0, -1) : cleanedVariableName; + cleanedVariableName = cleanedVariableName.endsWith('.') ? cleanedVariableName.slice(0, -1) : cleanedVariableName; if (this.semanticFindings.isLocalToken(cleanedVariableName)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(cleanedVariableName, symbolPosition.line + 1); this._logSPIN(` -- FOUND local name=[${cleanedVariableName}, referenceDetails=[${referenceDetails}]]`); @@ -4102,23 +4506,23 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- FOUND global name=[${cleanedVariableName}, referenceDetails=[${referenceDetails}]]`); } if (referenceDetails != undefined) { - const modificationArray: string[] = referenceDetails.modifiersWith("modification"); + const modificationArray: string[] = referenceDetails.modifiersWith('modification'); this._logSPIN(` -- spin: simple variableName=[${cleanedVariableName}], ofs=(${nameOffset})`); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: cleanedVariableName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modificationArray, + ptTokenModifiers: modificationArray }); - } else if (cleanedVariableName == "_") { + } else if (cleanedVariableName == '_') { this._logSPIN(` -- built-in=[${cleanedVariableName}], ofs=(${nameOffset})`); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: cleanedVariableName.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "defaultLibrary"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'defaultLibrary'] }); } else { // we don't have name registered so just mark it @@ -4134,8 +4538,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: cleanedVariableName.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -4160,12 +4564,12 @@ export class Spin2DocumentSemanticParser { //const assignmentRHSStr: string = this._getNonCommentLineReturnComment(currSingleLineOffset, lineIdx, line, tokenSet); const assignmentRHSStr: string = multiLineSet.line.substring(currSingleLineOffset); currSingleLineOffset = 0; - const preCleanAssignmentRHSStr = this.parseUtils.getNonInlineCommentLine(assignmentRHSStr).replace("..", " "); - const dotOffset: number = assignmentRHSStr.indexOf("."); - const spaceOffset: number = assignmentRHSStr.indexOf(" "); - const tabOffset: number = assignmentRHSStr.indexOf("\t"); - const bracketOffset: number = assignmentRHSStr.indexOf("["); - const parenOffset: number = assignmentRHSStr.indexOf("("); + const preCleanAssignmentRHSStr = this.parseUtils.getNonInlineCommentLine(assignmentRHSStr).replace('..', ' '); + const dotOffset: number = assignmentRHSStr.indexOf('.'); + const spaceOffset: number = assignmentRHSStr.indexOf(' '); + const tabOffset: number = assignmentRHSStr.indexOf('\t'); + const bracketOffset: number = assignmentRHSStr.indexOf('['); + const parenOffset: number = assignmentRHSStr.indexOf('('); const whiteOffset: number = spaceOffset != -1 ? spaceOffset : tabOffset; const hasWhite: boolean = whiteOffset != -1; // we have a single element if we have "." with "[" and "[" is before "." @@ -4181,9 +4585,15 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- SPIN assignmentRHSStr=[${assignmentRHSStr}], singleElement=(${singleElement})`); // SPECIAL Ex: scroller[scrollerIndex].initialize() - if (singleElement && this._isPossibleObjectReference(assignmentRHSStr) && assignmentRHSStr.includes("[")) { + if (singleElement && this._isPossibleObjectReference(assignmentRHSStr) && assignmentRHSStr.includes('[')) { symbolPosition = multiLineSet.locateSymbol(assignmentRHSStr, currSingleLineOffset); - let bHaveObjReference: boolean = this._reportObjectReference(assignmentRHSStr, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet); + const bHaveObjReference: boolean = this._reportObjectReference( + assignmentRHSStr, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ); if (bHaveObjReference) { return tokenSet; } @@ -4194,7 +4604,7 @@ export class Spin2DocumentSemanticParser { // possNames = possNames[0].split(".."); //} const lineInfo: IFilteredStrings = this._getNonWhiteSpinLinePartsNonArray(preCleanAssignmentRHSStr); - let possNames: string[] = lineInfo.lineParts; + const possNames: string[] = lineInfo.lineParts; const nonStringAssignmentRHSStr: string = lineInfo.lineNoQuotes; this._logSPIN(` -- SPINMulti possNames=[${possNames}](${possNames.length})`); const bIsDebugLine: boolean = haveDebugLine(nonStringAssignmentRHSStr); // nonStringAssignmentRHSStr.toLowerCase().indexOf("debug(") != -1 ? true : false; @@ -4206,7 +4616,7 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < possNames.length; index++) { let possibleName = possNames[index]; // special code to handle case of var.[bitfield] leaving name a 'var.' - if (possibleName.endsWith(".")) { + if (possibleName.endsWith('.')) { possibleName = possibleName.substr(0, possibleName.length - 1); } // special code to handle case of @pasmName leaving name a 'var.' @@ -4222,31 +4632,44 @@ export class Spin2DocumentSemanticParser { //nameOffset = offsetInNonStringRHS + assignmentStringOffset; symbolPosition = multiLineSet.locateSymbol(possibleName, currSingleLineOffset); nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); - let bHaveObjReference: boolean = this._isPossibleObjectReference(possibleName) - ? this._reportObjectReference(possibleName, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet) + const bHaveObjReference: boolean = this._isPossibleObjectReference(possibleName) + ? this._reportObjectReference( + possibleName, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ) : false; if (!bHaveObjReference) { // does name contain a dotted reference? - const isBitSubscript: boolean = possibleName.includes(".["); - if (possibleName.includes(".")) { - possibleNameSet = possibleName.split(/[\.\[\]]/).filter(Boolean); + const isBitSubscript: boolean = possibleName.includes('.['); + if (possibleName.includes('.')) { + possibleNameSet = possibleName.split(/[.[\]]/).filter(Boolean); const origNameSet = possibleNameSet; if (possibleNameSet.length == 2 && this.parseUtils.isStorageType(possibleNameSet[1])) { possibleNameSet = [possibleNameSet[0]]; // filter out " " } else if (possibleNameSet.length == 2 && !possibleNameSet[1].charAt(0).match(/[a-zA-Z_]/)) { possibleNameSet = [possibleNameSet[0]]; // filter out "header.[00..02]" - } else if (possibleNameSet.length > 2 && this.parseUtils.isStorageType(possibleNameSet[1]) && !possibleNameSet[2].charAt(0).match(/[a-zA-Z_]/)) { + } else if ( + possibleNameSet.length > 2 && + this.parseUtils.isStorageType(possibleNameSet[1]) && + !possibleNameSet[2].charAt(0).match(/[a-zA-Z_]/) + ) { possibleNameSet = [possibleNameSet[0]]; // filter out "variable.[long|word|byte][idx]" } this._logSPIN(` -- origNameSet=[${origNameSet}] -> possibleNameSet=[${possibleNameSet}]`); } const namePart = possibleNameSet[0]; currNameLength = namePart.length; - const searchString: string = possibleNameSet.length == 1 || isBitSubscript ? possibleNameSet[0] : `${possibleNameSet[0]}.${possibleNameSet[1]}`; + const searchString: string = + possibleNameSet.length == 1 || isBitSubscript ? possibleNameSet[0] : `${possibleNameSet[0]}.${possibleNameSet[1]}`; //nameOffset = nonStringAssignmentRHSStr.indexOf(searchString, offsetInNonStringRHS) + assignmentStringOffset; // so we don't match in in strings... this._logSPIN(` -- SPIN RHS nonStringAssignmentRHSStr=[${nonStringAssignmentRHSStr}]`); this._logSPIN(` -- SPIN RHS searchString=[${searchString}]`); - this._logSPIN(` -- SPIN RHS nameOffset=(${nameOffset}), offsetInNonStringRHS=(${offsetInNonStringRHS}), currSingleLineOffset=(${currSingleLineOffset})`); + this._logSPIN( + ` -- SPIN RHS nameOffset=(${nameOffset}), offsetInNonStringRHS=(${offsetInNonStringRHS}), currSingleLineOffset=(${currSingleLineOffset})` + ); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isLocalToken(namePart)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(namePart, symbolPosition.line + 1); @@ -4255,8 +4678,7 @@ export class Spin2DocumentSemanticParser { if (!referenceDetails && this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); this._logSPIN(` -- FOUND Global name=[${namePart}], referenceDetails=(${referenceDetails})`); - if (referenceDetails != undefined && referenceDetails?.type == "method") { - // FIXME: TODO: need better whitespace detection before parens! + if (referenceDetails != undefined && referenceDetails?.type == 'method') { const addressOf = `@${namePart}`; const methodFollowString: string = multiLineSet.line.substring(nameOffset + namePart.length); this._logSPIN(` -- methodFollowString=[${methodFollowString}](${methodFollowString.length})`); @@ -4273,7 +4695,7 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolPosition.character, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { const methodFollowString: string = multiLineSet.lineAt(symbolPosition.line).substring(nameOffset + namePart.length); @@ -4284,19 +4706,29 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "function", - ptTokenModifiers: ["support"], + ptTokenType: 'function', + ptTokenModifiers: ['support'] }); - } else if (this.parseUtils.isFloatConversion(namePart) && (nonStringAssignmentRHSStr.indexOf(namePart + "(") == -1 || nonStringAssignmentRHSStr.indexOf(namePart + "()") != -1)) { + } else if ( + this.parseUtils.isFloatConversion(namePart) && + (nonStringAssignmentRHSStr.indexOf(namePart + '(') == -1 || nonStringAssignmentRHSStr.indexOf(namePart + '()') != -1) + ) { + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' (ABOVE LINEs) this._logSPIN(` -- SPIN MISSING PARENS name=[${namePart}]`); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(symbolPosition.line, symbolPosition.character, symbolPosition.character + namePart.length, eSeverity.Error, "P2 Spin missing parens"); + this.semanticFindings.pushDiagnosticMessage( + symbolPosition.line, + symbolPosition.character, + symbolPosition.character + namePart.length, + eSeverity.Error, + 'P2 Spin missing parens' + ); } else if (this.parseUtils.isStorageType(namePart)) { // have unknown name!? is storage type spec? this._logSPIN(` -- SPIN RHS storageType=[${namePart}]`); @@ -4304,19 +4736,30 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); - } else if (this.parseUtils.isSpinBuiltinMethod(namePart) && !nonStringAssignmentRHSStr.includes(namePart + "(") && !this.parseUtils.isSpinNoparenMethod(namePart)) { + } else if ( + this.parseUtils.isSpinBuiltinMethod(namePart) && + !nonStringAssignmentRHSStr.includes(namePart + '(') && + !this.parseUtils.isSpinNoparenMethod(namePart) + ) { + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' this._logSPIN(` -- SPIN MISSING PARENS name=[${namePart}]`); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(symbolPosition.line, symbolPosition.character, symbolPosition.character + namePart.length, eSeverity.Error, "P2 Spin missing parens"); + this.semanticFindings.pushDiagnosticMessage( + symbolPosition.line, + symbolPosition.character, + symbolPosition.character + namePart.length, + eSeverity.Error, + 'P2 Spin missing parens' + ); } // we use bIsDebugLine in next line so we don't flag debug() arguments! else if ( @@ -4340,8 +4783,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); if (this.parseUtils.isP1SpinMethod(namePart)) { this.semanticFindings.pushDiagnosticMessage( @@ -4394,8 +4837,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: constantPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -4410,8 +4853,8 @@ export class Spin2DocumentSemanticParser { // found object ref. include it in length currNameLength = possibleName.length; } - } else if (possibleName.startsWith(".")) { - const externalMethodName: string = possibleName.replace(".", ""); + } else if (possibleName.startsWith('.')) { + const externalMethodName: string = possibleName.replace('.', ''); currNameLength = externalMethodName.length; //nameOffset = nonStringAssignmentRHSStr.indexOf(externalMethodName, offsetInNonStringRHS) + currSingleLineOffset; symbolPosition = multiLineSet.locateSymbol(externalMethodName, currSingleLineOffset); @@ -4421,13 +4864,15 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: externalMethodName.length, - ptTokenType: "method", - ptTokenModifiers: [], + ptTokenType: 'method', + ptTokenModifiers: [] }); } offsetInNonStringRHS += currNameLength + 1; currSingleLineOffset = nameOffset > 0 ? nameOffset + currNameLength : currSingleLineOffset + currNameLength; - this._logSPIN(` -- SPIN Multi loop currSingleLineOffset=(${currSingleLineOffset}) <-- nameOffset=(${nameOffset}), currNameLength=(${currNameLength})`); + this._logSPIN( + ` -- SPIN Multi loop currSingleLineOffset=(${currSingleLineOffset}) <-- nameOffset=(${nameOffset}), currNameLength=(${currNameLength})` + ); } } return tokenSet; @@ -4443,61 +4888,67 @@ export class Spin2DocumentSemanticParser { this._logCON(`- Ln#${lineIdx + 1} reportSPIN nonCommentSpinLine=[${nonCommentSpinLine}] remainingLength=${remainingLength}`); if (remainingLength > 0) { // special early error case - if (nonCommentSpinLine.toLowerCase().includes("else if")) { - const nameOffset = line.toLowerCase().indexOf("else if", currentOffset); - this._logSPIN(" -- Illegal ELSE-IF [" + nonCommentSpinLine + "]"); - const tokenLength: number = "else if".length; + if (nonCommentSpinLine.toLowerCase().includes('else if')) { + const nameOffset = line.toLowerCase().indexOf('else if', currentOffset); + this._logSPIN(' -- Illegal ELSE-IF [' + nonCommentSpinLine + ']'); + const tokenLength: number = 'else if'.length; this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: tokenLength, - ptTokenType: "keyword", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'keyword', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + tokenLength, eSeverity.Error, 'Illegal "else if" form for P2 Spin'); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + tokenLength, + eSeverity.Error, + 'Illegal "else if" form for P2 Spin' + ); } // FIXME: TODO: unwrap inline method calls withing method calls // locate key indicators of line style - let assignmentOffset: number = nonCommentSpinLine.includes(":=") ? line.indexOf(":=", currentOffset) : -1; + const assignmentOffset: number = nonCommentSpinLine.includes(':=') ? line.indexOf(':=', currentOffset) : -1; if (assignmentOffset != -1) { // ------------------------------------------- // have line assigning value to variable(s) // Process LHS side of this assignment // ------------------------------------------- const possibleVariableName = line.substr(currentOffset, assignmentOffset - currentOffset).trim(); - this._logSPIN(" -- LHS: possibleVariableName=[" + possibleVariableName + "]"); + this._logSPIN(' -- LHS: possibleVariableName=[' + possibleVariableName + ']'); let varNameList: string[] = [possibleVariableName]; - if (possibleVariableName.includes(",")) { - varNameList = possibleVariableName.split(","); + if (possibleVariableName.includes(',')) { + varNameList = possibleVariableName.split(','); } - if (possibleVariableName.includes(" ")) { + if (possibleVariableName.includes(' ')) { // force special case range chars to be removed // Ex: RESP_OVER..RESP_NOT_FOUND : error_code.byte[3] := mod // change .. to : so it is removed by getNonWhite... - const filteredLine: string = possibleVariableName.replace("..", ":"); + const filteredLine: string = possibleVariableName.replace('..', ':'); const lineInfo: IFilteredStrings = this._getNonWhiteSpinLineParts(filteredLine); varNameList = lineInfo.lineParts; } - this._logSPIN(" -- LHS: varNameList=[" + varNameList + "]"); + this._logSPIN(' -- LHS: varNameList=[' + varNameList + ']'); for (let index = 0; index < varNameList.length; index++) { const variableName: string = varNameList[index]; - if (variableName.includes("[")) { + if (variableName.includes('[')) { // NOTE this handles code: byte[pColor][2] := {value} // NOTE2 this handles code: result.byte[3] := {value} P2 OBEX: jm_apa102c.spin2 (139) // have complex target name, parse in loop - const variableNameParts: string[] = variableName.split(/[ \t\[\]\/\*\+\-\(\)\<\>]/); - this._logSPIN(" -- LHS: [] variableNameParts=[" + variableNameParts + "]"); + const variableNameParts: string[] = variableName.split(/[ \t[\]/*+\-()<>]/); + this._logSPIN(' -- LHS: [] variableNameParts=[' + variableNameParts + ']'); for (let index = 0; index < variableNameParts.length; index++) { - let variableNamePart = variableNameParts[index].replace("@", ""); + let variableNamePart = variableNameParts[index].replace('@', ''); // secial case handle datar.[i] which leaves var name as 'darar.' - if (variableNamePart.endsWith(".")) { + if (variableNamePart.endsWith('.')) { variableNamePart = variableNamePart.substr(0, variableNamePart.length - 1); } const nameOffset = line.indexOf(variableNamePart, currentOffset); if (variableNamePart.charAt(0).match(/[a-zA-Z_]/)) { - let possibleNameSet: string[] = [variableNamePart]; + //const possibleNameSet: string[] = [variableNamePart]; if (this._isPossibleObjectReference(variableNamePart)) { // go register object reference! const bHaveObjReference = this._reportObjectReference(variableNamePart, lineIdx, currentOffset, line, tokenSet); @@ -4506,39 +4957,39 @@ export class Spin2DocumentSemanticParser { continue; } } - if (variableNamePart.includes(".")) { - const varNameParts: string[] = variableNamePart.split("."); + if (variableNamePart.includes('.')) { + const varNameParts: string[] = variableNamePart.split('.'); if (this.parseUtils.isDatStorageType(varNameParts[1])) { variableNamePart = varNameParts[0]; // just use first part of name } } - this._logSPIN(" -- variableNamePart=[" + variableNamePart + "], ofs=(" + nameOffset + ")"); + this._logSPIN(' -- variableNamePart=[' + variableNamePart + '], ofs=(' + nameOffset + ')'); if (this.parseUtils.isStorageType(variableNamePart)) { this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: variableNamePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); } else { let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isLocalToken(variableNamePart)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(variableNamePart, lineNbr); - this._logSPIN(" -- FOUND local name=[" + variableNamePart + "]"); + this._logSPIN(' -- FOUND local name=[' + variableNamePart + ']'); } else if (this.semanticFindings.isGlobalToken(variableNamePart)) { referenceDetails = this.semanticFindings.getGlobalToken(variableNamePart); - this._logSPIN(" -- FOUND global name=[" + variableNamePart + "]"); + this._logSPIN(' -- FOUND global name=[' + variableNamePart + ']'); } if (referenceDetails != undefined) { - const modificationArray: string[] = referenceDetails.modifiersWith("modification"); - this._logSPIN(" -- SPIN variableName=[" + variableNamePart + "], ofs=(" + nameOffset + ")"); + const modificationArray: string[] = referenceDetails.modifiersWith('modification'); + this._logSPIN(' -- SPIN variableName=[' + variableNamePart + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: variableNamePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modificationArray, + ptTokenModifiers: modificationArray }); } else { if ( @@ -4549,15 +5000,21 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isSpinBuiltinMethod(variableNamePart) ) { // we don't have name registered so just mark it - this._logSPIN(" -- SPIN MISSING varname=[" + variableNamePart + "], ofs=(" + nameOffset + ")"); + this._logSPIN(' -- SPIN MISSING varname=[' + variableNamePart + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: variableNamePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + variableNamePart.length, eSeverity.Error, `P2 Spin B missing declaration [${variableNamePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + variableNamePart.length, + eSeverity.Error, + `P2 Spin B missing declaration [${variableNamePart}]` + ); } } } @@ -4566,34 +5023,37 @@ export class Spin2DocumentSemanticParser { } } else { // have simple target name, no [] - let cleanedVariableName: string = variableName.replace(/[ \t\(\)]/, ""); + let cleanedVariableName: string = variableName.replace(/[ \t()]/, ''); let nameOffset = line.indexOf(cleanedVariableName, currentOffset); - if (cleanedVariableName.charAt(0).match(/[a-zA-Z_]/) && !this.parseUtils.isStorageType(cleanedVariableName) && !this.parseUtils.isSpinSpecialMethod(cleanedVariableName)) { - this._logSPIN(" -- SPIN cleanedVariableName=[" + cleanedVariableName + "], ofs=(" + nameOffset + ")"); + if ( + cleanedVariableName.charAt(0).match(/[a-zA-Z_]/) && + !this.parseUtils.isStorageType(cleanedVariableName) && + !this.parseUtils.isSpinSpecialMethod(cleanedVariableName) + ) { + this._logSPIN(' -- SPIN cleanedVariableName=[' + cleanedVariableName + '], ofs=(' + nameOffset + ')'); // does name contain a namespace reference? if (this._isPossibleObjectReference(cleanedVariableName)) { - let bHaveObjReference: boolean = this._reportObjectReference(cleanedVariableName, lineIdx, startingOffset, line, tokenSet); + const bHaveObjReference: boolean = this._reportObjectReference(cleanedVariableName, lineIdx, startingOffset, line, tokenSet); if (!bHaveObjReference) { - let varNameParts: string[] = cleanedVariableName.split("."); - this._logSPIN(" -- varNameParts=[" + varNameParts + "]"); + let varNameParts: string[] = cleanedVariableName.split('.'); + this._logSPIN(' -- varNameParts=[' + varNameParts + ']'); if (varNameParts.length > 1 && this.parseUtils.isDatStorageType(varNameParts[1])) { varNameParts = [varNameParts[0]]; // just use first part of name } - let namePart = varNameParts[0]; - const searchString: string = varNameParts.length == 1 ? varNameParts[0] : varNameParts[0] + "." + varNameParts[1]; + const namePart = varNameParts[0]; + const searchString: string = varNameParts.length == 1 ? varNameParts[0] : varNameParts[0] + '.' + varNameParts[1]; nameOffset = line.indexOf(searchString, currentOffset); - this._logSPIN(" -- SPIN LHS searchString=[" + searchString + "]"); - this._logSPIN(" -- SPIN LHS nameOffset=(" + nameOffset + "), currentOffset=(" + currentOffset + ")"); + this._logSPIN(' -- SPIN LHS searchString=[' + searchString + ']'); + this._logSPIN(' -- SPIN LHS nameOffset=(' + nameOffset + '), currentOffset=(' + currentOffset + ')'); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isLocalToken(namePart)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(namePart, lineNbr); - this._logSPIN(" -- FOUND local name=[" + namePart + "]"); + this._logSPIN(' -- FOUND local name=[' + namePart + ']'); } else if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); - this._logSPIN(" -- FOUND global name=[" + namePart + "]"); - if (referenceDetails != undefined && referenceDetails?.type == "method") { + this._logSPIN(' -- FOUND global name=[' + namePart + ']'); + if (referenceDetails != undefined && referenceDetails?.type == 'method') { const addressOf = `@${namePart}`; - // FIXME: TODO: need better whitespace detection before parens! // if it's not a legit method call, kill the reference const methodFollowString: string = line.substring(nameOffset + namePart.length); this._logSPIN(` -- methodFollowString=[${methodFollowString}](${methodFollowString.length})`); @@ -4610,31 +5070,42 @@ export class Spin2DocumentSemanticParser { startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { - const searchKey: string = namePart.toLowerCase(); - const isMethodNoParen: boolean = searchKey == "return" || searchKey == "abort"; + //const searchKey: string = namePart.toLowerCase(); + //const isMethodNoParen: boolean = searchKey == 'return' || searchKey == 'abort'; // have unknown name!? is storage type spec? if (this.parseUtils.isStorageType(namePart)) { - this._logSPIN(" -- SPIN RHS storageType=[" + namePart + "]"); + this._logSPIN(' -- SPIN RHS storageType=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); - } else if (this.parseUtils.isSpinBuiltinMethod(namePart) && !searchString.includes(namePart + "(") && !this.parseUtils.isSpinNoparenMethod(namePart)) { - this._logSPIN(" -- SPIN MISSING PARENS name=[" + namePart + "]"); + } else if ( + this.parseUtils.isSpinBuiltinMethod(namePart) && + !searchString.includes(namePart + '(') && + !this.parseUtils.isSpinNoparenMethod(namePart) + ) { + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' + this._logSPIN(' -- SPIN MISSING PARENS name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin missing parens after [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin missing parens after [${namePart}]` + ); } // we use bIsDebugLine in next line so we don't flag debug() arguments! else if ( @@ -4650,15 +5121,21 @@ export class Spin2DocumentSemanticParser { //else { // this._logSPIN(' -- UNKNOWN?? name=[' + namePart + '] - name-get-breakage??'); //} - this._logSPIN(" -- SPIN MISSING rhs name=[" + namePart + "]"); + this._logSPIN(' -- SPIN MISSING rhs name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin C missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin C missing declaration [${namePart}]` + ); } } currentOffset = nameOffset + namePart.length + 1; @@ -4667,7 +5144,7 @@ export class Spin2DocumentSemanticParser { let referenceDetails: RememberedToken | undefined = undefined; nameOffset = line.indexOf(cleanedVariableName, currentOffset); // handle "got." form of name... - cleanedVariableName = cleanedVariableName.endsWith(".") ? cleanedVariableName.slice(0, -1) : cleanedVariableName; + cleanedVariableName = cleanedVariableName.endsWith('.') ? cleanedVariableName.slice(0, -1) : cleanedVariableName; if (this.semanticFindings.isLocalToken(cleanedVariableName)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(cleanedVariableName, lineNbr); this._logSPIN(` -- FOUND local name=[${cleanedVariableName}, referenceDetails=[${referenceDetails}]]`); @@ -4677,23 +5154,23 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- FOUND global name=[${cleanedVariableName}, referenceDetails=[${referenceDetails}]]`); } if (referenceDetails != undefined) { - const modificationArray: string[] = referenceDetails.modifiersWith("modification"); - this._logSPIN(" -- spin: simple variableName=[" + cleanedVariableName + "], ofs=(" + nameOffset + ")"); + const modificationArray: string[] = referenceDetails.modifiersWith('modification'); + this._logSPIN(' -- spin: simple variableName=[' + cleanedVariableName + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: cleanedVariableName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: modificationArray, + ptTokenModifiers: modificationArray }); - } else if (cleanedVariableName == "_") { - this._logSPIN(" -- built-in=[" + cleanedVariableName + "], ofs=(" + nameOffset + ")"); + } else if (cleanedVariableName == '_') { + this._logSPIN(' -- built-in=[' + cleanedVariableName + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: cleanedVariableName.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "defaultLibrary"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'defaultLibrary'] }); } else { // we don't have name registered so just mark it @@ -4704,13 +5181,13 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isDebugMethod(cleanedVariableName) && !this.parseUtils.isDebugControlSymbol(cleanedVariableName) ) { - this._logSPIN(" -- SPIN MISSING cln name=[" + cleanedVariableName + "], ofs=(" + nameOffset + ")"); + this._logSPIN(' -- SPIN MISSING cln name=[' + cleanedVariableName + '], ofs=(' + nameOffset + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: cleanedVariableName.length, - ptTokenType: "variable", - ptTokenModifiers: ["modification", "missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['modification', 'missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -4735,12 +5212,12 @@ export class Spin2DocumentSemanticParser { const assignmentRHSStr: string = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); //currentOffset = line.indexOf(assignmentRHSStr, 0); currentOffset = 0; - const preCleanAssignmentRHSStr = this.parseUtils.getNonInlineCommentLine(assignmentRHSStr).replace("..", " "); - const dotOffset: number = assignmentRHSStr.indexOf("."); - const spaceOffset: number = assignmentRHSStr.indexOf(" "); - const tabOffset: number = assignmentRHSStr.indexOf("\t"); - const bracketOffset: number = assignmentRHSStr.indexOf("["); - const parenOffset: number = assignmentRHSStr.indexOf("("); + const preCleanAssignmentRHSStr = this.parseUtils.getNonInlineCommentLine(assignmentRHSStr).replace('..', ' '); + const dotOffset: number = assignmentRHSStr.indexOf('.'); + const spaceOffset: number = assignmentRHSStr.indexOf(' '); + const tabOffset: number = assignmentRHSStr.indexOf('\t'); + const bracketOffset: number = assignmentRHSStr.indexOf('['); + const parenOffset: number = assignmentRHSStr.indexOf('('); const whiteOffset: number = spaceOffset != -1 ? spaceOffset : tabOffset; const hasWhite: boolean = whiteOffset != -1; // we have a single element if we have "." with "[" and "[" is before "." @@ -4756,8 +5233,8 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- SPIN assignmentRHSStr=[${assignmentRHSStr}], singleElement=(${singleElement})`); // SPECIAL Ex: scroller[scrollerIndex].initialize() - if (singleElement && this._isPossibleObjectReference(assignmentRHSStr) && assignmentRHSStr.includes("[")) { - let bHaveObjReference: boolean = this._reportObjectReference(assignmentRHSStr, lineIdx, currentOffset, line, tokenSet); + if (singleElement && this._isPossibleObjectReference(assignmentRHSStr) && assignmentRHSStr.includes('[')) { + const bHaveObjReference: boolean = this._reportObjectReference(assignmentRHSStr, lineIdx, currentOffset, line, tokenSet); if (bHaveObjReference) { return tokenSet; } @@ -4768,7 +5245,7 @@ export class Spin2DocumentSemanticParser { // possNames = possNames[0].split(".."); //} const lineInfo: IFilteredStrings = this._getNonWhiteSpinLinePartsNonArray(preCleanAssignmentRHSStr); - let possNames: string[] = lineInfo.lineParts; + const possNames: string[] = lineInfo.lineParts; const nonStringAssignmentRHSStr: string = lineInfo.lineNoQuotes; this._logSPIN(` -- SPIN possNames=[${possNames}](${possNames.length})`); const bIsDebugLine: boolean = haveDebugLine(nonStringAssignmentRHSStr); // nonStringAssignmentRHSStr.toLowerCase().indexOf("debug(") != -1 ? true : false; @@ -4779,7 +5256,7 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < possNames.length; index++) { let possibleName = possNames[index]; // special code to handle case of var.[bitfield] leaving name a 'var.' - if (possibleName.endsWith(".")) { + if (possibleName.endsWith('.')) { possibleName = possibleName.substr(0, possibleName.length - 1); } // special code to handle case of @pasmName leaving name a 'var.' @@ -4793,27 +5270,36 @@ export class Spin2DocumentSemanticParser { this._logSPIN(` -- Spin possibleName=[${possibleName}]`); offsetInNonStringRHS = nonStringAssignmentRHSStr.indexOf(possibleName, offsetInNonStringRHS); nameOffset = offsetInNonStringRHS + assignmentStringOffset; - let bHaveObjReference: boolean = this._isPossibleObjectReference(possibleName) ? this._reportObjectReference(possibleName, lineIdx, offsetInNonStringRHS, line, tokenSet) : false; + const bHaveObjReference: boolean = this._isPossibleObjectReference(possibleName) + ? this._reportObjectReference(possibleName, lineIdx, offsetInNonStringRHS, line, tokenSet) + : false; if (!bHaveObjReference) { // does name contain a dotted reference? - const isBitSubscript: boolean = possibleName.includes(".["); - if (possibleName.includes(".")) { - possibleNameSet = possibleName.split(/[\.\[\]]/).filter(Boolean); + const isBitSubscript: boolean = possibleName.includes('.['); + if (possibleName.includes('.')) { + possibleNameSet = possibleName.split(/[.[\]]/).filter(Boolean); const origNameSet = possibleNameSet; if (possibleNameSet.length == 2 && this.parseUtils.isStorageType(possibleNameSet[1])) { possibleNameSet = [possibleNameSet[0]]; // filter out " " } else if (possibleNameSet.length == 2 && !possibleNameSet[1].charAt(0).match(/[a-zA-Z_]/)) { possibleNameSet = [possibleNameSet[0]]; // filter out "header.[00..02]" - } else if (possibleNameSet.length > 2 && this.parseUtils.isStorageType(possibleNameSet[1]) && !possibleNameSet[2].charAt(0).match(/[a-zA-Z_]/)) { + } else if ( + possibleNameSet.length > 2 && + this.parseUtils.isStorageType(possibleNameSet[1]) && + !possibleNameSet[2].charAt(0).match(/[a-zA-Z_]/) + ) { possibleNameSet = [possibleNameSet[0]]; // filter out "variable.[long|word|byte][idx]" } this._logSPIN(` -- origNameSet=[${origNameSet}] -> possibleNameSet=[${possibleNameSet}]`); } - const searchString: string = possibleNameSet.length == 1 || isBitSubscript ? possibleNameSet[0] : `${possibleNameSet[0]}.${possibleNameSet[1]}`; + const searchString: string = + possibleNameSet.length == 1 || isBitSubscript ? possibleNameSet[0] : `${possibleNameSet[0]}.${possibleNameSet[1]}`; nameOffset = nonStringAssignmentRHSStr.indexOf(searchString, offsetInNonStringRHS) + assignmentStringOffset; // so we don't match in in strings... this._logSPIN(` -- SPIN RHS nonStringAssignmentRHSStr=[${nonStringAssignmentRHSStr}]`); this._logSPIN(` -- SPIN RHS searchString=[${searchString}]`); - this._logSPIN(` -- SPIN RHS nameOffset=(${nameOffset}), offsetInNonStringRHS=(${offsetInNonStringRHS}), currentOffset=(${currentOffset})`); + this._logSPIN( + ` -- SPIN RHS nameOffset=(${nameOffset}), offsetInNonStringRHS=(${offsetInNonStringRHS}), currentOffset=(${currentOffset})` + ); for (let index = 0; index < possibleNameSet.length; index++) { const namePart = possibleNameSet[index]; if (!namePart.charAt(0).match(/[a-zA-Z_]/)) { @@ -4839,8 +5325,7 @@ export class Spin2DocumentSemanticParser { } else { this._logSPIN(` -- EXISTS Global name=[${namePart}], BUT referenceDetails=(${referenceDetails})`); } - if (referenceDetails != undefined && referenceDetails?.type == "method") { - // FIXME: TODO: need better whitespace detection before parens! + if (referenceDetails != undefined && referenceDetails?.type == 'method') { const addressOf = `@${namePart}`; const methodFollowString: string = line.substring(nameOffset + namePart.length); this._logSPIN(` -- methodFollowString=[${methodFollowString}](${methodFollowString.length})`); @@ -4857,7 +5342,7 @@ export class Spin2DocumentSemanticParser { startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { const methodFollowString: string = line.substring(nameOffset + namePart.length); @@ -4868,39 +5353,60 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "function", - ptTokenModifiers: ["support"], + ptTokenType: 'function', + ptTokenModifiers: ['support'] }); - } else if (this.parseUtils.isFloatConversion(namePart) && (nonStringAssignmentRHSStr.indexOf(namePart + "(") == -1 || nonStringAssignmentRHSStr.indexOf(namePart + "()") != -1)) { - this._logSPIN(" -- SPIN MISSING PARENS name=[" + namePart + "]"); + } else if ( + this.parseUtils.isFloatConversion(namePart) && + (nonStringAssignmentRHSStr.indexOf(namePart + '(') == -1 || nonStringAssignmentRHSStr.indexOf(namePart + '()') != -1) + ) { + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' (ABOVE LINEs) + this._logSPIN(' -- SPIN MISSING PARENS name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, "P2 Spin missing parens"); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + 'P2 Spin missing parens' + ); } else if (this.parseUtils.isStorageType(namePart)) { // have unknown name!? is storage type spec? - this._logSPIN(" -- SPIN RHS storageType=[" + namePart + "]"); + this._logSPIN(' -- SPIN RHS storageType=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "storageType", - ptTokenModifiers: [], + ptTokenType: 'storageType', + ptTokenModifiers: [] }); - } else if (this.parseUtils.isSpinBuiltinMethod(namePart) && !nonStringAssignmentRHSStr.includes(namePart + "(") && !this.parseUtils.isSpinNoparenMethod(namePart)) { - this._logSPIN(" -- SPIN MISSING PARENS name=[" + namePart + "]"); + } else if ( + this.parseUtils.isSpinBuiltinMethod(namePart) && + !nonStringAssignmentRHSStr.includes(namePart + '(') && + !this.parseUtils.isSpinNoparenMethod(namePart) + ) { + // FIXME: TODO: replaces name-concat with regEX search past whitespace for '(' + this._logSPIN(' -- SPIN MISSING PARENS name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "method", - ptTokenModifiers: ["builtin", "missingDeclaration"], + ptTokenType: 'method', + ptTokenModifiers: ['builtin', 'missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, "P2 Spin missing parens"); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + 'P2 Spin missing parens' + ); } // we use bIsDebugLine in next line so we don't flag debug() arguments! else if ( @@ -4919,22 +5425,46 @@ export class Spin2DocumentSemanticParser { // this._logSPIN(' -- UNKNOWN?? name=[' + namePart + '] - name-get-breakage??'); //} - this._logSPIN(" -- SPIN MISSING rhs name=[" + namePart + "]"); + this._logSPIN(' -- SPIN MISSING rhs name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); if (this.parseUtils.isP1SpinMethod(namePart)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 Spin method [${namePart}()] not allowed in P2 Spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 Spin method [${namePart}()] not allowed in P2 Spin` + ); } else if (this.parseUtils.isP1AsmVariable(namePart)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 Pasm reserved word [${namePart}] not allowed in P2 Spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 Pasm reserved word [${namePart}] not allowed in P2 Spin` + ); } else if (this.parseUtils.isP1SpinVariable(namePart)) { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P1 Spin variable [${namePart}] not allowed in P2 Spin`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P1 Spin variable [${namePart}] not allowed in P2 Spin` + ); } else { - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin E missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin E missing declaration [${namePart}]` + ); } } currNameLength = namePart.length; @@ -4946,8 +5476,8 @@ export class Spin2DocumentSemanticParser { // found object ref. include it in length currNameLength = possibleName.length; } - } else if (possibleName.startsWith(".")) { - const externalMethodName: string = possibleName.replace(".", ""); + } else if (possibleName.startsWith('.')) { + const externalMethodName: string = possibleName.replace('.', ''); currNameLength = externalMethodName.length; nameOffset = nonStringAssignmentRHSStr.indexOf(externalMethodName, offsetInNonStringRHS) + currentOffset; this._logSPIN(` -- SPIN rhs externalMethodName=[${externalMethodName}](${externalMethodName.length}), ofs=(${nameOffset})`); @@ -4955,8 +5485,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: externalMethodName.length, - ptTokenType: "method", - ptTokenModifiers: [], + ptTokenType: 'method', + ptTokenModifiers: [] }); } offsetInNonStringRHS += currNameLength + 1; @@ -4976,32 +5506,32 @@ export class Spin2DocumentSemanticParser { const inLinePAsmRHSStr = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); if (inLinePAsmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhitePAsmLineParts(inLinePAsmRHSStr); - this._logPASM(" -- reportInLinePAsmDecl lineParts=[" + lineParts + "]"); + this._logPASM(' -- reportInLinePAsmDecl lineParts=[' + lineParts + ']'); //const bIsAlsoDebugLine: boolean = inLinePAsmRHSStr.toLowerCase().indexOf("debug(") != -1 ? true : false; const bIsAlsoDebugLine: boolean = haveDebugLine(inLinePAsmRHSStr); if (bIsAlsoDebugLine) { const partialTokenSet: IParsedToken[] = this._reportDebugStatement(lineIdx, startingOffset, line); - this._reportNonDupeTokens(partialTokenSet, "=> SPINpasm: ", line, tokenSet); + this._reportNonDupeTokens(partialTokenSet, '=> SPINpasm: ', line, tokenSet); } // handle name in as first part of line... // (process label/variable name (but 'debug' of debug() is NOT a label!)) - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]) && lineParts[0].toLowerCase() != "debug"; + let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]) && lineParts[0].toLowerCase() != 'debug'; const isDataDeclarationLine: boolean = lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1]) ? true : false; if (haveLabel) { const labelName: string = lineParts[0]; - this._logPASM(" -- labelName=[" + labelName + "]"); - const labelType: string = isDataDeclarationLine ? "variable" : "label"; + this._logPASM(' -- labelName=[' + labelName + ']'); + const labelType: string = isDataDeclarationLine ? 'variable' : 'label'; const nameOffset: number = line.indexOf(labelName, currentOffset); - var labelModifiers: string[] = ["declaration"]; - if (!isDataDeclarationLine && labelName.startsWith(".")) { - labelModifiers = ["declaration", "static"]; + let labelModifiers: string[] = ['declaration']; + if (!isDataDeclarationLine && labelName.startsWith('.')) { + labelModifiers = ['declaration', 'static']; } this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: labelName.length, ptTokenType: labelType, - ptTokenModifiers: labelModifiers, + ptTokenModifiers: labelModifiers }); haveLabel = true; } @@ -5020,44 +5550,50 @@ export class Spin2DocumentSemanticParser { argumentOffset++; minNonLabelParts++; } - if (lineParts[argumentOffset].toUpperCase().startsWith("IF_") || lineParts[argumentOffset].toUpperCase().startsWith("_RET_")) { + if (lineParts[argumentOffset].toUpperCase().startsWith('IF_') || lineParts[argumentOffset].toUpperCase().startsWith('_RET_')) { // skip our conditional argumentOffset++; minNonLabelParts++; } const possibleDirective: string = lineParts[argumentOffset]; - if (possibleDirective.toUpperCase() == "FILE") { + if (possibleDirective.toUpperCase() == 'FILE') { // we have illegal so flag it and abort handling rest of line - this._logPASM(" -- SPIN inlinePAsm ERROR[CODE] illegal directive=[" + possibleDirective + "]"); + this._logPASM(' -- SPIN inlinePAsm ERROR[CODE] illegal directive=[' + possibleDirective + ']'); const nameOffset: number = line.indexOf(possibleDirective, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: possibleDirective.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + possibleDirective.length, eSeverity.Error, `Illegal P2 Spin inline-pasm directive [${possibleDirective}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + possibleDirective.length, + eSeverity.Error, + `Illegal P2 Spin inline-pasm directive [${possibleDirective}]` + ); } else { if (lineParts.length > minNonLabelParts) { currentOffset = line.indexOf(lineParts[minNonLabelParts - 1], currentOffset) + lineParts[minNonLabelParts - 1].length + 1; let nameOffset: number = 0; - let namePart: string = ""; + let namePart: string = ''; for (let index = minNonLabelParts; index < lineParts.length; index++) { - const argumentName = lineParts[index].replace(/[@#]/, ""); + const argumentName = lineParts[index].replace(/[@#]/, ''); if (argumentName.length < 1) { // skip empty operand continue; } if (index == lineParts.length - 1 && this.parseUtils.isP2AsmEffect(argumentName)) { // conditional flag-set spec. - this._logPASM(" -- SKIP argumentName=[" + argumentName + "]"); + this._logPASM(' -- SKIP argumentName=[' + argumentName + ']'); continue; } - const currArgumentLen = argumentName.length; - if (argumentName.charAt(0).match(/[a-zA-Z_\.]/)) { + //const currArgumentLen = argumentName.length; + if (argumentName.charAt(0).match(/[a-zA-Z_.]/)) { // does name contain a namespace reference? - this._logPASM(" -- argumentName=[" + argumentName + "]"); + this._logPASM(' -- argumentName=[' + argumentName + ']'); if (this._isPossibleObjectReference(argumentName)) { const bHaveObjReference = this._reportObjectReference(argumentName, lineIdx, currentOffset, line, tokenSet); if (bHaveObjReference) { @@ -5066,36 +5602,36 @@ export class Spin2DocumentSemanticParser { } } let possibleNameSet: string[] = [argumentName]; - if (argumentName.includes(".") && !argumentName.startsWith(".")) { - possibleNameSet = argumentName.split("."); + if (argumentName.includes('.') && !argumentName.startsWith('.')) { + possibleNameSet = argumentName.split('.'); } - this._logPASM(" -- possibleNameSet=[" + possibleNameSet + "]"); + this._logPASM(' -- possibleNameSet=[' + possibleNameSet + ']'); namePart = possibleNameSet[0]; const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : `${possibleNameSet[0]}.${possibleNameSet[1]}`; nameOffset = line.indexOf(searchString, currentOffset); let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.hasLocalPAsmTokenForMethod(this.currentMethodName, namePart)) { referenceDetails = this.semanticFindings.getLocalPAsmTokenForMethod(this.currentMethodName, namePart); - this._logPASM(" -- FOUND local PASM name=[" + namePart + "]"); + this._logPASM(' -- FOUND local PASM name=[' + namePart + ']'); } else if (this.semanticFindings.isLocalToken(namePart)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(namePart, lineNbr); - this._logPASM(" -- FOUND local name=[" + namePart + "]"); + this._logPASM(' -- FOUND local name=[' + namePart + ']'); } else if (this.semanticFindings.isGlobalToken(namePart)) { referenceDetails = this.semanticFindings.getGlobalToken(namePart); - this._logPASM(" -- FOUND global name=[" + namePart + "]"); + this._logPASM(' -- FOUND global name=[' + namePart + ']'); } if (referenceDetails != undefined) { - this._logPASM(" -- SPIN inlinePASM add name=[" + namePart + "]"); + this._logPASM(' -- SPIN inlinePASM add name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // we don't have name registered so just mark it - if (namePart != ".") { + if (namePart != '.') { // odd special case! if ( !this.parseUtils.isSpinReservedWord(namePart) && @@ -5103,25 +5639,37 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isDebugMethod(namePart) && !this.parseUtils.isP2AsmModczOperand(namePart) ) { - this._logPASM(" -- SPIN PAsm MISSING name=[" + namePart + "]"); + this._logPASM(' -- SPIN PAsm MISSING name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin F pasm missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin F pasm missing declaration [${namePart}]` + ); } else if (this.parseUtils.isIllegalInlinePAsmDirective(namePart)) { - this._logPASM(" -- SPIN inlinePAsm ERROR[CODE] illegal name=[" + namePart + "]"); + this._logPASM(' -- SPIN inlinePAsm ERROR[CODE] illegal name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + possibleDirective.length, eSeverity.Error, "Illegal P2 Spin inline-pasm name"); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + possibleDirective.length, + eSeverity.Error, + 'Illegal P2 Spin inline-pasm name' + ); } } } @@ -5137,16 +5685,22 @@ export class Spin2DocumentSemanticParser { // if this symbol is NOT a global token then it could be bad! if (!this.semanticFindings.isKnownToken(nameOrDirective)) { if (this.parseUtils.isIllegalInlinePAsmDirective(nameOrDirective) || !this.parseUtils.isP2AsmInstruction(nameOrDirective)) { - this._logPASM(" -- SPIN inline-PAsm MISSING name=[" + nameOrDirective + "]"); + this._logPASM(' -- SPIN inline-PAsm MISSING name=[' + nameOrDirective + ']'); const nameOffset = line.indexOf(nameOrDirective, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: nameOrDirective.length, - ptTokenType: "variable", // color this offender! - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', // color this offender! + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + nameOrDirective.length, eSeverity.Error, "Illegal P2 Spin Directive within inline-pasm"); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + nameOrDirective.length, + eSeverity.Error, + 'Illegal P2 Spin Directive within inline-pasm' + ); } } } @@ -5159,8 +5713,15 @@ export class Spin2DocumentSemanticParser { } const allowLocalVarStatus: boolean = true; const NOT_DAT_PASM: boolean = false; - const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode(lineIdx, startingOffset, line, allowLocalVarStatus, this.showPAsmCode, NOT_DAT_PASM); - this._reportNonDupeTokens(partialTokenSet, "=> DATvalue: ", line, tokenSet); + const partialTokenSet: IParsedToken[] = this._reportDAT_ValueDeclarationCode( + lineIdx, + startingOffset, + line, + allowLocalVarStatus, + this.showPAsmCode, + NOT_DAT_PASM + ); + this._reportNonDupeTokens(partialTokenSet, '=> DATvalue: ', line, tokenSet); } } return tokenSet; @@ -5172,16 +5733,16 @@ export class Spin2DocumentSemanticParser { let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); const remainingNonCommentLineStr: string = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); this._logOBJ(`- RptObjDecl remainingNonCommentLineStr=[${remainingNonCommentLineStr}], currentOffset=(${currentOffset})`); - const bHasOverrides: boolean = remainingNonCommentLineStr.includes("|"); - const overrideParts: string[] = remainingNonCommentLineStr.split("|"); + const bHasOverrides: boolean = remainingNonCommentLineStr.includes('|'); + const overrideParts: string[] = remainingNonCommentLineStr.split('|'); const remainingLength: number = remainingNonCommentLineStr.length; - const bHasColon: boolean = remainingNonCommentLineStr.includes(":"); - let objectName: string = ""; + //const bHasColon: boolean = remainingNonCommentLineStr.includes(':'); + let objectName: string = ''; if (remainingLength > 0) { // get line parts - initially, we only care about first one - const lineParts: string[] = remainingNonCommentLineStr.split(/[ \t\:\[]/).filter(Boolean); - this._logOBJ(" -- OBJ lineParts=[" + lineParts + "]"); + const lineParts: string[] = remainingNonCommentLineStr.split(/[ \t:[]/).filter(Boolean); + this._logOBJ(' -- OBJ lineParts=[' + lineParts + ']'); objectName = lineParts[0]; // object name token must be offset into full line for token const nameOffset: number = line.indexOf(objectName, currentOffset); @@ -5189,13 +5750,13 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: objectName.length, - ptTokenType: "namespace", - ptTokenModifiers: ["declaration"], + ptTokenType: 'namespace', + ptTokenModifiers: ['declaration'] }); - const objArrayOpen: number = remainingNonCommentLineStr.indexOf("["); + const objArrayOpen: number = remainingNonCommentLineStr.indexOf('['); if (objArrayOpen != -1) { // we have an array of objects, study the index value for possible named reference(s) - const objArrayClose: number = remainingNonCommentLineStr.indexOf("]"); + const objArrayClose: number = remainingNonCommentLineStr.indexOf(']'); if (objArrayClose != -1) { const elemCountStr: string = remainingNonCommentLineStr.substr(objArrayOpen + 1, objArrayClose - objArrayOpen - 1); // if we have a variable name... @@ -5206,7 +5767,7 @@ export class Spin2DocumentSemanticParser { if (this._isPossibleObjectReference(elemCountStr)) { // go register object reference! bHaveObjReference = this._reportObjectReference(elemCountStr, lineIdx, startingOffset, line, tokenSet); - possibleNameSet = elemCountStr.split("."); + possibleNameSet = elemCountStr.split('.'); } if (!bHaveObjReference) { for (let index = 0; index < possibleNameSet.length; index++) { @@ -5217,27 +5778,37 @@ export class Spin2DocumentSemanticParser { const nameOffset = line.indexOf(nameReference, currentOffset); if (referenceDetails != undefined) { //const updatedModificationSet: string[] = this._modifiersWithout(referenceDetails.modifiers, "declaration"); - this._logOBJ(" -- FOUND global name=[" + nameReference + "]"); + this._logOBJ(' -- FOUND global name=[' + nameReference + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: nameReference.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } - } else if (!this.parseUtils.isSpinReservedWord(nameReference) && !this.parseUtils.isBuiltinStreamerReservedWord(nameReference) && !this.parseUtils.isDebugMethod(nameReference)) { + } else if ( + !this.parseUtils.isSpinReservedWord(nameReference) && + !this.parseUtils.isBuiltinStreamerReservedWord(nameReference) && + !this.parseUtils.isDebugMethod(nameReference) + ) { // we don't have name registered so just mark it - this._logOBJ(" -- OBJ MISSING name=[" + nameReference + "]"); + this._logOBJ(' -- OBJ MISSING name=[' + nameReference + ']'); const nameOffset = line.indexOf(nameReference, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: nameReference.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + nameReference.length, eSeverity.Error, `P2 Spin G missing declaration [${nameReference}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + nameReference.length, + eSeverity.Error, + `P2 Spin G missing declaration [${nameReference}]` + ); } } } @@ -5247,32 +5818,44 @@ export class Spin2DocumentSemanticParser { if (bHasOverrides && overrideParts.length > 1) { // Ex: child1 : "child" | MULTIPLIER = 3, COUNT = 5, HAVE_HIDPAD = true ' override child constants // ^^^^^^^^^^^^^^^^^^^^^^^^^ (process this part) - const overrides: string = overrideParts[1].replace(/[ \t]/, ""); - const overideSatements: string[] = overrides.split(",").filter(Boolean); + const overrides: string = overrideParts[1].replace(/[ \t]/, ''); + const overideSatements: string[] = overrides.split(',').filter(Boolean); this._logOBJ(` -- OBJ overideSatements=[${overideSatements}](${overideSatements.length})`); for (let index = 0; index < overideSatements.length; index++) { - const statementParts: string[] = overideSatements[index].split("="); + const statementParts: string[] = overideSatements[index].split('='); const overideName: string = statementParts[0].trim(); - const overideValue: string = statementParts.length > 1 ? statementParts[1].trim() : ""; // XYZZY - if (overideName === "...") { + const overideValue: string = statementParts.length > 1 ? statementParts[1].trim() : ''; // XYZZY + if (overideName === '...') { continue; // skip line continuation marker } const lookupName: string = `${objectName}%${overideName}`; this._logOBJ(` -- OBJ overideName=[${overideName}](${overideName.length}), overideValue=[${overideValue}](${overideValue.length})`); - let nameOffset: number = line.indexOf(overideName, currentOffset); - let bHaveObjReference: boolean = this._isPossibleObjectReference(lookupName) ? this._reportObjectReference(lookupName, lineIdx, nameOffset, line, tokenSet) : false; + const nameOffset: number = line.indexOf(overideName, currentOffset); + const bHaveObjReference: boolean = this._isPossibleObjectReference(lookupName) + ? this._reportObjectReference(lookupName, lineIdx, nameOffset, line, tokenSet) + : false; if (!bHaveObjReference) { - this._logOBJ(" -- OBJ MISSING name=[" + overideName + "]"); + this._logOBJ(' -- OBJ MISSING name=[' + overideName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: overideName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + overideName.length, eSeverity.Error, `P2 Spin H missing declaration [${overideName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + overideName.length, + eSeverity.Error, + `P2 Spin H missing declaration [${overideName}]` + ); } - this._logOBJ(` -- OBJ CALC currOffset nameOffset=(${nameOffset}) + nameLen=(${overideName.length}) = currentOffset=(${nameOffset + overideName.length})`); + this._logOBJ( + ` -- OBJ CALC currOffset nameOffset=(${nameOffset}) + nameLen=(${overideName.length}) = currentOffset=(${ + nameOffset + overideName.length + })` + ); currentOffset = nameOffset + overideName.length; // move past this name // process RHS of assignment (overideValue) too! @@ -5280,7 +5863,9 @@ export class Spin2DocumentSemanticParser { // process symbol name const nameOffset = line.indexOf(overideValue, currentOffset); this._logOBJ(` -- OBJ overideValue=[${overideValue}], ofs=(${nameOffset})`); - let bHaveObjReference: boolean = this._isPossibleObjectReference(overideValue) ? this._reportObjectReference(overideValue, lineIdx, nameOffset, line, tokenSet) : false; + const bHaveObjReference: boolean = this._isPossibleObjectReference(overideValue) + ? this._reportObjectReference(overideValue, lineIdx, nameOffset, line, tokenSet) + : false; if (!bHaveObjReference) { let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.isGlobalToken(overideValue)) { @@ -5289,34 +5874,40 @@ export class Spin2DocumentSemanticParser { // Token offsets must be line relative so search entire line... if (referenceDetails != undefined) { //const updatedModificationSet: string[] = this._modifiersWithout(referenceDetails.modifiers, "declaration"); - this._logOBJ(" -- FOUND global name=[" + overideValue + "]"); + this._logOBJ(' -- FOUND global name=[' + overideValue + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: overideValue.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else if (this.parseUtils.isP2AsmReservedWord(overideValue)) { - this._logOBJ(" -- FOUND built-in constant=[" + overideValue + "]"); + this._logOBJ(' -- FOUND built-in constant=[' + overideValue + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: overideValue.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly'] }); } else { // if (!this.parseUtils.isP2AsmReservedWord(overideValue)) { - this._logOBJ(" -- OBJ MISSING RHS name=[" + overideValue + "]"); + this._logOBJ(' -- OBJ MISSING RHS name=[' + overideValue + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: overideValue.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + overideValue.length, eSeverity.Error, `P2 Spin I missing declaration [${overideValue}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + overideValue.length, + eSeverity.Error, + `P2 Spin I missing declaration [${overideValue}]` + ); } } currentOffset = nameOffset + overideValue.length; @@ -5334,16 +5925,16 @@ export class Spin2DocumentSemanticParser { // FIXME: TODO: UNDONE - maybe we need to highlight comments which are NOT captured yet in multi-line set const remainingNonCommentLineStr: string = multiLineSet.line; this._logOBJ(`- RptObjDecl remainingNonCommentLineStr=[${remainingNonCommentLineStr}], currSingleLineOffset=(${currSingleLineOffset})`); - const bHasOverrides: boolean = remainingNonCommentLineStr.includes("|"); - const overrideParts: string[] = remainingNonCommentLineStr.split("|"); + const bHasOverrides: boolean = remainingNonCommentLineStr.includes('|'); + const overrideParts: string[] = remainingNonCommentLineStr.split('|'); const remainingLength: number = remainingNonCommentLineStr.length; - const bHasColon: boolean = remainingNonCommentLineStr.includes(":"); - let objectName: string = ""; + //const bHasColon: boolean = remainingNonCommentLineStr.includes(':'); + let objectName: string = ''; if (remainingLength > 0) { // get line parts - initially, we only care about first one - const lineParts: string[] = remainingNonCommentLineStr.split(/[ \t\:\[]/).filter(Boolean); - this._logOBJ(" -- OBJ lineParts=[" + lineParts + "]"); + const lineParts: string[] = remainingNonCommentLineStr.split(/[ \t:[]/).filter(Boolean); + this._logOBJ(' -- OBJ lineParts=[' + lineParts + ']'); objectName = lineParts[0]; // object name token must be offset into full line for token //const nameOffset: number = line.indexOf(objectName, currSingleLineOffset); @@ -5352,13 +5943,13 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: objectName.length, - ptTokenType: "namespace", - ptTokenModifiers: ["declaration"], + ptTokenType: 'namespace', + ptTokenModifiers: ['declaration'] }); - const objArrayOpen: number = remainingNonCommentLineStr.indexOf("["); + const objArrayOpen: number = remainingNonCommentLineStr.indexOf('['); if (objArrayOpen != -1) { // we have an array of objects, study the index value for possible named reference(s) - const objArrayClose: number = remainingNonCommentLineStr.indexOf("]"); + const objArrayClose: number = remainingNonCommentLineStr.indexOf(']'); if (objArrayClose != -1) { const elemCountStr: string = remainingNonCommentLineStr.substr(objArrayOpen + 1, objArrayClose - objArrayOpen - 1); // if we have a variable name... @@ -5369,8 +5960,14 @@ export class Spin2DocumentSemanticParser { if (this._isPossibleObjectReference(elemCountStr)) { // go register object reference! const symbolPosition: Position = multiLineSet.locateSymbol(elemCountStr, currSingleLineOffset); - bHaveObjReference = this._reportObjectReference(elemCountStr, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet); - possibleNameSet = elemCountStr.split("."); + bHaveObjReference = this._reportObjectReference( + elemCountStr, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ); + possibleNameSet = elemCountStr.split('.'); } if (!bHaveObjReference) { for (let index = 0; index < possibleNameSet.length; index++) { @@ -5381,24 +5978,28 @@ export class Spin2DocumentSemanticParser { // Token offsets must be line relative so search entire line... if (referenceDetails != undefined) { //const updatedModificationSet: string[] = this._modifiersWithout(referenceDetails.modifiers, "declaration"); - this._logOBJ(" -- FOUND global name=[" + nameReference + "]"); + this._logOBJ(' -- FOUND global name=[' + nameReference + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: nameReference.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } - } else if (!this.parseUtils.isSpinReservedWord(nameReference) && !this.parseUtils.isBuiltinStreamerReservedWord(nameReference) && !this.parseUtils.isDebugMethod(nameReference)) { + } else if ( + !this.parseUtils.isSpinReservedWord(nameReference) && + !this.parseUtils.isBuiltinStreamerReservedWord(nameReference) && + !this.parseUtils.isDebugMethod(nameReference) + ) { // we don't have name registered so just mark it - this._logOBJ(" -- OBJ MISSING name=[" + nameReference + "]"); + this._logOBJ(' -- OBJ MISSING name=[' + nameReference + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: nameReference.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -5416,22 +6017,28 @@ export class Spin2DocumentSemanticParser { if (bHasOverrides && overrideParts.length > 1) { // Ex: child1 : "child" | MULTIPLIER = 3, COUNT = 5, HAVE_HIDPAD = true ' override child constants // ^^^^^^^^^^^^^^^^^^^^^^^^^ (process this part) - const overrides: string = overrideParts[1].replace(/[ \t]/, ""); - const overideSatements: string[] = overrides.split(",").filter(Boolean); + const overrides: string = overrideParts[1].replace(/[ \t]/, ''); + const overideSatements: string[] = overrides.split(',').filter(Boolean); this._logOBJ(` -- OBJ overideSatements=[${overideSatements}](${overideSatements.length})`); for (let index = 0; index < overideSatements.length; index++) { - const statementParts: string[] = overideSatements[index].split("="); + const statementParts: string[] = overideSatements[index].split('='); const overideName: string = statementParts[0].trim(); - const overideValue: string = statementParts.length > 1 ? statementParts[1].trim() : ""; // XYZZY - if (overideName === "...") { + const overideValue: string = statementParts.length > 1 ? statementParts[1].trim() : ''; // XYZZY + if (overideName === '...') { continue; // skip line continuation marker } const lookupName: string = `${objectName}%${overideName}`; this._logOBJ(` -- OBJ overideName=[${overideName}](${overideName.length}), overideValue=[${overideValue}](${overideValue.length})`); const symbolPosition: Position = multiLineSet.locateSymbol(overideName, currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); - let bHaveObjReference: boolean = this._isPossibleObjectReference(lookupName) - ? this._reportObjectReference(lookupName, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet) + const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + const bHaveObjReference: boolean = this._isPossibleObjectReference(lookupName) + ? this._reportObjectReference( + lookupName, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ) : false; if (!bHaveObjReference) { this._logOBJ(` -- OBJ MISSING name=[${overideName}]`); @@ -5439,8 +6046,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: overideName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -5450,17 +6057,27 @@ export class Spin2DocumentSemanticParser { `P2 Spin H missing declaration [${overideName}]` ); } - this._logOBJ(` -- OBJ CALC currOffset nameOffset=(${nameOffset}) + nameLen=(${overideName.length}) = currSingleLineOffset=(${nameOffset + overideName.length})`); + this._logOBJ( + ` -- OBJ CALC currOffset nameOffset=(${nameOffset}) + nameLen=(${overideName.length}) = currSingleLineOffset=(${ + nameOffset + overideName.length + })` + ); currSingleLineOffset = nameOffset + overideName.length; // move past this name // process RHS of assignment (overideValue) too! if (overideValue.charAt(0).match(/[a-zA-Z_]/)) { // process symbol name const symbolPosition: Position = multiLineSet.locateSymbol(overideValue, currSingleLineOffset); - let nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); + const nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); this._logOBJ(` -- OBJ overideValue=[${overideValue}], ofs=(${nameOffset})`); - let bHaveObjReference: boolean = this._isPossibleObjectReference(overideValue) - ? this._reportObjectReference(overideValue, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet) + const bHaveObjReference: boolean = this._isPossibleObjectReference(overideValue) + ? this._reportObjectReference( + overideValue, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ) : false; if (!bHaveObjReference) { let referenceDetails: RememberedToken | undefined = undefined; @@ -5470,32 +6087,32 @@ export class Spin2DocumentSemanticParser { // Token offsets must be line relative so search entire line... if (referenceDetails != undefined) { //const updatedModificationSet: string[] = this._modifiersWithout(referenceDetails.modifiers, "declaration"); - this._logOBJ(" -- FOUND global name=[" + overideValue + "]"); + this._logOBJ(' -- FOUND global name=[' + overideValue + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: overideValue.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else if (this.parseUtils.isP2AsmReservedWord(overideValue)) { - this._logOBJ(" -- FOUND built-in constant=[" + overideValue + "]"); + this._logOBJ(' -- FOUND built-in constant=[' + overideValue + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: overideValue.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly'] }); } else { // if (!this.parseUtils.isP2AsmReservedWord(overideValue)) { - this._logOBJ(" -- OBJ MISSING RHS name=[" + overideValue + "]"); + this._logOBJ(' -- OBJ MISSING RHS name=[' + overideValue + ']'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: overideValue.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -5514,20 +6131,22 @@ export class Spin2DocumentSemanticParser { return tokenSet; } + /* private isNumeric(val: any): boolean { // REF https://stackoverflow.com/questions/23437476/in-typescript-how-to-check-if-a-string-is-numeric let desiredNumericStatus: boolean = false; - if (val.indexOf("%%") == 0) { + if (val.indexOf('%%') == 0) { desiredNumericStatus = true; - } else if (val.indexOf("%") == 0) { + } else if (val.indexOf('%') == 0) { desiredNumericStatus = true; - } else if (val.indexOf("$") == 0) { + } else if (val.indexOf('$') == 0) { desiredNumericStatus = true; } else { desiredNumericStatus = !(val instanceof Array) && val - parseFloat(val) + 1 >= 0; } return desiredNumericStatus; } + */ private _reportVAR_DeclarationLine(lineIdx: number, startingOffset: number, line: string): IParsedToken[] { const tokenSet: IParsedToken[] = []; @@ -5536,94 +6155,104 @@ export class Spin2DocumentSemanticParser { const remainingNonCommentLineStr: string = this._getNonCommentLineReturnComment(currentOffset, lineIdx, line, tokenSet); if (remainingNonCommentLineStr.length > 0) { // get line parts - we only care about first one - let lineParts: string[] = this.parseUtils.getCommaDelimitedNonWhiteLineParts(remainingNonCommentLineStr); + const lineParts: string[] = this.parseUtils.getCommaDelimitedNonWhiteLineParts(remainingNonCommentLineStr); this._logVAR(` -- rptVarDecl lineParts=[${lineParts}]`); // remember this object name so we can annotate a call to it - const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(","); + //const isMultiDeclaration: boolean = remainingNonCommentLineStr.includes(','); const hasStorageType: boolean = this.parseUtils.isStorageType(lineParts[0]); if (lineParts.length > 1) { const startIndex: number = hasStorageType ? 1 : 0; for (let index = startIndex; index < lineParts.length; index++) { let newName = lineParts[index]; - const hasArrayReference: boolean = newName.indexOf("[") != -1; + const hasArrayReference: boolean = newName.indexOf('[') != -1; if (hasArrayReference) { // remove array suffix from name - if (newName.includes("[")) { - const nameParts: string[] = newName.split("["); + if (newName.includes('[')) { + const nameParts: string[] = newName.split('['); newName = nameParts[0]; } } // in the following, let's not register a name with a trailing ']' this is part of an array size calculation! - if (newName.charAt(0).match(/[a-zA-Z_]/) && newName.indexOf("]") == -1) { - this._logVAR(" -- GLBL ADD rvdl newName=[" + newName + "]"); + if (newName.charAt(0).match(/[a-zA-Z_]/) && newName.indexOf(']') == -1) { + this._logVAR(' -- GLBL ADD rvdl newName=[' + newName + ']'); const nameOffset: number = line.indexOf(newName, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "instance"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'instance'] }); currentOffset = nameOffset + newName.length; } if (hasArrayReference) { // process name with array length value - const arrayOpenOffset: number = line.indexOf("[", currentOffset); - const arrayCloseOffset: number = line.indexOf("]", currentOffset); + const arrayOpenOffset: number = line.indexOf('[', currentOffset); + const arrayCloseOffset: number = line.indexOf(']', currentOffset); const arrayReference: string = line.substr(arrayOpenOffset + 1, arrayCloseOffset - arrayOpenOffset - 1); - const arrayReferenceParts: string[] = arrayReference.split(/[ \t\/\*\+\<\>]/); - this._logVAR(" -- arrayReferenceParts=[" + arrayReferenceParts + "]"); + const arrayReferenceParts: string[] = arrayReference.split(/[ \t/*+<>]/); + this._logVAR(' -- arrayReferenceParts=[' + arrayReferenceParts + ']'); for (let index = 0; index < arrayReferenceParts.length; index++) { const referenceName = arrayReferenceParts[index]; if (referenceName.charAt(0).match(/[a-zA-Z_]/)) { let possibleNameSet: string[] = []; // is it a namespace reference? - if (referenceName.includes(".")) { - possibleNameSet = referenceName.split("."); + if (referenceName.includes('.')) { + possibleNameSet = referenceName.split('.'); } else { possibleNameSet = [referenceName]; } - this._logVAR(" -- possibleNameSet=[" + possibleNameSet + "]"); + this._logVAR(' -- possibleNameSet=[' + possibleNameSet + ']'); const namePart = possibleNameSet[0]; if (this.semanticFindings.isGlobalToken(namePart)) { const referenceDetails: RememberedToken | undefined = this.semanticFindings.getGlobalToken(namePart); const searchString: string = possibleNameSet.length == 1 ? possibleNameSet[0] : `${possibleNameSet[0]}.${possibleNameSet[1]}`; const nameOffset = line.indexOf(searchString, currentOffset); if (referenceDetails != undefined) { - this._logVAR(" -- FOUND global name=[" + namePart + "]"); + this._logVAR(' -- FOUND global name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // we don't have name registered so just mark it - if (!this.parseUtils.isSpinReservedWord(namePart) && !this.parseUtils.isBuiltinStreamerReservedWord(namePart) && !this.parseUtils.isDebugMethod(namePart)) { - this._logVAR(" -- VAR Add MISSING name=[" + namePart + "]"); + if ( + !this.parseUtils.isSpinReservedWord(namePart) && + !this.parseUtils.isBuiltinStreamerReservedWord(namePart) && + !this.parseUtils.isDebugMethod(namePart) + ) { + this._logVAR(' -- VAR Add MISSING name=[' + namePart + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin I missing declaration [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin I missing declaration [${namePart}]` + ); } } } if (possibleNameSet.length > 1) { // we have .constant namespace suffix - this._logVAR(" -- VAR Add ReadOnly name=[" + namePart + "]"); + this._logVAR(' -- VAR Add ReadOnly name=[' + namePart + ']'); const constantPart: string = possibleNameSet[1]; const nameOffset = line.indexOf(constantPart, currentOffset); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: constantPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["readonly"], + ptTokenType: 'variable', + ptTokenModifiers: ['readonly'] }); } } @@ -5633,8 +6262,8 @@ export class Spin2DocumentSemanticParser { } else { // have single declaration per line let nameSet: string[] = [lineParts[0]]; - if (lineParts[0].includes("[")) { - nameSet = lineParts[0].split(/[\[\]}]/).filter(Boolean); + if (lineParts[0].includes('[')) { + nameSet = lineParts[0].split(/[[\]}]/).filter(Boolean); } let newName: string = nameSet[0]; if (newName.charAt(0).match(/[a-zA-Z_]/)) { @@ -5644,8 +6273,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["declaration", "instance"], + ptTokenType: 'variable', + ptTokenModifiers: ['declaration', 'instance'] }); } if (nameSet.length > 1) { @@ -5657,26 +6286,36 @@ export class Spin2DocumentSemanticParser { const searchString: string = newName; const nameOffset = line.indexOf(searchString, currentOffset); if (referenceDetails != undefined) { - this._logVAR(" -- FOUND global name=[" + newName + "]"); + this._logVAR(' -- FOUND global name=[' + newName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // we don't have name registered so just mark it - if (!this.parseUtils.isSpinReservedWord(newName) && !this.parseUtils.isBuiltinStreamerReservedWord(newName) && !this.parseUtils.isDebugMethod(newName)) { - this._logVAR(" -- VAR Add MISSING name=[" + newName + "]"); + if ( + !this.parseUtils.isSpinReservedWord(newName) && + !this.parseUtils.isBuiltinStreamerReservedWord(newName) && + !this.parseUtils.isDebugMethod(newName) + ) { + this._logVAR(' -- VAR Add MISSING name=[' + newName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: nameOffset, length: newName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + newName.length, eSeverity.Error, `P2 Spin J missing declaration [${newName}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + newName.length, + eSeverity.Error, + `P2 Spin J missing declaration [${newName}]` + ); } } } @@ -5703,24 +6342,25 @@ export class Spin2DocumentSemanticParser { } this._logDEBUG(`- Ln#${multiLineSet.lineStartIdx + 1} rtpDbgStmntMulti debugStatementStr=[${debugStatementStr}]`); - let lineParts: string[] = this.parseUtils.getDebugNonWhiteLineParts(debugStatementStr); + const lineParts: string[] = this.parseUtils.getDebugNonWhiteLineParts(debugStatementStr); this._logDEBUG(` -- rptDbg AM lineParts=[${lineParts}](${lineParts.length})`); - if (lineParts.length > 0 && lineParts[0].toLowerCase() != "debug") { + if (lineParts.length > 0 && lineParts[0].toLowerCase() != 'debug') { //this._logDEBUG(' -- rptDbg first name not debug! (label?) removing! lineParts[0]=[' + lineParts[0] + ']'); lineParts.shift(); // assume pasm, remove label } - if (lineParts[0].toLowerCase() == "debug") { + if (lineParts[0].toLowerCase() == 'debug') { //let symbolOffset: number = currSingleLineOffset; - const displayType: string = lineParts.length >= 2 ? lineParts[1] : ""; - if (displayType.startsWith("`")) { + const displayType: string = lineParts.length >= 2 ? lineParts[1] : ''; + if (displayType.startsWith('`')) { this._logDEBUG(` -- rptDbg have "debug("\` lineParts=[${lineParts}](${lineParts.length})`); //symbolOffset = line.indexOf(displayType, symbolOffset) + 1; // plus 1 to get past back-tic const newDisplayType: string = displayType.substring(1, displayType.length); - let displayTestName: string = lineParts[1] == "`" ? lineParts[1] + lineParts[2] : lineParts[1]; - displayTestName = displayTestName.toLowerCase().replace(/ \t/g, ""); - const isRuntimeNamed: boolean = displayTestName.startsWith("``") || displayTestName.startsWith("`zstr") || displayTestName.startsWith("`lstr"); + let displayTestName: string = lineParts[1] == '`' ? lineParts[1] + lineParts[2] : lineParts[1]; + displayTestName = displayTestName.toLowerCase().replace(/ \t/g, ''); + const isRuntimeNamed: boolean = + displayTestName.startsWith('``') || displayTestName.startsWith('`zstr') || displayTestName.startsWith('`lstr'); this._logDEBUG(` -- rptDbg displayTestName=[${displayTestName}], isRuntimeNamed=${isRuntimeNamed}`); - let bHaveInstantiation = this.parseUtils.isDebugDisplayType(newDisplayType) && !isRuntimeNamed; + const bHaveInstantiation = this.parseUtils.isDebugDisplayType(newDisplayType) && !isRuntimeNamed; if (bHaveInstantiation) { this._logDEBUG(` -- rptDbg --- PROCESSING Display Instantiation`); // ------------------------------------- @@ -5734,8 +6374,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newDisplayType.length, - ptTokenType: "displayType", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'displayType', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); currSingleLineOffset = nameOffset + newDisplayType.length; // (0b) register userName use @@ -5747,12 +6387,12 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newDisplayName.length, - ptTokenType: "displayName", - ptTokenModifiers: ["declaration"], + ptTokenType: 'displayName', + ptTokenModifiers: ['declaration'] }); currSingleLineOffset = nameOffset + newDisplayName.length; // (1) highlight parameter names - let eDisplayType: eDebugDisplayType = this.semanticFindings.getDebugDisplayEnumForType(newDisplayType); + const eDisplayType: eDebugDisplayType = this.semanticFindings.getDebugDisplayEnumForType(newDisplayType); const firstParamIdx: number = 3; // [0]=debug [1]=`{type}, [2]={userName} for (let idx = firstParamIdx; idx < lineParts.length; idx++) { const newParameter: string = lineParts[idx]; @@ -5765,8 +6405,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { const bIsColorName: boolean = this.parseUtils.isDebugColorName(newParameter); @@ -5776,8 +6416,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newParameter.length, - ptTokenType: "colorName", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'colorName', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { // unknown parameter, is known symbol? @@ -5799,7 +6439,7 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolPosition.character, length: newParameter.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // handle unknown-name case @@ -5807,20 +6447,20 @@ export class Spin2DocumentSemanticParser { if ( paramIsSymbolName && !this.parseUtils.isDebugMethod(newParameter) && - newParameter.indexOf("`") == -1 && + newParameter.indexOf('`') == -1 && !this.parseUtils.isUnaryOperator(newParameter) && !this.parseUtils.isBinaryOperator(newParameter) && !this.parseUtils.isFloatConversion(newParameter) && !this.parseUtils.isSpinBuiltinMethod(newParameter) && !this.parseUtils.isBuiltinStreamerReservedWord(newParameter) ) { - this._logDEBUG(" -- rptDbg 1 unkParam=[${newParameter}]"); + this._logDEBUG(' -- rptDbg 1 unkParam=[${newParameter}]'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -5862,7 +6502,7 @@ export class Spin2DocumentSemanticParser { this._logDEBUG(` -- rptDbg --- PROCESSING feed`); let currLineNbr: number = 0; if (isRuntimeNamed) { - firstParamIdx = displayName == "`" || displayName == "``" ? 2 : 1; // [0]=`debug` [1]=`runtimeName, [2]... symbols + firstParamIdx = displayName == '`' || displayName == '``' ? 2 : 1; // [0]=`debug` [1]=`runtimeName, [2]... symbols } else { firstParamIdx = 1; // [0]=debug [1]=`{userName}[[, {userName}], ...] // handle one or more names! @@ -5876,8 +6516,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: displayName.length, - ptTokenType: "displayName", - ptTokenModifiers: ["reference"], + ptTokenType: 'displayName', + ptTokenModifiers: ['reference'] }); currSingleLineOffset = nameOffset + displayName.length; if (firstParamIdx < lineParts.length) { @@ -5895,7 +6535,7 @@ export class Spin2DocumentSemanticParser { // override bad display type with directive if present eDisplayType = this._getDisplayTypeForLine(currLineNbr); } - let newParameter: string = ""; + let newParameter: string = ''; let symbolPosition: Position = Position.create(-1, -1); let nameOffset: number = 0; for (let idx = firstParamIdx; idx < lineParts.length; idx++) { @@ -5903,7 +6543,7 @@ export class Spin2DocumentSemanticParser { if (newParameter.indexOf("'") != -1 || this.parseUtils.isStorageType(newParameter)) { currSingleLineOffset += newParameter.length; continue; // skip this name (it's part of a string!) - } else if (newParameter.indexOf("#") != -1) { + } else if (newParameter.indexOf('#') != -1) { currSingleLineOffset += newParameter.length; continue; // skip this name (it's part of a string!) } @@ -5912,7 +6552,7 @@ export class Spin2DocumentSemanticParser { nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); this._logDEBUG(` -- rptDbg ?check? [${newParameter}] ofs=(${nameOffset})`); let bIsParameterName: boolean = this.parseUtils.isNameWithTypeFeed(newParameter, eDisplayType); - if (isRuntimeNamed && newParameter.toLowerCase() == "lutcolors") { + if (isRuntimeNamed && newParameter.toLowerCase() == 'lutcolors') { bIsParameterName = true; } if (bIsParameterName) { @@ -5921,8 +6561,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newParameter.length, - ptTokenType: "feedParameter", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'feedParameter', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { const bIsColorName: boolean = this.parseUtils.isDebugColorName(newParameter); @@ -5932,8 +6572,8 @@ export class Spin2DocumentSemanticParser { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newParameter.length, - ptTokenType: "colorName", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'colorName', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { // unknown parameter, is known symbol? @@ -5955,7 +6595,7 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolPosition.character, length: newParameter.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // handle unknown-name case @@ -5963,7 +6603,7 @@ export class Spin2DocumentSemanticParser { if ( paramIsSymbolName && this.parseUtils.isDebugMethod(newParameter) == false && - newParameter.indexOf("`") == -1 && + newParameter.indexOf('`') == -1 && !this.parseUtils.isUnaryOperator(newParameter) && !this.parseUtils.isBinaryOperator(newParameter) && !this.parseUtils.isFloatConversion(newParameter) && @@ -5971,13 +6611,13 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isSpinReservedWord(newParameter) && !this.parseUtils.isBuiltinStreamerReservedWord(newParameter) ) { - this._logDEBUG(" -- rptDbg 2 unkParam=[${newParameter}]"); // XYZZY LutColors + this._logDEBUG(' -- rptDbg 2 unkParam=[${newParameter}]'); // XYZZY LutColors this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -6001,11 +6641,11 @@ export class Spin2DocumentSemanticParser { } } } else { - this._logDEBUG(" -- rptDbg --- PROCESSING non-display (other)"); + this._logDEBUG(' -- rptDbg --- PROCESSING non-display (other)'); // ------------------------------------- // process non-display debug statement const firstParamIdx: number = 0; // no prefix to skip - let newParameter: string = ""; + let newParameter: string = ''; let symbolPosition: Position = Position.create(-1, -1); let nameOffset: number = 0; for (let idx = firstParamIdx; idx < lineParts.length; idx++) { @@ -6015,23 +6655,31 @@ export class Spin2DocumentSemanticParser { currSingleLineOffset += newParameter.length; continue; } - if (newParameter.toLowerCase() == "debug" || this.parseUtils.isStorageType(newParameter)) { + if (newParameter.toLowerCase() == 'debug' || this.parseUtils.isStorageType(newParameter)) { currSingleLineOffset += newParameter.length; continue; } //symbolOffset = line.indexOf(newParameter, symbolOffset); // walk this past each symbolPosition = multiLineSet.locateSymbol(newParameter, currSingleLineOffset); nameOffset = multiLineSet.offsetIntoLineForPosition(symbolPosition); - this._logDEBUG(` -- SYMBOL=[${newParameter}], currSingleLineOfs=(${currSingleLineOffset}), posn=[${symbolPosition.line}, ${symbolPosition.character}], nameOfs=(${nameOffset})`); + this._logDEBUG( + ` -- SYMBOL=[${newParameter}], currSingleLineOfs=(${currSingleLineOffset}), posn=[${symbolPosition.line}, ${symbolPosition.character}], nameOfs=(${nameOffset})` + ); // does name contain a namespace reference? let bHaveObjReference: boolean = false; if (this._isPossibleObjectReference(newParameter)) { // go register object reference! - bHaveObjReference = this._reportObjectReference(newParameter, symbolPosition.line, symbolPosition.character, multiLineSet.lineAt(symbolPosition.line), tokenSet); + bHaveObjReference = this._reportObjectReference( + newParameter, + symbolPosition.line, + symbolPosition.character, + multiLineSet.lineAt(symbolPosition.line), + tokenSet + ); } if (!bHaveObjReference) { this._logDEBUG(` -- ?check? [${newParameter}]`); - if (newParameter.endsWith(".")) { + if (newParameter.endsWith('.')) { newParameter = newParameter.slice(0, -1); } @@ -6053,7 +6701,7 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolPosition.character, length: newParameter.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // handle unknown-name case @@ -6068,13 +6716,13 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isSpinBuiltInVariable(newParameter) && !this.parseUtils.isSpinReservedWord(newParameter) ) { - this._logDEBUG(" -- rptDbg 3 unkParam=[${newParameter}]"); + this._logDEBUG(' -- rptDbg 3 unkParam=[${newParameter}]'); this._recordToken(tokenSet, multiLineSet.lineAt(symbolPosition.line), { line: symbolPosition.line, startCharacter: symbolPosition.character, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['illegalUse'] }); this.semanticFindings.pushDiagnosticMessage( symbolPosition.line, @@ -6111,10 +6759,10 @@ export class Spin2DocumentSemanticParser { // debug(`lstr_(displayName, len) lutcolors `uhex_long_array_(image_address, lut_size)) // debug(``#(letter) lutcolors `uhex_long_array_(image_address, lut_size)) // - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const debugStatementStr = this._getDebugStatement(currentOffset, line); - this._logDEBUG(" -- rptDbg debugStatementStr=[" + debugStatementStr + "]"); + this._logDEBUG(' -- rptDbg debugStatementStr=[' + debugStatementStr + ']'); if (debugStatementStr.length == 0) { return tokenSet; } @@ -6126,105 +6774,106 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: commentOffset, length: line.length - commentOffset + 1, - ptTokenType: "comment", - ptTokenModifiers: ["line"], + ptTokenType: 'comment', + ptTokenModifiers: ['line'] }; tokenSet.push(newToken); } - this._logDEBUG("-- DEBUG Ln#" + (lineIdx + 1) + " debugStatementStr=[" + debugStatementStr + "]"); - let lineParts: string[] = this.parseUtils.getDebugNonWhiteLineParts(debugStatementStr); - this._logDEBUG(" -- rptDbg A lineParts=[" + lineParts + "](" + lineParts.length + ")"); - if (lineParts.length > 0 && lineParts[0].toLowerCase() != "debug") { + this._logDEBUG('-- DEBUG Ln#' + (lineIdx + 1) + ' debugStatementStr=[' + debugStatementStr + ']'); + const lineParts: string[] = this.parseUtils.getDebugNonWhiteLineParts(debugStatementStr); + this._logDEBUG(' -- rptDbg A lineParts=[' + lineParts + '](' + lineParts.length + ')'); + if (lineParts.length > 0 && lineParts[0].toLowerCase() != 'debug') { //this._logDEBUG(' -- rptDbg first name not debug! (label?) removing! lineParts[0]=[' + lineParts[0] + ']'); lineParts.shift(); // assume pasm, remove label } - if (lineParts[0].toLowerCase() == "debug") { + if (lineParts[0].toLowerCase() == 'debug') { let symbolOffset: number = currentOffset; - const displayType: string = lineParts.length >= 2 ? lineParts[1] : ""; - if (displayType.startsWith("`")) { + const displayType: string = lineParts.length >= 2 ? lineParts[1] : ''; + if (displayType.startsWith('`')) { this._logDEBUG(` -- rptDbg have "debug("\` lineParts=[${lineParts}](${lineParts.length})`); symbolOffset = line.indexOf(displayType, symbolOffset) + 1; // plus 1 to get past back-tic const newDisplayType: string = displayType.substring(1, displayType.length); - let displayTestName: string = lineParts[1] == "`" ? lineParts[1] + lineParts[2] : lineParts[1]; - displayTestName = displayTestName.toLowerCase().replace(/ \t/g, ""); - const isRuntimeNamed: boolean = displayTestName.startsWith("``") || displayTestName.startsWith("`zstr") || displayTestName.startsWith("`lstr"); - this._logDEBUG(" -- rptDbg displayTestName=[" + displayTestName + "], isRuntimeNamed=" + isRuntimeNamed); - let bHaveInstantiation = this.parseUtils.isDebugDisplayType(newDisplayType) && !isRuntimeNamed; + let displayTestName: string = lineParts[1] == '`' ? lineParts[1] + lineParts[2] : lineParts[1]; + displayTestName = displayTestName.toLowerCase().replace(/ \t/g, ''); + const isRuntimeNamed: boolean = + displayTestName.startsWith('``') || displayTestName.startsWith('`zstr') || displayTestName.startsWith('`lstr'); + this._logDEBUG(' -- rptDbg displayTestName=[' + displayTestName + '], isRuntimeNamed=' + isRuntimeNamed); + const bHaveInstantiation = this.parseUtils.isDebugDisplayType(newDisplayType) && !isRuntimeNamed; if (bHaveInstantiation) { - this._logDEBUG(" -- rptDbg --- PROCESSING Instantiation"); + this._logDEBUG(' -- rptDbg --- PROCESSING Instantiation'); // ------------------------------------- // process Debug() display instantiation // ** debug(`{displayType} {displayName} ......) // (0a) register type use - this._logDEBUG(" -- rptDbg newDisplayType=[" + newDisplayType + "]"); + this._logDEBUG(' -- rptDbg newDisplayType=[' + newDisplayType + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newDisplayType.length, - ptTokenType: "displayType", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'displayType', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); // (0b) register userName use symbolOffset += displayType.length; const newDisplayName: string = lineParts[2]; symbolOffset = line.indexOf(newDisplayName, symbolOffset); - this._logDEBUG(" -- rptDbg newDisplayName=[" + newDisplayName + "]"); + this._logDEBUG(' -- rptDbg newDisplayName=[' + newDisplayName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newDisplayName.length, - ptTokenType: "displayName", - ptTokenModifiers: ["declaration"], + ptTokenType: 'displayName', + ptTokenModifiers: ['declaration'] }); symbolOffset += newDisplayName.length; // (1) highlight parameter names - let eDisplayType: eDebugDisplayType = this.semanticFindings.getDebugDisplayEnumForType(newDisplayType); + const eDisplayType: eDebugDisplayType = this.semanticFindings.getDebugDisplayEnumForType(newDisplayType); const firstParamIdx: number = 3; // [0]=debug [1]=`{type}, [2]={userName} for (let idx = firstParamIdx; idx < lineParts.length; idx++) { const newParameter: string = lineParts[idx]; symbolOffset = line.indexOf(newParameter, symbolOffset); const bIsParameterName: boolean = this.parseUtils.isNameWithTypeInstantiation(newParameter, eDisplayType); if (bIsParameterName) { - this._logDEBUG(" -- rptDbg newParam=[" + newParameter + "]"); + this._logDEBUG(' -- rptDbg newParam=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { const bIsColorName: boolean = this.parseUtils.isDebugColorName(newParameter); if (bIsColorName) { - this._logDEBUG(" -- rptDbg newColor=[" + newParameter + "]"); + this._logDEBUG(' -- rptDbg newColor=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, - ptTokenType: "colorName", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'colorName', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { // unknown parameter, is known symbol? let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.hasLocalPAsmTokenForMethod(this.currentMethodName, newParameter)) { referenceDetails = this.semanticFindings.getLocalPAsmTokenForMethod(this.currentMethodName, newParameter); - this._logPASM(" -- FOUND local PASM name=[" + newParameter + "]"); + this._logPASM(' -- FOUND local PASM name=[' + newParameter + ']'); } else if (this.semanticFindings.isLocalToken(newParameter)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(newParameter, lineNbr); - this._logPASM(" -- FOUND local name=[" + newParameter + "]"); + this._logPASM(' -- FOUND local name=[' + newParameter + ']'); } else if (this.semanticFindings.isGlobalToken(newParameter)) { referenceDetails = this.semanticFindings.getGlobalToken(newParameter); - this._logPASM(" -- FOUND global name=[" + newParameter + "]"); + this._logPASM(' -- FOUND global name=[' + newParameter + ']'); } if (referenceDetails != undefined) { - this._logPASM(" -- SPIN/PAsm add name=[" + newParameter + "]"); + this._logPASM(' -- SPIN/PAsm add name=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // handle unknown-name case @@ -6232,22 +6881,28 @@ export class Spin2DocumentSemanticParser { if ( paramIsSymbolName && !this.parseUtils.isDebugMethod(newParameter) && - newParameter.indexOf("`") == -1 && + newParameter.indexOf('`') == -1 && !this.parseUtils.isUnaryOperator(newParameter) && !this.parseUtils.isBinaryOperator(newParameter) && !this.parseUtils.isFloatConversion(newParameter) && !this.parseUtils.isSpinBuiltinMethod(newParameter) && !this.parseUtils.isBuiltinStreamerReservedWord(newParameter) ) { - this._logDEBUG(" -- rptDbg 1 unkParam=[" + newParameter + "]"); + this._logDEBUG(' -- rptDbg 1 unkParam=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, symbolOffset, symbolOffset + newParameter.length, eSeverity.Error, `P2 Spin debug() A unknown name [${newParameter}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + symbolOffset, + symbolOffset + newParameter.length, + eSeverity.Error, + `P2 Spin debug() A unknown name [${newParameter}]` + ); } } } @@ -6278,21 +6933,21 @@ export class Spin2DocumentSemanticParser { // handle 1st display here let firstParamIdx: number = 0; // value NOT used if (bHaveFeed) { - this._logDEBUG(" -- rptDbg --- PROCESSING feed"); + this._logDEBUG(' -- rptDbg --- PROCESSING feed'); if (isRuntimeNamed) { - firstParamIdx = displayName == "`" || displayName == "``" ? 2 : 1; // [0]=`debug` [1]=`runtimeName, [2]... symbols + firstParamIdx = displayName == '`' || displayName == '``' ? 2 : 1; // [0]=`debug` [1]=`runtimeName, [2]... symbols } else { firstParamIdx = 1; // [0]=debug [1]=`{userName}[[, {userName}], ...] // handle one or more names! do { // (0) register UserName use - this._logDEBUG(" -- rptDbg displayName=[" + displayName + "]"); + this._logDEBUG(' -- rptDbg displayName=[' + displayName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: displayName.length, - ptTokenType: "displayName", - ptTokenModifiers: ["reference"], + ptTokenType: 'displayName', + ptTokenModifiers: ['reference'] }); symbolOffset += displayName.length + 1; if (firstParamIdx < lineParts.length) { @@ -6310,63 +6965,63 @@ export class Spin2DocumentSemanticParser { // override bad display type with directive if present eDisplayType = this._getDisplayTypeForLine(lineNbr); } - let newParameter: string = ""; + let newParameter: string = ''; for (let idx = firstParamIdx; idx < lineParts.length; idx++) { newParameter = lineParts[idx]; if (newParameter.indexOf("'") != -1 || this.parseUtils.isStorageType(newParameter)) { symbolOffset += newParameter.length; continue; // skip this name (it's part of a string!) - } else if (newParameter.indexOf("#") != -1) { + } else if (newParameter.indexOf('#') != -1) { symbolOffset += newParameter.length; continue; // skip this name (it's part of a string!) } symbolOffset = line.indexOf(newParameter, symbolOffset); - this._logDEBUG(" -- rptDbg ?check? [" + newParameter + "] symbolOffset=" + symbolOffset); + this._logDEBUG(' -- rptDbg ?check? [' + newParameter + '] symbolOffset=' + symbolOffset); let bIsParameterName: boolean = this.parseUtils.isNameWithTypeFeed(newParameter, eDisplayType); - if (isRuntimeNamed && newParameter.toLowerCase() == "lutcolors") { + if (isRuntimeNamed && newParameter.toLowerCase() == 'lutcolors') { bIsParameterName = true; } if (bIsParameterName) { - this._logDEBUG(" -- rptDbg newParam=[" + newParameter + "]"); + this._logDEBUG(' -- rptDbg newParam=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, - ptTokenType: "feedParameter", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'feedParameter', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { const bIsColorName: boolean = this.parseUtils.isDebugColorName(newParameter); if (bIsColorName) { - this._logDEBUG(" -- rptDbg newColor=[" + newParameter + "]"); + this._logDEBUG(' -- rptDbg newColor=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, - ptTokenType: "colorName", - ptTokenModifiers: ["reference", "defaultLibrary"], + ptTokenType: 'colorName', + ptTokenModifiers: ['reference', 'defaultLibrary'] }); } else { // unknown parameter, is known symbol? let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.hasLocalPAsmTokenForMethod(this.currentMethodName, newParameter)) { referenceDetails = this.semanticFindings.getLocalPAsmTokenForMethod(this.currentMethodName, newParameter); - this._logPASM(" -- FOUND local PASM name=[" + newParameter + "]"); + this._logPASM(' -- FOUND local PASM name=[' + newParameter + ']'); } else if (this.semanticFindings.isLocalToken(newParameter)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(newParameter, lineNbr); - this._logPASM(" -- FOUND local name=[" + newParameter + "]"); + this._logPASM(' -- FOUND local name=[' + newParameter + ']'); } else if (this.semanticFindings.isGlobalToken(newParameter)) { referenceDetails = this.semanticFindings.getGlobalToken(newParameter); - this._logPASM(" -- FOUND global name=[" + newParameter + "]"); + this._logPASM(' -- FOUND global name=[' + newParameter + ']'); } if (referenceDetails != undefined) { - this._logPASM(" -- SPIN PAsm add name=[" + newParameter + "]"); + this._logPASM(' -- SPIN PAsm add name=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, // <-- this offset is bad! length: newParameter.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // handle unknown-name case @@ -6374,7 +7029,7 @@ export class Spin2DocumentSemanticParser { if ( paramIsSymbolName && this.parseUtils.isDebugMethod(newParameter) == false && - newParameter.indexOf("`") == -1 && + newParameter.indexOf('`') == -1 && !this.parseUtils.isUnaryOperator(newParameter) && !this.parseUtils.isBinaryOperator(newParameter) && !this.parseUtils.isFloatConversion(newParameter) && @@ -6382,15 +7037,21 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isSpinReservedWord(newParameter) && !this.parseUtils.isBuiltinStreamerReservedWord(newParameter) ) { - this._logDEBUG(" -- rptDbg 2 unkParam=[" + newParameter + "]"); // XYZZY LutColors + this._logDEBUG(' -- rptDbg 2 unkParam=[' + newParameter + ']'); // XYZZY LutColors this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, symbolOffset, symbolOffset + newParameter.length, eSeverity.Error, `P2 Spin debug() B unknown name [${newParameter}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + symbolOffset, + symbolOffset + newParameter.length, + eSeverity.Error, + `P2 Spin debug() B unknown name [${newParameter}]` + ); } } } @@ -6406,19 +7067,19 @@ export class Spin2DocumentSemanticParser { } } } else { - this._logDEBUG(" -- rptDbg --- PROCESSING non-display (other)"); + this._logDEBUG(' -- rptDbg --- PROCESSING non-display (other)'); // ------------------------------------- // process non-display debug statement const firstParamIdx: number = 0; // no prefix to skip let symbolOffset: number = currentOffset; - let newParameter: string = ""; + let newParameter: string = ''; for (let idx = firstParamIdx; idx < lineParts.length; idx++) { newParameter = lineParts[idx]; const paramIsSymbolName: boolean = newParameter.charAt(0).match(/[a-zA-Z_]/) ? true : false; if (!paramIsSymbolName) { continue; } - if (newParameter.toLowerCase() == "debug" || this.parseUtils.isStorageType(newParameter)) { + if (newParameter.toLowerCase() == 'debug' || this.parseUtils.isStorageType(newParameter)) { continue; } symbolOffset = line.indexOf(newParameter, symbolOffset); // walk this past each @@ -6429,21 +7090,21 @@ export class Spin2DocumentSemanticParser { bHaveObjReference = this._reportObjectReference(newParameter, lineIdx, startingOffset, line, tokenSet); } if (!bHaveObjReference) { - this._logDEBUG(" -- ?check? [" + newParameter + "]"); - if (newParameter.endsWith(".")) { + this._logDEBUG(' -- ?check? [' + newParameter + ']'); + if (newParameter.endsWith('.')) { newParameter = newParameter.substring(0, newParameter.length - 1); } let referenceDetails: RememberedToken | undefined = undefined; if (this.semanticFindings.hasLocalPAsmTokenForMethod(this.currentMethodName, newParameter)) { referenceDetails = this.semanticFindings.getLocalPAsmTokenForMethod(this.currentMethodName, newParameter); - this._logPASM(" -- FOUND local PASM name=[" + newParameter + "]"); + this._logPASM(' -- FOUND local PASM name=[' + newParameter + ']'); } else if (this.semanticFindings.isLocalToken(newParameter)) { referenceDetails = this.semanticFindings.getLocalTokenForLine(newParameter, lineNbr); - this._logPASM(" -- FOUND local name=[" + newParameter + "]"); + this._logPASM(' -- FOUND local name=[' + newParameter + ']'); } else if (this.semanticFindings.isGlobalToken(newParameter)) { referenceDetails = this.semanticFindings.getGlobalToken(newParameter); - this._logPASM(" -- FOUND global name=[" + newParameter + "]"); + this._logPASM(' -- FOUND global name=[' + newParameter + ']'); } if (referenceDetails != undefined) { //this._logPASM(' -- Debug() colorize name=[' + newParameter + ']'); @@ -6452,7 +7113,7 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolOffset, length: newParameter.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // handle unknown-name case @@ -6467,15 +7128,21 @@ export class Spin2DocumentSemanticParser { !this.parseUtils.isSpinBuiltInVariable(newParameter) && !this.parseUtils.isSpinReservedWord(newParameter) ) { - this._logDEBUG(" -- rptDbg 3 unkParam=[" + newParameter + "]"); + this._logDEBUG(' -- rptDbg 3 unkParam=[' + newParameter + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: newParameter.length, - ptTokenType: "setupParameter", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'setupParameter', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, symbolOffset, symbolOffset + newParameter.length, eSeverity.Error, `P2 Spin debug() C unknown name [${newParameter}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + symbolOffset, + symbolOffset + newParameter.length, + eSeverity.Error, + `P2 Spin debug() C unknown name [${newParameter}]` + ); } } } @@ -6489,7 +7156,7 @@ export class Spin2DocumentSemanticParser { }); } } else { - this._logDEBUG("ERROR: _reportDebugStatement() Ln#" + (lineIdx + 1) + " line=[" + line + "] no debug()??"); + this._logDEBUG('ERROR: _reportDebugStatement() Ln#' + (lineIdx + 1) + ' line=[' + line + '] no debug()??'); } return tokenSet; } @@ -6501,15 +7168,18 @@ export class Spin2DocumentSemanticParser { // NEW adjust dot check to symbol.symbol const dottedSymbolRegex = /[a-zA-Z0-9_]\.[a-zA-Z_]/; // sym.sym const dottedIndexedSymbolRegex = /[a-zA-Z0-9_]\]\.[a-zA-Z_]/; // sym#sym - const hashedSymbolRegex = /[a-zA-Z0-9_]\#[a-zA-Z_]/; // sym#sym - const percentSymbolRegex = /[a-zA-Z0-9_]\%[a-zA-Z_]/; // sym#sym + const hashedSymbolRegex = /[a-zA-Z0-9_]#[a-zA-Z_]/; // sym#sym + const percentSymbolRegex = /[a-zA-Z0-9_]%[a-zA-Z_]/; // sym#sym const hasSymbolDotSymbol: boolean = dottedSymbolRegex.test(possibleRef); const hasSymbolHashSymbol: boolean = hashedSymbolRegex.test(possibleRef); const hasPercentHashSymbol: boolean = percentSymbolRegex.test(possibleRef); const hasSymbolDOtIndexedSymbol: boolean = dottedIndexedSymbolRegex.test(possibleRef); const possibleRefLC: string = possibleRef.toLowerCase(); - const isPartialVariableAccess: boolean = possibleRefLC.includes(".byte[") || possibleRefLC.includes(".word[") || possibleRefLC.includes(".long["); - const refFoundStatus: boolean = !possibleRef.startsWith(".") && !isPartialVariableAccess && (hasSymbolDOtIndexedSymbol || hasSymbolDotSymbol || hasSymbolHashSymbol || hasPercentHashSymbol); + const isPartialVariableAccess: boolean = possibleRefLC.includes('.byte[') || possibleRefLC.includes('.word[') || possibleRefLC.includes('.long['); + const refFoundStatus: boolean = + !possibleRef.startsWith('.') && + !isPartialVariableAccess && + (hasSymbolDOtIndexedSymbol || hasSymbolDotSymbol || hasSymbolHashSymbol || hasPercentHashSymbol); this._logMessage(` -- isObjRef() possibleRef=[${possibleRef}] -> (${refFoundStatus})`); return refFoundStatus; } @@ -6525,19 +7195,19 @@ export class Spin2DocumentSemanticParser { if (line && line != null && line.length > 0) { const lineNbr: number = lineIdx + 1; let possibleNameSet: string[] = []; - const isP1ObjectConstantRef: boolean = dotReference.includes("#"); - const isP2ObjectOverrideConstantRef: boolean = dotReference.includes("%"); - if ((dotReference.includes(".") || dotReference.includes("#") || dotReference.includes("%")) && !dotReference.includes("..")) { + const isP1ObjectConstantRef: boolean = dotReference.includes('#'); + const isP2ObjectOverrideConstantRef: boolean = dotReference.includes('%'); + if ((dotReference.includes('.') || dotReference.includes('#') || dotReference.includes('%')) && !dotReference.includes('..')) { this._logMessage(` -- rObjRef dotReference=[${dotReference}]`); const symbolOffset: number = line.indexOf(dotReference, startingOffset); // walk this past each - possibleNameSet = dotReference.split(/[\.\#\%]/).filter(Boolean); + possibleNameSet = dotReference.split(/[.#%]/).filter(Boolean); let objInstanceName = possibleNameSet[0]; const dotLHS: string = objInstanceName; this._logMessage(` -- rObjRef possibleNameSet=[${possibleNameSet}](${possibleNameSet.length})`); let nameParts: string[] = [objInstanceName]; let indexNames: string | undefined = undefined; - if (objInstanceName.includes("[")) { - nameParts = objInstanceName.split(/[\[\]]/).filter(Boolean); + if (objInstanceName.includes('[')) { + nameParts = objInstanceName.split(/[[\]]/).filter(Boolean); objInstanceName = nameParts[0]; // FIXME: handle nameParts[1] is likely a local file variable if (nameParts.length > 1) { @@ -6549,9 +7219,9 @@ export class Spin2DocumentSemanticParser { } if (indexNames) { // handle case: instance[index].reference[()] - "index" value - let currentOffset: number = startingOffset; + const currentOffset: number = startingOffset; const namePart = indexNames; - let nameOffset = line.indexOf(namePart, startingOffset); + const nameOffset = line.indexOf(namePart, startingOffset); this._logMessage(` -- rObjRef-Idx searchString=[${namePart}]`); this._logMessage(` -- rObjRef-Idx nameOffset=(${nameOffset}), currentOffset=(${currentOffset})`); let referenceDetails: RememberedToken | undefined = undefined; @@ -6569,7 +7239,7 @@ export class Spin2DocumentSemanticParser { startCharacter: nameOffset, length: namePart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } else { // have unknown name!? what is it? @@ -6578,10 +7248,16 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: nameOffset, length: namePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); - this.semanticFindings.pushDiagnosticMessage(lineIdx, nameOffset, nameOffset + namePart.length, eSeverity.Error, `P2 Spin failed to parse index value [${namePart}]`); + this.semanticFindings.pushDiagnosticMessage( + lineIdx, + nameOffset, + nameOffset + namePart.length, + eSeverity.Error, + `P2 Spin failed to parse index value [${namePart}]` + ); } } // processed objectInstance name and [indexName], now do ref part @@ -6600,17 +7276,17 @@ export class Spin2DocumentSemanticParser { startCharacter: symbolOffset, length: objInstanceName.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: referenceDetails.modifiers, + ptTokenModifiers: referenceDetails.modifiers }); } if (possibleNameSet.length > 1) { // we have .constant namespace suffix // determine if this is method has '(' or is constant name - const refParts = possibleNameSet[1].split(/[\(\)]/).filter(Boolean); + const refParts = possibleNameSet[1].split(/[()]/).filter(Boolean); const refPart = refParts[0]; const referenceOffset = line.indexOf(refPart, symbolOffset + dotLHS.length + 1); let isMethod: boolean = false; - if (line.substr(referenceOffset + refPart.length, 1) == "(") { + if (line.substr(referenceOffset + refPart.length, 1) == '(') { isMethod = true; } @@ -6622,26 +7298,26 @@ export class Spin2DocumentSemanticParser { } if (referenceDetails) { const constantPart: string = possibleNameSet[1]; - const tokenModifiers: string[] = isMethod ? [] : ["readonly"]; - this._logMessage(" -- rObjRef rhs constant=[" + constantPart + "](" + (referenceOffset + 1) + ") (" + referenceDetails.type + ")"); + const tokenModifiers: string[] = isMethod ? [] : ['readonly']; + this._logMessage(' -- rObjRef rhs constant=[' + constantPart + '](' + (referenceOffset + 1) + ') (' + referenceDetails.type + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: referenceOffset, length: refPart.length, ptTokenType: referenceDetails.type, - ptTokenModifiers: tokenModifiers, + ptTokenModifiers: tokenModifiers }); } else { - this._logMessage(" -- rObjRef Error refPart=[" + refPart + "](" + (referenceOffset + 1) + ")"); + this._logMessage(' -- rObjRef Error refPart=[' + refPart + '](' + (referenceOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: referenceOffset, length: refPart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); if (!isP1ObjectConstantRef) { - const refType: string = isMethod ? "Method" : "Constant"; + const refType: string = isMethod ? 'Method' : 'Constant'; const adjustedName: string = isMethod ? `${refPart}()` : refPart; this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -6652,7 +7328,7 @@ export class Spin2DocumentSemanticParser { ); } else { // have old style P1 Constant ref - const refType: string = "Constant Reference"; + const refType: string = 'Constant Reference'; const adjustedName: string = `#${refPart}`; this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -6682,23 +7358,23 @@ export class Spin2DocumentSemanticParser { bGeneratedReference = true; const referenceOffset = line.indexOf(referencePart, symbolOffset + objInstanceName.length + 1); let isMethod: boolean = false; - if (line.substr(referenceOffset + referencePart.length, 1) == "(") { + if (line.substr(referenceOffset + referencePart.length, 1) == '(') { isMethod = true; } let nameParts: string[] = [objInstanceName]; - if (objInstanceName.includes("[")) { - nameParts = objInstanceName.split(/[\[\]]/).filter(Boolean); + if (objInstanceName.includes('[')) { + nameParts = objInstanceName.split(/[[\]]/).filter(Boolean); objInstanceName = nameParts[0]; // FIXME: handle nameParts[1] is likely a local file variable } - this._logDAT(" -- rObjRef MISSING instance declaration=[" + objInstanceName + "]"); + this._logDAT(' -- rObjRef MISSING instance declaration=[' + objInstanceName + ']'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: symbolOffset, length: objInstanceName.length, - ptTokenType: "variable", - ptTokenModifiers: ["missingDeclaration"], + ptTokenType: 'variable', + ptTokenModifiers: ['missingDeclaration'] }); this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -6708,16 +7384,16 @@ export class Spin2DocumentSemanticParser { `P2 Spin Missing object instance declaration [${objInstanceName}]` ); // and handle refenced object - this._logMessage(" -- rObjRef Error refPart=[" + referencePart + "](" + (referenceOffset + 1) + ")"); + this._logMessage(' -- rObjRef Error refPart=[' + referencePart + '](' + (referenceOffset + 1) + ')'); this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: referenceOffset, length: referencePart.length, - ptTokenType: "variable", - ptTokenModifiers: ["illegalUse"], + ptTokenType: 'variable', + ptTokenModifiers: ['illegalUse'] }); if (!isP1ObjectConstantRef) { - const refType: string = isMethod ? "Method" : "Constant"; + const refType: string = isMethod ? 'Method' : 'Constant'; const adjustedName: string = isMethod ? `${referencePart}()` : referencePart; this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -6728,7 +7404,7 @@ export class Spin2DocumentSemanticParser { ); } else { // have old style P1 Constant ref - const refType: string = "Constant Reference"; + const refType: string = 'Constant Reference'; const adjustedName: string = `#${referencePart}`; this.semanticFindings.pushDiagnosticMessage( lineIdx, @@ -6753,7 +7429,7 @@ export class Spin2DocumentSemanticParser { for (let index = 0; index < multiLineSet.numberLines; index++) { const lnOffset: number = index == 0 ? startingOffset : 0; const line = multiLineSet.lineAt(index).substring(lnOffset); - let tokenStringSet: IParsedToken[] = this._reportDebugDblQuoteStrings(multiLineSet.lineStartIdx + index, line, line); + const tokenStringSet: IParsedToken[] = this._reportDebugDblQuoteStrings(multiLineSet.lineStartIdx + index, line, line); if (tokenStringSet.length > 0) { for (let index = 0; index < tokenStringSet.length; index++) { const token = tokenStringSet[index]; @@ -6791,13 +7467,13 @@ export class Spin2DocumentSemanticParser { // find all strings in debug() statement but for now just do first... let currentOffset: number = line.indexOf(debugStatementStr); let nextStringOffset: number = 0; - let nextString: string = ""; + let nextString: string = ''; do { nextString = this._getSingleQuotedString(nextStringOffset, debugStatementStr); if (nextString.length > 0) { nextStringOffset = debugStatementStr.indexOf(nextString, nextStringOffset); - const chrBackTic: string = "`"; - const chrCloseParen: string = ")"; + const chrBackTic: string = '`'; + const chrCloseParen: string = ')'; const bStringContainssBackTic: boolean = nextString.indexOf(chrBackTic) != -1; if (bStringContainssBackTic) { // add special handling for '`()' this case @@ -6823,8 +7499,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: lineStrOffset, length: currStr.length, - ptTokenType: "string", - ptTokenModifiers: ["quoted", "single"], + ptTokenType: 'string', + ptTokenModifiers: ['quoted', 'single'] }); currStrOffset += currStr.length; lineStrOffset += currStr.length; @@ -6847,13 +7523,13 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: lineStrOffset, length: rightStr.length, - ptTokenType: "string", - ptTokenModifiers: ["quoted", "single"], + ptTokenType: 'string', + ptTokenModifiers: ['quoted', 'single'] }); searchOffset = closeParenOffset + currStr.length + 1; } } else { - this._logDEBUG(" -- rdsqs ERROR missing close paren!"); + this._logDEBUG(' -- rdsqs ERROR missing close paren!'); break; // no close paren? get outta here... } } @@ -6864,8 +7540,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: strOffset, length: nextString.length, - ptTokenType: "string", - ptTokenModifiers: ["quoted", "single"], + ptTokenType: 'string', + ptTokenModifiers: ['quoted', 'single'] }); } currentOffset += nextString.length + 1; @@ -6881,19 +7557,19 @@ export class Spin2DocumentSemanticParser { // find all strings in debug() statement but for now just do first... let currentOffset: number = line.indexOf(debugStatementStr); let nextStringOffset: number = 0; - let nextString: string = ""; + let nextString: string = ''; do { nextString = this._getDoubleQuotedString(nextStringOffset, debugStatementStr); if (nextString.length > 0) { nextStringOffset = debugStatementStr.indexOf(nextString, nextStringOffset); - const chrBackTic: string = "`"; + const chrBackTic: string = '`'; const bStringContainssBackTic: boolean = nextString.indexOf(chrBackTic) != -1; if (bStringContainssBackTic) { // add special handling for '`()' this case //this._logMessage('- BackTic nextString=[' + nextString + '] line=[' + line + ']'); - const chrCloseParen: string = ")"; + const chrCloseParen: string = ')'; let searchOffset: number = 0; // value doesn't matter - let lineStrOffset: number = line.indexOf(nextString, currentOffset); + const lineStrOffset: number = line.indexOf(nextString, currentOffset); let backTicOffset: number = 0; // value doesn't matter while ((backTicOffset = nextString.indexOf(chrBackTic, searchOffset)) != -1) { const leftStr = nextString.substring(0, backTicOffset); @@ -6902,8 +7578,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: lineStrOffset, length: leftStr.length, - ptTokenType: "string", - ptTokenModifiers: ["quoted", "double"], + ptTokenType: 'string', + ptTokenModifiers: ['quoted', 'double'] }); //this._logMessage(' -- leftStr=[' + leftStr + '] lineStrOffset=[' + lineStrOffset + ']'); const closeParenOffset: number = nextString.indexOf(chrCloseParen, backTicOffset); @@ -6913,16 +7589,16 @@ export class Spin2DocumentSemanticParser { const nextBackTicOffset: number = nextString.indexOf(chrBackTic, searchOffset); const currStrEndOffset: number = nextBackTicOffset != -1 ? nextBackTicOffset - 1 : nextString.length - 1; const rightStr = nextString.substring(closeParenOffset + 1, currStrEndOffset + 1); - let rightStrOffset: number = lineStrOffset + closeParenOffset + 1; - const leftOffset: number = closeParenOffset + 1; + const rightStrOffset: number = lineStrOffset + closeParenOffset + 1; + //const leftOffset: number = closeParenOffset + 1; //this._logMessage(' -- rightStr=(' + rightStrOffset + ')[' + rightStr + '] leftOffset=[' + leftOffset + '] currStrEndOffset=[' + currStrEndOffset + ']'); // record the right edge string this._recordToken(tokenSet, line, { line: lineIdx, startCharacter: rightStrOffset, length: rightStr.length, - ptTokenType: "string", - ptTokenModifiers: ["quoted", "double"], + ptTokenType: 'string', + ptTokenModifiers: ['quoted', 'double'] }); searchOffset = closeParenOffset + leftStr.length + 1; } else { @@ -6936,8 +7612,8 @@ export class Spin2DocumentSemanticParser { line: lineIdx, startCharacter: strOffset, length: nextString.length, - ptTokenType: "string", - ptTokenModifiers: ["quoted", "double"], + ptTokenType: 'string', + ptTokenModifiers: ['quoted', 'double'] }); } currentOffset += nextString.length + 1; @@ -6949,34 +7625,34 @@ export class Spin2DocumentSemanticParser { } private _getDoubleQuotedString(currentOffset: number, searchText: string): string { - let nextString: string = ""; + let nextString: string = ''; const chrDoubleQuote: string = '"'; const stringStartOffset: number = searchText.indexOf(chrDoubleQuote, currentOffset); if (stringStartOffset != -1) { - this._logDEBUG(" -- _getDoubleQuotedString(" + currentOffset + ", [" + searchText + "])"); + this._logDEBUG(' -- _getDoubleQuotedString(' + currentOffset + ', [' + searchText + '])'); const stringEndOffset: number = searchText.indexOf(chrDoubleQuote, stringStartOffset + 1); if (stringEndOffset != -1) { nextString = searchText.substring(stringStartOffset, stringEndOffset + 1); } } if (nextString.length > 0) { - this._logDEBUG(" -- debug() gdqs nextString=[" + nextString + "](" + nextString.length + ")"); + this._logDEBUG(' -- debug() gdqs nextString=[' + nextString + '](' + nextString.length + ')'); } return nextString; } private _getSingleQuotedString(currentOffset: number, searchText: string): string { - let nextString: string = ""; + let nextString: string = ''; const stringStartOffset: number = searchText.indexOf("'", currentOffset); if (stringStartOffset != -1) { - this._logDEBUG(" -- gsqs(" + currentOffset + ", [" + searchText + "])"); + this._logDEBUG(' -- gsqs(' + currentOffset + ', [' + searchText + '])'); const stringEndOffset: number = searchText.indexOf("'", stringStartOffset + 1); if (stringEndOffset != -1) { nextString = searchText.substring(stringStartOffset, stringEndOffset + 1); } } if (nextString.length > 0) { - this._logDEBUG(" -- debug() gsqs nextString=[" + nextString + "](" + nextString.length + ")"); + this._logDEBUG(' -- debug() gsqs nextString=[' + nextString + '](' + nextString.length + ')'); } return nextString; } @@ -6986,7 +7662,9 @@ export class Spin2DocumentSemanticParser { if (newToken.line != -1 && newToken.startCharacter != -1) { tokenSet.push(newToken); } else { - const tokenInterp: string = `token(${newToken.line + 1},${newToken.startCharacter})=[len:${newToken.length}](${newToken.ptTokenType}[${newToken.ptTokenModifiers}])]`; + const tokenInterp: string = `token(${newToken.line + 1},${newToken.startCharacter})=[len:${newToken.length}](${newToken.ptTokenType}[${ + newToken.ptTokenModifiers + }])]`; this._logMessage(`** ERROR: BAD token nextString=[${tokenInterp}]`); } } @@ -6997,29 +7675,31 @@ export class Spin2DocumentSemanticParser { const newDirective: ISpin2Directive = { lineNumber: lineIdx, displayType: displayType, - eDisplayType: this.semanticFindings.getDebugDisplayEnumForType(displayType), + eDisplayType: this.semanticFindings.getDebugDisplayEnumForType(displayType) }; - this._logMessage("=> Add DIRECTIVE: " + this._directiveString(newDirective)); + this._logMessage('=> Add DIRECTIVE: ' + this._directiveString(newDirective)); this.fileDirectives.push(newDirective); } private _getDisplayTypeForLine(lineNbr: number): eDebugDisplayType { let desiredType: eDebugDisplayType = eDebugDisplayType.Unknown; let maxLineBefore: number = 0; - let desiredDirective: ISpin2Directive; + //let desiredDirective: ISpin2Directive; for (let index = 0; index < this.fileDirectives.length; index++) { const currDirective: ISpin2Directive = this.fileDirectives[index]; - this._logMessage(" -- hunt Ln#" + lineNbr + ", ln=" + currDirective.lineNumber + ", typ=" + currDirective.displayType + "(" + currDirective.eDisplayType + ")"); + this._logMessage( + ' -- hunt Ln#' + lineNbr + ', ln=' + currDirective.lineNumber + ', typ=' + currDirective.displayType + '(' + currDirective.eDisplayType + ')' + ); if (currDirective.lineNumber <= lineNbr) { if (currDirective.lineNumber > maxLineBefore) { - desiredDirective = currDirective; + //desiredDirective = currDirective; desiredType = currDirective.eDisplayType; maxLineBefore = currDirective.lineNumber; } } } if (desiredType != eDebugDisplayType.Unknown) { - this._logMessage(" -- directive for Ln#" + lineNbr + ": " + desiredType); + this._logMessage(' -- directive for Ln#' + lineNbr + ': ' + desiredType); } return desiredType; } @@ -7092,13 +7772,13 @@ export class Spin2DocumentSemanticParser { } private _getDebugStatement(startingOffset: number, line: string): string { - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); let debugNonCommentStr: string = line; - let openParenOffset: number = line.indexOf("(", currentOffset); - let closeParenOffset: number = this.parseUtils.indexOfMatchingCloseParen(line, openParenOffset); + const openParenOffset: number = line.indexOf('(', currentOffset); + const closeParenOffset: number = this.parseUtils.indexOfMatchingCloseParen(line, openParenOffset); if (line.length - startingOffset > 0 && openParenOffset != -1 && closeParenOffset != -1) { // have scope of debug line - remove trailing comment, trim it and return it - let commentOffset: number = line.indexOf("'", closeParenOffset + 1); + const commentOffset: number = line.indexOf("'", closeParenOffset + 1); if (commentOffset != -1) { // have trailing comment remove it const nonCommentEOL: number = commentOffset != -1 ? commentOffset - 1 : line.length - 1; @@ -7108,7 +7788,7 @@ export class Spin2DocumentSemanticParser { } } else if (line.length - startingOffset == 0 || openParenOffset == -1) { // if we don't have open paren - erase entire line - debugNonCommentStr = ""; + debugNonCommentStr = ''; } //if (line.length != debugNonCommentStr.length) { // this._logMessage(' -- DS line [' + line.substring(startingOffset) + ']'); @@ -7119,7 +7799,7 @@ export class Spin2DocumentSemanticParser { private _getNonCommentLineReturnComment(startingOffset: number, lineIdx: number, line: string, tokenSet: IParsedToken[]): string { // skip Past Whitespace - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); this._logMessage(` -- Ln#${lineIdx + 1} gNCL-RC startingOffset=(${startingOffset}), line=[${line}](${line.length})`); const nonCommentStr: string = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); // now record the comment if we have one @@ -7129,11 +7809,21 @@ export class Spin2DocumentSemanticParser { this._logMessage(` -- gNCL-RC filtLine=[${filtLine}](${filtLine.length})`); const commentRHSStrOffset: number = nonCommentStr.length; const commentOffset: number = this.parseUtils.getTrailingCommentOffset(commentRHSStrOffset, line); - const bHaveBlockComment: boolean = filtLine.indexOf("{", commentOffset) != -1 || filtLine.indexOf("}", commentOffset) != -1; - const bHaveDocComment: boolean = filtLine.indexOf("''", commentOffset) != -1 || filtLine.indexOf("{{", commentOffset) != -1 || filtLine.indexOf("}}", commentOffset) != -1; - this._logMessage(` -- gNCL-RC commentOffset=(${commentOffset}), bHvBlockComment=(${bHaveBlockComment}), bHvDocComment=(${bHaveDocComment}), filtLine=[${filtLine}](${filtLine.length})`); + const bHaveBlockComment: boolean = filtLine.indexOf('{', commentOffset) != -1 || filtLine.indexOf('}', commentOffset) != -1; + const bHaveDocComment: boolean = + filtLine.indexOf("''", commentOffset) != -1 || filtLine.indexOf('{{', commentOffset) != -1 || filtLine.indexOf('}}', commentOffset) != -1; + this._logMessage( + ` -- gNCL-RC commentOffset=(${commentOffset}), bHvBlockComment=(${bHaveBlockComment}), bHvDocComment=(${bHaveDocComment}), filtLine=[${filtLine}](${filtLine.length})` + ); if (commentOffset != -1) { - const newToken: IParsedToken | undefined = this._generateComentToken(lineIdx, commentOffset, line.length - commentOffset + 1, bHaveBlockComment, bHaveDocComment, line); + const newToken: IParsedToken | undefined = this._generateComentToken( + lineIdx, + commentOffset, + line.length - commentOffset + 1, + bHaveBlockComment, + bHaveDocComment, + line + ); if (newToken) { //this._logMessage("=> CMT: " + this._tokenString(newToken, line)); tokenSet.push(newToken); @@ -7146,22 +7836,33 @@ export class Spin2DocumentSemanticParser { return nonCommentStr; } - private _generateComentToken(lineIdx: number, startIdx: number, commentLength: number, bHaveBlockComment: boolean, bHaveDocComment: boolean, line: string): IParsedToken | undefined { + private _generateComentToken( + lineIdx: number, + startIdx: number, + commentLength: number, + bHaveBlockComment: boolean, + bHaveDocComment: boolean, + line: string + ): IParsedToken | undefined { //this._logMessage(" -- gNCL-RC commentOffset=(" + commentOffset + "), bHaveDocComment=[" + bHaveDocComment + "], line=[" + line + "]"); let desiredToken: IParsedToken | undefined = undefined; if (line.length > 0) { //const commentDocModifiers: string[] = bHaveBlockComment ? ["block", "documentation"] : ["line", "documentation"]; // A NO - const commentDocModifiers: string[] = bHaveBlockComment ? ["documentation", "block"] : ["documentation", "line"]; // B NO - const commentModifiers: string[] = bHaveBlockComment ? ["block"] : ["line"]; + const commentDocModifiers: string[] = bHaveBlockComment ? ['documentation', 'block'] : ['documentation', 'line']; // B NO + const commentModifiers: string[] = bHaveBlockComment ? ['block'] : ['line']; desiredToken = { line: lineIdx, startCharacter: startIdx, length: commentLength, - ptTokenType: "comment", - ptTokenModifiers: bHaveDocComment ? commentDocModifiers : commentModifiers, + ptTokenType: 'comment', + ptTokenModifiers: bHaveDocComment ? commentDocModifiers : commentModifiers }; const comment: string = line.substring(startIdx, startIdx + commentLength); - this._logMessage(` -- Ln#${lineIdx + 1} genCT Recorded Comment [${comment}](${comment.length}) (${desiredToken.ptTokenType}[${desiredToken.ptTokenModifiers}])`); + this._logMessage( + ` -- Ln#${lineIdx + 1} genCT Recorded Comment [${comment}](${comment.length}) (${desiredToken.ptTokenType}[${ + desiredToken.ptTokenModifiers + }])` + ); } return desiredToken; } @@ -7170,19 +7871,19 @@ export class Spin2DocumentSemanticParser { // split(/[ \t\-\:\,\+\[\]\@\(\)\!\*\=\<\>\&\|\?\\\~\#\^\/]/); // mods to allow returning of objInstanceName#constant form of names const nonEqualsLine: string = this.parseUtils.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\-\:\,\+\[\]\@\(\)\!\*\=\<\>\&\|\?\\\~\^\/]+/g); + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\-:,+[\]@()!*=<>&|?\\~^/]+/g); let reducedLineParts: string[] = []; if (lineParts == null) { reducedLineParts = []; } else { for (let index = 0; index < lineParts.length; index++) { const name = lineParts[index]; - if (name === "#") { + if (name === '#') { continue; } - if (name.startsWith("#")) { + if (name.startsWith('#')) { reducedLineParts.push(name.substring(1)); // remvoe first char - } else if (name.endsWith("#")) { + } else if (name.endsWith('#')) { reducedLineParts.push(name.slice(0, -1)); // remove last char } else { reducedLineParts.push(name); @@ -7191,7 +7892,7 @@ export class Spin2DocumentSemanticParser { } return { lineNoQuotes: nonEqualsLine, - lineParts: reducedLineParts, + lineParts: reducedLineParts }; } @@ -7203,7 +7904,7 @@ export class Spin2DocumentSemanticParser { // in second pass, if item dosn't have period but does have [...] then split a [] and push parts // const nonEqualsLine: string = this.parseUtils.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\-\:\,\+\@\(\)\!\*\=\<\>\&\|\?\\\~\^\/]+/g); + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\-:,+@()!*=<>&|?\\~^/]+/g); this._logMessage(` -- gnwsplna line=[${line}](${line.length})`); const partsLen: number = lineParts == null ? 0 : lineParts.length; this._logMessage(` --- gnwsplna lineParts=[${lineParts}](${partsLen})`); @@ -7213,18 +7914,18 @@ export class Spin2DocumentSemanticParser { } else { for (let index = 0; index < lineParts.length; index++) { const name = lineParts[index]; - if (name === "#" || name === "[") { + if (name === '#' || name === '[') { continue; } let tempName: string = name; - if (name.startsWith("#")) { + if (name.startsWith('#')) { tempName = name.substring(1); // remvoe first char - } else if (name.endsWith("#")) { + } else if (name.endsWith('#')) { tempName = name.slice(0, -1); // remove last char } ///now... - if (!tempName.includes(".") && (tempName.includes("[") || tempName.includes("]"))) { - const moreParts: string[] = tempName.split(/[\[\]]/).filter(Boolean); + if (!tempName.includes('.') && (tempName.includes('[') || tempName.includes(']'))) { + const moreParts: string[] = tempName.split(/[[\]]/).filter(Boolean); for (let index = 0; index < moreParts.length; index++) { const namePart = moreParts[index]; reducedLineParts.push(namePart); @@ -7237,7 +7938,7 @@ export class Spin2DocumentSemanticParser { this._logMessage(` --- gnwsplna reducedLineParts=[${reducedLineParts}](${reducedLineParts.length})`); return { lineNoQuotes: nonEqualsLine, - lineParts: reducedLineParts, + lineParts: reducedLineParts }; } @@ -7267,32 +7968,45 @@ export class Spin2DocumentSemanticParser { } private _tokenString(aToken: IParsedToken, line: string): string { - let varName: string = line.substr(aToken.startCharacter, aToken.length); - let desiredInterp: string = - " -- token=[Ln#" + (aToken.line + 1) + ",ofs:" + aToken.startCharacter + ",len:" + aToken.length + " [" + varName + "](" + aToken.ptTokenType + "[" + aToken.ptTokenModifiers + "])]"; + const varName: string = line.substr(aToken.startCharacter, aToken.length); + const desiredInterp: string = + ' -- token=[Ln#' + + (aToken.line + 1) + + ',ofs:' + + aToken.startCharacter + + ',len:' + + aToken.length + + ' [' + + varName + + '](' + + aToken.ptTokenType + + '[' + + aToken.ptTokenModifiers + + '])]'; return desiredInterp; } private _rememberdTokenString(tokenName: string, aToken: RememberedToken | undefined): string { - let desiredInterp: string = " -- token=[len:" + tokenName.length + " [" + tokenName + "](undefined)"; + let desiredInterp: string = ' -- token=[len:' + tokenName.length + ' [' + tokenName + '](undefined)'; if (aToken != undefined) { - desiredInterp = " -- token=[len:" + tokenName.length + " [" + tokenName + "](" + aToken.type + "[" + aToken.modifiers + "])]"; + desiredInterp = ' -- token=[len:' + tokenName.length + ' [' + tokenName + '](' + aToken.type + '[' + aToken.modifiers + '])]'; } return desiredInterp; } private _checkTokenSet(tokenSet: IParsedToken[]): void { - this._logMessage("\n---- Checking " + tokenSet.length + " tokens. ----"); + this._logMessage('\n---- Checking ' + tokenSet.length + ' tokens. ----'); tokenSet.forEach((parsedToken) => { if (parsedToken.length == undefined || parsedToken.startCharacter == undefined) { - this._logMessage("- BAD Token=[" + parsedToken + "]"); + this._logMessage('- BAD Token=[' + parsedToken + ']'); } }); - this._logMessage("---- Check DONE ----\n"); + this._logMessage('---- Check DONE ----\n'); } private _directiveString(aDirective: ISpin2Directive): string { - let desiredInterp: string = " -- directive=[Ln#" + aDirective.lineNumber + ",typ:" + aDirective.displayType + "[" + aDirective.eDisplayType + "])]"; + const desiredInterp: string = + ' -- directive=[Ln#' + aDirective.lineNumber + ',typ:' + aDirective.displayType + '[' + aDirective.eDisplayType + '])]'; return desiredInterp; } } diff --git a/spin2/server/src/parser/spin2.documentSymbolParser.ts b/spin2/server/src/parser/spin2.documentSymbolParser.ts index e47e44f..ced50ad 100644 --- a/spin2/server/src/parser/spin2.documentSymbolParser.ts +++ b/spin2/server/src/parser/spin2.documentSymbolParser.ts @@ -1,12 +1,12 @@ -"use strict"; +'use strict'; // src/spin2.outline.ts -import * as lsp from "vscode-languageserver"; -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Spin2ParseUtils } from "./spin2.utils"; -import { OutLineSymbol, DocumentFindings } from "./spin.semantic.findings"; -import { Context } from "../context"; -import { eParseState } from "./spin.common"; +import * as lsp from 'vscode-languageserver'; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Spin2ParseUtils } from './spin2.utils'; +import { OutLineSymbol, DocumentFindings } from './spin.semantic.findings'; +import { Context } from '../context'; +import { eParseState } from './spin.common'; // ---------------------------------------------------------------------------- // OUTLINE Provider @@ -27,9 +27,9 @@ export class Spin2DocumentSymbolParser { if (this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin2 Outline log started."); + this._logMessage('Spin2 Outline log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -44,10 +44,16 @@ export class Spin2DocumentSymbolParser { } for (let i = 0; i < document.lineCount; i++) { - const desiredLineRange: lsp.Range = { start: { line: i, character: 0 }, end: { line: i, character: Number.MAX_VALUE } }; + const desiredLineRange: lsp.Range = { + start: { line: i, character: 0 }, + end: { line: i, character: Number.MAX_VALUE } + }; //let line = document.lineAt(i); - const line = document.getText(desiredLineRange).replace(/\s+$/, ""); - const lineRange: lsp.Range = { start: { line: i, character: 0 }, end: { line: i, character: line.length - 1 } }; + const line = document.getText(desiredLineRange).replace(/\s+$/, ''); + const lineRange: lsp.Range = { + start: { line: i, character: 0 }, + end: { line: i, character: line.length - 1 } + }; const trimmedLine = line.trim(); let nonCommentLine = this.parseUtils.getRemainderWOutTrailingTicComment(0, line); if (nonCommentLine.length == 0) { @@ -72,9 +78,9 @@ export class Spin2DocumentSymbolParser { // skip all {{ --- }} multi-line doc comments if (currState == eParseState.inMultiLineDocComment) { // in multi-line doc-comment, hunt for end '}}' to exit - const openingOffset = nonCommentLine.indexOf("{{"); + const openingOffset = nonCommentLine.indexOf('{{'); const searchOffset: number = openingOffset != -1 ? openingOffset + 2 : 0; - const closingOffset = nonCommentLine.indexOf("}}", searchOffset); + const closingOffset = nonCommentLine.indexOf('}}', searchOffset); const haveInlineCmt: boolean = openingOffset != -1 && closingOffset != -1 && openingOffset < closingOffset; if (!haveInlineCmt && closingOffset != -1) { // have close, comment ended @@ -84,15 +90,15 @@ export class Spin2DocumentSymbolParser { continue; } else if (currState == eParseState.inMultiLineComment) { // in multi-line non-doc-comment, hunt for end '}' to exit - const openingOffset = nonCommentLine.indexOf("{"); - const closingOffset = nonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = nonCommentLine.indexOf('{'); + const closingOffset = nonCommentLine.indexOf('}', openingOffset + 1); const haveInlineCmt: boolean = openingOffset != -1 && closingOffset != -1 && openingOffset < closingOffset; if (!haveInlineCmt && closingOffset != -1) { // have close, comment ended currState = priorState; } // no more processing for this line - const cmtState: string = currState != eParseState.inMultiLineComment ? "LAST " : ""; + const cmtState: string = currState != eParseState.inMultiLineComment ? 'LAST ' : ''; this._logMessage(`* SKIP ${cmtState}BlockCmt Ln#${i + 1} nonCommentLine=[${nonCommentLine}]`); continue; } else if (nonCommentLine.startsWith("''")) { @@ -101,11 +107,11 @@ export class Spin2DocumentSymbolParser { } else if (nonCommentLine.startsWith("'")) { // no more processing for this line continue; - } else if (nonCommentLine.trim().startsWith("{{")) { + } else if (nonCommentLine.trim().startsWith('{{')) { // process multi-line doc comment - const openingOffset = nonCommentLine.indexOf("{{"); + const openingOffset = nonCommentLine.indexOf('{{'); const searchOffset: number = openingOffset != -1 ? openingOffset + 2 : 0; - const closingOffset = nonCommentLine.indexOf("}}", searchOffset); + const closingOffset = nonCommentLine.indexOf('}}', searchOffset); if (closingOffset != -1) { // is single line comment, just ignore it } else { @@ -115,11 +121,11 @@ export class Spin2DocumentSymbolParser { // no more processing for this line } continue; - } else if (nonCommentLine.trim().startsWith("{")) { + } else if (nonCommentLine.trim().startsWith('{')) { // process possible multi-line non-doc comment // do we have a close on this same line? - const openingOffset = nonCommentLine.indexOf("{"); - const closingOffset = nonCommentLine.indexOf("}", openingOffset + 1); + const openingOffset = nonCommentLine.indexOf('{'); + const closingOffset = nonCommentLine.indexOf('}', openingOffset + 1); if (closingOffset == -1) { // is open of multiline comment priorState = currState; @@ -135,15 +141,15 @@ export class Spin2DocumentSymbolParser { } if (line.length > 2) { - const lineParts: string[] = linePrefix.split(/[ \t\{]/).filter(Boolean); - linePrefix = lineParts.length > 0 ? lineParts[0].toUpperCase() : ""; + const lineParts: string[] = linePrefix.split(/[ \t{]/).filter(Boolean); + linePrefix = lineParts.length > 0 ? lineParts[0].toUpperCase() : ''; // the only form of comment we care about here is block comment after section name (e.g., "CON { text }") // NEW and let's add the use of ' comment too - const openBraceOffset: number = line.indexOf("{"); + const openBraceOffset: number = line.indexOf('{'); const singleQuoteOffset: number = line.indexOf("'"); if (openBraceOffset != -1) { commentOffset = openBraceOffset; - const closeBraceOffset: number = line.indexOf("}", openBraceOffset + 1); + const closeBraceOffset: number = line.indexOf('}', openBraceOffset + 1); if (closeBraceOffset != -1) { lineHasComment = true; commentLength = closeBraceOffset - openBraceOffset + 1; @@ -156,11 +162,11 @@ export class Spin2DocumentSymbolParser { } if (sectionStatus.isSectionStart) { - if (linePrefix == "PUB" || linePrefix == "PRI") { + if (linePrefix == 'PUB' || linePrefix == 'PRI') { // start PUB/PRI - let methodScope: string = "Public"; - if (line.startsWith("PRI")) { - methodScope = "Private"; + let methodScope: string = 'Public'; + if (line.startsWith('PRI')) { + methodScope = 'Private'; } let methodName: string = line.substr(3).trim(); if (methodName.includes("'")) { @@ -168,33 +174,33 @@ export class Spin2DocumentSymbolParser { const lineParts: string[] = methodName.split("'"); methodName = lineParts[0].trim(); } - if (methodName.includes("{")) { + if (methodName.includes('{')) { // remove brace-wrapped-comment - const lineParts: string[] = methodName.split("{"); + const lineParts: string[] = methodName.split('{'); methodName = lineParts[0].trim(); } - if (methodName.includes("|")) { + if (methodName.includes('|')) { // remove local vars - const lineParts: string[] = methodName.split("|"); + const lineParts: string[] = methodName.split('|'); methodName = lineParts[0].trim(); } // NOTE this changed to METHOD when we added global labels which are to be Functions! - const methodSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + " " + methodName, methodScope, lsp.SymbolKind.Method, lineRange); + const methodSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + ' ' + methodName, methodScope, lsp.SymbolKind.Method, lineRange); this.setContainerSymbol(methodSymbol); } else { // start CON/VAR/OBJ/DAT - let sectionComment = lineHasComment ? line.substr(commentOffset, commentLength) : ""; - const blockSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + " " + sectionComment, "", lsp.SymbolKind.Field, lineRange); + const sectionComment = lineHasComment ? line.substr(commentOffset, commentLength) : ''; + const blockSymbol: OutLineSymbol = new OutLineSymbol(linePrefix + ' ' + sectionComment, '', lsp.SymbolKind.Field, lineRange); this.setContainerSymbol(blockSymbol); // HANDLE label declaration on DAT line! - if (linePrefix == "DAT") { + if (linePrefix == 'DAT') { const lineParts: string[] = nonCommentLine.split(/[ \t]/).filter(Boolean); let posssibleLabel: string | undefined = undefined; if (lineParts.length >= 2) { // possibly have label, report it if we do posssibleLabel = lineParts[1]; if ( - posssibleLabel.toUpperCase().startsWith("ORG") || + posssibleLabel.toUpperCase().startsWith('ORG') || this.parseUtils.isP2AsmEffect(posssibleLabel) || this.parseUtils.isP2AsmInstruction(posssibleLabel) || this.parseUtils.isP2AsmReservedWord(posssibleLabel) @@ -204,7 +210,7 @@ export class Spin2DocumentSymbolParser { posssibleLabel = undefined; // Nope! } if (posssibleLabel) { - const labelSymbol: OutLineSymbol = new OutLineSymbol(lineParts[1], "", lsp.SymbolKind.Constant, lineRange); + const labelSymbol: OutLineSymbol = new OutLineSymbol(lineParts[1], '', lsp.SymbolKind.Constant, lineRange); if (this.containerDocSymbol) { this.containerDocSymbol.addChild(labelSymbol); } @@ -220,11 +226,11 @@ export class Spin2DocumentSymbolParser { if (currState == eParseState.inPAsmInline) { // process pasm (assembly) lines if (trimmedLine.length > 0) { - this._logMessage(" scan inPAsmInline Ln#" + (i + 1) + " nonCommentLine=[" + nonCommentLine + "]"); + this._logMessage(' scan inPAsmInline Ln#' + (i + 1) + ' nonCommentLine=[' + nonCommentLine + ']'); const lineParts: string[] = nonCommentLine.split(/[ \t]/).filter(Boolean); - if (lineParts.length > 0 && lineParts[0].toUpperCase() == "END") { + if (lineParts.length > 0 && lineParts[0].toUpperCase() == 'END') { currState = prePasmState; - this._logMessage(" scan END-InLine Ln#" + (i + 1) + " POP currState=[" + currState + "]"); + this._logMessage(' scan END-InLine Ln#' + (i + 1) + ' POP currState=[' + currState + ']'); // and ignore rest of this line continue; } @@ -234,20 +240,20 @@ export class Spin2DocumentSymbolParser { } else if (currState == eParseState.inDatPAsm) { // process pasm (assembly) lines if (trimmedLine.length > 0) { - this._logMessage(" scan inDatPAsm Ln#" + (i + 1) + " nonCommentLine=[" + nonCommentLine + "]"); + this._logMessage(' scan inDatPAsm Ln#' + (i + 1) + ' nonCommentLine=[' + nonCommentLine + ']'); // didn't leave this state check for new global label global_label = this._getOlnDAT_PasmDeclaration(0, line); // let's get possible label on this ORG statement } } else if (currState == eParseState.inDat) { - this._logMessage(" scan inDat Ln#" + (i + 1) + " nonCommentLine=[" + nonCommentLine + "]"); - if (nonCommentLine.length > 6 && nonCommentLine.toUpperCase().includes("ORG")) { + this._logMessage(' scan inDat Ln#' + (i + 1) + ' nonCommentLine=[' + nonCommentLine + ']'); + if (nonCommentLine.length > 6 && nonCommentLine.toUpperCase().includes('ORG')) { // ORG, ORGF, ORGH const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(nonCommentLine); - if (nonStringLine.toUpperCase().includes("ORG")) { - this._logMessage(" - pre-scan DAT line trimmedLine=[" + trimmedLine + "] now Dat PASM"); + if (nonStringLine.toUpperCase().includes('ORG')) { + this._logMessage(' - pre-scan DAT line trimmedLine=[' + trimmedLine + '] now Dat PASM'); prePasmState = currState; currState = eParseState.inDatPAsm; - this._logMessage(" scan START DATPasm Ln#" + (i + 1) + " PUSH currState=[" + prePasmState + "]"); + this._logMessage(' scan START DATPasm Ln#' + (i + 1) + ' PUSH currState=[' + prePasmState + ']'); // and ignore rest of this line global_label = this._getOlnDAT_PasmDeclaration(0, line); // let's get possible label on this ORG statement } @@ -258,14 +264,14 @@ export class Spin2DocumentSymbolParser { // Detect start of INLINE PASM - org detect // NOTE: The directives ORGH, ALIGNW, ALIGNL, and FILE are not allowed within in-line PASM code. if (trimmedLine.length > 0) { - this._logMessage(" scan inPub/inPri Ln#" + (i + 1) + " nonCommentLine=[" + nonCommentLine + "]"); + this._logMessage(' scan inPub/inPri Ln#' + (i + 1) + ' nonCommentLine=[' + nonCommentLine + ']'); const lineParts: string[] = nonCommentLine.split(/[ \t]/).filter(Boolean); - if (lineParts.length > 0 && (lineParts[0].toUpperCase() == "ORG" || lineParts[0].toUpperCase() == "ORGF")) { + if (lineParts.length > 0 && (lineParts[0].toUpperCase() == 'ORG' || lineParts[0].toUpperCase() == 'ORGF')) { // Only ORG, not ORGF or ORGH - this._logMessage(" - (" + (i + 1) + "): outline PUB/PRI line trimmedLine=[" + trimmedLine + "]"); + this._logMessage(' - (' + (i + 1) + '): outline PUB/PRI line trimmedLine=[' + trimmedLine + ']'); prePasmState = currState; currState = eParseState.inPAsmInline; - this._logMessage(" scan START-InLine Ln#" + (i + 1) + " PUSH currState=[" + prePasmState + "]"); + this._logMessage(' scan START-InLine Ln#' + (i + 1) + ' PUSH currState=[' + prePasmState + ']'); // and ignore rest of this line continue; } @@ -274,7 +280,7 @@ export class Spin2DocumentSymbolParser { if (global_label) { // was Variable: sorta OK (image good, color bad) // was Constant: sorta OK (image good, color bad) SAME - const labelSymbol: OutLineSymbol = new OutLineSymbol(global_label, "", lsp.SymbolKind.Constant, lineRange); + const labelSymbol: OutLineSymbol = new OutLineSymbol(global_label, '', lsp.SymbolKind.Constant, lineRange); // if we have a container add to container, else just record it if (this.containerDocSymbol) { this.containerDocSymbol.addChild(labelSymbol); @@ -320,17 +326,17 @@ export class Spin2DocumentSymbolParser { if (lineParts.length > 0) { const sectionName: string = lineParts[0].toUpperCase(); startStatus = true; - if (sectionName === "CON") { + if (sectionName === 'CON') { inProgressState = eParseState.inCon; - } else if (sectionName === "DAT") { + } else if (sectionName === 'DAT') { inProgressState = eParseState.inDat; - } else if (sectionName === "OBJ") { + } else if (sectionName === 'OBJ') { inProgressState = eParseState.inObj; - } else if (sectionName === "PUB") { + } else if (sectionName === 'PUB') { inProgressState = eParseState.inPub; - } else if (sectionName === "PRI") { + } else if (sectionName === 'PRI') { inProgressState = eParseState.inPri; - } else if (sectionName === "VAR") { + } else if (sectionName === 'VAR') { inProgressState = eParseState.inVar; } else { startStatus = false; @@ -338,11 +344,11 @@ export class Spin2DocumentSymbolParser { } } if (startStatus) { - this._logMessage("** isSectStart line=[" + line + "], enum(" + inProgressState + ")"); + this._logMessage('** isSectStart line=[' + line + '], enum(' + inProgressState + ')'); } return { isSectionStart: startStatus, - inProgressStatus: inProgressState, + inProgressStatus: inProgressState }; } @@ -351,31 +357,32 @@ export class Spin2DocumentSymbolParser { // didShow byte FALSE[256] // byte FALSE[256] let newGlobalLabel: string | undefined = undefined; - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const dataDeclNonCommentStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); - let lineParts: string[] = this.parseUtils.getNonWhiteNParenLineParts(dataDeclNonCommentStr); - this._logMessage("- OLn GetDatDecl lineParts=[" + lineParts + "](" + lineParts.length + ")"); - let haveMoreThanDat: boolean = lineParts.length > 1 && lineParts[0].toUpperCase() == "DAT"; - if (haveMoreThanDat || (lineParts.length > 0 && lineParts[0].toUpperCase() != "DAT")) { + const lineParts: string[] = this.parseUtils.getNonWhiteNParenLineParts(dataDeclNonCommentStr); + this._logMessage('- OLn GetDatDecl lineParts=[' + lineParts + '](' + lineParts.length + ')'); + const haveMoreThanDat: boolean = lineParts.length > 1 && lineParts[0].toUpperCase() == 'DAT'; + if (haveMoreThanDat || (lineParts.length > 0 && lineParts[0].toUpperCase() != 'DAT')) { // remember this object name so we can annotate a call to it let nameIndex: number = 0; let typeIndex: number = 1; let maxParts: number = 2; - if (lineParts[0].toUpperCase() == "DAT") { + if (lineParts[0].toUpperCase() == 'DAT') { nameIndex = 1; typeIndex = 2; maxParts = 3; } - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[nameIndex]); - const isDataDeclarationLine: boolean = lineParts.length > maxParts - 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[typeIndex]) ? true : false; - let lblFlag: string = haveLabel ? "T" : "F"; - let dataDeclFlag: string = isDataDeclarationLine ? "T" : "F"; - this._logMessage("- OLn GetDatDecl lineParts=[" + lineParts + "](" + lineParts.length + ") label=" + lblFlag + ", daDecl=" + dataDeclFlag); + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[nameIndex]); + const isDataDeclarationLine: boolean = + lineParts.length > maxParts - 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[typeIndex]) ? true : false; + const lblFlag: string = haveLabel ? 'T' : 'F'; + const dataDeclFlag: string = isDataDeclarationLine ? 'T' : 'F'; + this._logMessage('- OLn GetDatDecl lineParts=[' + lineParts + '](' + lineParts.length + ') label=' + lblFlag + ', daDecl=' + dataDeclFlag); if (haveLabel) { - let newName = lineParts[nameIndex]; + const newName = lineParts[nameIndex]; if ( - !newName.toLowerCase().startsWith("debug") && + !newName.toLowerCase().startsWith('debug') && !this.parseUtils.isP2AsmReservedWord(newName) && !this.parseUtils.isSpinBuiltInVariable(newName) && !this.parseUtils.isSpinReservedWord(newName) && @@ -385,10 +392,10 @@ export class Spin2DocumentSymbolParser { !this.parseUtils.isP1AsmVariable(newName) && !this.parseUtils.isBadP1AsmEffectOrConditional(newName) ) { - if (!isDataDeclarationLine && !newName.startsWith(".") && !newName.startsWith(":") && !newName.includes("#")) { + if (!isDataDeclarationLine && !newName.startsWith('.') && !newName.startsWith(':') && !newName.includes('#')) { newGlobalLabel = newName; } - this._logMessage(" -- OLn GLBL gddcl newName=[" + newGlobalLabel + "]"); + this._logMessage(' -- OLn GLBL gddcl newName=[' + newGlobalLabel + ']'); } } } @@ -399,26 +406,26 @@ export class Spin2DocumentSymbolParser { // HAVE bGammaEnable BYTE TRUE ' comment // didShow byte FALSE[256] let newGlobalLabel: string | undefined = undefined; - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const datPasmRHSStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); if (datPasmRHSStr.length > 0) { const lineParts: string[] = this.parseUtils.getNonWhiteNParenLineParts(datPasmRHSStr); - this._logMessage("- Oln GetDatPasmDecl lineParts=[" + lineParts + "](" + lineParts.length + ")"); + this._logMessage('- Oln GetDatPasmDecl lineParts=[' + lineParts + '](' + lineParts.length + ')'); // handle name in 1 column - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(lineParts[0]); const isDataDeclarationLine: boolean = lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1]) ? true : false; - if (haveLabel && !isDataDeclarationLine && !lineParts[0].startsWith(".") && !lineParts[0].startsWith(":") && !lineParts[0].includes("#")) { + if (haveLabel && !isDataDeclarationLine && !lineParts[0].startsWith('.') && !lineParts[0].startsWith(':') && !lineParts[0].includes('#')) { const labelName: string = lineParts[0]; if ( !this.parseUtils.isP2AsmReservedSymbols(labelName) && - !labelName.toUpperCase().startsWith("IF_") && - !labelName.toUpperCase().startsWith("_RET_") && - !labelName.toUpperCase().startsWith("DEBUG") + !labelName.toUpperCase().startsWith('IF_') && + !labelName.toUpperCase().startsWith('_RET_') && + !labelName.toUpperCase().startsWith('DEBUG') ) { // org in first column is not label name, nor is if_ conditional newGlobalLabel = labelName; - this._logMessage(" -- Oln GetDatPasmDecl GLBL newGlobalLabel=[" + newGlobalLabel + "]"); + this._logMessage(' -- Oln GetDatPasmDecl GLBL newGlobalLabel=[' + newGlobalLabel + ']'); } } } @@ -429,18 +436,25 @@ export class Spin2DocumentSymbolParser { // HAVE next8SLine ' or .nextLine in col 0 // nPhysLineIdx long 0 let newGlobalLabel: string | undefined = undefined; - let currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); + const currentOffset: number = this.parseUtils.skipWhite(line, startingOffset); // get line parts - we only care about first one const inLinePasmRHSStr = this.parseUtils.getNonCommentLineRemainder(currentOffset, line); const lineParts: string[] = this.parseUtils.getNonWhiteNParenLineParts(inLinePasmRHSStr); //this._logPASM('- GetInLinePasmDecl lineParts=[' + lineParts + ']'); // handle name in 1 column const labelName: string = lineParts[0]; - let haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(labelName); + const haveLabel: boolean = this.parseUtils.isDatOrPAsmLabel(labelName); const isDataDeclarationLine: boolean = lineParts.length > 1 && haveLabel && this.parseUtils.isDatStorageType(lineParts[1]) ? true : false; - if (haveLabel && !isDataDeclarationLine && !labelName.startsWith(".") && !labelName.startsWith(":") && !labelName.toLowerCase().startsWith("debug") && !labelName.includes("#")) { + if ( + haveLabel && + !isDataDeclarationLine && + !labelName.startsWith('.') && + !labelName.startsWith(':') && + !labelName.toLowerCase().startsWith('debug') && + !labelName.includes('#') + ) { newGlobalLabel = labelName; - this._logMessage(" -- Inline PASM newGlobalLabel=[" + newGlobalLabel + "]"); + this._logMessage(' -- Inline PASM newGlobalLabel=[' + newGlobalLabel + ']'); } return newGlobalLabel; } diff --git a/spin2/server/src/parser/spin2.utils.ts b/spin2/server/src/parser/spin2.utils.ts index 8f57dca..9dc5d17 100644 --- a/spin2/server/src/parser/spin2.utils.ts +++ b/spin2/server/src/parser/spin2.utils.ts @@ -1,19 +1,19 @@ -"use strict"; +'use strict'; // src/spin2.utils.ts -import { eBuiltInType, eDebugDisplayType, IBuiltinDescription } from "./spin.common"; -import { Context } from "../context"; +import { eBuiltInType, eDebugDisplayType, IBuiltinDescription } from './spin.common'; +import { Context } from '../context'; export const displayEnumByTypeName = new Map([ - ["logic", eDebugDisplayType.ddtLogic], - ["scope", eDebugDisplayType.ddtScope], - ["scope_xy", eDebugDisplayType.ddtScopeXY], - ["fft", eDebugDisplayType.ddtFFT], - ["spectro", eDebugDisplayType.ddtSpectro], - ["plot", eDebugDisplayType.ddtPlot], - ["term", eDebugDisplayType.ddtTerm], - ["bitmap", eDebugDisplayType.ddtBitmap], - ["midi", eDebugDisplayType.ddtMidi], + ['logic', eDebugDisplayType.ddtLogic], + ['scope', eDebugDisplayType.ddtScope], + ['scope_xy', eDebugDisplayType.ddtScopeXY], + ['fft', eDebugDisplayType.ddtFFT], + ['spectro', eDebugDisplayType.ddtSpectro], + ['plot', eDebugDisplayType.ddtPlot], + ['term', eDebugDisplayType.ddtTerm], + ['bitmap', eDebugDisplayType.ddtBitmap], + ['midi', eDebugDisplayType.ddtMidi] ]); // this is how we decribe our methods with parameters in our tables... @@ -23,7 +23,7 @@ export enum eSearchFilterType { Unknown = 0, FT_NO_PREFERENCE, FT_METHOD, - FT_NOT_METHOD, + FT_NOT_METHOD } export class Spin2ParseUtils { @@ -70,10 +70,10 @@ export class Spin2ParseUtils { for (let index = 0; index < line.length; index++) { const char = line.charAt(index); switch (char) { - case " ": + case ' ': insetCount++; break; - case "\t": + case '\t': insetCount += tabWidth - (insetCount % tabWidth); break; default: @@ -92,9 +92,9 @@ export class Spin2ParseUtils { let desiredCloseOffset: number = -1; let nestingDepth: number = 1; for (let offset = openParenOffset + 1; offset < line.length; offset++) { - if (line.substring(offset, offset + 1) == "(") { + if (line.substring(offset, offset + 1) == '(') { nestingDepth++; - } else if (line.substring(offset, offset + 1) == ")") { + } else if (line.substring(offset, offset + 1) == ')') { nestingDepth--; if (nestingDepth == 0) { // we closed the inital open @@ -115,16 +115,17 @@ export class Spin2ParseUtils { //this._logMessage(" -- gdnwlp nonDblStringLine=[" + nonDblStringLine + "]"); const nonSglStringLine: string = this.removeDebugSingleQuotedStrings(nonDblStringLine, true); //this._logMessage(" -- gdnwlp nonSglStringLine=[" + nonSglStringLine + "]"); - let lineParts: string[] | null = nonSglStringLine.match(/[^ ,@\[\]\=\+\-\*\/\:\#\<\>\|\^\&\t\(\)\!\?\~\\]+/g); + const lineParts: string[] | null = nonSglStringLine.match(/[^ ,@[\]=+\-*/:#<>|^&\t()!?~\\]+/g); //let lineParts: string[] | null = line.match(/[^ ,@\[\]\+\-\*\/\<\>\t\(\)]+/g); return lineParts == null ? [] : lineParts; } public getCommaDelimitedNonWhiteLineParts(line: string): string[] { - let lineParts: string[] | null = line.match(/[^ \t,]+/g); + const lineParts: string[] | null = line.match(/[^ \t,]+/g); return lineParts == null ? [] : lineParts; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public removeDebugSingleQuotedStrings(line: string, showDebug: boolean = true): string { // remove single-quoted strings from keyword processing // Ex #1: ' a string ' @@ -139,19 +140,18 @@ export class Spin2ParseUtils { //this._logMessage(`- RQS line [${line}]`); let trimmedLine: string = line; const chrSingleQuote: string = "'"; - const chrCloseParen: string = ")"; + const chrCloseParen: string = ')'; // skip past tic-open pairs and their closes let nextTicEscape: number = this._nextTicEscape(trimmedLine, 0); let quoteStartOffset: number = trimmedLine.indexOf(chrSingleQuote, 0); // should we process this line? - let badParse: boolean = false; // while we have tic pairs remove them // if back-tic() operation within don't remove them! - let badElement: string = ""; + let badElement: string = ''; while (quoteStartOffset != -1) { // SKIP past ticEscapes to locate last closing paren - let quoteEndOffset: number = trimmedLine.indexOf(chrSingleQuote, quoteStartOffset + 1); + const quoteEndOffset: number = trimmedLine.indexOf(chrSingleQuote, quoteStartOffset + 1); if (quoteEndOffset == -1) { break; // no more pairs, exit } @@ -172,13 +172,15 @@ export class Spin2ParseUtils { stringNoTicEscape = false; // we need to remove before and after tic escape } } - this._logMessage(` -- RdsQS quoteStartOffset=(${quoteStartOffset}), nextTicEscape=(${nextTicEscape}), quoteEndOffset=(${quoteEndOffset}): stringNoTicEscape=(${stringNoTicEscape})`); + this._logMessage( + ` -- RdsQS quoteStartOffset=(${quoteStartOffset}), nextTicEscape=(${nextTicEscape}), quoteEndOffset=(${quoteEndOffset}): stringNoTicEscape=(${stringNoTicEscape})` + ); if (stringNoTicEscape) { // ---------------------------------------- // have string with no tic escape, remove it // badElement = trimmedLine.substring(quoteStartOffset, quoteEndOffset + 1); - trimmedLine = trimmedLine.replace(badElement, "#".repeat(badElement.length)); + trimmedLine = trimmedLine.replace(badElement, '#'.repeat(badElement.length)); this._logMessage(` -- RdsQS A trimmedLine=[${trimmedLine}](${trimmedLine.length})`); // FIXME: TODO: splice instead of search / replace (will work in face of dupe strings) } else { @@ -187,12 +189,11 @@ export class Spin2ParseUtils { // // remove front badElement = trimmedLine.substring(quoteStartOffset, nextTicEscape); // no +1 leave tic there - trimmedLine = trimmedLine.replace(badElement, "#".repeat(badElement.length)); + trimmedLine = trimmedLine.replace(badElement, '#'.repeat(badElement.length)); this._logMessage(` -- RdsQS B trimmedLine=[${trimmedLine}](${trimmedLine.length})`); let closeParenOffset: number = trimmedLine.indexOf(chrCloseParen, nextTicEscape); if (closeParenOffset == -1) { - badParse = true; this._logMessage(` -- RdsQS FAILED A to locate close paren of \`() clause`); break; } @@ -202,7 +203,7 @@ export class Spin2ParseUtils { while (nextTicEscape != -1 && nextTicEscape < quoteEndOffset) { // yes remove string from `() to `()... badElement = trimmedLine.substring(closeParenOffset + 1, nextTicEscape); - trimmedLine = trimmedLine.replace(badElement, "#".repeat(badElement.length)); + trimmedLine = trimmedLine.replace(badElement, '#'.repeat(badElement.length)); this._logMessage(` -- RdsQS C trimmedLine=[${trimmedLine}](${trimmedLine.length})`); closeParenOffset = trimmedLine.indexOf(chrCloseParen, nextTicEscape); @@ -215,14 +216,13 @@ export class Spin2ParseUtils { } // if our tic-escape loop bailed we need to as well if (closeParenOffset == -1) { - badParse = true; this._logMessage(` -- RdsQS FAILED C to locate close paren of \`() clause`); break; } // ---------------------------------------- // have string from last escape to end quote badElement = trimmedLine.substring(closeParenOffset + 1, quoteEndOffset + 1); - trimmedLine = trimmedLine.replace(badElement, "#".repeat(badElement.length)); + trimmedLine = trimmedLine.replace(badElement, '#'.repeat(badElement.length)); this._logMessage(` -- RdsQS D trimmedLine=[${trimmedLine}](${trimmedLine.length})`); // if we have `( followed by ) then skip this close, look for next @@ -237,10 +237,10 @@ export class Spin2ParseUtils { private _nextTicEscape(line: string, startingOffset: number): number { let nextLocation: number = -1; // start with NOT found - let nextDecimal: number = line.indexOf("`(", startingOffset); - let nextHex: number = line.indexOf("`$(", startingOffset); - let nextBinary: number = line.indexOf("`%(", startingOffset); - let nextCharacter: number = line.indexOf("`#(", startingOffset); + const nextDecimal: number = line.indexOf('`(', startingOffset); + const nextHex: number = line.indexOf('`$(', startingOffset); + const nextBinary: number = line.indexOf('`%(', startingOffset); + const nextCharacter: number = line.indexOf('`#(', startingOffset); if (nextDecimal != -1) { nextLocation = nextDecimal; } @@ -266,24 +266,24 @@ export class Spin2ParseUtils { // NEW remove {comment} and {{comment}} single-line elements too let nonInlineCommentStr: string = line; // TODO: UNDONE make this into loop to find all single line {} or {{}} comments - const startDoubleBraceOffset: number = nonInlineCommentStr.indexOf("{{"); + const startDoubleBraceOffset: number = nonInlineCommentStr.indexOf('{{'); if (startDoubleBraceOffset != -1) { - const endDoubleBraceOffset: number = nonInlineCommentStr.indexOf("}}", startDoubleBraceOffset + 2); + const endDoubleBraceOffset: number = nonInlineCommentStr.indexOf('}}', startDoubleBraceOffset + 2); if (endDoubleBraceOffset != -1) { // remove this comment const badElement = nonInlineCommentStr.substr(startDoubleBraceOffset, endDoubleBraceOffset - startDoubleBraceOffset + 1); //this._logMessage(' -- badElement=[' + badElement + ']'); - nonInlineCommentStr = nonInlineCommentStr.replace(badElement, " ".repeat(badElement.length)); + nonInlineCommentStr = nonInlineCommentStr.replace(badElement, ' '.repeat(badElement.length)); } } - const startSingleBraceOffset: number = nonInlineCommentStr.indexOf("{"); + const startSingleBraceOffset: number = nonInlineCommentStr.indexOf('{'); if (startSingleBraceOffset != -1) { - const endSingleBraceOffset: number = nonInlineCommentStr.indexOf("}", startSingleBraceOffset + 1); + const endSingleBraceOffset: number = nonInlineCommentStr.indexOf('}', startSingleBraceOffset + 1); if (endSingleBraceOffset != -1) { // remove this comment const badElement = nonInlineCommentStr.substr(startSingleBraceOffset, endSingleBraceOffset - startSingleBraceOffset + 1); //this._logMessage(' -- badElement=[' + badElement + ']'); - nonInlineCommentStr = nonInlineCommentStr.replace(badElement, " ".repeat(badElement.length)); + nonInlineCommentStr = nonInlineCommentStr.replace(badElement, ' '.repeat(badElement.length)); } } //if (nonInlineCommentStr.length != line.length) { @@ -303,16 +303,16 @@ export class Spin2ParseUtils { nonDocCommentRHSStr = line.substr(startingOffset, nonCommentEOL - startingOffset + 1).trimEnd(); //this._logMessage('- gNDCLR nonCommentRHSStr=[' + startingOffset + ']'); - const singleBraceBeginOffset: number = nonDocCommentRHSStr.indexOf("{", startingOffset); + const singleBraceBeginOffset: number = nonDocCommentRHSStr.indexOf('{', startingOffset); if (singleBraceBeginOffset != -1) { - const singleBraceEndOffset: number = nonDocCommentRHSStr.indexOf("}", singleBraceBeginOffset); + const singleBraceEndOffset: number = nonDocCommentRHSStr.indexOf('}', singleBraceBeginOffset); if (singleBraceEndOffset != -1) { const inLineComment: string = nonDocCommentRHSStr.substr(singleBraceBeginOffset, singleBraceEndOffset - singleBraceBeginOffset + 1); - nonDocCommentRHSStr = nonDocCommentRHSStr.replace(inLineComment, "").trim(); + nonDocCommentRHSStr = nonDocCommentRHSStr.replace(inLineComment, '').trim(); } } } else if (line.length - startingOffset == 0) { - nonDocCommentRHSStr = ""; + nonDocCommentRHSStr = ''; } //if (line.substr(startingOffset).length != nonCommentRHSStr.length) { // this._logMessage(' -- gNDCLR line [' + line.substr(startingOffset) + ']'); @@ -323,8 +323,8 @@ export class Spin2ParseUtils { public getNonWhiteDataDeclarationLineParts(line: string): string[] { const nonEqualsLine: string = this.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\,\(\)\+\-\/\<\>\|\&\*\^\@]+/g); - let filterParts: string[] = []; + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t,()+\-/<>|&*^@]+/g); + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -339,8 +339,8 @@ export class Spin2ParseUtils { public getNonWhiteDataInitLineParts(line: string): string[] { const nonEqualsLine: string = this.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\,\[\]\(\)\+\-\/\<\>\|\&\*\^\@]+/g); - let filterParts: string[] = []; + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t,[\]()+\-/<>|&*^@]+/g); + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -355,8 +355,8 @@ export class Spin2ParseUtils { public getNonWhiteCONLineParts(line: string): string[] { const nonEqualsLine: string = this.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\(\)\|\?\:\*\+\-\/\>\<\=\&]+/g); - let filterParts: string[] = []; + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t()|?:*+\-/><=&]+/g); + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -371,8 +371,8 @@ export class Spin2ParseUtils { public getNonWhitePAsmLineParts(line: string): string[] { const nonEqualsLine: string = this.removeDoubleQuotedStrings(line); - const lineParts: string[] | null = nonEqualsLine.match(/[^ \t\,\(\)\[\]\<\>\=\?\!\^\+\*\&\|\-\\\#\@\/]+/g); - let filterParts: string[] = []; + const lineParts: string[] | null = nonEqualsLine.match(/[^ \t,()[\]<>=?!^+*&|\-\\#@/]+/g); + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -388,10 +388,10 @@ export class Spin2ParseUtils { public getTrailingCommentOffset(startingOffset: number, line: string): number { let desiredOffset: number = -1; // ensure we have unique { and {{ offsets if possible - const doubleBraceOffset: number = line.indexOf("{{", startingOffset); - let singleBraceOffset: number = line.indexOf("{", startingOffset); + const doubleBraceOffset: number = line.indexOf('{{', startingOffset); + let singleBraceOffset: number = line.indexOf('{', startingOffset); if (doubleBraceOffset != -1 && doubleBraceOffset == singleBraceOffset) { - singleBraceOffset = line.indexOf("{", doubleBraceOffset + 2); + singleBraceOffset = line.indexOf('{', doubleBraceOffset + 2); } const singleTicOffset: number = line.indexOf("'", startingOffset); // now return the earliest of the offsets (or -1 if none found) @@ -420,21 +420,21 @@ export class Spin2ParseUtils { let cleanedLine: string = line; if (!line.trim().startsWith("'")) { - let didReplace: boolean = false; + //let didReplace: boolean = false; // if we have quoted string hide them for now... const startDoubleQuoteOffset: number = cleanedLine.indexOf('"'); - let checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; + const checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; // REPLACE {{...}} when found, all occurrences //do { - const doubleBraceBeginOffset: number = checkLine.indexOf("{{"); + const doubleBraceBeginOffset: number = checkLine.indexOf('{{'); if (doubleBraceBeginOffset != -1) { - const doubleBraceEndOffset: number = checkLine.indexOf("}}", doubleBraceBeginOffset); + const doubleBraceEndOffset: number = checkLine.indexOf('}}', doubleBraceBeginOffset); if (doubleBraceEndOffset != -1) { const inLineComment: string = cleanedLine.substring(doubleBraceBeginOffset, doubleBraceEndOffset + 2); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt {{cmt}} [${cleanedLine}]`); } } @@ -442,20 +442,20 @@ export class Spin2ParseUtils { // REPLACE {...} when found, all occurrences //do { - const singleBraceBeginOffset: number = checkLine.indexOf("{"); + const singleBraceBeginOffset: number = checkLine.indexOf('{'); if (singleBraceBeginOffset != -1) { - const singleBraceEndOffset: number = checkLine.indexOf("}", singleBraceBeginOffset); + const singleBraceEndOffset: number = checkLine.indexOf('}', singleBraceBeginOffset); if (singleBraceEndOffset != -1) { const inLineComment: string = cleanedLine.substring(singleBraceBeginOffset, singleBraceEndOffset + 1); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt {cmt} [${cleanedLine}]`); } } //} while (cleanedLine.indexOf("{") != -1); if (cleanedLine.trim().length == 0) { - cleanedLine = ""; - didReplace = true; + cleanedLine = ''; + //didReplace = true; } //if (didReplace) { @@ -471,12 +471,12 @@ export class Spin2ParseUtils { let cleanedLine: string = line; if (!line.trim().startsWith("'")) { - let didReplace: boolean = false; + //let didReplace: boolean = false; if (startingOffset > 0) { - const prefixToStart: string = " ".repeat(startingOffset); + const prefixToStart: string = ' '.repeat(startingOffset); cleanedLine = `${prefixToStart}${line.substring(startingOffset)}`; - didReplace = true; + //didReplace = true; } // REPLACE {{...}} when found @@ -496,12 +496,12 @@ export class Spin2ParseUtils { let cleanedLine: string = line; if (!line.trim().startsWith("'")) { - let didReplace: boolean = false; + //let didReplace: boolean = false; if (startingOffset > 0) { - const prefixToStart: string = " ".repeat(startingOffset); + const prefixToStart: string = ' '.repeat(startingOffset); cleanedLine = `${prefixToStart}${line.substring(startingOffset)}`; - didReplace = true; + //didReplace = true; } // REPLACE {{...}} when found @@ -510,25 +510,25 @@ export class Spin2ParseUtils { // if we have quoted string hide them for now... const startDoubleQuoteOffset: number = cleanedLine.indexOf('"'); - let checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; + const checkLine: string = startDoubleQuoteOffset != -1 ? this.removeDoubleQuotedStrings(cleanedLine, true) : cleanedLine; // REPLACE ^...}} when NO {{ before it on start of line (unless there's an earlier ' comment) const tickOffset: number = checkLine.indexOf("'", startingOffset); - const doubleBraceEndOffset: number = checkLine.indexOf("}}", startingOffset); + const doubleBraceEndOffset: number = checkLine.indexOf('}}', startingOffset); let isInComment: boolean = doubleBraceEndOffset != -1 && tickOffset != -1 && tickOffset < doubleBraceEndOffset; if (doubleBraceEndOffset != -1 && !isInComment) { const inLineComment: string = cleanedLine.substring(0, doubleBraceEndOffset + 2); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt ^cmt}} [${cleanedLine}]`); } // REPLACE ^...} when NO { before it on start of line (unless there's an earlier ' comment) - const singleBraceEndOffset: number = checkLine.indexOf("}", startingOffset); + const singleBraceEndOffset: number = checkLine.indexOf('}', startingOffset); isInComment = singleBraceEndOffset != -1 && tickOffset != -1 && tickOffset < singleBraceEndOffset; if (singleBraceEndOffset != -1 && !isInComment) { const inLineComment: string = cleanedLine.substring(0, singleBraceEndOffset + 1); - cleanedLine = cleanedLine.replace(inLineComment, " ".repeat(inLineComment.length)); - didReplace = true; + cleanedLine = cleanedLine.replace(inLineComment, ' '.repeat(inLineComment.length)); + //didReplace = true; //this._logMessage(` -- RInCmt ^cmt} [${cleanedLine}]`); } @@ -546,7 +546,7 @@ export class Spin2ParseUtils { // find comment at end of line and remove there to end of line // ( where comment is ' or '' or unpaired {{ or { ) // return 0 len line if trim() removes all after removing/replacing comments - let lineWithoutTrailingCommentStr: string = ""; + let lineWithoutTrailingCommentStr: string = ''; // TODO: UNDONE make this into loop to find first ' not in string if (line.length - startingOffset > 0) { // get line parts - we only care about first one @@ -571,7 +571,7 @@ export class Spin2ParseUtils { lineWithoutTrailingCommentStr = lineWithoutTrailingCommentStr.substring(0, nonCommentEOL).trimEnd(); //this._logMessage('- gnclr lineWithoutTrailingCommentStr=[' + startingOffset + ']'); if (lineWithoutTrailingCommentStr.trim().length == 0) { - lineWithoutTrailingCommentStr = ""; + lineWithoutTrailingCommentStr = ''; //this._logMessage(` -- gRWoTTC line forced to EMPTY`); } //if (line.substr(startingOffset) !== lineWithoutTrailingCommentStr) { @@ -595,7 +595,7 @@ export class Spin2ParseUtils { // find comment at end of line and remove there to end of line // ( where comment is ' or '' or unpaired {{ or { ) // return 0 len line if trim() removes all after removing/replacing comments - let lineWithoutTrailingCommentStr: string = ""; + let lineWithoutTrailingCommentStr: string = ''; // TODO: UNDONE make this into loop to find first ' not in string if (line.length - startingOffset > 0) { // get line parts - we only care about first one @@ -603,7 +603,7 @@ export class Spin2ParseUtils { let beginCommentOffset: number = lineWithoutTrailingCommentStr.indexOf("'"); if (beginCommentOffset != -1) { // have single quote, is it within quoted string? - let currentOffset: number = this.skipWhite(line, startingOffset); + const currentOffset: number = this.skipWhite(line, startingOffset); // if we have quited string hide them for now... const startDoubleQuoteOffset: number = line.indexOf('"', currentOffset); if (startDoubleQuoteOffset != -1) { @@ -621,7 +621,7 @@ export class Spin2ParseUtils { lineWithoutTrailingCommentStr = lineWithoutTrailingCommentStr.substring(0, nonCommentEOL).trimEnd(); //this._logMessage('- gnclr lineWithoutTrailingCommentStr=[' + startingOffset + ']'); if (lineWithoutTrailingCommentStr.trim().length == 0) { - lineWithoutTrailingCommentStr = ""; + lineWithoutTrailingCommentStr = ''; //this._logMessage(` -- gNCLR line forced to EMPTY`); } //if (line.substr(startingOffset) !== lineWithoutTrailingCommentStr) { @@ -634,34 +634,35 @@ export class Spin2ParseUtils { return lineWithoutTrailingCommentStr; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public removeDoubleQuotedStrings(line: string, showDebug: boolean = true): string { //this._logMessage("- RQS line [" + line + "]"); let trimmedLine: string = line; const doubleQuote: string = '"'; let quoteStartOffset: number = 0; // value doesn't matter - let didRemove: boolean = false; + //let didRemove: boolean = false; while ((quoteStartOffset = trimmedLine.indexOf(doubleQuote)) != -1) { const quoteEndOffset: number = trimmedLine.indexOf(doubleQuote, quoteStartOffset + 1); if (quoteEndOffset != -1) { const badElement = trimmedLine.substr(quoteStartOffset, quoteEndOffset - quoteStartOffset + 1); //this._logMessage(' -- badElement=[' + badElement + ']'); - trimmedLine = trimmedLine.replace(badElement, "#".repeat(badElement.length)); - didRemove = showDebug ? true : false; + trimmedLine = trimmedLine.replace(badElement, '#'.repeat(badElement.length)); + //didRemove = showDebug ? true : false; } else { break; // we don't handle a single double-quote } } // NEW also remove {text} strings - const braceStartChar: string = "{"; - const braceEndChar: string = "}"; + const braceStartChar: string = '{'; + const braceEndChar: string = '}'; let braceStartOffset: number = 0; // value doesn't matter while ((braceStartOffset = trimmedLine.indexOf(braceStartChar)) != -1) { const braceEndOffset: number = trimmedLine.indexOf(braceEndChar, braceStartOffset + 1); if (braceEndOffset != -1) { const badElement = trimmedLine.substr(braceStartOffset, braceEndOffset - braceStartOffset + 1); - trimmedLine = trimmedLine.replace(badElement, " ".repeat(badElement.length)); - didRemove = showDebug ? true : false; + trimmedLine = trimmedLine.replace(badElement, ' '.repeat(badElement.length)); + //didRemove = showDebug ? true : false; } else { break; // we don't handle a single brace (of multi-line) } @@ -678,7 +679,7 @@ export class Spin2ParseUtils { public skipWhite(line: string, currentOffset: number): number { let firstNonWhiteIndex: number = currentOffset; for (let index = currentOffset; index < line.length; index++) { - if (line.substr(index, 1) != " " && line.substr(index, 1) != "\t") { + if (line.substr(index, 1) != ' ' && line.substr(index, 1) != '\t') { firstNonWhiteIndex = index; break; } @@ -688,7 +689,7 @@ export class Spin2ParseUtils { public getNonWhiteLineParts(line: string): string[] { const lineParts: string[] | null = line.match(/[^ \t]+/g); - let filterParts: string[] = []; + const filterParts: string[] = []; if (lineParts != null) { for (let index = 0; index < lineParts.length; index++) { const element = lineParts[index]; @@ -701,12 +702,12 @@ export class Spin2ParseUtils { } public getNonWhiteNOperatorLineParts(line: string): string[] { - let lineParts: string[] | null = line.match(/[^ \t\+\<\>]+/g); + const lineParts: string[] | null = line.match(/[^ \t+<>[\]]+/g); return lineParts == null ? [] : lineParts; } public getNonWhiteNParenLineParts(line: string): string[] { - let lineParts: string[] | null = line.match(/[^ \t\()]+/g); + const lineParts: string[] | null = line.match(/[^ \t()]+/g); return lineParts == null ? [] : lineParts; } @@ -714,54 +715,60 @@ export class Spin2ParseUtils { // Built-in SPIN variables P2 // private _tableSpinHubLocations: { [Identifier: string]: string } = { - clkmode: "Clock mode value", - clkfreq: "Clock frequency value", + clkmode: 'Clock mode value', + clkfreq: 'Clock frequency value' }; private _tableSpinHubVariables: { [Identifier: string]: string } = { - varbase: "Object base pointer, @VARBASE is VAR base, used by method-pointer calls", + varbase: 'Object base pointer, @VARBASE is VAR base, used by method-pointer calls' }; private _tableSpinCogRegisters: { [Identifier: string]: string } = { - pr0: "Spin2 <-> PASM communication", - pr1: "Spin2 <-> PASM communication", - pr2: "Spin2 <-> PASM communication", - pr3: "Spin2 <-> PASM communication", - pr4: "Spin2 <-> PASM communication", - pr5: "Spin2 <-> PASM communication", - pr6: "Spin2 <-> PASM communication", - pr7: "Spin2 <-> PASM communication", - ijmp1: "Interrupt JMP 1 (of 3)", - ijmp2: "Interrupt JMP 2 (of 3)", - ijmp3: "Interrupt JMP 3 (of 3)", - iret1: "Interrupt RET 1 (of 3)", - iret2: "Interrupt RET 2 (of 3)", - iret3: "Interrupt RET 3 (of 3)", - pa: "General pointer register A", - pb: "General pointer register B", - ptra: "Data pointer passed from COGINIT", - ptrb: "Code pointer passed from COGINIT", - dira: "Output enables for P31..P0", - dirb: "Output enables for P63..P32", - outa: "Output states for P31..P0", - outb: "Output states for P63..P32", - ina: "Input states from P31..P0", - inb: "Input states from P63..P32", + pr0: 'Spin2 <-> PASM communication', + pr1: 'Spin2 <-> PASM communication', + pr2: 'Spin2 <-> PASM communication', + pr3: 'Spin2 <-> PASM communication', + pr4: 'Spin2 <-> PASM communication', + pr5: 'Spin2 <-> PASM communication', + pr6: 'Spin2 <-> PASM communication', + pr7: 'Spin2 <-> PASM communication', + ijmp1: 'Interrupt JMP 1 (of 3)', + ijmp2: 'Interrupt JMP 2 (of 3)', + ijmp3: 'Interrupt JMP 3 (of 3)', + iret1: 'Interrupt RET 1 (of 3)', + iret2: 'Interrupt RET 2 (of 3)', + iret3: 'Interrupt RET 3 (of 3)', + pa: 'General pointer register A', + pb: 'General pointer register B', + ptra: 'Data pointer passed from COGINIT', + ptrb: 'Code pointer passed from COGINIT', + dira: 'Output enables for P31..P0', + dirb: 'Output enables for P63..P32', + outa: 'Output states for P31..P0', + outb: 'Output states for P63..P32', + ina: 'Input states from P31..P0', + inb: 'Input states from P63..P32' }; private _docTextForSpinBuiltInVariable(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (this.isSpinBuiltInVariable(name)) { desiredDocText.found = true; if (nameKey in this._tableSpinHubLocations) { - desiredDocText.category = "Hub Location"; + desiredDocText.category = 'Hub Location'; desiredDocText.description = this._tableSpinHubLocations[nameKey]; } else if (nameKey in this._tableSpinHubVariables) { - desiredDocText.category = "Hub Variable"; + desiredDocText.category = 'Hub Variable'; desiredDocText.description = this._tableSpinHubVariables[nameKey]; } else if (nameKey in this._tableSpinCogRegisters) { - desiredDocText.category = "Cog Register"; + desiredDocText.category = 'Cog Register'; desiredDocText.description = this._tableSpinCogRegisters[nameKey]; } } @@ -784,32 +791,38 @@ export class Spin2ParseUtils { // Built-in SPIN variables P2 // private _tableSpinBlockNames: { [Identifier: string]: string } = { - con: "32-bit Constant declarations
*(NOTE: CON is the initial/default block type)*", - obj: "Child object instantiations
*(objects manipulated by this object)*", - var: "Object Instance variable declarations", - pub: "Public method for use by the parent object and within this object", - pri: "Private method for use within this object", - dat: "Object Shared variable declarations and/or PASM code", + con: '32-bit Constant declarations
*(NOTE: CON is the initial/default block type)*', + obj: 'Child object instantiations
*(objects manipulated by this object)*', + var: 'Object Instance variable declarations', + pub: 'Public method for use by the parent object and within this object', + pri: 'Private method for use within this object', + dat: 'Object Shared variable declarations and/or PASM code' }; private _tableSpinPAsmLangParts: { [Identifier: string]: string[] } = { // DAT cogexec - org: ["ORG", "begin a cog-exec program (no symbol allowed before ORG),
or Start block of inline-pasm code within SPIN (ends with END)"], - orgf: ["ORGF [value]", "fill to cog address {value} with zeros (no symbol allowed before ORGF)"], - orgh: ["ORGH [originValue[,limitValue]]", "begin a hub-exec program (no symbol allowed before ORGH) (Default origin=$00400, limit=$100000)"], - end: ["END", "Ends block of inline-pasm code (started with ORG)"], - fit: ["FIT [value]", "test to make sure hub/cog address has not exceeded {value}"], + org: ['ORG', 'begin a cog-exec program (no symbol allowed before ORG),
or Start block of inline-pasm code within SPIN (ends with END)'], + orgf: ['ORGF [value]', 'fill to cog address {value} with zeros (no symbol allowed before ORGF)'], + orgh: ['ORGH [originValue[,limitValue]]', 'begin a hub-exec program (no symbol allowed before ORGH) (Default origin=$00400, limit=$100000)'], + end: ['END', 'Ends block of inline-pasm code (started with ORG)'], + fit: ['FIT [value]', 'test to make sure hub/cog address has not exceeded {value}'] }; private _docTextForSpinBuiltInLanguagePart(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (nameKey in this._tableSpinBlockNames) { - desiredDocText.category = "Block Name"; + desiredDocText.category = 'Block Name'; desiredDocText.description = this._tableSpinBlockNames[nameKey]; } else if (nameKey in this._tableSpinFloatConversions) { - desiredDocText.category = "Float Conversions"; - let methodDescr: TMethodTuple = this._tableSpinFloatConversions[nameKey]; + desiredDocText.category = 'Float Conversions'; + const methodDescr: TMethodTuple = this._tableSpinFloatConversions[nameKey]; desiredDocText.signature = methodDescr[0]; desiredDocText.description = methodDescr[1]; if (methodDescr[2] && methodDescr[2].length > 0) { @@ -819,22 +832,22 @@ export class Spin2ParseUtils { desiredDocText.returns = methodDescr[3]; } } else if (nameKey in this._tableSpinBinaryOperators) { - desiredDocText.category = "Binary Operators"; + desiredDocText.category = 'Binary Operators'; desiredDocText.description = this._tableSpinBinaryOperators[nameKey]; } else if (nameKey in this._tableSpinUnaryOperators) { - desiredDocText.category = "Unary Operators"; + desiredDocText.category = 'Unary Operators'; desiredDocText.description = this._tableSpinUnaryOperators[nameKey]; } else if (nameKey in this._tableSmartPinNames) { - desiredDocText.category = "Smart Pin Configuration"; + desiredDocText.category = 'Smart Pin Configuration'; desiredDocText.description = this._tableSmartPinNames[nameKey]; } else if (this.isBuiltinStreamerReservedWord(nameKey)) { - desiredDocText.category = "Streamer Mode Configuration"; - desiredDocText.description = ""; // TODO: add decription table and then fill this in! + desiredDocText.category = 'Streamer Mode Configuration'; + desiredDocText.description = ''; // TODO: add decription table and then fill this in! } else if (nameKey in this._tableEventNames) { - desiredDocText.category = "Event / Interrupt Source"; + desiredDocText.category = 'Event / Interrupt Source'; desiredDocText.description = this._tableEventNames[nameKey]; } else if (nameKey in this._tableSpinPAsmLangParts) { - desiredDocText.category = "DAT HubExec/CogExec Directives"; + desiredDocText.category = 'DAT HubExec/CogExec Directives'; const protoWDescr: string[] = this._tableSpinPAsmLangParts[nameKey]; desiredDocText.signature = protoWDescr[0]; desiredDocText.description = protoWDescr[1]; // bold @@ -853,14 +866,14 @@ export class Spin2ParseUtils { desiredDocText = this._docTextForSpinBuiltInDebugDisplayType(name); if (desiredDocText.found) { desiredDocText.type = eBuiltInType.BIT_DEBUG_SYMBOL; - } else if (name.toLowerCase() == "debug") { + } else if (name.toLowerCase() == 'debug') { desiredDocText.found = true; desiredDocText.type = eBuiltInType.BIT_DEBUG_SYMBOL; - desiredDocText.signature = "debug(...)"; - desiredDocText.category = "Debug Output"; + desiredDocText.signature = 'debug(...)'; + desiredDocText.category = 'Debug Output'; let description: string = - "Run output commands that serially transmit the state of variables and equations as your application runs. Each time a DEBUG statement is encountered during execution, the debugging program is invoked and it outputs the message for that statement."; - description = description + "
*(Affected by DEBUG_PIN_TX symbol)*"; + 'Run output commands that serially transmit the state of variables and equations as your application runs. Each time a DEBUG statement is encountered during execution, the debugging program is invoked and it outputs the message for that statement.'; + description = description + '
*(Affected by DEBUG_PIN_TX symbol)*'; desiredDocText.description = description; } else { // not a debug specific symbol then check other built-in's @@ -882,7 +895,7 @@ export class Spin2ParseUtils { } else { desiredDocText = this._docTextForCogAndNumericSymbols(name); if (desiredDocText.found) { - if (desiredDocText.category.includes("Method Pointer")) { + if (desiredDocText.category.includes('Method Pointer')) { desiredDocText.type = eBuiltInType.BIT_METHOD_POINTER; } else { desiredDocText.type = eBuiltInType.BIT_SYMBOL; @@ -890,7 +903,7 @@ export class Spin2ParseUtils { } else { desiredDocText = this._docTextForSpinBuiltInLanguagePart(name); if (desiredDocText.found) { - if (desiredDocText.category.includes("Float Conversions")) { + if (desiredDocText.category.includes('Float Conversions')) { desiredDocText.type = eBuiltInType.BIT_METHOD; } else { desiredDocText.type = eBuiltInType.BIT_LANG_PART; @@ -928,240 +941,240 @@ export class Spin2ParseUtils { // smart pin names - "decr
mode bits" // FIXME: break this into multiple table each with own cat. name // - A Input Polarity - p_true_a: "True A input
%0000_0000_000_0000000000000_00_00000_0", - p_invert_a: "Invert A input
%1000_0000_000_0000000000000_00_00000_0", + p_true_a: 'True A input
%0000_0000_000_0000000000000_00_00000_0', + p_invert_a: 'Invert A input
%1000_0000_000_0000000000000_00_00000_0', // - A Input Selection - p_local_a: "Select local pin for A input
%0000_0000_000_0000000000000_00_00000_0", - p_plus1_a: "Select pin+1 for A input
%0001_0000_000_0000000000000_00_00000_0", - p_plus2_a: "Select pin+2 for A input
%0010_0000_000_0000000000000_00_00000_0", - p_plus3_a: "Select pin+3 for A input
%0011_0000_000_0000000000000_00_00000_0", - p_outbit_a: "Select OUT bit for A input
%0100_0000_000_0000000000000_00_00000_0", - p_minus3_a: "Select pin-3 for A input
%0101_0000_000_0000000000000_00_00000_0", - p_minus2_a: "Select pin-2 for A input
%0110_0000_000_0000000000000_00_00000_0", - p_minus1_a: "Select pin-1 for A input
%0111_0000_000_0000000000000_00_00000_0", + p_local_a: 'Select local pin for A input
%0000_0000_000_0000000000000_00_00000_0', + p_plus1_a: 'Select pin+1 for A input
%0001_0000_000_0000000000000_00_00000_0', + p_plus2_a: 'Select pin+2 for A input
%0010_0000_000_0000000000000_00_00000_0', + p_plus3_a: 'Select pin+3 for A input
%0011_0000_000_0000000000000_00_00000_0', + p_outbit_a: 'Select OUT bit for A input
%0100_0000_000_0000000000000_00_00000_0', + p_minus3_a: 'Select pin-3 for A input
%0101_0000_000_0000000000000_00_00000_0', + p_minus2_a: 'Select pin-2 for A input
%0110_0000_000_0000000000000_00_00000_0', + p_minus1_a: 'Select pin-1 for A input
%0111_0000_000_0000000000000_00_00000_0', // - B Input Polarity - p_true_b: "True B input
%0000_0000_000_0000000000000_00_00000_0", - p_invert_b: "Invert B input
%0000_1000_000_0000000000000_00_00000_0", + p_true_b: 'True B input
%0000_0000_000_0000000000000_00_00000_0', + p_invert_b: 'Invert B input
%0000_1000_000_0000000000000_00_00000_0', // - B Input Selection - p_local_b: "Select local pin for B input
%0000_0000_000_0000000000000_00_00000_0", - p_plus1_b: "Select pin+1 for B input
%0000_0001_000_0000000000000_00_00000_0", - p_plus2_b: "Select pin+2 for B input
%0000_0010_000_0000000000000_00_00000_0", - p_plus3_b: "Select pin+3 for B input
%0000_0011_000_0000000000000_00_00000_0", - p_outbit_b: "Select OUT bit for B input
%0000_0100_000_0000000000000_00_00000_0", - p_minus3_b: "Select pin-3 for B input
%0000_0101_000_0000000000000_00_00000_0", - p_minus2_b: "Select pin-2 for B input
%0000_0110_000_0000000000000_00_00000_0", - p_minus1_b: "Select pin-1 for B input
%0000_0111_000_0000000000000_00_00000_0", + p_local_b: 'Select local pin for B input
%0000_0000_000_0000000000000_00_00000_0', + p_plus1_b: 'Select pin+1 for B input
%0000_0001_000_0000000000000_00_00000_0', + p_plus2_b: 'Select pin+2 for B input
%0000_0010_000_0000000000000_00_00000_0', + p_plus3_b: 'Select pin+3 for B input
%0000_0011_000_0000000000000_00_00000_0', + p_outbit_b: 'Select OUT bit for B input
%0000_0100_000_0000000000000_00_00000_0', + p_minus3_b: 'Select pin-3 for B input
%0000_0101_000_0000000000000_00_00000_0', + p_minus2_b: 'Select pin-2 for B input
%0000_0110_000_0000000000000_00_00000_0', + p_minus1_b: 'Select pin-1 for B input
%0000_0111_000_0000000000000_00_00000_0', // - A,B Input Selection - p_pass_ab: "Select A, B
%0000_0000_000_0000000000000_00_00000_0", - p_and_ab: "Select A & B, B
%0000_0000_001_0000000000000_00_00000_0", - p_or_ab: "Select A | B, B
%0000_0000_010_0000000000000_00_00000_0", - p_xor_ab: "Select A ^ B, B
%0000_0000_011_0000000000000_00_00000_0", - p_filt0_ab: "Select FILT0 settings for A, B
%0000_0000_100_0000000000000_00_00000_0", - p_filt1_ab: "Select FILT1 settings for A, B
%0000_0000_101_0000000000000_00_00000_0", - p_filt2_ab: "Select FILT2 settings for A, B
%0000_0000_110_0000000000000_00_00000_0", - p_filt3_ab: "Select FILT3 settings for A, B
%0000_0000_111_0000000000000_00_00000_0", + p_pass_ab: 'Select A, B
%0000_0000_000_0000000000000_00_00000_0', + p_and_ab: 'Select A & B, B
%0000_0000_001_0000000000000_00_00000_0', + p_or_ab: 'Select A | B, B
%0000_0000_010_0000000000000_00_00000_0', + p_xor_ab: 'Select A ^ B, B
%0000_0000_011_0000000000000_00_00000_0', + p_filt0_ab: 'Select FILT0 settings for A, B
%0000_0000_100_0000000000000_00_00000_0', + p_filt1_ab: 'Select FILT1 settings for A, B
%0000_0000_101_0000000000000_00_00000_0', + p_filt2_ab: 'Select FILT2 settings for A, B
%0000_0000_110_0000000000000_00_00000_0', + p_filt3_ab: 'Select FILT3 settings for A, B
%0000_0000_111_0000000000000_00_00000_0', // - Low Level Pin Modes - p_logic_a: "Logic level A → IN, output OUT
%0000_0000_000_0000000000000_00_00000_0", - p_logic_a_fb: "Logic level A → IN, output feedback
%0000_0000_000_0001000000000_00_00000_0", - p_logic_b_fb: "Logic level B → IN, output feedback
%0000_0000_000_0010000000000_00_00000_0", - p_schmitt_a: "Schmitt trigger A → IN, output OUT
%0000_0000_000_0011000000000_00_00000_0", - p_schmitt_a_fb: "Schmitt trigger A → IN, output feedback
%0000_0000_000_0100000000000_00_00000_0", - p_schmitt_b_fb: "Schmitt trigger B → IN, output feedback
%0000_0000_000_0101000000000_00_00000_0", - p_compare_ab: "A > B → IN, output OUT
%0000_0000_000_0110000000000_00_00000_0", - p_compare_ab_fb: "A > B → IN, output feedback
%0000_0000_000_0111000000000_00_00000_0", + p_logic_a: 'Logic level A → IN, output OUT
%0000_0000_000_0000000000000_00_00000_0', + p_logic_a_fb: 'Logic level A → IN, output feedback
%0000_0000_000_0001000000000_00_00000_0', + p_logic_b_fb: 'Logic level B → IN, output feedback
%0000_0000_000_0010000000000_00_00000_0', + p_schmitt_a: 'Schmitt trigger A → IN, output OUT
%0000_0000_000_0011000000000_00_00000_0', + p_schmitt_a_fb: 'Schmitt trigger A → IN, output feedback
%0000_0000_000_0100000000000_00_00000_0', + p_schmitt_b_fb: 'Schmitt trigger B → IN, output feedback
%0000_0000_000_0101000000000_00_00000_0', + p_compare_ab: 'A > B → IN, output OUT
%0000_0000_000_0110000000000_00_00000_0', + p_compare_ab_fb: 'A > B → IN, output feedback
%0000_0000_000_0111000000000_00_00000_0', // - ADC Input Modes - p_adc_gio: "ADC GIO → IN, output OUT
%0000_0000_000_1000000000000_00_00000_0", - p_adc_vio: "ADC VIO → IN, output OUT
%0000_0000_000_1000010000000_00_00000_0", - p_adc_float: "ADC FLOAT → IN, output OUT
%0000_0000_000_1000100000000_00_00000_0", - p_adc_1x: "ADC 1x → IN, output OUT
%0000_0000_000_1000110000000_00_00000_0", - p_adc_3x: "ADC 3.16x → IN, output OUT
%0000_0000_000_1001000000000_00_00000_0", - p_adc_10x: "ADC 10x → IN, output OUT
%0000_0000_000_1001010000000_00_00000_0", - p_adc_30x: "ADC 31.6x → IN, output OUT
%0000_0000_000_1001100000000_00_00000_0", - p_adc_100x: "ADC 100x → IN, output OUT
%0000_0000_000_1001110000000_00_00000_0", + p_adc_gio: 'ADC GIO → IN, output OUT
%0000_0000_000_1000000000000_00_00000_0', + p_adc_vio: 'ADC VIO → IN, output OUT
%0000_0000_000_1000010000000_00_00000_0', + p_adc_float: 'ADC FLOAT → IN, output OUT
%0000_0000_000_1000100000000_00_00000_0', + p_adc_1x: 'ADC 1x → IN, output OUT
%0000_0000_000_1000110000000_00_00000_0', + p_adc_3x: 'ADC 3.16x → IN, output OUT
%0000_0000_000_1001000000000_00_00000_0', + p_adc_10x: 'ADC 10x → IN, output OUT
%0000_0000_000_1001010000000_00_00000_0', + p_adc_30x: 'ADC 31.6x → IN, output OUT
%0000_0000_000_1001100000000_00_00000_0', + p_adc_100x: 'ADC 100x → IN, output OUT
%0000_0000_000_1001110000000_00_00000_0', // - DAC Output Modes - p_dac_990r_3v: "DAC 990Ω, 3.3V peak, ADC 1x → IN
%0000_0000_000_1010000000000_00_00000_0", - p_dac_600r_2v: "DAC 600Ω, 2.0V peak, ADC 1x → IN
%0000_0000_000_1010100000000_00_00000_0", - p_dac_124r_3v: "DAC 123.75Ω, 3.3V peak, ADC 1x → IN
%0000_0000_000_1011000000000_00_00000_0", - p_dac_75r_2v: "DAC 75Ω, 2.0V peak, ADC 1x → IN
%0000_0000_000_1011100000000_00_00000_0", + p_dac_990r_3v: 'DAC 990Ω, 3.3V peak, ADC 1x → IN
%0000_0000_000_1010000000000_00_00000_0', + p_dac_600r_2v: 'DAC 600Ω, 2.0V peak, ADC 1x → IN
%0000_0000_000_1010100000000_00_00000_0', + p_dac_124r_3v: 'DAC 123.75Ω, 3.3V peak, ADC 1x → IN
%0000_0000_000_1011000000000_00_00000_0', + p_dac_75r_2v: 'DAC 75Ω, 2.0V peak, ADC 1x → IN
%0000_0000_000_1011100000000_00_00000_0', // - Level-Comparison Modes - p_level_a: "A > Level → IN, output OUT
%0000_0000_000_1100000000000_00_00000_0", - p_level_a_fbn: "A > Level → IN, output negative feedback
%0000_0000_000_1101000000000_00_00000_0", - p_level_b_fbp: "B > Level → IN, output positive feedback
%0000_0000_000_1110000000000_00_00000_0", - p_level_b_fbn: "B > Level → IN, output negative feedback
%0000_0000_000_1111000000000_00_00000_0", + p_level_a: 'A > Level → IN, output OUT
%0000_0000_000_1100000000000_00_00000_0', + p_level_a_fbn: 'A > Level → IN, output negative feedback
%0000_0000_000_1101000000000_00_00000_0', + p_level_b_fbp: 'B > Level → IN, output positive feedback
%0000_0000_000_1110000000000_00_00000_0', + p_level_b_fbn: 'B > Level → IN, output negative feedback
%0000_0000_000_1111000000000_00_00000_0', // - Low-Level Pin Sub-Modes: Sync Mode - p_async_io: "Select asynchronous I/O
%0000_0000_000_0000000000000_00_00000_0", - p_sync_io: "Select synchronous I/O
%0000_0000_000_0000100000000_00_00000_0", + p_async_io: 'Select asynchronous I/O
%0000_0000_000_0000000000000_00_00000_0', + p_sync_io: 'Select synchronous I/O
%0000_0000_000_0000100000000_00_00000_0', // - Low-Level Pin Sub-Modes: IN Polarity - p_true_in: "True IN bit
%0000_0000_000_0000000000000_00_00000_0", - p_invert_in: "Invert IN bit
%0000_0000_000_0000010000000_00_00000_0", + p_true_in: 'True IN bit
%0000_0000_000_0000000000000_00_00000_0', + p_invert_in: 'Invert IN bit
%0000_0000_000_0000010000000_00_00000_0', // - Low-Level Pin Sub-Modes: Output Polarity - p_true_output: "Select true output
%0000_0000_000_0000000000000_00_00000_0", - p_invert_output: "Select inverted output
0000_0000_000_0000001000000_00_00000_0", + p_true_output: 'Select true output
%0000_0000_000_0000000000000_00_00000_0', + p_invert_output: 'Select inverted output
0000_0000_000_0000001000000_00_00000_0', // - Low-Level Pin Sub-Modes: Drive-High Strength - p_high_fast: "Drive high fast (30mA)
%0000_0000_000_0000000000000_00_00000_0", - p_high_1k5: "Drive high 1.5kΩ
%0000_0000_000_0000000001000_00_00000_0", - p_high_15k: "Drive high 15kΩ
%0000_0000_000_0000000010000_00_00000_0", - p_high_150k: "Drive high 150kΩ
%0000_0000_000_0000000011000_00_00000_0", - p_high_1ma: "Drive high 1mA
%0000_0000_000_0000000100000_00_00000_0", - p_high_100ua: "Drive high 100μA
%0000_0000_000_0000000101000_00_00000_0", - p_high_10ua: "Drive high 10μA
%0000_0000_000_0000000110000_00_00000_0", - p_high_float: "Float high
%0000_0000_000_0000000111000_00_00000_0", + p_high_fast: 'Drive high fast (30mA)
%0000_0000_000_0000000000000_00_00000_0', + p_high_1k5: 'Drive high 1.5kΩ
%0000_0000_000_0000000001000_00_00000_0', + p_high_15k: 'Drive high 15kΩ
%0000_0000_000_0000000010000_00_00000_0', + p_high_150k: 'Drive high 150kΩ
%0000_0000_000_0000000011000_00_00000_0', + p_high_1ma: 'Drive high 1mA
%0000_0000_000_0000000100000_00_00000_0', + p_high_100ua: 'Drive high 100μA
%0000_0000_000_0000000101000_00_00000_0', + p_high_10ua: 'Drive high 10μA
%0000_0000_000_0000000110000_00_00000_0', + p_high_float: 'Float high
%0000_0000_000_0000000111000_00_00000_0', // - Low-Level Pin Sub-Modes: Drive-Low Strength - p_low_fast: "Drive low fast (30mA)
%0000_0000_000_0000000000000_00_00000_0", - p_low_1k5: "Drive low 1.5kΩ
%0000_0000_000_0000000000001_00_00000_0", - p_low_15k: "Drive low 15kΩ
%0000_0000_000_0000000000010_00_00000_0", - p_low_150k: "Drive low 150kΩ
%0000_0000_000_0000000000011_00_00000_0", - p_low_1ma: "Drive low 1mA
%0000_0000_000_0000000000100_00_00000_0", - p_low_100ua: "Drive low 100μA
%0000_0000_000_0000000000101_00_00000_0", - p_low_10ua: "Drive low 10μA
%0000_0000_000_0000000000110_00_00000_0", - p_low_float: "Float low
%0000_0000_000_0000000000111_00_00000_0", + p_low_fast: 'Drive low fast (30mA)
%0000_0000_000_0000000000000_00_00000_0', + p_low_1k5: 'Drive low 1.5kΩ
%0000_0000_000_0000000000001_00_00000_0', + p_low_15k: 'Drive low 15kΩ
%0000_0000_000_0000000000010_00_00000_0', + p_low_150k: 'Drive low 150kΩ
%0000_0000_000_0000000000011_00_00000_0', + p_low_1ma: 'Drive low 1mA
%0000_0000_000_0000000000100_00_00000_0', + p_low_100ua: 'Drive low 100μA
%0000_0000_000_0000000000101_00_00000_0', + p_low_10ua: 'Drive low 10μA
%0000_0000_000_0000000000110_00_00000_0', + p_low_float: 'Float low
%0000_0000_000_0000000000111_00_00000_0', // - DIR/OUT Control - p_tt_00: "TT = %00
%0000_0000_000_0000000000000_00_00000_0", - p_tt_01: "TT = %01
%0000_0000_000_0000000000000_01_00000_0", - p_tt_10: "TT = %10
%0000_0000_000_0000000000000_10_00000_0", - p_tt_11: "TT = %11
%0000_0000_000_0000000000000_11_00000_0", - p_oe: "Enable output in smart pin mode
%0000_0000_000_0000000000000_01_00000_0", - p_channel: "Enable DAC channel in non-smart pin DAC mode
%0000_0000_000_0000000000000_01_00000_0", - p_bitdac: "Enable BITDAC for non-smart pin DAC mode
%0000_0000_000_0000000000000_10_00000_0", + p_tt_00: 'TT = %00
%0000_0000_000_0000000000000_00_00000_0', + p_tt_01: 'TT = %01
%0000_0000_000_0000000000000_01_00000_0', + p_tt_10: 'TT = %10
%0000_0000_000_0000000000000_10_00000_0', + p_tt_11: 'TT = %11
%0000_0000_000_0000000000000_11_00000_0', + p_oe: 'Enable output in smart pin mode
%0000_0000_000_0000000000000_01_00000_0', + p_channel: 'Enable DAC channel in non-smart pin DAC mode
%0000_0000_000_0000000000000_01_00000_0', + p_bitdac: 'Enable BITDAC for non-smart pin DAC mode
%0000_0000_000_0000000000000_10_00000_0', // - Smart Pin Modes - p_normal: "Normal mode (not smart pin mode)
%0000_0000_000_0000000000000_00_00000_0", - p_repository: "Long repository (non-DAC mode)
%0000_0000_000_0000000000000_00_00001_0", - p_dac_noise: "DAC Noise (DAC mode)
%0000_0000_000_0000000000000_00_00001_0", - p_dac_dither_rnd: "DAC 16-bit random dither (DAC mode)
%0000_0000_000_0000000000000_00_00010_0", - p_dac_dither_pwm: "DAC 16-bit PWM dither (DAC mode)
%0000_0000_000_0000000000000_00_00011_0", - p_pulse: "Pulse/cycle output
%0000_0000_000_0000000000000_00_00100_0", - p_transition: "Transition output
%0000_0000_000_0000000000000_00_00101_0", - p_nco_freq: "NCO frequency output
%0000_0000_000_0000000000000_00_00110_0", - p_nco_duty: "NCO duty output
%0000_0000_000_0000000000000_00_00111_0", - p_pwm_triangle: "PWM triangle output
%0000_0000_000_0000000000000_00_01000_0", - p_pwm_sawtooth: "PWM sawtooth output
%0000_0000_000_0000000000000_00_01001_0", - p_pwm_smps: "PWM switch-mode power supply I/O
%0000_0000_000_0000000000000_00_01010_0", - p_quadrature: "A-B quadrature encoder input
%0000_0000_000_0000000000000_00_01011_0", - p_reg_up: "Inc on A-rise when B-high
%0000_0000_000_0000000000000_00_01100_0", - p_reg_down: "Inc on A-rise when B-high, dec on A-rise when B-low
%0000_0000_000_0000000000000_00_01101_0", - p_count_rises: "Inc on A-rise, optionally dec on B-rise
%0000_0000_000_0000000000000_00_01110_0", - p_count_highs: "Inc on A-high, optionally dec on B-high
%0000_0000_000_0000000000000_00_01111_0", - p_state_ticks: "For A-low and A-high states, count ticks
%0000_0000_000_0000000000000_00_10000_0", - p_high_ticks: "For A-high states, count ticks
%0000_0000_000_0000000000000_00_10001_0", - p_events_ticks: "For X A-highs/rises/edges, count ticks / Timeout on X ticks of no A-high/rise/edge
%0000_0000_000_0000000000000_00_10010_0", - p_periods_ticks: "For X periods of A, count ticks
%0000_0000_000_0000000000000_00_10011_0", - p_periods_highs: "For X periods of A, count highs
%0000_0000_000_0000000000000_00_10100_0", - p_counter_ticks: "For periods of A in X+ ticks, count ticks
%0000_0000_000_0000000000000_00_10101_0", - p_counter_highs: "For periods of A in X+ ticks, count highs
%0000_0000_000_0000000000000_00_10110_0", - p_counter_periods: "For periods of A in X+ ticks, count periods
%0000_0000_000_0000000000000_00_10111_0", - p_adc: "ADC sample/filter/capture, internally clocked
%0000_0000_000_0000000000000_00_11000_0", - p_adc_ext: "ADC sample/filter/capture, externally clocked
%0000_0000_000_0000000000000_00_11001_0", - p_adc_scope: "ADC scope with trigger
%0000_0000_000_0000000000000_00_11010_0", - p_usb_pair: "USB pin pair
%0000_0000_000_0000000000000_00_11011_0", - p_sync_tx: "Synchronous serial transmit
%0000_0000_000_0000000000000_00_11100_0", - p_sync_rx: "Synchronous serial receive
%0000_0000_000_0000000000000_00_11101_0", - p_async_tx: "Asynchronous serial transmit
%0000_0000_000_0000000000000_00_11110_0", - p_async_rx: "Asynchronous serial receive
%0000_0000_000_0000000000000_00_11111_0", + p_normal: 'Normal mode (not smart pin mode)
%0000_0000_000_0000000000000_00_00000_0', + p_repository: 'Long repository (non-DAC mode)
%0000_0000_000_0000000000000_00_00001_0', + p_dac_noise: 'DAC Noise (DAC mode)
%0000_0000_000_0000000000000_00_00001_0', + p_dac_dither_rnd: 'DAC 16-bit random dither (DAC mode)
%0000_0000_000_0000000000000_00_00010_0', + p_dac_dither_pwm: 'DAC 16-bit PWM dither (DAC mode)
%0000_0000_000_0000000000000_00_00011_0', + p_pulse: 'Pulse/cycle output
%0000_0000_000_0000000000000_00_00100_0', + p_transition: 'Transition output
%0000_0000_000_0000000000000_00_00101_0', + p_nco_freq: 'NCO frequency output
%0000_0000_000_0000000000000_00_00110_0', + p_nco_duty: 'NCO duty output
%0000_0000_000_0000000000000_00_00111_0', + p_pwm_triangle: 'PWM triangle output
%0000_0000_000_0000000000000_00_01000_0', + p_pwm_sawtooth: 'PWM sawtooth output
%0000_0000_000_0000000000000_00_01001_0', + p_pwm_smps: 'PWM switch-mode power supply I/O
%0000_0000_000_0000000000000_00_01010_0', + p_quadrature: 'A-B quadrature encoder input
%0000_0000_000_0000000000000_00_01011_0', + p_reg_up: 'Inc on A-rise when B-high
%0000_0000_000_0000000000000_00_01100_0', + p_reg_down: 'Inc on A-rise when B-high, dec on A-rise when B-low
%0000_0000_000_0000000000000_00_01101_0', + p_count_rises: 'Inc on A-rise, optionally dec on B-rise
%0000_0000_000_0000000000000_00_01110_0', + p_count_highs: 'Inc on A-high, optionally dec on B-high
%0000_0000_000_0000000000000_00_01111_0', + p_state_ticks: 'For A-low and A-high states, count ticks
%0000_0000_000_0000000000000_00_10000_0', + p_high_ticks: 'For A-high states, count ticks
%0000_0000_000_0000000000000_00_10001_0', + p_events_ticks: 'For X A-highs/rises/edges, count ticks / Timeout on X ticks of no A-high/rise/edge
%0000_0000_000_0000000000000_00_10010_0', + p_periods_ticks: 'For X periods of A, count ticks
%0000_0000_000_0000000000000_00_10011_0', + p_periods_highs: 'For X periods of A, count highs
%0000_0000_000_0000000000000_00_10100_0', + p_counter_ticks: 'For periods of A in X+ ticks, count ticks
%0000_0000_000_0000000000000_00_10101_0', + p_counter_highs: 'For periods of A in X+ ticks, count highs
%0000_0000_000_0000000000000_00_10110_0', + p_counter_periods: 'For periods of A in X+ ticks, count periods
%0000_0000_000_0000000000000_00_10111_0', + p_adc: 'ADC sample/filter/capture, internally clocked
%0000_0000_000_0000000000000_00_11000_0', + p_adc_ext: 'ADC sample/filter/capture, externally clocked
%0000_0000_000_0000000000000_00_11001_0', + p_adc_scope: 'ADC scope with trigger
%0000_0000_000_0000000000000_00_11010_0', + p_usb_pair: 'USB pin pair
%0000_0000_000_0000000000000_00_11011_0', + p_sync_tx: 'Synchronous serial transmit
%0000_0000_000_0000000000000_00_11100_0', + p_sync_rx: 'Synchronous serial receive
%0000_0000_000_0000000000000_00_11101_0', + p_async_tx: 'Asynchronous serial transmit
%0000_0000_000_0000000000000_00_11110_0', + p_async_rx: 'Asynchronous serial receive
%0000_0000_000_0000000000000_00_11111_0' }; private _tableEventNames: { [Identifier: string]: string } = { // event names - event_atn: "(14) event Attention-requested from another COG", - event_ct1: "(01) event CT-passed-CT1", - event_ct2: "(02) event CT-passed-CT2", - event_ct3: "(03) event CT-passed-CT3", - event_fbw: "(09) event Hub FIFO block-wrap", - event_int: "(00) event Interrupt-occurred", - int_off: "(00) interrupts off", - event_pat: "(08) INA/INB pattern match/mismatch", - event_qmt: "(15) event GETQX/GETQY-on-empty", - event_se1: "(04) event Selectable event 1", - event_se2: "(05) event Selectable event 2", - event_se3: "(06) event Selectable event 3", - event_se4: "(07) event Selectable event 4", - event_xfi: "(11) event Streamer command-finished", - event_xmt: "(10) event Streamer command-empty", - event_xrl: "(13) event Streamer-read-last-LUT-location", - event_xro: "(12) event Streamer NCO-rollover", + event_atn: '(14) event Attention-requested from another COG', + event_ct1: '(01) event CT-passed-CT1', + event_ct2: '(02) event CT-passed-CT2', + event_ct3: '(03) event CT-passed-CT3', + event_fbw: '(09) event Hub FIFO block-wrap', + event_int: '(00) event Interrupt-occurred', + int_off: '(00) interrupts off', + event_pat: '(08) INA/INB pattern match/mismatch', + event_qmt: '(15) event GETQX/GETQY-on-empty', + event_se1: '(04) event Selectable event 1', + event_se2: '(05) event Selectable event 2', + event_se3: '(06) event Selectable event 3', + event_se4: '(07) event Selectable event 4', + event_xfi: '(11) event Streamer command-finished', + event_xmt: '(10) event Streamer command-empty', + event_xrl: '(13) event Streamer-read-last-LUT-location', + event_xro: '(12) event Streamer NCO-rollover' }; public isBuiltinStreamerReservedWord(name: string): boolean { // streamer constants, smart-pin constants const builtinNamesOfNote: string[] = [ // streamer names - "x_16p_2dac8_wfword", - "x_16p_4dac4_wfword", - "x_1adc8_0p_1dac8_wfbyte", - "x_1adc8_8p_2dac8_wfword", - "x_1p_1dac1_wfbyte", - "x_2adc8_0p_2dac8_wfword", - "x_2adc8_16p_4dac8_wflong", - "x_2p_1dac2_wfbyte", - "x_2p_2dac1_wfbyte", - "x_32p_4dac8_wflong", - "x_4adc8_0p_4dac8_wflong", - "x_4p_1dac4_wfbyte", - "x_4p_2dac2_wfbyte", - "x_4p_4dac1_wfbyte", - "x_8p_1dac8_wfbyte", - "x_8p_2dac4_wfbyte", - "x_8p_4dac2_wfbyte", - "x_alt_off", - "x_alt_on", - "x_dacs_0n0_0n0", - "x_dacs_0n0_x_x", - "x_dacs_0_0_0_0", - "x_dacs_0_0_x_x", - "x_dacs_0_x_x_x", - "x_dacs_1n1_0n0", - "x_dacs_1_0_1_0", - "x_dacs_1_0_x_x", - "x_dacs_3_2_1_0", - "x_dacs_off", - "x_dacs_x_0_x_x", - "x_dacs_x_x_0n0", - "x_dacs_x_x_0_0", - "x_dacs_x_x_0_x", - "x_dacs_x_x_1_0", - "x_dacs_x_x_x_0", - "x_dds_goertzel_sinc1", - "x_dds_goertzel_sinc2", - "x_imm_16x2_1dac2", - "x_imm_16x2_2dac1", - "x_imm_16x2_lut", - "x_imm_1x32_4dac8", - "x_imm_2x16_2dac8", - "x_imm_2x16_4dac4", - "x_imm_32x1_1dac1", - "x_imm_32x1_lut", - "x_imm_4x8_1dac8", - "x_imm_4x8_2dac4", - "x_imm_4x8_4dac2", - "x_imm_4x8_lut", - "x_imm_8x4_1dac4", - "x_imm_8x4_2dac2", - "x_imm_8x4_4dac1", - "x_imm_8x4_lut", - "x_pins_off", - "x_pins_on", - "x_rfbyte_1p_1dac1", - "x_rfbyte_2p_1dac2", - "x_rfbyte_2p_2dac1", - "x_rfbyte_4p_1dac4", - "x_rfbyte_4p_2dac2", - "x_rfbyte_4p_4dac1", - "x_rfbyte_8p_1dac8", - "x_rfbyte_8p_2dac4", - "x_rfbyte_8p_4dac2", - "x_rfbyte_luma8", - "x_rfbyte_rgb8", - "x_rfbyte_rgbi8", - "x_rflong_16x2_lut", - "x_rflong_32p_4dac8", - "x_rflong_32x1_lut", - "x_rflong_4x8_lut", - "x_rflong_8x4_lut", - "x_rflong_rgb24", - "x_rfword_16p_2dac8", - "x_rfword_16p_4dac4", - "x_rfword_rgb16", - "x_write_off", - "x_write_on", + 'x_16p_2dac8_wfword', + 'x_16p_4dac4_wfword', + 'x_1adc8_0p_1dac8_wfbyte', + 'x_1adc8_8p_2dac8_wfword', + 'x_1p_1dac1_wfbyte', + 'x_2adc8_0p_2dac8_wfword', + 'x_2adc8_16p_4dac8_wflong', + 'x_2p_1dac2_wfbyte', + 'x_2p_2dac1_wfbyte', + 'x_32p_4dac8_wflong', + 'x_4adc8_0p_4dac8_wflong', + 'x_4p_1dac4_wfbyte', + 'x_4p_2dac2_wfbyte', + 'x_4p_4dac1_wfbyte', + 'x_8p_1dac8_wfbyte', + 'x_8p_2dac4_wfbyte', + 'x_8p_4dac2_wfbyte', + 'x_alt_off', + 'x_alt_on', + 'x_dacs_0n0_0n0', + 'x_dacs_0n0_x_x', + 'x_dacs_0_0_0_0', + 'x_dacs_0_0_x_x', + 'x_dacs_0_x_x_x', + 'x_dacs_1n1_0n0', + 'x_dacs_1_0_1_0', + 'x_dacs_1_0_x_x', + 'x_dacs_3_2_1_0', + 'x_dacs_off', + 'x_dacs_x_0_x_x', + 'x_dacs_x_x_0n0', + 'x_dacs_x_x_0_0', + 'x_dacs_x_x_0_x', + 'x_dacs_x_x_1_0', + 'x_dacs_x_x_x_0', + 'x_dds_goertzel_sinc1', + 'x_dds_goertzel_sinc2', + 'x_imm_16x2_1dac2', + 'x_imm_16x2_2dac1', + 'x_imm_16x2_lut', + 'x_imm_1x32_4dac8', + 'x_imm_2x16_2dac8', + 'x_imm_2x16_4dac4', + 'x_imm_32x1_1dac1', + 'x_imm_32x1_lut', + 'x_imm_4x8_1dac8', + 'x_imm_4x8_2dac4', + 'x_imm_4x8_4dac2', + 'x_imm_4x8_lut', + 'x_imm_8x4_1dac4', + 'x_imm_8x4_2dac2', + 'x_imm_8x4_4dac1', + 'x_imm_8x4_lut', + 'x_pins_off', + 'x_pins_on', + 'x_rfbyte_1p_1dac1', + 'x_rfbyte_2p_1dac2', + 'x_rfbyte_2p_2dac1', + 'x_rfbyte_4p_1dac4', + 'x_rfbyte_4p_2dac2', + 'x_rfbyte_4p_4dac1', + 'x_rfbyte_8p_1dac8', + 'x_rfbyte_8p_2dac4', + 'x_rfbyte_8p_4dac2', + 'x_rfbyte_luma8', + 'x_rfbyte_rgb8', + 'x_rfbyte_rgbi8', + 'x_rflong_16x2_lut', + 'x_rflong_32p_4dac8', + 'x_rflong_32x1_lut', + 'x_rflong_4x8_lut', + 'x_rflong_8x4_lut', + 'x_rflong_rgb24', + 'x_rfword_16p_2dac8', + 'x_rfword_16p_4dac4', + 'x_rfword_rgb16', + 'x_write_off', + 'x_write_on' ]; const nameKey: string = name.toLowerCase(); let reservedStatus: boolean = builtinNamesOfNote.indexOf(nameKey) != -1; @@ -1180,187 +1193,221 @@ export class Spin2ParseUtils { // ------------------------------------------------------------------------- // keyword checks private _tableDebugMethodsString: { [Identifier: string]: TMethodTuple } = { - zstr: ["ZSTR(hub_pointer)", "Output zero-terminated string found at hub_pointer", ["hub_pointer - address of zero-terminated string in HUB RAM"]], - lstr: ["LSTR(hub_pointer,byteCount)", "Output 'byteCount' characters found at hub_pointer", ["hub_pointer - address of bytes in HUB RAM", "byteCount - number of bytes at location in HUB RAM"]], + zstr: ['ZSTR(hub_pointer)', 'Output zero-terminated string found at hub_pointer', ['hub_pointer - address of zero-terminated string in HUB RAM']], + lstr: [ + 'LSTR(hub_pointer,byteCount)', + "Output 'byteCount' characters found at hub_pointer", + ['hub_pointer - address of bytes in HUB RAM', 'byteCount - number of bytes at location in HUB RAM'] + ] }; private _tableDebugMethodsUnsignedDec: { [Identifier: string]: TMethodTuple } = { - udec: ["UDEC(value)", "Output as auto-sized unsigned decimal value (0 - 4_294_967_295)", ["value - BYTE, WORD or LONG value"]], - udec_byte: ["UDEC_BYTE(byteValue)", "Output BYTE as unsigned decimal value (0 - 255)", ["byteValue - 8-bit value"]], - udec_word: ["UDEC_WORD(wordValue)", "Output WORD as unsigned decimal value (0 - 65_535)", ["wordValue - 16-bit value"]], - udec_long: ["UDEC_LONG(longValue)", "Output LONG as unsigned decimal value (0 - 4_294_967_295)", ["longValue - 32-bit value"]], + udec: ['UDEC(value)', 'Output as auto-sized unsigned decimal value (0 - 4_294_967_295)', ['value - BYTE, WORD or LONG value']], + udec_byte: ['UDEC_BYTE(byteValue)', 'Output BYTE as unsigned decimal value (0 - 255)', ['byteValue - 8-bit value']], + udec_word: ['UDEC_WORD(wordValue)', 'Output WORD as unsigned decimal value (0 - 65_535)', ['wordValue - 16-bit value']], + udec_long: ['UDEC_LONG(longValue)', 'Output LONG as unsigned decimal value (0 - 4_294_967_295)', ['longValue - 32-bit value']], udec_reg_array: [ - "UDEC_REG_ARRAY(reg_pointer, size)", - "Output register array as unsigned decimal values (0 - 4_294_967_295)", - ["reg_pointer - address of array of COG registers", "size - count of registers in array"], + 'UDEC_REG_ARRAY(reg_pointer, size)', + 'Output register array as unsigned decimal values (0 - 4_294_967_295)', + ['reg_pointer - address of array of COG registers', 'size - count of registers in array'] ], udec_byte_array: [ - "UDEC_BYTE_ARRAY(hub_pointer, size)", - "Output hub BYTE array as unsigned decimal values (0 - 255)", - ["hub_pointer - address of array of BYTEs in HUB ram", "size - count of BYTEs in array"], + 'UDEC_BYTE_ARRAY(hub_pointer, size)', + 'Output hub BYTE array as unsigned decimal values (0 - 255)', + ['hub_pointer - address of array of BYTEs in HUB ram', 'size - count of BYTEs in array'] ], udec_word_array: [ - "UDEC_WORD_ARRAY(hub_pointer, size)", - "Output hub WORD array as unsigned decimal value (0 - 65_535)", - ["hub_pointer - address of array of WORDs in HUB ram", "size - count of WORDs in array"], + 'UDEC_WORD_ARRAY(hub_pointer, size)', + 'Output hub WORD array as unsigned decimal value (0 - 65_535)', + ['hub_pointer - address of array of WORDs in HUB ram', 'size - count of WORDs in array'] ], udec_long_array: [ - "UDEC_LONG_ARRAY(hub_pointer, size)", - "Output hub LONG array as unsigned decimal value (0 - 4_294_967_295)", - ["hub_pointer - address of array of LONGs in HUB ram", "size - count of LONGs in array"], - ], + 'UDEC_LONG_ARRAY(hub_pointer, size)', + 'Output hub LONG array as unsigned decimal value (0 - 4_294_967_295)', + ['hub_pointer - address of array of LONGs in HUB ram', 'size - count of LONGs in array'] + ] }; private _tableDebugMethodsSignedDec: { [Identifier: string]: TMethodTuple } = { - sdec: ["SDEC(value)", "Output as auto-sized signed decimal value (-2_147_483_648 - 2_147_483_647)", ["value - BYTE, WORD or LONG value"]], - sdec_byte: ["SDEC_BYTE(byteValue)", "Output BYTE as signed decimal value (-128 - 127)", ["byteValue - 8-bit value"]], - sdec_word: ["SDEC_WORD(wordValue)", "Output WORD as signed decimal value (-32_768 - 65_535)", ["wordValue - 16-bit value"]], - sdec_long: ["SDEC_LONG(longValue)", "Output LONG as signed decimal value (-2_147_483_648 - 2_147_483_647)", ["longValue - 32-bit value"]], + sdec: ['SDEC(value)', 'Output as auto-sized signed decimal value (-2_147_483_648 - 2_147_483_647)', ['value - BYTE, WORD or LONG value']], + sdec_byte: ['SDEC_BYTE(byteValue)', 'Output BYTE as signed decimal value (-128 - 127)', ['byteValue - 8-bit value']], + sdec_word: ['SDEC_WORD(wordValue)', 'Output WORD as signed decimal value (-32_768 - 65_535)', ['wordValue - 16-bit value']], + sdec_long: ['SDEC_LONG(longValue)', 'Output LONG as signed decimal value (-2_147_483_648 - 2_147_483_647)', ['longValue - 32-bit value']], sdec_reg_array: [ - "SDEC_REG_ARRAY(reg_pointer, size)", - "Output COG register array as signed decimal values (-2_147_483_648 - 2_147_483_647)", - ["reg_pointer - address of array of COG registers", "size - count of registers in array"], + 'SDEC_REG_ARRAY(reg_pointer, size)', + 'Output COG register array as signed decimal values (-2_147_483_648 - 2_147_483_647)', + ['reg_pointer - address of array of COG registers', 'size - count of registers in array'] ], sdec_byte_array: [ - "SDEC_BYTE_ARRAY(hub_pointer, size)", - "Output hub BYTE array as signed decimal values (-128 - 127)", - ["hub_pointer - address of array of BYTEs in HUB ram", "size - count of BYTEs in array"], + 'SDEC_BYTE_ARRAY(hub_pointer, size)', + 'Output hub BYTE array as signed decimal values (-128 - 127)', + ['hub_pointer - address of array of BYTEs in HUB ram', 'size - count of BYTEs in array'] ], sdec_word_array: [ - "SDEC_WORD_ARRAY(hub_pointer, size)", - "Output hub WORD array as signed decimal value (-32_768 - 32_767)", - ["hub_pointer - address of array of WORDs in HUB ram", "size - count of WORDs in array"], + 'SDEC_WORD_ARRAY(hub_pointer, size)', + 'Output hub WORD array as signed decimal value (-32_768 - 32_767)', + ['hub_pointer - address of array of WORDs in HUB ram', 'size - count of WORDs in array'] ], sdec_long_array: [ - "SDEC_LONG_ARRAY(hub_pointer, size)", - "Output hub LONG array as signed decimal value (-2_147_483_648 - 2_147_483_647)", - ["hub_pointer - address of array of LONGs in HUB ram", "size - count of LONGs in array"], - ], + 'SDEC_LONG_ARRAY(hub_pointer, size)', + 'Output hub LONG array as signed decimal value (-2_147_483_648 - 2_147_483_647)', + ['hub_pointer - address of array of LONGs in HUB ram', 'size - count of LONGs in array'] + ] }; private _tableDebugMethodsUnsignedHex: { [Identifier: string]: TMethodTuple } = { - uhex: ["UHEX(value)", "Output as auto-sized unsigned hex value ($0 - $FFFF_FFFF)", ["value - BYTE, WORD or LONG value"]], - uhex_byte: ["UHEX_BYTE(byteValue)", "Output BYTE as unsigned hex value ($00 - $FF)", ["byteValue - 8-bit value"]], - uhex_word: ["UHEX_WORD(wordValue)", "Output WORD as unsigned hex value ($0000 - $FFFF)", ["wordValue - 16-bit value"]], - uhex_long: ["UHEX_LONG(longValue)", "Output LONG as unsigned hex value ($0000_0000 - $FFFF_FFFF)", ["longValue - 32-bit value"]], + uhex: ['UHEX(value)', 'Output as auto-sized unsigned hex value ($0 - $FFFF_FFFF)', ['value - BYTE, WORD or LONG value']], + uhex_byte: ['UHEX_BYTE(byteValue)', 'Output BYTE as unsigned hex value ($00 - $FF)', ['byteValue - 8-bit value']], + uhex_word: ['UHEX_WORD(wordValue)', 'Output WORD as unsigned hex value ($0000 - $FFFF)', ['wordValue - 16-bit value']], + uhex_long: ['UHEX_LONG(longValue)', 'Output LONG as unsigned hex value ($0000_0000 - $FFFF_FFFF)', ['longValue - 32-bit value']], uhex_reg_array: [ - "UHEX_REG_ARRAY(reg_pointer, size)", - "Output register array as unsigned hex values ($0000_0000 - $FFFF_FFFF)", - ["reg_pointer - address of array of COG registers", "size - count of registers in array"], + 'UHEX_REG_ARRAY(reg_pointer, size)', + 'Output register array as unsigned hex values ($0000_0000 - $FFFF_FFFF)', + ['reg_pointer - address of array of COG registers', 'size - count of registers in array'] ], uhex_byte_array: [ - "UHEX_BYTE_ARRAY(hub_pointer, size)", - "Output hub BYTE array as unsigned hex values ($00 - $FF)", - ["hub_pointer - address of array of BYTEs in HUB ram", "size - count of BYTEs in array"], + 'UHEX_BYTE_ARRAY(hub_pointer, size)', + 'Output hub BYTE array as unsigned hex values ($00 - $FF)', + ['hub_pointer - address of array of BYTEs in HUB ram', 'size - count of BYTEs in array'] ], uhex_word_array: [ - "UHEX_WORD_ARRAY(hub_pointer, size)", - "Output hub WORD array as unsigned hex values ($0000 - $FFFF)", - ["hub_pointer - address of array of WORDs in HUB ram", "size - count of WORDs in array"], + 'UHEX_WORD_ARRAY(hub_pointer, size)', + 'Output hub WORD array as unsigned hex values ($0000 - $FFFF)', + ['hub_pointer - address of array of WORDs in HUB ram', 'size - count of WORDs in array'] ], uhex_long_array: [ - "UHEX_LONG_ARRAY(hub_pointer, size)", - "Output hub LONG array as unsigned hex values ($0000_0000 - $FFFF_FFFF)", - ["hub_pointer - address of array of LONGs in HUB ram", "size - count of LONGs in array"], - ], + 'UHEX_LONG_ARRAY(hub_pointer, size)', + 'Output hub LONG array as unsigned hex values ($0000_0000 - $FFFF_FFFF)', + ['hub_pointer - address of array of LONGs in HUB ram', 'size - count of LONGs in array'] + ] }; private _tableDebugMethodsSignedHex: { [Identifier: string]: TMethodTuple } = { - shex: ["SHEX(value)", "Output as auto-sized signed hex value (-$8000_0000 - $7FFF_FFFF)", ["value - BYTE, WORD or LONG value"]], - shex_byte: ["SHEX_BYTE(byteValue)", "Output BYTE as signed hex value (-$80 - $7F)", ["byteValue - 8-bit value"]], - shex_word: ["SHEX_WORD(wordValue)", "Output WORD as signed hex value (-$8000 - $7FFF)", ["wordValue - 16-bit value"]], - shex_long: ["SHEX_LONG(longValue)", "Output LONG as signed hex value (-$8000_0000 - $7FFF_FFFF)", ["longValue - 32-bit value"]], + shex: ['SHEX(value)', 'Output as auto-sized signed hex value (-$8000_0000 - $7FFF_FFFF)', ['value - BYTE, WORD or LONG value']], + shex_byte: ['SHEX_BYTE(byteValue)', 'Output BYTE as signed hex value (-$80 - $7F)', ['byteValue - 8-bit value']], + shex_word: ['SHEX_WORD(wordValue)', 'Output WORD as signed hex value (-$8000 - $7FFF)', ['wordValue - 16-bit value']], + shex_long: ['SHEX_LONG(longValue)', 'Output LONG as signed hex value (-$8000_0000 - $7FFF_FFFF)', ['longValue - 32-bit value']], shex_reg_array: [ - "SHEX_REG_ARRAY(reg_pointer, size)", - "Output register array as signed hex values (-$8000_0000 - $7FFF_FFFF)", - ["reg_pointer - address of array of COG registers", "size - count of registers in array"], + 'SHEX_REG_ARRAY(reg_pointer, size)', + 'Output register array as signed hex values (-$8000_0000 - $7FFF_FFFF)', + ['reg_pointer - address of array of COG registers', 'size - count of registers in array'] ], shex_byte_array: [ - "SHEX_BYTE_ARRAY(hub_pointer, size)", - "Output hub BYTE array as signed hex values (-$80 - $7F)", - ["hub_pointer - address of array of BYTEs in HUB ram", "size - count of BYTEs in array"], + 'SHEX_BYTE_ARRAY(hub_pointer, size)', + 'Output hub BYTE array as signed hex values (-$80 - $7F)', + ['hub_pointer - address of array of BYTEs in HUB ram', 'size - count of BYTEs in array'] ], shex_word_array: [ - "SHEX_WORD_ARRAY(hub_pointer, size)", - "Output hub WORD array as signed hex values (-$8000 - $7FFF)", - ["hub_pointer - address of array of WORDs in HUB ram", "size - count of WORDs in array"], + 'SHEX_WORD_ARRAY(hub_pointer, size)', + 'Output hub WORD array as signed hex values (-$8000 - $7FFF)', + ['hub_pointer - address of array of WORDs in HUB ram', 'size - count of WORDs in array'] ], shex_long_array: [ - "SHEX_LONG_ARRAY(hub_pointer, size)", - "Output hub LONG array as signed hex values (-$8000_0000 - $7FFF_FFFF)", - ["hub_pointer - address of array of LONGs in HUB ram", "size - count of LONGs in array"], - ], + 'SHEX_LONG_ARRAY(hub_pointer, size)', + 'Output hub LONG array as signed hex values (-$8000_0000 - $7FFF_FFFF)', + ['hub_pointer - address of array of LONGs in HUB ram', 'size - count of LONGs in array'] + ] }; private _tableDebugMethodsUnsignedBin: { [Identifier: string]: TMethodTuple } = { - ubin: ["UBIN(value)", "Output as auto-sized unsigned binary value", ["value - BYTE, WORD or LONG value"]], - ubin_byte: ["UBIN_BYTE(byteValue)", "Output BYTE as unsigned binary value", ["byteValue - 8-bit value"]], - ubin_word: ["UBIN_WORD(wordValue)", "Output WORD as unsigned binary value", ["wordValue - 16-bit value"]], - ubin_long: ["UBIN_LONG(longValue)", "Output LONG as unsigned binary value", ["longValue - 32-bit value"]], - ubin_reg_array: ["UBIN_REG_ARRAY(reg_pointer, size)", "Output register array as unsigned binary values", ["reg_pointer - address of array of COG registers", "size - count of registers in array"]], + ubin: ['UBIN(value)', 'Output as auto-sized unsigned binary value', ['value - BYTE, WORD or LONG value']], + ubin_byte: ['UBIN_BYTE(byteValue)', 'Output BYTE as unsigned binary value', ['byteValue - 8-bit value']], + ubin_word: ['UBIN_WORD(wordValue)', 'Output WORD as unsigned binary value', ['wordValue - 16-bit value']], + ubin_long: ['UBIN_LONG(longValue)', 'Output LONG as unsigned binary value', ['longValue - 32-bit value']], + ubin_reg_array: [ + 'UBIN_REG_ARRAY(reg_pointer, size)', + 'Output register array as unsigned binary values', + ['reg_pointer - address of array of COG registers', 'size - count of registers in array'] + ], ubin_byte_array: [ - "UBIN_BYTE_ARRAY(hub_pointer, size)", - "Output hub BYTE array as unsigned binary values", - ["hub_pointer - address of array of BYTEs in HUB ram", "size - count of BYTEs in array"], + 'UBIN_BYTE_ARRAY(hub_pointer, size)', + 'Output hub BYTE array as unsigned binary values', + ['hub_pointer - address of array of BYTEs in HUB ram', 'size - count of BYTEs in array'] ], ubin_word_array: [ - "UBIN_WORD_ARRAY(hub_pointer, size)", - "Output hub WORD array as unsigned binary values", - ["hub_pointer - address of array of WORDs in HUB ram", "size - count of WORDs in array"], + 'UBIN_WORD_ARRAY(hub_pointer, size)', + 'Output hub WORD array as unsigned binary values', + ['hub_pointer - address of array of WORDs in HUB ram', 'size - count of WORDs in array'] ], ubin_long_array: [ - "UBIN_LONG_ARRAY(hub_pointer, size)", - "Output hub LONG array as unsigned binary values", - ["hub_pointer - address of array of LONGs in HUB ram", "size - count of LONGs in array"], - ], + 'UBIN_LONG_ARRAY(hub_pointer, size)', + 'Output hub LONG array as unsigned binary values', + ['hub_pointer - address of array of LONGs in HUB ram', 'size - count of LONGs in array'] + ] }; private _tableDebugMethodsSignedBin: { [Identifier: string]: TMethodTuple } = { - sbin: ["SBIN(value)", "Output as auto-sized signed binary value", ["value - BYTE, WORD or LONG value"]], - sbin_byte: ["SBIN_BYTE(byteValue)", "Output BYTE as signed binary value", ["byteValue - 8-bit value"]], - sbin_word: ["SBIN_WORD(wordValue)", "Output WORD as signed binary value", ["wordValue - 16-bit value"]], - sbin_long: ["SBIN_LONG(longValue)", "Output LONG as signed binary value", ["longValue - 32-bit value"]], - sbin_reg_array: ["SBIN_REG_ARRAY(reg_pointer, size)", "Output register array as signed binary values", ["reg_pointer - address of array of COG registers", "size - count of registers in array"]], - sbin_byte_array: ["SBIN_BYTE_ARRAY(hub_pointer, size)", "Output hub BYTE array as signed binary values", ["hub_pointer - address of array of BYTEs in HUB ram", "size - count of BYTEs in array"]], - sbin_word_array: ["SBIN_WORD_ARRAY(hub_pointer, size)", "Output hub WORD array as signed binary values", ["hub_pointer - address of array of WORDs in HUB ram", "size - count of WORDs in array"]], - sbin_long_array: ["SBIN_LONGARRAY(hub_pointer, size)", "Output hub LONG array as signed binary values", ["hub_pointer - address of array of LONGs in HUB ram", "size - count of LONGs in array"]], + sbin: ['SBIN(value)', 'Output as auto-sized signed binary value', ['value - BYTE, WORD or LONG value']], + sbin_byte: ['SBIN_BYTE(byteValue)', 'Output BYTE as signed binary value', ['byteValue - 8-bit value']], + sbin_word: ['SBIN_WORD(wordValue)', 'Output WORD as signed binary value', ['wordValue - 16-bit value']], + sbin_long: ['SBIN_LONG(longValue)', 'Output LONG as signed binary value', ['longValue - 32-bit value']], + sbin_reg_array: [ + 'SBIN_REG_ARRAY(reg_pointer, size)', + 'Output register array as signed binary values', + ['reg_pointer - address of array of COG registers', 'size - count of registers in array'] + ], + sbin_byte_array: [ + 'SBIN_BYTE_ARRAY(hub_pointer, size)', + 'Output hub BYTE array as signed binary values', + ['hub_pointer - address of array of BYTEs in HUB ram', 'size - count of BYTEs in array'] + ], + sbin_word_array: [ + 'SBIN_WORD_ARRAY(hub_pointer, size)', + 'Output hub WORD array as signed binary values', + ['hub_pointer - address of array of WORDs in HUB ram', 'size - count of WORDs in array'] + ], + sbin_long_array: [ + 'SBIN_LONGARRAY(hub_pointer, size)', + 'Output hub LONG array as signed binary values', + ['hub_pointer - address of array of LONGs in HUB ram', 'size - count of LONGs in array'] + ] }; private _tableDebugMethodsFloat: { [Identifier: string]: TMethodTuple } = { - fdec: ["FDEC(value)", "Output floating-point value (-3.4e+38 - 3.4e+38)", ["value - float 32-bit value"]], + fdec: ['FDEC(value)', 'Output floating-point value (-3.4e+38 - 3.4e+38)', ['value - float 32-bit value']], fdec_array: [ - "FDEC_ARRAY(hub_pointer, size)", - "Output hub long array as floating-point values (-3.4e+38 - 3.4e+38)", - ["hub_pointer - address of long array in HUB ram", "size - count of longs in the array"], + 'FDEC_ARRAY(hub_pointer, size)', + 'Output hub long array as floating-point values (-3.4e+38 - 3.4e+38)', + ['hub_pointer - address of long array in HUB ram', 'size - count of longs in the array'] ], fdec_reg_array: [ - "FDEC_REG_ARRAY(reg_pointer, size)", - "Output register array as floating-point values (-3.4e+38 - 3.4e+38)", - ["reg_pointer - address of register array in COG ram", "size - count of registers in the array"], - ], + 'FDEC_REG_ARRAY(reg_pointer, size)', + 'Output register array as floating-point values (-3.4e+38 - 3.4e+38)', + ['reg_pointer - address of register array in COG ram', 'size - count of registers in the array'] + ] }; private _tableDebugMethodsMisc: { [Identifier: string]: TMethodTuple } = { - dly: ["DLY(milliseconds)", "Delay for some milliseconds to slow down continuous message outputs for this cog", ["milliseconds - number of 1/1_000's of seconds to delay"]], + dly: [ + 'DLY(milliseconds)', + 'Delay for some milliseconds to slow down continuous message outputs for this cog', + ["milliseconds - number of 1/1_000's of seconds to delay"] + ], pc_key: [ - "PC_KEY(pointer_to_long)", - "FOR USE IN GRAPHICAL DEBUG() DISPLAYS - Must be the last command in a DEBUG() statement
Returns any new host-PC keypress that occurred within the last 100ms into a long inside the chip
The DEBUG() Display must have focus for keypresses to be noticed", - ["pointer_to_long - address to long to receive the pressed key-value"], + 'PC_KEY(pointer_to_long)', + 'FOR USE IN GRAPHICAL DEBUG() DISPLAYS - Must be the last command in a DEBUG() statement
Returns any new host-PC keypress that occurred within the last 100ms into a long inside the chip
The DEBUG() Display must have focus for keypresses to be noticed', + ['pointer_to_long - address to long to receive the pressed key-value'] ], pc_mouse: [ - "PC_MOUSE(pointer_to_7_longs)", - "FOR USE IN GRAPHICAL DEBUG DISPLAYS - Must be the last command in a DEBUG() statement
Returns the current host-PC mouse status into a 7-long structure inside the chip", - ["pointer_to_7_longs - address of the 7-long structure to receive the mouse status"], - ], + 'PC_MOUSE(pointer_to_7_longs)', + 'FOR USE IN GRAPHICAL DEBUG DISPLAYS - Must be the last command in a DEBUG() statement
Returns the current host-PC mouse status into a 7-long structure inside the chip', + ['pointer_to_7_longs - address of the 7-long structure to receive the mouse status'] + ] }; private _tableDebugMethodsConditionals: { [Identifier: string]: string[] } = { - if: ["IF(condition)", "If condition <> 0 then continue at the next command within the DEBUG() statement, else skip all remaining commands and output CR+LF."], - ifnot: ["IFNOT(condition)", "If condition = 0 then continue at the next command within the DEBUG() statement, else skip all remaining commands and output CR+LF."], + if: [ + 'IF(condition)', + 'If condition <> 0 then continue at the next command within the DEBUG() statement, else skip all remaining commands and output CR+LF.' + ], + ifnot: [ + 'IFNOT(condition)', + 'If condition = 0 then continue at the next command within the DEBUG() statement, else skip all remaining commands and output CR+LF.' + ] }; public isDebugMethod(name: string): boolean { - const bIsUnderscoreSuffix: boolean = name.endsWith("_") ? true : false; + const bIsUnderscoreSuffix: boolean = name.endsWith('_') ? true : false; const nameKey: string = bIsUnderscoreSuffix ? name.substring(0, name.length - 1).toLowerCase() : name.toLowerCase(); let reservedStatus: boolean = nameKey in this._tableDebugMethodsString; if (!reservedStatus) { @@ -1394,45 +1441,51 @@ export class Spin2ParseUtils { } private _docTextForSpinDebugBuiltInMethod(name: string): IBuiltinDescription { - const bIsUnderscoreSuffix: boolean = name.endsWith("_") ? true : false; + const bIsUnderscoreSuffix: boolean = name.endsWith('_') ? true : false; const nameKey: string = bIsUnderscoreSuffix ? name.substring(0, name.length - 1).toLowerCase() : name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; let bSupportsSuffix: boolean = true; if (this.isDebugMethod(name)) { desiredDocText.found = true; let protoWDescr: string[] = []; - let methodDescr: TMethodTuple = ["", "", []]; + let methodDescr: TMethodTuple = ['', '', []]; if (nameKey in this._tableDebugMethodsString) { - desiredDocText.category = "String Output"; + desiredDocText.category = 'String Output'; methodDescr = this._tableDebugMethodsString[nameKey]; } else if (nameKey in this._tableDebugMethodsUnsignedDec) { - desiredDocText.category = "Unsigned Decimal Output"; + desiredDocText.category = 'Unsigned Decimal Output'; methodDescr = this._tableDebugMethodsUnsignedDec[nameKey]; } else if (nameKey in this._tableDebugMethodsSignedDec) { - desiredDocText.category = "Signed Decimal Output"; + desiredDocText.category = 'Signed Decimal Output'; methodDescr = this._tableDebugMethodsSignedDec[nameKey]; } else if (nameKey in this._tableDebugMethodsUnsignedHex) { - desiredDocText.category = "Unsigned Hexedecimal Output"; + desiredDocText.category = 'Unsigned Hexedecimal Output'; methodDescr = this._tableDebugMethodsUnsignedHex[nameKey]; } else if (nameKey in this._tableDebugMethodsSignedHex) { - desiredDocText.category = "Signed Hexedecimal Output"; + desiredDocText.category = 'Signed Hexedecimal Output'; methodDescr = this._tableDebugMethodsSignedHex[nameKey]; } else if (nameKey in this._tableDebugMethodsUnsignedBin) { - desiredDocText.category = "Unsigned Binary Output"; + desiredDocText.category = 'Unsigned Binary Output'; methodDescr = this._tableDebugMethodsUnsignedBin[nameKey]; } else if (nameKey in this._tableDebugMethodsSignedBin) { - desiredDocText.category = "Signed Binary Output"; + desiredDocText.category = 'Signed Binary Output'; methodDescr = this._tableDebugMethodsSignedBin[nameKey]; } else if (nameKey in this._tableDebugMethodsFloat) { - desiredDocText.category = "Floating Point Output"; + desiredDocText.category = 'Floating Point Output'; methodDescr = this._tableDebugMethodsFloat[nameKey]; } else if (nameKey in this._tableDebugMethodsMisc) { bSupportsSuffix = false; - desiredDocText.category = "Miscellaneous"; + desiredDocText.category = 'Miscellaneous'; methodDescr = this._tableDebugMethodsMisc[nameKey]; } else if (nameKey in this._tableDebugMethodsConditionals) { bSupportsSuffix = false; - desiredDocText.category = "Conditionals"; + desiredDocText.category = 'Conditionals'; protoWDescr = this._tableDebugMethodsConditionals[nameKey]; } if (methodDescr[0].length > 0) { @@ -1448,14 +1501,14 @@ export class Spin2ParseUtils { if (protoWDescr.length != 0) { desiredDocText.signature = protoWDescr[0]; if (bIsUnderscoreSuffix) { - desiredDocText.description = protoWDescr[1] + "
*(Trailing underscore: removes the variable name from the output)*"; // italics + desiredDocText.description = protoWDescr[1] + '
*(Trailing underscore: removes the variable name from the output)*'; // italics } else { desiredDocText.description = protoWDescr[1]; } } } else if (bIsUnderscoreSuffix && !bSupportsSuffix) { desiredDocText.signature = protoWDescr[0]; - desiredDocText.description = protoWDescr[1] + "
**(WARNING Underscore Suffix is NOT allowed)**"; // bold + desiredDocText.description = protoWDescr[1] + '
**(WARNING Underscore Suffix is NOT allowed)**'; // bold } } return desiredDocText; @@ -1465,47 +1518,56 @@ export class Spin2ParseUtils { debug: "invoke this cog's PASM-level debugger", debug_main: 'each cog\'s PASM-level debugger will initially be invoked when a COGINIT occurs, and it will be ready to single-step through main (non-interrupt) code. In this case, DEBUG commands will be ignored, until you select "DEBUG" sensitivity in the debugger.', - debug_coginit: "each cog's PASM-level debugger will initially be invoked when a COGINIT occurs", + debug_coginit: "each cog's PASM-level debugger will initially be invoked when a COGINIT occurs" }; public isDebugInvocation(name: string): boolean { const nameKey: string = name.toLowerCase(); - let reservedStatus: boolean = nameKey in this._tableDebugInvokeSymbols; + const reservedStatus: boolean = nameKey in this._tableDebugInvokeSymbols; return reservedStatus; } private _tableDebugControlSymbols: { [Identifier: string]: string } = { - download_baud: "(default 2_000_000)
Sets the download baud rate", - debug_cogs: "(default %1111_1111)
Selects which cogs have debug interrupts enabled. Bits 7..0 enable debugging interrupts in cogs 7..0", - debug_delay: "(default 0)
Sets a delay in milliseconds before your application runs and begins transmitting DEBUG messages", - debug_pin_tx: "(default 62)
Sets the DEBUG serial output pin. For DEBUG windows to open, DEBUG_PIN must be 62", - debug_pin_rx: "(default 63)
Sets the DEBUG serial input pin for interactivity with the host PC", - debug_baud: "(default download_baud)
Sets the DEBUG baud rate. May be necessary to add DEBUG_DELAY if DEBUG_BAUD is less than DOWNLOAD_BAUD", - debug_timestamp: "By declaring this symbol, each DEBUG message will be time-stamped with the 64-bit CT value", - debug_log_size: "(default 0)
Sets the maximum size in bytes of the 'DEBUG.log' file which will collect DEBUG messages. A value of 0 will inhibit log file generation", - debug_left: "Sets the left screen coordinate where the DEBUG message window will appear", - debug_top: "Sets the top screen coordinate where the DEBUG message window will appear", - debug_width: "Sets the width of the DEBUG message window", - debug_height: "Sets the height of the DEBUG message window", - debug_display_left: "(default 0)
Sets the overall left screen offset where any DEBUG displays will appear (adds to 'POS' x coordinate in each DEBUG display)", - debug_display_top: "(default 0)
Sets the overall top screen offset where any DEBUG displays will appear (adds to 'POS' y coordinate in each DEBUG display)", - debug_windows_off: "(default 0)
Disables any DEBUG windows from opening after downloading, if set to a non-zero value", + download_baud: '(default 2_000_000)
Sets the download baud rate', + debug_cogs: '(default %1111_1111)
Selects which cogs have debug interrupts enabled. Bits 7..0 enable debugging interrupts in cogs 7..0', + debug_delay: '(default 0)
Sets a delay in milliseconds before your application runs and begins transmitting DEBUG messages', + debug_pin_tx: '(default 62)
Sets the DEBUG serial output pin. For DEBUG windows to open, DEBUG_PIN must be 62', + debug_pin_rx: '(default 63)
Sets the DEBUG serial input pin for interactivity with the host PC', + debug_baud: '(default download_baud)
Sets the DEBUG baud rate. May be necessary to add DEBUG_DELAY if DEBUG_BAUD is less than DOWNLOAD_BAUD', + debug_timestamp: 'By declaring this symbol, each DEBUG message will be time-stamped with the 64-bit CT value', + debug_log_size: + "(default 0)
Sets the maximum size in bytes of the 'DEBUG.log' file which will collect DEBUG messages. A value of 0 will inhibit log file generation", + debug_left: 'Sets the left screen coordinate where the DEBUG message window will appear', + debug_top: 'Sets the top screen coordinate where the DEBUG message window will appear', + debug_width: 'Sets the width of the DEBUG message window', + debug_height: 'Sets the height of the DEBUG message window', + debug_display_left: + "(default 0)
Sets the overall left screen offset where any DEBUG displays will appear (adds to 'POS' x coordinate in each DEBUG display)", + debug_display_top: + "(default 0)
Sets the overall top screen offset where any DEBUG displays will appear (adds to 'POS' y coordinate in each DEBUG display)", + debug_windows_off: '(default 0)
Disables any DEBUG windows from opening after downloading, if set to a non-zero value' }; public isDebugControlSymbol(name: string): boolean { const nameKey: string = name.toLowerCase(); - let reservedStatus: boolean = nameKey in this._tableDebugControlSymbols; + const reservedStatus: boolean = nameKey in this._tableDebugControlSymbols; return reservedStatus; } private _docTextForSpinDebugBuiltInSymbols(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (this.isDebugControlSymbol(nameKey)) { desiredDocText.found = true; - let protoWDescr: string[] = []; + //const protoWDescr: string[] = []; if (nameKey in this._tableDebugControlSymbols) { - desiredDocText.category = "Debug Symbol"; + desiredDocText.category = 'Debug Symbol'; desiredDocText.description = this._tableDebugControlSymbols[nameKey]; } } @@ -1514,12 +1576,18 @@ export class Spin2ParseUtils { private _docTextForSpinDebugBuiltInInvoke(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (this.isDebugInvocation(nameKey)) { desiredDocText.found = true; - let protoWDescr: string[] = []; + //const protoWDescr: string[] = []; if (nameKey in this._tableDebugInvokeSymbols) { - desiredDocText.category = "Debugger Invocation"; + desiredDocText.category = 'Debugger Invocation'; desiredDocText.description = this._tableDebugInvokeSymbols[nameKey]; } } @@ -1530,19 +1598,19 @@ export class Spin2ParseUtils { // MAYBE??: add signature forms for all but last 3, logicals private _tableSpinBinaryOperators: { [Identifier: string]: string } = { sar: "Shift x right by y bits, insert MSB's", - ror: "Rotate x right by y bits", - rol: "Rotate x left by y bits", - rev: "Reverse order of bits 0..y of x and zero-extend", - zerox: "Zero-extend above bit y", - signx: "Sign-extend from bit y", - sca: "Unsigned scale, (x * y) >> 32", - scas: "Signed scale, (x * y) >> 30", - frac: "Unsigned fraction, (x << 32) / y", - addbits: "Make bitfield, (x & $1F) | (y & $1F) << 5", - addpins: "Make pinfield, (x & $3F) | (y & $1F) << 6", - and: "Logical AND (x <> 0 AND y <> 0, returns FALSE (0) or TRUE (-1))", - or: "Logical OR (x <> 0 OR y <> 0, returns FALSE (0) or TRUE (-1))", - xor: "Logical XOR (x <> 0 XOR y <> 0, returns FALSE (0) or TRUE (-1))", + ror: 'Rotate x right by y bits', + rol: 'Rotate x left by y bits', + rev: 'Reverse order of bits 0..y of x and zero-extend', + zerox: 'Zero-extend above bit y', + signx: 'Sign-extend from bit y', + sca: 'Unsigned scale, (x * y) >> 32', + scas: 'Signed scale, (x * y) >> 30', + frac: 'Unsigned fraction, (x << 32) / y', + addbits: 'Make bitfield, (x & $1F) | (y & $1F) << 5', + addpins: 'Make pinfield, (x & $3F) | (y & $1F) << 6', + and: 'Logical AND (x <> 0 AND y <> 0, returns FALSE (0) or TRUE (-1))', + or: 'Logical OR (x <> 0 OR y <> 0, returns FALSE (0) or TRUE (-1))', + xor: 'Logical XOR (x <> 0 XOR y <> 0, returns FALSE (0) or TRUE (-1))' }; public isBinaryOperator(name: string): boolean { @@ -1552,17 +1620,17 @@ export class Spin2ParseUtils { } private _tableSpinUnaryOperators: { [Identifier: string]: string } = { - not: "Logical NOT (0 → -1, non-0 → 0)", - abs: "Absolute value", - fabs: "Floating-point absolute value (clears MSB)", - encod: "Encode MSB, 0..31", - decod: "Decode, 1 << (x & $1F)", - bmask: "Bitmask, (2 << (x & $1F)) - 1", + not: 'Logical NOT (0 → -1, non-0 → 0)', + abs: 'Absolute value', + fabs: 'Floating-point absolute value (clears MSB)', + encod: 'Encode MSB, 0..31', + decod: 'Decode, 1 << (x & $1F)', + bmask: 'Bitmask, (2 << (x & $1F)) - 1', ones: "Sum all '1' bits, 0..32", - sqrt: "Square root of unsigned value", - fsqrt: "Floating-point square root", + sqrt: 'Square root of unsigned value', + fsqrt: 'Floating-point square root', qlog: "Unsigned value to logarithm {5'whole, 27'fraction}", - qexp: "Logarithm to unsigned value", + qexp: 'Logarithm to unsigned value' }; public isUnaryOperator(name: string): boolean { @@ -1572,41 +1640,56 @@ export class Spin2ParseUtils { } private _tableSpinFloatConversions: { [Identifier: string]: TMethodTuple } = { - float: ["FLOAT(x): floatValue", "Convert integer x to float", ["x - integer value to be converted"], ["floatValue - x-value represented as float"]], - trunc: ["TRUNC(x): integerValue", "Convert float x to truncated integer", ["x - float value to be converted (remove all after decimal)"], ["integerValue - result of truncation operation"]], - round: ["ROUND(x): integerValue", "Convert float x to rounded integer", ["x - float value to be converted (round to nearest integer)"], ["integerValue - result of rounding operation"]], + float: [ + 'FLOAT(x): floatValue', + 'Convert integer x to float', + ['x - integer value to be converted'], + ['floatValue - x-value represented as float'] + ], + trunc: [ + 'TRUNC(x): integerValue', + 'Convert float x to truncated integer', + ['x - float value to be converted (remove all after decimal)'], + ['integerValue - result of truncation operation'] + ], + round: [ + 'ROUND(x): integerValue', + 'Convert float x to rounded integer', + ['x - float value to be converted (round to nearest integer)'], + ['integerValue - result of rounding operation'] + ] }; public isSpinReservedWord(name: string): boolean { const nameKey: string = name.toLowerCase(); const spinInstructionsOfNote: string[] = [ - "reg", - "field", - "nan", - "clkmode", - "clkfreq", - "varbase", - "clkmode_", - "clkfreq_", - "if", - "ifnot", - "elseif", - "elseifnot", - "else", - "while", - "repeat", - "with", - "until", - "from", - "to", - "step", - "next", - "quit", - "case", - "case_fast", - "other", - "abort", - "return", + 'reg', + 'field', + 'nan', + 'clkmode', + 'clkfreq', + 'varbase', + 'clkmode_', + 'clkfreq_', + 'if', + 'ifnot', + 'elseif', + 'elseifnot', + 'else', + 'while', + 'repeat', + 'with', + 'until', + 'from', + 'to', + 'step', + 'next', + 'quit', + 'case', + 'case_fast', + 'other', + 'abort', + 'return' ]; let reservedStatus: boolean = spinInstructionsOfNote.indexOf(nameKey) != -1; if (reservedStatus == false) { @@ -1626,54 +1709,54 @@ export class Spin2ParseUtils { public isSpinNumericSymbols(name: string): boolean { const nameKey: string = name.toLowerCase(); - let reservedStatus: boolean = nameKey in this._tableSpinNumericSymbols; + const reservedStatus: boolean = nameKey in this._tableSpinNumericSymbols; return reservedStatus; } private _tableSpinNumericSymbols: { [Identifier: string]: string } = { - false: "%0000_0000, Same as 0", - true: "%FFFF_FFFF, Same as -1", - negx: "%8000_0000, Negative-extreme integer, -2_147_483_648", - posx: "%7FFF_FFFF, ositive-extreme integer, +2_147_483_647 ($7FFF_FFFF)", - pi: "%4049_0FDB, Single-precision floating-point value of Pi, 3.14159265", + false: '%0000_0000, Same as 0', + true: '%FFFF_FFFF, Same as -1', + negx: '%8000_0000, Negative-extreme integer, -2_147_483_648', + posx: '%7FFF_FFFF, ositive-extreme integer, +2_147_483_647 ($7FFF_FFFF)', + pi: '%4049_0FDB, Single-precision floating-point value of Pi, 3.14159265' }; private _tableSpinCoginitSymbols: { [Identifier: string]: string } = { cogexec: '%00_0000, (default) Use "COGEXEC + CogNumber" to start a cog in cogexec mode', hubexec: '%10_0000, Use "HUBEXEC + CogNumber" to start a cog in hubexec mode', - cogexec_new: "%01_0000, Starts an available cog in cogexec mode", - hubexec_new: "%11_0000, Starts an available cog in hubexec mode", - cogexec_new_pair: "%01_0001, Starts an available eve/odd pair of cogs in cogexec mode, useful for LUT sharing", - hubexec_new_pair: "%11_0001, Starts an available eve/odd pair of cogs in hubexec mode, useful for LUT sharing", + cogexec_new: '%01_0000, Starts an available cog in cogexec mode', + hubexec_new: '%11_0000, Starts an available cog in hubexec mode', + cogexec_new_pair: '%01_0001, Starts an available eve/odd pair of cogs in cogexec mode, useful for LUT sharing', + hubexec_new_pair: '%11_0001, Starts an available eve/odd pair of cogs in hubexec mode, useful for LUT sharing' }; private _tableSpinCogexecSymbols: { [Identifier: string]: string } = { - newcog: "%01_0000, Starts an available cog", + newcog: '%01_0000, Starts an available cog' }; private _tableSpinMethodPointerSymbols: { [Identifier: string]: TMethodTuple } = { send: [ - "SEND(userParam)", - "SEND() is a special method pointer which is inherited from the calling method and, in turn, conveyed to all called methods. Must point to a method which takes one parameter and has no return values", - ["userParam - single value or list of values passed to pointed to method"], + 'SEND(userParam)', + 'SEND() is a special method pointer which is inherited from the calling method and, in turn, conveyed to all called methods. Must point to a method which takes one parameter and has no return values', + ['userParam - single value or list of values passed to pointed to method'] ], recv: [ - "RECV(): returnValue", - "RECV(), like SEND(), is a special method pointer which is inherited from the calling method and, in turn, conveyed to all called methods. Must point to a method which takes no parameters and returns a single value", + 'RECV(): returnValue', + 'RECV(), like SEND(), is a special method pointer which is inherited from the calling method and, in turn, conveyed to all called methods. Must point to a method which takes no parameters and returns a single value', [], - ["returnValue - single value returned from pointed to method"], - ], + ['returnValue - single value returned from pointed to method'] + ] }; public isSpinSpecialMethod(name: string): boolean { const nameKey: string = name.toLowerCase(); - let reservedStatus: boolean = nameKey in this._tableSpinMethodPointerSymbols; + const reservedStatus: boolean = nameKey in this._tableSpinMethodPointerSymbols; return reservedStatus; } public isSpinNoparenMethod(name: string): boolean { const nameKey: string = name.toLowerCase(); - let reservedStatus: boolean = nameKey in this._tableSpinMethodPointerSymbols && nameKey == "recv"; // recv of [send, recv] + let reservedStatus: boolean = nameKey in this._tableSpinMethodPointerSymbols && nameKey == 'recv'; // recv of [send, recv] if (!reservedStatus) { reservedStatus = nameKey in this._tableSpinControlFlowMethods; // abort, return } @@ -1682,21 +1765,27 @@ export class Spin2ParseUtils { private _docTextForCogAndNumericSymbols(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; - let methodDescr: TMethodTuple = ["", "", []]; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; + let methodDescr: TMethodTuple = ['', '', []]; if (this.isCoginitReservedSymbol(name)) { if (nameKey in this._tableSpinCoginitSymbols) { - desiredDocText.category = "Coginit"; + desiredDocText.category = 'Coginit'; desiredDocText.description = this._tableSpinCoginitSymbols[nameKey]; } else if (nameKey in this._tableSpinCogexecSymbols) { - desiredDocText.category = "Cogexec"; + desiredDocText.category = 'Cogexec'; desiredDocText.description = this._tableSpinCogexecSymbols[nameKey]; } } else if (nameKey in this._tableSpinNumericSymbols) { - desiredDocText.category = "Numeric"; + desiredDocText.category = 'Numeric'; desiredDocText.description = this._tableSpinNumericSymbols[nameKey]; } else if (nameKey in this._tableSpinMethodPointerSymbols) { - desiredDocText.category = "Method Pointer"; + desiredDocText.category = 'Method Pointer'; methodDescr = this._tableSpinMethodPointerSymbols[nameKey]; } if (methodDescr[0].length != 0) { @@ -1725,45 +1814,45 @@ export class Spin2ParseUtils { } public isFloatConversion(name: string): boolean { - const floatConversionOfNote: string[] = ["float", "round", "trunc"]; + const floatConversionOfNote: string[] = ['float', 'round', 'trunc']; const reservedStatus: boolean = floatConversionOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isP2AsmModczOperand(name: string): boolean { const pasmModczOperand: string[] = [ - "_clr", - "_nc_and_nz", - "_nz_and_nc", - " _gt", - "_nc_and_z", - "_z_and_nc", - "_nc", - "_ge", - "_c_and_nz", - "_nz_and_c", - "_nz", - "_ne", - "_c_ne_z", - "_z_ne_c", - "_nc_or_nz", - "_nz_or_nc", - "_c_and_z", - "_z_and_c", - "_c_eq_z", - "_z_eq_c", - "_z", - "_e", - "_nc_or_z", - "_z_or_nc", - "_c", - "_lt", - "_c_or_nz", - "_nz_or_c", - "_c_or_z", - "_z_or_c", - "_le", - "_set", + '_clr', + '_nc_and_nz', + '_nz_and_nc', + ' _gt', + '_nc_and_z', + '_z_and_nc', + '_nc', + '_ge', + '_c_and_nz', + '_nz_and_c', + '_nz', + '_ne', + '_c_ne_z', + '_z_ne_c', + '_nc_or_nz', + '_nz_or_nc', + '_c_and_z', + '_z_and_c', + '_c_eq_z', + '_z_eq_c', + '_z', + '_e', + '_nc_or_z', + '_z_or_nc', + '_c', + '_lt', + '_c_or_nz', + '_nz_or_c', + '_c_or_z', + '_z_or_c', + '_le', + '_set' ]; const reservedStatus: boolean = pasmModczOperand.indexOf(name.toLowerCase()) != -1; return reservedStatus; @@ -1773,318 +1862,469 @@ export class Spin2ParseUtils { // Built-in SPIN methods P2 // private _tableSpinHubMethods: { [Identifier: string]: TMethodTuple } = { - hubset: ["HUBSET(Value)", "Set HUB configuration to Value, or reset the Propeller", ["Value - hub configuration value"]], - clkset: ["CLKSET(NewCLKMODE, NewCLKFREQ)", "Safely establish new clock settings, updates CLKMODE and CLKFREQ", ["NewCLKMODE - desired clock mode value", "NewCLKFREQ - desired clock frequency"]], + hubset: ['HUBSET(Value)', 'Set HUB configuration to Value, or reset the Propeller', ['Value - hub configuration value']], + clkset: [ + 'CLKSET(NewCLKMODE, NewCLKFREQ)', + 'Safely establish new clock settings, updates CLKMODE and CLKFREQ', + ['NewCLKMODE - desired clock mode value', 'NewCLKFREQ - desired clock frequency'] + ], cogspin: [ - "COGSPIN(CogNum, Method({Pars}), StkAddr)[ : CogId]", + 'COGSPIN(CogNum, Method({Pars}), StkAddr)[ : CogId]', "Start Spin2 method in a cog, returns cog's ID if used as an expression element, -1 = no cog free", - ["CogNum - id of COG to be started (or NEWCOG for next available)", "Method({Pars}) - method (with parameters) to be run in cog", "StkAddr - Address of memory to be used as stack"], - ["CogId - cog's ID if used as an expression element, -1 = no cog free"], + [ + 'CogNum - id of COG to be started (or NEWCOG for next available)', + 'Method({Pars}) - method (with parameters) to be run in cog', + 'StkAddr - Address of memory to be used as stack' + ], + ["CogId - cog's ID if used as an expression element, -1 = no cog free"] ], coginit: [ - "COGINIT(CogNum, PASMaddr, PTRAvalue)[ : CogId]", + 'COGINIT(CogNum, PASMaddr, PTRAvalue)[ : CogId]', "Start PASM code in a cog, returns cog's ID if used as an expression element, -1 = no cog free", - ["CogNum - COG id of cog to be started and/or COGINIT Symbol (e.g., COGEXEC_NEW)", "PASMaddr - Address of p2asm code to be run in COG", "PTRAvalue - value to be passed to new COG a startup"], - ["CogId - cog's ID if used as an expression element, -1 = no cog free"], - ], - cogstop: ["COGSTOP(CogNum)", "Stop cog CogNum", ["CogNum - id of COG to be stopped"]], - cogid: ["COGID() : CogNum", "Get this cog's ID", [], ["CogNum - ID of currently running COG"]], - cogchk: ["COGCHK(CogNum) : Running", "Check if COG CogNum is running", ["CogNum - id of COG to be checked"], ["Running - TRUE (-1) if running or FALSE (0) if not"]], - locknew: ["LOCKNEW() : LockNum", "Check out a new LOCK from inventory", [], ["LockNum - 0..15 if successful or < 0 if no LOCK available"]], - lockret: ["LOCKRET(LockNum)", "Return a LOCK to inventory", ["LockNum - [0-15] id of the lock to be returned"]], + [ + 'CogNum - COG id of cog to be started and/or COGINIT Symbol (e.g., COGEXEC_NEW)', + 'PASMaddr - Address of p2asm code to be run in COG', + 'PTRAvalue - value to be passed to new COG a startup' + ], + ["CogId - cog's ID if used as an expression element, -1 = no cog free"] + ], + cogstop: ['COGSTOP(CogNum)', 'Stop cog CogNum', ['CogNum - id of COG to be stopped']], + cogid: ['COGID() : CogNum', "Get this cog's ID", [], ['CogNum - ID of currently running COG']], + cogchk: [ + 'COGCHK(CogNum) : Running', + 'Check if COG CogNum is running', + ['CogNum - id of COG to be checked'], + ['Running - TRUE (-1) if running or FALSE (0) if not'] + ], + locknew: ['LOCKNEW() : LockNum', 'Check out a new LOCK from inventory', [], ['LockNum - 0..15 if successful or < 0 if no LOCK available']], + lockret: ['LOCKRET(LockNum)', 'Return a LOCK to inventory', ['LockNum - [0-15] id of the lock to be returned']], locktry: [ - "LOCKTRY(LockNum) : LockState", - "Try to capture a LOCK", - ["LockNum - [0-15] id of the lock to capture"], - ["LockState - TRUE (-1) if successful or FALSE (0) if another cog has captured the LOCK."], + 'LOCKTRY(LockNum) : LockState', + 'Try to capture a LOCK', + ['LockNum - [0-15] id of the lock to capture'], + ['LockState - TRUE (-1) if successful or FALSE (0) if another cog has captured the LOCK.'] ], - lockrel: ["LOCKREL(LockNum)", "Release a LOCK", ["LockNum - [0-15] id of the lock to release"]], + lockrel: ['LOCKREL(LockNum)', 'Release a LOCK', ['LockNum - [0-15] id of the lock to release']], lockchk: [ - "LOCKCHK(LockNum) : LockState", + 'LOCKCHK(LockNum) : LockState', "Check a certain LOCK's state", - ["LockNum - [0-15] id of the lock to check"], - ["LockState - LockState[31] = captured, LockState[3:0] = current or last owner cog"], + ['LockNum - [0-15] id of the lock to check'], + ['LockState - LockState[31] = captured, LockState[3:0] = current or last owner cog'] ], - cogatn: ["COGATN(CogMask)", "Strobe ATN input(s) of cog(s) according to 16-bit CogMask", ["CogMask - [0-15] bitmask list of cogs to be Strobed"]], - pollatn: ["POLLATN() : AtnFlag", "Check if this cog has received an ATN strobe", [], ["AtnFlag - is TRUE (-1) if ATN strobed or FALSE (0) if not strobed"]], - waitatn: ["WAITATN()", "Wait for this cog to receive an ATN strobe", []], + cogatn: ['COGATN(CogMask)', 'Strobe ATN input(s) of cog(s) according to 16-bit CogMask', ['CogMask - [0-15] bitmask list of cogs to be Strobed']], + pollatn: [ + 'POLLATN() : AtnFlag', + 'Check if this cog has received an ATN strobe', + [], + ['AtnFlag - is TRUE (-1) if ATN strobed or FALSE (0) if not strobed'] + ], + waitatn: ['WAITATN()', 'Wait for this cog to receive an ATN strobe', []] }; private _tableSpinPinMethods: { [Identifier: string]: TMethodTuple } = { // key: [ signature, description, ["param1 - descr", "param2 - descr", "..."], ["return1 - descr", "return2 - descr", "..."] ] pinw: [ - "PINW(PinField, Data)", - "Drive PinField pin(s) with Data
(same as PINWRITE(PinField, Data)", - ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)", "Data - bit values to write, ea. bit in same position as each active pin in `PinField`"], + 'PINW(PinField, Data)', + 'Drive PinField pin(s) with Data
(same as PINWRITE(PinField, Data)', + [ + 'PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)', + 'Data - bit values to write, ea. bit in same position as each active pin in `PinField`' + ] ], pinwrite: [ - "PINWRITE(PinField, Data)", - "Drive PinField pin(s) with Data
(same as PINW(PinField, Data)", - ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)", "Data - bit values to write, ea. bit in same position as each active pin in `PinField`"], + 'PINWRITE(PinField, Data)', + 'Drive PinField pin(s) with Data
(same as PINW(PinField, Data)', + [ + 'PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)', + 'Data - bit values to write, ea. bit in same position as each active pin in `PinField`' + ] ], pinr: [ - "PINR(PinField) : PinStates : PinStates", - "Read PinField pin(s)
(same as PINREAD(PinField) : PinStates)", - ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"], - ["PinStates - bit values read, one bit in same position as each active pin in `PinField`"], + 'PINR(PinField) : PinStates : PinStates', + 'Read PinField pin(s)
(same as PINREAD(PinField) : PinStates)', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'], + ['PinStates - bit values read, one bit in same position as each active pin in `PinField`'] ], pinread: [ - "PINREAD(PinField) : PinStates", - "Read PinField pin(s)
(same as PINR(PinField) : PinStates)", - ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"], - ["PinStates - bit values read, one bit in same position as each active pin in `PinField`"], - ], - pinl: ["PINL(PinField)", "Drive PinField pin(s) low
(same as PINLOW(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], - pinlow: ["PINLOW(PinField)", "Drive PinField pin(s) low
(same as PINL(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], - pinh: ["PINH(PinField)", "Drive PinField pin(s) high
(same as PINHIGH(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], - pinhigh: ["PINHIGH(PinField)", "Drive PinField pin(s) high
(same as PINH(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], - pint: ["PINT(PinField)", "Drive and toggle PinField pin(s)
(same as PINTOGGLE(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], - pintoggle: ["PINTOGGLE(PinField)", "Drive and toggle PinField pin(s)
(same as PINT(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], - pinf: ["PINF(PinField)", "Float PinField pin(s)
(same as PINFLOAT(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], - pinfloat: ["PINFLOAT(PinField)", "Float PinField pin(s)
(same as PINF(PinField))", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], + 'PINREAD(PinField) : PinStates', + 'Read PinField pin(s)
(same as PINR(PinField) : PinStates)', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'], + ['PinStates - bit values read, one bit in same position as each active pin in `PinField`'] + ], + pinl: [ + 'PINL(PinField)', + 'Drive PinField pin(s) low
(same as PINLOW(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], + pinlow: [ + 'PINLOW(PinField)', + 'Drive PinField pin(s) low
(same as PINL(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], + pinh: [ + 'PINH(PinField)', + 'Drive PinField pin(s) high
(same as PINHIGH(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], + pinhigh: [ + 'PINHIGH(PinField)', + 'Drive PinField pin(s) high
(same as PINH(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], + pint: [ + 'PINT(PinField)', + 'Drive and toggle PinField pin(s)
(same as PINTOGGLE(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], + pintoggle: [ + 'PINTOGGLE(PinField)', + 'Drive and toggle PinField pin(s)
(same as PINT(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], + pinf: [ + 'PINF(PinField)', + 'Float PinField pin(s)
(same as PINFLOAT(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], + pinfloat: [ + 'PINFLOAT(PinField)', + 'Float PinField pin(s)
(same as PINF(PinField))', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] + ], pinstart: [ - "PINSTART(PinField, Mode, Xval, Yval)", - "Start PinField smart pin(s): DIR=0, then WRPIN=Mode, WXPIN=Xval, WYPIN=Yval, then DIR=1", + 'PINSTART(PinField, Mode, Xval, Yval)', + 'Start PinField smart pin(s): DIR=0, then WRPIN=Mode, WXPIN=Xval, WYPIN=Yval, then DIR=1', [ - "PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)", - "Mode - mode bits for selected smart pin(s)", - "XVal - initial value for X register of selected smart pin(s)", - "YVal - initial value for Y register of selected smart pin(s)", - ], + 'PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)', + 'Mode - mode bits for selected smart pin(s)', + 'XVal - initial value for X register of selected smart pin(s)', + 'YVal - initial value for Y register of selected smart pin(s)' + ] + ], + pinclear: [ + 'PINCLEAR(PinField)', + 'Clear PinField smart pin(s): DIR=0, then WRPIN=0', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] ], - pinclear: ["PINCLEAR(PinField)", "Clear PinField smart pin(s): DIR=0, then WRPIN=0", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], wrpin: [ - "WRPIN(PinField, Data)", + 'WRPIN(PinField, Data)', "Write 'mode' register(s) of PinField smart pin(s) with Data", - ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)", "Data - mode bits for selected smart pin(s)"], + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)', 'Data - mode bits for selected smart pin(s)'] ], wxpin: [ - "WXPIN(PinField, Data)", + 'WXPIN(PinField, Data)', "Write 'X' register(s) of PinField smart pin(s) with Data", - ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)", "Data - initial value for X register of selected smart pin(s)"], + [ + 'PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)', + 'Data - initial value for X register of selected smart pin(s)' + ] ], wypin: [ - "WYPIN(PinField, Data)", + 'WYPIN(PinField, Data)', "Write 'Y' register(s) of PinField smart pin(s) with Data", - ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)", "Data - initial value for Y register of selected smart pin(s)"], + [ + 'PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)', + 'Data - initial value for Y register of selected smart pin(s)' + ] + ], + akpin: [ + 'AKPIN(PinField)', + 'Acknowledge PinField smart pin(s)', + ['PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)'] ], - akpin: ["AKPIN(PinField)", "Acknowledge PinField smart pin(s)", ["PinField - selects one or more pins within same 32-bit block (P0-P31 or P32-P63)"]], rdpin: [ - "RDPIN(Pin) : Zval", - "Read Pin smart pin and acknowledge
NOTE: this read overwrites zval[31] with the c flag value, but this does not interfere with expected data", - ["Pin - a single smart pin (P0-P63)"], - ["Zval - Zval[31] = C flag from RQPIN, other bits are RQPIN data"], + 'RDPIN(Pin) : Zval', + 'Read Pin smart pin and acknowledge
NOTE: this read overwrites zval[31] with the c flag value, but this does not interfere with expected data', + ['Pin - a single smart pin (P0-P63)'], + ['Zval - Zval[31] = C flag from RQPIN, other bits are RQPIN data'] ], rqpin: [ - "RQPIN(Pin) : Zval", - "Read Pin smart pin without acknowledge
NOTE: this read overwrites zval[31] with the c flag value, but this does not interfere with expected data", - ["Pin - a single smart pin (P0-P63)"], - ["Zval - Zval[31] = C flag from RQPIN, other bits are RQPIN data"], - ], + 'RQPIN(Pin) : Zval', + 'Read Pin smart pin without acknowledge
NOTE: this read overwrites zval[31] with the c flag value, but this does not interfere with expected data', + ['Pin - a single smart pin (P0-P63)'], + ['Zval - Zval[31] = C flag from RQPIN, other bits are RQPIN data'] + ] }; private _tableSpinTimingMethods: { [Identifier: string]: TMethodTuple } = { - getct: ["GETCT() : Count", "Get 32-bit system counter", [], ["Count - the current 32-bit system counter value"]], - pollct: ["POLLCT(Tick) : Past", "Check if system counter has gone past 'Tick'", ["Tick - a 32-bit counter check value"], ["Past - returns TRUE (-1) if past or FALSE (0) if not"]], - waitct: ["WAITCT(Tick)", "Wait for system counter to get past 'Tick'", ["Tick - 32-bit counter value"]], - waitus: ["WAITUS(Microseconds)", "Wait Microseconds, uses CLKFREQ, duration must not exceed $8000_0000 clocks", ["Microseconds - number of 1/1_000_000's of a second to wait"]], - waitms: ["WAITMS(Milliseconds)", "Wait Milliseconds, uses CLKFREQ, duration must not exceed $8000_0000 clocks", ["Milliseconds - number of 1/1_000's of a second to wait"]], - getsec: ["GETSEC() : Seconds", "Get seconds since booting, uses 64-bit system counter and CLKFREQ, rolls over every 136 years", [], ["Seconds - seconds since boot"]], - getms: ["GETMS() : Milliseconds", "Get milliseconds since booting, uses 64-bit system counter and CLKFREQ, rolls over every 49.7 days", [], ["Milliseconds - milliseconds since boot"]], + getct: ['GETCT() : Count', 'Get 32-bit system counter', [], ['Count - the current 32-bit system counter value']], + pollct: [ + 'POLLCT(Tick) : Past', + "Check if system counter has gone past 'Tick'", + ['Tick - a 32-bit counter check value'], + ['Past - returns TRUE (-1) if past or FALSE (0) if not'] + ], + waitct: ['WAITCT(Tick)', "Wait for system counter to get past 'Tick'", ['Tick - 32-bit counter value']], + waitus: [ + 'WAITUS(Microseconds)', + 'Wait Microseconds, uses CLKFREQ, duration must not exceed $8000_0000 clocks', + ["Microseconds - number of 1/1_000_000's of a second to wait"] + ], + waitms: [ + 'WAITMS(Milliseconds)', + 'Wait Milliseconds, uses CLKFREQ, duration must not exceed $8000_0000 clocks', + ["Milliseconds - number of 1/1_000's of a second to wait"] + ], + getsec: [ + 'GETSEC() : Seconds', + 'Get seconds since booting, uses 64-bit system counter and CLKFREQ, rolls over every 136 years', + [], + ['Seconds - seconds since boot'] + ], + getms: [ + 'GETMS() : Milliseconds', + 'Get milliseconds since booting, uses 64-bit system counter and CLKFREQ, rolls over every 49.7 days', + [], + ['Milliseconds - milliseconds since boot'] + ] }; private _tablePAsmInterfaceMethods: { [Identifier: string]: TMethodTuple } = { call: [ - "CALL(RegisterOrHubAddr)", - "CALL PASM code at Addr, PASM code should avoid registers $130..$1D7 and LUT", - ["RegisterOrHubAddr - address of COG register containing instruction to be executed"], + 'CALL(RegisterOrHubAddr)', + 'CALL PASM code at Addr, PASM code should avoid registers $130..$1D7 and LUT', + ['RegisterOrHubAddr - address of COG register containing instruction to be executed'] ], regexec: [ - "REGEXEC(HubAddr)", - "Load a self-defined chunk of PASM code from HubAddr into COG registers and CALL it", - ["HubAddr - address of chunk which is preceded with two words which provide the starting register and the number of registers (longs) to load, minus 1"], + 'REGEXEC(HubAddr)', + 'Load a self-defined chunk of PASM code from HubAddr into COG registers and CALL it', + [ + 'HubAddr - address of chunk which is preceded with two words which provide the starting register and the number of registers (longs) to load, minus 1' + ] ], regload: [ - "REGLOAD(HubAddr)", - "Load a self-defined chunk of PASM code or data from HubAddr into registers", - ["HubAddr - address of chunk which is preceded with two words which provide the starting register and the number of registers (longs) to load, minus 1"], - ], + 'REGLOAD(HubAddr)', + 'Load a self-defined chunk of PASM code or data from HubAddr into registers', + [ + 'HubAddr - address of chunk which is preceded with two words which provide the starting register and the number of registers (longs) to load, minus 1' + ] + ] }; private _tableSpinMathMethods: { [Identifier: string]: TMethodTuple } = { rotxy: [ - "ROTXY(x, y, angle32bit) : rotx, roty", - "Rotate (x,y) by angle32bit and return rotated (x,y)", - ["x - horizontal coordinate", "y - vertical coordinate", "angle32bit - unsigned 32-bit angle, where $00000000..$FFFFFFFF = 0..359.9999999 degrees"], - ["x - x rotated by angle32bit", "y - y rotated by angle32bit"], + 'ROTXY(x, y, angle32bit) : rotx, roty', + 'Rotate (x,y) by angle32bit and return rotated (x,y)', + [ + 'x - horizontal coordinate', + 'y - vertical coordinate', + 'angle32bit - unsigned 32-bit angle, where $00000000..$FFFFFFFF = 0..359.9999999 degrees' + ], + ['x - x rotated by angle32bit', 'y - y rotated by angle32bit'] ], polxy: [ - "POLXY(length, angle32bit) : x, y", - "Convert (length,angle32bit) to (x,y)", - ["length - integer distance from 0,0", "angle32bit - unsigned 32-bit angle, where $00000000..$FFFFFFFF = 0..359.9999999 degrees"], - ["x - resulting X", "y - resulting Y"], + 'POLXY(length, angle32bit) : x, y', + 'Convert (length,angle32bit) to (x,y)', + ['length - integer distance from 0,0', 'angle32bit - unsigned 32-bit angle, where $00000000..$FFFFFFFF = 0..359.9999999 degrees'], + ['x - resulting X', 'y - resulting Y'] ], xypol: [ - "XYPOL(x, y) : length, angle32bit", - "Convert (x,y) to (length,angle32bit)", - ["x - horizontal coordinate", "y - vertical coordinate"], - ["length - integer distance from 0,0", "angle32bit - unsigned 32-bit angle, where $00000000..$FFFFFFFF = 0..359.9999999 degrees"], + 'XYPOL(x, y) : length, angle32bit', + 'Convert (x,y) to (length,angle32bit)', + ['x - horizontal coordinate', 'y - vertical coordinate'], + ['length - integer distance from 0,0', 'angle32bit - unsigned 32-bit angle, where $00000000..$FFFFFFFF = 0..359.9999999 degrees'] ], qsin: [ - "QSIN(length, step, stepsInCircle) : y", - "Rotate (length,0) by (step / stepsInCircle) * 2Pi and return y.", + 'QSIN(length, step, stepsInCircle) : y', + 'Rotate (length,0) by (step / stepsInCircle) * 2Pi and return y.', [ - "length - integer distance from 0,0", - "step - is the positon on the circle in terms of stepsInCircle", - "stepsInCircle - unsigned number of steps around the circle. Use 0 for stepsInCircle = $1_0000_0000", + 'length - integer distance from 0,0', + 'step - is the positon on the circle in terms of stepsInCircle', + 'stepsInCircle - unsigned number of steps around the circle. Use 0 for stepsInCircle = $1_0000_0000' ], - ["y - computed Y value from rotation"], + ['y - computed Y value from rotation'] ], qcos: [ - "QCOS(length, step, stepsInCircle) : x", - "Rotate (length, 0) by (step / stepsInCircle) * 2Pi and return x", + 'QCOS(length, step, stepsInCircle) : x', + 'Rotate (length, 0) by (step / stepsInCircle) * 2Pi and return x', [ - "length - integer distance from 0,0", - "step - is the positon on the circle in terms of stepsInCircle", - "stepsInCircle - unsigned number of steps around the circle. Use 0 for stepsInCircle = $1_0000_0000", + 'length - integer distance from 0,0', + 'step - is the positon on the circle in terms of stepsInCircle', + 'stepsInCircle - unsigned number of steps around the circle. Use 0 for stepsInCircle = $1_0000_0000' ], - ["x - computed X value from rotation"], + ['x - computed X value from rotation'] ], muldiv64: [ - "MULDIV64(mult1,mult2,divisor) : quotient", + 'MULDIV64(mult1,mult2,divisor) : quotient', "Divide the 64-bit product of 'mult1' and 'mult2' by 'divisor', return quotient (unsigned operation)", - ["mult1 - the 32-bit multiplicand", "mult2 - the 32-bit multiplier", "divisor - the 32-bit value to divide by"], - ["quotient - 32-bit result of multiply followed by divide"], + ['mult1 - the 32-bit multiplicand', 'mult2 - the 32-bit multiplier', 'divisor - the 32-bit value to divide by'], + ['quotient - 32-bit result of multiply followed by divide'] ], - getrnd: ["GETRND() : rnd", "Get random long (from xoroshiro128** pseudo-random number generator, seeded on boot with thermal noise from ADC)", [], ["rnd - a random 32-bit integer"]], - nan: [ - "NAN(float) : NotANumber", - "Determine if a floating-point value is not a number", - ["float - floating point number to be evaluated"], - ["NotANumber - returns TRUE (-1) if number or FALSE (0) if not"], + getrnd: [ + 'GETRND() : rnd', + 'Get random long (from xoroshiro128** pseudo-random number generator, seeded on boot with thermal noise from ADC)', + [], + ['rnd - a random 32-bit integer'] ], + nan: [ + 'NAN(float) : NotANumber', + 'Determine if a floating-point value is not a number', + ['float - floating point number to be evaluated'], + ['NotANumber - returns TRUE (-1) if number or FALSE (0) if not'] + ] }; private _tableSpinMemoryMethods: { [Identifier: string]: TMethodTuple } = { getregs: [ - "GETREGS(HubAddr, CogAddr, Count)", - "Move Count registers at CogAddr to longs at HubAddr", - ["HubAddr - address of HUB long array to receive values", "CogAddr - address of COG register array to be copied", "Count - number of registers to be copied"], + 'GETREGS(HubAddr, CogAddr, Count)', + 'Move Count registers at CogAddr to longs at HubAddr', + [ + 'HubAddr - address of HUB long array to receive values', + 'CogAddr - address of COG register array to be copied', + 'Count - number of registers to be copied' + ] ], setregs: [ - "SETREGS(HubAddr, CogAddr, Count)", - "Move Count longs at HubAddr to registers at CogAddr", - ["HubAddr - address of HUB long array to be copied", "CogAddr - address of COG register array to receive values", "Count - number of registers to be copied"], + 'SETREGS(HubAddr, CogAddr, Count)', + 'Move Count longs at HubAddr to registers at CogAddr', + [ + 'HubAddr - address of HUB long array to be copied', + 'CogAddr - address of COG register array to receive values', + 'Count - number of registers to be copied' + ] ], bytemove: [ - "BYTEMOVE(Destination, Source, Count)", - "Move Count bytes from Source to Destination", - ["Destination - address of BYTE array to receive values", "Source - address of BYTE array to be copied", "Count - the number of BYTEs to be copied"], + 'BYTEMOVE(Destination, Source, Count)', + 'Move Count bytes from Source to Destination', + [ + 'Destination - address of BYTE array to receive values', + 'Source - address of BYTE array to be copied', + 'Count - the number of BYTEs to be copied' + ] ], wordmove: [ - "WORDMOVE(Destination, Source, Count)", - "Move Count words from Source to Destination", - ["Destination - address of WORD array to receive values", "Source - address of WORD array to be copied", "Count - the number of WORDs to be copied"], + 'WORDMOVE(Destination, Source, Count)', + 'Move Count words from Source to Destination', + [ + 'Destination - address of WORD array to receive values', + 'Source - address of WORD array to be copied', + 'Count - the number of WORDs to be copied' + ] ], longmove: [ - "LONGMOVE(Destination, Source, Count)", - "Move Count longs from Source to Destination", - ["Destination - address of LONG array to receive values", "Source - address of LONG array to be copied", "Count - the number of LONGs to be copied"], + 'LONGMOVE(Destination, Source, Count)', + 'Move Count longs from Source to Destination', + [ + 'Destination - address of LONG array to receive values', + 'Source - address of LONG array to be copied', + 'Count - the number of LONGs to be copied' + ] ], bytefill: [ - "BYTEFILL(Destination, Value, Count)", - "Fill Count bytes starting at Destination with Value", - ["Destination - address of BYTE array to receive values", "Value - 8-bit value", "Count - the number of BYTEs to be filled"], + 'BYTEFILL(Destination, Value, Count)', + 'Fill Count bytes starting at Destination with Value', + ['Destination - address of BYTE array to receive values', 'Value - 8-bit value', 'Count - the number of BYTEs to be filled'] ], wordfill: [ - "WORDFILL(Destination, Value, Count)", - "Fill Count words starting at Destination with Value", - ["Destination - address of WORD array to receive values", "Value - 16-bit value", "Count - the number of WORDs to be filled"], + 'WORDFILL(Destination, Value, Count)', + 'Fill Count words starting at Destination with Value', + ['Destination - address of WORD array to receive values', 'Value - 16-bit value', 'Count - the number of WORDs to be filled'] ], longfill: [ - "LONGFILL(Destination, Value, Count)", - "Fill Count longs starting at Destination with Value", - ["Destination - address of LONG array to receive values", "Value - 32-bit value", "Count - the number of LONGs to be filled"], - ], + 'LONGFILL(Destination, Value, Count)', + 'Fill Count longs starting at Destination with Value', + ['Destination - address of LONG array to receive values', 'Value - 32-bit value', 'Count - the number of LONGs to be filled'] + ] }; private _tableSpinStringMethods: { [Identifier: string]: TMethodTuple } = { - strsize: ["STRSIZE(Addr) : Size", "Count bytes of zero-terminated string at Addr", ["Addr - address of zero-terminated string"], ["Size - the string length, not including the zero"]], + strsize: [ + 'STRSIZE(Addr) : Size', + 'Count bytes of zero-terminated string at Addr', + ['Addr - address of zero-terminated string'], + ['Size - the string length, not including the zero'] + ], strcomp: [ - "STRCOMP(AddrA,AddrB) : Match", - "Compare zero-terminated strings at AddrA and AddrB", - ["AddrA - address of zero-terminated string", "AddrB - address of zero-terminated string"], - ["Match - return TRUE (-1) if match or FALSE (0) if not"], + 'STRCOMP(AddrA,AddrB) : Match', + 'Compare zero-terminated strings at AddrA and AddrB', + ['AddrA - address of zero-terminated string', 'AddrB - address of zero-terminated string'], + ['Match - return TRUE (-1) if match or FALSE (0) if not'] ], strcopy: [ - "STRCOPY(Destination, Source, Max)", - "Copy a zero-terminated string of up to Max characters from Source to Destination. The copied string will occupy up to Max+1 bytes, including the zero terminator", - ["Destination - address of place to put string copy", "Source - address of zero-terminated string to be copied", "Max - maximum number of bytes of string to copy (less the terminator)"], + 'STRCOPY(Destination, Source, Max)', + 'Copy a zero-terminated string of up to Max characters from Source to Destination. The copied string will occupy up to Max+1 bytes, including the zero terminator', + [ + 'Destination - address of place to put string copy', + 'Source - address of zero-terminated string to be copied', + 'Max - maximum number of bytes of string to copy (less the terminator)' + ] ], getcrc: [ - "GETCRC(BytePtr, Poly, Count) : CRC", - "Compute a CRC of Count bytes starting at BytePtr using a custom polynomial of up to 32 bits", - ["BytePtr - address of source byte array", "Poly - the 32-bit polynomial to be used", "Count - number of bytes in the source byte array"], - ["CRC - the 32-bit computed CRC value"], - ], + 'GETCRC(BytePtr, Poly, Count) : CRC', + 'Compute a CRC of Count bytes starting at BytePtr using a custom polynomial of up to 32 bits', + ['BytePtr - address of source byte array', 'Poly - the 32-bit polynomial to be used', 'Count - number of bytes in the source byte array'], + ['CRC - the 32-bit computed CRC value'] + ] }; private _tableSpinStringBuilder: { [Identifier: string]: string[] } = { // NOTE: this does NOT support signature help! (paramaters are not highlighted for signature help due to variant forms for string() being allowed) string: [ 'STRING("Text",13) : StringAddress', - "Compose a zero-terminated string (quoted characters and values 1..255 allowed), return address of string

@param `listOfElements` - a comma separated list of elements to be built into a string (quoted characters and values 1..255 allowed)
@returns `StringAddress` - address of where string was placed in ram", + 'Compose a zero-terminated string (quoted characters and values 1..255 allowed), return address of string

@param `listOfElements` - a comma separated list of elements to be built into a string (quoted characters and values 1..255 allowed)
@returns `StringAddress` - address of where string was placed in ram' ], // new additions at v42 but cleaned up at v43 - byte: ["BYTE($80,$09,$77,WORD $1234,LONG -1) : BytesAddress", "Compose a string of bytes, return address of string. WORD/LONG size overrides allowed."], - word: ["WORD(1_000,10_000,50_000,LONG $12345678) : WordsAddress", "Compose a string of words, return address of string. BYTE/LONG size overrides allowed."], - long: ["LONG(1e-6,1e-3,1.0,1e3,1e6,-50,BYTE $FF) : LongsAddress", "Compose a string of longs, return address of string. BYTE/WORD size overrides allowed."], + byte: [ + 'BYTE($80,$09,$77,WORD $1234,LONG -1) : BytesAddress', + 'Compose a string of bytes, return address of string. WORD/LONG size overrides allowed.' + ], + word: [ + 'WORD(1_000,10_000,50_000,LONG $12345678) : WordsAddress', + 'Compose a string of words, return address of string. BYTE/LONG size overrides allowed.' + ], + long: [ + 'LONG(1e-6,1e-3,1.0,1e3,1e6,-50,BYTE $FF) : LongsAddress', + 'Compose a string of longs, return address of string. BYTE/WORD size overrides allowed.' + ] }; private _tableSpinEnhancements_v43: { [Identifier: string]: string[] } = { // NOTE: this does NOT support signature help! (paramaters are not highlighted for signature help due to variant forms for string() being allowed) - lstring: ['LSTRING("Hello",0,"Terve",0) : StringAddress', "Compose a length-headed string (quoted characters and values 0..255), return address of string."], + lstring: [ + 'LSTRING("Hello",0,"Terve",0) : StringAddress', + 'Compose a length-headed string (quoted characters and values 0..255), return address of string.' + ] }; private _tableSpinIndexValueMethods: { [Identifier: string]: string[] } = { // NOTE: this does NOT support signature help! (paramaters are not highlighted for signature help due to ':' being param separater) lookup: [ - "LOOKUP(Index: ExpressionList) : Value", - "Lookup value (values and ranges allowed) using 1-based index, return value (0 if index out of range)

" + - "@param `Index` - an expression indicating the position of the desired value in ExpressionList
" + - "@param `ExpressionList` - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Value` - the value found (or 0 if index out of range)
", + 'LOOKUP(Index: ExpressionList) : Value', + 'Lookup value (values and ranges allowed) using 1-based index, return value (0 if index out of range)

' + + '@param `Index` - an expression indicating the position of the desired value in ExpressionList
' + + '@param `ExpressionList` - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
' + + '@returns `Value` - the value found (or 0 if index out of range)
' ], lookupz: [ - "LOOKUPZ(Index: ExpressionList) : Value", - "Lookup value (values and ranges allowed) using 0-based index, return value (0 if index out of range)

" + + 'LOOKUPZ(Index: ExpressionList) : Value', + 'Lookup value (values and ranges allowed) using 0-based index, return value (0 if index out of range)

' + "@param `Index' - is an expression indicating the position of the desired value in ExpressionList
" + "@param `ExpressionList' - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Value` - the value found (or 0 if index out of range)
", + '@returns `Value` - the value found (or 0 if index out of range)
' ], lookdown: [ - "LOOKDOWN(Value: ExpressionList) : Index", - "Determine 1-based index of matching value (values and ranges allowed), return index (0 if no match)

" + + 'LOOKDOWN(Value: ExpressionList) : Index', + 'Determine 1-based index of matching value (values and ranges allowed), return index (0 if no match)

' + "@param `Value' - is an expression indicating the value to find in ExpressionList
" + "@param `ExpressionList' - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Index` - the index found (or 0 if no match for value in list)
", + '@returns `Index` - the index found (or 0 if no match for value in list)
' ], lookdownz: [ - "LOOKDOWNZ(Value: ExpressionList) : Index", - "Determine 0-based index of matching value (values and ranges allowed), return index (0 if no match)

" + + 'LOOKDOWNZ(Value: ExpressionList) : Index', + 'Determine 0-based index of matching value (values and ranges allowed), return index (0 if no match)

' + "@param `Value' - is an expression indicating the value to find in ExpressionList
" + "@param `ExpressionList' - a comma-separated list of expressions. Quoted strings of characters are also allowed; they are treated as a comma-separated list of characters
" + - "@returns `Index` - the index found (or 0 if no match for value in list)
", - ], + '@returns `Index` - the index found (or 0 if no match for value in list)
' + ] }; private _tableSpinControlFlowMethods: { [Identifier: string]: string[] } = { abort: [ - "ABORT [ErrorCode]", - "Instantly return, from any depth of nested method calls, back to a base caller which used '\\' before the method name. A single return value can be conveyed from the abort point back to the base caller", + 'ABORT [ErrorCode]', + "Instantly return, from any depth of nested method calls, back to a base caller which used '\\' before the method name. A single return value can be conveyed from the abort point back to the base caller" ], - return: ["RETURN [Value[, Value[,...]]]", "Return zero or more values from a PUB/PRI method."], + return: ['RETURN [Value[, Value[,...]]]', 'Return zero or more values from a PUB/PRI method.'] }; public isSpinBuiltinMethod(name: string): boolean { @@ -2126,44 +2366,50 @@ export class Spin2ParseUtils { private _docTextForSpinBuiltInMethod(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (this.isSpinBuiltinMethod(name)) { desiredDocText.found = true; let protoWDescr: string[] = []; - let methodDescr: TMethodTuple = ["", "", []]; + let methodDescr: TMethodTuple = ['', '', []]; if (nameKey in this._tableSpinHubMethods) { - desiredDocText.category = "Hub Method"; + desiredDocText.category = 'Hub Method'; methodDescr = this._tableSpinHubMethods[nameKey]; } else if (nameKey in this._tableSpinPinMethods) { - desiredDocText.category = "Pin Method"; + desiredDocText.category = 'Pin Method'; methodDescr = this._tableSpinPinMethods[nameKey]; } else if (nameKey in this._tableSpinTimingMethods) { - desiredDocText.category = "Timing Method"; + desiredDocText.category = 'Timing Method'; methodDescr = this._tableSpinTimingMethods[nameKey]; } else if (nameKey in this._tablePAsmInterfaceMethods) { - desiredDocText.category = "PAsm Interface Method"; + desiredDocText.category = 'PAsm Interface Method'; methodDescr = this._tablePAsmInterfaceMethods[nameKey]; } else if (nameKey in this._tableSpinMathMethods) { - desiredDocText.category = "Math Method"; + desiredDocText.category = 'Math Method'; methodDescr = this._tableSpinMathMethods[nameKey]; } else if (nameKey in this._tableSpinMemoryMethods) { - desiredDocText.category = "Memory Method"; + desiredDocText.category = 'Memory Method'; methodDescr = this._tableSpinMemoryMethods[nameKey]; } else if (nameKey in this._tableSpinStringMethods) { - desiredDocText.category = "String Method"; + desiredDocText.category = 'String Method'; methodDescr = this._tableSpinStringMethods[nameKey]; } else if (nameKey in this._tableSpinStringBuilder) { - desiredDocText.category = "String Method"; + desiredDocText.category = 'String Method'; protoWDescr = this._tableSpinStringBuilder[nameKey]; } else if (this.requestedSpinVersion(43) && nameKey in this._tableSpinEnhancements_v43) { // if {Spin2_v43} or greater then also search this table - desiredDocText.category = "String Method"; + desiredDocText.category = 'String Method'; protoWDescr = this._tableSpinEnhancements_v43[nameKey]; } else if (nameKey in this._tableSpinIndexValueMethods) { - desiredDocText.category = "Hub Method"; + desiredDocText.category = 'Hub Method'; protoWDescr = this._tableSpinIndexValueMethods[nameKey]; } else if (nameKey in this._tableSpinControlFlowMethods) { - desiredDocText.category = "Control Flow Method"; + desiredDocText.category = 'Control Flow Method'; protoWDescr = this._tableSpinControlFlowMethods[nameKey]; } if (methodDescr[0].length != 0) { @@ -2184,64 +2430,82 @@ export class Spin2ParseUtils { } public isFlexspinPreprocessorDirective(name: string): boolean { - const flexspinDirectiveOfNote: string[] = ["#define", "#ifdef", "#ifndef", "#else", "#elseifdef", "#elseifndef", "#endif", "#error", "#include", "#warn", "#undef"]; + const flexspinDirectiveOfNote: string[] = [ + '#define', + '#ifdef', + '#ifndef', + '#else', + '#elseifdef', + '#elseifndef', + '#endif', + '#error', + '#include', + '#warn', + '#undef' + ]; const reservedStatus: boolean = flexspinDirectiveOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isFlexspinReservedWord(name: string): boolean { const flexspinReservedswordsOfNote: string[] = [ - "__propeller__", - "__propeller2__", - "__p2__", - "__flexspin__", - "__spincvt__", - "__spin2pasm__", - "__spin2cpp__", - "__have_fcache__", - "__cplusplus__", - "__date__", - "__file__", - "__line__", - "__time__", - "__version__", - "__debug__", - "__output_asm__", - "__output_bytecode__", - "__output_c__", - "__output_cpp__", + '__propeller__', + '__propeller2__', + '__p2__', + '__flexspin__', + '__spincvt__', + '__spin2pasm__', + '__spin2cpp__', + '__have_fcache__', + '__cplusplus__', + '__date__', + '__file__', + '__line__', + '__time__', + '__version__', + '__debug__', + '__output_asm__', + '__output_bytecode__', + '__output_c__', + '__output_cpp__' ]; const reservedStatus: boolean = flexspinReservedswordsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; } public isP2AsmReservedSymbols(name: string): boolean { - const reservedPAsmSymbolNames: string[] = ["org", "orgf", "orgh", "fit", "end"]; + const reservedPAsmSymbolNames: string[] = ['org', 'orgf', 'orgh', 'fit', 'end']; const reservedStatus: boolean = reservedPAsmSymbolNames.indexOf(name.toLowerCase()) != -1; return reservedStatus; } private _tableClockConstants: { [Identifier: string]: string } = { - _clkfreq: "Selects XI/XO-crystal-plus-PLL mode, assumes 20 MHz crystal", - _xtlfreq: "Selects XI/XO-crystal mode and frequency", - _xinfreq: "Selects XI-input mode and frequency", - _rcslow: "Selects internal RCSLOW oscillator which runs at ~20 KHz", - _rcfast: "Selects internal RCFAST oscillator which runs at 20 MHz+", + _clkfreq: 'Selects XI/XO-crystal-plus-PLL mode, assumes 20 MHz crystal', + _xtlfreq: 'Selects XI/XO-crystal mode and frequency', + _xinfreq: 'Selects XI-input mode and frequency', + _rcslow: 'Selects internal RCSLOW oscillator which runs at ~20 KHz', + _rcfast: 'Selects internal RCFAST oscillator which runs at 20 MHz+' }; private _tableClockSpinSymbols: { [Identifier: string]: string } = { - clkmode_: "The compiled clock mode, settable via HUBSET", - clkfreq_: "The compiled clock frequency", + clkmode_: 'The compiled clock mode, settable via HUBSET', + clkfreq_: 'The compiled clock frequency' }; private _tableClockSpinVariables: { [Identifier: string]: string } = { clkmode: "The current clock mode, located at LONG[$40]. Initialized with the 'clkmode_' value", - clkfreq: "The current clock frequency, located at LONG[$44]. Initialized with the 'clkfreq_' value", + clkfreq: "The current clock frequency, located at LONG[$44]. Initialized with the 'clkfreq_' value" }; private _docTextForSpinClockVars(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (nameKey in this._tableClockConstants) { desiredDocText.description = this._tableClockConstants[nameKey]; desiredDocText.type = eBuiltInType.BIT_CONSTANT; @@ -2253,7 +2517,7 @@ export class Spin2ParseUtils { desiredDocText.type = eBuiltInType.BIT_VARIABLE; } if (desiredDocText.type != eBuiltInType.Unknown) { - desiredDocText.category = "Clock"; + desiredDocText.category = 'Clock'; desiredDocText.found = true; } return desiredDocText; @@ -2261,40 +2525,40 @@ export class Spin2ParseUtils { public isP2AsmReservedWord(name: string): boolean { const pasmReservedswordsOfNote: string[] = [ - "ijmp1", - "ijmp2", - "ijmp3", - "iret1", - "iret2", - "iret3", - "ptra", - "ptrb", - "addpins", - "clkfreq_", - "clkmode_", - "pa", - "pb", - "clkfreq", - "clkmode", - "_clkfreq", - "_rcfast", - "_rcslow", - "_xinfreq", - "_xtlfreq", - "round", - "float", - "trunc", - "dira", - "dirb", - "ina", - "inb", - "outa", - "outb", - "fvar", - "fvars", - "addbits", - "true", - "false", + 'ijmp1', + 'ijmp2', + 'ijmp3', + 'iret1', + 'iret2', + 'iret3', + 'ptra', + 'ptrb', + 'addpins', + 'clkfreq_', + 'clkmode_', + 'pa', + 'pb', + 'clkfreq', + 'clkmode', + '_clkfreq', + '_rcfast', + '_rcslow', + '_xinfreq', + '_xtlfreq', + 'round', + 'float', + 'trunc', + 'dira', + 'dirb', + 'ina', + 'inb', + 'outa', + 'outb', + 'fvar', + 'fvars', + 'addbits', + 'true', + 'false' ]; const reservedStatus: boolean = pasmReservedswordsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; @@ -2302,367 +2566,367 @@ export class Spin2ParseUtils { public isP2AsmInstruction(name: string): boolean { const pasmInstructions: string[] = [ - "abs", - "add", - "addct1", - "addct2", - "addct3", - "addpix", - "adds", - "addsx", - "addx", - "akpin", - "allowi", - "altb", - "altd", - "altgb", - "altgn", - "altgw", - "alti", - "altr", - "alts", - "altsb", - "altsn", - "altsw", - "and", - "andn", - "asmclk", - "augd", - "augs", - "bitc", - "bith", - "bitl", - "bitnc", - "bitnot", - "bitnz", - "bitrnd", - "bitz", - "blnpix", - "bmask", - "brk", - "call", - "calla", - "callb", - "calld", - "callpa", - "callpb", - "cmp", - "cmpm", - "cmpr", - "cmps", - "cmpsub", - "cmpsx", - "cmpx", - "cogatn", - "cogbrk", - "cogid", - "coginit", - "cogstop", - "crcbit", - "crcnib", - "decmod", - "decod", - "dirc", - "dirh", - "dirl", - "dirnc", - "dirnot", - "dirnz", - "dirrnd", - "dirz", - "djf", - "djnf", - "djnz", - "djz", - "drvc", - "drvh", - "drvl", - "drvnc", - "drvnot", - "drvnz", - "drvrnd", - "drvz", - "encod", - "execf", - "fblock", - "fge", - "fges", - "fle", - "fles", - "fltc", - "flth", - "fltl", - "fltnc", - "fltnot", - "fltnz", - "fltrnd", - "fltz", - "getbrk", - "getbyte", - "getct", - "getnib", - "getptr", - "getqx", - "getqy", - "getrnd", - "getrnd", - "getscp", - "getword", - "getxacc", - "hubset", - "ijnz", - "ijz", - "incmod", - "jatn", - "jct1", - "jct2", - "jct3", - "jfbw", - "jint", - "jmp", - "jmprel", - "jnatn", - "jnct1", - "jnct2", - "jnct3", - "jnfbw", - "jnint", - "jnpat", - "jnqmt", - "jnse1", - "jnse2", - "jnse3", - "jnse4", - "jnxfi", - "jnxmt", - "jnxrl", - "jnxro", - "jpat", - "jqmt", - "jse1", - "jse2", - "jse3", - "jse4", - "jxfi", - "jxmt", - "jxrl", - "jxro", - "loc", - "locknew", - "lockrel", - "lockret", - "locktry", - "mergeb", - "mergew", - "mixpix", - "modc", - "modcz", - "modz", - "mov", - "movbyts", - "mul", - "mulpix", - "muls", - "muxc", - "muxnc", - "muxnibs", - "muxnits", - "muxnz", - "muxq", - "muxz", - "neg", - "negc", - "negnc", - "negnz", - "negz", - "nixint1", - "nixint2", - "nixint3", - "nop", - "not", - "ones", - "or", - "outc", - "outh", - "outl", - "outnc", - "outnot", - "outnz", - "outrnd", - "outz", - "pollatn", - "pollct1", - "pollct2", - "pollct3", - "pollfbw", - "pollint", - "pollpat", - "pollqmt", - "pollse1", - "pollse2", - "pollse3", - "pollse4", - "pollxfi", - "pollxmt", - "pollxrl", - "pollxro", - "pop", - "popa", - "popb", - "push", - "pusha", - "pushb", - "qdiv", - "qexp", - "qfrac", - "qlog", - "qmul", - "qrotate", - "qsqrt", - "qvector", - "rcl", - "rcr", - "rczl", - "rczr", - "rdbyte", - "rdfast", - "rdlong", - "rdlut", - "rdpin", - "rdword", - "rep", - "resi0", - "resi1", - "resi2", - "resi3", - "ret", - "reta", - "retb", - "reti0", - "reti1", - "reti2", - "reti3", - "rev", - "rfbyte", - "rflong", - "rfvar", - "rfvars", - "rfword", - "rgbexp", - "rgbsqz", - "rol", - "rolbyte", - "rolbyte", - "rolnib", - "rolword", - "rolword", - "ror", - "rqpin", - "sal", - "sar", - "sca", - "scas", - "setbyte", - "setcfrq", - "setci", - "setcmod", - "setcq", - "setcy", - "setd", - "setdacs", - "setint1", - "setint2", - "setint3", - "setluts", - "setnib", - "setpat", - "setpiv", - "setpix", - "setq", - "setq2", - "setr", - "sets", - "setscp", - "setse1", - "setse2", - "setse3", - "setse4", - "setword", - "setxfrq", - "seussf", - "seussr", - "shl", - "shr", - "signx", - "skip", - "skipf", - "splitb", - "splitw", - "stalli", - "sub", - "subr", - "subs", - "subsx", - "subx", - "sumc", - "sumnc", - "sumnz", - "sumz", - "test", - "testb", - "testbn", - "testn", - "testp", - "testpn", - "tjf", - "tjnf", - "tjns", - "tjnz", - "tjs", - "tjv", - "tjz", - "trgint1", - "trgint2", - "trgint3", - "waitatn", - "waitct1", - "waitct2", - "waitct3", - "waitfbw", - "waitint", - "waitpat", - "waitse1", - "waitse2", - "waitse3", - "waitse4", - "waitx", - "waitxfi", - "waitxmt", - "waitxrl", - "waitxro", - "wfbyte", - "wflong", - "wfword", - "wmlong", - "wrbyte", - "wrc", - "wrfast", - "wrlong", - "wrlut", - "wrnc", - "wrnz", - "wrpin", - "wrword", - "wrz", - "wxpin", - "wypin", - "xcont", - "xinit", - "xor", - "xoro32", - "xstop", - "xzero", - "zerox", + 'abs', + 'add', + 'addct1', + 'addct2', + 'addct3', + 'addpix', + 'adds', + 'addsx', + 'addx', + 'akpin', + 'allowi', + 'altb', + 'altd', + 'altgb', + 'altgn', + 'altgw', + 'alti', + 'altr', + 'alts', + 'altsb', + 'altsn', + 'altsw', + 'and', + 'andn', + 'asmclk', + 'augd', + 'augs', + 'bitc', + 'bith', + 'bitl', + 'bitnc', + 'bitnot', + 'bitnz', + 'bitrnd', + 'bitz', + 'blnpix', + 'bmask', + 'brk', + 'call', + 'calla', + 'callb', + 'calld', + 'callpa', + 'callpb', + 'cmp', + 'cmpm', + 'cmpr', + 'cmps', + 'cmpsub', + 'cmpsx', + 'cmpx', + 'cogatn', + 'cogbrk', + 'cogid', + 'coginit', + 'cogstop', + 'crcbit', + 'crcnib', + 'decmod', + 'decod', + 'dirc', + 'dirh', + 'dirl', + 'dirnc', + 'dirnot', + 'dirnz', + 'dirrnd', + 'dirz', + 'djf', + 'djnf', + 'djnz', + 'djz', + 'drvc', + 'drvh', + 'drvl', + 'drvnc', + 'drvnot', + 'drvnz', + 'drvrnd', + 'drvz', + 'encod', + 'execf', + 'fblock', + 'fge', + 'fges', + 'fle', + 'fles', + 'fltc', + 'flth', + 'fltl', + 'fltnc', + 'fltnot', + 'fltnz', + 'fltrnd', + 'fltz', + 'getbrk', + 'getbyte', + 'getct', + 'getnib', + 'getptr', + 'getqx', + 'getqy', + 'getrnd', + 'getrnd', + 'getscp', + 'getword', + 'getxacc', + 'hubset', + 'ijnz', + 'ijz', + 'incmod', + 'jatn', + 'jct1', + 'jct2', + 'jct3', + 'jfbw', + 'jint', + 'jmp', + 'jmprel', + 'jnatn', + 'jnct1', + 'jnct2', + 'jnct3', + 'jnfbw', + 'jnint', + 'jnpat', + 'jnqmt', + 'jnse1', + 'jnse2', + 'jnse3', + 'jnse4', + 'jnxfi', + 'jnxmt', + 'jnxrl', + 'jnxro', + 'jpat', + 'jqmt', + 'jse1', + 'jse2', + 'jse3', + 'jse4', + 'jxfi', + 'jxmt', + 'jxrl', + 'jxro', + 'loc', + 'locknew', + 'lockrel', + 'lockret', + 'locktry', + 'mergeb', + 'mergew', + 'mixpix', + 'modc', + 'modcz', + 'modz', + 'mov', + 'movbyts', + 'mul', + 'mulpix', + 'muls', + 'muxc', + 'muxnc', + 'muxnibs', + 'muxnits', + 'muxnz', + 'muxq', + 'muxz', + 'neg', + 'negc', + 'negnc', + 'negnz', + 'negz', + 'nixint1', + 'nixint2', + 'nixint3', + 'nop', + 'not', + 'ones', + 'or', + 'outc', + 'outh', + 'outl', + 'outnc', + 'outnot', + 'outnz', + 'outrnd', + 'outz', + 'pollatn', + 'pollct1', + 'pollct2', + 'pollct3', + 'pollfbw', + 'pollint', + 'pollpat', + 'pollqmt', + 'pollse1', + 'pollse2', + 'pollse3', + 'pollse4', + 'pollxfi', + 'pollxmt', + 'pollxrl', + 'pollxro', + 'pop', + 'popa', + 'popb', + 'push', + 'pusha', + 'pushb', + 'qdiv', + 'qexp', + 'qfrac', + 'qlog', + 'qmul', + 'qrotate', + 'qsqrt', + 'qvector', + 'rcl', + 'rcr', + 'rczl', + 'rczr', + 'rdbyte', + 'rdfast', + 'rdlong', + 'rdlut', + 'rdpin', + 'rdword', + 'rep', + 'resi0', + 'resi1', + 'resi2', + 'resi3', + 'ret', + 'reta', + 'retb', + 'reti0', + 'reti1', + 'reti2', + 'reti3', + 'rev', + 'rfbyte', + 'rflong', + 'rfvar', + 'rfvars', + 'rfword', + 'rgbexp', + 'rgbsqz', + 'rol', + 'rolbyte', + 'rolbyte', + 'rolnib', + 'rolword', + 'rolword', + 'ror', + 'rqpin', + 'sal', + 'sar', + 'sca', + 'scas', + 'setbyte', + 'setcfrq', + 'setci', + 'setcmod', + 'setcq', + 'setcy', + 'setd', + 'setdacs', + 'setint1', + 'setint2', + 'setint3', + 'setluts', + 'setnib', + 'setpat', + 'setpiv', + 'setpix', + 'setq', + 'setq2', + 'setr', + 'sets', + 'setscp', + 'setse1', + 'setse2', + 'setse3', + 'setse4', + 'setword', + 'setxfrq', + 'seussf', + 'seussr', + 'shl', + 'shr', + 'signx', + 'skip', + 'skipf', + 'splitb', + 'splitw', + 'stalli', + 'sub', + 'subr', + 'subs', + 'subsx', + 'subx', + 'sumc', + 'sumnc', + 'sumnz', + 'sumz', + 'test', + 'testb', + 'testbn', + 'testn', + 'testp', + 'testpn', + 'tjf', + 'tjnf', + 'tjns', + 'tjnz', + 'tjs', + 'tjv', + 'tjz', + 'trgint1', + 'trgint2', + 'trgint3', + 'waitatn', + 'waitct1', + 'waitct2', + 'waitct3', + 'waitfbw', + 'waitint', + 'waitpat', + 'waitse1', + 'waitse2', + 'waitse3', + 'waitse4', + 'waitx', + 'waitxfi', + 'waitxmt', + 'waitxrl', + 'waitxro', + 'wfbyte', + 'wflong', + 'wfword', + 'wmlong', + 'wrbyte', + 'wrc', + 'wrfast', + 'wrlong', + 'wrlut', + 'wrnc', + 'wrnz', + 'wrpin', + 'wrword', + 'wrz', + 'wxpin', + 'wypin', + 'xcont', + 'xinit', + 'xor', + 'xoro32', + 'xstop', + 'xzero', + 'zerox' ]; const instructionStatus: boolean = pasmInstructions.indexOf(name.toLowerCase()) != -1; return instructionStatus; @@ -2671,25 +2935,25 @@ export class Spin2ParseUtils { public isP1AsmInstruction(name: string): boolean { // mark these RED if seen in P2 code const p1asmInstructions: string[] = [ - "absneg", - "addabs", - "clkset", - "hubop", - "jmpret", - "lockclr", - "lockset", - "max", - "maxs", - "min", - "mins", - "movd", - "movi", - "movs", - "subabs", - "waitcnt", - "waitpeq", - "waitpne", - "waitvid", + 'absneg', + 'addabs', + 'clkset', + 'hubop', + 'jmpret', + 'lockclr', + 'lockset', + 'max', + 'maxs', + 'min', + 'mins', + 'movd', + 'movi', + 'movs', + 'subabs', + 'waitcnt', + 'waitpeq', + 'waitpne', + 'waitvid' ]; const instructionStatus: boolean = p1asmInstructions.indexOf(name.toLowerCase()) != -1; return instructionStatus; @@ -2697,14 +2961,14 @@ export class Spin2ParseUtils { public isP1SpinVariable(name: string): boolean { // mark these RED if seen in P2 code - const p1spinVariables: string[] = ["result"]; + const p1spinVariables: string[] = ['result']; const instructionStatus: boolean = p1spinVariables.indexOf(name.toLowerCase()) != -1; return instructionStatus; } public isP1SpinMethod(name: string): boolean { // mark these RED if seen in P2 code - const p1spinMethods: string[] = ["lockclr", "lockset", "constant", "chipver", "cognew", "waitcnt", "waitpeq", "waitpne", "waitvid", "reboot"]; + const p1spinMethods: string[] = ['lockclr', 'lockset', 'constant', 'chipver', 'cognew', 'waitcnt', 'waitpeq', 'waitpne', 'waitvid', 'reboot']; const instructionStatus: boolean = p1spinMethods.indexOf(name.toLowerCase()) != -1; return instructionStatus; } @@ -2712,30 +2976,30 @@ export class Spin2ParseUtils { public isP1AsmVariable(name: string): boolean { // mark these RED if seen in P2 code const p1asmVariables: string[] = [ - "_clkmode", - "_free", - "_stack", - "cnt", - "xtal1", - "xtal2", - "xtal3", - "rcfast", - "rcslow", - "pll1x", - "pll2x", - "pll4x", - "pll8x", - "pll16x", - "ctra", - "ctrb", - "frqa", - "frqb", - "phsa", - "phsb", - "vcfg", - "vscl", - "par", - "spr", + '_clkmode', + '_free', + '_stack', + 'cnt', + 'xtal1', + 'xtal2', + 'xtal3', + 'rcfast', + 'rcslow', + 'pll1x', + 'pll2x', + 'pll4x', + 'pll8x', + 'pll16x', + 'ctra', + 'ctrb', + 'frqa', + 'frqb', + 'phsa', + 'phsb', + 'vcfg', + 'vscl', + 'par', + 'spr' ]; const instructionStatus: boolean = p1asmVariables.indexOf(name.toLowerCase()) != -1; return instructionStatus; @@ -2743,65 +3007,65 @@ export class Spin2ParseUtils { public isP2AsmNonArgumentInstruction(name: string): boolean { const pasmNonArgumentInstructions: string[] = [ - "nop", - "resi3", - "resi2", - "resi1", - "resi0", - "reti3", - "reti2", - "reti1", - "reti0", - "xstop", - "allowi", - "stalli", - "trgint1", - "trgint2", - "trgint3", - "nixint1", - "nixint2", - "nixint3", - "ret", - "reta", - "retb", - "pollint", - "pollct1", - "pollct2", - "pollct3", - "pollse1", - "pollse2", - "pollse3", - "pollse4", - "pollpat", - "pollfbw", - "pollxmt", - "pollxfi", - "pollxro", - "pollxrl", - "pollatn", - "pollqmt", - "waitint", - "waitct1", - "waitct2", - "waitct3", - "waitse1", - "waitse2", - "waitse3", - "waitse4", - "waitpat", - "waitfbw", - "waitxmt", - "waitxfi", - "waitxro", - "waitxrl", - "waitatn", + 'nop', + 'resi3', + 'resi2', + 'resi1', + 'resi0', + 'reti3', + 'reti2', + 'reti1', + 'reti0', + 'xstop', + 'allowi', + 'stalli', + 'trgint1', + 'trgint2', + 'trgint3', + 'nixint1', + 'nixint2', + 'nixint3', + 'ret', + 'reta', + 'retb', + 'pollint', + 'pollct1', + 'pollct2', + 'pollct3', + 'pollse1', + 'pollse2', + 'pollse3', + 'pollse4', + 'pollpat', + 'pollfbw', + 'pollxmt', + 'pollxfi', + 'pollxro', + 'pollxrl', + 'pollatn', + 'pollqmt', + 'waitint', + 'waitct1', + 'waitct2', + 'waitct3', + 'waitse1', + 'waitse2', + 'waitse3', + 'waitse4', + 'waitpat', + 'waitfbw', + 'waitxmt', + 'waitxfi', + 'waitxro', + 'waitxrl', + 'waitatn' ]; const instructionStatus: boolean = pasmNonArgumentInstructions.indexOf(name.toLowerCase()) != -1; return instructionStatus; } public isIllegalInlinePAsmDirective(name: string): boolean { - const illegalInlinePAsmDirective: string[] = ["alignw", "alignl", "file", "orgh"]; + const illegalInlinePAsmDirective: string[] = ['alignw', 'alignl', 'file', 'orgh']; const illegalStatus: boolean = illegalInlinePAsmDirective.indexOf(name.toLowerCase()) != -1; return illegalStatus; } @@ -2810,7 +3074,7 @@ export class Spin2ParseUtils { let returnStatus: boolean = this.isBadP1AsmEffect(name); if (name.length >= 2) { const checkType: string = name.toUpperCase(); - if (checkType == "IF_ALWAYS" || checkType == "IF_NEVER") { + if (checkType == 'IF_ALWAYS' || checkType == 'IF_NEVER') { returnStatus = true; } } @@ -2821,7 +3085,7 @@ export class Spin2ParseUtils { let returnStatus: boolean = false; if (name.length >= 2) { const checkType: string = name.toUpperCase(); - if (checkType == "NR" || checkType == "WR") { + if (checkType == 'NR' || checkType == 'WR') { returnStatus = true; } } @@ -2833,15 +3097,15 @@ export class Spin2ParseUtils { if (name.length >= 2) { const checkType: string = name.toUpperCase(); if ( - checkType == "WC" || - checkType == "WZ" || - checkType == "WCZ" || - checkType == "XORC" || - checkType == "XORZ" || - checkType == "ORC" || - checkType == "ORZ" || - checkType == "ANDC" || - checkType == "ANDZ" + checkType == 'WC' || + checkType == 'WZ' || + checkType == 'WCZ' || + checkType == 'XORC' || + checkType == 'XORZ' || + checkType == 'ORC' || + checkType == 'ORZ' || + checkType == 'ANDC' || + checkType == 'ANDZ' ) { returnStatus = true; } @@ -2850,18 +3114,18 @@ export class Spin2ParseUtils { } public isDatOrPAsmLabel(name: string): boolean { - let haveLabelStatus: boolean = name.charAt(0).match(/[a-zA-Z_\.\:]/) ? true : false; + let haveLabelStatus: boolean = name.charAt(0).match(/[a-zA-Z_.:]/) ? true : false; if (haveLabelStatus) { if (this.isDatNFileStorageType(name)) { haveLabelStatus = false; - } else if (name.toUpperCase() == "DAT") { + } else if (name.toUpperCase() == 'DAT') { haveLabelStatus = false; } else if (this.isIllegalInlinePAsmDirective(name)) { // these can't be label either! haveLabelStatus = false; } else if (this.isP2AsmReservedSymbols(name)) { haveLabelStatus = false; - } else if (name.toUpperCase().startsWith("IF_") || name.toUpperCase() == "_RET_") { + } else if (name.toUpperCase().startsWith('IF_') || name.toUpperCase() == '_RET_') { haveLabelStatus = false; } else if (this.isP2AsmEffect(name)) { haveLabelStatus = false; @@ -2884,7 +3148,7 @@ export class Spin2ParseUtils { if (name.length > 2) { const checkType: string = name.toUpperCase(); // yeah, FILE too! (oddly enough) - if (checkType == "FILE") { + if (checkType == 'FILE') { returnStatus = true; } else { returnStatus = this.isDatStorageType(name); @@ -2898,7 +3162,7 @@ export class Spin2ParseUtils { let returnStatus: boolean = false; if (name.length > 2) { const checkType: string = name.toUpperCase(); - if (checkType == "RES") { + if (checkType == 'RES') { returnStatus = true; } else { returnStatus = this.isStorageType(name); @@ -2912,11 +3176,11 @@ export class Spin2ParseUtils { let returnStatus: boolean = false; if (name.length > 3) { const checkType: string = name.toUpperCase(); - if (checkType == "BYTE" || checkType == "WORD" || checkType == "LONG") { + if (checkType == 'BYTE' || checkType == 'WORD' || checkType == 'LONG') { returnStatus = true; } if (!returnStatus && languageVersion >= 43) { - if (checkType == "LSTRING") { + if (checkType == 'LSTRING') { returnStatus = true; } } @@ -2929,7 +3193,7 @@ export class Spin2ParseUtils { let returnStatus: boolean = false; if (name.length > 3) { const checkType: string = name.toUpperCase(); - if (checkType == "BYTEFIT" || checkType == "WORDFIT" || checkType == "BYTE" || checkType == "WORD" || checkType == "LONG") { + if (checkType == 'BYTEFIT' || checkType == 'WORDFIT' || checkType == 'BYTE' || checkType == 'WORD' || checkType == 'LONG') { returnStatus = true; } } @@ -2941,7 +3205,7 @@ export class Spin2ParseUtils { let returnStatus: boolean = false; if (name.length > 5) { const checkType: string = name.toUpperCase(); - if (checkType == "ALIGNL" || checkType == "ALIGNW") { + if (checkType == 'ALIGNL' || checkType == 'ALIGNW') { returnStatus = true; } } @@ -2949,37 +3213,43 @@ export class Spin2ParseUtils { } private _tableSpinStorageTypes: { [Identifier: string]: string } = { - byte: "8-bit storage", - word: "16-bit storage", - long: "32-bit storage", - bytefit: "like BYTE for use in DAT sections, but verifies BYTE data are -$80 to $FF", - wordfit: "like WORD for use in DAT sections, but verifies word data are -$8000 to $FFFF", + byte: '8-bit storage', + word: '16-bit storage', + long: '32-bit storage', + bytefit: 'like BYTE for use in DAT sections, but verifies BYTE data are -$80 to $FF', + wordfit: 'like WORD for use in DAT sections, but verifies word data are -$8000 to $FFFF' }; private _tableSpinStorageSpecials: { [Identifier: string]: string[] } = { - res: ["RES n", "reserve n register(s), advance cog address by n, don't advance hub address"], - file: ['FileDat FILE "Filename"', 'include binary file, "FileDat" is a BYTE symbol that points to file'], + res: ['RES n', "reserve n register(s), advance cog address by n, don't advance hub address"], + file: ['FileDat FILE "Filename"', 'include binary file, "FileDat" is a BYTE symbol that points to file'] }; private _tableSpinAlignment: { [Identifier: string]: string } = { - alignw: "word-align to hub memory, advances variable pointer as necessary", - alignl: "long-align to hub memory, advances variable pointer as necessary", + alignw: 'word-align to hub memory, advances variable pointer as necessary', + alignl: 'long-align to hub memory, advances variable pointer as necessary' }; private _docTextForSpinStorageTypesAlignment(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (nameKey in this._tableSpinStorageTypes) { desiredDocText.found = true; - desiredDocText.category = "Storage Types"; + desiredDocText.category = 'Storage Types'; desiredDocText.description = this._tableSpinStorageTypes[nameKey]; } else if (nameKey in this._tableSpinAlignment) { desiredDocText.found = true; - desiredDocText.category = "DAT Alignment"; + desiredDocText.category = 'DAT Alignment'; desiredDocText.description = this._tableSpinAlignment[nameKey]; } else if (nameKey in this._tableSpinStorageSpecials) { desiredDocText.found = true; - desiredDocText.category = "DAT Special"; + desiredDocText.category = 'DAT Special'; const protoWDescr: string[] = this._tableSpinStorageSpecials[nameKey]; desiredDocText.signature = protoWDescr[0]; desiredDocText.description = protoWDescr[1]; @@ -3001,15 +3271,16 @@ export class Spin2ParseUtils { // bitmap - PDM, Bitmap, 1..2048 x 1..2048 pixels, 1/2/4/8/16/32-bit pixels with 19 color systems, 15 direction/autoscroll modes, independent X and Y pixel size of 1..256 // ---------------------------------------------------- private _tableDebugDisplayTypes: { [Identifier: string]: string } = { - plot: "General-purpose plotter with cartesian and polar modes", - term: "Text terminal with up to 300 x 200 characters, 6..200 point font size, 4 simultaneous color schemes", - midi: "Piano keyboard with 1..128 keys, velocity depiction, variable screen scale", - logic: "PDM, Logic analyzer with single and multi-bit labels, 1..32 channels, can trigger on pattern", - scope: "PDM, Oscilloscope with 1..8 channels, can trigger on level with hysteresis", - scope_xy: "PDM, XY oscilloscope with 1..8 channels, persistence of 0..512 samples, polar mode, log scale mode", - fft: "PDM, Fast Fourier Transform with 1..8 channels, 4..2048 points, windowed results, log scale mode", - spectro: "PDM, Spectrograph with 4..2048-point FFT, windowed results, phase-coloring, and log scale mode", - bitmap: "PDM, Bitmap, 1..2048 x 1..2048 pixels, 1/2/4/8/16/32-bit pixels with 19 color systems, 15 direction/autoscroll modes, independent X and Y pixel size of 1..256", + plot: 'General-purpose plotter with cartesian and polar modes', + term: 'Text terminal with up to 300 x 200 characters, 6..200 point font size, 4 simultaneous color schemes', + midi: 'Piano keyboard with 1..128 keys, velocity depiction, variable screen scale', + logic: 'PDM, Logic analyzer with single and multi-bit labels, 1..32 channels, can trigger on pattern', + scope: 'PDM, Oscilloscope with 1..8 channels, can trigger on level with hysteresis', + scope_xy: 'PDM, XY oscilloscope with 1..8 channels, persistence of 0..512 samples, polar mode, log scale mode', + fft: 'PDM, Fast Fourier Transform with 1..8 channels, 4..2048 points, windowed results, log scale mode', + spectro: 'PDM, Spectrograph with 4..2048-point FFT, windowed results, phase-coloring, and log scale mode', + bitmap: + 'PDM, Bitmap, 1..2048 x 1..2048 pixels, 1/2/4/8/16/32-bit pixels with 19 color systems, 15 direction/autoscroll modes, independent X and Y pixel size of 1..256' }; public isDebugDisplayType(name: string): boolean { @@ -3020,17 +3291,23 @@ export class Spin2ParseUtils { private _docTextForSpinBuiltInDebugDisplayType(name: string): IBuiltinDescription { const nameKey: string = name.toLowerCase(); - let desiredDocText: IBuiltinDescription = { found: false, type: eBuiltInType.Unknown, category: "", description: "", signature: "" }; + const desiredDocText: IBuiltinDescription = { + found: false, + type: eBuiltInType.Unknown, + category: '', + description: '', + signature: '' + }; if (nameKey in this._tableDebugDisplayTypes) { desiredDocText.found = true; - desiredDocText.category = "Debug Display-type"; + desiredDocText.category = 'Debug Display-type'; desiredDocText.description = this._tableDebugDisplayTypes[nameKey]; } return desiredDocText; } public isNameWithTypeInstantiation(newParameter: string, displayType: eDebugDisplayType): boolean { - var nameStatus: boolean = false; + let nameStatus: boolean = false; const bHasPackedData: boolean = this.debugTypeHasPackedData(displayType); const bHasColorMode: boolean = this.debugTypeHasColorMode(displayType); switch (displayType) { @@ -3079,7 +3356,7 @@ export class Spin2ParseUtils { } public isNameWithTypeFeed(newParameter: string, displayType: eDebugDisplayType): boolean { - var nameStatus: boolean = false; + let nameStatus: boolean = false; const bHasColorMode: boolean = this.debugTypeHasColorMode(displayType); switch (displayType) { case eDebugDisplayType.ddtTerm: @@ -3123,91 +3400,104 @@ export class Spin2ParseUtils { // each type has decl and feed parameter-name check methods // Debug Display: TERM declaration public isDebugTermDeclarationParam(name: string): boolean { - const debugTermDeclTypes: string[] = ["title", "pos", "size", "textsize", "color", "backcolor", "update", "hidexy"]; + const debugTermDeclTypes: string[] = ['title', 'pos', 'size', 'textsize', 'color', 'backcolor', 'update', 'hidexy']; const bTermDeclParamStatus: boolean = debugTermDeclTypes.indexOf(name.toLowerCase()) != -1; return bTermDeclParamStatus; } // Debug Display: TERM feed public isDebugTermFeedParam(name: string): boolean { - const debugTermFeedTypes: string[] = ["clear", "update", "save", "close"]; + const debugTermFeedTypes: string[] = ['clear', 'update', 'save', 'close']; const bTermFeedParamStatus: boolean = debugTermFeedTypes.indexOf(name.toLowerCase()) != -1; return bTermFeedParamStatus; } // Debug Display: SCOPE declaration public isDebugScopeDeclarationParam(name: string): boolean { - const debugScopeDeclTypes: string[] = ["title", "pos", "size", "samples", "rate", "dotsize", "linesize", "textsize", "color", "hidexy", "auto"]; + const debugScopeDeclTypes: string[] = ['title', 'pos', 'size', 'samples', 'rate', 'dotsize', 'linesize', 'textsize', 'color', 'hidexy', 'auto']; const bScopeDeclParamStatus: boolean = debugScopeDeclTypes.indexOf(name.toLowerCase()) != -1; return bScopeDeclParamStatus; } // Debug Display: SCOPE feed public isDebugScopeFeedParam(name: string): boolean { - const debugScopeFeedTypes: string[] = ["trigger", "holdoff", "samples", "clear", "save", "window", "close", "auto"]; + const debugScopeFeedTypes: string[] = ['trigger', 'holdoff', 'samples', 'clear', 'save', 'window', 'close', 'auto']; const bScopeFeedParamStatus: boolean = debugScopeFeedTypes.indexOf(name.toLowerCase()) != -1; return bScopeFeedParamStatus; } // Debug Display: SCOPE_XY declaration public isDebugScopeXYDeclarationParam(name: string): boolean { - const debugScopeXYDeclTypes: string[] = ["title", "pos", "size", "range", "samples", "rate", "dotsize", "textsize", "color", "polar", "logscale", "hidexy"]; + const debugScopeXYDeclTypes: string[] = [ + 'title', + 'pos', + 'size', + 'range', + 'samples', + 'rate', + 'dotsize', + 'textsize', + 'color', + 'polar', + 'logscale', + 'hidexy' + ]; const bScopeXYDeclParamStatus: boolean = debugScopeXYDeclTypes.indexOf(name.toLowerCase()) != -1; return bScopeXYDeclParamStatus; } // Debug Display: SCOPE_XY feed public isDebugScopeXYFeedParam(name: string): boolean { - const debugScopeXYFeedTypes: string[] = ["clear", "save", "window", "close"]; + const debugScopeXYFeedTypes: string[] = ['clear', 'save', 'window', 'close']; const bScopeXYFeedParamStatus: boolean = debugScopeXYFeedTypes.indexOf(name.toLowerCase()) != -1; return bScopeXYFeedParamStatus; } // Debug Display: LOGIC declaration public isDebugLogicDeclarationParam(name: string): boolean { - const debugLogicDeclTypes: string[] = ["title", "pos", "samples", "spacing", "rate", "linesize", "textsize", "color", "hidexy"]; + const debugLogicDeclTypes: string[] = ['title', 'pos', 'samples', 'spacing', 'rate', 'linesize', 'textsize', 'color', 'hidexy']; const bLogicDeclParamStatus: boolean = debugLogicDeclTypes.indexOf(name.toLowerCase()) != -1; return bLogicDeclParamStatus; } // Debug Display: LOGIC feed public isDebugLogicFeedParam(name: string): boolean { - const debugLogicFeedTypes: string[] = ["trigger", "holdoff", "clear", "save", "window", "close"]; + const debugLogicFeedTypes: string[] = ['trigger', 'holdoff', 'clear', 'save', 'window', 'close']; const bLogicFeedParamStatus: boolean = debugLogicFeedTypes.indexOf(name.toLowerCase()) != -1; return bLogicFeedParamStatus; } // Debug Display: FFT declaration public isDebugFFTDeclarationParam(name: string): boolean { - const debugFFTDeclTypes: string[] = ["title", "pos", "size", "samples", "rate", "dotsize", "linesize", "textsize", "color", "logscale", "hidexy"]; + const debugFFTDeclTypes: string[] = ['title', 'pos', 'size', 'samples', 'rate', 'dotsize', 'linesize', 'textsize', 'color', 'logscale', 'hidexy']; const bFFTDeclParamStatus: boolean = debugFFTDeclTypes.indexOf(name.toLowerCase()) != -1; return bFFTDeclParamStatus; } // Debug Display: FFT feed public isDebugFFTFeedParam(name: string): boolean { - const debugFFTFeedTypes: string[] = ["clear", "save", "window", "close"]; + const debugFFTFeedTypes: string[] = ['clear', 'save', 'window', 'close']; const bFFTFeedParamStatus: boolean = debugFFTFeedTypes.indexOf(name.toLowerCase()) != -1; return bFFTFeedParamStatus; } // Debug Display: SPECTRO declaration public isDebugSpectroDeclarationParam(name: string): boolean { - const debugSpectroDeclTypes: string[] = ["title", "pos", "samples", "depth", "mag", "range", "rate", "trace", "dotsize", "logscale", "hidexy"]; + const debugSpectroDeclTypes: string[] = ['title', 'pos', 'samples', 'depth', 'mag', 'range', 'rate', 'trace', 'dotsize', 'logscale', 'hidexy']; const bSpectroDeclParamStatus: boolean = debugSpectroDeclTypes.indexOf(name.toLowerCase()) != -1; return bSpectroDeclParamStatus; } // Debug Display: SPECTRO feed public isDebugSpectroFeedParam(name: string): boolean { - const debugSpectroFeedTypes: string[] = ["clear", "save", "window", "close"]; + const debugSpectroFeedTypes: string[] = ['clear', 'save', 'window', 'close']; const bSpectroFeedParamStatus: boolean = debugSpectroFeedTypes.indexOf(name.toLowerCase()) != -1; return bSpectroFeedParamStatus; } // Debug Display: PLOT declaration public isDebugPlotDeclarationParam(name: string): boolean { - const debugPlotDeclTypes: string[] = ["title", "pos", "size", "dotsize", "lutcolors", "backcolor", "update", "hidexy"]; + const debugPlotDeclTypes: string[] = ['title', 'pos', 'size', 'dotsize', 'lutcolors', 'backcolor', 'update', 'hidexy']; const bPlotDeclParamStatus: boolean = debugPlotDeclTypes.indexOf(name.toLowerCase()) != -1; return bPlotDeclParamStatus; } @@ -3215,34 +3505,34 @@ export class Spin2ParseUtils { // Debug Display: PLOT feed public isDebugPlotFeedParam(name: string): boolean { const debugPlotFeedTypes: string[] = [ - "lutcolors", - "backcolor", - "color", - "opacity", - "precise", - "linesize", - "origin", - "set", - "dot", - "line", - "circle", - "oval", - "box", - "obox", - "text", - "textsize", - "textstyle", - "textangle", - "text", - "spritedef", - "sprite", - "polar", - "cartesian", - "update", - "clear", - "save", - "window", - "close", + 'lutcolors', + 'backcolor', + 'color', + 'opacity', + 'precise', + 'linesize', + 'origin', + 'set', + 'dot', + 'line', + 'circle', + 'oval', + 'box', + 'obox', + 'text', + 'textsize', + 'textstyle', + 'textangle', + 'text', + 'spritedef', + 'sprite', + 'polar', + 'cartesian', + 'update', + 'clear', + 'save', + 'window', + 'close' ]; const bPlotFeedParamStatus: boolean = debugPlotFeedTypes.indexOf(name.toLowerCase()) != -1; return bPlotFeedParamStatus; @@ -3250,28 +3540,28 @@ export class Spin2ParseUtils { // Debug Display: BITMAP declaration public isDebugBitmapDeclarationParam(name: string): boolean { - const debugBitmapDeclTypes: string[] = ["title", "pos", "size", "dotsize", "lutcolors", "trace", "rate", "scroll", "update", "hidexy", "sparse"]; + const debugBitmapDeclTypes: string[] = ['title', 'pos', 'size', 'dotsize', 'lutcolors', 'trace', 'rate', 'scroll', 'update', 'hidexy', 'sparse']; const bBitmapDeclParamStatus: boolean = debugBitmapDeclTypes.indexOf(name.toLowerCase()) != -1; return bBitmapDeclParamStatus; } // Debug Display: BITMAP feed public isDebugBitmapFeedParam(name: string): boolean { - const debugBitmapFeedTypes: string[] = ["lutcolors", "trace", "rate", "set", "scroll", "clear", "update", "scroll", "save", "window", "close"]; + const debugBitmapFeedTypes: string[] = ['lutcolors', 'trace', 'rate', 'set', 'scroll', 'clear', 'update', 'scroll', 'save', 'window', 'close']; const bBitmapFeedParamStatus: boolean = debugBitmapFeedTypes.indexOf(name.toLowerCase()) != -1; return bBitmapFeedParamStatus; } // Debug Display: MIDI declaration public isDebugMidiDeclarationParam(name: string): boolean { - const debugMidiDeclTypes: string[] = ["title", "pos", "size", "range", "channel", "color"]; + const debugMidiDeclTypes: string[] = ['title', 'pos', 'size', 'range', 'channel', 'color']; const bMidiDeclParamStatus: boolean = debugMidiDeclTypes.indexOf(name.toLowerCase()) != -1; return bMidiDeclParamStatus; } // Debug Display: MIDI feed public isDebugMidiFeedParam(name: string): boolean { - const debugMidiFeedTypes: string[] = ["clear", "save", "window", "close"]; + const debugMidiFeedTypes: string[] = ['clear', 'save', 'window', 'close']; const bMidiFeedParamStatus: boolean = debugMidiFeedTypes.indexOf(name.toLowerCase()) != -1; return bMidiFeedParamStatus; } @@ -3314,7 +3604,7 @@ export class Spin2ParseUtils { // color names for use in debug() // BLACK / WHITE or ORANGE / BLUE / GREEN / CYAN / RED / MAGENTA / YELLOW / GREY|GRAY public isDebugColorName(name: string): boolean { - const debugColorNames: string[] = ["black", "white", "orange", "blue", "green", "cyan", "red", "magenta", "yellow", "grey", "gray"]; + const debugColorNames: string[] = ['black', 'white', 'orange', 'blue', 'green', 'cyan', 'red', 'magenta', 'yellow', 'grey', 'gray']; const bColorNameStatus: boolean = debugColorNames.indexOf(name.toLowerCase()) != -1; return bColorNameStatus; } @@ -3322,21 +3612,21 @@ export class Spin2ParseUtils { // packed data forms for use in debug() public isDebugPackedDataType(name: string): boolean { const debugPackedDataTypes: string[] = [ - "longs_1bit", - "longs_2bit", - "longs_4bit", - "longs_8bit", - "longs_16bit", - "words_1bit", - "words_2bit", - "words_4bit", - "words_8bit", - "bytes_1bit", - "bytes_2bit", - "bytes_4bit", + 'longs_1bit', + 'longs_2bit', + 'longs_4bit', + 'longs_8bit', + 'longs_16bit', + 'words_1bit', + 'words_2bit', + 'words_4bit', + 'words_8bit', + 'bytes_1bit', + 'bytes_2bit', + 'bytes_4bit', // optional operators - "alt", - "signed", + 'alt', + 'signed' ]; const bPackedDataTypeStatus: boolean = debugPackedDataTypes.indexOf(name.toLowerCase()) != -1; return bPackedDataTypeStatus; @@ -3345,25 +3635,25 @@ export class Spin2ParseUtils { // Bitmap Color Modes public isDebugBitmapColorMode(name: string): boolean { const debugBitmapColorModes: string[] = [ - "lut1", - "lut2", - "lut4", - "lut8", - "luma8", - "luma8w", - "luma8x", - "hsv8", - "hsv8w", - "hsv8x", - "rgbi8", - "rgbi8w", - "rgbi8x", - "rgb8", - "rgb16", - "rgb24", - "hsv16", - "hsv16w", - "hsv16x", + 'lut1', + 'lut2', + 'lut4', + 'lut8', + 'luma8', + 'luma8w', + 'luma8x', + 'hsv8', + 'hsv8w', + 'hsv8x', + 'rgbi8', + 'rgbi8w', + 'rgbi8x', + 'rgb8', + 'rgb16', + 'rgb24', + 'hsv16', + 'hsv16w', + 'hsv16x' ]; const bBitmapColorModeStatus: boolean = debugBitmapColorModes.indexOf(name.toLowerCase()) != -1; return bBitmapColorModeStatus; @@ -3371,7 +3661,7 @@ export class Spin2ParseUtils { // Spectro reduced-set Color Modes public isDebugSpectroColorMode(name: string): boolean { - const debugSpectropColorModes: string[] = ["luma8", "luma8w", "luma8x", "hsv16", "hsv16w", "hsv16x"]; + const debugSpectropColorModes: string[] = ['luma8', 'luma8w', 'luma8x', 'hsv16', 'hsv16w', 'hsv16x']; const bSpectroColorModeStatus: boolean = debugSpectropColorModes.indexOf(name.toLowerCase()) != -1; return bSpectroColorModeStatus; } diff --git a/spin2/server/src/providers/CompletionProvider.ts b/spin2/server/src/providers/CompletionProvider.ts index bd65142..63c11cd 100644 --- a/spin2/server/src/providers/CompletionProvider.ts +++ b/spin2/server/src/providers/CompletionProvider.ts @@ -1,16 +1,16 @@ -"use strict"; +'use strict'; // src/providers/CompletionProvider.ts // A DEMO Completion Provider! -import * as lsp from "vscode-languageserver"; -import { CompletionItemKind } from "vscode-languageserver/node"; +import * as lsp from 'vscode-languageserver'; +import { CompletionItemKind } from 'vscode-languageserver/node'; //import { promises as fsp } from "fs"; //import { relative } from "path"; //import { fileURLToPath } from "url"; -import { Provider } from "."; -import { Context } from "../context"; +import { Provider } from '.'; +import { Context } from '../context'; export default class CompletionProvider implements Provider { //private namedRegs: lsp.CompletionItem[]; @@ -30,37 +30,38 @@ export default class CompletionProvider implements Provider { connection.onCompletionResolve(this.handleCompletionResolve.bind(this)); return { completionProvider: { - triggerCharacters: ["."], - resolveProvider: true, - }, + triggerCharacters: ['.'], + resolveProvider: true + } }; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars async handleCompletion({ position, textDocument }: lsp.CompletionParams): Promise { // The pass parameter contains the position of the text document in // which code complete got requested. For the example we ignore this // info and always provide the same completion items. return [ { - label: "TypeScript", + label: 'TypeScript', kind: CompletionItemKind.Text, - data: 1, + data: 1 }, { - label: "JavaScript", + label: 'JavaScript', kind: CompletionItemKind.Text, - data: 2, - }, + data: 2 + } ]; } private handleCompletionResolve(item: lsp.CompletionItem) { if (item.data === 1) { - item.detail = "TypeScript details"; - item.documentation = "TypeScript documentation"; + item.detail = 'TypeScript details'; + item.documentation = 'TypeScript documentation'; } else if (item.data === 2) { - item.detail = "JavaScript details"; - item.documentation = "JavaScript documentation"; + item.detail = 'JavaScript details'; + item.documentation = 'JavaScript documentation'; } return item; } diff --git a/spin2/server/src/providers/DefinitionProvider.ts b/spin2/server/src/providers/DefinitionProvider.ts index ca0cf9b..c8862c3 100644 --- a/spin2/server/src/providers/DefinitionProvider.ts +++ b/spin2/server/src/providers/DefinitionProvider.ts @@ -1,17 +1,17 @@ -"use strict"; +'use strict'; // src/extensions.ts -import * as lsp from "vscode-languageserver"; -import { Provider } from "."; -import { Context } from "../context"; +import * as lsp from 'vscode-languageserver'; +import { Provider } from '.'; +import { Context } from '../context'; //import { getDefinitions } from "../symbols"; -import * as path from "path"; -import { Position, Location } from "vscode-languageserver-types"; -import { DocumentFindings, ILocationOfToken } from "../parser/spin.semantic.findings"; -import { fileSpecFromURI } from "../parser/lang.utils"; -import { ExtensionUtils } from "../parser/spin.extension.utils"; -import { Range, TextDocument } from "vscode-languageserver-textdocument"; -import { DocumentLineAt } from "../parser/lsp.textDocument.utils"; +import * as path from 'path'; +import { Position, Location } from 'vscode-languageserver-types'; +import { DocumentFindings, ILocationOfToken } from '../parser/spin.semantic.findings'; +import { fileSpecFromURI } from '../parser/lang.utils'; +import { ExtensionUtils } from '../parser/spin.extension.utils'; +import { Range, TextDocument } from 'vscode-languageserver-textdocument'; +import { DocumentLineAt } from '../parser/lsp.textDocument.utils'; //import { URI } from "vscode-uri"; export interface NamedSymbol { @@ -33,15 +33,15 @@ export interface Definition extends NamedSymbol { */ export enum DefinitionType { - Section = "section", - Label = "label", - Constant = "constant", - Variable = "variable", - Register = "register", - RegisterList = "register_list", - Offset = "offset", - Macro = "macro", - XRef = "xref", + Section = 'section', + Label = 'label', + Constant = 'constant', + Variable = 'variable', + Register = 'register', + RegisterList = 'register_list', + Offset = 'offset', + Macro = 'macro', + XRef = 'xref' } export interface FindingsAtPostion { @@ -60,9 +60,9 @@ export default class DefinitionProvider implements Provider { if (this.defnLogEnabled) { if (this.bLogStarted == false) { this.bLogStarted = true; - this._logMessage("Spin Hover log started."); + this._logMessage('Spin Hover log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -79,7 +79,7 @@ export default class DefinitionProvider implements Provider { } async handleGetDefinitions({ textDocument, position }: lsp.DefinitionParams): Promise { - const defLocation: Location[] = []; + //const defLocation: Location[] = []; const docFSpec: string = fileSpecFromURI(textDocument.uri); const processed = this.ctx.docsByFSpec.get(docFSpec); if (!processed) { @@ -108,7 +108,7 @@ export default class DefinitionProvider implements Provider { this._logMessage(`+ Defn: found Locn=[ln=${tokenLocation.position.line}, char=${tokenLocation.position.character}] in uri=[${uri}]`); definitionResults.push({ uri, - range, + range }); } @@ -118,7 +118,7 @@ export default class DefinitionProvider implements Provider { register(connection: lsp.Connection) { connection.onDefinition(this.handleGetDefinitions.bind(this)); return { - definitionProvider: true, + definitionProvider: true }; } @@ -163,30 +163,34 @@ export default class DefinitionProvider implements Provider { const wordUnderCursor: string = adjustedPos[2]; if (objectRef === wordUnderCursor) { - objectRef = ""; + objectRef = ''; } const sourcePosition: Position = adjustedPos[3]; - let fileBasename = path.basename(document.uri); + const fileBasename = path.basename(document.uri); this._logMessage( `+ Defn: wordUnderCursor=[${wordUnderCursor}], inObjDecl=(${inObjDeclarationStatus}), objectRef=(${objectRef}), adjPos=(${position.line},${position.character}), file=[${fileBasename}], line=[${declarationLine}]` ); - return { position: sourcePosition, objectReference: objectRef, selectedWord: wordUnderCursor }; + return { + position: sourcePosition, + objectReference: objectRef, + selectedWord: wordUnderCursor + }; } private _objectNameFromDeclaration(line: string): string { - let desiredString: string = ""; + let desiredString: string = ''; // parse object declaration forms: // ex: child1 : "dummy_child" | MULTIplIER = 3, CoUNT = 5 // child1[4] : "dummy_child" | MULTIplIER = 3, CoUNT = 5 // child1[child.MAX_CT] : "dummy_child" | MULTIplIER = 3, CoUNT = 5 - if (line.includes(":")) { - let lineParts: string[] = line.split(":"); + if (line.includes(':')) { + let lineParts: string[] = line.split(':'); //this._logMessage(`+ Defn: _getObjName() :-split lineParts=[${lineParts}](${lineParts.length})`); if (lineParts.length >= 2) { const instanceName = lineParts[0].trim(); - if (instanceName.includes("[")) { - lineParts = instanceName.split("["); + if (instanceName.includes('[')) { + lineParts = instanceName.split('['); //this._logMessage(`+ Defn: _getObjName() [-split lineParts=[${lineParts}](${lineParts.length})`); if (lineParts.length >= 2) { desiredString = lineParts[0].trim(); diff --git a/spin2/server/src/providers/DocumentSymbolProvider.ts b/spin2/server/src/providers/DocumentSymbolProvider.ts index eea9426..75953a4 100644 --- a/spin2/server/src/providers/DocumentSymbolProvider.ts +++ b/spin2/server/src/providers/DocumentSymbolProvider.ts @@ -1,11 +1,11 @@ -"use strict"; +'use strict'; // src/DocumentSymbolProvider.ts -import * as lsp from "vscode-languageserver/node"; -import { Provider } from "."; -import { Context } from "../context"; -import { DocumentFindings, OutLineSymbol } from "../parser/spin.semantic.findings"; -import { fileSpecFromURI } from "../parser/lang.utils"; +import * as lsp from 'vscode-languageserver/node'; +import { Provider } from '.'; +import { Context } from '../context'; +import { DocumentFindings, OutLineSymbol } from '../parser/spin.semantic.findings'; +import { fileSpecFromURI } from '../parser/lang.utils'; export default class DocumentSymbolProvider implements Provider { constructor(protected readonly ctx: Context) {} @@ -30,7 +30,7 @@ export default class DocumentSymbolProvider implements Provider { detail: currSymbol.description, kind: currSymbol.kind(), range: currSymbol.location(), - selectionRange: currSymbol.location(), + selectionRange: currSymbol.location() }; const childOutlineSymbols: OutLineSymbol[] = currSymbol.children(); @@ -42,7 +42,7 @@ export default class DocumentSymbolProvider implements Provider { detail: currChildSymbol.description, kind: currChildSymbol.kind(), range: currChildSymbol.location(), - selectionRange: currChildSymbol.location(), + selectionRange: currChildSymbol.location() }; if (newLspSymbol.children == undefined) { newLspSymbol.children = []; @@ -60,7 +60,7 @@ export default class DocumentSymbolProvider implements Provider { register(connection: lsp.Connection) { connection.onDocumentSymbol(this.handleGetDocumentSymbols.bind(this)); return { - documentSymbolProvider: true, + documentSymbolProvider: true }; } } diff --git a/spin2/server/src/providers/FoldingRangeProvider.ts b/spin2/server/src/providers/FoldingRangeProvider.ts index c0f27d0..52bd792 100644 --- a/spin2/server/src/providers/FoldingRangeProvider.ts +++ b/spin2/server/src/providers/FoldingRangeProvider.ts @@ -1,9 +1,9 @@ -import * as lsp from "vscode-languageserver"; -import { Provider } from "."; -import { Context } from "../context"; -import { ExtensionUtils } from "../parser/spin.extension.utils"; -import { fileSpecFromURI } from "../parser/lang.utils"; -import { DocumentFindings, IFoldSpan, eFoldSpanType } from "../parser/spin.semantic.findings"; +import * as lsp from 'vscode-languageserver'; +import { Provider } from '.'; +import { Context } from '../context'; +import { ExtensionUtils } from '../parser/spin.extension.utils'; +import { fileSpecFromURI } from '../parser/lang.utils'; +import { DocumentFindings, IFoldSpan, eFoldSpanType } from '../parser/spin.semantic.findings'; export default class FoldingRangeProvider implements Provider { private foldingLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit @@ -15,9 +15,9 @@ export default class FoldingRangeProvider implements Provider { if (this.foldingLogEnabled) { if (this.bLogStarted == false) { this.bLogStarted = true; - this._logMessage("Spin Folding log started."); + this._logMessage('Spin Folding log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -52,7 +52,7 @@ export default class FoldingRangeProvider implements Provider { const folds: lsp.FoldingRange[] = []; for (let index = 0; index < foldSpans.length; index++) { const foldingCodeSpan = foldSpans[index]; - const spanType: string | undefined = foldingCodeSpan.type == eFoldSpanType.Comment ? "comment" : undefined; + const spanType: string | undefined = foldingCodeSpan.type == eFoldSpanType.Comment ? 'comment' : undefined; const newRange: lsp.FoldingRange = lsp.FoldingRange.create( foldingCodeSpan.foldstart.line, foldingCodeSpan.foldEnd.line, @@ -69,7 +69,7 @@ export default class FoldingRangeProvider implements Provider { register(connection: lsp.Connection) { connection.onFoldingRanges(this.onFoldingRanges.bind(this)); return { - foldingRangeProvider: true, + foldingRangeProvider: true }; } } diff --git a/spin2/server/src/providers/HoverProvider.ts b/spin2/server/src/providers/HoverProvider.ts index 97e31d8..b7c19ea 100644 --- a/spin2/server/src/providers/HoverProvider.ts +++ b/spin2/server/src/providers/HoverProvider.ts @@ -1,22 +1,22 @@ -"use strict"; +'use strict'; // src/providers/HoverProvider.ts -import * as path from "path"; +import * as path from 'path'; -import * as lsp from "vscode-languageserver"; -import { Position, Hover, MarkupKind } from "vscode-languageserver-types"; +import * as lsp from 'vscode-languageserver'; +import { Position, Hover, MarkupKind } from 'vscode-languageserver-types'; -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Provider } from "."; -import { Context } from "../context"; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Provider } from '.'; +import { Context } from '../context'; -import { DocumentFindings, ITokenDescription } from "../parser/spin.semantic.findings"; -import { IDefinitionInfo, ExtensionUtils } from "../parser/spin.extension.utils"; -import { DocumentLineAt } from "../parser/lsp.textDocument.utils"; -import { Spin2ParseUtils, eSearchFilterType } from "../parser/spin2.utils"; -import { Spin1ParseUtils } from "../parser/spin1.utils"; -import { eBuiltInType, isMethodCall } from "../parser/spin.common"; -import { isSpin1File, fileSpecFromURI } from "../parser/lang.utils"; +import { DocumentFindings, ITokenDescription } from '../parser/spin.semantic.findings'; +import { IDefinitionInfo, ExtensionUtils } from '../parser/spin.extension.utils'; +import { DocumentLineAt } from '../parser/lsp.textDocument.utils'; +import { Spin2ParseUtils, eSearchFilterType } from '../parser/spin2.utils'; +import { Spin1ParseUtils } from '../parser/spin1.utils'; +import { eBuiltInType, isMethodCall } from '../parser/spin.common'; +import { isSpin1File, fileSpecFromURI } from '../parser/lang.utils'; export default class HoverProvider implements Provider { private hoverLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit @@ -32,9 +32,9 @@ export default class HoverProvider implements Provider { if (this.hoverLogEnabled) { if (this.bLogStarted == false) { this.bLogStarted = true; - this._logMessage("Spin Hover log started."); + this._logMessage('Spin Hover log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -60,7 +60,7 @@ export default class HoverProvider implements Provider { register(connection: lsp.Connection): lsp.ServerCapabilities { connection.onHover(this.handleGetHover.bind(this)); return { - hoverProvider: true, + hoverProvider: true }; } @@ -93,24 +93,28 @@ export default class HoverProvider implements Provider { return null; } - const lines = IDefinitionInfo.declarationlines.filter((line) => line !== "").map((line) => line.replace(/\t/g, " ")); - let text = lines.join("\n").replace(/\n+$/, ""); + const lines = IDefinitionInfo.declarationlines.filter((line) => line !== '').map((line) => line.replace(/\t/g, ' ')); + const text = lines.join('\n').replace(/\n+$/, ''); const hoverTexts: string[] = []; - const breakRegEx = /\/gi; // we are globally replacing
or
markers + const breakRegEx = /
/gi; // we are globally replacing
or
markers - hoverTexts.push(this.codeBlock(text, "spin2")); + hoverTexts.push(this.codeBlock(text, 'spin2')); if (IDefinitionInfo.doc != null) { // SIGH: Markdown renders line breaks when there are two or more of them. // so replace
with two newLines! - hoverTexts.push(IDefinitionInfo.doc.replace(breakRegEx, "\n\n")); + hoverTexts.push(IDefinitionInfo.doc.replace(breakRegEx, '\n\n')); } //this._logMessage(`+ Hvr: provideHover() EXIT with hover: [${hoverTexts.join("\n")}]`); + + // experiment: insert language: 'spin2', into contents.. didn't work! + // REF: https://stackoverflow.com/questions/62999411/how-to-use-vs-code-hover-provider-text-color + return { contents: { kind: MarkupKind.Markdown, - value: hoverTexts.join("\n"), - }, + value: hoverTexts.join('\n') + } }; }, () => { @@ -144,10 +148,10 @@ export default class HoverProvider implements Provider { const hoverSource: string = adjustedPos[2]; if (objectRef === hoverSource) { - objectRef = ""; + objectRef = ''; } const sourcePosition: Position = adjustedPos[3]; - let fileBasename = path.basename(document.uri); + const fileBasename = path.basename(document.uri); const methodFollowString: string = declarationLine.substring(wordStart.character + hoverSource.length); const bMethodCall: boolean = isMethodCall(methodFollowString); this._logMessage(`+ Hvr: methodFollowString=[${methodFollowString}](${methodFollowString.length})`); @@ -161,18 +165,18 @@ export default class HoverProvider implements Provider { } private _objectNameFromDeclaration(line: string): string { - let desiredString: string = ""; + let desiredString: string = ''; // parse object declaration forms: // ex: child1 : "dummy_child" | MULTIplIER = 3, CoUNT = 5 // child1[4] : "dummy_child" | MULTIplIER = 3, CoUNT = 5 // child1[child.MAX_CT] : "dummy_child" | MULTIplIER = 3, CoUNT = 5 - if (line.includes(":")) { - let lineParts: string[] = line.split(":"); + if (line.includes(':')) { + let lineParts: string[] = line.split(':'); //this._logMessage(`+ Hvr: _getObjName() :-split lineParts=[${lineParts}](${lineParts.length})`); if (lineParts.length >= 2) { const instanceName = lineParts[0].trim(); - if (instanceName.includes("[")) { - lineParts = instanceName.split("["); + if (instanceName.includes('[')) { + lineParts = instanceName.split('['); //this._logMessage(`+ Hvr: _getObjName() [-split lineParts=[${lineParts}](${lineParts.length})`); if (lineParts.length >= 2) { desiredString = lineParts[0].trim(); @@ -190,29 +194,35 @@ export default class HoverProvider implements Provider { private getSignatureWithoutLocals(line: string): string { let desiredLinePortion: string = line; // strip off locals - const localOffset: number = line.indexOf("|"); + const localOffset: number = line.indexOf('|'); if (localOffset != -1) { desiredLinePortion = line.substring(0, localOffset).trim(); } // upper case the pub/pri - if (desiredLinePortion.startsWith("pub ")) { - desiredLinePortion = desiredLinePortion.replace("pub ", "PUB "); - } else if (desiredLinePortion.startsWith("pri ")) { - desiredLinePortion = desiredLinePortion.replace("pri ", "PRI "); + if (desiredLinePortion.startsWith('pub ')) { + desiredLinePortion = desiredLinePortion.replace('pub ', 'PUB '); + } else if (desiredLinePortion.startsWith('pri ')) { + desiredLinePortion = desiredLinePortion.replace('pri ', 'PRI '); } return desiredLinePortion; } - private getSymbolDetails(document: TextDocument, position: Position, objRef: string, searchWord: string, isMethodCall: boolean): Promise { + private getSymbolDetails( + document: TextDocument, + position: Position, + objRef: string, + searchWord: string, + isMethodCall: boolean + ): Promise { return new Promise((resolve, reject) => { const defInfo: IDefinitionInfo = { file: document.uri, line: position.line, column: position.character, - toolUsed: "????", + toolUsed: '????', declarationlines: [], - doc: "{huh, I have no clue!}", - name: path.basename(document.uri), + doc: '{huh, I have no clue!}', + name: path.basename(document.uri) }; let symbolsSet: DocumentFindings = this.symbolsFound; @@ -238,24 +248,26 @@ export default class HoverProvider implements Provider { let cursorCharPosn = position.character; do { const char: string = sourceLineRaw.substring(cursorCharPosn, cursorCharPosn); - if (char == " " || char == "\t") { + if (char == ' ' || char == '\t') { break; } cursorCharPosn--; } while (cursorCharPosn > 0); - const isSignatureLine: boolean = sourceLine.toLowerCase().startsWith("pub") || sourceLine.toLowerCase().startsWith("pri"); + const isSignatureLine: boolean = sourceLine.toLowerCase().startsWith('pub') || sourceLine.toLowerCase().startsWith('pri'); // ensure we don't recognize debug() in spin1 files! - const isDebugLine: boolean = this.spin1File ? false : sourceLine.toLowerCase().startsWith("debug("); + const isDebugLine: boolean = this.spin1File ? false : sourceLine.toLowerCase().startsWith('debug('); let bFoundSomething: boolean = false; // we've no answer const filterType: eSearchFilterType = isMethodCall ? eSearchFilterType.FT_METHOD : eSearchFilterType.FT_NOT_METHOD; - let builtInFindings = isDebugLine ? this.parseUtils.docTextForDebugBuiltIn(searchWord) : this.parseUtils.docTextForBuiltIn(searchWord, filterType); + const builtInFindings = isDebugLine + ? this.parseUtils.docTextForDebugBuiltIn(searchWord) + : this.parseUtils.docTextForBuiltIn(searchWord, filterType); if (!builtInFindings.found) { this._logMessage(`+ Hvr: built-in=[${searchWord}], NOT found!`); } else { this._logMessage(`+ Hvr: built-in=[${searchWord}], Found!`); } - let bFoundParseToken: boolean = isObjectReference ? symbolsSet.isPublicToken(searchWord) : symbolsSet.isKnownToken(searchWord); + const bFoundParseToken: boolean = isObjectReference ? symbolsSet.isPublicToken(searchWord) : symbolsSet.isKnownToken(searchWord); if (!bFoundParseToken) { this._logMessage(`+ Hvr: token=[${searchWord}], NOT found!`); } else { @@ -292,11 +304,11 @@ export default class HoverProvider implements Provider { const scopeString: string = tokenFindings.scope; const typeString: string = tokenFindings.interpretation; - let docRootCommentMD: string = `(*${scopeString}* ${typeString}) **${nameString}**`; // parsedFindings + //let docRootCommentMD: string = `(*${scopeString}* ${typeString}) **${nameString}**`; // parsedFindings let typeInterpWName: string = `(${scopeString} ${typeString}) ${nameString}`; // better formatting of interp let typeInterp: string = `(${scopeString} ${typeString})`; // better formatting of interp if (scopeString.length == 0) { - docRootCommentMD = `(${typeString}) **${nameString}**`; + //docRootCommentMD = `(${typeString}) **${nameString}**`; typeInterpWName = `(${typeString}) ${nameString}`; // better formatting of interp typeInterp = `(${typeString})`; } @@ -308,11 +320,11 @@ export default class HoverProvider implements Provider { // ------------------------------- // load CODE section of hover // - const isMethod: boolean = typeString.includes("method"); + const isMethod: boolean = typeString.includes('method'); if (isMethod) { tokenFindings.signature = this.getSignatureWithoutLocals(nonCommentDecl); - if (tokenFindings.scope.includes("object")) { - if (typeString.includes("method")) { + if (tokenFindings.scope.includes('object')) { + if (typeString.includes('method')) { defInfo.declarationlines = [`(${scopeString} ${typeString}) ${tokenFindings.signature}`]; } else { defInfo.declarationlines = [`(${scopeString} ${typeString}) ${nameString}`]; @@ -336,35 +348,35 @@ export default class HoverProvider implements Provider { // ------------------------------- // load MarkDown section // - let mdLines: string[] = []; + const mdLines: string[] = []; if (isMethod) { //if (!isSignatureLine) { // TODO: remove NOT USING THIS mdLines.push(`Custom Method: User defined
`); //} } if ( - (tokenFindings.interpretation.includes("32-bit constant") && !tokenFindings.relatedObjectName) || - tokenFindings.interpretation.includes("shared variable") || - tokenFindings.interpretation.includes("instance variable") || - tokenFindings.interpretation.includes("inline-pasm variable") || - tokenFindings.interpretation.includes("enum value") + (tokenFindings.interpretation.includes('32-bit constant') && !tokenFindings.relatedObjectName) || + tokenFindings.interpretation.includes('shared variable') || + tokenFindings.interpretation.includes('instance variable') || + tokenFindings.interpretation.includes('inline-pasm variable') || + tokenFindings.interpretation.includes('enum value') ) { // if global constant push declaration line, first... - mdLines.push("Decl: " + nonCommentDecl + "
"); + mdLines.push('Decl: ' + nonCommentDecl + '
'); } - if (tokenFindings.interpretation.includes("pasm label") && tokenFindings.relatedFilename) { - mdLines.push("Refers to file: " + tokenFindings.relatedFilename + "
"); + if (tokenFindings.interpretation.includes('pasm label') && tokenFindings.relatedFilename) { + mdLines.push('Refers to file: ' + tokenFindings.relatedFilename + '
'); } - if (tokenFindings.interpretation.includes("named instance") && tokenFindings.relatedFilename) { - mdLines.push("An instance of: " + tokenFindings.relatedFilename + "
"); + if (tokenFindings.interpretation.includes('named instance') && tokenFindings.relatedFilename) { + mdLines.push('An instance of: ' + tokenFindings.relatedFilename + '
'); } if (tokenFindings.relatedObjectName) { - mdLines.push("Found in object: " + tokenFindings.relatedObjectName + "
"); + mdLines.push('Found in object: ' + tokenFindings.relatedObjectName + '
'); } if (tokenFindings.declarationComment) { // have object comment if (isMethod) { - mdLines.push("- " + tokenFindings.declarationComment); + mdLines.push('- ' + tokenFindings.declarationComment); } else { mdLines.push(tokenFindings.declarationComment); } @@ -380,7 +392,7 @@ export default class HoverProvider implements Provider { } } if (mdLines.length > 0) { - defInfo.doc = mdLines.join(" "); + defInfo.doc = mdLines.join(' '); } else { defInfo.doc = undefined; } @@ -392,59 +404,61 @@ export default class HoverProvider implements Provider { const bHaveParams = builtInFindings.parameters && builtInFindings.parameters.length > 0 ? true : false; const bHaveReturns = builtInFindings.returns && builtInFindings.returns.length > 0 ? true : false; // ensure we don't recognize debug() in spin1 files! - if (this.spin1File == false && searchWord.toLowerCase() == "debug" && sourceLine.toLowerCase().startsWith("debug(")) { + if (this.spin1File == false && searchWord.toLowerCase() == 'debug' && sourceLine.toLowerCase().startsWith('debug(')) { bISdebugStatement = true; } this._logMessage(`+ Hvr: bISdebugStatement=[${bISdebugStatement}], sourceLine=[${sourceLine}]`); let mdLines: string[] = []; bFoundSomething = true; defInfo.declarationlines = []; - const langIdString: string = this.spin1File ? "Spin" : "Spin2"; - this._logMessage(`+ Hvr: searchWord=[${searchWord}], descr=(${builtInFindings.description}), type=[${langIdString} built-in], cat=[${builtInFindings.category}]`); + const langIdString: string = this.spin1File ? 'Spin' : 'Spin2'; + this._logMessage( + `+ Hvr: searchWord=[${searchWord}], descr=(${builtInFindings.description}), type=[${langIdString} built-in], cat=[${builtInFindings.category}]` + ); let titleText: string | undefined = builtInFindings.category; let subTitleText: string | undefined = undefined; if (builtInFindings.type == eBuiltInType.BIT_VARIABLE) { - defInfo.declarationlines = ["(variable) " + searchWord]; + defInfo.declarationlines = ['(variable) ' + searchWord]; // in one case, we are doubling "variable", remove one... - if (titleText && titleText.includes("Spin Variable")) { - titleText = "Spin"; + if (titleText && titleText.includes('Spin Variable')) { + titleText = 'Spin'; } subTitleText = ` variable: *${langIdString} built-in*`; } else if (builtInFindings.type == eBuiltInType.BIT_SYMBOL) { - defInfo.declarationlines = ["(symbol) " + searchWord]; + defInfo.declarationlines = ['(symbol) ' + searchWord]; subTitleText = ` symbol: *${langIdString} built-in*`; } else if (builtInFindings.type == eBuiltInType.BIT_CONSTANT) { - defInfo.declarationlines = ["(constant 32-bit) " + searchWord]; + defInfo.declarationlines = ['(constant 32-bit) ' + searchWord]; subTitleText = ` constant: *${langIdString} built-in*`; } else if (builtInFindings.type == eBuiltInType.BIT_METHOD_POINTER) { - defInfo.declarationlines = ["(built-in method pointer) " + builtInFindings.signature]; + defInfo.declarationlines = ['(built-in method pointer) ' + builtInFindings.signature]; subTitleText = `: *${langIdString} built-in*`; } else if (builtInFindings.type == eBuiltInType.BIT_METHOD) { - defInfo.declarationlines = ["(built-in method) " + builtInFindings.signature]; + defInfo.declarationlines = ['(built-in method) ' + builtInFindings.signature]; subTitleText = `: *${langIdString} built-in*`; } else if (builtInFindings.type == eBuiltInType.BIT_LANG_PART) { defInfo.declarationlines = [`(${langIdString} language) ` + searchWord]; subTitleText = `: *${langIdString} built-in*`; } else if (builtInFindings.type == eBuiltInType.BIT_PASM_DIRECTIVE) { - defInfo.declarationlines = ["(built-in directive) " + builtInFindings.signature]; + defInfo.declarationlines = ['(built-in directive) ' + builtInFindings.signature]; subTitleText = `: *${langIdString} built-in*`; } else if (this.spin1File == false && builtInFindings.type == eBuiltInType.BIT_DEBUG_SYMBOL) { this._logMessage(`+ Hvr: builtInFindings.type=[eBuiltInType.BIT_DEBUG_SYMBOL]`); if (bISdebugStatement) { - defInfo.declarationlines = ["(DEBUG method) " + builtInFindings.signature]; - defInfo.doc = "".concat(`${builtInFindings.category}: *${langIdString} debug built-in*
`, "- " + builtInFindings.description); + defInfo.declarationlines = ['(DEBUG method) ' + builtInFindings.signature]; + defInfo.doc = ''.concat(`${builtInFindings.category}: *${langIdString} debug built-in*
`, '- ' + builtInFindings.description); // deselect lines into mdLines mech... mdLines = []; titleText = undefined; subTitleText = undefined; } else { - defInfo.declarationlines = ["(DEBUG symbol) " + searchWord]; + defInfo.declarationlines = ['(DEBUG symbol) ' + searchWord]; subTitleText = `: *${langIdString} debug built-in*`; } } else if (this.spin1File == false && builtInFindings.type == eBuiltInType.BIT_DEBUG_METHOD) { this._logMessage(`+ Hvr: builtInFindings.type=[eBuiltInType.BIT_DEBUG_METHOD]`); - defInfo.declarationlines = ["(DEBUG method) " + builtInFindings.signature]; + defInfo.declarationlines = ['(DEBUG method) ' + builtInFindings.signature]; subTitleText = `: *${langIdString} debug built-in*`; } else if (builtInFindings.type == eBuiltInType.BIT_TYPE) { defInfo.declarationlines = [`(${langIdString} Storage) ` + searchWord]; @@ -458,41 +472,41 @@ export default class HoverProvider implements Provider { const lineText: string | undefined = tokenFindings.declarationLine; const declLine = lineText ? lineText : DocumentLineAt(document, desiredLine).trim(); // declaration line const nonCommentDecl: string = this.parseUtils.getNonCommentLineRemainder(0, declLine).trim(); - mdLines.push("Decl: " + nonCommentDecl + "
"); + mdLines.push('Decl: ' + nonCommentDecl + '
'); } } mdLines.push(`${titleText}${subTitleText}
`); - mdLines.push("- " + builtInFindings.description); + mdLines.push('- ' + builtInFindings.description); } if (bHaveParams || bHaveReturns) { - mdLines.push("

"); // blank line + mdLines.push('

'); // blank line } if (bHaveParams && builtInFindings.parameters) { for (let parmIdx = 0; parmIdx < builtInFindings.parameters.length; parmIdx++) { const paramDescr = builtInFindings.parameters[parmIdx]; - const lineParts: string[] = paramDescr.split(" - "); - const valueName: string = lineParts[0].replace("`", "").replace("`", ""); + const lineParts: string[] = paramDescr.split(' - '); + const valueName: string = lineParts[0].replace('`', '').replace('`', ''); if (lineParts.length >= 2) { - mdLines.push("@param `" + valueName + "` - " + paramDescr.substring(lineParts[0].length + 3) + "
"); // formatted parameter description + mdLines.push('@param `' + valueName + '` - ' + paramDescr.substring(lineParts[0].length + 3) + '
'); // formatted parameter description } else { // special handling when we have non-param lines, too // FIXME: TODO: is this spin1 only?? (came from spin1 hover in orig code) - mdLines.push(paramDescr + "
"); // formatted parameter description + mdLines.push(paramDescr + '
'); // formatted parameter description } } } if (bHaveReturns && builtInFindings.returns) { for (let parmIdx = 0; parmIdx < builtInFindings.returns.length; parmIdx++) { const returnsDescr = builtInFindings.returns[parmIdx]; - const lineParts: string[] = returnsDescr.split(" - "); - const valueName: string = lineParts[0].replace("`", "").replace("`", ""); + const lineParts: string[] = returnsDescr.split(' - '); + const valueName: string = lineParts[0].replace('`', '').replace('`', ''); if (lineParts.length >= 2) { - mdLines.push("@returns `" + valueName + "` - " + returnsDescr.substring(lineParts[0].length + 3) + "
"); // formatted parameter description + mdLines.push('@returns `' + valueName + '` - ' + returnsDescr.substring(lineParts[0].length + 3) + '
'); // formatted parameter description } } } if (mdLines.length > 0) { - defInfo.doc = mdLines.join(" "); + defInfo.doc = mdLines.join(' '); } else { // if we have title or subTitle but no mdLines then just clear .doc if (titleText || subTitleText) { diff --git a/spin2/server/src/providers/SemanticTokensProvider.ts b/spin2/server/src/providers/SemanticTokensProvider.ts index 7cd549a..df511ba 100644 --- a/spin2/server/src/providers/SemanticTokensProvider.ts +++ b/spin2/server/src/providers/SemanticTokensProvider.ts @@ -1,64 +1,64 @@ -"use strict"; +'use strict'; // src/extensions.ts -import * as lsp from "vscode-languageserver"; -import { Provider } from "."; -import { Context } from "../context"; -import { DocumentFindings, IParsedToken } from "../parser/spin.semantic.findings"; -import { fileSpecFromURI } from "../parser/lang.utils"; +import * as lsp from 'vscode-languageserver'; +import { Provider } from '.'; +import { Context } from '../context'; +import { DocumentFindings, IParsedToken } from '../parser/spin.semantic.findings'; +import { fileSpecFromURI } from '../parser/lang.utils'; export default class SemanticTokensProvider implements Provider { private tokenTypes = new Map(); private tokenModifiers = new Map(); private tokenTypesLegend = [ - "comment", - "string", - "keyword", - "number", - "regexp", - "operator", - "namespace", - "type", - "struct", - "class", - "interface", - "enum", - "typeParameter", - "function", - "method", - "macro", - "variable", - "parameter", - "property", - "label", - "enumMember", - "event", - "returnValue", - "storageType", - "colorName", - "displayType", - "displayName", - "setupParameter", - "feedParameter", + 'comment', + 'string', + 'keyword', + 'number', + 'regexp', + 'operator', + 'namespace', + 'type', + 'struct', + 'class', + 'interface', + 'enum', + 'typeParameter', + 'function', + 'method', + 'macro', + 'variable', + 'parameter', + 'property', + 'label', + 'enumMember', + 'event', + 'returnValue', + 'storageType', + 'colorName', + 'displayType', + 'displayName', + 'setupParameter', + 'feedParameter' ]; private tokenModifiersLegend = [ - "declaration", - "documentation", - "readonly", - "static", - "abstract", - "deprecated", - "modification", - "async", - "definition", - "defaultLibrary", - "local", - "pasmInline", - "instance", - "missingDeclaration", - "illegalUse", + 'declaration', + 'documentation', + 'readonly', + 'static', + 'abstract', + 'deprecated', + 'modification', + 'async', + 'definition', + 'defaultLibrary', + 'local', + 'pasmInline', + 'instance', + 'missingDeclaration', + 'illegalUse' ]; private semanticLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit @@ -79,9 +79,9 @@ export default class SemanticTokensProvider implements Provider { if (this.bLogStarted == false) { this.bLogStarted = true; //Create output channel - this._logMessage("Spin2 Semantic log started."); + this._logMessage('Spin2 Semantic log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -110,7 +110,13 @@ export default class SemanticTokensProvider implements Provider { let tokenIdx: number = 0; allTokens.forEach((token) => { this._logMessage(`Token ${this._tokenString(tokenIdx++, token)}`); - builder.push(token.line, token.startCharacter, token.length, this._encodeTokenType(token.ptTokenType), this._encodeTokenModifiers(token.ptTokenModifiers)); + builder.push( + token.line, + token.startCharacter, + token.length, + this._encodeTokenType(token.ptTokenType), + this._encodeTokenModifiers(token.ptTokenModifiers) + ); }); // return them to client return builder.build(); @@ -121,7 +127,9 @@ export default class SemanticTokensProvider implements Provider { private _tokenString(tokenIdx: number, aToken: IParsedToken): string { let desiredInterp: string = ` -- token(${aToken.line + 1},${aToken.startCharacter})=[idx:${tokenIdx}][len:${aToken.length}](undefined)`; if (aToken != undefined) { - desiredInterp = ` -- token(${aToken.line + 1},${aToken.startCharacter})=[idx:${tokenIdx}][len:${aToken.length}](${aToken.ptTokenType}[${aToken.ptTokenModifiers}])]`; + desiredInterp = ` -- token(${aToken.line + 1},${aToken.startCharacter})=[idx:${tokenIdx}][len:${aToken.length}](${aToken.ptTokenType}[${ + aToken.ptTokenModifiers + }])]`; } return desiredInterp; } @@ -129,7 +137,7 @@ export default class SemanticTokensProvider implements Provider { private _encodeTokenType(tokenType: string): number { if (this.tokenTypes.has(tokenType)) { return this.tokenTypes.get(tokenType)!; - } else if (tokenType === "notInLegend") { + } else if (tokenType === 'notInLegend') { return this.tokenTypes.size + 2; } return 0; @@ -141,7 +149,7 @@ export default class SemanticTokensProvider implements Provider { const tokenModifier = strTokenModifiers[i]; if (this.tokenModifiers.has(tokenModifier)) { result = result | (1 << this.tokenModifiers.get(tokenModifier)!); - } else if (tokenModifier === "notInLegend") { + } else if (tokenModifier === 'notInLegend') { result = result | (1 << (this.tokenModifiers.size + 2)); } } @@ -149,14 +157,14 @@ export default class SemanticTokensProvider implements Provider { } register(connection: lsp.Connection): lsp.ServerCapabilities { - connection.onRequest("textDocument/semanticTokens/full", this.handleGetSemanticTokensFull.bind(this)); + connection.onRequest('textDocument/semanticTokens/full', this.handleGetSemanticTokensFull.bind(this)); return { semanticTokensProvider: { full: { - delta: false, + delta: false }, - legend: this.Spin2Legend(), - }, + legend: this.Spin2Legend() + } }; } } diff --git a/spin2/server/src/providers/SignatureHelpProvider.ts b/spin2/server/src/providers/SignatureHelpProvider.ts index 80f26a3..e9fc002 100644 --- a/spin2/server/src/providers/SignatureHelpProvider.ts +++ b/spin2/server/src/providers/SignatureHelpProvider.ts @@ -1,21 +1,21 @@ -"use strict"; +'use strict'; // src/providers/SignatureHelpProvider.ts -import * as path from "path"; +import * as path from 'path'; -import * as lsp from "vscode-languageserver"; -import { Position, Range, ParameterInformation, SignatureInformation, SignatureHelp } from "vscode-languageserver-types"; -import { TextDocument } from "vscode-languageserver-textdocument"; -import { Provider } from "."; -import { Context } from "../context"; +import * as lsp from 'vscode-languageserver'; +import { Position, Range, ParameterInformation, SignatureInformation, SignatureHelp } from 'vscode-languageserver-types'; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import { Provider } from '.'; +import { Context } from '../context'; -import { DocumentFindings, ITokenDescription } from "../parser/spin.semantic.findings"; -import { IDefinitionInfo, ExtensionUtils, IPairs } from "../parser/spin.extension.utils"; -import { GetWordRangeAtPosition, DocumentLineAt, PositionTranslate } from "../parser/lsp.textDocument.utils"; -import { Spin2ParseUtils, eSearchFilterType } from "../parser/spin2.utils"; -import { Spin1ParseUtils } from "../parser/spin1.utils"; -import { IBuiltinDescription, eBuiltInType } from "../parser/spin.common"; -import { isSpin1File, fileSpecFromURI } from "../parser/lang.utils"; +import { DocumentFindings, ITokenDescription } from '../parser/spin.semantic.findings'; +import { IDefinitionInfo, ExtensionUtils, IPairs } from '../parser/spin.extension.utils'; +import { GetWordRangeAtPosition, DocumentLineAt, PositionTranslate } from '../parser/lsp.textDocument.utils'; +import { Spin2ParseUtils, eSearchFilterType } from '../parser/spin2.utils'; +import { Spin1ParseUtils } from '../parser/spin1.utils'; +import { IBuiltinDescription, eBuiltInType } from '../parser/spin.common'; +import { isSpin1File, fileSpecFromURI } from '../parser/lang.utils'; export default class SignatureHelpProvider implements Provider { private signatureLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit @@ -31,9 +31,9 @@ export default class SignatureHelpProvider implements Provider { if (this.signatureLogEnabled) { if (this.bLogStarted == false) { this.bLogStarted = true; - this._logMessage("Spin signatureHelp log started."); + this._logMessage('Spin signatureHelp log started.'); } else { - this._logMessage("\n\n------------------ NEW FILE ----------------\n\n"); + this._logMessage('\n\n------------------ NEW FILE ----------------\n\n'); } } } @@ -60,9 +60,9 @@ export default class SignatureHelpProvider implements Provider { connection.onSignatureHelp(this.handleGetSignatureHelp.bind(this)); return { signatureHelpProvider: { - triggerCharacters: ["(", ","], - retriggerCharacters: ["(", ","], - }, + triggerCharacters: ['(', ','], + retriggerCharacters: ['(', ','] + } }; } @@ -93,14 +93,16 @@ export default class SignatureHelpProvider implements Provider { this._logMessage(`+ Sig: defInfo NOT found`); return Promise.resolve(null); } - this._logMessage(`+ Sig: defInfo.line=[${defInfo.line}], defInfo.doc=[${defInfo.doc}], defInfo.declarationlines=[${defInfo.declarationlines}], defInfo.parameters=[${defInfo.parameters}]`); + this._logMessage( + `+ Sig: defInfo.line=[${defInfo.line}], defInfo.doc=[${defInfo.doc}], defInfo.declarationlines=[${defInfo.declarationlines}], defInfo.parameters=[${defInfo.parameters}]` + ); if (defInfo.line === callerPos?.line) { // This must be a function definition this._logMessage(`+ Sig: IGNORING function/method definition`); return Promise.resolve(null); } - let declarationText: string = (defInfo.declarationlines || []).join(" ").trim(); + const declarationText: string = (defInfo.declarationlines || []).join(' ').trim(); this._logMessage(`+ Sig: declarationText=[${declarationText}]`); if (!declarationText) { this._logMessage(`+ Sig: IGNORING no declarationText`); @@ -110,28 +112,28 @@ export default class SignatureHelpProvider implements Provider { const signatureHelp: SignatureHelp = { activeParameter: 0, activeSignature: 0, - signatures: [], + signatures: [] }; let sig: string | undefined; let si: SignatureInformation | undefined; - const breakRegEx = /\/gi; // we are globally replacing
or double-newline markers - if (defInfo.doc?.includes("Custom Method")) { + const breakRegEx = /
/gi; // we are globally replacing
or double-newline markers + if (defInfo.doc?.includes('Custom Method')) { // use this for user(custom) methods - const methodType: string = defInfo.declarationlines[0].substring(0, 3).toUpperCase(); - const isPrivate: boolean = methodType == "PRI"; - const sigScope: string = isPrivate ? "private" : "public"; + //const methodType: string = defInfo.declarationlines[0].substring(0, 3).toUpperCase(); + //const isPrivate: boolean = methodType == 'PRI'; + //const sigScope: string = isPrivate ? 'private' : 'public'; //sig = this.signatureWithOutLocals(`(object ${sigScope} method) ` + nonCommentDecl); sig = defInfo.declarationlines[0]; - const methDescr: string = this._removeCustomMethod(this.getMethodDescriptionFromDoc(defInfo.doc).replace(breakRegEx, "\n")); + const methDescr: string = this._removeCustomMethod(this.getMethodDescriptionFromDoc(defInfo.doc).replace(breakRegEx, '\n')); si = SignatureInformation.create(sig, methDescr); if (si) { si.parameters = this.getParametersAndReturnTypeFromDoc(defInfo.doc); } } else if (defInfo.line == -1) { // use this for built-in methods - const methDescr: string = this.getMethodDescriptionFromDoc(defInfo.doc).replace(breakRegEx, "\n"); - sig = "(Built-in) " + defInfo.declarationlines[0]; + const methDescr: string = this.getMethodDescriptionFromDoc(defInfo.doc).replace(breakRegEx, '\n'); + sig = '(Built-in) ' + defInfo.declarationlines[0]; this._logMessage(`+ Sig: sig=[${sig}], methDescr=[${methDescr}]`); si = SignatureInformation.create(sig, methDescr); if (si && defInfo.parameters) { @@ -156,36 +158,36 @@ export default class SignatureHelpProvider implements Provider { } private _removeCustomMethod(lineWNewlines: string): string { - const lines: string[] = lineWNewlines.split("\n"); + const lines: string[] = lineWNewlines.split('\n'); const filtLines: string[] = []; for (let index = 0; index < lines.length; index++) { const element = lines[index]; - if (!element.includes("Custom Method")) { + if (!element.includes('Custom Method')) { filtLines.push(element); } } - return filtLines.join("\n"); + return filtLines.join('\n'); } private signatureWithOutLocals(signature: string): string { let trimmedSignature: string = signature; - const localIndicaPosn: number = trimmedSignature.indexOf("|"); + const localIndicaPosn: number = trimmedSignature.indexOf('|'); if (localIndicaPosn != -1) { - trimmedSignature = trimmedSignature.substring(0, localIndicaPosn).replace(/\s+$/, ""); + trimmedSignature = trimmedSignature.substring(0, localIndicaPosn).replace(/\s+$/, ''); } return trimmedSignature; } private getParametersAndReturnTypeFromParameterStringAr(paramList: string[] | undefined): ParameterInformation[] { // convert list of parameters frombuilt-in description tables to vscode ParameterInformation's - let parameterDetails: ParameterInformation[] = []; + const parameterDetails: ParameterInformation[] = []; if (paramList && paramList.length > 0) { for (let paramIdx = 0; paramIdx < paramList.length; paramIdx++) { const paramDescr = paramList[paramIdx]; // SPIN1: cognew and coginit have lines without param - description hyphens, skip them - if (paramDescr.includes("-")) { + if (paramDescr.includes('-')) { const lineParts: string[] = paramDescr.split(/[ \t]/).filter(Boolean); - let paramName: string = lineParts[0]; + const paramName: string = lineParts[0]; this._logMessage(`+ Sig: gpartfpsa paramName=[${paramName}], paramDescr=[${paramDescr}})`); const newParamInfo: ParameterInformation = ParameterInformation.create(paramName, paramDescr); parameterDetails.push(newParamInfo); @@ -207,8 +209,13 @@ export default class SignatureHelpProvider implements Provider { const objectRef = adjustedPos[1]; const searchWord = adjustedPos[2]; wordPosition = adjustedPos[3]; - let fileBasename = path.basename(document.uri); - this._logMessage(`+ Sig: searchWord=[${searchWord}], adjPos=(${wordPosition.line},${wordPosition.character}), file=[${fileBasename}], line=[${DocumentLineAt(document, wordPosition)}]`); + const fileBasename = path.basename(document.uri); + this._logMessage( + `+ Sig: searchWord=[${searchWord}], adjPos=(${wordPosition.line},${wordPosition.character}), file=[${fileBasename}], line=[${DocumentLineAt( + document, + wordPosition + )}]` + ); this._logMessage(`+ Sig: definitionLocation() EXIT after getting symbol details`); return this.getSymbolDetails(document, wordPosition, objectRef, searchWord); @@ -220,12 +227,12 @@ export default class SignatureHelpProvider implements Provider { file: document.uri, line: position.line, column: position.character, - toolUsed: "????", + toolUsed: '????', declarationlines: [], parameters: [], returns: [], - doc: "{huh, I have no clue!}", - name: path.basename(document.uri), + doc: '{huh, I have no clue!}', + name: path.basename(document.uri) }; let symbolsSet: DocumentFindings = this.symbolsFound; @@ -252,26 +259,30 @@ export default class SignatureHelpProvider implements Provider { let cursorCharPosn = position.character; do { const char: string = sourceLineRaw.substring(cursorCharPosn, cursorCharPosn); - if (char == " " || char == "\t") { + if (char == ' ' || char == '\t') { break; } cursorCharPosn--; } while (cursorCharPosn > 0); - const isSignatureLine: boolean = sourceLine.toLowerCase().startsWith("pub") || sourceLine.toLowerCase().startsWith("pri"); - const isPrivate: boolean = sourceLine.toLowerCase().startsWith("pri"); + const isSignatureLine: boolean = sourceLine.toLowerCase().startsWith('pub') || sourceLine.toLowerCase().startsWith('pri'); + const isPrivate: boolean = sourceLine.toLowerCase().startsWith('pri'); // spin1 doesn't support debug() - const isDebugLine: boolean = this.spin1File == false && sourceLine.toLowerCase().startsWith("debug("); - this._logMessage(`+ Sig: getSymbolDetails() isSignatureLine=(${isSignatureLine}), isDebugLine=(${isDebugLine}), isObjectReference=(${isObjectReference})`); + const isDebugLine: boolean = this.spin1File == false && sourceLine.toLowerCase().startsWith('debug('); + this._logMessage( + `+ Sig: getSymbolDetails() isSignatureLine=(${isSignatureLine}), isDebugLine=(${isDebugLine}), isObjectReference=(${isObjectReference})` + ); let bFoundSomething: boolean = false; // we've no answer - let builtInFindings: IBuiltinDescription = isDebugLine ? this.parseUtils.docTextForDebugBuiltIn(searchWord) : this.parseUtils.docTextForBuiltIn(searchWord, eSearchFilterType.FT_NO_PREFERENCE); + const builtInFindings: IBuiltinDescription = isDebugLine + ? this.parseUtils.docTextForDebugBuiltIn(searchWord) + : this.parseUtils.docTextForBuiltIn(searchWord, eSearchFilterType.FT_NO_PREFERENCE); if (!builtInFindings.found) { this._logMessage(`+ Sig: built-in=[${searchWord}], NOT found!`); } else { this._logMessage(`+ Sig: built-in=[${searchWord}], Found!`); } - let bFoundParseToken: boolean = isObjectReference ? symbolsSet.isPublicToken(searchWord) : symbolsSet.isKnownToken(searchWord); + const bFoundParseToken: boolean = isObjectReference ? symbolsSet.isPublicToken(searchWord) : symbolsSet.isKnownToken(searchWord); if (!bFoundParseToken) { this._logMessage(`+ Sig: token=[${searchWord}], NOT found!`); } else { @@ -295,17 +306,20 @@ export default class SignatureHelpProvider implements Provider { const typeString: string = tokenFindings.interpretation; defInfo.line = tokenFindings.declarationLineIdx; // report not our line but where the method is declared - const desiredLinePosition: Position = { line: tokenFindings.declarationLineIdx, character: 0 }; + const desiredLinePosition: Position = { + line: tokenFindings.declarationLineIdx, + character: 0 + }; const lineText: string | undefined = tokenFindings.declarationLine; const declLine = lineText ? lineText : DocumentLineAt(document, desiredLinePosition).trim(); // declaration line const nonCommentDecl: string = this.parseUtils.getNonCommentLineRemainder(0, declLine).trim(); const signatureNoLocals: string = this.signatureWithOutLocals(nonCommentDecl).substring(4); - let docRootCommentMD: string = `(*${scopeString}* ${typeString}) **${nameString}**`; // parsedFindings + //let docRootCommentMD: string = `(*${scopeString}* ${typeString}) **${nameString}**`; // parsedFindings let typeInterpWName: string = `(${scopeString} ${typeString}) ${nameString}`; // better formatting of interp let typeInterp: string = `(${scopeString} ${typeString})`; // better formatting of interp if (scopeString.length == 0) { - docRootCommentMD = `(${typeString}) **${nameString}**`; + //docRootCommentMD = `(${typeString}) **${nameString}**`; typeInterpWName = `(${typeString}) ${nameString}`; // better formatting of interp typeInterp = `(${typeString})`; } @@ -313,9 +327,9 @@ export default class SignatureHelpProvider implements Provider { // ------------------------------- // load CODE section of signature help // - if (typeString.includes("method")) { - if (tokenFindings.scope.includes("object")) { - const sigPrefix: string = isPrivate ? "PRI" : "PUB"; + if (typeString.includes('method')) { + if (tokenFindings.scope.includes('object')) { + const sigPrefix: string = isPrivate ? 'PRI' : 'PUB'; defInfo.declarationlines = [`(${scopeString} ${typeString}) ${sigPrefix} ${signatureNoLocals}`]; } else if (isSignatureLine) { // for method declaration use declaration line @@ -336,37 +350,37 @@ export default class SignatureHelpProvider implements Provider { // ------------------------------- // load MarkDown section // - let mdLines: string[] = []; - if (typeString.includes("method")) { + const mdLines: string[] = []; + if (typeString.includes('method')) { //if (!isSignatureLine) { mdLines.push(`Custom Method: User defined
`); // this is removed later //} } if ( - (tokenFindings.interpretation.includes("32-bit constant") && !tokenFindings.relatedObjectName) || - tokenFindings.interpretation.includes("shared variable") || - tokenFindings.interpretation.includes("instance variable") || - tokenFindings.interpretation.includes("inline-pasm variable") || - tokenFindings.interpretation.includes("enum value") + (tokenFindings.interpretation.includes('32-bit constant') && !tokenFindings.relatedObjectName) || + tokenFindings.interpretation.includes('shared variable') || + tokenFindings.interpretation.includes('instance variable') || + tokenFindings.interpretation.includes('inline-pasm variable') || + tokenFindings.interpretation.includes('enum value') ) { // if global constant push declaration line, first... - mdLines.push("Decl: " + nonCommentDecl + "
"); + mdLines.push('Decl: ' + nonCommentDecl + '
'); } - if (tokenFindings.interpretation.includes("pasm label") && tokenFindings.relatedFilename) { - mdLines.push("Refers to file: " + tokenFindings.relatedFilename + "
"); + if (tokenFindings.interpretation.includes('pasm label') && tokenFindings.relatedFilename) { + mdLines.push('Refers to file: ' + tokenFindings.relatedFilename + '
'); } - if (tokenFindings.interpretation.includes("named instance") && tokenFindings.relatedFilename) { - mdLines.push("An instance of: " + tokenFindings.relatedFilename + "
"); + if (tokenFindings.interpretation.includes('named instance') && tokenFindings.relatedFilename) { + mdLines.push('An instance of: ' + tokenFindings.relatedFilename + '
'); } if (tokenFindings.relatedObjectName) { - mdLines.push("Found in object: " + tokenFindings.relatedObjectName + "
"); + mdLines.push('Found in object: ' + tokenFindings.relatedObjectName + '
'); } if (tokenFindings.declarationComment) { // have object comment mdLines.push(tokenFindings.declarationComment); } else { // no object comment - if (typeString.includes("method")) { + if (typeString.includes('method')) { // if methods show that we should have doc-comment, except for external object reference were we can't get to doc comments, yet!... if (!tokenFindings.relatedObjectName) { mdLines.push(`*(no doc-comment provided)*`); @@ -376,7 +390,7 @@ export default class SignatureHelpProvider implements Provider { } } if (mdLines.length > 0) { - defInfo.doc = mdLines.join(" "); + defInfo.doc = mdLines.join(' '); } else { defInfo.doc = undefined; } @@ -385,17 +399,19 @@ export default class SignatureHelpProvider implements Provider { // no token, let's check for built-in language parts if (builtInFindings.found) { let bISdebugStatement: boolean = false; - if (searchWord.toLowerCase() == "debug" && sourceLine.toLowerCase().startsWith("debug(")) { + if (searchWord.toLowerCase() == 'debug' && sourceLine.toLowerCase().startsWith('debug(')) { bISdebugStatement = true; } this._logMessage(`+ Sig: bISdebugStatement=[${bISdebugStatement}], sourceLine=[${sourceLine}]`); - let mdLines: string[] = []; + const mdLines: string[] = []; bFoundSomething = true; defInfo.declarationlines = []; - const langIdString: string = this.spin1File ? "Spin" : "Spin2"; - this._logMessage(`+ Sig: searchWord=[${searchWord}], descr=(${builtInFindings.description}), type=[${langIdString} built-in], cat=[${builtInFindings.category}]`); + const langIdString: string = this.spin1File ? 'Spin' : 'Spin2'; + this._logMessage( + `+ Sig: searchWord=[${searchWord}], descr=(${builtInFindings.description}), type=[${langIdString} built-in], cat=[${builtInFindings.category}]` + ); - let titleText: string | undefined = builtInFindings.category; + const titleText: string | undefined = builtInFindings.category; let subTitleText: string | undefined = undefined; if (builtInFindings.type == eBuiltInType.BIT_METHOD) { defInfo.declarationlines = [builtInFindings.signature]; @@ -410,18 +426,21 @@ export default class SignatureHelpProvider implements Provider { if (builtInFindings.type == eBuiltInType.BIT_CONSTANT && bFoundParseToken) { const tokenFindings = symbolsSet.getTokenWithDescription(searchWord, position.line + 1); if (tokenFindings.found) { - const desiredLinePosition: Position = { line: tokenFindings.declarationLineIdx, character: 0 }; + const desiredLinePosition: Position = { + line: tokenFindings.declarationLineIdx, + character: 0 + }; const lineText: string | undefined = tokenFindings.declarationLine; const declLine = lineText ? lineText : DocumentLineAt(document, desiredLinePosition).trim(); // declaration line const nonCommentDecl: string = this.parseUtils.getNonCommentLineRemainder(0, declLine).trim(); - mdLines.push("Decl: " + nonCommentDecl + "
"); + mdLines.push('Decl: ' + nonCommentDecl + '
'); } } mdLines.push(`${titleText}${subTitleText}
`); - mdLines.push("- " + builtInFindings.description); + mdLines.push('- ' + builtInFindings.description); } if (mdLines.length > 0) { - defInfo.doc = mdLines.join(" "); + defInfo.doc = mdLines.join(' '); } else { // if we have title or subTitle but no mdLines then just clear .doc if (titleText || subTitleText) { @@ -446,16 +465,19 @@ export default class SignatureHelpProvider implements Provider { // ["foo", "bar string", "baz string"] // Takes care of balancing parens so to not get confused by signatures like: // (pattern string, handler func(ResponseWriter, *Request)) { - private getParametersAndReturnType(signature: string): { params: string[]; returnType: string } { + private getParametersAndReturnType(signature: string): { + params: string[]; + returnType: string; + } { const params: string[] = []; let parenCount = 0; let lastStart = 1; for (let i = 1; i < signature.length; i++) { switch (signature[i]) { - case "(": + case '(': parenCount++; break; - case ")": + case ')': parenCount--; if (parenCount < 0) { if (i > lastStart) { @@ -463,11 +485,11 @@ export default class SignatureHelpProvider implements Provider { } return { params, - returnType: i < signature.length - 1 ? signature.substr(i + 1) : "", + returnType: i < signature.length - 1 ? signature.substr(i + 1) : '' }; } break; - case ",": + case ',': if (parenCount === 0) { params.push(signature.substring(lastStart, i)); lastStart = i + 2; @@ -475,34 +497,34 @@ export default class SignatureHelpProvider implements Provider { break; } } - return { params: [], returnType: "" }; + return { params: [], returnType: '' }; } private getMethodDescriptionFromDoc(docMD: string | undefined): string { - let methodDescr: string = ""; + let methodDescr: string = ''; // this isolates mothd description lines and returns them // skipping first line, and @param, @returns lines if (docMD) { - const lines = docMD.split("
"); + const lines = docMD.split('
'); this._logMessage(`+ Sig: gmdfd lines=[${lines}]({${lines.length}})`); - let descrLines: string[] = []; + const descrLines: string[] = []; if (lines.length > 0) { for (let lnIdx = 1; lnIdx < lines.length; lnIdx++) { const sglLine = lines[lnIdx]; - if (sglLine.includes("@param")) { + if (sglLine.includes('@param')) { continue; } - if (sglLine.includes("@returns")) { + if (sglLine.includes('@returns')) { continue; } - if (sglLine.includes("NOTE: insert comment template")) { + if (sglLine.includes('NOTE: insert comment template')) { // specific so we don't filter users comments continue; } descrLines.push(sglLine); } if (descrLines.length > 0) { - methodDescr = descrLines.join("
"); + methodDescr = descrLines.join('
'); } } } @@ -511,13 +533,13 @@ export default class SignatureHelpProvider implements Provider { } private getParametersAndReturnTypeFromDoc(docMD: string): ParameterInformation[] { - let parameterDetails: ParameterInformation[] = []; + const parameterDetails: ParameterInformation[] = []; // this ignores return type info and just provides deets on param's - const lines = docMD.split("
").filter(Boolean); + const lines = docMD.split('
').filter(Boolean); if (lines.length > 0) { for (let lnIdx = 0; lnIdx < lines.length; lnIdx++) { const sglLine = lines[lnIdx]; - if (sglLine.includes("@param")) { + if (sglLine.includes('@param')) { const lineParts: string[] = sglLine.split(/[ \t]/).filter(Boolean); let paramName: string = lineParts[1]; this._logMessage(`+ Sig: gpartfd paramName=[${paramName}], lineParts=[${lineParts}]({${lineParts.length}})`); @@ -539,7 +561,7 @@ export default class SignatureHelpProvider implements Provider { const origPosition: Position = position; while (position.character > 0) { const lineText = DocumentLineAt(document, position); - let wordRange: Range | undefined = GetWordRangeAtPosition(lineText, position); + const wordRange: Range | undefined = GetWordRangeAtPosition(lineText, position); if (wordRange) { position = wordRange.start; break; @@ -573,24 +595,25 @@ export default class SignatureHelpProvider implements Provider { } // if its current line, get the text until the position given, otherwise get the full line. - const [currentLine, characterPosition] = lineNr === position.line ? [line.substring(0, position.character), position.character] : [line, line.length - 1]; + const [currentLine, characterPosition] = + lineNr === position.line ? [line.substring(0, position.character), position.character] : [line, line.length - 1]; for (let char = characterPosition; char >= 0; char--) { switch (currentLine[char]) { - case "(": + case '(': parenBalance--; if (parenBalance < 0) { this._logMessage(`+ Sig: walkBTBOC() = open[line=${lineNr}, char=${char}]`); return { openParen: { line: lineNr, character: char }, - commas, + commas }; } break; - case ")": + case ')': parenBalance++; break; - case ",": + case ',': { const commaPos: Position = { line: lineNr, character: char }; if (parenBalance === 0 && !this.extensionUtils.isPositionInString(line, commaPos, stringsFound, ticVarsFound)) { diff --git a/spin2/server/src/providers/TextDocumentSyncProvider.ts b/spin2/server/src/providers/TextDocumentSyncProvider.ts index 4fd23eb..10a3479 100644 --- a/spin2/server/src/providers/TextDocumentSyncProvider.ts +++ b/spin2/server/src/providers/TextDocumentSyncProvider.ts @@ -1,13 +1,13 @@ -import * as lsp from "vscode-languageserver"; -import { TextDocument } from "vscode-languageserver-textdocument"; +import * as lsp from 'vscode-languageserver'; +import { TextDocument } from 'vscode-languageserver-textdocument'; //import Parser from "web-tree-sitter"; -import { Provider } from "."; -import { Context, ServerBehaviorConfiguration, EditorConfiguration } from "../context"; +import { Provider } from '.'; +import { Context, ServerBehaviorConfiguration, EditorConfiguration } from '../context'; //import DiagnosticProcessor from "../diagnostics"; -import DocumentProcessor, { ProcessedDocument } from "../DocumentProcessor"; -import { positionToPoint, Point } from "../geometry"; -import { fileSpecFromURI } from "../parser/lang.utils"; +import DocumentProcessor, { ProcessedDocument } from '../DocumentProcessor'; +import { positionToPoint, Point } from '../geometry'; +import { fileSpecFromURI } from '../parser/lang.utils'; export interface Edit { startIndex: number; @@ -60,6 +60,7 @@ export default class TextDocumentSyncProvider implements Provider { const updatedDoc = TextDocument.update(document, contentChanges, version); + // eslint-disable-next-line @typescript-eslint/no-unused-vars await this.processor.process(updatedDoc).then(({ parseResult }) => { // Send just local parser diagnostics // FIXME: not quite correct but works for now... @@ -86,19 +87,19 @@ export default class TextDocumentSyncProvider implements Provider { async getLatestClientConfig(): Promise { let configChanged: boolean = false; - await this.ctx.connection.workspace.getConfiguration("spinExtension.ServerBehavior").then((serverConfiguration: ServerBehaviorConfiguration) => { + await this.ctx.connection.workspace.getConfiguration('spinExtension.ServerBehavior').then((serverConfiguration: ServerBehaviorConfiguration) => { if (serverConfiguration == null) { this.ctx.logger.log(`TRC: DP.process() ERROR! get settings received no info: config left at defaults`); } else { configChanged = - serverConfiguration["maxNumberOfReportedIssues"] != this.ctx.parserConfig.maxNumberOfReportedIssues || - serverConfiguration["highlightFlexspinDirectives"] != this.ctx.parserConfig.highlightFlexspinDirectives; + serverConfiguration['maxNumberOfReportedIssues'] != this.ctx.parserConfig.maxNumberOfReportedIssues || + serverConfiguration['highlightFlexspinDirectives'] != this.ctx.parserConfig.highlightFlexspinDirectives; if (configChanged) { - this.ctx.parserConfig.maxNumberOfReportedIssues = serverConfiguration["maxNumberOfReportedIssues"]; + this.ctx.parserConfig.maxNumberOfReportedIssues = serverConfiguration['maxNumberOfReportedIssues']; if (this.ctx.parserConfig.maxNumberOfReportedIssues < 0) { this.ctx.parserConfig.maxNumberOfReportedIssues = 0; // don't confuse our initial startup! } - this.ctx.parserConfig.highlightFlexspinDirectives = serverConfiguration["highlightFlexspinDirectives"]; + this.ctx.parserConfig.highlightFlexspinDirectives = serverConfiguration['highlightFlexspinDirectives']; } } //this.ctx.logger.log(`TRC: process() received settings RAW=[${serverConfiguration}], JSON=[${JSON.stringify(serverConfiguration)}]`); @@ -106,24 +107,28 @@ export default class TextDocumentSyncProvider implements Provider { ` DBG -- ctx.parserConfig.maxNumberOfReportedIssues=(${this.ctx.parserConfig.maxNumberOfReportedIssues}), highlightFlexspinDirectives=[${this.ctx.parserConfig.highlightFlexspinDirectives}], changes=(${configChanged})` ); }); - await this.ctx.connection.workspace.getConfiguration("editor").then((editorConfiguration: EditorConfiguration) => { + await this.ctx.connection.workspace.getConfiguration('editor').then((editorConfiguration: EditorConfiguration) => { if (editorConfiguration == null) { this.ctx.logger.log(`TRC: DP.process() ERROR! get editor settings received no info: config left at defaults`); } else { - configChanged = editorConfiguration["tabSize"] != this.ctx.editorConfig.tabSize || editorConfiguration["insertSpaces"] != this.ctx.editorConfig.insertSpaces; + configChanged = + editorConfiguration['tabSize'] != this.ctx.editorConfig.tabSize || + editorConfiguration['insertSpaces'] != this.ctx.editorConfig.insertSpaces; if (configChanged) { - this.ctx.editorConfig.tabSize = editorConfiguration["tabSize"]; - this.ctx.editorConfig.insertSpaces = editorConfiguration["insertSpaces"]; + this.ctx.editorConfig.tabSize = editorConfiguration['tabSize']; + this.ctx.editorConfig.insertSpaces = editorConfiguration['insertSpaces']; } } //this.ctx.logger.log(`TRC: process() received settings RAW=[${serverConfiguration}], JSON=[${JSON.stringify(serverConfiguration)}]`); - this.ctx.logger.log(` DBG -- ctx.editorConfiguration.tabSize=(${this.ctx.editorConfig.tabSize}), insertSpaces=[${this.ctx.editorConfig.insertSpaces}], changes=(${configChanged})`); + this.ctx.logger.log( + ` DBG -- ctx.editorConfiguration.tabSize=(${this.ctx.editorConfig.tabSize}), insertSpaces=[${this.ctx.editorConfig.insertSpaces}], changes=(${configChanged})` + ); }); return configChanged; } async handleConfigurationChanged({ settings }: lsp.DidChangeConfigurationParams): Promise { - this.ctx.logger.log("TRC: DOC have settings reparse all docs"); + this.ctx.logger.log('TRC: DOC have settings reparse all docs'); this.ctx.logger.log(`TRC: onDidChangeConfiguration() change.settings=[${settings}]`); if (settings != null) { this.ctx.logger.log(`TRC: onDidChangeConfiguration() new settings [${JSON.stringify(settings)}]`); @@ -141,13 +146,13 @@ export default class TextDocumentSyncProvider implements Provider { } async handleSaveTextDocument({ textDocument: { uri } }: lsp.DidSaveTextDocumentParams) { - this.ctx.logger.log("TRC: DOC-SAVE: update symbols for: [" + uri + "] and those including URI"); + this.ctx.logger.log('TRC: DOC-SAVE: update symbols for: [' + uri + '] and those including URI'); await this.fileDiagnostics(uri); this._showStats(); // dump storage stats } async handleCloseTextDocument({ textDocument: { uri } }: lsp.DidCloseTextDocumentParams) { - this.ctx.logger.log("TRC: DOC-CLOSE: remove symbols for: [" + uri + "] and included files if no longer needed"); + this.ctx.logger.log('TRC: DOC-CLOSE: remove symbols for: [' + uri + '] and included files if no longer needed'); const docFSpec: string = fileSpecFromURI(uri); const processedDocument = this.ctx.docsByFSpec.get(docFSpec); // if we have symbols for this file... @@ -162,7 +167,7 @@ export default class TextDocumentSyncProvider implements Provider { if (openCount == 0) { this.ctx.docsByFSpec.clear(); this.ctx.findingsByFSpec.clear(); - this.ctx.logger.log("TRC: close: ALL documents Closed"); + this.ctx.logger.log('TRC: close: ALL documents Closed'); } this._showStats(); // dump storage stats } @@ -196,11 +201,13 @@ export default class TextDocumentSyncProvider implements Provider { const processedDocument: ProcessedDocument | undefined = this.ctx.docsByFSpec.get(docFSpec); if (processedDocument) { this.ctx.logger.log(`TRC: CHK CFG maxNumberOfReportedIssues=(${this.ctx.parserConfig.maxNumberOfReportedIssues})`); - const captureDiagnostics: lsp.Diagnostic[] = processedDocument.parseResult.allDiagnosticMessages(this.ctx.parserConfig.maxNumberOfReportedIssues); + const captureDiagnostics: lsp.Diagnostic[] = processedDocument.parseResult.allDiagnosticMessages( + this.ctx.parserConfig.maxNumberOfReportedIssues + ); const uri = processedDocument.document.uri; this.connection.sendDiagnostics({ uri, - diagnostics: [...captureDiagnostics], + diagnostics: [...captureDiagnostics] }); } } @@ -227,50 +234,50 @@ export default class TextDocumentSyncProvider implements Provider { let captureDiagnostics: lsp.Diagnostic[] = processedDocument.parseResult.allDiagnosticMessages(this.ctx.parserConfig.maxNumberOfReportedIssues); //this.ctx.logger.log(`CL-TRC: captureDiagnostics=[${JSON.stringify(captureDiagnostics)}]`); // crappy override for unit testing - if (uri.endsWith("diagnostics.spin2")) { + if (uri.endsWith('diagnostics.spin2')) { captureDiagnostics = this.validateTestDocument(processedDocument); } this.connection.sendDiagnostics({ uri, - diagnostics: [...captureDiagnostics], + diagnostics: [...captureDiagnostics] }); } private validateTestDocument(documentInfo: ProcessedDocument): lsp.Diagnostic[] { - let diagnostics: lsp.Diagnostic[] = []; + const diagnostics: lsp.Diagnostic[] = []; // The validator creates diagnostics for all uppercase words length 2 and more const textDocument = documentInfo.document; const text = textDocument.getText(); const pattern = /\b[A-Z]{2,}\b/g; let m: RegExpExecArray | null; - let problems = 0; + //let problems = 0; while ((m = pattern.exec(text))) { - problems++; + //problems++; const diagnostic: lsp.Diagnostic = { severity: lsp.DiagnosticSeverity.Warning, range: { start: textDocument.positionAt(m.index), - end: textDocument.positionAt(m.index + m[0].length), + end: textDocument.positionAt(m.index + m[0].length) }, message: `${m[0]} is all uppercase.`, - source: "ex", + source: 'ex' }; diagnostic.relatedInformation = [ { location: { uri: textDocument.uri, - range: Object.assign({}, diagnostic.range), + range: Object.assign({}, diagnostic.range) }, - message: "Spelling matters", + message: 'Spelling matters' }, { location: { uri: textDocument.uri, - range: Object.assign({}, diagnostic.range), + range: Object.assign({}, diagnostic.range) }, - message: "Particularly for names", - }, + message: 'Particularly for names' + } ]; diagnostics.push(diagnostic); } @@ -280,7 +287,7 @@ export default class TextDocumentSyncProvider implements Provider { changeToEdit(document: TextDocument, change: lsp.TextDocumentContentChangeEvent): Edit { // convert a change to an edit object if (!lsp.TextDocumentContentChangeEvent.isIncremental(change)) { - throw new Error("Not incremental"); + throw new Error('Not incremental'); } const rangeOffset = document.offsetAt(change.range.start); const rangeLength = document.offsetAt(change.range.end) - rangeOffset; @@ -290,7 +297,7 @@ export default class TextDocumentSyncProvider implements Provider { newEndPosition: positionToPoint(document.positionAt(rangeOffset + change.text.length)), startIndex: rangeOffset, oldEndIndex: rangeOffset + rangeLength, - newEndIndex: rangeOffset + change.text.length, + newEndIndex: rangeOffset + change.text.length }; } @@ -302,7 +309,7 @@ export default class TextDocumentSyncProvider implements Provider { connection.onDidChangeConfiguration(this.handleConfigurationChanged.bind(this)); connection.onDidChangeWatchedFiles(this.handleWatchedFilesChange.bind(this)); return { - textDocumentSync: lsp.TextDocumentSyncKind.Incremental, + textDocumentSync: lsp.TextDocumentSyncKind.Incremental }; } } diff --git a/spin2/server/src/providers/index.ts b/spin2/server/src/providers/index.ts index 251f732..e753867 100644 --- a/spin2/server/src/providers/index.ts +++ b/spin2/server/src/providers/index.ts @@ -1,24 +1,24 @@ -"use strict"; +'use strict'; // src/providers/index.ts -import { ClientCapabilities, Connection, ServerCapabilities } from "vscode-languageserver"; -import { Context } from "../context"; +import { ClientCapabilities, Connection, ServerCapabilities } from 'vscode-languageserver'; +import { Context } from '../context'; //import CompletionProvider from "./CompletionProvider"; -import SemanticTokensProvider from "./SemanticTokensProvider"; +import SemanticTokensProvider from './SemanticTokensProvider'; // import ConfiguratonProvider from "./ConfigurationProvider"; -import DefinitionProvider from "./DefinitionProvider"; +import DefinitionProvider from './DefinitionProvider'; // import DocumentFormattingProvider from "./DocumentFormatttingProvider"; // import DocumentHighlightProvider from "./DocumentHighlightProvider"; // import DocumentLinkProvider from "./DocumentLinkProvider"; -import DocumentSymbolProvider from "./DocumentSymbolProvider"; +import DocumentSymbolProvider from './DocumentSymbolProvider'; // import FileOperationsProvider from "./FileOperationsProvider"; -import FoldingRangeProvider from "./FoldingRangeProvider"; -import HoverProvider from "./HoverProvider"; +import FoldingRangeProvider from './FoldingRangeProvider'; +import HoverProvider from './HoverProvider'; // import ReferencesProvider from "./ReferencesProvider"; // import RenameProvider from "./RenameProvider"; -import SignatureHelpProvider from "./SignatureHelpProvider"; -import TextDocumentSyncProvider from "./TextDocumentSyncProvider"; +import SignatureHelpProvider from './SignatureHelpProvider'; +import TextDocumentSyncProvider from './TextDocumentSyncProvider'; // import WorkspaceSymbolProvider from "./WorkspaceSymbolProvider"; export interface Provider { @@ -39,11 +39,16 @@ const providers = [ // ReferencesProvider, // RenameProvider, SignatureHelpProvider, - TextDocumentSyncProvider, + TextDocumentSyncProvider // WorkspaceSymbolProvider, ]; -export default function registerProviders(connection: Connection, ctx: Context, clientCapabilities: ClientCapabilities): ServerCapabilities { +export default function registerProviders( + connection: Connection, + ctx: Context, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + clientCapabilities: ClientCapabilities +): ServerCapabilities { return providers.reduce((acc, P) => { const p = new P(ctx); const c = p.register(connection); diff --git a/spin2/server/src/server.ts b/spin2/server/src/server.ts index 18211f8..f876ad7 100644 --- a/spin2/server/src/server.ts +++ b/spin2/server/src/server.ts @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; // src/server.ts /* -------------------------------------------------------------------------------------------- @@ -13,12 +13,12 @@ import { DidChangeConfigurationNotification, InitializeResult, ServerCapabilities, - FileChangeType, -} from "vscode-languageserver/node"; + FileChangeType +} from 'vscode-languageserver/node'; -import { TextDocument } from "vscode-languageserver-textdocument"; -import registerProviders from "./providers"; -import { createContext } from "./context"; +import { TextDocument } from 'vscode-languageserver-textdocument'; +import registerProviders from './providers'; +import { createContext } from './context'; // Create a connection for the server, using Node's IPC as a transport. // Also include all preview / proposed LSP features. @@ -29,6 +29,7 @@ const documents: TextDocuments = new TextDocuments(TextDocument); let hasConfigurationCapability = false; let hasWorkspaceFolderCapability = false; +// eslint-disable-next-line @typescript-eslint/no-unused-vars let hasDiagnosticRelatedInformationCapability = false; connection.onInitialize(async (params: InitializeParams) => { @@ -38,20 +39,24 @@ connection.onInitialize(async (params: InitializeParams) => { // If not, we fall back using global settings. hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration); hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders); - hasDiagnosticRelatedInformationCapability = !!(capabilities.textDocument && capabilities.textDocument.publishDiagnostics && capabilities.textDocument.publishDiagnostics.relatedInformation); + hasDiagnosticRelatedInformationCapability = !!( + capabilities.textDocument && + capabilities.textDocument.publishDiagnostics && + capabilities.textDocument.publishDiagnostics.relatedInformation + ); const ctx = await createContext(params.workspaceFolders ?? [], connection.console, connection); const registrations: ServerCapabilities = registerProviders(connection, ctx, params.capabilities); const result: InitializeResult = { - capabilities: registrations, + capabilities: registrations }; if (hasWorkspaceFolderCapability) { result.capabilities.workspace = { workspaceFolders: { - supported: true, - }, + supported: true + } }; } connection.console.log(`CL-TRC: onInitialize() Workspace folders [${JSON.stringify(params.workspaceFolders)}]`); diff --git a/spin2/themes/isp-spin-dark-bg-theme.json b/spin2/themes/isp-spin-dark-bg-theme.json index 4f6d1a8..e7ef601 100644 --- a/spin2/themes/isp-spin-dark-bg-theme.json +++ b/spin2/themes/isp-spin-dark-bg-theme.json @@ -34,6 +34,7 @@ "editor.inactiveSelectionBackground": "#888888e0", "editor.selectionBackground": "#BBBBBBe0", "editor.selectionHighlightBackground": "#d59880", + "editorCursor.foreground": "#000000", "editorGroup.border": "#ffffff17", "editorGroupHeader.tabsBackground": "#181818", "editorGroupHeader.tabsBorder": "#ffffff15", @@ -139,6 +140,7 @@ "terminal.foreground": "#cccccc", "terminal.inactiveSelectionBackground": "#3A3D41", "terminal.tab.activeBorder": "#0078d4", + "terminalCursor.foreground": "#CCCCCC", "textBlockQuote.background": "#010409", "textBlockQuote.border": "#ffffff14", "textCodeBlock.background": "#6e768166", diff --git a/spin2/themes/isp-spin-dark-theme-old.json b/spin2/themes/isp-spin-dark-theme-old.json deleted file mode 100644 index e23935f..0000000 --- a/spin2/themes/isp-spin-dark-theme-old.json +++ /dev/null @@ -1,319 +0,0 @@ -{ - "$schema": "vscode://schemas/color-theme", - "name": "Spin2 Ironsheep Dark", - "semanticHighlighting": true, - "type": "dark", - "colors": { - "activityBar.background": "#444444", - "activityBar.border": "#2F8FBF", - "activityBar.foreground": "#888888", - "activityBarBadge.foreground": "#FFFFFF", - "activityBarBadge.background": "#2F8FBF", - "editor.background": "#222222", - "editor.foreground": "#aaaaaa", // #3981da - "editorError.border": "#BF2F2F", - "editorLineNumber.foreground": "#444444", - "panel.border": "#2F8FBF", - "panelTitle.activeBorder": "#2F8FBF", - "panelTitle.activeForeground": "#2F8FBF", - "panelTitle.inactiveForeground": "#444444", - "sideBar.background": "#222222", - "sideBar.border": "#888888", - "sideBar.foreground": "#AAAAAA", - "sideBarSectionHeader.background": "#444444", - "sideBarSectionHeader.foreground": "#000000", - "sideBarTitle.foreground": "#AAAAAA", - "terminal.ansiBlue": "#2F8FBF", - "terminal.ansiBrightBlue": "#007FBF", - "terminal.ansiCyan": "#2FBF8F", - "terminal.ansiBrightCyan": "#00BF7F", - "terminal.ansiGreen": "#8FBF2F", - "terminal.ansiBrightGreen": "#7FBF00", - "terminal.ansiMagenta": "#8F2FBF", - "terminal.ansiBrightMagenta": "#7F00BF", - "terminal.ansiRed": "#BF3060", - "terminal.ansiBrightRed": "#BF0040", - "terminal.ansiYellow": "#BF8F2F", - "terminal.ansiBrightYellow": "#BF7F00" - }, - "tokenColors": [ - { - "name": "Documentation Block", - "scope": ["comment.block.documentation"], - "settings": { - "foreground": "#5db55d" - } - }, - { - "name": "Documentation Line", - "scope": ["comment.line.documentation"], - "settings": { - "foreground": "#5db55d" - } - }, - { - "name": "Block", - "scope": ["comment.block"], - "settings": { - "foreground": "#538054", - "fontStyle": "italic" - } - }, - { - "name": "Comment", - "scope": ["comment.line"], - "settings": { - "foreground": "#538054", - "fontStyle": "italic" - } - }, - { - "name": "Immediate", - "scope": ["constant.character.escape"], - "settings": { - "foreground": "#ff4444" - } - }, - { - "name": "Constant", - "scope": ["constant.language"], - "settings": { - "foreground": "#8a358a" - } - }, - { - "name": "Variable", - "scope": ["variable.language"], - "settings": { - "foreground": "#8a358a" - } - }, - { - "name": "Numeric", - "scope": ["constant.numeric"], - "settings": { - "foreground": "#3e9096" - } - }, - { - "name": "Section", - "scope": ["keyword.block"], - "settings": { - "foreground": "#873d54", - "fontStyle": "bold" - } - }, - { - "name": "Invalid", - "scope": ["invalid"], - "settings": { - "foreground": "#ff0000", - "fontStyle": "bold" - } - }, - { - "name": "Control", - "scope": ["keyword.control"], - "settings": { - "foreground": "#b57bb0" // c586c0, cccc44 - } - }, - { - "name": "Control", - "scope": ["keyword.control.include"], - "settings": { - "foreground": "#c659bd" // c586c0, cccc44 - } - }, - { - "name": "Cog Register", - "scope": ["variable.language.cog.register"], - "settings": { - "foreground": "#9437FF" - } - }, - { - "name": "Operator", - "scope": ["keyword.operator"], - "settings": { - "foreground": "#b567ae" // aaaa66 - } - }, - { - "name": "Operator", - "scope": ["keyword.pasm.operators"], - "settings": { - "foreground": "#b567ae" // aaaa66 - } - }, - { - "name": "Other", - "scope": ["keyword.other"], - "settings": { - "foreground": "#2f8fbf" - } - }, - { - "name": "debug functions", - "scope": ["support.function.debug.methods"], - "settings": { - "foreground": "#b96c00" - } - }, - { - "name": "debug method", - "scope": ["support.function.debug"], - "settings": { - "foreground": "#ffd493" - } - }, - { - "name": "storage types", - "scope": ["storage.type"], - "settings": { - "foreground": "#3b7585" - } - }, - { - "name": "Object Variables", - "scope": ["entity.name.object"], - "settings": { - "foreground": "#7A81FF" - } - }, - { - "name": "Simple Variables", - "scope": ["variable.name.readwrite"], - "settings": { - "foreground": "#7A81FF" - } - }, - { - "name": "String", - "scope": ["string.quoted.double"], - "settings": { - "foreground": "#ba4343" - } - }, - { - "name": "Method Return Variable", - "scope": ["meta.return-type.spin"], - "settings": { - "foreground": "#3e8b95" - } - }, - { - "name": "Filename", - "scope": ["meta.object.filename"], - "settings": { - "foreground": "#eb6077" - } - }, - { - "name": "spin operators", - "scope": ["keyword.spin.operators"], - "settings": { - "foreground": "#831799" - } - }, - { - "name": "spin methods", - "scope": ["support.function"], - "settings": { - "foreground": "#c1c07d" // 6d8ad3, 5D83AC - } - }, - { - "name": "pasm storage modifiers", - "scope": ["storage.modifier"], - "settings": { - "foreground": "#7172ac" - } - }, - { - "name": "pasm control", - "scope": ["keyword.pasm.control"], - "settings": { - "foreground": "#9b3834" - } - }, - { - "name": "pasm instructions", - "scope": ["keyword.pasm.instruction"], - "settings": { - "foreground": "#9b3834" - } - } - ], - "semanticTokenColors": { - // method parts: name (parameters) : returnValues | localVariables - // #A7BAE7 #D0BBE6 #D0E5FA #FEF5FA/D3F1D2 - // colors - "string": "#ba4343", // debug() strings - "comment": "#538054", // single line non-doc comments - "label": "#9C775D", // pasm labels - "label.declaration": "#9C775D", // pasm labels - "label.static": "#99605C", // pasm local labels - "label.declaration.static": "#99605C", // pasm local labels - "label.static.illegalUse": "#ff0000", // pasm local labels - "label.declaration.static.illegalUse": "#ff0000", // pasm local labels - "variable": "#8bc4e3", // class global variable - "variable.modification": "#8bc4e3", // class global variable - "variable.instance": "#64bfb9", // instance global varable - "variable.modification.instance": "#64bfb9", // instance global varable - "variable.declaration.instance": "#64bfb9", // instance global varable - "enumMember": "#a051a0", // constants - "enumMember.declaration": "#a051a0", // constants - "variable.readonly": "#a051a0", // constants - "variable.declaration.readonly": "#a051a0", // constants - "variable.local": "#a0c1b8", // constants - "variable.modification.local": "#a0c1b8", // constants - "variable.declaration.local": "#a0c1b8", // constants - "returnValue.local": "#508b93", // constants - "returnValue.declaration.local": "#438e98", // constants - "method": "#7b9be4", // constants - "method.declaration": "#7b9be4", // constants - "method.static": "#9178da", // private methods - "method.declaration.static": "#9178da", // private method declarations - "parameter.readonly": "#b68ce3", // constants - "parameter.declaration.readonly": "#b68ce3", // constants - "namespace": "#6a66b3", // objects (old: 7A81FF) (new:5d60a0) - "namespace.declaration": "#6a66b3", // objects - "colorName": "#8a5ea3", // debug() display userName - "displayType": "#b37746", // debug() display type - "displayName": "#5d59a0", // debug() display userName - "displayName.declaration": "#5d59a0", // debug() display userName - "setupParameter": "#aaac61", // debug() setup parameter name - "feedParameter": "#b4a666", // debug() display type - // things from typescript - "parameter.declaration": "#b68ce3", // TypeScript: passed parameters .ts - "meta.type.annotation.ts": "#3b7585", // TypeScript: data types - // things from python - "string.quoted.single.python": "#ba4343", // Python: quoted strings - "support.function.builtin.python": "#c1c07d", // Python: built-in methods - // style overrides - "*.static": { "fontStyle": "italic" }, // all static names are italic - "*.declaration": { "fontStyle": "bold" }, // all declarations are bold - "*.declaration.static": { "fontStyle": "italic" }, // all declarations are bold - "*.modification.missingDeclaration": { - // missing assignment target - "fontStyle": "bold", - "foreground": "#d83333" - }, - "*.readonly.missingDeclaration": { - // missing constant - "fontStyle": "bold", - "foreground": "#d83333" - }, - "*.missingDeclaration": { - // missing variable - "fontStyle": "bold", - "foreground": "#d83333" - }, - "*.illegalUse": { - // keywords/variables in bad places - "foreground": "#ff0000", - "fontStyle": "bold" - } - } -} diff --git a/spin2/themes/isp-spin-dark-theme.json b/spin2/themes/isp-spin-dark-theme.json index 5112fa1..d1ecebe 100644 --- a/spin2/themes/isp-spin-dark-theme.json +++ b/spin2/themes/isp-spin-dark-theme.json @@ -29,6 +29,7 @@ "editor.background": "#1f1f1f", "editor.findMatchBackground": "#9e6a03", "editor.foreground": "#cccccc", + "editorCursor.foreground": "#AEB0AD", "editorGroup.border": "#ffffff17", "editorGroupHeader.tabsBackground": "#181818", "editorGroupHeader.tabsBorder": "#ffffff15", @@ -115,7 +116,8 @@ "tab.unfocusedHoverBackground": "#6e76811a", "terminal.foreground": "#cccccc", "terminal.tab.activeBorder": "#0078d4", - "textBlockQuote.background": "#010409", + "terminalCursor.foreground": "#CCCCCC", + "textBlockQuote.background": "#010409", "textBlockQuote.border": "#ffffff14", "textCodeBlock.background": "#6e768166", "textLink.activeForeground": "#40A6FF", @@ -130,8 +132,8 @@ "welcomePage.progress.foreground": "#0078d4", "widget.border": "#ffffff15", "editor.inactiveSelectionBackground": "#3A3D41", - "editorIndentGuide.background": "#404040", - "editorIndentGuide.activeBackground": "#707070", + "editorIndentGuide.background1": "#404040", + "editorIndentGuide.activeBackground1": "#707070", "editor.selectionHighlightBackground": "#ADD6FF26", "list.dropBackground": "#383B3D", "menu.foreground": "#CCCCCC", diff --git a/spin2/themes/isp-spin-light-bg-theme.json b/spin2/themes/isp-spin-light-bg-theme.json index 31c717c..d320084 100644 --- a/spin2/themes/isp-spin-light-bg-theme.json +++ b/spin2/themes/isp-spin-light-bg-theme.json @@ -13,6 +13,7 @@ "editor.inactiveSelectionBackground": "#666666e0", "editor.selectionBackground": "#222222e0", "editor.selectionHighlightBackground": "#d59880", + "editorCursor.foreground": "#000000", "editorIndentGuide.activeBackground1": "#939393", "editorIndentGuide.background1": "#D3D3D3", "editorSuggestWidget.background": "#F3F3F3", @@ -43,7 +44,8 @@ "tab.lastPinnedBorder": "#61616130", "terminal.foreground": "#cccccc", "terminal.inactiveSelectionBackground": "#E5EBF1", - "widget.border": "#d4d4d4" + "terminalCursor.foreground": "#333333", + "widget.border": "#d4d4d4" }, "tokenColors": [ { diff --git a/spin2/themes/isp-spin-light-theme-old.json b/spin2/themes/isp-spin-light-theme-old.json deleted file mode 100644 index 9b5ee03..0000000 --- a/spin2/themes/isp-spin-light-theme-old.json +++ /dev/null @@ -1,319 +0,0 @@ -{ - "$schema": "vscode://schemas/color-theme", - "name": "Spin2 Ironsheep Light", - "semanticHighlighting": true, - "type": "light", - "colors": { - "activityBar.background": "#444444", - "activityBar.border": "#2F8FBF", - "activityBar.foreground": "#888888", - "activityBarBadge.foreground": "#FFFFFF", - "activityBarBadge.background": "#2F8FBF", - "editor.background": "#222222", - "editor.foreground": "#aaaaaa", // #3981da - "editorError.border": "#BF2F2F", - "editorLineNumber.foreground": "#444444", - "panel.border": "#2F8FBF", - "panelTitle.activeBorder": "#2F8FBF", - "panelTitle.activeForeground": "#2F8FBF", - "panelTitle.inactiveForeground": "#444444", - "sideBar.background": "#222222", - "sideBar.border": "#888888", - "sideBar.foreground": "#AAAAAA", - "sideBarSectionHeader.background": "#444444", - "sideBarSectionHeader.foreground": "#000000", - "sideBarTitle.foreground": "#AAAAAA", - "terminal.ansiBlue": "#2F8FBF", - "terminal.ansiBrightBlue": "#007FBF", - "terminal.ansiCyan": "#2FBF8F", - "terminal.ansiBrightCyan": "#00BF7F", - "terminal.ansiGreen": "#8FBF2F", - "terminal.ansiBrightGreen": "#7FBF00", - "terminal.ansiMagenta": "#8F2FBF", - "terminal.ansiBrightMagenta": "#7F00BF", - "terminal.ansiRed": "#BF3060", - "terminal.ansiBrightRed": "#BF0040", - "terminal.ansiYellow": "#BF8F2F", - "terminal.ansiBrightYellow": "#BF7F00" - }, - "tokenColors": [ - { - "name": "Documentation Block", - "scope": ["comment.block.documentation"], - "settings": { - "foreground": "#5db55d" - } - }, - { - "name": "Documentation Line", - "scope": ["comment.line.documentation"], - "settings": { - "foreground": "#5db55d" - } - }, - { - "name": "Block", - "scope": ["comment.block"], - "settings": { - "foreground": "#538054", - "fontStyle": "italic" - } - }, - { - "name": "Comment", - "scope": ["comment.line"], - "settings": { - "foreground": "#538054", - "fontStyle": "italic" - } - }, - { - "name": "Immediate", - "scope": ["constant.character.escape"], - "settings": { - "foreground": "#ff4444" - } - }, - { - "name": "Constant", - "scope": ["constant.language"], - "settings": { - "foreground": "#8a358a" - } - }, - { - "name": "Variable", - "scope": ["variable.language"], - "settings": { - "foreground": "#8a358a" - } - }, - { - "name": "Numeric", - "scope": ["constant.numeric"], - "settings": { - "foreground": "#3e9096" - } - }, - { - "name": "Section", - "scope": ["keyword.block"], - "settings": { - "foreground": "#873d54", - "fontStyle": "bold" - } - }, - { - "name": "Invalid", - "scope": ["invalid"], - "settings": { - "foreground": "#ff0000", - "fontStyle": "bold" - } - }, - { - "name": "Control", - "scope": ["keyword.control"], - "settings": { - "foreground": "#b57bb0" // c586c0, cccc44 - } - }, - { - "name": "Control", - "scope": ["keyword.control.include"], - "settings": { - "foreground": "#c659bd" // c586c0, cccc44 - } - }, - { - "name": "Cog Register", - "scope": ["variable.language.cog.register"], - "settings": { - "foreground": "#9437FF" - } - }, - { - "name": "Operator", - "scope": ["keyword.operator"], - "settings": { - "foreground": "#b567ae" // aaaa66 - } - }, - { - "name": "Operator", - "scope": ["keyword.pasm.operators"], - "settings": { - "foreground": "#b567ae" // aaaa66 - } - }, - { - "name": "Other", - "scope": ["keyword.other"], - "settings": { - "foreground": "#2f8fbf" - } - }, - { - "name": "debug functions", - "scope": ["support.function.debug.methods"], - "settings": { - "foreground": "#b96c00" - } - }, - { - "name": "debug method", - "scope": ["support.function.debug"], - "settings": { - "foreground": "#ffd493" - } - }, - { - "name": "storage types", - "scope": ["storage.type"], - "settings": { - "foreground": "#3b7585" - } - }, - { - "name": "Object Variables", - "scope": ["entity.name.object"], - "settings": { - "foreground": "#7A81FF" - } - }, - { - "name": "Simple Variables", - "scope": ["variable.name.readwrite"], - "settings": { - "foreground": "#7A81FF" - } - }, - { - "name": "String", - "scope": ["string.quoted.double"], - "settings": { - "foreground": "#ba4343" - } - }, - { - "name": "Method Return Variable", - "scope": ["meta.return-type.spin"], - "settings": { - "foreground": "#3e8b95" - } - }, - { - "name": "Filename", - "scope": ["meta.object.filename"], - "settings": { - "foreground": "#eb6077" - } - }, - { - "name": "spin operators", - "scope": ["keyword.spin.operators"], - "settings": { - "foreground": "#831799" - } - }, - { - "name": "spin methods", - "scope": ["support.function"], - "settings": { - "foreground": "#c1c07d" // 6d8ad3, 5D83AC - } - }, - { - "name": "pasm storage modifiers", - "scope": ["storage.modifier"], - "settings": { - "foreground": "#7172ac" - } - }, - { - "name": "pasm control", - "scope": ["keyword.pasm.control"], - "settings": { - "foreground": "#9b3834" - } - }, - { - "name": "pasm instructions", - "scope": ["keyword.pasm.instruction"], - "settings": { - "foreground": "#9b3834" - } - } - ], - "semanticTokenColors": { - // method parts: name (parameters) : returnValues | localVariables - // #A7BAE7 #D0BBE6 #D0E5FA #FEF5FA/D3F1D2 - // colors - "string": "#ba4343", // debug() strings - "comment": "#538054", // single line non-doc comments - "label": "#9C775D", // pasm labels - "label.declaration": "#9C775D", // pasm labels - "label.static": "#99605C", // pasm local labels - "label.declaration.static": "#99605C", // pasm local labels - "label.static.illegalUse": "#ff0000", // pasm local labels - "label.declaration.static.illegalUse": "#ff0000", // pasm local labels - "variable": "#8bc4e3", // class global variable - "variable.modification": "#8bc4e3", // class global variable - "variable.instance": "#64bfb9", // instance global varable - "variable.modification.instance": "#64bfb9", // instance global varable - "variable.declaration.instance": "#64bfb9", // instance global varable - "enumMember": "#a051a0", // constants - "enumMember.declaration": "#a051a0", // constants - "variable.readonly": "#a051a0", // constants - "variable.declaration.readonly": "#a051a0", // constants - "variable.local": "#a0c1b8", // constants - "variable.modification.local": "#a0c1b8", // constants - "variable.declaration.local": "#a0c1b8", // constants - "returnValue.local": "#508b93", // constants - "returnValue.declaration.local": "#438e98", // constants - "method": "#7b9be4", // constants - "method.declaration": "#7b9be4", // constants - "method.static": "#9178da", // private methods - "method.declaration.static": "#9178da", // private method declarations - "parameter.readonly": "#b68ce3", // constants - "parameter.declaration.readonly": "#b68ce3", // constants - "namespace": "#6a66b3", // objects (old: 7A81FF) (new:5d60a0) - "namespace.declaration": "#6a66b3", // objects - "colorName": "#8a5ea3", // debug() display userName - "displayType": "#b37746", // debug() display type - "displayName": "#5d59a0", // debug() display userName - "displayName.declaration": "#5d59a0", // debug() display userName - "setupParameter": "#aaac61", // debug() setup parameter name - "feedParameter": "#b4a666", // debug() display type - // things from typescript - "parameter.declaration": "#b68ce3", // TypeScript: passed parameters .ts - "meta.type.annotation.ts": "#3b7585", // TypeScript: data types - // things from python - "string.quoted.single.python": "#ba4343", // Python: quoted strings - "support.function.builtin.python": "#c1c07d", // Python: built-in methods - // style overrides - "*.static": { "fontStyle": "italic" }, // all static names are italic - "*.declaration": { "fontStyle": "bold" }, // all declarations are bold - "*.declaration.static": { "fontStyle": "italic" }, // all declarations are bold - "*.modification.missingDeclaration": { - // missing assignment target - "fontStyle": "bold", - "foreground": "#d83333" - }, - "*.readonly.missingDeclaration": { - // missing constant - "fontStyle": "bold", - "foreground": "#d83333" - }, - "*.missingDeclaration": { - // missing variable - "fontStyle": "bold", - "foreground": "#d83333" - }, - "*.illegalUse": { - // keywords/variables in bad places - "foreground": "#ff0000", - "fontStyle": "bold" - } - } -} diff --git a/spin2/themes/isp-spin-light-theme.json b/spin2/themes/isp-spin-light-theme.json index 760d0a2..40215c0 100644 --- a/spin2/themes/isp-spin-light-theme.json +++ b/spin2/themes/isp-spin-light-theme.json @@ -9,6 +9,7 @@ "editorIndentGuide.background1": "#D3D3D3", "editorIndentGuide.activeBackground1": "#939393", "editor.selectionHighlightBackground": "#ADD6FF80", + "editorCursor.foreground": "#000000", "editorSuggestWidget.background": "#F3F3F3", "activityBarBadge.background": "#007ACC", "sideBarTitle.foreground": "#6F6F6F", @@ -30,6 +31,7 @@ "list.activeSelectionIconForeground": "#FFF", "list.focusAndSelectionOutline": "#90C2F9", "terminal.inactiveSelectionBackground": "#E5EBF1", + "terminalCursor.foreground": "#333333", "widget.border": "#d4d4d4" }, "tokenColors": [ diff --git a/spin2/themes/isp-spin-syntax-theme.json b/spin2/themes/isp-spin-syntax-theme.json index 4e3289a..f132ea1 100644 --- a/spin2/themes/isp-spin-syntax-theme.json +++ b/spin2/themes/isp-spin-syntax-theme.json @@ -10,7 +10,8 @@ "activityBarBadge.background": "#2F8FBF", "editor.background": "#222222", "editor.foreground": "#aaaaaa", // #3981da - "editorError.border": "#BF2F2F", + "editorCursor.foreground": "#AEB0AD", + "editorError.border": "#BF2F2F", "editorLineNumber.foreground": "#444444", "panel.border": "#2F8FBF", "panelTitle.activeBorder": "#2F8FBF", @@ -33,7 +34,8 @@ "terminal.ansiRed": "#BF3060", "terminal.ansiBrightRed": "#BF0040", "terminal.ansiYellow": "#BF8F2F", - "terminal.ansiBrightYellow": "#BF7F00" + "terminal.ansiBrightYellow": "#BF7F00", + "terminalCursor.foreground": "#CCCCCC", }, "tokenColors": [ {