Skip to content

Commit 574d39b

Browse files
committed
[Parse] Split ParserPosition declaration to dedicated header file
1 parent 724052d commit 574d39b

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CodeCompletionCallbacks {
3434
protected:
3535
Parser &P;
3636
ASTContext &Context;
37-
Parser::ParserPosition ExprBeginPosition;
37+
ParserPosition ExprBeginPosition;
3838

3939
/// The declaration parsed during delayed parsing that was caused by code
4040
/// completion. This declaration contained the code completion token.
@@ -65,7 +65,7 @@ class CodeCompletionCallbacks {
6565
return CompleteExprSelectorContext != ObjCSelectorContext::None;
6666
}
6767

68-
void setExprBeginning(Parser::ParserPosition PP) {
68+
void setExprBeginning(ParserPosition PP) {
6969
ExprBeginPosition = PP;
7070
}
7171

include/swift/Parse/Parser.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "swift/Parse/LocalContext.h"
3131
#include "swift/Parse/PersistentParserState.h"
3232
#include "swift/Parse/Token.h"
33+
#include "swift/Parse/ParserPosition.h"
3334
#include "swift/Parse/ParserResult.h"
3435
#include "swift/Parse/SyntaxParserResult.h"
3536
#include "swift/Syntax/SyntaxParsingContext.h"
@@ -358,24 +359,6 @@ class Parser {
358359
//===--------------------------------------------------------------------===//
359360
// Routines to save and restore parser state.
360361

361-
class ParserPosition {
362-
public:
363-
ParserPosition() = default;
364-
ParserPosition &operator=(const ParserPosition &) = default;
365-
366-
bool isValid() const {
367-
return LS.isValid();
368-
}
369-
370-
private:
371-
ParserPosition(LexerState LS, SourceLoc PreviousLoc):
372-
LS(LS), PreviousLoc(PreviousLoc)
373-
{}
374-
LexerState LS;
375-
SourceLoc PreviousLoc;
376-
friend class Parser;
377-
};
378-
379362
ParserPosition getParserPosition() {
380363
return ParserPosition(L->getStateForBeginningOfToken(Tok, LeadingTrivia),
381364
PreviousLoc);

include/swift/Parse/ParserPosition.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--- ParserPosition.h - Parser Position ---------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// Parser position where Parser can jump to.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_PARSE_PARSERPOSITION_H
18+
#define SWIFT_PARSE_PARSERPOSITION_H
19+
20+
#include "swift/Basic/SourceLoc.h"
21+
#include "swift/Parse/LexerState.h"
22+
23+
namespace swift {
24+
25+
class ParserPosition {
26+
LexerState LS;
27+
SourceLoc PreviousLoc;
28+
friend class Parser;
29+
30+
ParserPosition(LexerState LS, SourceLoc PreviousLoc)
31+
: LS(LS), PreviousLoc(PreviousLoc) {}
32+
public:
33+
ParserPosition() = default;
34+
ParserPosition &operator=(const ParserPosition &) = default;
35+
36+
bool isValid() const { return LS.isValid(); }
37+
};
38+
39+
} // end namespace swift
40+
41+
#endif

0 commit comments

Comments
 (0)