Commit Graph

113 Commits

Author SHA1 Message Date
Rintaro Ishizaki
5096ab7bc4 [CodeCompletion] Complete type attributes
Complete type attributes after '@' in a type position

rdar://44917341
2021-05-19 20:44:40 -07:00
Rintaro Ishizaki
b348bf60e1 [CodeCompletion] Complete pattern introducer for 'for'
After 'for', suggest 'try', 'await', 'var' and 'case'.

rdar://76355581
2021-05-06 18:13:43 -07:00
Rintaro Ishizaki
4284a51589 [Parse/CodeCompletion] Implement effects specifier completion
Rewrote and rename 'parseAsyncThrows' to 'parseEffectsSpecifiers'.
Implemented 'CodeCompletionCallbacks::completeEffectsSpecifier()'
2020-12-14 12:38:15 -08:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Nathan Hawes
cf60b2fe61 [CodeCompletion] Pass the CodeCompletionExpr rather than just the base expression to the DotExpr completion callback. 2020-08-28 22:24:22 -07:00
Rintaro Ishizaki
67e88f4f26 [SourceKit] Disable labeled trailing closure support except code completion
Don't insert CodeCompletionExpr at the cursor position in
"conforming method list" or "typecontext" mode. This increase the chance
of successful type checking.

rdar://problem/63781922
2020-06-09 13:02:03 -07:00
Rintaro Ishizaki
1cbb1e76d4 [CodeCompletion] Update for braceless multiple trailing closure 2020-05-06 01:56:41 -04:00
Rintaro Ishizaki
0f1cffd2d2 [CodeCompletion] Completion for control trasfer target
Completion after 'break' and 'continue'

rdar://problem/57016218
2020-04-17 14:18:33 -07:00
Rintaro Ishizaki
e5cdbb7fab [CodeCompletion] completeGenericRequirement to use the decl context
instead of the parsed type name for the extension.
Preparation for generalize this to other 'where' clause (e.g. functions)
2020-02-26 09:57:17 -08:00
Rintaro Ishizaki
5cf88a15cf [CodeCompletion] Rename GenericParam kind to GenericRequiremnt
NFC
2020-02-26 09:57:17 -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
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03: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
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
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
Rintaro Ishizaki
257b61744e [CodeCompletion] Eliminate super related completion
In parser, 'parseExprPostfixSuffix()' can parse postfix expression for
'super'. 'parseExprSuper()' doesn't need to parse them.

In code-completion, 'completeExprSuper()' and 'completeExprSuperDot()'
can be consolidated to 'completePostfixExpr()' and 'completeDotExpr()'.
2019-06-26 09:59:47 -07:00
Rintaro Ishizaki
35f8686574 [CodeCompletion] Remove getTypeContextEnumElementCompletions()
Use getUnresolvedmemberCompletion() instead.

rdar://problem/45219937
2019-06-25 11:58:12 -07:00
Rintaro Ishizaki
588d87b90e [CodeCompletion] Remove completeCaseStmtDotPrefix() completion
Now that, normal dot-member completion works at case position. We don't
need to handle it specially.

rdar://problem/45219937
2019-06-25 11:18:14 -07:00
Rintaro Ishizaki
09ca68e485 [CodeCompletion] Don't attach attr to decl if blank line exists
```
@#^COMPLETE^#

public func something() {}
```
In this case, we can't say the user is adding attribute to the func or
starting a new declaration. So if there're one or more blank lines after the
completion, suggest context free attribute list.

rdar://problem/50441643
2019-06-20 17:06:32 -07:00
Rintaro Ishizaki
04ca9752cf [CodeCompletion] Enable type name completion for param decl attribute
rdar://problem/50074177
2019-06-11 17:34:45 -07:00
Rintaro Ishizaki
9ba232d718 [CodeCompletion] Implement completion at custom attribute argument 2019-05-31 11:09:54 -07:00
Rintaro Ishizaki
878c9c600b [CodeCompletion] Enable type completion at beginning of attribute
for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
2019-05-31 09:44:19 -07:00
Rintaro Ishizaki
5b5d342995 [CodeCompletion] Enable call signature completion for unresolved member
rdar://problem/50696432
2019-05-15 17:31:19 -07:00
Ben Langmuir
81ce653bc3 Merge pull request #23587 from benlangmuir/cc-omit-return
[code-completion] Add type context for single-expression function bodies
2019-04-25 13:49:45 -07:00
Rintaro Ishizaki
7078862921 [CodeCompletion] Provide 'some' keyword where applicable
rdar://problem/49353647
2019-04-19 17:11:16 -07:00
Ben Langmuir
e255bac6be [code-completion] Fix type context for single-expression implicit getter
This adds an implicit body so that we can dig out the return type
context the same way as a normal function. For now, we are also treating
the first expression in a multi-statement implicit getter body the same
way; we'll need to refactor how we complete in accessors to
differentiate those cases.
2019-03-26 16:45:32 -07:00
Ben Langmuir
f5a216fc04 Merge pull request #23411 from benlangmuir/cc-1-close
[code-completion] Add type context for single-expression closures
2019-03-20 06:56:49 -07:00
Ben Langmuir
b817cbb9bc [code-completion] Add type context for single-expression closures
When completing in the only expression of closure, use the return type
of the closure as the type context for the code-completion. However,
since code-completion may be on an incomplete input, we only use the
return type to improve the quality of the result, not to mark it
invalid, since (a) we may add another statement afterwards, or (b) if
the context type is Void it doesn't need to match the value.
2019-03-18 17:04:33 -07:00
Rintaro Ishizaki
fd542e267c [CodeCompletion] 'case' keyword completion at the top of 'switch' stmt
rdar://problem/35943849
2019-03-18 16:58:52 -07:00
fischertony
86d9d7a6b5 Fix override completions when a valid introducer is present but the override keyword is not. 2019-02-16 16:02:22 +03:00
Rintaro Ishizaki
7837130ae1 [IDE] Give default implementation for completion callbacks 2019-02-08 14:09:00 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Rintaro Ishizaki
90fe0a7e86 [CodeCompletion] Implement completion for 'get', 'set', 'willSet', 'didSet'
Implement 'get', 'set', 'willSet', 'didSet' completion at the beginning
of accessor position.

  var value: Ty {
    <HERE> // 'get', 'set', 'willSet' and 'didSet' along with normal
           // completion.
  }

  var value: Ty {
    get { return ... }
    <HERE> // 'get', 'set', 'willSet' and 'didSet' only.
  }

