Commit Graph

2426 Commits

Author SHA1 Message Date
Rintaro Ishizaki
bbf288b53f [IDE] Use 'Demangle::getTypeForMangling()' instead of 'getDeclFromMangledSymbolName()' 2019-02-08 14:43:59 -08:00
Rintaro Ishizaki
7837130ae1 [IDE] Give default implementation for completion callbacks 2019-02-08 14:09:00 -08:00
Rintaro Ishizaki
1d845d6e3f [IDE/SourceKit] New SourceKit request for filtered method list
`source.request.conformingmethods` is a new SourceKit request which
receives a source position and a list of protocol namses, returns a list
of methods whose return type conforms to the requested protocols.

rdar://problem/44699573
2019-02-08 12:56:58 -08:00
Slava Pestov
b2f0327516 IDE: Remove getTypeFromMangledSymbolname()
There was only one remaining usage other than in testing tools.

Note that when a declaration mangling was passed in, the old entry
point would (try to) return the type of the declaration.

The new entry point no longer has this behavior. I changed the
bridging-header-first test to run lldb-moduleimport-test with
-decl-from-mangled instead of -type-from-mangled-old to preserve
the behavior of the test.

Also, I removed test/DebugInfo/DumpTypeFromMangledName.swift
completely. This test only covered a handful of cases, and a bunch
of them were declaration manglings rather than type manglings.
The new tests in test/TypeDecoder/ are much more comprehensive.
2019-02-08 02:56:05 -05:00
Xi Ge
d537009ed1 Merge pull request #22365 from nkcsgexi/47777848
ASTPrinter: add an option to skip keywords with an underscore prefix
2019-02-06 16:04:50 -08:00
Xi Ge
a92ea0c256 IDE: print underscored keywords for interface generation
Addressing @airspeedswift's code review feedback.
2019-02-06 14:51:39 -08:00
Rintaro Ishizaki
d4c3ee6b49 [IDE] Handle '@unknown' attribute in syntax map
`@unknown` is so far the only attribute for statement. Handle it
specially in syntax-map.

rdar://problem/47855035 / https://bugs.swift.org/browse/SR-9873
2019-02-06 11:23:53 -08:00
Xi Ge
8dbbb2ba1d sourcekitd/format: avoid performing sibling-based indentation for PrefixUnaryExpr.
rdar://47659949
2019-01-31 15:44:19 -08:00
Rintaro Ishizaki
e7700dc67f [IDE] Fix SyntaxModel to corretly walk sequence expression correctly
* Handle sequence expression at call argument position
* Set the sequence expression as the parent when walking into its sub
  expressions.
* Correctly call walkToExprPost() to the sequence expression.

rdar://problem/47603866 / https://bugs.swift.org/browse/SR-9776
2019-01-28 11:25:07 -08:00
Marcelo Fabri
cab4968da3 [SR-9740][SourceKit] Mark types inside enum case decl as typeidentifiers 2019-01-24 09:14:11 -08:00
Xi Ge
c74cf897d7 Merge pull request #22017 from marcelofabri/rethrows
[SR-9576][SourceKit] Fix syntax type when rethrows is present
2019-01-24 08:43:52 -08:00
Marcelo Fabri
d948823d89 [SR-9576][SourceKit] Fix syntax type when rethrows is present 2019-01-22 20:26:23 -08:00
Rintaro Ishizaki
f41b694140 [IDE] Code style: space between 'override' and '{}' 2019-01-22 15:38:28 -08:00
Robert Widmann
c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05:00
Slava Pestov
e3c5eb7d3a IDE: Remove unused function 2019-01-14 14:57:03 -05:00
Rintaro Ishizaki
b446d6b051 Merge pull request #21377 from rintaro/ide-contextinfo
[SourceKit][IDE] New SourceKit request to retrieve context type information
2019-01-15 01:54:16 +09:00
Rintaro Ishizaki
54f0fab93e [IDE] Add TypeContextInfo callbacks to parser
TypeContextInfo is for new SourceKit request which receives source
location, and returns context type and members which can be referenced
by "implicit member expression" syntax.

