Commit Graph

986 Commits

Author SHA1 Message Date
Rintaro Ishizaki
566a84d641 [CodeCompletion] Handle new kinds in type relation printing 2020-02-05 15:35:01 -08:00
Rintaro Ishizaki
e9c51a0755 [CodeCompletion] Report 'Unrelated' type relation for keywords 2020-02-05 15:09:14 -08:00
Rintaro Ishizaki
c31bfaeeed [CodeCompletion] Introduce 'Unknown' type relation
Now

* NotApplicable: The result is not relevant for type relation (e.g.
  keywords, and overloads)
* Unknown: the relation was not calculated (e.g. cached results), or the
  context type is unknown.
* Invalid: The result type is invalid for this context (i.e. 'Void' for
  non-'Void' context)
* Unrelated: The result type has no relation to the context type
* Convertible: The result type is convertible to the context type
* Identical: The result type is identical to the context type
2020-02-05 14:23:59 -08:00
Rintaro Ishizaki
17abedf1ef [CodeCompletion] Introduce 'NotApplicable' type relation
For keywords, and overrides.
2020-02-05 14:23:59 -08:00
Rintaro Ishizaki
71aeffdf17 [CodeCompletion] Calculate type relation for EnumElementDecl 2020-02-03 17:20:50 -08:00
David Zarzycki
ed15a9e939 [QoI] Fix -Wmisleading-indentation warnings 2020-01-19 13:31:16 -05:00
Rintaro Ishizaki
ac7ba746f6 [CodeCompletion] Stop printing underlined keyword in override completion
e.g. `__consuming`. Now, conformance completion for
Sequence.makeIterator() is:

  struct MySequence: Sequence {
    func makeIterator() -> some IteratorProtocol {
      <#code#>
    }
  }

rdar://problem/56963545
2020-01-10 13:03:42 -08:00
Rintaro Ishizaki
b9f1e58b37 [CodeCompletion] Use GenericSignature methods to get associatedtype reqs 2020-01-08 21:35:49 -08:00
Rintaro Ishizaki
1dd6fe5688 [CodeCompletion] Stop suggesting opaque result type for generic function
in override completion. As per SE-0244:

> Associated type inference can only infer an opaque result type for a
> non-generic requirement, because the opaque type is parameterized by
> the function's own generic arguments
2020-01-08 17:37:42 -08:00
Rintaro Ishizaki
e388c4a381 [CodeCompletion] Get associatedtype constraints from ProtocolDecl::getRequirementSignature()
instead of AssociatedTypeDecl::getInherited() when checking if the
return type should be suggested as "opaque result type" in override
completion.

AssociatedTypeDecl::getInherited() is not serialized. So if the protocol
is declared in a module, it was never suggested as 'some' result.

rdar://problem/57245073
2020-01-08 17:37:42 -08:00
Varun Gandhi
022314a640 Merge pull request #28643 from kitaisreal/using-located-instead-of-pair
[Compiler]: Using Located<T> instead of std::pair<SourceLoc, T>
2020-01-06 14:22:29 -08:00
Rintaro Ishizaki
ab0475178a [CodeCompletion] Eliminate CodeCompletionCallbacks::completeExpr()
Well, this does nothing. It just set the parser position twice and calls
the consumer's 'handleResults()' without any reason.
It seems it was intended to be a "fallback" completion, but it was never
implemented properly. So just remove it for now.

