Skip to content

[SourceKit] Don't link 'sourcekitd' to service related code #62308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ else()
endif()
target_link_libraries(sourcekitdInProc PRIVATE
SourceKitSwiftLang
sourcekitdAPI)
sourcekitdAPI
sourcekitdService
swiftIDETool)

# While it is possible to build this as a static library,
# to get the runtime paths correct, it must be linked into a binary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "sourcekitd/Internal.h"
#include "sourcekitd/Service.h"

#include "SourceKit/Support/Concurrency.h"
#include "SourceKit/Support/Logging.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ if (BUILD_SOURCEKIT_XPC_SERVICE)
else()
target_link_libraries(SourceKitService PRIVATE
SourceKitSwiftLang
sourcekitdAPI)
sourcekitdAPI
sourcekitdService)
endif()
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "sourcekitd/Internal-XPC.h"
#include "sourcekitd/Logging.h"
#include "sourcekitd/Service.h"

#include "SourceKit/Core/LLVM.h"
#include "SourceKit/Support/Concurrency.h"
Expand Down
25 changes: 1 addition & 24 deletions tools/SourceKit/tools/sourcekitd/include/sourcekitd/Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// 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
Expand Down Expand Up @@ -153,19 +153,6 @@ class RequestDict {
Optional<int64_t> getOptionalInt64(SourceKit::UIdent Key);
};

/// Initialize the service. Must be called before attempting to handle requests.
/// \param swiftExecutablePath The path of the swift-frontend executable.
/// Used to find clang relative to it.
/// \param runtimeLibPath The path to the toolchain's library directory.
/// \param diagnosticDocumentationPath The path to diagnostics documentation.
/// \param postNotification Callback to post a notification.
void initializeService(
llvm::StringRef swiftExecutablePath, llvm::StringRef runtimeLibPath,
llvm::StringRef diagnosticDocumentationPath,
std::function<void(sourcekitd_response_t)> postNotification);
/// Shutdown the service.
void shutdownService();

/// Initialize the sourcekitd client library. Returns true if this is the first
/// time it is initialized.
bool initializeClient();
Expand All @@ -175,16 +162,6 @@ bool shutdownClient();

void set_interrupted_connection_handler(llvm::function_ref<void()> handler);

typedef std::function<void(sourcekitd_response_t)> ResponseReceiver;

void handleRequest(sourcekitd_object_t Request,
SourceKitCancellationToken CancellationToken,
ResponseReceiver Receiver);

void cancelRequest(SourceKitCancellationToken CancellationToken);

void disposeCancellationToken(SourceKitCancellationToken CancellationToken);

void printRequestObject(sourcekitd_object_t Obj, llvm::raw_ostream &OS);
void printResponse(sourcekitd_response_t Resp, llvm::raw_ostream &OS);

Expand Down
50 changes: 50 additions & 0 deletions tools/SourceKit/tools/sourcekitd/include/sourcekitd/Service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===--- Service.h - --------------------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_SOURCEKITD_SERVICE_H
#define LLVM_SOURCEKITD_SERVICE_H

#include "SourceKit/Support/CancellationToken.h"
#include "sourcekitd/sourcekitd.h"
#include "llvm/ADT/StringRef.h"

#include <functional>

namespace sourcekitd {
using SourceKit::SourceKitCancellationToken;

/// Initialize the service. Must be called before attempting to handle requests.
/// \param swiftExecutablePath The path of the swift-frontend executable.
/// Used to find clang relative to it.
/// \param runtimeLibPath The path to the toolchain's library directory.
/// \param diagnosticDocumentationPath The path to diagnostics documentation.
/// \param postNotification Callback to post a notification.
void initializeService(
llvm::StringRef swiftExecutablePath, llvm::StringRef runtimeLibPath,
llvm::StringRef diagnosticDocumentationPath,
std::function<void(sourcekitd_response_t)> postNotification);
/// Shutdown the service.
void shutdownService();

typedef std::function<void(sourcekitd_response_t)> ResponseReceiver;

void handleRequest(sourcekitd_object_t Request,
SourceKitCancellationToken CancellationToken,
ResponseReceiver Receiver);

void cancelRequest(SourceKitCancellationToken CancellationToken);

void disposeCancellationToken(SourceKitCancellationToken CancellationToken);

} // namespace sourcekitd

