Commit Graph

3985 Commits

Author SHA1 Message Date
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
Sonny Falk
4d895eb464 Some code formatting fixes.
Swift SVN r7630
2013-08-27 21:28:49 +00:00
Sonny Falk
0f1a58c0ee Add support for skipping / displacing SyntaxNode tokens, so that we can effectively replace Identifier nodes with TypeId nodes.
Reenable SyntaxNodeKind::Identifier.



Swift SVN r7629
2013-08-27 21:20:17 +00:00
Sonny Falk
feed0097b2 Remove the code to emit SyntaxNodeKind::Identifier to pass the tests.
We need to support turning identifer nodes into potential type identifiers before we can enable identifer nodes again.



Swift SVN r7619
2013-08-27 01:30:57 +00:00
Sonny Falk
417a162f2c Rename enum class SyntaxColor to SyntaxNodeKind, since this represents more than color.
Set the size for SyntaxNodeKind to uint_8_t, since we're packing it together with length in a 32-bit value in SourceKit.
Add SyntaxNodeKind::Identifier.



Swift SVN r7609
2013-08-26 23:49:03 +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
Argyrios Kyrtzidis
0d7fc0aa1d [ide] Use the newly introduce CharSourceRange inside ide::SyntaxNode.
Swift SVN r7174
2013-08-12 20:58:20 +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
db08a32a95 Factor out SourceManager::getLocOffsetInBuffer()
and remove some abuse of SourceLoc::Value::getPointer()


Swift SVN r7105
2013-08-09 21:53:32 +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
686f9ec7fc SourceManager: add functions that compare SourceLocs and SourceRanges
Swift SVN r6994
2013-08-07 20:06:12 +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
Argyrios Kyrtzidis
4e297d044b Move tokenization of interpolated strings in swift::tokenize().
Swift SVN r6941
2013-08-06 14:59:02 +00:00
Argyrios Kyrtzidis
d6b048dfe0 [Lexer] Refactor lexing of interpolated strings.
Decouple splitting an interpolated string to segments, from encoding the string segments.
This allows us to tokenize or re-lex a string literal without having to allocate memory for
encoding the string segments when we don't need them encoded.

Swift SVN r6940
2013-08-06 14:59:01 +00:00
Argyrios Kyrtzidis
7c9831df88 [IDE] Handle string interpolation for syntax-coloring.
Swift SVN r6894
2013-08-05 15:21:58 +00:00
Argyrios Kyrtzidis
885c9ce119 [IDE] Highlight type identifiers.
Swift SVN r6862
2013-08-02 22:44:59 +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
Dmitri Hrybenko
a9701602c4 Fix indentation
Swift SVN r6843
2013-08-02 17:31:03 +00:00
Argyrios Kyrtzidis
49389348ac [IDE] Introduce the "syntax-coloring" action.
Swift SVN r6837
2013-08-02 02:50:32 +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
34cbef8385 REPL code completion: unbreak REPL completion after r6818 and finally add tests
(now we can test it!) so that I don't break it again.


Swift SVN r6828
2013-08-02 00:24:32 +00:00
Dmitri Hrybenko
5cea4ebf41 Code completion: put CodeCompletionOffset on SourceManager instead of passing
around everywhere

Fixes:
rdar://14585108 Code completion does not work at the beginning of the file
rdar://14592634 Code completion returns zero results at EOF in a function
                without a closing brace


Swift SVN r6820
2013-08-01 22:08:58 +00:00
Dmitri Hrybenko
e1c4ae3174 Wrap llvm::SourceMgr in swift::SourceManager so that we can add new members
to the source manager.


Swift SVN r6815
2013-08-01 20:39:22 +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