Implement that as a code completion callbacks.
2019-01-10 17:52:37 +09:00
Rintaro Ishizaki
cc1d5c1147 [IDE] Move typeCheckContext() to ExprContextAnalysis.cpp
NFC
2019-01-10 17:52:37 +09:00
Rintaro Ishizaki
2fbd3fe682 [IDE] Move ExprContextAnalyser to its own file
NFC
2019-01-10 17:52:37 +09:00
Rintaro Ishizaki
d17bb78a0b [AST] Add shouldHideFromEditor() method
This replaces shouldHideDeclFromCompletionResults() in IDE.
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
867c28ea74 [IDE] Rename collectArgumentExpectation() to analyzeApplyExpr()
Removed unnecessary arguments.
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
e3387c6fdb [IDE] ExprContextAnalyzer::Analyze() doesn't need to return success 2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
758ba5e5d0 [IDE] Decouple ExprContextAnalyzer and ExprContextInfo
Just refactoring.
ExprContextInfo automatically construct analyzer and analyze().
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
5c64324740 [IDE] Refactor ExprContextAnalyzer. NFC
We don't need to keep ExprFinder beyond analysis.
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
2fb542537f [IDE] Rename CodeCompletionTypeContextAnalyzer to ExprContextAnalyzer
NFC
2019-01-10 17:52:36 +09:00
Rintaro Ishizaki
b033f4880c [CodeCompletion] Only analyze inner most context
Now that this passes all test cases we currently have. Stop analyzing
outer contexts because it may emit invalid context type.
2019-01-10 17:52:36 +09:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Rintaro Ishizaki
4b39c20ace [CodeCompletion] Unresolved member completion at type parameter context
We need to map 'GenericTypeParamType' to 'ArchetypeType' to lookup its
members.

rdar://problem/46657585
2019-01-09 14:44:29 +09:00
Slava Pestov
dffa857b2a Merge pull request #21704 from slavapestov/remove-restate-filtering-consumer
Fix a crash by removing the RestateFilteringConsumer
2019-01-08 08:03:59 -05:00
Slava Pestov
c41be6ee0c IDE: Fix another usage of lookupVisibleMemberDecls() to not pass in an existential type
It's better to use the 'Self' archetype here.
2019-01-08 00:14:52 -05:00
Slava Pestov
8a201af7e6 IDE: Fix a usage of lookupVisibleMemberDecls() to not pass in an existential type
It's better to use the 'Self' archetype here.
2019-01-08 00:14:52 -05:00
Slava Pestov
f81c23d154 IDE: Replace some dead code with an assert 2019-01-08 00:14:52 -05:00
Argyrios Kyrtzidis
ab7427723e [Parse/Syntax] Refactoring to decouple the parser from syntax tree creation
Instead of creating syntax nodes directly, modify the parser to invoke an abstract interface 'SyntaxParseActions' while it is parsing the source code.
This decouples the act of parsing from the act of forming a syntax tree representation.
'SyntaxTreeCreator' is an implementation of SyntaxParseActions that handles the logic of creating a syntax tree.
To enforce the layering separation of parsing and syntax tree creation, a static library swiftSyntaxParse is introduced to compose the two.

This decoupling is important for introducing a syntax parser library for SwiftSyntax to directly access parsing.
2019-01-07 19:52:59 -08:00
Nathan Hawes
43c2f27783 [Refactoring][Migrator] Fix rename of callsites with a trailing closure argument
A label range of 0 length was being reported as the label of trailing closure
arguments, just before the opening '{'.

For the rename refactoring, this meant that if the corresponding parameter had
an external label (e.g. 'a') the occurrence would be treated as not matching the
expected symbol name, and so not be updated at all.

For the migrator, when renaming a function with an unlabelled closure for its
last parameter to have a label, it would incorrectly insert the new label in
front of the opening '{' on all of that function's callsites with trailing
closures.

