Commit Graph

1275 Commits

Author SHA1 Message Date
Dmitri Hrybenko
f06d124ef9 Code completion: fix crash on invalid protocol conformance
rdar://16723481


Swift SVN r16815
2014-04-25 09:58:44 +00:00
Dmitri Hrybenko
28c2514589 Remove unused member
Swift SVN r16756
2014-04-24 16:00:32 +00:00
Dmitri Hrybenko
e36baf4123 Code completion: add basic support for completing overriding decls
rdar://16539292


Swift SVN r16755
2014-04-24 15:59:05 +00:00
Argyrios Kyrtzidis
9bd10774b0 [IDE/CodeCompletion] Mark a code-completion result as 'not-recommended' if the declaration
that it refers to is unavailable.

rdar://16675550

Swift SVN r16687
2014-04-23 04:26:14 +00:00
Dmitri Hrybenko
2812aba59c Code completion: speed up by more than 2x
... at the cost of correctness, see test changes

This change was suggested by Argyrios.

But we still take 10 seconds to compute completion results for Cocoa.

Swift SVN r16599
2014-04-20 20:03:25 +00:00
Doug Gregor
09797f7f99 Introduce a new declaration node, ParamDecl, for function parameters.
Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
2014-04-20 05:23:35 +00:00
Dmitri Hrybenko
70ed107d69 Code completion: extend the hack to complete function call patterns after left
paren to work with method calls on AnyObject and curried function calls


Swift SVN r16412
2014-04-16 13:42:55 +00:00
Dmitri Hrybenko
236c581de7 Code completion: complete "?.member" on T?, and ".member" on @unchecked T?
In order for Xcode to use these completions, we complete "?.member" when the
user has typed "anOptional.", but we also say that in order to apply this
result, N bytes to the left of the cursor should be erased first.

rdar://16579657 rdar://15233283


