|
| 1 | +//===--- ASTMigratorPass.h --------------------------------------*- 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 | +// A base class for a syntactic migrator pass that uses the temporary |
| 14 | +// swift::migrator::EditorAdapter infrastructure. |
| 15 | +// |
| 16 | +//===----------------------------------------------------------------------===// |
| 17 | + |
| 18 | +#ifndef SWIFT_MIGRATOR_ASTMIGRATORPASS_H |
| 19 | +#define SWIFT_MIGRATOR_ASTMIGRATORPASS_H |
| 20 | + |
| 21 | +#include "swift/AST/ASTContext.h" |
| 22 | +#include "swift/Migrator/EditorAdapter.h" |
| 23 | + |
| 24 | +namespace swift { |
| 25 | +class SourceManager; |
| 26 | +struct MigratorOptions; |
| 27 | + |
| 28 | +namespace migrator { |
| 29 | +class ASTMigratorPass { |
| 30 | +protected: |
| 31 | + EditorAdapter &Editor; |
| 32 | + SourceFile *SF; |
| 33 | + const MigratorOptions &Opts; |
| 34 | + const StringRef Filename; |
| 35 | + const unsigned BufferID; |
| 36 | + SourceManager &SM; |
| 37 | + |
| 38 | + ASTMigratorPass(EditorAdapter &Editor, SourceFile *SF, |
| 39 | + const MigratorOptions &Opts) |
| 40 | + : Editor(Editor), SF(SF), Opts(Opts), Filename(SF->getFilename()), |
| 41 | + BufferID(SF->getBufferID().getValue()), |
| 42 | + SM(SF->getASTContext().SourceMgr) {} |
| 43 | +}; |
| 44 | + |
| 45 | +/// Run a general pass to migrate code based on SDK differences in the previous |
| 46 | +/// release. |
| 47 | +void runAPIDiffMigratorPass(EditorAdapter &Editor, |
| 48 | + SourceFile *SF, |
| 49 | + const MigratorOptions &Opts); |
| 50 | + |
| 51 | +/// Run a pass to fix up new tuple interpretation in SE-0110. |
| 52 | +void runTupleSplatMigratorPass(EditorAdapter &Editor, |
| 53 | + SourceFile *SF, |
| 54 | + const MigratorOptions &Opts); |
| 55 | + |
| 56 | +/// Run a pass to prepend 'Swift.' to `type(of:)` expressions if they will |
| 57 | +/// be shadowed in Swift 4, as these are now resolved by normal overload |
| 58 | +/// resolution. |
| 59 | +void runTypeOfMigratorPass(EditorAdapter &Editor, |
| 60 | + SourceFile *SF, |
| 61 | + const MigratorOptions &Opts); |
| 62 | + |
| 63 | +} // end namespace migrator |
| 64 | +} // end namespace swift |
| 65 | + |
| 66 | +#endif // SWIFT_MIGRATOR_ASTMIGRATORPASS_H |
0 commit comments