Commit Graph

238 Commits

Author SHA1 Message Date
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
814476ad98 [CodeCompletion] Rename CompletionKind::SwiftKeyPath to KeyPathExprSwift 2018-08-22 11:08:53 +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
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
Argyrios Kyrtzidis
18dfb2810a [swift-ide-test] Provide option '-code-completion-comments' for swift-ide-test to print documentation comments for the completion results 2018-01-12 16:09:03 -08: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
Ben Langmuir
0258839815 [code-completion] Add leading-dot completion for enums
When using completion options that will allow the lone "." completion,
provide that result when in contexts that expect an enum type.  Note:
this is a crappy approximationg for whether the type can have "implicit
member expression" syntax, since uninhabited enums should not support
it, and many non-enum types should.  However, it is currently expensive
to compute the accurate answer and this approximation is good enough for
some clients.

rdar://problem/31260505
2017-07-19 11:34:01 -07:00
Xi Ge
e997128129 [CodeCompletion] Provide basic code completion support for Swift KeyPath. rdar://31768743 (#9467) 2017-05-10 21:48:50 -07:00
David Farler
7ee42994c8 Start the Syntax library and optional full token lexing
Add an option to the lexer to go back and get a list of "full"
tokens, which include their leading and trailing trivia, which
we can index into from SourceLocs in the current AST.

This starts the Syntax sublibrary, which will support structured
editing APIs. Some skeleton support and basic implementations are
in place for types and generics in the grammar. Yes, it's slightly
redundant with what we have right now. lib/AST conflates syntax
and semantics in the same place(s); this is a first step in changing
that to separate the two concepts for clarity and also to get closer
to incremental parsing and type-checking. The goal is to eventually
extract all of the syntactic information from lib/AST and change that
to be more of a semantic/symbolic model.

Stub out a Semantics manager. This ought to eventually be used as a hub
for encapsulating lazily computed semantic information for syntax nodes.
For the time being, it can serve as a temporary place for mapping from
Syntax nodes to semantically full lib/AST nodes.

This is still in a molten state - don't get too close, wear appropriate
proximity suits, etc.
2017-02-17 12:57:04 -08:00
Bob Wilson
cf3a0458f2 Merge remote-tracking branch 'origin/master' into master-next 2017-01-10 09:05:23 -08:00
Slava Pestov
8d3516abfa Merge pull request #5871 from jtbandes/open-season
[Diagnostics] handle ‘open’ access control; introduce %error modifier
2017-01-09 00:54:31 -08:00
Bob Wilson
37e7d1c627 Merge remote-tracking branch 'origin/master' into master-next 2017-01-08 17:07:46 -08:00
Jacob Bandes-Storch
32635696bd [Diagnostics] handle ‘open’ access control; introduce %error modifier 2017-01-06 22:48:29 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Bob Wilson
13da3fa8b1 Merge remote-tracking branch 'origin/master' into master-next 2016-12-04 18:16:09 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Bob Wilson
5c4f517824 Checkpoint fixes for llvm r284966 (TimeValue) 2016-10-28 12:09:57 -07:00
Rintaro Ishizaki
81c1edee5d [CodeCompletion] Suffix ": " instead of "=" when completing attribute argument names
In addtion, renamed DeclAttrParamEqual to DeclAttrParamColon.
2016-08-17 02:33:04 +09:00
John McCall
c8c41b385c Implement SE-0077: precedence group declarations.
What I've implemented here deviates from the current proposal text
in the following ways:

- I had to introduce a FunctionArrowPrecedence to capture the parsing
  of -> in expression contexts.

- I found it convenient to continue to model the assignment property
  explicitly.

- The comparison and casting operators have historically been
  non-associative; I have chosen to preserve that, since I don't
  think this proposal intended to change it.

- This uses the precedence group names and higherThan/lowerThan
  as agreed in discussion.
