Files
swift-mirror/include/swift/Parse/DelayedParsingCallbacks.h
practicalswift ca92efc8e6 Use consistent formatting of header comments.
Correct format:
```
//===--- Name of file - Description ----------------------------*- Lang -*-===//
```

Notes:
* Comment line should be exactly 80 chars.
* Padding: Pad with dashes after "Description" to reach 80 chars.
* "Name of file", "Description" and "Lang" are all optional.
* In case of missing "Lang": drop the "-*-" markers.
* In case of missing space: drop one, two or three dashes before "Name of file".
2016-01-04 23:00:53 +01:00

69 lines
2.4 KiB
C++

//===--- DelayedParsingCallbacks.h - Delayed parsing callbacks ------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_PARSE_DELAYED_PARSING_CALLBACKS_H
#define SWIFT_PARSE_DELAYED_PARSING_CALLBACKS_H
#include "swift/Basic/SourceLoc.h"
#include "swift/Basic/SourceManager.h"
#include "swift/Parse/Parser.h"
namespace swift {
class DeclAttributes;
class AbstractFunctionDecl;
/// \brief Callbacks for Parser's delayed parsing.
class DelayedParsingCallbacks {
virtual void anchor();
public:
virtual ~DelayedParsingCallbacks() = default;
/// Checks if a function body should be delayed or skipped altogether.
virtual bool shouldDelayFunctionBodyParsing(Parser &TheParser,
AbstractFunctionDecl *AFD,
const DeclAttributes &Attrs,
SourceRange BodyRange) = 0;
};
class AlwaysDelayedCallbacks : public DelayedParsingCallbacks {
bool shouldDelayFunctionBodyParsing(Parser &TheParser,
AbstractFunctionDecl *AFD,
const DeclAttributes &Attrs,
SourceRange BodyRange) override {
return true;
}
};
/// \brief Implementation of callbacks that guide the parser in delayed
/// parsing for code completion.
class CodeCompleteDelayedCallbacks : public DelayedParsingCallbacks {
SourceLoc CodeCompleteLoc;
public:
explicit CodeCompleteDelayedCallbacks(SourceLoc CodeCompleteLoc)
: CodeCompleteLoc(CodeCompleteLoc) {
}
bool shouldDelayFunctionBodyParsing(Parser &TheParser,
AbstractFunctionDecl *AFD,
const DeclAttributes &Attrs,
SourceRange BodyRange) override {
// Delay parsing if the code completion point is in the function body.
return TheParser.SourceMgr
.rangeContainsTokenLoc(BodyRange, CodeCompleteLoc);
}
};
} // namespace swift
#endif