Skip to content

Commit b857b22

Browse files
committed
NFC: Rename shouldCollectToken -> shouldCollectTokens
And fix the name of the underlying vector.
1 parent 84d376a commit b857b22

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

include/swift/AST/SourceFile.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,13 @@ class SourceFile final : public FileUnit {
573573

574574
std::vector<Token> &getTokenVector();
575575

576+
/// If this source file has been told to collect its parsed tokens, retrieve
577+
/// those tokens.
576578
ArrayRef<Token> getAllTokens() const;
577579

578-
bool shouldCollectToken() const;
580+
/// Whether the parsed tokens of this source file should be saved, allowing
581+
/// them to be accessed from \c getAllTokens.
582+
bool shouldCollectTokens() const;
579583

580584
bool shouldBuildSyntaxTree() const;
581585

@@ -602,8 +606,9 @@ class SourceFile final : public FileUnit {
602606

603607
private:
604608

605-
/// If not None, the underlying vector should contain tokens of this source file.
606-
Optional<std::vector<Token>> AllCorrectedTokens;
609+
/// If not \c None, the underlying vector contains the parsed tokens of this
610+
/// source file.
611+
Optional<std::vector<Token>> AllCollectedTokens;
607612

608613
std::unique_ptr<SourceFileSyntaxInfo> SyntaxInfo;
609614
};

lib/AST/Module.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,26 +2232,26 @@ SourceFile::SourceFile(ModuleDecl &M, SourceFileKind K,
22322232
(void)problem;
22332233
}
22342234
if (KeepParsedTokens) {
2235-
AllCorrectedTokens = std::vector<Token>();
2235+
AllCollectedTokens = std::vector<Token>();
22362236
}
22372237
}
22382238

22392239
std::vector<Token> &SourceFile::getTokenVector() {
2240-
assert(shouldCollectToken() && "Disabled");
2241-
return *AllCorrectedTokens;
2240+
assert(shouldCollectTokens() && "Disabled");
2241+
return *AllCollectedTokens;
22422242
}
22432243

22442244
ArrayRef<Token> SourceFile::getAllTokens() const {
2245-
assert(shouldCollectToken() && "Disabled");
2246-
return *AllCorrectedTokens;
2245+
assert(shouldCollectTokens() && "Disabled");
2246+
return *AllCollectedTokens;
22472247
}
22482248

2249-
bool SourceFile::shouldCollectToken() const {
2249+
bool SourceFile::shouldCollectTokens() const {
22502250
switch (Kind) {
22512251
case SourceFileKind::Library:
22522252
case SourceFileKind::Main:
22532253
case SourceFileKind::Interface:
2254-
return (bool)AllCorrectedTokens;
2254+
return (bool)AllCollectedTokens;
22552255
case SourceFileKind::SIL:
22562256
return false;
22572257
}
@@ -2283,7 +2283,7 @@ bool SourceFile::hasDelayedBodyParsing() const {
22832283
return false;
22842284
if (hasInterfaceHash())
22852285
return false;
2286-
if (shouldCollectToken())
2286+
if (shouldCollectTokens())
22872287
return false;
22882288
if (shouldBuildSyntaxTree())
22892289
return false;

lib/Parse/Parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ Parser::Parser(std::unique_ptr<Lexer> Lex, SourceFile &SF,
531531
CurDeclContext(&SF),
532532
Context(SF.getASTContext()),
533533
CurrentTokenHash(SF.getInterfaceHashPtr()),
534-
TokReceiver(SF.shouldCollectToken() ?
534+
TokReceiver(SF.shouldCollectTokens() ?
535535
new TokenRecorder(SF, L->getBufferID()) :
536536
new ConsumeTokenReceiver()),
537537
SyntaxContext(new SyntaxParsingContext(SyntaxContext, SF,

0 commit comments

Comments
 (0)