Skip to content

Commit 8eebda8

Browse files
committed
map items with souce instead of defining it every time
1 parent c36cce5 commit 8eebda8

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/diagnostic.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
4444
message: error.message,
4545
range: subRange(error.range),
4646
severity: DiagnosticSeverity.Error,
47-
source: 'syntax-script',
4847
data: error.actions
4948
});
5049
} else {
5150
items.push({ message: `Parser Error: ${error.message}`, range: { end: { line: 0, character: 1 }, start: { line: 0, character: 0 } }, severity: DiagnosticSeverity.Warning });
5251
}
5352
} finally {
54-
return { items, kind: DocumentDiagnosticReportKind.Full };
53+
return { items:items.map(r=>{return {...r,source:'syntax-script'};}), kind: DocumentDiagnosticReportKind.Full };
5554
}
5655

5756
}
@@ -68,7 +67,6 @@ function ruleConflictCheck(ast: ProgramStatement, filePath: string): Diagnostic[
6867
if (dictRule.conflicts.includes(otherRules.rule)) items.push({
6968
message: `Rule '${otherRules.rule}' conflicts with '${stmt.rule}', Both of them should not be defined.`,
7069
range: subRange(otherRules.range),
71-
source: 'syntax-script',
7270
severity: DiagnosticSeverity.Warning,
7371
data: [
7472
{
@@ -118,7 +116,6 @@ function sameRuleCheck(ast: ProgramStatement, filePath: string): Diagnostic[] {
118116
if (otherRules.rule === stmt.rule) items.push({
119117
message: `Rule '${stmt.rule}' is already defined.`,
120118
range: subRange(stmt.range),
121-
source: 'syntax-script',
122119
severity: DiagnosticSeverity.Error,
123120
data: [
124121
{
@@ -156,7 +153,6 @@ function importedExistentCheck(ast: ProgramStatement, filePath: string): Diagnos
156153
message: `Can't find file '${fullPath}' imported from '${filePathButPath}'`,
157154
severity: DiagnosticSeverity.Error,
158155
range: subRange(stmt.range),
159-
source: 'syntax-script',
160156
data: [
161157
{
162158
title: 'Remove this import statement',
@@ -179,7 +175,6 @@ function importedExistentCheck(ast: ProgramStatement, filePath: string): Diagnos
179175
message: `'${fullPath}' imported from '${filePathButPath}' doesn't seem to be a file.`,
180176
severity: DiagnosticSeverity.Error,
181177
range: subRange(stmt.range),
182-
source: 'syntax-script',
183178
data: [
184179
{
185180
title: 'Remove this import statement',
@@ -199,7 +194,6 @@ function importedExistentCheck(ast: ProgramStatement, filePath: string): Diagnos
199194
message: `'${fullPath}' imported from '${filePathButPath}' cannot be imported.`,
200195
severity: DiagnosticSeverity.Error,
201196
range: subRange(stmt.range),
202-
source: 'syntax-script',
203197
data: [
204198
{
205199
title: 'Remove this import statement',
@@ -235,7 +229,6 @@ function sameRegexCheck(ast:ProgramStatement, filePath:string): Diagnostic[] {
235229
message:'Regex of this operator is same with another operator.',
236230
range:subRange(syxparser.combineTwo(stmt.regex[0].range,stmt.regex[stmt.regex.length-1].range)),
237231
severity:DiagnosticSeverity.Error,
238-
source:'syntax-script',
239232
data:[
240233
{
241234
title:'Remove this operator',
@@ -271,7 +264,6 @@ function exportableCheck(statements: Statement[], filePath: string): Diagnostic[
271264
message: 'This statement cannot be exported.',
272265
range: subRange(stmt.range),
273266
severity: DiagnosticSeverity.Error,
274-
source: 'syntax-script',
275267
data: [
276268
{
277269
title: 'Remove export keyword',
@@ -315,7 +307,6 @@ function sameNameCheck(statements: Statement[], filePath: string): Diagnostic[]
315307
if(encounteredNames.includes(n)) items.push({
316308
message:`Name '${n}' is already seen before.`,
317309
range:subRange(stmt.range),
318-
source:'syntax-script',
319310
severity:DiagnosticSeverity.Error
320311
});
321312
else encounteredNames.push(n);

0 commit comments

Comments
 (0)