Skip to content

Commit d9b7a33

Browse files
authored
Use forward declarations instead of IWYU (#4868)
* Remove rarely used template argumnets from SortedMap/SortedSet * Remove unused STATUS_CHECK_OK * Rename QuerySnapshot::Listener to QuerySnapshotListener This makes the type something that can be forward declared. * Rename DocumentSnapshot::Listener to DocumentSnapshotListener This makes the type something that can be forward declared. * Rename ViewSnapshot::Listener to ViewSnapshotListener This makes the type something that can be forward declared. * Put most QueryListener implementation in .cc * Actually use sync_engine_callback.h * Add forward declaration headers for api, core, and model These centralize forward declarations, including declarations for some hard-to-forward-declare types. * Move includes of hard_assert.h out of other headers * Make testutil definitions out of line * Move definitions out-of-line * Move DocumentKey definitions out-of-line * Move definitions out-of-line * Shorten unnecessarily long namespace usages * Use default destructors where possible * Delete unused MutationBatch::kUnknown constant * Use forward declarations instead of IWYU * Misc fixups from Linux/GCC 9.2.1 * Fix testutil under VS 2017 Forward declarations of functions local to a function body end up generating unresolved externals. Reduce most of these back to just calling FieldValue::FromX methods.
1 parent f321ad8 commit d9b7a33

File tree

213 files changed

+1420
-818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+1420
-818
lines changed

Firestore/Example/Tests/API/FIRFieldPathTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
2424

25+
#include "Firestore/core/src/firebase/firestore/model/field_path.h"
2526
#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
2627

2728
namespace testutil = firebase::firestore::testutil;

Firestore/Example/Tests/API/FIRQueryUnitTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#import "Firestore/Example/Tests/API/FSTAPIHelpers.h"
2525
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
2626

27+
#include "Firestore/core/src/firebase/firestore/core/query.h"
2728
#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
2829

2930
namespace api = firebase::firestore::api;

Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
2424
#import "Firestore/Source/API/FIRFirestore+Internal.h"
2525

26+
#include "Firestore/core/src/firebase/firestore/api/query_snapshot.h"
2627
#include "Firestore/core/src/firebase/firestore/core/firestore_client.h"
2728
#include "Firestore/core/test/firebase/firestore/testutil/app_testing.h"
2829

Firestore/Example/Tests/Integration/FSTDatastoreTests.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929

3030
#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
3131
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
32+
#include "Firestore/core/src/firebase/firestore/local/local_documents_view.h"
3233
#include "Firestore/core/src/firebase/firestore/local/local_store.h"
3334
#include "Firestore/core/src/firebase/firestore/local/memory_persistence.h"
3435
#include "Firestore/core/src/firebase/firestore/local/simple_query_engine.h"
3536
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
3637
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
3738
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
39+
#include "Firestore/core/src/firebase/firestore/model/mutation_batch_result.h"
3840
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
41+
#include "Firestore/core/src/firebase/firestore/model/set_mutation.h"
3942
#include "Firestore/core/src/firebase/firestore/remote/datastore.h"
4043
#include "Firestore/core/src/firebase/firestore/remote/remote_event.h"
4144
#include "Firestore/core/src/firebase/firestore/remote/remote_store.h"

Firestore/Example/Tests/SpecTests/FSTMockDatastore.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
#include <unordered_map>
2121
#include <vector>
2222

23-
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
24-
#include "Firestore/core/src/firebase/firestore/model/types.h"
23+
#include "Firestore/core/src/firebase/firestore/model/model_fwd.h"
2524
#include "Firestore/core/src/firebase/firestore/remote/datastore.h"
2625
#include "Firestore/core/src/firebase/firestore/util/status_fwd.h"
2726

Firestore/Example/Tests/SpecTests/FSTSpecTests.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@
3232

3333
#include "Firestore/core/include/firebase/firestore/firestore_errors.h"
3434
#include "Firestore/core/src/firebase/firestore/auth/user.h"
35+
#include "Firestore/core/src/firebase/firestore/core/field_filter.h"
3536
#include "Firestore/core/src/firebase/firestore/local/persistence.h"
3637
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
38+
#include "Firestore/core/src/firebase/firestore/model/delete_mutation.h"
3739
#include "Firestore/core/src/firebase/firestore/model/document.h"
3840
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
3941
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
4042
#include "Firestore/core/src/firebase/firestore/model/field_value.h"
4143
#include "Firestore/core/src/firebase/firestore/model/maybe_document.h"
4244
#include "Firestore/core/src/firebase/firestore/model/no_document.h"
45+
#include "Firestore/core/src/firebase/firestore/model/patch_mutation.h"
4346
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
47+
#include "Firestore/core/src/firebase/firestore/model/set_mutation.h"
4448
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
4549
#include "Firestore/core/src/firebase/firestore/model/types.h"
4650
#include "Firestore/core/src/firebase/firestore/nanopb/nanopb_util.h"

Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,9 @@
2323
#include <vector>
2424

2525
#include "Firestore/core/src/firebase/firestore/auth/user.h"
26-
#include "Firestore/core/src/firebase/firestore/core/event_listener.h"
2726
#include "Firestore/core/src/firebase/firestore/core/query.h"
2827
#include "Firestore/core/src/firebase/firestore/core/view_snapshot.h"
29-
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
30-
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
31-
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
32-
#include "Firestore/core/src/firebase/firestore/model/mutation.h"
33-
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
34-
#include "Firestore/core/src/firebase/firestore/model/types.h"
28+
#include "Firestore/core/src/firebase/firestore/model/model_fwd.h"
3529
#include "Firestore/core/src/firebase/firestore/nanopb/byte_string.h"
3630
#include "Firestore/core/src/firebase/firestore/nanopb/nanopb_util.h"
3731
#include "Firestore/core/src/firebase/firestore/remote/watch_change.h"
@@ -43,15 +37,19 @@ namespace firestore {
4337
namespace local {
4438

4539
class Persistence;
40+
class TargetData;
4641

4742
} // namespace local
4843
} // namespace firestore
4944
} // namespace firebase
5045

