mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
This introduces an abstraction layer around `IndexStoreDB` (yes, I known another one …) that consults the underlying `IndexStoreDB` and then checks whether the entries are up-to-date with respect to some `IndexCheckLevel`. Requests can specify how picky they want to be about declaring results from the index out-of-date. The default choice right now is to not include index entries from source files that have been deleted (because those are definitely from lingering unit files) but include results even if the source file has been modified after it was last indexed. We do include results from files that have been modified since they were last indexed because: When a file gets modified, it's likely that some of the line:column locations in it are still correct – eg. if only one line is modified and if lines are inserted/deleted all locations above are still correct. For locations that are out of date, showing stale results is one of the best ways of communicating to the user that the index is out-of-date and that they need to rebuild. We might want to reconsider this default when we have background indexing. rdar://125230833 rdar://126622963
28 lines
1002 B
Swift
28 lines
1002 B
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import LanguageServerProtocol
|
|
|
|
/// A type that can provide the set of main files that include a particular file.
|
|
public protocol MainFilesProvider: Sendable {
|
|
|
|
/// Returns the set of main files that contain the given file.
|
|
///
|
|
/// For example,
|
|
///
|
|
/// ```
|
|
/// mainFilesContainingFile("foo.cpp") == Set(["foo.cpp"])
|
|
/// mainFilesContainingFile("foo.h") == Set(["foo.cpp", "bar.cpp"])
|
|
/// ```
|
|
func mainFilesContainingFile(_: DocumentURI) async -> Set<DocumentURI>
|
|
}
|