Commit Graph

1181 Commits

Author SHA1 Message Date
Dmitri Hrybenko
ec53b6d5c9 Code completion for DynamicLookup: subscripting
Swift SVN r8809
2013-10-01 20:46:45 +00:00
Dmitri Hrybenko
1cdc05f4b4 Code completion for DynamicLookup: use Optional<T> type for properties
Swift SVN r8808
2013-10-01 18:47:05 +00:00
Dmitri Hrybenko
6f4cb05603 Code completion: basic support for completing memebrs of DynamicLookup (id)
Only tested with functions (instance/class functions) declared in swift
classes.  Need more testcases.


Swift SVN r8800
2013-10-01 02:14:25 +00:00
Dmitri Hrybenko
c003b4e23d Code completion: use AST Printer to print patterns
Swift SVN r8796
2013-09-30 23:12:01 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Jordan Rose
15bfc8db2b Don't type-check imported decls unless referenced in the source file.
Instead, pass a LazyResolver down through name lookup, and type-check
things on demand. Most of the churn here is simply passing that extra
LazyResolver parameter through.

This doesn't actually work yet; the later commits will fix this.

Swift SVN r8643
2013-09-25 20:08:14 +00:00
Jordan Rose
6e1ed42c07 s/swift::lookupVisibleDecls/swift::lookupVisibleMemberDecls/g
There were two overloads of lookupVisibleDecls: one that performed
unqualified lookup from a particular decl context, the other performing
qualified lookup into a given type from a particular decl context.
They don't really behave the same, so let's give them different names.

Swift SVN r8641
2013-09-25 20:08:09 +00:00
Dmitri Hrybenko
bd38bc4c06 Code completion: don't show [byref] on 'self'
Of course, in structs 'self' is a reference to the value, but this is so
obvious and natural, that calling out this [byref] in code completion results
every single time adds nothing but syntactic noise.

We still show [byref] in other cases, for example, when we complete references
to user-written function parameters.


Swift SVN r8464
2013-09-19 21:31:33 +00:00
Dmitri Hrybenko
667969602b Code completion: implement completion of types in constructor parameter lists
Swift SVN r8439
2013-09-19 00:56:12 +00:00
Sonny Falk
5dba8fca24 Code Completion: Add case sensitive secondary sort order.
Swift SVN r8414
2013-09-18 19:47:09 +00:00
Dmitri Hrybenko
a813e14b6d Code completion: complete 'super.init' in constructors
Also add tests for completing constructors declared with selector syntax.


Swift SVN r8412
2013-09-18 19:05:39 +00:00
Dmitri Hrybenko
0b69e0e4cd Code completion tests: factor out duplication
Swift SVN r8377
2013-09-18 00:39:45 +00:00
Doug Gregor
90b8b3e499 Constructor selectors always start with 'init'.
Implement the new rules for mapping between selector names and
constructors. The selector for a given constructor is formed by
looking at the names of the constructor parameters:
  * For the first parameter, prepend "init" to the parameter name and
  uppercase the first letter of the parameter name. Append ':' if
  there are > 1 parameters or the parameter has non-empty-tuple type.
  * For the remaining parameters, the name of each parameter followed
  by ':'.

When a parameter doesn't exist, assume that the parameter name is the
empty string.

And, because I failed to commit it separately, support selector-style
declarations of constructor parameters so that we can actually write
constructors nicely, e.g.:

  // selector is initWithFoo:bar:
  constructor withFoo(foo : Foo) bar(bar : Bar) { ... }



Swift SVN r8361
2013-09-17 22:49:05 +00:00
Dmitri Hrybenko
a11f623a47 Code completion: partial type checking of constructor bodies
Swift SVN r8343
2013-09-17 18:45:51 +00:00
Dmitri Hrybenko
07e83ea49c Code completion: basic completion in constructor bodies
Swift SVN r8338
2013-09-17 18:20:26 +00:00
Dmitri Hrybenko
10291e0334 Make AbstractClosureExpr a DeclContext
(remove DeclContext base class from PipeClosureExpr and ImplicitClosureExpr)


Swift SVN r8303
2013-09-16 22:39:12 +00:00
Dmitri Hrybenko
45e654fbaa Make AbstractFunctionDecl a DeclContext
and remove DeclContext base class from FuncDecl, ConstructorDecl and
DestructorDecl

This decreases the number of DeclContexts to 7 and allows us to apply
alignas(8) to DeclContext.


Swift SVN r8186
2013-09-13 03:38:33 +00:00
Dmitri Hrybenko
0d6d9a0ffb Move the DeclContext base class from FuncExpr to FuncDecl
FuncDecl still has a FuncExpr because capture list is stored in FuncExpr
(which is a CapturingExpr).


Swift SVN r8179
2013-09-13 01:40:41 +00:00
Dmitri Hrybenko
7da84fd13d Make FuncExpr, PipeClosureExpr and ClosureExpr DeclContexts on their own.
This is a first step to detach them from CapturingExpr and eventually move them
in the AST class hierarchy.


Swift SVN r8171
2013-09-12 23:58:06 +00:00
Dmitri Hrybenko
c69c79084a Move result typeloc and body result type from FuncExpr to FuncDecl
Swift SVN r8153
2013-09-12 18:40:57 +00:00
Dmitri Hrybenko
5975fb71b2 Use FuncDecl in typeCheckFunctionBody() parameters
Swift SVN r8139
2013-09-12 01:23:21 +00:00
Dmitri Hrybenko
3cc01cf7d6 Introduce AbstractFunctionDecl -- a base class for ConstructorDecl,
DestructorDecl, FuncDecl -- and move some of the common concepts and logic
into it

No functionality change.


Swift SVN r8090
2013-09-11 04:04:01 +00:00
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