Commit Graph

35 Commits

Author SHA1 Message Date
Brian Gesiak
663b92ece9 [AST] Completely replace Module with ModuleDecl
The typedef `swift::Module` was a temporary solution that allowed
`swift::Module` to be renamed to `swift::ModuleDecl` without requiring
every single callsite to be modified.

Modify all the callsites, and get rid of the typedef.
2017-01-08 00:36:08 -05:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01: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
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
Ben Langmuir
c8f7da4de1 [CodeCompletion] Support a narrow case for producing trailing closures directly
This adds a narrow special case in code-completion for control-flow-like
methods such as DispatchQueue().sync that are () -> (), to add a new
completion where the trailing closure is immediately expanded rather
than having to invoke placeholder expansion as a second step.

rdar://problem/26628804
2016-07-01 14:16:57 -07:00
Ben Langmuir
4600b1dd12 [CodeCompletion] Fix incorrect upper bound for assertion
This assertion was bogus if there were fewer results than N.
2016-06-04 18:22:18 -07:00
Ben Langmuir
122350d450 [CodeCompletion] Apply filter rules directly to inner results
... and don't try to filter the extended results.  Once the results are
extended with the common prefix they will not match identifier filter
rules, which will create differences between completions depending on
whether they had a filter text or were a postfix expression.  Also,
allow filtering by name directly on the inner operator name for inner
operators.

rdar://problem/26312235
2016-05-25 12:07:17 -07:00
Ben Langmuir
5615b38040 [CodeCompletion] Show 'return' completion by default when appropriate
Ideally we would have precise completion for all our keywords; for now,
just imporove handling of 'return', which we can do by checking if the
current context is a function/closure/init/subscript/etc.

rdar://problem/26307555
2016-05-24 11:01:22 -07:00
Ben Langmuir
b4ce34aba9 [CodeCompletion] Remove ... and & from function filter names
The filter name of a function should match the spelling of the function
name according to the language except that we don't insert _ for unnamed
parameters because underscores are legal inside identifiers and we don't
want to introduce spurious matches (also, we keep the () on a
parameterless function for disambiguation).

rdar://problem/26118915
2016-05-10 11:13:45 -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
Ben Langmuir
f1ba846c78 [CodeCompletion] Swap the exact-match if one is a better case-sensitive match
Instead of just taking the first one, consider whether there is a better
result because of case-sensitivity.

rdar://problem/25994202
2016-05-03 10:23:12 -07:00
Ben Langmuir
6c2ec9a1b1 [CodeCompletion] Do our best to set NotRecommended on other-module results
These results are cached, so we can't use the type-relation.  Instead we
use a small hack of checking the textual return type for "Void".  This
is obviously not ideal, but it lets us detect the most important cases.

rdar://problem/22810741
2016-03-30 16:57:18 -07: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
968b0491b8 [CodeCompletion] Make Void-returning functions "NotRecommended" in typed context
When we know we're expecting an expression that returns a value, make
the completion "NotRecommended" to deprioritize it.

rdar://problem/22810741
2016-03-29 14:20:25 -07:00
Ben Langmuir
a760b70827 Fixup recent formatting boo boos I've committed
I always think I'll remember to clang-format before pushing, but I don't
always follow through.
2016-03-16 15:58:11 -07:00
Ben Langmuir
4e33d50c7f [CodeCompletion] Bump the priority on keywords in the
experimental code-completion path. Move them right before "other module"
results. This is a bit of a hack. Ideally, we would have a much better
idea which keywords are actually legal/likely in a given context and
could prioritize them even more.  Since today we basically splat in all
the keywords, keep them below the current module results so they don't
overwhelm us.

rdar://problem/25119529
2016-03-16 14:58:35 -07:00
Ben Langmuir
94c23c3e1f [CodeCompletion] Include exact matches even when adding inner results
... in the experimental code-completion path. They seem to be generally
useful as a baseline result still as long as they are guaranteed to be
the first result.

rdar://problem/25177968
2016-03-16 14:21:53 -07:00
Ben Langmuir
cebf51989d [SourceKit] Use ChunkKind::is consistently NFC 2016-03-02 18:21:38 -08: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
Ben Langmuir
5da0906089 [CodeCompletion] Add optional top-N results that precede literals
Experiment with having some locals or nominal members come first, but
only a few so that the literals are still predictably near the top.

Part of rdar://problem/23865118
2016-02-03 16:31:26 -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
f1a8fea9f0 [CodeCompletion] Re-order literal suggestions
Move compound types (almost) to the end, put string just behind int and
fix the order of true/false.

Part of rdar://problem/23865118
2016-02-03 09:05:19 -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
Ben Langmuir
7b3bd75b2a [SourceKit] Omit internal parameters from filter name
The internal parameter names are just there to give an extra hint in the
source text for what the argument is. Consequently, we don't want to
allow filtering to match against them.
2016-01-14 14:37:14 -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
dfcece7960 Use consistent style for comment separators. 2016-01-04 01:41:33 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Ben Langmuir
11444373a5 [CodeCompletion] Don't fuzzy-match on single characters
Use prefix matching on the first character, switch to fuzzy after 2 or
more. With only a single character, we often get silly fuzzy results.
2015-11-06 19:26:48 -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
Argyrios Kyrtzidis
d19e4ae026 [SourceKit] Add license notices to all the source files. 2015-11-05 12:01:14 -08:00
Argyrios Kyrtzidis
8ff6a98a99 [sourcekit] Merge SourceKit into the Swift repo.
The code goes into its own sub-tree under 'tools' but tests go under 'test',
so that running 'check-swift' will also run all the SourceKit tests.

SourceKit is disabled on non-darwin platforms.
2015-11-05 01:09:08 -08:00