Commit Graph

894 Commits

Author SHA1 Message Date
Dmitri Hrybenko
8a7628d795 Code completion: fix a bug where code completing in a function body on the next
line after a var decl with initializer would complete based on the initializer
expression.

These are technically valid completions, but confusing.  Now this suggests
unqualified completions.


Swift SVN r7188
2013-08-13 02:25:00 +00:00
Dmitri Hrybenko
21dafe110c Code completion: if the postfix expression is located on a different line than
the code completion token, then the expression is irrelevant from the user's
point of view.


Swift SVN r7125
2013-08-10 02:55:33 +00:00
Dmitri Hrybenko
8d75dccc84 Code completion: implement partial typechecking of function bodies
This allows us to complete members of local variables and members of
expressions that include local variables.


Swift SVN r7033
2013-08-08 00:59:46 +00:00
Dmitri Hrybenko
2bbef342f0 Code completion: refactor code completion callbacks so that actual name lookups
happen after delayed parsing is finished.  This ensures that the AST for
delayed parsed code (for example, function body) is constructed.  This is
required for partial type checking of function bodies.


Swift SVN r7010
2013-08-07 22:42:36 +00:00
Dmitri Hrybenko
a6519a907d Code completion: implement code completion for dot member access on clang modules
Because we don't want FooModule.#^A^# to show completion results for other
clang modules, global completion cache was replaced with a per-module cache.


Swift SVN r6951
2013-08-06 21:15:23 +00:00
Dmitri Hrybenko
773227d90a Code completion: add results for __FILE__, __LINE__, __COLUMN__
Swift SVN r6859
2013-08-02 22:08:53 +00:00
Dmitri Hrybenko
947354ac5b Code completion: in '.metatype' completions, strip LValueType before
constructing the MetaTypeType.  LValueness of the expression does not matter
for the metatype type.  (And it also makes the type annotations very long in
many cases.)


Swift SVN r6857
2013-08-02 21:50:53 +00:00
Argyrios Kyrtzidis
7e81b4919a [IDE] Rename "code_completion" namespace to "ide"
Swift SVN r6834
2013-08-02 02:50:28 +00:00
Dmitri Hrybenko
bea606fc4b CodeCompletionString: replace CallParameter*Annotation chunks with an
"IsAnnotation" flag on the Chunk.  This flag is also set on the TypeAnnotation
chunk.

This revised design makes it easy for the client to find out if a particular
chunk should be inserted into the editor buffer or not.


Swift SVN r6809
2013-08-01 18:08:34 +00:00
Dmitri Hrybenko
2dc2182e61 Code completion: add an API to sort code completion results and use it in REPL
Swift SVN r6780
2013-07-31 20:52:11 +00:00
Dmitri Hrybenko
001cbb1808 Code completion: handle ParenPatterns in function parameters when completing
a function call


Swift SVN r6749
2013-07-30 20:48:07 +00:00
Dmitri Hrybenko
647dff9caf Code completion: don't add results that reference operators with function call
syntax when we complete after module name


Swift SVN r6731
2013-07-30 00:53:12 +00:00
Dmitri Hrybenko
f9fa6aa8fc Code completion: insert a zero character into the buffer to mark the code
completion token

This is required to handle cases like fooObject.#^A^#.bar where code completion
is invoked inside the ".." token.  Previously, the token would not be split and
the lexer would produce an incorrect tokenization for this case.  Now we
produce ".", tok::code_complete, ".".


Swift SVN r6635
2013-07-26 00:45:57 +00:00
Dmitri Hrybenko
96b0f31ae7 removeCodeCompletionTokens(): return a 0-based offset of the code completion token
Documentation comment says that it should return a 0-based offset, but it
actually returns a 1-based offest.

Code completion tests did not catch this bug because the only consequence is
that the code completion token is shifted one character to the right, and in
all code completion tests we had a space after the code completion token.


Swift SVN r6566
2013-07-24 22:30:24 +00:00
Dmitri Hrybenko
dcd26e8a1f Code completion: implement completion of imported Clang declarations by first
importing them

Because going through the import for every code completion request is slow,
Clang code completion results are cached in the CodeCompletionContext.  The
cache needs to be invalidated whenever a new Clang module is loaded.  In order
to implement this, ModuleLoadListener class was added.


Swift SVN r6505
2013-07-23 18:12:58 +00:00
Dmitri Hrybenko
909352879a Code completion: recognize and print the correct signature for implicitly
curried functions


Swift SVN r6470
2013-07-22 21:18:09 +00:00
Dmitri Hrybenko
bc67a82be8 lookupVisibleDecls(): use correct abstractions of lookup kinds
Removes the boolean IsTypeLookup and OnlyInstanceMembers, which were totally
misleading.

This fixes some bugs in lookupVisibleDecls, which allows us to remove
workarounds in code completion, that were not correct in some corner cases.

Now we also code complete references to instance functions in static contexts,
but code completion results in this case state the type of the resulting object
incorrectly.


Swift SVN r6396
2013-07-19 23:42:54 +00:00
Dmitri Hrybenko
bac0d84e2a Code completion: don't include instance variables and instance functions in
code completion results inside static functions

