@@ -1989,10 +1989,18 @@ void SwiftEditorDocument::parse(ImmutableTextSnapshotRef Snapshot,
1989
1989
Impl.SyntaxInfo ->parse ();
1990
1990
}
1991
1991
1992
- void SwiftEditorDocument::readSyntaxInfo (EditorConsumer &Consumer) {
1992
+ static UIdent SemaDiagStage (" source.diagnostic.stage.swift.sema" );
1993
+ static UIdent ParseDiagStage (" source.diagnostic.stage.swift.parse" );
1994
+
1995
+ void SwiftEditorDocument::readSyntaxInfo (EditorConsumer &Consumer, bool ReportDiags) {
1993
1996
llvm::sys::ScopedLock L (Impl.AccessMtx );
1994
1997
1995
1998
Impl.ParserDiagnostics = Impl.SyntaxInfo ->getDiagnostics ();
1999
+ if (ReportDiags) {
2000
+ Consumer.setDiagnosticStage (ParseDiagStage);
2001
+ for (auto &Diag : Impl.ParserDiagnostics )
2002
+ Consumer.handleDiagnostic (Diag, ParseDiagStage);
2003
+ }
1996
2004
1997
2005
SwiftSyntaxMap NewMap = SwiftSyntaxMap (Impl.SyntaxMap .Tokens .size () + 16 );
1998
2006
@@ -2059,9 +2067,6 @@ void SwiftEditorDocument::readSemanticInfo(ImmutableTextSnapshotRef Snapshot,
2059
2067
Consumer.handleSemanticAnnotation (Offset, Length, Kind, IsSystem);
2060
2068
}
2061
2069
2062
- static UIdent SemaDiagStage (" source.diagnostic.stage.swift.sema" );
2063
- static UIdent ParseDiagStage (" source.diagnostic.stage.swift.parse" );
2064
-
2065
2070
// If there's no value returned for diagnostics it means they are out-of-date
2066
2071
// (based on a different snapshot).
2067
2072
if (SemaDiags.hasValue ()) {
@@ -2304,7 +2309,6 @@ void SwiftEditorDocument::reportDocumentStructure(SourceFile &SrcFile,
2304
2309
// ===----------------------------------------------------------------------===//
2305
2310
// EditorOpen
2306
2311
// ===----------------------------------------------------------------------===//
2307
-
2308
2312
void SwiftLangSupport::editorOpen (
2309
2313
StringRef Name, llvm::MemoryBuffer *Buf, EditorConsumer &Consumer,
2310
2314
ArrayRef<const char *> Args, Optional<VFSOptions> vfsOptions) {
@@ -2343,8 +2347,7 @@ void SwiftLangSupport::editorOpen(
2343
2347
EditorDoc->updateSemaInfo ();
2344
2348
}
2345
2349
2346
- EditorDoc->readSyntaxInfo (Consumer);
2347
- EditorDoc->readSemanticInfo (Snapshot, Consumer);
2350
+ EditorDoc->readSyntaxInfo (Consumer, /* ReportDiags=*/ true );
2348
2351
2349
2352
if (Consumer.syntaxTreeEnabled ()) {
2350
2353
assert (EditorDoc->getSyntaxTree ().hasValue ());
@@ -2506,7 +2509,8 @@ void SwiftLangSupport::editorReplaceText(StringRef Name,
2506
2509
}
2507
2510
EditorDoc->parse (Snapshot, *this , Consumer.syntaxTreeEnabled (),
2508
2511
SyntaxCachePtr);
2509
- EditorDoc->readSyntaxInfo (Consumer);
2512
+ // Do not report syntactic diagnostics; will be handled in readSemanticInfo.
2513
+ EditorDoc->readSyntaxInfo (Consumer, /* ReportDiags=*/ false );
2510
2514
2511
2515
// Log reuse information
2512
2516
if (SyntaxCache.hasValue () && LogReuseRegions) {
0 commit comments