mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Parse] Check the SourceFile to see if bodies can be delayed
Remove the `DelayBodyParsing` flag from the parser and instead query the source file.
This commit is contained in:
@@ -569,6 +569,10 @@ public:
|
||||
|
||||
bool isSuitableForASTScopes() const { return canBeParsedInFull(); }
|
||||
|
||||
/// Whether the bodies of types and functions within this file can be lazily
|
||||
/// parsed.
|
||||
bool hasDelayedBodyParsing() const;
|
||||
|
||||
syntax::SourceFileSyntax getSyntaxRoot() const;
|
||||
void setSyntaxRoot(syntax::SourceFileSyntax &&Root);
|
||||
bool hasSyntaxRoot() const;
|
||||
|
||||
@@ -173,9 +173,9 @@ public:
|
||||
|
||||
LocalContext *CurLocalContext = nullptr;
|
||||
|
||||
bool isDelayedParsingEnabled() const {
|
||||
return DelayBodyParsing || isCodeCompletionFirstPass();
|
||||
}
|
||||
/// Whether we should delay parsing nominal type, extension, and function
|
||||
/// bodies.
|
||||
bool isDelayedParsingEnabled() const;
|
||||
|
||||
void setCodeCompletionCallbacks(CodeCompletionCallbacks *Callbacks) {
|
||||
CodeCompletion = Callbacks;
|
||||
@@ -213,16 +213,6 @@ public:
|
||||
/// Always empty if !SF.shouldBuildSyntaxTree().
|
||||
ParsedTrivia TrailingTrivia;
|
||||
|
||||
/// Whether we should delay parsing nominal type and extension bodies,
|
||||
/// and skip function bodies.
|
||||
///
|
||||
/// This is false in primary files, since we want to type check all
|
||||
/// declarations and function bodies.
|
||||
///
|
||||
/// This is true for non-primary files, where declarations only need to be
|
||||
/// lazily parsed and type checked.
|
||||
bool DelayBodyParsing;
|
||||
|
||||
/// Whether to evaluate the conditions of #if decls, meaning that the bodies
|
||||
/// of any active clauses are hoisted such that they become sibling nodes with
|
||||
/// the #if decl.
|
||||
@@ -408,16 +398,16 @@ public:
|
||||
SILParserTUStateBase *SIL,
|
||||
PersistentParserState *PersistentState,
|
||||
std::shared_ptr<SyntaxParseActions> SPActions = nullptr,
|
||||
bool DelayBodyParsing = true, bool EvaluateConditionals = true);
|
||||
bool EvaluateConditionals = true);
|
||||
Parser(unsigned BufferID, SourceFile &SF, SILParserTUStateBase *SIL,
|
||||
PersistentParserState *PersistentState = nullptr,
|
||||
std::shared_ptr<SyntaxParseActions> SPActions = nullptr,
|
||||
bool DelayBodyParsing = true, bool EvaluateConditionals = true);
|
||||
bool EvaluateConditionals = true);
|
||||
Parser(std::unique_ptr<Lexer> Lex, SourceFile &SF,
|
||||
SILParserTUStateBase *SIL = nullptr,
|
||||
PersistentParserState *PersistentState = nullptr,
|
||||
std::shared_ptr<SyntaxParseActions> SPActions = nullptr,
|
||||
bool DelayBodyParsing = true, bool EvaluateConditionals = true);
|
||||
bool EvaluateConditionals = true);
|
||||
~Parser();
|
||||
|
||||
/// Returns true if the buffer being parsed is allowed to contain SIL.
|
||||
|
||||
@@ -108,11 +108,7 @@ namespace swift {
|
||||
/// \param SF The file within the module being parsed.
|
||||
///
|
||||
/// \param BufferID The buffer to parse from.
|
||||
///
|
||||
/// \param DelayBodyParsing Whether parsing of type and function bodies can be
|
||||
/// delayed.
|
||||
void parseIntoSourceFile(SourceFile &SF, unsigned BufferID,
|
||||
bool DelayBodyParsing = true,
|
||||
bool EvaluateConditionals = true);
|
||||
|
||||
/// Parse a source file's SIL declarations into a given SIL module.
|
||||
|
||||
Reference in New Issue
Block a user