Commit Graph

238 Commits

Author SHA1 Message Date
Dmitri Hrybenko
0aeb095416 Code completion: change the spelling of DynamicLookupMethodCallTail chunk to "!"
This is the "!" in method calls on AnyObject:

  var a: AnyObject = get()
  a.doFoo!()

rdar://15233283


Swift SVN r16366
2014-04-15 09:36:50 +00:00
Dmitri Hrybenko
efa2f3b896 Code completion: add brief comments to code completion results
Swift SVN r15059
2014-03-14 17:53:22 +00:00
Dmitri Hrybenko
06be7781f8 Fix code completion for 'inout' by completing '&' in the function argument
Partially addresses rdar://15999689


Swift SVN r14299
2014-02-24 12:48:56 +00:00
Argyrios Kyrtzidis
408cff5dea [IDE] Make CodeCompletionResult::getCodeCompletionDeclKind() public.
Swift SVN r12475
2014-01-17 07:33:50 +00:00
Jordan Rose
be12d86ddd Turn ClangModule into ClangModuleUnit.
Part of the FileUnit restructuring. A Clang module (whether from a framework
or a simple collection of headers) is now imported as a TranslationUnit
containing a single ClangModuleUnit.

One wrinkle in all this is that Swift very much wants to do searches on a
per-module basis, but Clang can only do lookups across the entire
TranslationUnit. Unless and until we get a better way to deal with this,
we're stuck with an inefficiency here. Previously, we used to hack around
this by ignoring the "per-module" bit and only performing one lookup into
all Clang modules, but that's not actually correct with respect to visibility.

Now, we're just taking the filtering hit for looking up a particular name,
and caching the results when we look up everything (for code completion).
This isn't ideal, but it doesn't seem to be costing too much in performance,
at least not right now, and it means we can get visibility correct.

In the future, it might make sense to include a ClangModuleUnit alongside a
SerializedASTFile for adapter modules, rather than having two separate
modules with the same name. I haven't really thought through this yet, though.

Swift SVN r10834
2013-12-05 01:51:11 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +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
Dmitri Hrybenko
a927afa412 Remove unused #includes
Swift SVN r9662
2013-10-24 22:54:34 +00:00
Dmitri Hrybenko
0cafcee4c0 Code completion: add more assertions
Swift SVN r9659
2013-10-24 22:20:05 +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
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
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
0f93a9277d Code completion: complete '!' and '?' on Optional<T>
rdar://14848266


Swift SVN r9377
2013-10-15 21:36:42 +00:00
Doug Gregor
939f24aa12 Code completion: Generic parameter name chunks have text.
Swift SVN r9108
2013-10-09 23:16:41 +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
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
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
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
This was not likely an error-free change.  Where you see problems
please correct them.  This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.

Swift SVN r7631
2013-08-27 21:58:27 +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
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
99b626e8dd Fix indentation
Swift SVN r6844
2013-08-02 17:35:31 +00:00
Argyrios Kyrtzidis
df96177b36 [IDE] Add hasText() convenience method in the code-completion chunk.
Swift SVN r6839
2013-08-02 16:56:02 +00:00
Argyrios Kyrtzidis
cff4cf4e16 [IDE] Add CodeCompletionResult::getKind().
Swift SVN r6835
2013-08-02 02:50:31 +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
72c531b3d5 Make CodeCompletionString::Chunk class a public member of CodeCompletionString
It is used in CodeCompletionString public APIs which happen to be unused
outside libIDE right now.


Swift SVN r6623
2013-07-25 23:34:33 +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
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
f28d4a081a Refactor CodeCompletionString and CodeCompletionResult stringification
functions to use raw_ostream like the rest of clang and swift.  Also add a
comment that these functions are intended for debugging only.


Swift SVN r6212
2013-07-12 20:50:26 +00:00
Dmitri Hrybenko
c4f33c89a8 Add code completion for subscript operators
Swift SVN r6202
2013-07-12 18:03:15 +00:00
Dmitri Hrybenko
02084efab7 Implement code completion for some function calls and member variable accesses
in expr-dot and expr-postfix that can be typechecked without typechecking the
beginning of the function body.


Swift SVN r6198
2013-07-12 02:00:41 +00:00
Dmitri Hrybenko
3c5b12fc0f Code completion: add a lot of infrastructure code
* Added a mode in swift-ide-test to test code completion.  Unlike c-index-test,
  the code completion token in tests is a real token -- we don't need to
  count lines and columns anymore.

* Added support in lexer to produce a code completion token.

* Added a parser interface to code completion.  It is passed down from the
  libFrontend to the parser, but its functions are not called yet.

* Added a sketch of the interface of code completion consumer and code
  completion results.

Note: all this is not doing anything useful yet.


Swift SVN r6128
2013-07-10 20:53:40 +00:00