#endif // LLVM_SOURCEKITD_SERVICE_H
9 changes: 3 additions & 6 deletions tools/SourceKit/tools/sourcekitd/lib/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ add_sourcekit_library(sourcekitdAPI
DocStructureArray.cpp
DocSupportAnnotationArray.cpp
RawData.cpp
Requests.cpp
sourcekitdAPI-Common.cpp
TokenAnnotationsArray.cpp
ExpressionTypeArray.cpp
VariableTypeArray.cpp
UIDHandling.cpp
)
UIDHandling.cpp)

target_link_libraries(sourcekitdAPI PRIVATE
swiftBasic
SourceKitSupport
SourceKitSwiftLang
swiftCompilerModules)
SourceKitSupport)

if(APPLE AND HAVE_XPC_H)
target_sources(sourcekitdAPI PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#include "sourcekitd/CodeCompletionResultsArray.h"
#include "sourcekitd/CompactArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "SourceKit/Core/LLVM.h"
#include "SourceKit/Support/UIdent.h"
#include "DictionaryKeys.h"

#include "llvm/Support/MemoryBuffer.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
//===----------------------------------------------------------------------===//

#include "sourcekitd/DocStructureArray.h"
#include "DictionaryKeys.h"
#include "sourcekitd/CompactArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "SourceKit/Core/LLVM.h"
#include "SourceKit/Support/UIdent.h"
#include "sourcekitd/CompactArray.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
//===----------------------------------------------------------------------===//

#include "sourcekitd/DocSupportAnnotationArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "sourcekitd/CompactArray.h"
#include "SourceKit/Core/LangSupport.h"
#include "llvm/Support/MemoryBuffer.h"

#include "DictionaryKeys.h"

using namespace SourceKit;
using namespace sourcekitd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

#include "sourcekitd/ExpressionTypeArray.h"
#include "sourcekitd/CompactArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "SourceKit/Core/LLVM.h"
#include "SourceKit/Core/LangSupport.h"
#include "SourceKit/Support/UIdent.h"
#include "DictionaryKeys.h"

#include "llvm/Support/MemoryBuffer.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#include "sourcekitd/TokenAnnotationsArray.h"
#include "sourcekitd/CompactArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "SourceKit/Core/LLVM.h"
#include "SourceKit/Support/UIdent.h"
#include "DictionaryKeys.h"

#include "llvm/Support/MemoryBuffer.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

#include "sourcekitd/VariableTypeArray.h"
#include "sourcekitd/CompactArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "SourceKit/Core/LLVM.h"
#include "SourceKit/Core/LangSupport.h"
#include "SourceKit/Support/UIdent.h"
#include "DictionaryKeys.h"

#include "llvm/Support/MemoryBuffer.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#include "DictionaryKeys.h"
#include "sourcekitd/DictionaryKeys.h"
#include "sourcekitd/Internal.h"
#include "sourcekitd/Logging.h"
#include "sourcekitd/RequestResponsePrinterBase.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#include "DictionaryKeys.h"
#include "sourcekitd/DictionaryKeys.h"
#include "sourcekitd/Internal.h"
#include "sourcekitd/CodeCompletionResultsArray.h"
#include "sourcekitd/DocStructureArray.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//

#include "DictionaryKeys.h"
#include "sourcekitd/CodeCompletionResultsArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "sourcekitd/DocStructureArray.h"
#include "sourcekitd/DocSupportAnnotationArray.h"
#include "sourcekitd/TokenAnnotationsArray.h"
Expand Down
1 change: 1 addition & 0 deletions tools/SourceKit/tools/sourcekitd/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(API)
add_subdirectory(Service)
10 changes: 10 additions & 0 deletions tools/SourceKit/tools/sourcekitd/lib/Service/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

add_sourcekit_library(sourcekitdService
Requests.cpp
)
target_link_libraries(sourcekitdService PRIVATE
sourcekitdAPI
swiftBasic
SourceKitSupport
SourceKitSwiftLang
swiftCompilerModules)
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
//
//===----------------------------------------------------------------------===//

#include "DictionaryKeys.h"
#include "sourcekitd/Service.h"
#include "sourcekitd/CodeCompletionResultsArray.h"
#include "sourcekitd/DictionaryKeys.h"
#include "sourcekitd/DocStructureArray.h"
#include "sourcekitd/DocSupportAnnotationArray.h"
#include "sourcekitd/TokenAnnotationsArray.h"
Expand Down