@@ -19,7 +19,7 @@ func (c *Checker) grammarErrorOnFirstToken(node *ast.Node, message *diagnostics.
1919 sourceFile := ast .GetSourceFileOfNode (node )
2020 if ! c .hasParseDiagnostics (sourceFile ) {
2121 span := scanner .GetRangeOfTokenAtPosition (sourceFile , node .Pos ())
22- c .diagnostics . Add (ast .NewDiagnostic (sourceFile , span , message , args ... ))
22+ c .addDiagnostic (ast .NewDiagnostic (sourceFile , span , message , args ... ))
2323 return true
2424 }
2525 return false
@@ -28,7 +28,7 @@ func (c *Checker) grammarErrorOnFirstToken(node *ast.Node, message *diagnostics.
2828func (c * Checker ) grammarErrorAtPos (nodeForSourceFile * ast.Node , start int , length int , message * diagnostics.Message , args ... any ) bool {
2929 sourceFile := ast .GetSourceFileOfNode (nodeForSourceFile )
3030 if ! c .hasParseDiagnostics (sourceFile ) {
31- c .diagnostics . Add (ast .NewDiagnostic (sourceFile , core .NewTextRange (start , start + length ), message , args ... ))
31+ c .addDiagnostic (ast .NewDiagnostic (sourceFile , core .NewTextRange (start , start + length ), message , args ... ))
3232 return true
3333 }
3434 return false
@@ -48,7 +48,7 @@ func (c *Checker) grammarErrorOnNodeSkippedOnNoEmit(node *ast.Node, message *dia
4848 if ! c .hasParseDiagnostics (sourceFile ) {
4949 d := NewDiagnosticForNode (node , message , args ... )
5050 d .SetSkippedOnNoEmit ()
51- c .diagnostics . Add (d )
51+ c .addDiagnostic (d )
5252 return true
5353 }
5454 return false
@@ -81,7 +81,7 @@ func (c *Checker) checkGrammarRegularExpressionLiteral(node *ast.RegularExpressi
8181 lastError .AddRelatedInfo (err )
8282 } else if lastError == nil || start != lastError .Pos () {
8383 lastError = ast .NewDiagnostic (sourceFile , core .NewTextRange (start , start + length ), message , args ... )
84- c .diagnostics . Add (lastError )
84+ c .addDiagnostic (lastError )
8585 }
8686 })
8787 c .regExpScanner .SetText (sourceFile .Text ())
@@ -1208,13 +1208,13 @@ func (c *Checker) checkGrammarForInOrForOfStatement(forInOrOfStatement *ast.ForI
12081208 if ast .IsInTopLevelContext (asNode ) {
12091209 if ! c .hasParseDiagnostics (sourceFile ) {
12101210 if ! ast .IsEffectiveExternalModule (sourceFile , c .compilerOptions ) {
1211- c .diagnostics . Add (createDiagnosticForNode (forInOrOfStatement .AwaitModifier , diagnostics .X_for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module ))
1211+ c .addDiagnostic (createDiagnosticForNode (forInOrOfStatement .AwaitModifier , diagnostics .X_for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module ))
12121212 }
12131213 switch c .moduleKind {
12141214 case core .ModuleKindNode16 , core .ModuleKindNode18 , core .ModuleKindNode20 , core .ModuleKindNodeNext :
12151215 sourceFileMetaData := c .program .GetSourceFileMetaData (sourceFile .Path ())
12161216 if sourceFileMetaData .ImpliedNodeFormat == core .ModuleKindCommonJS {
1217- c .diagnostics . Add (createDiagnosticForNode (forInOrOfStatement .AwaitModifier , diagnostics .The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level ))
1217+ c .addDiagnostic (createDiagnosticForNode (forInOrOfStatement .AwaitModifier , diagnostics .The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level ))
12181218 break
12191219 }
12201220 fallthrough
@@ -1227,7 +1227,7 @@ func (c *Checker) checkGrammarForInOrForOfStatement(forInOrOfStatement *ast.ForI
12271227 }
12281228 fallthrough
12291229 default :
1230- c .diagnostics . Add (createDiagnosticForNode (forInOrOfStatement .AwaitModifier , diagnostics .Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_node20_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher ))
1230+ c .addDiagnostic (createDiagnosticForNode (forInOrOfStatement .AwaitModifier , diagnostics .Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_node20_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher ))
12311231 }
12321232 }
12331233 } else {
@@ -1240,7 +1240,7 @@ func (c *Checker) checkGrammarForInOrForOfStatement(forInOrOfStatement *ast.ForI
12401240 relatedInfo := createDiagnosticForNode (containingFunc , diagnostics .Did_you_mean_to_mark_this_function_as_async )
12411241 diagnostic .AddRelatedInfo (relatedInfo )
12421242 }
1243- c .diagnostics . Add (diagnostic )
1243+ c .addDiagnostic (diagnostic )
12441244 return true
12451245 }
12461246 }
@@ -1702,7 +1702,7 @@ func (c *Checker) checkGrammarAwaitOrAwaitUsing(node *ast.Node) bool {
17021702 message = diagnostics .X_await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module
17031703 }
17041704 diagnostic := ast .NewDiagnostic (sourceFile , span , message )
1705- c .diagnostics . Add (diagnostic )
1705+ c .addDiagnostic (diagnostic )
17061706 hasError = true
17071707 }
17081708 switch c .moduleKind {
@@ -1715,7 +1715,7 @@ func (c *Checker) checkGrammarAwaitOrAwaitUsing(node *ast.Node) bool {
17151715 if ! spanCalculated {
17161716 span = scanner .GetRangeOfTokenAtPosition (sourceFile , node .Pos ())
17171717 }
1718- c .diagnostics . Add (ast .NewDiagnostic (sourceFile , span , diagnostics .The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level ))
1718+ c .addDiagnostic (ast .NewDiagnostic (sourceFile , span , diagnostics .The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level ))
17191719 hasError = true
17201720 break
17211721 }
@@ -1738,7 +1738,7 @@ func (c *Checker) checkGrammarAwaitOrAwaitUsing(node *ast.Node) bool {
17381738 } else {
17391739 message = diagnostics .Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_node20_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher
17401740 }
1741- c .diagnostics . Add (ast .NewDiagnostic (sourceFile , span , message ))
1741+ c .addDiagnostic (ast .NewDiagnostic (sourceFile , span , message ))
17421742 hasError = true
17431743 }
17441744 }
@@ -1758,7 +1758,7 @@ func (c *Checker) checkGrammarAwaitOrAwaitUsing(node *ast.Node) bool {
17581758 relatedInfo := NewDiagnosticForNode (container , diagnostics .Did_you_mean_to_mark_this_function_as_async )
17591759 diagnostic .AddRelatedInfo (relatedInfo )
17601760 }
1761- c .diagnostics . Add (diagnostic )
1761+ c .addDiagnostic (diagnostic )
17621762 hasError = true
17631763 }
17641764 }
0 commit comments