2016-07-26 14:04:57 -07:00
Jordan Rose
aee92ff612 SE-0025: Parsing and basic completion for 'fileprivate'. (#3391)
Right now 'fileprivate' is parsed as an alias for 'private' (or
perhaps vice versa, since the semantics of 'private' haven't changed
yet). This allows us to migrate code to 'fileprivate' without waiting
for the full implementation.
2016-07-07 15:20:41 -07:00
Ben Langmuir
a629d668ac [CodeCompletion] Mark deprecated completions as "not recommended"
If a declaration is marked deprecated (but not unavailable) we want to
mark it as "not recommended" so that users know this probably isn't what
you want. We already do something like this in Clang code completions of
deprecated ObjC declarations.

rdar://problem/26335424
2016-05-23 09:25:30 -07:00
Doug Gregor
814a08a5da [IDE] Code completion for Objective-C #keyPath expressions.
Implement code completion support for Objective-C #keyPath
expressions, using semantic analysis of the partially-typed keypath
argument to provide an appropriate set of results (i.e., just
properties and types).

This implements all of the necessary parts of SE-0062 / SR-1237 /
rdar://problem/25710611, although at some point I'd like to follow it
up with some warnings to help migrate existing string literals to
2016-05-21 22:28:51 -07:00
Ben Langmuir
69967ca45c [CodeCompletion] Identify known operators and force a fixed sort order
In the new code-completion code path, force any known operators to go
through a fixed sort order. To identify operators unambiguously, add a
new BuiltinOperator code-completion kind to handle non-decl operators
(!, ., ?., and =).

rdar://problem/25994246
rdar://problem/23440367
2016-05-03 10:23:13 -07:00
Chris Lattner
2ab38e0660 Merge pull request #1987 from danra/danra-patch-1
Cosmetic fixes (NFC)
2016-03-31 20:45:05 -07:00
danra
6ea2bfcac9 Remove C-style for loop example comment
Remove C-style for loop example from the comment demonstrating the ExpressionSpecific code completion context; C-style have been deprecated and will be removed.
2016-04-01 02:40:49 +03:00
danra
71f354e151 Cosmetic fixes (NFC)
- Minor comment fixes
- Split line longer than 80 chars
- Apply conventional header ifdef guard name convention
2016-03-31 21:45:22 +03:00
Xi Ge
c452f9640f [CodeCompletion] Add a field NotRecommendedReason to code completion result to indicate why an item is not recommended, NFC. rdar://25415947
As implied in rdar://24818863, striking through a module name may be an overkill to suggest the module is redundant to import. We try to
fine-grain not-recommended-reason so that proper UI cue can be adopted in the future.
2016-03-30 16:23:33 -07:00
Ben Langmuir
8f9299cc97 [CodeCompletion] Add assignment to experimental operator completion
When the LHS is an lvalue/assignable tuple and there is no leading
sequence of binary expressions.

It's a bit hacky right now since we don't have a good way to
differentiate general pattern completions from builtin operators.

rdar://problem/23209683
2016-03-02 18:21:37 -08:00
Jordan Rose
66189ffac9 Convert many more classes to use llvm::TrailingObjects.
I only intend to do SIL instructions after this; I'm leaving the runtime alone.
2016-02-09 08:57:19 -08:00
Chris Lattner
8dedfb31e3 Add support for #file/#line, etc according to SE-0028. __FILE__ and friends
are still accepted without deprecation warning as of this patch.
2016-02-04 14:22:22 -08:00
Ben Langmuir
a927dc8a5a [CodeCompletion] Hide literals that don't match the type context in SourceKit
If there is a type context, hide literal suggesetions that don't match
it, unless they are keywords and we have filtered to their names.

Incidentally fix an output buffering issue when combining filtering with
the -raw flag in complete-test.

Part of rdar://problem/23865118
2016-02-03 10:51:07 -08:00
Ben Langmuir
9ae6846ac7 [CodeCompletion] Remove more vestiges of 0.0 literal suggestion
Obviously dead code.
2016-02-03 08:29:20 -08:00
Ben Langmuir
e75402e49e [CodeCompletion] Add image literal similar to color
Part of rdar://problem/23865118
2016-02-03 07:55:07 -08:00
Ben Langmuir
d16e4b0467 [CodeCompletion] Add rudimentary support for configuring allowable completions
On a per-request basis. Allows hiding/showing at multiple granularities
* everything
* module
* API by name
* keywords (by uid or all of them)
* literals (by uid or all of them)

With more specific rules overriding less specific ones (so you can hide
everything and then selectively show certain API for example).

rdar://24170060
2016-01-25 08:45:48 -08:00
practicalswift
a3f857ca7b [gardening] Add "-*- C++ -*-" to header files currently missing it 2016-01-23 11:53:05 +01:00
Xi Ge
0f4e7a5ea5 [CodeCompletion] Add code completion for where clauses. rdar://24245022
When completing at "extension A where #^HERE^#", we suggest the generic params of A to users.
2016-01-19 14:17:15 -08:00
Doug Gregor
38c1de69e4 Reinstate "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit ce7b2bcf09, tweaking
a few validation tests appropriately (1 crasher fixed, two -verify
tests that needed updating).
2016-01-14 00:21:48 -08:00
Erik Eckstein
ce7b2bcf09 Revert "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit 2b2e9dc80e.

It broke some compiler crasher tests
2016-01-13 20:42:58 -08:00
gregomni
2b2e9dc80e [SR-511][Parse] Add 'associatedtype' keyword and fixit
Adds an associatedtype keyword to the parser tokens, and accepts either
typealias or associatedtype to create an AssociatedTypeDecl, warning
that the former is deprecated. The ASTPrinter now emits associatedtype
for AssociatedTypeDecls.

Separated AssociatedType from TypeAlias as two different kinds of
CodeCompletionDeclKinds. This part probably doesn’t turn out to be
absolutely necessary currently, but it is nice cleanup from formerly
specifically glomming the two together.

And then many, many changes to tests. The actual new tests for the fixits
is at the end of Generics/associated_types.swift.
2016-01-13 17:54:31 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
149b50d901 Fix typos in code (non-comment/documentation typos). 2015-12-28 11:42:15 +01:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
practicalswift
c75590d6c5 Fix typo: implementetion → implementation 2015-12-14 00:11:53 +01:00
Xi Ge
22ba61bea1 Reapply "[CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover." after fixing a linux failure. (thanks, Dmitri) 2015-11-09 16:36:25 -08:00
Xi Ge
0a82a6fa41 Revert "[CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover."
This reverts commit 448a23c9af for failing linux bots.
2015-11-06 19:06:45 -08:00
Xi Ge
448a23c9af [CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover.
Similar with @keyword, manifesting @recommended and @recommendedover content in code
completion results can help IDE users to choose the right API in the long candidate list.
This commit extract these two attributes from Clang doc comments and insert/cache them in
code completion results.

rdar://23101030 and rdar://23101029
2015-11-06 18:11:17 -08:00
Xi Ge
c022c9925c [CodeComplete] Start to support keyword-based code completion. rdar://23101032
Conventionally, code completion results are matched with user input solely by
names. However, names are limited in expressiveness. From this comments, we start to
decorate code completion results with @keywords fields extracted from Clang doc comments.
These fields are added by API authors to comment the decl with information that
is not manifested clear enough through names. Code completion users' typing of the
keyword leads to the corresponding code completion results being selected as well.
Keywords can be arbitrarily long and can be multiple.

For instance, a function called "index()" has "@keyword find" in its doc comment.
Users' typing of "find" leads to "index()" being selected in the code completion list.
2015-11-05 15:36:55 -08:00