[SourceKit] Similar with what we do for module printing, for quick help, elevate the doc-comment from conformances if the decl itself does not have associated doc-comment. rdar://24409720

This commit is contained in:
Xi Ge
2016-03-21 15:04:55 -07:00
parent 66fb8062fe
commit 2c75cfba39
2 changed files with 35 additions and 0 deletions

View File

@@ -178,6 +178,26 @@ func goo1(f : FooClass1) {
f.fooFunc1()
}
public protocol P4 {
/// foo1 comment from P4
func foo1()
/// foo2 comment from P4
func foo2()
}
public class C8 : P4 {
public func foo1() {
}
/// foo2 comment from C1
public func foo2() {
}
}
func foo2(f: C8) {
f.foo1()
f.foo2()
}
// RUN: rm -rf %t.tmp
// RUN: mkdir %t.tmp
// RUN: %swiftc_driver -emit-module -o %t.tmp/FooSwiftModule.swiftmodule %S/Inputs/FooSwiftModule.swift
@@ -623,3 +643,9 @@ func goo1(f : FooClass1) {
// RUN: %sourcekitd-test -req=cursor -pos=178:10 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | FileCheck -check-prefix=CHECK77 %s
// CHECK77-NOT: @warn_unused_result
// RUN: %sourcekitd-test -req=cursor -pos=197:7 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | FileCheck -check-prefix=CHECK78 %s
// RUN: %sourcekitd-test -req=cursor -pos=198:7 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | FileCheck -check-prefix=CHECK79 %s
// CHECK78: foo1 comment from P4
// CHECK79: foo2 comment from C1

View File

@@ -632,6 +632,15 @@ static bool passCursorInfoForDecl(const ValueDecl *VD,
}
unsigned DocCommentEnd = SS.size();
if (DocCommentEnd == DocCommentBegin) {
if (auto *Req = ASTPrinter::findConformancesWithDocComment(
const_cast<ValueDecl*>(VD))) {
llvm::raw_svector_ostream OS(SS);
ide::getDocumentationCommentAsXML(Req, OS);
}
DocCommentEnd = SS.size();
}
unsigned DeclBegin = SS.size();
{
llvm::raw_svector_ostream OS(SS);