Commit Graph

3980 Commits

Author SHA1 Message Date
Ben Langmuir
65c86b713d [ReconstructType] Fix decl lookup when there are multiple constructors
We were failing to find init() decls whenever there was more than one
candidate.

The mangled function type we get will be (args...) -> T, but the real
thing is (T.Type) -> (args...) -> T. Strip the metatype so we can match
successfully.
2016-03-18 14:15:24 -07:00
Xi Ge
a99a3556e7 ModulePrinting: Encapsulate bracket options into a sub-structure of PrintOptions. NFC 2016-03-17 21:34:51 -07:00
Xi Ge
d8a7118966 ModulePrinting: Rename merge group kinds. 2016-03-17 17:54:50 -07:00
Xi Ge
b894798e46 ModulePrinting: For those extensions have no doc-comments, no constraints and no inheritance, we merge their contents to the body of the type declaration. 2016-03-17 16:26:34 -07:00
Xi Ge
3dbd14be00 ModulePrinting: Refactoring SynthesizedExtensionAnalyzer to better expose the merge groups of extensions. NFC 2016-03-17 16:26:34 -07:00
Xi Ge
c3de0db612 ModulePrinting: Merge the content of extensions of the same constraints/inherits, disregarding of whether they are synthesized or actual. 2016-03-16 17:29:37 -07:00
Ben Langmuir
a760b70827 Fixup recent formatting boo boos I've committed
I always think I'll remember to clang-format before pushing, but I don't
always follow through.
2016-03-16 15:58:11 -07:00
Ben Langmuir
47d2c24078 [IDE] Factor code that looks up USRs into getDeclFromUSR 2016-03-16 15:43:02 -07:00
Xi Ge
f0e96f1e70 [SyntaxColoring] Allow empty lines when highlighting doc comment keywords. rdar://25144566 2016-03-15 13:28:34 -07:00
Ben Langmuir
8c0d5408b7 [CodeCompletion] Fix call-arg completion when we remove all the overloads we found
We have code for pruning unlikely overloads, but when it pruned all
overloads it was treating that as if there was nothing to complete.
Instead, fallback to postfix-expr-begin.

We should also figure out why we're not getting any viable types here,
but we need to handle failure gracefully.

rdar://problem/24356118
2016-03-15 13:19:11 -07:00
Ben Langmuir
8030d44826 [SyntaxMap] Fold unary minus into numeric literals
Unlike other prefix operators, unary minus is folded into the
NumberLiteralExpr in the parser. This commit recreates this effect in
the lexer-based syntax map so that token ranges will include the leading
minus.

rdar://problem/20205885
2016-03-15 10:40:52 -07:00
Ben Langmuir
1b08d83b6f [SourceKit] Annotate class method dynamic Self return types
Pass through the original Type in addition to the TypeDecl so that we
can distinguish DynamicSelfType with underlying ClassType from just any
old ClassType.

rdar://problem/25158493
2016-03-14 19:43:54 -07:00
Xi Ge
b74bd730a6 [SyntaxColoring] Not coloring 'keywords' appearing in API argument names as actual keywords; they are legal names. rdar://25129880 2016-03-14 17:39:40 -07:00
Xi Ge
8b7eff2e7f [SyntaxColoring] Sanitize extra closing parenthesis by the end of URLs. 2016-03-14 11:18:48 -07:00
Xi Ge
f64ff89bd4 [SyntaxColoring] Remember to search for URLs inside doc comment lines/blocks. 2016-03-14 11:18:48 -07:00
Ben Langmuir
92a038cbe2 [CodeCompletion] Strengthen null check to assert NFC
This function is only called with a non-null type, which is the only
reasonable way to call it anyway.
2016-03-12 09:01:38 -08:00
Ben Langmuir
812d1566a7 [CodeCompletion] Don't look through non-type contexts in override
We don't actually want to skip non-type contexts here, since we should
only be showing override completions in the type context itself. This
was pretty obscure to hit in practice, but I noticed it while fixing the
crasher.
2016-03-12 08:39:11 -08:00
Ben Langmuir
da9c68d373 [CodeCompletion] Don't complete inits after func/var/override keywords
When completing nominal members (overrides, etc.), don't show inits if
the user already added a keyword that can't go before an init.
2016-03-11 23:00:11 -08:00
Xi Ge
fd91b119a7 Merge pull request #1600 from apple/unhide-important-underscored-protocols
stdlib: unhide important underscored protocols in the generated interface
2016-03-11 17:44:28 -08:00
Ben Langmuir
49b70ebe56 Fix formatting missed in previous commit NFC
Argh, forgot to git-add.
2016-03-11 17:16:08 -08:00
Ben Langmuir
47723848bd [CodeCompletion] Fix crash in override completion in a bogus context
Use the right context for getting the formal access. To get the
completions right, we should fix the FIXME about not backtracking the
parser so far.
2016-03-11 17:15:19 -08:00
Ben Langmuir
d51c0f1aa7 [IDE] StringRefize the ReconstructType APIs NFC
Luckily const char* clients can work unmodified.
2016-03-11 14:24:32 -08:00
Xi Ge
f602f5c6e9 [CodeCompletion] Exclude underscored stdlib protocols from code completion items. 2016-03-11 14:08:31 -08:00
Xi Ge
ae1dd18f1c Revert "ModuelPrinter: Add delineator to mark Decls from a different source file start."
The delineator is not handled properly by IDE.