rdar://problem/58102910
2019-12-20 09:39:02 -08:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
Slava Pestov
3604b21f2a AST: Simplify Expr::getReferencedDecl() 2019-12-19 23:51:53 -05:00
Slava Pestov
3149d6d62c IDE: Preparations for Sema building curry thunks 2019-12-19 23:51:53 -05:00
Rintaro Ishizaki
62078c79dd [ASTPrinter/CodeCompletion] Stop printing base type when possible
rdar://problem/57033931
2019-12-17 16:26:37 -08:00
Brent Royal-Gordon
1df792ae9f [NFC] Convert TypeRepr to use DeclName(Loc)?
Replaces `ComponentIdentTypeRepr::getIdentifier()` and `getIdLoc()` with `getNameRef()` and `getNameLoc()`, which use `DeclName` and `DeclNameRef` respectively.
2019-12-11 00:45:08 -08:00
Robert Widmann
a9ce2babd2 Merge pull request #28624 from CodaFi/heres-looking-up-you-kid
[NFC] Pull Semantic Member Synthesis into TypeChecker's Lookup Entrypoints
2019-12-10 10:40:31 -08:00
Robert Widmann
00407857d0 [NFC] Swap CodeCompletion's lookupQualified for TypeChecker's
This call relied on semantic member synthesis, so now it has to go through TypeChecker::lookupQualified.
2019-12-06 14:18:31 -08:00
Brent Royal-Gordon
63ec1cf5af Introduce a separate #filePath, remove -pound-file
This makes the path behavior more first-class. The feature is now hidden behind an experimental flag, -enable-experimental-concise-pound-file.
2019-12-04 16:35:13 -08:00
Rintaro Ishizaki
ad4b9df3c0 [CodeCompletion] Suggest the property name in its didSet clause
Previously, property names are hidden in the whole range of the
declarations. Now, it's only hidden in its own initializer range.

rdar://problem/49697202
2019-12-03 18:12:47 -08:00
Rintaro Ishizaki
97b16ce5e3 [CodeCompletion] Remove unsound check in override completion
In override completion, we didn't use to emit 'class var' with the initial
expression. However, having initial expression does not have any bearing
on whether the declaration is overridable or not.
2019-11-12 17:40:36 +09:00
Rintaro Ishizaki
f6a76f51a0 Utilize forEachTypeWitness()/forEachValueWitness() 2019-11-12 13:30:55 +09:00
Rintaro Ishizaki
2564a6e494 [CodeCompletion] Avoid typechecking all toplevel decls in the current file
- Use `performParseAndResolveImportsOnly()` to invoke the frontend
- Do `bindExtensions()` in `ide::typeCheckContextUntil()`
- Typecheck preceding `TopLevelCodeDecl`s only if the compleiton is in
  a `TopLevelCodeDecl`
- Other related tweaks

rdar://problem/56636747
2019-11-12 12:57:18 +09:00
Robert Widmann
2b08d1b834 [NFC] ASTContext::getLazyResolver -> ASTContext::getLegacyGlobalTypeChecker 2019-11-05 14:44:41 -08:00
Nathan Hawes
aeea756718 Merge pull request #27935 from nathawes/module-qualified-type-completion
[code-completion] Suggest module names, and handle module name bases for member completion in type position
2019-11-01 13:51:17 -07:00
Nathan Hawes
eabb561994 [code-completion] Give Modules a SemanticContextKind of None
This seems more correct than OtherModule, and means they're treated as
low-priority results for the session-based completion APIs. With default
options that means won't be shown in global completion results but will be
once there's some matching filter text. It also sorts them below any symbols
that actually come from other modules, which is desirable, since most symbols
don't need to be module qualified.

The SemanticContextKind change doesn't seem to affect Xcode's handling of the
results.
2019-11-01 11:11:52 -07:00
Nathan Hawes
14107acfe6 Merge pull request #27983 from nathawes/complete-self-dot-init-in-struct-initializer
[code-completion] Suggest self.init in value type constructors
2019-10-31 12:34:36 -07:00
Nathan Hawes
1317db9520 [code-completion] Suggest self.init(..) in value type constructors
We missed these previously.
2019-10-30 17:41:34 -07:00
Robert Widmann
4996858c4d Re-implement isInvalid for ValueDecls 2019-10-30 15:09:14 -07:00
Nathan Hawes
b871454b8f [code-completion] Suggest module names in type and expression position
They can be used to qualify both.
2019-10-30 11:28:56 -07:00
Robert Widmann
e7006a92b1 Clean up some trivially true condition clauses
ProtocolConformanceRef::isConcrete checks the invalid bit for us.
2019-10-29 16:56:22 -07:00
Robert Widmann
3e1a61f425 [NFC] Fold The Tri-State In Optional<ProtocolConformanceRef>
ProtocolConformanceRef already has an invalid state.  Drop all of the
uses of Optional<ProtocolConformanceRef> and just use
ProtocolConformanceRef::forInvalid() to represent it.  Mechanically
translate all of the callers and callsites to use this new
representation.
2019-10-29 16:55:56 -07:00
Nathan Hawes
7350917c22 [code-completion] Complete after qualifying module names in type position
Previously we would just return if the parsed type loc didn't type check as a
type.
2019-10-29 10:48:53 -07:00
Rintaro Ishizaki
bf5aa0a5a1 Revert "Merge pull request #27325 from rintaro/syntaxparse-cctype"
This reverts commit 439b9111b7, reversing
changes made to 4e476ff243.
2019-10-14 12:20:57 -07:00
Xi Ge
dd33540231 AST: rename printDeclUSRForModuleDoc to printDeclUSR. NFC 2019-10-09 15:29:52 -07:00
Slava Pestov
a260d0a445 AST: getInterfaceType() returns ErrorType instead of Type() on circularity 2019-10-08 01:37:09 -04:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
Rintaro Ishizaki
439b9111b7 Merge pull request #27325 from rintaro/syntaxparse-cctype
[SyntaxParse] Introduce CodeCompletionTypeSyntax
2019-09-24 20:43:43 +02:00
Rintaro Ishizaki
1a9b6d0dbf [SyntaxParse] Introduce CodeCompletionTypeSyntax
To represent a type with code completion.

  type? '.'? <code-completion-token>

