Skip to content

Commit 27cb118

Browse files
committed
transfer into a function
1 parent 99cb66a commit 27cb118

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

src/diagnostic.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,30 @@ import { CompilerError } from './types.js';
55
import { readFileSync } from 'fs';
66

77

8-
export namespace diagnostic {
9-
10-
/**
11-
* Creates a diagnostic report from the file path given.
12-
* @param {string} filePath Path of the file to create a report.
13-
* @returns A diagnostic report language servers can use.
14-
*/
15-
export function createReport(filePath: string): FullDocumentDiagnosticReport {
16-
const isSyx: boolean = filePath.endsWith('.syx');
17-
18-
try {
19-
20-
const content = readFileSync(filePath).toString();
21-
const tokens = (isSyx ? tokenizeSyx : tokenizeSys)(content);
22-
(isSyx ? syxparser : sysparser).parseTokens(tokens);
23-
24-
return { kind: DocumentDiagnosticReportKind.Full, items: [] };
25-
} catch (error) {
26-
if (error instanceof CompilerError) {
27-
const compilerError = error as CompilerError;
28-
return {
29-
kind: DocumentDiagnosticReportKind.Full, items: [
30-
{ message: compilerError.message, range: compilerError.range, severity: DiagnosticSeverity.Error, source: 'syntax-script' }
31-
]
32-
};
33-
}
8+
/**
9+
* Creates a diagnostic report from the file path given.
10+
* @param {string} filePath Path of the file to create a report.
11+
* @returns A diagnostic report language servers can use.
12+
*/
13+
export function createSyntaxScriptDiagnosticReport(filePath: string): FullDocumentDiagnosticReport {
14+
const isSyx: boolean = filePath.endsWith('.syx');
15+
16+
try {
17+
18+
const content = readFileSync(filePath).toString();
19+
const tokens = (isSyx ? tokenizeSyx : tokenizeSys)(content);
20+
(isSyx ? syxparser : sysparser).parseTokens(tokens);
21+
22+
return { kind: DocumentDiagnosticReportKind.Full, items: [] };
23+
} catch (error) {
24+
if (error instanceof CompilerError) {
25+
const compilerError = error as CompilerError;
26+
return {
27+
kind: DocumentDiagnosticReportKind.Full, items: [
28+
{ message: compilerError.message, range: compilerError.range, severity: DiagnosticSeverity.Error, source: 'syntax-script' }
29+
]
30+
};
3431
}
35-
3632
}
3733

38-
}
34+
}

0 commit comments

Comments
 (0)