This reverts commit fb05179ed7.
2016-03-10 18:26:02 -08:00
Xi Ge
c22e9bcf53 ModulePrinting: Merge synthesized extensions' bodies if they have the common constraints. 2016-03-10 17:50:24 -08:00
Ben Langmuir
0df450ddb1 [ReconstructType] Start sketching in lookup to get local declarations
Add cases to handle basic local variable declarations by looking up the
identifier found in the LocalDeclName. There is some duplication with
Identifier nodes that could be cleaned up still.

The actual lookup is currently dumb - it just attempts to do a
function-wide lookup at the end location of the function body. We'll
need a better way to find the local declarations, but for now it lets us
make some incremental progress.
2016-03-10 15:48:34 -08:00
Ben Langmuir
3d9dc0c5f8 [ReconstructType] Factor the giant switch out of VisitNode NFC
Make the control flow clearer by factoring out the switch.  There was a
single key line burried under there where the node is popped.

Incidentally rename the lonely snake_case parameter to this functiong,
since we're modifying every line anyway.
2016-03-10 09:25:14 -08:00
Ben Langmuir
381caaa6d0 [ReconstructType] Remove dead log parameters NFC 2016-03-10 09:23:09 -08:00
Ben Langmuir
5725d22c89 [IDE] Add an entry point to get decls out of 'ReconstructType'
For now, just tack the testing onto the existing walker that checks the
types.  It doesn't seem to work at all for local declarations yet, but
at least we get some top-level stuff.
2016-03-09 21:14:29 -08:00
Max Moiseev
885b564bf5 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 17:16:37 -08:00
Ben Langmuir
0bc2cc4290 [CodeCompletion] Negate incorrect comment NFC 2016-03-09 16:20:24 -08:00
Ben Langmuir
4a30637e08 [CodeCompletion] Don't complete unavailable methods in override
We generally don't want to override unavailable methods.  We already
filter out unavailable decls when completing values, but that's in a
separate visible decl consumer.

rdar://problem/25058233
2016-03-09 16:20:23 -08:00
Max Moiseev
02006f20bc Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 16:05:03 -08:00
Leo Giertz
70816b7cf8 Just include <cstdarg> unconditionally 2016-03-09 19:49:15 +01:00
Leo Giertz
9787a72288 [FreeBSD] Include <stdarg.h>, needed for va_start etc. 2016-03-09 17:11:01 +01:00
Ben Langmuir
d03539c127 [ReconstructType] Run clang-format on this file
I wouldn't normally do a bulk reformat like this, but in this case I
think the benefits of consistently formatting the file outweigh the
costs, because (a) there is no substantive history to this file yet in
the swift repo, and (b) there are widespread and *distracting* style
differences like brace-placement and spaces before opening (.
2016-03-08 22:03:28 -08:00
Ben Langmuir
1af03871dc [ReconstructType] Remove a call to printf 2016-03-08 22:03:27 -08:00
Ben Langmuir
43f078eaf2 [ReconstructType] Remove an unnecessary typedef NFC
Eventually all three of these should go away.  I want to keep
ConstString around for now, because it makes it easier to audit where
you should consider using a StringRef. I'm hoping only a few of those
actually need std::string.
2016-03-08 22:03:27 -08:00
Ben Langmuir
acbebfacb3 [ReconstructType] Drop unnecessary llvm:: qualifications NFC
Behold the power of LLVM.h
2016-03-08 22:03:26 -08:00
Ben Langmuir
da00713bd8 [ReconstructType] Don't explicitly qualify swift:: NFC
Now it feels more like home.
2016-03-08 22:03:25 -08:00
Ben Langmuir
46c6dd5a34 [ReconstructType] Rename an unfortunate enum 'Type' NFC
Preparing to drop swift:: everywhere.
2016-03-08 22:03:25 -08:00
Ben Langmuir
fb223fc187 [ReconstructType] Reorder and prune includes
No promise that this is minimal or optimal.
2016-03-08 22:03:24 -08:00
Xi Ge
09cd9c1f9d ModulePrinting: Fix several issues pointed by Ben. 2016-03-08 18:34:38 -08:00
Max Moiseev
1fae0d1325 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-08 12:48:48 -08:00
Xi Ge
fb05179ed7 ModuelPrinter: Add delineator to mark Decls from a different source file start. 2016-03-08 12:18:10 -08:00
Xi Ge
e674e986a2 ModulePrinting: Print stdlib Decls from the same source file in source order. 2016-03-08 12:18:10 -08:00
Xi Ge
7a3276738b Re-apply "ModulePrinter: Print decls from the same source file near each other."
This reverts commit 1db83907e3.
2016-03-08 12:18:10 -08:00
Ben Langmuir
ce3c2de4a6 [CodeCompletion] Convert optionals when checking for literal protocol conformance
Except for nil literals, we don't want to look at the optional itself,
since the typechecker would implicitly look to the underlying type.

rdar://problem/24707210
2016-03-08 09:39:04 -08:00
Xi Ge
1db83907e3 Revert "ModulePrinter: Print decls from the same source file near each other."
This reverts commit a5c9072344 for mysterious bot test failure.
2016-03-07 23:33:23 -08:00
Xi Ge
a5c9072344 ModulePrinter: Print decls from the same source file near each other. 2016-03-07 22:51:50 -08:00