Skip to content

Commit 85bf521

Browse files
committed
[CodeCompletion] Move CodeCompletionResultSink to its own file
1 parent e37796d commit 85bf521

File tree

2 files changed

+59
-36
lines changed

2 files changed

+59
-36
lines changed

include/swift/IDE/CodeCompletion.h

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/Basic/StringExtras.h"
2222
#include "swift/Frontend/Frontend.h"
2323
#include "swift/IDE/CodeCompletionResult.h"
24+
#include "swift/IDE/CodeCompletionResultSink.h"
2425
#include "swift/IDE/CodeCompletionString.h"
2526
#include "llvm/ADT/ArrayRef.h"
2627
#include "llvm/ADT/StringMap.h"
@@ -75,42 +76,6 @@ ArrayRef<T> copyArray(llvm::BumpPtrAllocator &Allocator,
7576
return llvm::makeArrayRef(Buffer, Arr.size());
7677
}
7778

78-
struct CodeCompletionResultSink {
79-
using AllocatorPtr = std::shared_ptr<llvm::BumpPtrAllocator>;
80-
81-
/// The allocator used to allocate results "native" to this sink.
82-
AllocatorPtr Allocator;
83-
84-
/// Allocators that keep alive "foreign" results imported into this sink from
85-
/// other sinks.
86-
std::vector<AllocatorPtr> ForeignAllocators;
87-
88-
/// Whether to annotate the results with XML.
89-
bool annotateResult = false;
90-
91-
/// Whether to emit object literals if desired.
92-
bool includeObjectLiterals = true;
93-
94-
/// Whether to emit type initializers in addition to type names in expression
95-
/// position.
96-
bool addInitsToTopLevel = false;
97-
98-
/// Whether to perform "call pettern heuristics".
99-
bool enableCallPatternHeuristics = false;
100-
101-
/// Whether to include an item without any default arguments.
102-
bool addCallWithNoDefaultArgs = true;
103-
104-
std::vector<CodeCompletionResult *> Results;
105-
106-
/// A single-element cache for module names stored in Allocator, keyed by a
107-
/// clang::Module * or swift::ModuleDecl *.
108-
std::pair<void *, NullTerminatedStringRef> LastModule;
109-
110-
CodeCompletionResultSink()
111-
: Allocator(std::make_shared<llvm::BumpPtrAllocator>()) {}
112-
};
113-
11479
/// A utility for calculating the import depth of a given module. Direct imports
11580
/// have depth 1, imports of those modules have depth 2, etc.
11681
///
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//===--- CodeCompletionResultSink.h ---------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2022 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+
#ifndef SWIFT_IDE_CODECOMPLETIONRESULTSINK
14+
#define SWIFT_IDE_CODECOMPLETIONRESULTSINK
15+
16+
namespace swift {
17+
namespace ide {
18+
19+
struct CodeCompletionResultSink {
20+
using AllocatorPtr = std::shared_ptr<llvm::BumpPtrAllocator>;
21+
22+
/// The allocator used to allocate results "native" to this sink.
23+
AllocatorPtr Allocator;
24+
25+
/// Allocators that keep alive "foreign" results imported into this sink from
26+
/// other sinks.
27+
std::vector<AllocatorPtr> ForeignAllocators;
28+
29+
/// Whether to annotate the results with XML.
30+
bool annotateResult = false;
31+
32+
/// Whether to emit object literals if desired.
33+
bool includeObjectLiterals = true;
34+
35+
/// Whether to emit type initializers in addition to type names in expression
36+
/// position.
37+
bool addInitsToTopLevel = false;
38+
39+
/// Whether to perform "call pettern heuristics".
40+
bool enableCallPatternHeuristics = false;
41+
42+
/// Whether to include an item without any default arguments.
43+
bool addCallWithNoDefaultArgs = true;
44+
45+
std::vector<CodeCompletionResult *> Results;
46+
47+
/// A single-element cache for module names stored in Allocator, keyed by a
48+
/// clang::Module * or swift::ModuleDecl *.
49+
std::pair<void *, NullTerminatedStringRef> LastModule;
50+
51+
CodeCompletionResultSink()
52+
: Allocator(std::make_shared<llvm::BumpPtrAllocator>()) {}
53+
};
54+
55+
} // end namespace ide
56+
} // end namespace swift
57+
58+
#endif // SWIFT_IDE_CODECOMPLETIONRESULTSINK

0 commit comments

Comments
 (0)