From 1491aad2ea16b082c749f078294ab81082908aac Mon Sep 17 00:00:00 2001 From: christoph_xd Date: Sat, 25 Jan 2025 00:19:55 +0100 Subject: [PATCH] fix:First line can comment #5 --- .vscode/launch.json | 48 +-- client/src/common/handlers.ts | 20 +- client/tsconfig.json | 2 +- package.json | 8 +- syntaxes/tm.xml | 638 ---------------------------------- vite.config.js | 17 - 6 files changed, 43 insertions(+), 690 deletions(-) delete mode 100644 syntaxes/tm.xml delete mode 100644 vite.config.js diff --git a/.vscode/launch.json b/.vscode/launch.json index e0b27b7..8aeb409 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,28 +3,28 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 { - "version": "0.2.0", - "configurations": [ - { - "name": "Run Extension", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceFolder}"], - "outFiles": ["${workspaceFolder}/out/**/*.js"], - "preLaunchTask": "npm: watch" - }, - { - "name": "Extension Tests", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": [ - "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/out/test" - ], - "outFiles": ["${workspaceFolder}/out/test/**/*.js"], - "preLaunchTask": "npm: watch" - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": ["--extensionDevelopmentPath=${workspaceFolder}"], + "outFiles": ["${workspaceFolder}/client/out/**/*.js"], + "preLaunchTask": "npm: watch" + }, + { + "name": "Extension Tests", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}", + "--extensionTestsPath=${workspaceFolder}/out/test" + ], + "outFiles": ["${workspaceFolder}/out/test/**/*.js"], + "preLaunchTask": "npm: watch" + } + ] } diff --git a/client/src/common/handlers.ts b/client/src/common/handlers.ts index 9fa1db1..fa73667 100644 --- a/client/src/common/handlers.ts +++ b/client/src/common/handlers.ts @@ -37,14 +37,22 @@ export function formatDefFile(content: string): string { } export function isFirstLineMachine(content: string): boolean { - const firstLine = content.split("\n")[0].trim() - const machineRegex = /^MACHINE\s+\S+/ - return machineRegex.test(firstLine) + const lines = content.split("\n").map((line) => line.trim()) + for (const line of lines) { + console.log(line) + if (line === "" || line.startsWith("#")) { + console.log("skipping line") + continue + } + const machineRegex = /^MACHINE\s+\S+/ + return machineRegex.test(line) + } + return false } export function diagnosticHandler(document: vscode.TextDocument) { + const diagnostics: vscode.Diagnostic[] = [] if (document.languageId === "cdl" || document.languageId === "def") { - const diagnostics: vscode.Diagnostic[] = [] if (!isFirstLineMachine(document.getText())) { const range = new vscode.Range( document.positionAt(0), @@ -52,13 +60,13 @@ export function diagnosticHandler(document: vscode.TextDocument) { ) const diagnostic = new vscode.Diagnostic( range, - "The first line of the CDL file should contain 'MACHINE'.", + "The first line should contain 'MACHINE'.", vscode.DiagnosticSeverity.Error ) diagnostics.push(diagnostic) } - return diagnostics } + return diagnostics } export function completionHandlerCdl(document: vscode.TextDocument, position: vscode.Position) { diff --git a/client/tsconfig.json b/client/tsconfig.json index d7e4250..c4c78f2 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es2019", "lib": ["ES2019"], - "outDir": "./out", + "outDir": "./dist", "rootDir": "src", "sourceMap": true }, diff --git a/package.json b/package.json index f4a8418..f031b98 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "publisher": "Christoph", "repository": { "type": "git", - "url": "https://git.cbsk-tech.de/Christoph/vscode-cdl.git" + "url": "https://git.cbsk-tech.de/Christoph/nx_post_support.git" }, - "main": "./client/out/src/extension.js", + "main": "./client/dist/extension.js", "keywords": [ "cdl", "NX CDL", @@ -75,9 +75,9 @@ ] }, "scripts": { - "compile": "vite build", + "compile": "node esbuild.js --production", "watch": "node esbuild.js --watch", - "package": "vite build --mode production" + "package": "node esbuild.js --production" }, "devDependencies": { "@types/vscode": "^1.96.0", diff --git a/syntaxes/tm.xml b/syntaxes/tm.xml deleted file mode 100644 index e7d6e7b..0000000 --- a/syntaxes/tm.xml +++ /dev/null @@ -1,638 +0,0 @@ - - - - - fileTypes - - tcl - - name - tcl - patterns - - - include - #main - - - scopeName - source.tcl - uuid - c7017136-2ff2-48e9-bdb0-570cf238b4a2 - repository - - main - - patterns - - - include - #command - - - - args - - patterns - - - include - #quoted_args - - - include - #numeric - - - match - ((?<=;)\s*#.*$) - name - comment.tcl - comment - Inline comments. - - - - braced - - patterns - - - begin - ((?<!\\)\{) - beginCaptures - - 1 - - name - punctuation.tcl - - - patterns - - - include - #braced__1 - - - end - (\}([^\s\]]*)) - endCaptures - - 1 - - name - punctuation.tcl - - - - - - braced__1 - - patterns - - - match - (\\(?:\d{1,3}|x[a-fA-F0-9]{1,2}|u[a-fA-F0-9]{1,4}|U[a-fA-F0-9]{1,8}|.)) - name - constant.character.escape.tcl - - - include - #keywords - - - match - ((?<={)\s*(?:after|append|apply|array|auto_execok|auto_import|auto_load|auto_mkindex|auto_qualify|auto_reset|bgerror|binary|break|catch|cd|chan|clock|close|concat|continue|coroutine|dde|dict|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|fileevent|file|flush|foreach|for|format|gets|global|glob|history|http|if|incr|info|interp|join|lappend|lassign|lindex|linsert|list|llength|lmap|load|lrange|lrepeat|lreplace|lreverse|lsearch|lset|lsort|memory|my|namespace|nextto|next|oo::class|oo::copy|oo::define|oo::objdefine|oo::object|open|package|parray|pid|pkg::create|pkg_mkIndex|platform::shell|proc|puts|pwd|read|regexp|registry|regsub|rename|return|scan|seek|self|set|socket|source|split|string|subst|switch|tailcall|tcl::prefix|tcl_endOfWord|tcl_findLibrary|tcl_startOfNextWord|tcl_startOfPreviousWord|tcl_wordBreakAfter|tcl_wordBreakBefore|tell|throw|time|trace|try|unknown|unload|unset|update|uplevel|upvar|variable|vwait|while|yieldto|yield)\s+) - name - keyword.tcl - comment - Special handling for known commands. - - - include - #braced_inner - - - include - #args - - - - braced_inner - - patterns - - - begin - (\{) - beginCaptures - - 1 - - name - punctuation.tcl - - - patterns - - - include - #braced_inner__1 - - - end - (\}) - endCaptures - - 1 - - name - punctuation.tcl - - - - - - braced_inner__1 - - patterns - - - match - (\\[\x{007b}\x{007d}]) - name - constant.character.escape.tcl - - - include - #numeric - - - include - #braced_inner - - - include - #args - - - - braced_lit - - patterns - - - match - ((?:(?<!\\){)(?:[^\x{007b}\x{007d}\n]*(?:\g<1>(?:\\{|\\}|[^\x{007b}\x{007d}])*)*)}) - name - none.tcl - comment - Handle braced literal. - - - - braced_lit_re - - patterns - - - match - ((?:(?<!\\){)(?:[^\x{007b}\x{007d}\n]*(?:\g<1>(?:\\{|\\}|[^\x{007b}\x{007d}])*)*)}) - name - string.regexp.tcl - comment - Handle braced regex pattern. - - - - command - - patterns - - - begin - (\\\s*$) - beginCaptures - - 1 - - name - constant.character.escape.tcl - - - patterns - - - include - #command__1 - - - end - ((?<!\\\s)$) - endCaptures - - 1 - - name - none.tcl - - - - - match - (^\s*#.*) - name - comment.tcl - comment - Line comments. - - - match - (\{\s*$|^\s*\}) - name - punctuation.tcl - comment - Leading/trailing curly braces. - - - match - (?<=^|{)(\s*proc\s+)(\S+\s+)((?:(?<!\\){)(?:[^\x{007b}\x{007d}\n]*(?:\g<1>(?:\\{|\\}|[^\x{007b}\x{007d}])*)*)}) - captures - - 1 - - name - keyword.tcl - - 2 - - name - entity.name.function.tcl - - 3 - - name - none.tcl - - - comment - Proc command. - - - include - #regexp - - - include - #keywords - - - match - (^\s*\S+|(?:(?<=[^\x{005c}]\[)[^\s\]]++(?!\]))) - name - keyword.tcl - comment - All other commands. (NOTE: Iro doesn't support possessive quantifiers, but the grammar does; be sure to replace the second + with ++ after regenerating!) - - - include - #args - - - - command__1 - - patterns - - - include - #keywords - - - include - #args - - - - embedded - - patterns - - - begin - ((?<!\\)\[) - beginCaptures - - 1 - - name - punctuation.tcl - - - patterns - - - include - #embedded__1 - - - end - ((?<!\\)\]) - endCaptures - - 1 - - name - punctuation.tcl - - - - - - embedded__1 - - patterns - - - include - #command - - - - keywords - - patterns - - - match - ((?<=^|[\[\x{007b}\x{003b}])\s*(break|catch|continue|default|error|exit|foreach|for|if|return|switch|throw|try|while)\b) - name - keyword.control.tcl - comment - Keywords. - - - match - ((?<=^|})\s*(then|elseif|else)\b) - name - keyword.control.tcl - comment - Inline keywords. - - - - numeric - - patterns - - - match - ((?:\b|[\+\-\.])(?:0b[01]+|0o[0-7]+|0x[0-9a-fA-F]+|(?:\d*\.\d+(?:[Ee][-\x{002b}]?\d+)?)|(?:\d+\.?[Ee][-\x{002b}]?\d+)|\d+|[Ii][Nn][Ff]|[Nn][Aa][Nn])\b) - name - constant.numeric.tcl - - - - quoted - - patterns - - - begin - ((?<!\\)") - beginCaptures - - 1 - - name - string.tcl - - - patterns - - - include - #quoted__1 - - - end - (") - endCaptures - - 1 - - name - string.tcl - - - - - - quoted__1 - - patterns - - - include - #quoted_args - - - match - ([^\x{0024}\x{005b}\x{0022}\x{005c}]+) - name - string.tcl - - - - quoted_args - - patterns - - - include - #braced - - - include - #quoted - - - include - #embedded - - - match - (\\(?:\d{1,3}|x[a-fA-F0-9]{1,2}|u[a-fA-F0-9]{1,4}|U[a-fA-F0-9]{1,8}|.)) - name - constant.character.escape.tcl - - - include - #variable - - - - regexp - - patterns - - - begin - ((?<=^|[\[\x{007b}\x{003b}])\s*(?:regexp|regsub)\s+)((?:(?:(?:-about|-all|-expanded|-indices|-inline|-lineanchor|-linestop|-line|-nocase|(?:-index\s+(?:end|\d+)(?:[\+\-]-?\d+)?))\s+)*(?:--\s+)?)?) - beginCaptures - - 1 - - name - keyword.tcl - - 2 - - name - none.tcl - - - patterns - - - include - #regexp__1 - - - end - (\s+) - endCaptures - - 1 - - name - none.tcl - - - - - include - #args - - - - regexp__1 - - patterns - - - include - #braced_lit_re - - - begin - ((?:(?<!\\)")) - beginCaptures - - 1 - - name - string.regexp.tcl - - - patterns - - - include - #regexp__2 - - - end - ((?:(?<!\\)")) - endCaptures - - 1 - - name - string.regexp.tcl - - - - - include - #variable - - - match - (\S+) - name - string.regexp.tcl - comment - Handle bare regex pattern. - - - - regexp__2 - - patterns - - - include - #braced_lit_re - - - include - #embedded - - - include - #variable - - - match - (\\"|[^\x{0022}]) - name - string.regexp.tcl - comment - All other quoted text. - - - - variable - - patterns - - - match - (\$(?:(?:[a-zA-Z0-9_]|::)+(?:\([^\)]+\))?|\{(?:[^\}]*|[^\}\x{0028}]+\([^\}\x{0029}]+\))\})) - name - variable.tcl - - - - word_lit__1 - - patterns - - - include - #braced_lit - - - include - #embedded - - - include - #variable - - - match - (\\"|[^\x{0022}]) - name - string.tcl - comment - All other quoted text. - - - - - - \ No newline at end of file diff --git a/vite.config.js b/vite.config.js deleted file mode 100644 index cbafb57..0000000 --- a/vite.config.js +++ /dev/null @@ -1,17 +0,0 @@ -import { defineConfig } from "vite" - -export default defineConfig({ - build: { - lib: { - entry: "./client/src/extension.ts", - formats: ["cjs", "es"], - fileName: "extension" - }, - rollupOptions: { - external: ["vscode"] - }, - sourcemap: true, - outDir: "client/out/src" - }, - plugins: [] -})