46+
namespace auth = firebase::firestore::auth;
5147
namespace core = firebase::firestore::core;
5248
namespace local = firebase::firestore::local;
5349
namespace model = firebase::firestore::model;
5450
namespace nanopb = firebase::firestore::nanopb;
51+
namespace remote = firebase::firestore::remote;
52+
namespace util = firebase::firestore::util;
5553

5654
// A map holds expected information about currently active targets. The keys are
5755
// target ID, and the values are a vector of `TargetData`s mapped to the target and
@@ -70,8 +68,8 @@ NS_ASSUME_NONNULL_BEGIN
7068
@property(nonatomic, assign) core::Query query;
7169
@property(nonatomic, strong, nullable) NSError *error;
7270

73-
- (const absl::optional<firebase::firestore::core::ViewSnapshot> &)viewSnapshot;
74-
- (void)setViewSnapshot:(absl::optional<firebase::firestore::core::ViewSnapshot>)snapshot;
71+
- (const absl::optional<core::ViewSnapshot> &)viewSnapshot;
72+
- (void)setViewSnapshot:(absl::optional<core::ViewSnapshot>)snapshot;
7573

7674
@end
7775

@@ -91,9 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
9189
@end
9290

9391
/** Mapping of user => array of FSTMutations for that user. */
94-
typedef std::unordered_map<firebase::firestore::auth::User,
95-
NSMutableArray<FSTOutstandingWrite *> *,
96-
firebase::firestore::auth::HashUser>
92+
typedef std::unordered_map<auth::User, NSMutableArray<FSTOutstandingWrite *> *, auth::HashUser>
9793
FSTOutstandingWriteQueues;
9894

