//===----------------------------------------------------------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2022 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 BuildServerIntegration @_spi(SourceKitLSP) import LanguageServerProtocol import SKLogging import SKTestSupport import SwiftExtensions import TSCBasic import TSCExtensions import ToolchainRegistry import XCTest final class CompilationDatabaseTests: SourceKitLSPTestCase { func testModifyCompilationDatabase() async throws { let project = try await MultiFileTestProject(files: [ "main.cpp": """ #if FOO void 1️⃣foo2️⃣() {} #else void 3️⃣foo4️⃣() {} #endif int main() { 5️⃣foo6️⃣(); } """, "compile_flags.txt": """ -DFOO """, ]) let (mainUri, positions) = try project.openDocument("main.cpp") // Verify that we get the expected result from a hover response before modifying the compile commands. let highlightRequest = DocumentHighlightRequest( textDocument: TextDocumentIdentifier(mainUri), position: positions["5️⃣"] ) let preChangeHighlightResponse = try await project.testClient.send(highlightRequest) XCTAssertEqual( preChangeHighlightResponse, [ DocumentHighlight(range: positions["1️⃣"]..