-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit][IDE] New SourceKit request to retrieve context type information #21377
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b033f48
[CodeCompletion] Only analyze inner most context
rintaro 2fb5425
[IDE] Rename CodeCompletionTypeContextAnalyzer to ExprContextAnalyzer
rintaro 5c64324
[IDE] Refactor ExprContextAnalyzer. NFC
rintaro 758ba5e
[IDE] Decouple ExprContextAnalyzer and ExprContextInfo
rintaro e3387c6
[IDE] ExprContextAnalyzer::Analyze() doesn't need to return success
rintaro 867c28e
[IDE] Rename collectArgumentExpectation() to analyzeApplyExpr()
rintaro d17bb78
[AST] Add shouldHideFromEditor() method
rintaro 2fbd3fe
[IDE] Move ExprContextAnalyser to its own file
rintaro cc1d5c1
[IDE] Move typeCheckContext() to ExprContextAnalysis.cpp
rintaro 54f0fab
[IDE] Add TypeContextInfo callbacks to parser
rintaro 3797b7a
[SourceKit] New request to retrieve context type information
rintaro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//===--- TypeContextInfo.h --------------------------------------*- C++ -*-===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2019 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 SWIFT_IDE_TYPECONTEXTINFO_H | ||
#define SWIFT_IDE_TYPECONTEXTINFO_H | ||
|
||
#include "swift/AST/Type.h" | ||
#include "swift/Basic/LLVM.h" | ||
|
||
namespace swift { | ||
class CodeCompletionCallbacksFactory; | ||
|
||
namespace ide { | ||
|
||
/// A result item for context info query. | ||
class TypeContextInfoItem { | ||
public: | ||
/// Possible expected type. | ||
Type ExpectedTy; | ||
/// Members of \c ExpectedTy which can be referenced by "Implicit Member | ||
/// Expression". | ||
SmallVector<ValueDecl *, 0> ImplicitMembers; | ||
|
||
TypeContextInfoItem(Type ExpectedTy) : ExpectedTy(ExpectedTy) {} | ||
}; | ||
|
||
/// An abstract base class for consumers of context info results. | ||
class TypeContextInfoConsumer { | ||
public: | ||
virtual ~TypeContextInfoConsumer() {} | ||
virtual void handleResults(ArrayRef<TypeContextInfoItem>) = 0; | ||
}; | ||
|
||
/// Printing consumer | ||
class PrintingTypeContextInfoConsumer : public TypeContextInfoConsumer { | ||
llvm::raw_ostream &OS; | ||
|
||
public: | ||
PrintingTypeContextInfoConsumer(llvm::raw_ostream &OS) : OS(OS) {} | ||
|
||
void handleResults(ArrayRef<TypeContextInfoItem>) override; | ||
}; | ||
|
||
/// Create a factory for code completion callbacks. | ||
CodeCompletionCallbacksFactory * | ||
makeTypeContextInfoCallbacksFactory(TypeContextInfoConsumer &Consumer); | ||
|
||
} // namespace ide | ||
} // namespace swift | ||
|
||
#endif // SWIFT_IDE_TYPECONTEXTINFO_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2550,6 +2550,34 @@ 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't usually copy doc comments to the definition since then we have two places to keep up to date separately. |
||
bool ValueDecl::shouldHideFromEditor() const { | ||
// Hide private stdlib declarations. | ||
if (isPrivateStdlibDecl(/*treatNonBuiltinProtocolsAsPublic*/ false) || | ||
// ShowInInterfaceAttr is for decls to show in interface as exception but | ||
// they are not intended to be used directly. | ||
getAttrs().hasAttribute<ShowInInterfaceAttr>()) | ||
return true; | ||
|
||
if (AvailableAttr::isUnavailable(this)) | ||
return true; | ||
|
||
if (auto *ClangD = getClangDecl()) { | ||
if (ClangD->hasAttr<clang::SwiftPrivateAttr>()) | ||
return true; | ||
} | ||
|
||
if (!isUserAccessible()) | ||
return true; | ||
|
||
// Hide editor placeholders. | ||
if (getBaseName().isEditorPlaceholder()) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
/// Return the access level of an internal or public declaration | ||
/// that's been testably imported. | ||
static AccessLevel getTestableOrPrivateImportsAccess(const ValueDecl *decl) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"despite of" -> "despite", or "in spite of"