mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
sourcekitd: build Swift syntax tree more lazily than collecting parsed tokens. (#14578)
Before this patch, we have one flag (KeepSyntaxInfo) to turn on two syntax functionalities of parser: (1) collecting parsed tokens for coloring and (2) building syntax trees. Since sourcekitd is the only consumer of either of these functionalities, sourcekitd by default always enables such flag. However, empirical results show (2) is both heavier and less-frequently needed than (1). Therefore, separating the flag to two flags makes more sense, where CollectParsedToken controls (1) and BuildSyntaxTree controls (2). CollectingParsedToken is always enabled by sourcekitd because formatting and syntax-coloring need it; however BuildSyntaxTree should be explicitly switched on by sourcekitd clients. resolves: rdar://problem/37483076
This commit is contained in:
@@ -442,7 +442,7 @@ bool SwiftASTManager::initCompilerInvocation(CompilerInvocation &Invocation,
|
||||
Invocation.setSerializedDiagnosticsPath(StringRef());
|
||||
Invocation.getLangOptions().AttachCommentsToDecls = true;
|
||||
Invocation.getLangOptions().DiagnosticsEditorMode = true;
|
||||
Invocation.getLangOptions().KeepSyntaxInfoInSourceFile = true;
|
||||
Invocation.getLangOptions().CollectParsedToken = true;
|
||||
auto &FrontendOpts = Invocation.getFrontendOptions();
|
||||
if (FrontendOpts.PlaygroundTransform) {
|
||||
// The playground instrumenter changes the AST in ways that disrupt the
|
||||
@@ -817,7 +817,7 @@ ASTUnitRef ASTProducer::createASTUnit(SwiftASTManager::Implementation &MgrImpl,
|
||||
InvokRef->Impl.Opts.applyToSubstitutingInputs(
|
||||
Invocation, convertFileContentsToInputs(Contents));
|
||||
|
||||
Invocation.getLangOptions().KeepSyntaxInfoInSourceFile = true;
|
||||
Invocation.getLangOptions().CollectParsedToken = true;
|
||||
|
||||
if (CompIns.setup(Invocation)) {
|
||||
// FIXME: Report the diagnostic.
|
||||
|
||||
Reference in New Issue
Block a user