Referencing an instance function from a static function is allowed by the
language, but the compiler crashes on this right now.  (rdar://14432081)


Swift SVN r6390
2013-07-19 21:19:15 +00:00
Dmitri Hrybenko
0fc469e80a lookupVisibleDecls(): now we don't find references to generic types outside of
the containing DeclContext

Fixes a few FIXMEs in code completion where we were providing results that
refer to generic arguments outside of their scope.


Swift SVN r6370
2013-07-19 01:46:30 +00:00
Dmitri Hrybenko
e4b44a6bbb Add a 'current module' parameter to lookupVisibleDecls() so that it can do what
is documented: look up members of a type that are visible from a specific
module.  It does not matter much now, but when we have access control, it will.

Before this change, lookupVisibleDecls() tried to guess the *defining* module
of the type, and gave up if it could not.  It forced us to duplicate some
lookup logic for some types (archetypes and protocol compositions).  Also add a
test that lookup finds members of archetype's superclass, which the original
(duplicated) code did not handle.


Swift SVN r6363
2013-07-18 23:32:16 +00:00
Dmitri Hrybenko
be7d4ae71d Code completion: fix a few crashes while code completing expressions that have
generic parameter lists


Swift SVN r6349
2013-07-18 18:37:58 +00:00
Dmitri Hrybenko
c22ac1dc06 lookupVisibleDecls() should operate on a canonical type so that it does not
need to unwrap the type sugar.

This was uncovered by the removal of IdentifierType and removal of
getCanonicalType() in code completion, which was working around
lookupVisibleDecls() not working for IdentifierTypes.


Swift SVN r6332
2013-07-17 18:28:52 +00:00
Dmitri Hrybenko
90889c391e Handle ParenPattern in function arguments
It seems strange, but 'func f(_ : Int)' has a ParenPattern for its arguments,
but 'func f(a : Int)' has a TuplePattern.


Swift SVN r6311
2013-07-17 00:25:22 +00:00
Dmitri Hrybenko
858ce26b2b Code complete expressions that type check to ArchetypeTypes
This required fixing a bug in lookupVisibleDecls(), which did not return any
results for ArchetypeTypes.


Swift SVN r6310
2013-07-16 23:49:25 +00:00
Dmitri Hrybenko
6aa7b63900 Remove unintended fallthrough in CompletionLookup::foundDecl
Swift SVN r6289
2013-07-16 17:03:51 +00:00
Dmitri Hrybenko
bed619073c Code completion: produce results that refer to TypeAliasDecls
Swift SVN r6287
2013-07-16 02:04:37 +00:00
Dmitri Hrybenko
7823c53956 Code completion: produce results that refer to NominalTypeDecls from
expr-postfix that can be resolved


Swift SVN r6282
2013-07-16 01:44:21 +00:00
Dmitri Hrybenko
b8babd448e Code completion: produce completion results which refer to NominalTypeDecls
Swift SVN r6279
2013-07-16 01:29:49 +00:00
Dmitri Hrybenko
e650f2f8fc Implement basic code completion at the beginning of the expr-postfix
We produce only names that are found by name lookup, no keywords or types yet.


Swift SVN r6276
2013-07-16 00:49:08 +00:00
Dmitri Hrybenko
189ffc49a5 Code completion: don't crash on functions with selector-style arguments
Swift SVN r6269
2013-07-15 20:11:22 +00:00
Dmitri Hrybenko
6a0c6f4879 Code completion: use 'Void' instead of '()' in type annotations
Swift SVN r6265
2013-07-15 18:28:51 +00:00
Dmitri Hrybenko
98aaf3bb45 Add code completion for expr-super: 'super#^A^#' and 'super.#^A^#'
Swift SVN r6264
2013-07-15 18:11:48 +00:00
Dmitri Hrybenko
f19de086ca Add code completion results for expressions that have function types
Fixes rdar://14431044


Swift SVN r6229
2013-07-12 23:42:15 +00:00
Dmitri Hrybenko
e89b90e797 Produce correct type annotations for '.metatype' completion strings
Swift SVN r6217
2013-07-12 22:07:03 +00:00
Dmitri Hrybenko
7b93a74a7e Code completion: add type annotations to ".metatype" completion strings
Swift SVN r6216
2013-07-12 21:17:25 +00:00
Dmitri Hrybenko
034c9e370c dump() output should go to errs(). Thanks, Jordan!
Swift SVN r6215
2013-07-12 21:07:16 +00:00
Dmitri Hrybenko
c80697e411 Add FIXMEs to code completion code.
Swift SVN r6214
2013-07-12 21:04:47 +00:00
Dmitri Hrybenko
bdf8768522 Don't track prefix while doing a code completion lookup.
Swift SVN r6213
2013-07-12 20:55:09 +00:00
Dmitri Hrybenko
f28d4a081a Refactor CodeCompletionString and CodeCompletionResult stringification
functions to use raw_ostream like the rest of clang and swift.  Also add a
comment that these functions are intended for debugging only.


Swift SVN r6212
2013-07-12 20:50:26 +00:00
Dmitri Hrybenko
3a7f5dfd94 Don't add SubscriptDecls to code completion results for a metatype base expression.
Swift SVN r6207
2013-07-12 18:40:19 +00:00
Dmitri Hrybenko
9b3ce25c17 Add code completion for constructors
Swift SVN r6203
2013-07-12 18:34:25 +00:00
Dmitri Hrybenko
c4f33c89a8 Add code completion for subscript operators
Swift SVN r6202
2013-07-12 18:03:15 +00:00
Dmitri Hrybenko
02084efab7 Implement code completion for some function calls and member variable accesses
in expr-dot and expr-postfix that can be typechecked without typechecking the
beginning of the function body.


Swift SVN r6198
2013-07-12 02:00:41 +00:00
Dmitri Hrybenko
3c5b12fc0f Code completion: add a lot of infrastructure code
* Added a mode in swift-ide-test to test code completion.  Unlike c-index-test,
  the code completion token in tests is a real token -- we don't need to
  count lines and columns anymore.

* Added support in lexer to produce a code completion token.

* Added a parser interface to code completion.  It is passed down from the
  libFrontend to the parser, but its functions are not called yet.

* Added a sketch of the interface of code completion consumer and code
  completion results.

Note: all this is not doing anything useful yet.


Swift SVN r6128
2013-07-10 20:53:40 +00:00