Skip to content

[SourceKit][IDE] Update for feedback #22055

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 3 commits into from
Jan 24, 2019
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
2 changes: 1 addition & 1 deletion include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2416,7 +2416,7 @@ class ValueDecl : public Decl {
bool isUsableFromInline() const;

/// Returns \c true if this declaration is *not* intended to be used directly
/// by application developers despite of the visibility.
/// by application developers despite the visibility.
bool shouldHideFromEditor() const;

bool hasAccess() const {
Expand Down
2 changes: 0 additions & 2 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2550,8 +2550,6 @@ bool ValueDecl::isUsableFromInline() const {
return false;
}

/// Returns \c true if this declaration is *not* intended to be used directly
/// by application developers despite of the visibility.
bool ValueDecl::shouldHideFromEditor() const {
// Hide private stdlib declarations.
if (isPrivateStdlibDecl(/*treatNonBuiltinProtocolsAsPublic*/ false) ||
Expand Down
18 changes: 9 additions & 9 deletions lib/IDE/TypeContextInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class ContextInfoCallbacks : public CodeCompletionCallbacks {

// Ignore callbacks for suffix completions
// {
void completeDotExpr(Expr *E, SourceLoc DotLoc) override{};
void completePostfixExpr(Expr *E, bool hasSpace) override{};
void completeExprSuper(SuperRefExpr *SRE) override{};
void completeExprSuperDot(SuperRefExpr *SRE) override{};
void completeDotExpr(Expr *E, SourceLoc DotLoc) override {};
void completePostfixExpr(Expr *E, bool hasSpace) override {};
void completeExprSuper(SuperRefExpr *SRE) override {};
void completeExprSuperDot(SuperRefExpr *SRE) override {};
// }

// Ignore non-expression callbacks.
// {
void completeInPrecedenceGroup(SyntaxKind SK) override{};
void completePoundAvailablePlatform() override{};
void completeInPrecedenceGroup(SyntaxKind SK) override {};
void completePoundAvailablePlatform() override {};
void completeExprKeyPath(KeyPathExpr *KPE, SourceLoc DotLoc) override {}
void completeTypeSimpleBeginning() override {}
void completeTypeIdentifierWithDot(IdentTypeRepr *ITR) override {}
Expand All @@ -65,15 +65,15 @@ class ContextInfoCallbacks : public CodeCompletionCallbacks {
void completePlatformCondition() override {}
void completeGenericParams(TypeLoc TL) override {}
void completeAfterIfStmt(bool hasElse) override {}
void completeAccessorBeginning() override{};
void completeAccessorBeginning() override {};
// }

void completeStmtOrExpr() override{};
void completeStmtOrExpr() override {};
void completePostfixExprBeginning(CodeCompletionExpr *E) override;
void completeForEachSequenceBeginning(CodeCompletionExpr *E) override;
void completeCaseStmtBeginning() override;

void completeAssignmentRHS(AssignExpr *E) override{};
void completeAssignmentRHS(AssignExpr *E) override {};
void completeCallArg(CodeCompletionExpr *E) override;
void completeReturnStmt(CodeCompletionExpr *E) override;
void completeYieldStmt(CodeCompletionExpr *E,
Expand Down
12 changes: 12 additions & 0 deletions test/SourceKit/CompileNotifications/type-context-info.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %sourcekitd-test -req=track-compiles == -req=typecontextinfo %s -offset=0 -- %s | %FileCheck %s -check-prefix=COMPILE_1
// COMPILE_1: {
// COMPILE_1: key.notification: source.notification.compile-will-start,
// COMPILE_1: key.filepath: "SOURCE_DIR{{.*}}type-context-info.swift",
// COMPILE_1: key.compileid: [[CID1:".*"]]
// COMPILE_1: }
// COMPILE_1: {
// COMPILE_1: key.notification: source.notification.compile-did-finish,
// COMPILE_1: key.compileid: [[CID1]]
// COMPILE_1: }
// COMPILE_1-NOT: compile-will-start
// COMPILE_1-NOT: compile-did-finish
18 changes: 18 additions & 0 deletions tools/SourceKit/lib/SwiftLang/SwiftTypeContextInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "SwiftASTManager.h"
#include "SwiftLangSupport.h"
#include "SwiftEditorDiagConsumer.h"
#include "swift/Frontend/Frontend.h"
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
#include "swift/IDE/TypeContextInfo.h"
Expand Down Expand Up @@ -54,13 +55,30 @@ static bool swiftTypeContextInfoImpl(SwiftLangSupport &Lang,
auto bufferIdentifier =
Lang.resolvePathSymlinks(UnresolvedInputFile->getBufferIdentifier());

auto origOffset = Offset;
auto newBuffer = makeCodeCompletionMemoryBuffer(UnresolvedInputFile, Offset,
bufferIdentifier);

CompilerInstance CI;
PrintingDiagnosticConsumer PrintDiags;
CI.addDiagnosticConsumer(&PrintDiags);

EditorDiagConsumer TraceDiags;
trace::TracedOperation TracedOp(trace::OperationKind::CodeCompletion);
if (TracedOp.enabled()) {
CI.addDiagnosticConsumer(&TraceDiags);
trace::SwiftInvocation SwiftArgs;
trace::initTraceInfo(SwiftArgs, bufferIdentifier, Args);
TracedOp.setDiagnosticProvider(
[&TraceDiags](SmallVectorImpl<DiagnosticEntryInfo> &diags) {
TraceDiags.getAllDiagnostics(diags);
});
TracedOp.start(
SwiftArgs,
{std::make_pair("OriginalOffset", std::to_string(origOffset)),
std::make_pair("Offset", std::to_string(Offset))});
}

CompilerInvocation Invocation;
bool Failed = Lang.getASTManager()->initCompilerInvocation(
Invocation, Args, CI.getDiags(), bufferIdentifier, Error);
Expand Down