Resolves rdar://problem/42162571
2018-12-19 16:24:14 -08:00
Argyrios Kyrtzidis
66be4a58b4 [Parser] Introduce ParserUnit::parse() function to avoid duplication of code 2018-12-16 09:52:15 -08:00
Bob Wilson
3347d482e9 NFC: Simplify code by using Triple.getOSAndEnvironmentName
This avoids the need to check if the environment component is set.
2018-12-12 11:30:58 -08:00
Davide Italiano
56e3da97cd Revert "[TypeRecontruction] Remove handling of InOutTypes."
This reverts commit 751550be1a.
2018-12-07 09:13:09 -08:00
Davide Italiano
751550be1a [TypeRecontruction] Remove handling of InOutTypes. 2018-12-06 17:31:43 -08:00
Saleem Abdulrasool
f898abef63 Merge pull request #21027 from compnerd/save-the-environment
IDE: preserve the environment in the triple
2018-12-05 18:19:46 -08:00
swift-ci
39161d5b36 Merge pull request #20600 from adrian-prantl/36032653 2018-12-05 17:01:58 -08:00
Adrian Prantl
d63debeb60 Experimental: Extend ClangImporter to import clang modules from DWARF
When debugging Objective-C or C++ code on Darwin, the debug info
collected by dsymutil in the .dSYM bundle is entirely
self-contained. It is possible to debug a program, set breakpoints and
print variables even without having the complete original source code
or a matching SDK available. With Swift, this is currently not the
case. Even though .dSYM bundles contain the binary .swiftmodule for
all Swift modules, any Clang modules that the Swift modules depend on,
still need to be imported from source to even get basic LLDB
functionality to work. If ClangImporter fails to import a Clang
module, effectively the entire Swift module depending on it gets
poisoned.

This patch is addressing this issue by introducing a ModuleLoader that
can ask queries about Clang Decls to LLDB, since LLDB knows how to
reconstruct Clang decls from DWARF and clang -gmodules producxes full
debug info for Clang modules that is embedded into the .dSYM budle.

This initial version does not contain any advanced functionality at
all, it merely produces an empty ModuleDecl. Intertestingly, even this
is a considerable improvement over the status quo. LLDB can now print
Swift-only variables in modules with failing Clang depenecies, and
becuase of fallback mechanisms that were implemented earlier, it can
even display the contents of pure Objective-C objects that are
imported into Swift. C structs obviously don't work yet.

rdar://problem/36032653
2018-12-05 13:54:13 -08:00
Saleem Abdulrasool
7f6a333c16 IDE: preserve the environment in the triple
Adjust the triple manipulation to preserve the environment.  This is
particularly important for android which is an environment for Linux,
and Windows, where we support specific environments only.
2018-12-04 19:50:39 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Rintaro Ishizaki
337d53f217 [CodeCompletion] Be lenient in callee analysis
Accept `getInterfaceType->hasError()` declarations. Even if the part of
the declaration has error, we still have chance to get context info from
the other part of it. For instance:

  func foo(x: Int, y: INt) { }
  foo(x: #^COMPLETE^#

We should resolve 'Int' as the context type even if parameter `y` is an
error type.
2018-12-03 17:26:12 +09:00
Slava Pestov
fc8f122336 AST: Remove FuncDecl::getReturnTypeLoc() 2018-12-02 18:41:39 -05:00
Rintaro Ishizaki
56c531d05a [CodeCompletion][NFC] Add some doc comments 2018-11-27 08:02:47 +09:00
Rintaro Ishizaki
c55d6ce7bd [CodeCompletion] Fix call arguments completion in overloaded case
In `<expr> '(' <code-completion-token>` case, we usually complete call
arguments. If '<expr>' isn't typechecked, for example, because of
overloading, we used to give up arguments completions.

Now, use possible callee informations from the context type analyzer. This
increases the chance to provide accurate completions.

rdar://problem/43703157
2018-11-27 02:41:11 +09:00
Rintaro Ishizaki
8a6c540e74 [CodeCompletion][NFC] Collect possible callees instead of params
in context type analysis.
Still NFC, but this is needed by later commits.
2018-11-27 02:41:03 +09:00
Rintaro Ishizaki
1af807894e [CodeCompletion][NFC] Store context results in analyzer member fields
To simplify call-site code.
2018-11-26 23:09:29 +09:00
Rintaro Ishizaki
bd4f20dd5f [CodeCompletion][NFC] Move collectArgumentExpectation()
These functions are only used by CodeCompletionTypeContextAnalyzer.
Move them into it.
2018-11-26 20:06:38 +09:00