Commit Graph

1181 Commits

Author SHA1 Message Date
Dmitri Hrybenko
e2b8312797 Code completion: try to substitute generic arguments when completing
a constructor reference


Swift SVN r10820
2013-12-04 23:54:42 +00:00
Dmitri Hrybenko
b3cf7d7a08 Code completion: remove redundant parentheses that were being shown in the
types of the implicitly curried instance functions


Swift SVN r10807
2013-12-04 23:07:18 +00:00
Dmitri Hrybenko
25d0ab2c3a Code completion: substitute generic parameters in references to members of metatypes
Swift SVN r10801
2013-12-04 22:44:00 +00:00
Dmitri Hrybenko
6d3f2f9f45 Code completion: when completing a reference to a variable that comes from a
generic nominal, substitute known generic parameters if possible


Swift SVN r10788
2013-12-04 19:31:00 +00:00
Dmitri Hrybenko
541c04f7af Code completion: switch constructor completion from using argument patterns to
use type of the constructor member


Swift SVN r10787
2013-12-04 18:51:05 +00:00
Dmitri Hrybenko
d076501cca Don't repeat Context.getIdentifier("self") everywhere in the code base
Swift SVN r10786
2013-12-04 18:42:34 +00:00
Dmitri Hrybenko
e974992039 Code completion: when completing a call to a function that comes from a generic
nominal, substitute known generic parameters if possible

This should improve code completion experience for generic containers a lot:

(swift) var a = Array<Float>()
// a : Array<Float> = []
(swift) a.
...
  Decl[InstanceMethod]/CurrNominal:   append({#val: Float#})[#Void#]
...
  Decl[InstanceMethod]/CurrNominal:   each({#f: (Float) -> Void#})[#Void#]
...
  Decl[InstanceMethod]/CurrNominal:   enumerate()[#Array<Float>#]
...
  Decl[InstanceMethod]/CurrNominal:   next()[#Float?#]
...
  Decl[InstanceMethod]/CurrNominal:   sort({#pred: (Float, Float) -> Bool#})[#Void#]
...

Only implemented for functions.  Constructors and subscripts coming soon.


Swift SVN r10774
2013-12-04 02:33:16 +00:00
Dmitri Hrybenko
12c525a4d1 Code completion: add parentheses in all cases when completing enum elements
with payloads


Swift SVN r10773
2013-12-04 02:02:28 +00:00
Dmitri Hrybenko
4d827aa7d5 Replace an unnamed namespace with a static specifier on the function
Swift SVN r10766
2013-12-03 23:39:30 +00:00
Dmitri Hrybenko
47951efcb9 Implement code completion support for static variables
Swift SVN r10487
2013-11-15 01:32:20 +00:00
John McCall
00dad2e89f Thread an isSILType bit through the validateType APIs.
Has no effect... yet.

Swift SVN r9983
2013-11-06 01:56:40 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Dmitri Hrybenko
fb08372e10 Code completion tests: check declaration kind, it is computed with non-trivial logic now
These tests revealed this bug: rdar://15353073


Swift SVN r9800
2013-10-30 18:05:55 +00:00
Argyrios Kyrtzidis
e31c93add3 [AST] The ASTContext parameter in FuncDecl::getResultType() is not really needed.
Swift SVN r9798
2013-10-30 17:09:56 +00:00
Dmitri Hrybenko
a2da6e5f1a Code completion: use imports only from the current SourceFile
Prevents duplicating results and displaying results from modules that are not
imported in this SourceFile.


Swift SVN r9713
2013-10-28 18:31:05 +00:00
Jordan Rose
ec4234bdbc Perform unqualified lookup using the current SourceFile as context.
And, properly treat imports as per-file: when looking up decls through the
TU module, don't pick up every other source file's imports.

This implements our resolution rules:
1. Check the current source file.
2. Check the current module.
3. Check imported modules.

Currently, "import Foo" is treated as a file-private import and
"@reexported import Foo" is treated as a public /and/ module-wide import.
This further suggests that access control is the right tool for re-export
control:

(private) import Foo // current file only
package import Foo   // whole module
public import Foo    // whole world

Swift SVN r9682
2013-10-25 22:21:12 +00:00
Dmitri Hrybenko
a927afa412 Remove unused #includes
Swift SVN r9662
2013-10-24 22:54:34 +00:00
Dmitri Hrybenko
341c4e07a9 Code completion result caching: update result set cost in libcache after we
have created the result set


Swift SVN r9660
2013-10-24 22:20:58 +00:00
Dmitri Hrybenko
0cafcee4c0 Code completion: add more assertions
Swift SVN r9659
2013-10-24 22:20:05 +00:00
Dmitri Hrybenko
045c0b99e3 Code completion result cache: implement cache invalidation
Swift SVN r9656
2013-10-24 21:46:11 +00:00
Dmitri Hrybenko
b7d3a23518 Code completion result cache: use libcache
Swift SVN r9653
2013-10-24 20:59:28 +00:00
Argyrios Kyrtzidis
d64313d169 [IDE] Use a switch to convert to CodeCompletionDeclKind, to make sure we cover every decl kind.
Also add the GenericTypeParam for kind.

Swift SVN r9640
2013-10-24 17:47:26 +00:00
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