Swift SVN r16409
2014-04-16 10:50:14 +00:00
Dmitri Hrybenko
da41b2e766 Code completion: provide results for initializers after the left paren:
class A {
    init(a: Int) {}
  }
  A(#^HERE^#

In its current state, this is a hack that I am not proud of.  There is
potential here to provide such completions for all function calls:

  class A {
    func foo(a: Int) {}
    func foo(a: Double) {}
  }
  A().foo(#^HERE^#

but this requires code completion doing its own name lookup, since the type
checker will give us an error type due to ambiguity of overloaded functions.

Type checker also sometimes gives up in cases like these:

  struct A {
    func foo() {}
  }
  A().foo

which is understandable, since we disallow partial applications of functions on
values, but returning the correct type here is useful for code completion.

rdar://16597372


Swift SVN r16367
2014-04-15 12:05:05 +00:00
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
a98375b286 Cleanup, NFC.
Swift SVN r16211
2014-04-11 10:44:10 +00:00
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00
Joe Groff
9f7dab725c Make the ASTContext parameter to MetatypeType::get optional for type-checked types.
We can just get it from the instance type, if the instance type has been fully initialized, which is the case except during parsing of type decls when the decls' own types are being formed.

Swift SVN r15598
2014-03-29 02:50:30 +00:00
Joe Pamer
56e2b28b76 Remove more unnecessary semicolons.
Swift SVN r15489
2014-03-26 06:07:06 +00:00
Dmitri Hrybenko
04b9f8c384 Code completion: correctly call type checking routines for a function nested
inside a closure

rdar://16139669


Swift SVN r15453
2014-03-25 14:42:33 +00:00
Jordan Rose
8d35d75ce3 [ClangImporter] Resolve forward class declarations to definitions in Swift.
When we see an unresolved @class in a Clang module, we check the class name
against the classes in the Swift module with the same name.

This unfortunately necessitates putting a reference to the active type checker
into the ClangImporter, because the class in the current Swift module hasn't
been type-checked yet. This is now being used everywhere we do a lookup.

<rdar://problem/16295994>

Swift SVN r15355
2014-03-22 00:19:59 +00:00
Doug Gregor
195fb46e44 Typo correction in a variable name.
Swift SVN r15170
2014-03-17 23:23:55 +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
5659f8a78c Code completion: don't assert if module loading failed
Swift SVN r14867
2014-03-10 12:14:00 +00:00
Chris Lattner
d758e0dfe3 Eliminate more "DynamicLookup" in favor of "AnyObject", this is the
bulk of finishing rdar://13327098.


Swift SVN r14653
2014-03-04 22:15:46 +00:00
Dmitri Hrybenko
0c4c291d20 Fix code completion in variable initializers that are not at the top level
Code completion used to suggest non-static members in member var initializer,
and incorrectly reported the reason why the declarations are visible from the
initializer.


Swift SVN r14457
2014-02-27 11:13:25 +00:00
Joe Groff
98d6fecc99 '.metatype' -> '.Type'
Also, reserve 'type' as a keyword for ensuing syntax changes.

Swift SVN r14375
2014-02-26 04:23:21 +00:00
Dmitri Hrybenko
15e3dd2e6d Code completion: don't crash on didSet/willSet
User can not call them directly, so code completion now skips them just like
getters and setters.

This is part of fixing rdar://15849262


Swift SVN r14341
2014-02-25 17:34:15 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +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
Chris Lattner
9ee7d99a46 switch a few things off of argument patterns, onto body patterns.
Swift SVN r13891
2014-02-14 01:33:14 +00:00
Chris Lattner
827acad533 Various inout improvements:
- purge @inout from comments in the compiler except for places talking about
   the SIL argument convention.
 - change diagnostics to not refer to @inout
 - Change the astprinter to print InoutType without the @, so it doesn't show
   up in diagnostics or in closure argument types in code completion.
 - Implement type parsing support for the new inout syntax (before we just 
   handled patterns).
 - Switch the last couple of uses in the stdlib (in types) to inout.
 - Various testcase updates (more to come).



Swift SVN r13564
2014-02-06 06:22:27 +00:00
Chris Lattner
79cbda7f88 convert a heck of a lot of tests to use the new inout syntax (yay for regex's),
and implement code completion and ast-printer support for the new syntax.



Swift SVN r13562
2014-02-06 05:35:36 +00:00
Doug Gregor
04475c6a85 Use @unchecked optionals for member references into AnyObject/AnyClass.
This eliminates the need for a number of !'s when dealing with
Objective-C APIs. Now with actual executable behavior!


Swift SVN r13483
2014-02-05 07:58:18 +00:00
Dmitri Hrybenko
b2938db915 Code completion: simplify code using the new getInnermostMethodContext() function
Swift SVN r13430
2014-02-04 11:36:19 +00:00
Argyrios Kyrtzidis
1d6fdcbe97 [IDE] Code-completion: References to types should not mention ".metatype"
rdar://15805275

Swift SVN r13062
2014-01-28 19:38:42 +00:00
Argyrios Kyrtzidis
6e1d1c0b10 [IDE] Adding ".metatype" is not a valid completion in an expression context but it is valid in
a type context.

Swift SVN r13061
2014-01-28 19:38:40 +00:00
Doug Gregor
d52cec4b20 Eliminate a pile of literal identifiers for self, init, destructor, etc.
... because I can't stomach adding another one of these.


Swift SVN r12687
2014-01-22 01:09:49 +00:00
John McCall
1ccf23487e Remove unnecessary ASTContext& argument from getOptionalObjectType().
Swift SVN r12344
2014-01-15 21:00:58 +00:00
Argyrios Kyrtzidis
cb6a006f19 [IDE] Fix crash during code-completion with invalid code.
Swift SVN r12093
2014-01-09 09:47:23 +00:00
Chris Lattner
d2a33362dc Fix getRValueType() to not strip off @inout types, only @lvalue types.
- Introduce a new TypeBase::getInOutObjectType() that strips off @inout types
- Switch stuff that is calling getRValueType() to call getInOutObjectType()
  when they are stripping @inout, not @lvalue (this is primarily around
  stuff working with self)
- Update testcases, some diagnostics improve around & handling.

This fixes rdar://15708430 and rdar://15729093.



Swift SVN r11794
2014-01-01 18:56:44 +00:00
Dmitri Hrybenko
537e1259f8 Code completion: annotate associated types with concrete style while completing expressions
Swift SVN r11537
2013-12-21 04:11:22 +00:00
Dmitri Hrybenko
8c76b4c0b4 Code completion: when reporting associated type aliases, try to annotate them with concrete types
Swift SVN r11536
2013-12-21 02:59:42 +00:00
Chris Lattner
b29748a6be remove the ASTContext argument from Type::transform,
(various) FunctionType::get's, ArrayType::get,
ArraySliceType::get, OptionalType::get, and a few
other places.

There is more to be done here, but this is all I plan to do
for now.


Swift SVN r11497
2013-12-20 02:23:21 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
John McCall
dfe138fdc4 Build and register the PDB earlier, removing the need for a
special case in code-completion.

Swift SVN r11179
2013-12-12 03:36:30 +00:00
John McCall
342a8b35db Parse default-argument expressions in an initializer context.
Swift SVN r11178
2013-12-12 03:36:27 +00:00
Dmitri Hrybenko
6a776132d2 Code completion: don't substitute generic parameters if the actual parameters
are just canonical generic types

Fixes rdar://15588242 using a different approach than suggested in the radar.


Swift SVN r10904
2013-12-06 02:15:23 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
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