-
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
Conversation
The name "context info" is fairly general; do you think "type context info" would work? Right now all the results are related to the semantic type of the context. On the other hand, if you foresee us adding non-type information here it might be misleading. |
} | ||
llvm::outs() << "found code completion token " << CodeCompletionToken | ||
<< " at offset " << Offset << "\n"; | ||
llvm::errs() << "found code completion token " << CodeCompletionToken |
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.
Huh, I wonder why we write this to both outs()
and errs()
. Seems silly. I guess it's fine to copy what code-completion does for now though.
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.
Yeah, I just copied from code-completion code.
I believe outs()
is for FileCheck
and errs()
is to see which test case failed from failure log.
One possible enhancement in my mind is adding "kind" of context. Like foo(x: #TOKEN#) // -> call argument
return #TOKEN# // -> return value
if #TOKEN# { // -> statement condition But I'm not sure it's valuable. And I think "type context info" still works even after adding it. |
cb7f5ff
to
d71fac0
Compare
d71fac0
to
d0df476
Compare
Now that this passes all test cases we currently have. Stop analyzing outer contexts because it may emit invalid context type.
We don't need to keep ExprFinder beyond analysis.
Just refactoring. ExprContextInfo automatically construct analyzer and analyze().
Removed unnecessary arguments.
This replaces shouldHideDeclFromCompletionResults() in IDE.
TypeContextInfo is for new SourceKit request which receives source location, and returns context type and members which can be referenced by "implicit member expression" syntax. Implement that as a code completion callbacks.
d0df476
to
aa6d86b
Compare
@swift-ci Please smoke test |
This is a new SourceKit request which receives a position in the source file, returns possible expected types and their members which can be referenced by "implicit member expression" syntax.
aa6d86b
to
3797b7a
Compare
@swift-ci Please smoke test |
@benlangmuir @akyrtzi I think this PR is ready for reviewing. |
@@ -2412,6 +2412,10 @@ 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. |
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"
@@ -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 comment
The 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.
@@ -2116,7 +2049,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer { | |||
void addVarDeclRef(const VarDecl *VD, DeclVisibilityKind Reason) { | |||
if (!VD->hasName() || | |||
!VD->isAccessibleFrom(CurrDeclContext) || | |||
shouldHideDeclFromCompletionResults(VD)) | |||
VD->shouldHideFromEditor()) |
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.
Is the function shouldHideDeclFromCompletionResults
removed? I can't find it in this patch.
|
||
// Ignore callbacks for suffix completions | ||
// { | ||
void completeDotExpr(Expr *E, SourceLoc DotLoc) override{}; |
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.
Style: should have a space before {}
.
} | ||
CI.performSema(); | ||
|
||
return true; |
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.
We should copy over the trace::TracedOperation
code from code-completion as well so that this action shows up in compilation traces such as the Index Log.
This is a new SourceKit request which receives a position in the source file, returns possible expected types and their members which can be referenced by "implicit member expression" syntax.
rdar://problem/44698136