-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Dont mark type mismatching items 'not recommended' #31474
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
[CodeCompletion] Dont mark type mismatching items 'not recommended' #31474
Conversation
lib/IDE/CodeCompletion.cpp
Outdated
@@ -1240,7 +1240,7 @@ CodeCompletionResult *CodeCompletionResultBuilder::takeResult() { | |||
typeRelation = | |||
calculateMaxTypeRelationForDecl(AssociatedDecl, declTypeContext); | |||
|
|||
if (typeRelation == CodeCompletionResult::Invalid) { | |||
if (!IsNotRecommended && typeRelation == CodeCompletionResult::Invalid) { | |||
IsNotRecommended = true; | |||
NotRecReason = CodeCompletionResult::NotRecommendedReason::TypeMismatch; | |||
} |
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.
At this point, I don't remove this because complete.open
uses this for sorting, and I don't want to change them to use the type relation. It'd be non trivial change.
@swift-ci Please smoke test |
dc6b1d7
to
b4b7a1f
Compare
@swift-ci Please smoke test |
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.
The original idea with "NotRecommendedReason" was we have various kinds of "invalid" symbols, and we could expose the reason so clients could decide how they wanted to mark them up. For example, we also show module names as "not recommended" when they are already imported, which is also distinct from "deprecated".
Have you considered exposing the NotRecommendedReason instead and letting the client decide?
Yes, but I don't think the reason should have |
Okay, I don't have a strong preference and I'm okay with this approach. I would prefer we cleanup the internal API as well though. I'm not clear why you think that would be a big change? CodeCompletionOrganizer already uses the type relations, so I don't see why we couldn't handle "invalid" specifically in the places where we currently handle "not recommended". |
b4b7a1f
to
de36957
Compare
@swift-ci Please smoke test |
Removed |
include/swift/IDE/CodeCompletion.h
Outdated
@@ -705,17 +704,18 @@ class CodeCompletionResult { | |||
StringRef BriefDocComment, | |||
ArrayRef<StringRef> AssociatedUSRs, | |||
ArrayRef<std::pair<StringRef, StringRef>> DocWords, | |||
enum ExpectedTypeRelation TypeDistance, |
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.
Why is "enum" used here? I would expect the type name to be unambiiguous in this context
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.
Oops, just a copy/paste mistake.
func foo() {} let a: Int = #^HERE^# Previously, we marked 'foo()' as 'NotRecommented' because 'Void' doesn't have any member hence it cannot be 'Int'. But it wass confusing with 'deprecated'. Now that we output 'typerelation' which is 'invalid' in this case. So clients can deprioritize results, or even filter them out. rdar://problem/57726512
de36957
to
e9c438c
Compare
@swift-ci Please smoke test |
Previously, we marked
foo()
asNotRecommented
becauseVoid
doesn't have any member hence it cannot beInt
. But it was confusing withdeprecated
.Now that we output 'typerelation' which is 'invalid' in this case. So clients can de-prioritize them, or even filter them out.
rdar://problem/57726512