Commit Graph

1359 Commits

Author SHA1 Message Date
Dmitri Hrybenko
1e23c936e0 Rename FuncDecl::getBody() to FuncDecl::getFuncExpr()
ConstructorDecl::getBody() and DestructorDecl::getBody() return 'BraceStmt *'.
After changing the AST representation for functions, FuncDecl::getBody() will
return 'BraceStmt *' and FuncDecl::getFuncExpr() will be gone.


Swift SVN r8050
2013-09-09 19:57:27 +00:00
Dmitri Hrybenko
dfec888b1c Parser: build AST for 'for <expr>; {}' and improve partial type checking of
function bodies

Allows us to fix a few FIXMEs in code completion.


Swift SVN r7883
2013-09-04 00:23:20 +00:00
Dmitri Hrybenko
d3d16755cf Simplify handling of ErrorType
The typechecker is not creating (LValueType (ErrorType)) anymore.


Swift SVN r7703
2013-08-28 23:57:48 +00:00
Dmitri Hrybenko
69cfa73640 More 'this' -> 'self' replacements
Swift SVN r7657
2013-08-28 02:57:21 +00:00
Dmitri Hrybenko
3ef60c577e Code completion: eat the code completion token where we handle it
This ensures that we parse the next statement we don't see the code completion
token.

Allows to remove an ugly workaround in the code completion engine.


Swift SVN r7598
2013-08-26 22:36:51 +00:00
Dmitri Hrybenko
0cf6ba54fb Code completion: complete types in the struct inheritance clause
Swift SVN r7534
2013-08-23 22:13:35 +00:00
Dmitri Hrybenko
b91b4b61e1 Code completion: complete type-ident without dot, for example Foo#^A^#
Swift SVN r7499
2013-08-23 01:30:04 +00:00
Dmitri Hrybenko
fec5c851d0 Code completion: complete types in protocol compositions
Swift SVN r7495
2013-08-23 00:30:32 +00:00
Doug Gregor
1ddb34fb71 Factor generic parameters and associated types into their own decl nodes.
Previously, TypeAliasDecl was used for typealiases, generic
parameters, and assocaited types, which is hideous and the source of
much confusion. Factor the latter two out into their own decl nodes,
with a common abstract base for "type parameters", and push these
nodes throughout the frontend.

No real functionality change, but this is a step toward uniquing
polymorphic types, among other things.


Swift SVN r7345
2013-08-19 23:36:58 +00:00
Dmitri Hrybenko
cdb1df51a3 Code completion: completion of type-ident in type contexts (like Foo.#^A^#)
This introduces the required code completion callbacks which pass partially
parsed TypeReprs to code completion.  These types can refer to generic function
parameters.  Because we need to typecheck these types, we need to typecheck
generic parameters first.  Because exposing fine-grained typechecker interface
just for code completion is bad, we create a function declaration based on the
limited information we have (i.e., just the function name and generic
parameters) and pass that to the typechecker.  This approach (in theory) should
work uniformly for function decls and nominal type decls, but the nominal type
decl case is not tested yet.  Eventually we will also want to use a similar
approach for normal parser recovery as well.


Swift SVN r7313
2013-08-17 02:35:32 +00:00
Dmitri Hrybenko
2786c30dd8 Code completion: add a parser hook to inform code completion about generic
parameters while parsing the function signature.  Generic parameters are not
accessible at that time through the AST node, because the FuncDecl AST node was
not constructed yet.


Swift SVN r7222
2013-08-14 02:16:55 +00:00
Dmitri Hrybenko
b2a5e2c11a Code completion: complete in type contexts -- basic implementation
Swift SVN r7207
2013-08-13 20:36:48 +00:00
Dmitri Hrybenko
0f6df2dd77 Code completion: rename CompletionLookup::LookupKind::DeclContext to
...::ValueInDeclContext

Code completion in type contexts is coming soon, need to differentiate between
two lookup kinds.


Swift SVN r7205
2013-08-13 18:21:09 +00:00
Dmitri Hrybenko
fa5a82b29d Code completion: rename internal implementation functions from addSwiftZzz() to
addZzz().  The 'Swift' part of the name was added because there was a codepath
for completing swift decls and a different one for completing clang decls.  Now
we complete clang decls by first importing them, so the 'Swift' part of the
name is just redundant.


Swift SVN r7195
2013-08-13 03:53:19 +00:00
Dmitri Hrybenko
66a447adb8 Code completion: code completion on a different line that the expr-postfix:
use the Tok.isAtStartOfLine() check instead of comparing line numbers


Swift SVN r7192
2013-08-13 03:17:54 +00:00
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