Now that ASTGen should be able to generate most Swift code. Let's
remove "legacy parser" call-in, and remove the unhealthy cyclic
dependency between lib/Parse and ASTGen.
Previously, they were being parsed as top-level code, which would cause
errors because there are no definitions. Introduce a new
GeneratedSourceInfo kind to mark the purpose of these buffers so the
parser can handle them appropriately.
This simplifies both the diagnostic declarations and usages.
To create a new diangnostic message, create a static method:
extension ASTGenDiagnostic {
static func invalidToken(_ token: TokenSyntax) -> Self {
return Self(
node: token,
message: "invalid token: '\(token.trimmed)'"
)
}
}
To use it In ASTGenVisitor:
self.diagnose(.invalidToken(token))
* Make ExportedSourceFile hold any Syntax as the root node
* Move `ExportedSourceFileRequest::evaluate()` to `ParseRequests.cpp`
* Pass the decl context and `GeneatedSourceFileInfo::Kind` to
`swift_ASTGen_parseSourceFile()` to customize the parsing
* Make `ExportedSourceFile` to hold an arbitrary Syntax node
* Move round-trip checking into `ExportedSourceFileRequest::evaluate()`
* Split `parseSourceFileViaASTGen` completely from C++ parsing logic
(in `ParseSourceFileRequest::evaluate()`)
* Remove 'ParserDiagnostics' experimental feature: Now that we have
ParserASTGen mode which includes the swift-syntax parser diagnostics.
Add the necessary compiler-side logic to allow
the regex parsing library to hand back a set of
features for a regex literal, which can then be
diagnosed by ExprAvailabilityWalker if the
availability context isn't sufficient. No tests
as this only adds the necessary infrastructure,
we don't yet hand back the features from the regex
parsing library.
Instead of doing the pattern parsing in both the
C++ parser and ASTGen, factor out the parsing into
a request that returns the pattern to emit, regex
type, and version. This can then be lazily run
during type-checking.
Fixes
```
.../swift/lib/ASTGen/Sources/ASTGen/Types.swift:359:29: warning: 'specifier' is deprecated: Access the specifiers list instead
if let specifier = node.specifier {
^
```
TopLevelCodeDecl::getEndLoc() should return the token location of the
last token. If the last token is a string literal or a regex literal,
it should be the location of the literal token.