This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"module": "commonjs",
|
||||
"target": "es2019",
|
||||
"lib": ["ES2019"],
|
||||
"outDir": "./out",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "src",
|
||||
"sourceMap": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user