This is "parser only" node which is not exposed to SwiftSyntax.
Using this, defer to set the parsed type to code-completion callbacks.
2019-09-24 10:21:38 -07:00
Robert Widmann
50d9ab6694 [NFC] Drop some unnecesary interface type forcing 2019-09-24 10:12:16 -07:00
Robert Widmann
792e1db448 Port getInterfaceType() patterns in ancillary libraries 2019-09-23 16:49:51 -07:00
Robert Widmann
b135928125 Drop CheckingWithValidSignature from the validation state machine
Now that the generic signature is computable on demand, this predicate is doubly useless.  All of the callers intended to ask "hasInterfaceType" anyways.
2019-09-20 22:22:49 -07:00
Robert Widmann
38bde33067 Merge pull request #27172 from CodaFi/aliasing-artifacts-and-noise-reduction-techniques
Kill validateDeclForNameLookup Harder
2019-09-18 15:00:51 -07:00
Nathan Hawes
4dac0d1e8b Merge pull request #27218 from nathawes/r53958454-getFixedTypeRecursive-code-completion-crash
[code-completion] Remove special handling for completion on the RHS of an assignment
2019-09-18 10:49:38 -07:00
Nathan Hawes
54defbc7f7 [code-completion] Remove special handling for completion on the RHS of an assignment
This simplifies the code and prevents an assertion failure this code was
hitting computing the type relations between the result types and what it
determined as the expected type.

Resolves rdar://problem/53958454
2019-09-17 18:59:33 -07:00
Jordan Rose
8d7f1b7c5d [AST] Separate SourceFile from FileUnit.h
Like the last commit, SourceFile is used a lot by Parse and Sema, but
less so by the ClangImporter and (de)Serialization. Split it out to
cut down on recompilation times when something changes.

This commit does /not/ split the implementation of SourceFile out of
Module.cpp, which is where most of it lives. That might also be a
reasonable change, but the reason I was reluctant to is because a
number of SourceFile members correspond to the entry points in
ModuleDecl. Someone else can pick this up later if they decide it's a
good idea.

No functionality change.
2019-09-17 17:54:41 -07:00
Robert Widmann
5e34169aca Separate computing interface types and underlying types
Computing the interface type of a typealias used to push validation forward and recompute the interface type on the fly.  This was fragile and inconsistent with the way interface types are computed in the rest of the decls.  Separate these two notions, and plumb through explicit interface type computations with the same "computeType" idiom.  This will better allow us to identify the places where we have to force an interface type computation.

Also remove access to the underlying type loc.  It's now just a cache location the underlying type request will use.  Push a type repr accessor to the places that need it, and push the underlying type accessor for everywhere else.  Getting the structural type is still preferred for pre-validated computations.

This required the resetting of a number of places where we were - in many cases tacitly - asking the question "does the interface type exist".  This enables the removal of validateDeclForNameLookup
2019-09-17 08:20:55 -07:00
Sasha Krassovsky
d4110e44f2 Fix warnings in IDE 2019-09-13 09:57:48 -07:00