Commit Graph

1359 Commits

Author SHA1 Message Date
Dmitri Hrybenko
7b5e0db0f1 Simplify code and fix a bug: we can have computed properties in an extension
Swift SVN r9637
2013-10-24 04:47:35 +00:00
Argyrios Kyrtzidis
881e646632 [IDE] Introduce CodeCompletionDeclKind enum to encapsulate a bit more info than the DeclKind (e.g. whether the function is an instance/static method).
Swift SVN r9635
2013-10-24 04:33:51 +00:00
Dmitri Hrybenko
8d8b60f973 Code completion: implement result caching per-imported module across muptiple
ASTContexts

This introduces swift::ide::CodeCompletionCache, which is a persistent code
completion result cache.

Right now REPL happens to use it (try importing Cocoa and doing code
completion), and the difference is noticeable.  But completion in REPL is
still slow, because Cocoa goes through the AST Verifier on every completion
(for unknown reasons).

This commit does not implement cache invalidation yet, and it does not use
libcache to evict cache entries under memory pressure.

This commit also introduces two regressions:
- We get fewer Cocoa results that expected.  Module::isModuleVisible in Clang
does not incorrectly reports that that ObjectiveC.NSObject submodule is not
visible from Cocoa.

- We are not implementing the decl hiding rules correctly.  We used to rely on
visible decl lookup to do it for us, but now we have a different data structure
we have real decls from the current module and we have a text-only cache, so we
are forced to reimplement this part of name lookup in code completion.


Swift SVN r9633
2013-10-24 02:13:34 +00:00
Dmitri Hrybenko
c495dafeb0 Code completion: assign "OtherModule" semantic context to Axle results
From user's point of view, these completions refer to types from the standard
library.


Swift SVN r9582
2013-10-22 08:08:18 +00:00
Dmitri Hrybenko
238d898a0d Code completion for enums: model completion in switch case as a separate kind
of completion.  This approach (rather than SourceLoc tricks) better reflects
the intent and allows us to fix the rest of testcases.


Swift SVN r9557
2013-10-21 20:58:23 +00:00
Dmitri Hrybenko
63c264446d Code completion for enums: complete "switch e { case .#^A^#"
Swift SVN r9551
2013-10-21 18:53:31 +00:00
Dmitri Hrybenko
0bf1e89fb1 Code completion: remove debug output, it is not useful
Swift SVN r9522
2013-10-20 06:18:24 +00:00
Dmitri Hrybenko
4ce90a83a9 Code completion: move result builder to a private header
Swift SVN r9485
2013-10-18 18:13:23 +00:00
Dmitri Hrybenko
4e29c56cdd Code completion: don't copy static strings into a separate allocator
Swift SVN r9484
2013-10-18 18:04:41 +00:00
Dmitri Hrybenko
ae03a13d54 Code completion: complete tuple memebrs
Swift SVN r9483
2013-10-18 17:49:34 +00:00
Dmitri Hrybenko
a3bf2b477f Code completion: basic completion for qualified references to enum elements
Swift SVN r9453
2013-10-17 18:35:40 +00:00
Dmitri Hrybenko
de6a0a0f8c Code completion: complete references to enum elements in switch statements when
we have enough type context to find the correct enum


Swift SVN r9439
2013-10-17 02:09:49 +00:00
Dmitri Hrybenko
2415cd9028 Code completion: rename a variable for consistency with AST node name
Swift SVN r9425
2013-10-16 22:28:26 +00:00
Dmitri Hrybenko
278cbad8a4 Code completion: don't produce any results in enum case. Only integer literals
are allowed in that context.


Swift SVN r9383
2013-10-15 22:45:54 +00:00
Dmitri Hrybenko
0f93a9277d Code completion: complete '!' and '?' on Optional<T>
rdar://14848266


Swift SVN r9377
2013-10-15 21:36:42 +00:00
Dmitri Hrybenko
46a4bc1402 Code completion: preserve the AST for the parsed top-level code. This enables
us to find iteration variables while doing code completion in nested top-level
code.

Fixes part of rdar://15199468


Swift SVN r9343
2013-10-15 01:24:16 +00:00
Dmitri Hrybenko
1f47c79b71 Remove a fixed FIXME
Swift SVN r9332
2013-10-14 22:55:54 +00:00
Dmitri Hrybenko
af4ad7e9b7 Code completion: assign a special semantic context for iteration variables
in a C-style for loop


Swift SVN r9111
2013-10-09 23:32:59 +00:00
Doug Gregor
9f7325a6a2 Axle: add code completions for Vec<type, length> and Matrix<type, rows, cols>
Swift SVN r9110
2013-10-09 23:27:16 +00:00
Doug Gregor
f7b84d4f41 Code completion: add chunks for <, >, and generic parameters.
Swift SVN r9107
2013-10-09 23:11:42 +00:00
Dmitri Hrybenko
a5814865cb Code completion: assign a special semantic context for calling overridden decls
through 'super'


Swift SVN r9094
2013-10-09 21:49:30 +00:00
Dmitri Hrybenko
6895c34741 Code completion: report "semantic context" for every code completion result
Semantic context describes the origin of the declaration and serves the same
purpose as opaque numeric "priority" in Clang -- to determine the most likely
completion.

This is the initial implementation.  There are a few opportunities to bump the
priority of a certain decl by giving it SemanticContextKind::ExprSpecific
context that are not implemented yet.


Swift SVN r9052
2013-10-09 02:08:05 +00:00
Jordan Rose
9d3720c8e2 Excise TranslationUnit from some parts of code completion and type checking.
In most cases an ASTContext and/or DeclContext is good enough.

Swift SVN r9013
2013-10-08 00:48:56 +00:00
Dmitri Hrybenko
7f6a183bf0 Code completion: [really] type check all decl contexts of the completion point, not just the nearest one
Swift SVN r9010
2013-10-08 00:39:04 +00:00
Dmitri Hrybenko
9ca8498bc5 Code completion: type check all decl contexts of the completion point, not just the nearest one
Fixes some of the crashes with nested nominal type decls.


Swift SVN r9008
2013-10-08 00:15:46 +00:00
Jordan Rose
c2b00fc2d4 Excise the global TranslationUnit from TypeChecker.
Now that TypeChecker is being used to check all sorts of things (not all
from a single TU), it's not really correct to have a single top-level TU
that gets used everywhere. Instead, we should be using the TU that's
appropriate for whatever's being checked. This is a small correctness win
for order-independent type-checking, but is critical for multi-file
translation units, which is needed for implicit visibility.

This basically involves passing around DeclContexts much more.

Caveat: we aren't smart about, say, filtering extensions based on the
current context, so we're still not 100% correct here.

Swift SVN r9006
2013-10-07 23:47:55 +00:00
Dmitri Hrybenko
fcdf862611 Code completion: use a helper function to add type annotations -- it does getString() for us
Swift SVN r8989
2013-10-07 21:09:05 +00:00
Dmitri Hrybenko
849ea3318d When constructing a CodeCompletionString, compute the required memory chunk
size correctly


Swift SVN r8973
2013-10-07 18:28:59 +00:00
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