File tree Expand file tree Collapse file tree 5 files changed +18
-1
lines changed Expand file tree Collapse file tree 5 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -296,6 +296,11 @@ namespace swift {
296
296
// / incrementals parsing.
297
297
bool BuildSyntaxTree = false ;
298
298
299
+ // / Whether parsing is occurring for creation of syntax tree only, and no typechecking will occur after
300
+ // / parsing e.g. when parsing for SwiftSyntax. This is intended to affect parsing, e.g. disable
301
+ // / unnecessary name lookups that are not useful for pure syntactic parsing.
302
+ bool ParseForSyntaxTreeOnly = false ;
303
+
299
304
// / Whether to verify the parsed syntax tree and emit related diagnostics.
300
305
bool VerifySyntaxTree = false ;
301
306
Original file line number Diff line number Diff line change @@ -2264,7 +2264,10 @@ Expr *Parser::parseExprIdentifier() {
2264
2264
}
2265
2265
2266
2266
ValueDecl *D = nullptr ;
2267
- if (!InPoundIfEnvironment) {
2267
+ // When doing incremental re-parsing for SwiftSyntax this check may emit bogus
2268
+ // diagnostic. Also really the syntactic parser should not be doing name
2269
+ // lookups, so disable this check when parsing for SwiftSyntax.
2270
+ if (!InPoundIfEnvironment && !Context.LangOpts .ParseForSyntaxTreeOnly ) {
2268
2271
D = lookupInScope (name);
2269
2272
// FIXME: We want this to work: "var x = { x() }", but for now it's better
2270
2273
// to disallow it than to crash.
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %validate-incrparse %s --test-case REPLACE
3
+
4
+ let myFont : Font = {
5
+ let myFont = Font . body
6
+ return myFont. weight ( .< < REPLACE< bold||| light>>> )
7
+ } ( )
Original file line number Diff line number Diff line change @@ -277,6 +277,7 @@ swiftparse_client_node_t SynParser::parse(const char *source) {
277
277
TypeCheckerOptions tyckOpts;
278
278
LangOptions langOpts;
279
279
langOpts.BuildSyntaxTree = true ;
280
+ langOpts.ParseForSyntaxTreeOnly = true ;
280
281
langOpts.CollectParsedToken = false ;
281
282
// Disable name lookups during parsing.
282
283
// Not ready yet:
Original file line number Diff line number Diff line change @@ -606,6 +606,7 @@ int parseFile(
606
606
// Set up the compiler invocation
607
607
CompilerInvocation Invocation;
608
608
Invocation.getLangOptions ().BuildSyntaxTree = true ;
609
+ Invocation.getLangOptions ().ParseForSyntaxTreeOnly = true ;
609
610
Invocation.getLangOptions ().VerifySyntaxTree = options::VerifySyntaxTree;
610
611
Invocation.getLangOptions ().RequestEvaluatorGraphVizPath = options::GraphVisPath;
611
612
Invocation.getFrontendOptions ().InputsAndOutputs .addInputFile (InputFileName);
You can’t perform that action at this time.
0 commit comments