9995
/**
@@ -131,7 +127,7 @@ typedef std::unordered_map<firebase::firestore::auth::User,
131127
* mutation queues).
132128
*/
133129
- (instancetype)initWithPersistence:(std::unique_ptr<local::Persistence>)persistence
134-
initialUser:(const firebase::firestore::auth::User &)initialUser
130+
initialUser:(const auth::User &)initialUser
135131
outstandingWrites:(const FSTOutstandingWriteQueues &)outstandingWrites
136132
NS_DESIGNATED_INITIALIZER;
137133

@@ -155,7 +151,7 @@ typedef std::unordered_map<firebase::firestore::auth::User,
155151
* @param query A valid query to execute against the backend.
156152
* @return The target ID assigned by the system to track the query.
157153
*/
158-
- (firebase::firestore::model::TargetId)addUserListenerWithQuery:(core::Query)query;
154+
- (model::TargetId)addUserListenerWithQuery:(core::Query)query;
159155

160156
/**
161157
* Removes a listener from the FSTSyncEngine as if the user had removed a listener corresponding
@@ -178,8 +174,8 @@ typedef std::unordered_map<firebase::firestore::auth::User,
178174
* @param snapshot A snapshot version to attach, if applicable. This should be sent when
179175
* simulating the server having sent a complete snapshot.
180176
*/
181-
- (void)receiveWatchChange:(const firebase::firestore::remote::WatchChange &)change
182-
snapshotVersion:(const firebase::firestore::model::SnapshotVersion &)snapshot;
177+
- (void)receiveWatchChange:(const remote::WatchChange &)change
178+
snapshotVersion:(const model::SnapshotVersion &)snapshot;
183179

184180
/**
185181
* Delivers a watch stream error as if the Streaming Watch backend has generated some kind of error.
@@ -226,9 +222,9 @@ typedef std::unordered_map<firebase::firestore::auth::User,
226222
* the mutation. Snapshot versions must be monotonically increasing.
227223
* @param mutationResults The mutation results for the write that is being acked.
228224
*/
229-
- (FSTOutstandingWrite *)
230-
receiveWriteAckWithVersion:(const firebase::firestore::model::SnapshotVersion &)commitVersion
231-
mutationResults:(std::vector<model::MutationResult>)mutationResults;
225+
- (FSTOutstandingWrite *)receiveWriteAckWithVersion:(const model::SnapshotVersion &)commitVersion
226+
mutationResults:
227+
(std::vector<model::MutationResult>)mutationResults;
232228

233229
/**
234230
* A count of the mutations written to the write stream by the FSTSyncEngine, but not yet
@@ -261,14 +257,14 @@ typedef std::unordered_map<firebase::firestore::auth::User,
261257
/**
262258
* Runs a pending timer callback on the worker queue.
263259
*/
264-
- (void)runTimer:(firebase::firestore::util::TimerId)timerID;
260+
- (void)runTimer:(util::TimerId)timerID;
265261

266262
/**
267263
* Switches the FSTSyncEngine to a new user. The test driver tracks the outstanding mutations for
268264
* each user, so future receiveWriteAck/Error operations will validate the write sent to the mock
269265
* datastore matches the next outstanding write for that user.
270266
*/
271-
- (void)changeUser:(const firebase::firestore::auth::User &)user;
267+
- (void)changeUser:(const auth::User &)user;
272268

273269
/**
274270
* Drains the client's dispatch queue.
@@ -294,14 +290,13 @@ typedef std::unordered_map<firebase::firestore::auth::User,
294290
- (NSArray<NSString *> *)capturedRejectedWritesSinceLastCall;
295291

296292
/** The current set of documents in limbo. */
297-
- (std::map<firebase::firestore::model::DocumentKey, firebase::firestore::model::TargetId>)
298-
currentLimboDocuments;
293+
- (std::map<model::DocumentKey, model::TargetId>)currentLimboDocuments;
299294