rdar://problem/20957182
2018-10-19 14:28:56 +09:00
Anthony Latsis
f2ff87e652 Merge branch 'master' into code-compl-precedencegroups 2018-10-09 18:08:16 +03:00
Rintaro Ishizaki
3d80635cf4 [CodeCompletion] Fix completion for local decls in trailing closure
Previously, local decls in trailing closure didn't show up if the
closure had preceding arguments and the completion was triggered at
beginning position of expression context. like:

   funcName(x: arg1) {
      var localVar = 12
      if <HERE>
   }

The completion mode used to be overwritten in 'completeCallArg()' which
is called from 'parseExprCallSuffix(). We should detect completion for
immediate argument position in 'parseExprList()'.

rdar://problem/41869885
2018-10-04 16:56:07 +09:00
fischertony
e505d417fa [Parse][CodeCompletion] Completions for precedencegroup decls
Added the 'Module::getPrecedenceGroups' API to separate precedence group lookup
from 'Module::lookupVisibleDecls', which together with 'FileUnit::lookupVisibleDecls',
to which the former is forwarded, are expected to look up only 'ValueDecl'. In particular, this
prevents completions like Module.PrecedenceGroup.
2018-10-03 22:12:20 +03:00
Rintaro Ishizaki
4797a7caf6 Merge pull request #18919 from rintaro/ide-complete-pound
[CodeCompletion] Implement completion for # directives
2018-08-31 10:50:40 +09:00
Rintaro Ishizaki
deb4aa84e0 [CodeCompletion] Add completion for platform condition
* 'true'/'false' keyword
* 'os(<name>)', 'canImport(<module>)' etc.
* Custom flags specified with '-D'

rdar://problem/19572779
2018-08-24 12:24:54 +09:00
Rintaro Ishizaki
5ef5f5ed84 [CodeCompletion] Implement completion for # directives
rdar://problem/29976235
2018-08-24 12:24:54 +09:00
Rintaro Ishizaki
bce3326840 [CodeCompletion] Rename completeAfterPound() to completeAfterPoundExpr()
Also, `CompletionKind::AfterPound` to `CompletionKind::AfterPoundExpr`.
2018-08-24 11:12:48 +09:00
Rintaro Ishizaki
2052d4bc83 [CodeCompleiton] Enable after '#' completion in arbitrary expr position
Previously, it's enabled only at stmt condition position.
2018-08-24 11:12:48 +09:00
Rintaro Ishizaki
8467203b9e [CodeCompletion][NFC] Tweak completion for ObjC keyPath expression
* Consolidate CompletionKind::KeyPathExpr and CompletionKind::KeyPathExprDot
  to CompletionKind::KeyPathExprObjC
* Make completeKeyPath() to receive DotLoc.
2018-08-22 11:08:53 +09:00
Rintaro Ishizaki
aac92da252 [CodeCompletion] Completion for UnresolvedMember via CodeCompletionExpr
Using dummy UnresolvedMemberExpr doesn't give us much benefit. Instead, use
CodeCompletionExpr which is type checked as type variable so can use
CodeCompletionTypeContextAnalyzer to infer context types.
This way, we can eliminate most of special logic for UnresolvedMember.

rdar://problem/39098974
2018-08-10 22:23:23 +09:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
Ben Langmuir
b394e35fdd [codecomplete] Add completion of if after else
At some point we stopped completing keywords after `else` in an if
statement. Bring back the completion of `if`, which is the only valid
continuation other than a brace.

rdar://37467474
2018-07-10 11:45:10 -07:00
Rintaro Ishizaki
574d39bcb6 [Parse] Split ParserPosition declaration to dedicated header file 2017-12-09 13:58:50 +09:00
Rintaro Ishizaki
07957070cd [CodeComplete] Remove C-style-for specific facilities 2017-08-04 23:25:26 +09:00
Ben Langmuir
534c0cc2cb [code-completion] Generic where clauses
Complete generic parameters and their members inside generic where
clauses on structs, classes, enums, extensions, typealiases, funcs,
subscripts and inits.

Still not handled correctly are associatedtypes.

rdar://problem/20582394
2017-07-31 09:57:00 -07:00
Ben Langmuir
93d22c9ff0 [code-completion] Add a new custom completion context for a for-each sequence
For normal completions it behaves the same as PostfixExprBeginning, but
it provides a hook for clients to provide a custom completion for this
position.  For example, you might want to a x ..< y snippet in this
position.

rdar://problem/29910383
2017-07-19 13:29:36 -07:00