@@ -36,8 +36,8 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
3636 items . push ( ...ruleConflictCheck ( ast , filePath ) ) ;
3737 items . push ( ...sameRuleCheck ( ast , filePath ) ) ;
3838 items . push ( ...importedExistentCheck ( ast , filePath ) ) ;
39- items . push ( ...sameRegexCheck ( ast , filePath ) ) ;
40- items . push ( ...sameNameCheck ( ast . body , filePath ) ) ;
39+ items . push ( ...sameRegexCheck ( ast , filePath ) ) ;
40+ items . push ( ...sameNameCheck ( ast . body , filePath ) ) ;
4141 } catch ( error ) {
4242 if ( isCompilerError ( error ) ) {
4343 items . push ( {
@@ -50,7 +50,7 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
5050 items . push ( { message : `Parser Error: ${ error . message } ` , range : { end : { line : 0 , character : 1 } , start : { line : 0 , character : 0 } } , severity : DiagnosticSeverity . Warning } ) ;
5151 }
5252 } finally {
53- return { items :items . map ( r => { return { ...r , source :'syntax-script' } ; } ) , kind : DocumentDiagnosticReportKind . Full } ;
53+ return { items : items . map ( r => { return { ...r , source : 'syntax-script' } ; } ) , kind : DocumentDiagnosticReportKind . Full } ;
5454 }
5555
5656}
@@ -216,29 +216,29 @@ function importedExistentCheck(ast: ProgramStatement, filePath: string): Diagnos
216216}
217217
218218// Checks if there are multiple operators with the same regex
219- function sameRegexCheck ( ast :ProgramStatement , filePath :string ) : Diagnostic [ ] {
220- const items :Diagnostic [ ] = [ ] ;
219+ function sameRegexCheck ( ast : ProgramStatement , filePath : string ) : Diagnostic [ ] {
220+ const items : Diagnostic [ ] = [ ] ;
221221
222- const encounteredRegexes :RegExp [ ] = [ ] ;
222+ const encounteredRegexes : RegExp [ ] = [ ] ;
223223
224- ast . body . filter ( r => statementIsA ( r , NodeType . Operator ) ) . map ( r => r as OperatorStatement ) . forEach ( stmt => {
224+ ast . body . filter ( r => statementIsA ( r , NodeType . Operator ) ) . map ( r => r as OperatorStatement ) . forEach ( stmt => {
225225
226226 const regex = new RegExp ( CompilerFunctions . generateRegexMatcher ( stmt ) ) ;
227227
228- if ( encounteredRegexes . some ( r => r . source === regex . source ) ) items . push ( {
229- message :'Regex of this operator is same with another operator.' ,
230- range :subRange ( syxparser . combineTwo ( stmt . regex [ 0 ] . range , stmt . regex [ stmt . regex . length - 1 ] . range ) ) ,
231- severity :DiagnosticSeverity . Error ,
232- data :[
228+ if ( encounteredRegexes . some ( r => r . source === regex . source ) ) items . push ( {
229+ message : 'Regex of this operator is same with another operator.' ,
230+ range : subRange ( syxparser . combineTwo ( stmt . regex [ 0 ] . range , stmt . regex [ stmt . regex . length - 1 ] . range ) ) ,
231+ severity : DiagnosticSeverity . Error ,
232+ data : [
233233 {
234- title :'Remove this operator' ,
235- kind :CodeActionKind . QuickFix ,
236- edit :{
237- changes :{
238- [ filePath ] :[
234+ title : 'Remove this operator' ,
235+ kind : CodeActionKind . QuickFix ,
236+ edit : {
237+ changes : {
238+ [ filePath ] : [
239239 {
240- newText :'' ,
241- range :subRange ( stmt . range )
240+ newText : '' ,
241+ range : subRange ( stmt . range )
242242 }
243243 ]
244244 }
@@ -289,30 +289,30 @@ function exportableCheck(statements: Statement[], filePath: string): Diagnostic[
289289
290290// Check if everything has a unique name
291291function sameNameCheck ( statements : Statement [ ] , filePath : string ) : Diagnostic [ ] {
292- const items :Diagnostic [ ] = [ ] ;
293-
294- function c ( s :Statement [ ] ) {
292+ const items : Diagnostic [ ] = [ ] ;
293+
294+ function c ( s : Statement [ ] ) {
295295 const encounteredNames = [ ] ;
296296
297297 s
298- . filter ( r => statementIsA ( r , NodeType . Function ) || statementIsA ( r , NodeType . Global ) || statementIsA ( r , NodeType . Keyword ) )
299- . map ( r => {
300- if ( statementIsA ( r , NodeType . Function ) ) return r as FunctionStatement ;
301- if ( statementIsA ( r , NodeType . Global ) ) return r as GlobalStatement ;
302- if ( statementIsA ( r , NodeType . Keyword ) ) return r as KeywordStatement ;
303- } ) . forEach ( stmt => {
304-
305- const n = stmt [ statementIsA ( stmt , NodeType . Keyword ) ?'word' :'name' ] ;
306-
307- if ( encounteredNames . includes ( n ) ) items . push ( {
308- message :`Name '${ n } ' is already seen before.` ,
309- range :subRange ( stmt . range ) ,
310- severity :DiagnosticSeverity . Error
311- } ) ;
312- else encounteredNames . push ( n ) ;
298+ . filter ( r => statementIsA ( r , NodeType . Function ) || statementIsA ( r , NodeType . Global ) || statementIsA ( r , NodeType . Keyword ) )
299+ . map ( r => {
300+ if ( statementIsA ( r , NodeType . Function ) ) return r as FunctionStatement ;
301+ if ( statementIsA ( r , NodeType . Global ) ) return r as GlobalStatement ;
302+ if ( statementIsA ( r , NodeType . Keyword ) ) return r as KeywordStatement ;
303+ } ) . forEach ( stmt => {
313304
314- if ( statementIsA ( stmt , NodeType . Global ) ) c ( stmt . body ) ;
315- } ) ;
305+ const n = stmt [ statementIsA ( stmt , NodeType . Keyword ) ? 'word' : 'name' ] ;
306+
307+ if ( encounteredNames . includes ( n ) ) items . push ( {
308+ message : `Name '${ n } ' is already seen before.` ,
309+ range : subRange ( stmt . range ) ,
310+ severity : DiagnosticSeverity . Error
311+ } ) ;
312+ else encounteredNames . push ( n ) ;
313+
314+ if ( statementIsA ( stmt , NodeType . Global ) ) c ( stmt . body ) ;
315+ } ) ;
316316
317317 }
318318
0 commit comments