Skip to content

Commit 381684a

Browse files
committed
[SourceKit] Remove diagnostics path calculation
The diagnostic group documentation now point to the swift.org URL rather than the toolchain path, so it no longer needs to be passed all the way through sourcekitd. Resolves rdar://151500502.
1 parent f7529ea commit 381684a

File tree

22 files changed

+47
-107
lines changed

22 files changed

+47
-107
lines changed

include/swift/IDETool/CompileInstance.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ namespace ide {
3333
class CompileInstance {
3434
const std::string &SwiftExecutablePath;
3535
const std::string &RuntimeResourcePath;
36-
const std::string &DiagnosticDocumentationPath;
3736
const std::shared_ptr<swift::PluginRegistry> Plugins;
3837

3938
struct Options {
@@ -70,12 +69,10 @@ class CompileInstance {
7069
public:
7170
CompileInstance(const std::string &SwiftExecutablePath,
7271
const std::string &RuntimeResourcePath,
73-
const std::string &DiagnosticDocumentationPath,
7472
std::shared_ptr<swift::PluginRegistry> Plugins = nullptr)
7573
: SwiftExecutablePath(SwiftExecutablePath),
76-
RuntimeResourcePath(RuntimeResourcePath),
77-
DiagnosticDocumentationPath(DiagnosticDocumentationPath),
78-
Plugins(Plugins), CachedCIInvalidated(false), CachedReuseCount(0) {}
74+
RuntimeResourcePath(RuntimeResourcePath), Plugins(Plugins),
75+
CachedCIInvalidated(false), CachedReuseCount(0) {}
7976

8077
/// NOTE: \p Args is only used for checking the equaity of the invocation.
8178
/// Since this function assumes that it is already normalized, exact the same

include/swift/IDETool/CompilerInvocation.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ bool initCompilerInvocation(
2727
StringRef UnresolvedPrimaryFile,
2828
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
2929
const std::string &swiftExecutablePath,
30-
const std::string &runtimeResourcePath,
31-
const std::string &diagnosticDocumentationPath, time_t sessionTimestamp,
30+
const std::string &runtimeResourcePath, time_t sessionTimestamp,
3231
std::string &Error);
3332

3433
bool initInvocationByClangArguments(ArrayRef<const char *> ArgList,

lib/IDETool/CompileInstance.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,9 @@ bool CompileInstance::setupCI(
258258
auto &Diags = CI->getDiags();
259259

260260
SmallVector<const char *, 16> args;
261-
// Put '-resource-dir' and '-diagnostic-documentation-path' at the top to
262-
// allow overriding them with the passed in arguments.
261+
// Put '-resource-dir' at the top to allow overriding them with the passed in
262+
// arguments.
263263
args.append({"-resource-dir", RuntimeResourcePath.c_str()});
264-
args.append({"-Xfrontend", "-diagnostic-documentation-path", "-Xfrontend",
265-
DiagnosticDocumentationPath.c_str()});
266264
args.append(origArgs.begin(), origArgs.end());
267265

268266
SmallString<256> driverPath(SwiftExecutablePath);

lib/IDETool/CompilerInvocation.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,13 @@ bool ide::initCompilerInvocation(
157157
StringRef UnresolvedPrimaryFile,
158158
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
159159
const std::string &swiftExecutablePath,
160-
const std::string &runtimeResourcePath,
161-
const std::string &diagnosticDocumentationPath, time_t sessionTimestamp,
160+
const std::string &runtimeResourcePath, time_t sessionTimestamp,
162161
std::string &Error) {
163162
SmallVector<const char *, 16> Args;
164-
// Make sure to put '-resource-dir' and '-diagnostic-documentation-path' at
165-
// the top to allow overriding them with the passed in arguments.
163+
// Make sure to put '-resource-dir' at the top to allow overriding them with
164+
// the passed in arguments.
166165
Args.push_back("-resource-dir");
167166
Args.push_back(runtimeResourcePath.c_str());
168-
Args.push_back("-Xfrontend");
169-
Args.push_back("-diagnostic-documentation-path");
170-
Args.push_back("-Xfrontend");
171-
Args.push_back(diagnosticDocumentationPath.c_str());
172167
Args.append(OrigArgs.begin(), OrigArgs.end());
173168

174169
SmallString<32> ErrStr;

test/SourceKit/Sema/educational_note_diags.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
typealias Crap = () -> ()
2-
extension Crap {}
1+
typealias Foo = () -> ()
2+
extension Foo {}
33

44
// RUN: %sourcekitd-test -req=sema %s -- %s | %FileCheck %s -check-prefix=NO_OVERRIDE
55

66
// NO_OVERRIDE: key.description: "non-nominal type
77
// NO_OVERRIDE: key.educational_note_paths: [
8-
// NO_OVERRIDE-NEXT: share{{[/\\]+}}doc{{[/\\]+}}swift{{[/\\]+}}diagnostics{{[/\\]+}}nominal-types"
8+
// NO_OVERRIDE-NEXT: "https://docs.swift.org/compiler/documentation/diagnostics/nominal-types"
99
// NO_OVERRIDE-NEXT: ]
1010

1111
// RUN: %sourcekitd-test -req=sema %s -- -Xfrontend -diagnostic-documentation-path -Xfrontend /educational/notes/path/prefix %s | %FileCheck %s -check-prefix=OVERRIDE

tools/SourceKit/include/SourceKit/Core/Context.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ class Context {
166166
/// Used to find clang relative to it.
167167
std::string SwiftExecutablePath;
168168
std::string RuntimeLibPath;
169-
std::string DiagnosticDocumentationPath;
170169
std::unique_ptr<LangSupport> SwiftLang;
171170
std::shared_ptr<NotificationCenter> NotificationCtr;
172171
std::shared_ptr<GlobalConfig> Config;
@@ -176,7 +175,6 @@ class Context {
176175

177176
public:
178177
Context(StringRef SwiftExecutablePath, StringRef RuntimeLibPath,
179-
StringRef DiagnosticDocumentationPath,
180178
llvm::function_ref<std::unique_ptr<LangSupport>(Context &)>
181179
LangSupportFactoryFn,
182180
llvm::function_ref<std::shared_ptr<PluginSupport>(Context &)>
@@ -187,9 +185,6 @@ class Context {
187185
StringRef getSwiftExecutablePath() const { return SwiftExecutablePath; }
188186

189187
StringRef getRuntimeLibPath() const { return RuntimeLibPath; }
190-
StringRef getDiagnosticDocumentationPath() const {
191-
return DiagnosticDocumentationPath;
192-
}
193188

194189
LangSupport &getSwiftLangSupport() { return *SwiftLang; }
195190

tools/SourceKit/lib/Core/Context.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ GlobalConfig::getIDEInspectionOpts() const {
3737

3838
SourceKit::Context::Context(
3939
StringRef SwiftExecutablePath, StringRef RuntimeLibPath,
40-
StringRef DiagnosticDocumentationPath,
4140
llvm::function_ref<std::unique_ptr<LangSupport>(Context &)>
4241
LangSupportFactoryFn,
4342
llvm::function_ref<std::shared_ptr<PluginSupport>(Context &)>
4443
PluginSupportFactoryFn,
4544
bool shouldDispatchNotificationsOnMain)
4645
: SwiftExecutablePath(SwiftExecutablePath), RuntimeLibPath(RuntimeLibPath),
47-
DiagnosticDocumentationPath(DiagnosticDocumentationPath),
4846
NotificationCtr(
4947
new NotificationCenter(shouldDispatchNotificationsOnMain)),
5048
Config(new GlobalConfig()), ReqTracker(new RequestTracker()),

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,11 @@ struct SwiftASTManager::Implementation {
564564
std::shared_ptr<SwiftStatistics> Stats,
565565
std::shared_ptr<RequestTracker> ReqTracker,
566566
std::shared_ptr<PluginRegistry> Plugins, StringRef SwiftExecutablePath,
567-
StringRef RuntimeResourcePath, StringRef DiagnosticDocumentationPath)
567+
StringRef RuntimeResourcePath)
568568
: EditorDocs(EditorDocs), Config(Config), Stats(Stats),
569569
ReqTracker(ReqTracker), Plugins(Plugins),
570570
SwiftExecutablePath(SwiftExecutablePath),
571571
RuntimeResourcePath(RuntimeResourcePath),
572-
DiagnosticDocumentationPath(DiagnosticDocumentationPath),
573572
SessionTimestamp(llvm::sys::toTimeT(std::chrono::system_clock::now())) {
574573
}
575574

@@ -582,7 +581,6 @@ struct SwiftASTManager::Implementation {
582581
/// Used to find clang relative to it.
583582
std::string SwiftExecutablePath;
584583
std::string RuntimeResourcePath;
585-
std::string DiagnosticDocumentationPath;
586584
SourceManager SourceMgr;
587585
Cache<ASTKey, ASTProducerRef> ASTCache{ "sourcekit.swift.ASTCache" };
588586
llvm::sys::Mutex CacheMtx;
@@ -668,10 +666,9 @@ SwiftASTManager::SwiftASTManager(
668666
std::shared_ptr<SwiftStatistics> Stats,
669667
std::shared_ptr<RequestTracker> ReqTracker,
670668
std::shared_ptr<PluginRegistry> Plugins, StringRef SwiftExecutablePath,
671-
StringRef RuntimeResourcePath, StringRef DiagnosticDocumentationPath)
669+
StringRef RuntimeResourcePath)
672670
: Impl(*new Implementation(EditorDocs, Config, Stats, ReqTracker, Plugins,
673-
SwiftExecutablePath, RuntimeResourcePath,
674-
DiagnosticDocumentationPath)) {}
671+
SwiftExecutablePath, RuntimeResourcePath)) {}
675672

676673
SwiftASTManager::~SwiftASTManager() {
677674
delete &Impl;
@@ -710,8 +707,8 @@ bool SwiftASTManager::initCompilerInvocation(
710707
std::string &Error) {
711708
return ide::initCompilerInvocation(
712709
Invocation, OrigArgs, Action, Diags, UnresolvedPrimaryFile, FileSystem,
713-
Impl.SwiftExecutablePath, Impl.RuntimeResourcePath,
714-
Impl.DiagnosticDocumentationPath, Impl.SessionTimestamp, Error);
710+
Impl.SwiftExecutablePath, Impl.RuntimeResourcePath, Impl.SessionTimestamp,
711+
Error);
715712
}
716713

717714
bool SwiftASTManager::initCompilerInvocation(

tools/SourceKit/lib/SwiftLang/SwiftASTManager.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ class SwiftASTManager : public std::enable_shared_from_this<SwiftASTManager> {
259259
std::shared_ptr<RequestTracker> ReqTracker,
260260
std::shared_ptr<swift::PluginRegistry> Plugins,
261261
StringRef SwiftExecutablePath,
262-
StringRef RuntimeResourcePath,
263-
StringRef DiagnosticDocumentationPath);
262+
StringRef RuntimeResourcePath);
264263
~SwiftASTManager();
265264

266265
SwiftInvocationRef getTypecheckInvocation(ArrayRef<const char *> Args,

tools/SourceKit/lib/SwiftLang/SwiftCompile.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ compile::SessionManager::getSession(StringRef name) {
3131
}
3232

3333
bool inserted = false;
34-
std::tie(i, inserted) =
35-
sessions.try_emplace(name, std::make_shared<compile::Session>(
36-
SwiftExecutablePath, RuntimeResourcePath,
37-
DiagnosticDocumentationPath, Plugins));
34+
std::tie(i, inserted) = sessions.try_emplace(
35+
name, std::make_shared<compile::Session>(SwiftExecutablePath,
36+
RuntimeResourcePath, Plugins));
3837
assert(inserted);
3938
return i->second;
4039
}

0 commit comments

Comments
 (0)