300295
/** The expected set of documents in limbo. */
301-
- (const firebase::firestore::model::DocumentKeySet &)expectedLimboDocuments;
296+
- (const model::DocumentKeySet &)expectedLimboDocuments;
302297

303298
/** Sets the expected set of documents in limbo. */
304-
- (void)setExpectedLimboDocuments:(firebase::firestore::model::DocumentKeySet)docs;
299+
- (void)setExpectedLimboDocuments:(model::DocumentKeySet)docs;
305300

306301
/**
307302
* The writes that have been sent to the FSTSyncEngine via writeUserMutation: but not yet
@@ -322,7 +317,7 @@ typedef std::unordered_map<firebase::firestore::auth::User,
322317
@property(nonatomic, assign, readonly) const FSTOutstandingWriteQueues &outstandingWrites;
323318

324319
/** The current user for the FSTSyncEngine; determines which mutation queue is active. */
325-
@property(nonatomic, assign, readonly) const firebase::firestore::auth::User &currentUser;
320+
@property(nonatomic, assign, readonly) const auth::User &currentUser;
326321

327322
/**
328323
* The number of snapshots-in-sync events that have been received.
@@ -345,8 +340,7 @@ typedef std::unordered_map<firebase::firestore::auth::User,
345340
- (void)removeSnapshotsInSyncListener;
346341

347342
/** The set of active targets as observed on the watch stream. */
348-
- (const std::unordered_map<firebase::firestore::model::TargetId, local::TargetData> &)
349-
activeTargets;
343+
- (const std::unordered_map<model::TargetId, local::TargetData> &)activeTargets;
350344

351345
/** The expected set of active targets, keyed by target ID. */
352346
- (const ActiveTargetMap &)expectedActiveTargets;

Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "Firestore/core/src/firebase/firestore/auth/user.h"
3333
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
3434
#include "Firestore/core/src/firebase/firestore/core/event_manager.h"
35+
#include "Firestore/core/src/firebase/firestore/core/listen_options.h"
36+
#include "Firestore/core/src/firebase/firestore/core/query_listener.h"
3537
#include "Firestore/core/src/firebase/firestore/core/sync_engine.h"
3638
#include "Firestore/core/src/firebase/firestore/local/index_free_query_engine.h"
3739
#include "Firestore/core/src/firebase/firestore/local/local_store.h"

Firestore/Example/Tests/Util/FSTHelpers.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,13 @@
1919
#include <string>
2020
#include <vector>
2121

22-
#include "Firestore/core/src/firebase/firestore/model/field_path.h"
22+
#include "Firestore/core/src/firebase/firestore/model/model_fwd.h"
2323
#include "absl/strings/string_view.h"
2424

2525
@class FIRGeoPoint;
2626
@class FSTDocumentKeyReference;
2727
@class FSTUserDataConverter;
2828

29-
namespace firebase {
30-
namespace firestore {
31-
32-
namespace model {
33-
class DeleteMutation;
34-
class DocumentKey;
35-
class FieldValue;
36-
class ObjectValue;
37-
class PatchMutation;
38-
class SetMutation;
39-
class TransformMutation;
40-
} // namespace model
41-
42-
} // namespace firestore
43-
} // namespace firebase
44-
4529
namespace model = firebase::firestore::model;
4630

4731
NS_ASSUME_NONNULL_BEGIN

Firestore/Example/Tests/Util/FSTHelpers.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "Firestore/core/src/firebase/firestore/model/field_value.h"
3333
#include "Firestore/core/src/firebase/firestore/model/patch_mutation.h"
3434
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
35+
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
3536
#include "Firestore/core/src/firebase/firestore/model/set_mutation.h"
3637
#include "Firestore/core/src/firebase/firestore/model/transform_mutation.h"
3738
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"

0 commit comments

Comments
 (0)