Commit Graph

39 Commits

Author SHA1 Message Date
Xi Ge
cc395e792c SourceKit/InterfaceGen: sanitize Clang-specific doc-comment style when printing headers as Swift interface
rdar://47985888
2019-03-11 14:16:45 -07:00
Slava Pestov
c51f884879 SourceKit: Just always call getFormalAccess() 2018-09-05 16:51:20 -07:00
Jordan Rose
5a8cbe4503 [AST] Never print access levels on protocol requirements
We might allow this at some point in the future, but for now we should
stick to the syntax that people write in source.

rdar://problem/26746605
2018-08-16 16:00:49 -07:00
John McCall
69f4dd1ec9 Generalize accessor storage to preserve the original accessor list.
Only not NFC because it's detectable by source tools.
2018-06-16 18:16:31 -04:00
Marcelo Fabri
ba39c7b235 [SourceKit] Include AccessLevel attributes in structure (SR-5978) (#12086) 2017-10-11 20:57:09 -07:00
Marcelo Fabri
2bf49b0151 [SourceKit] Add range for attributes in a structure (SR-5587) (#11750) 2017-09-20 15:54:42 -07:00
Slava Pestov
696694b61d Update some IDE tests 2017-09-14 01:15:31 -07:00
Xi Ge
34e2aec662 Parser: use parser to generate a refined token stream to help syntax coloring. (#11809)
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
2017-09-08 10:28:19 -07:00
Marcelo Fabri
c639147f02 [SourceKit] Include function return type in function kinds structure (SR-5613) 2017-08-14 20:53:00 +02:00
Arnold Schwaighofer
f442dd93bd CompilerInvocation: If no optimization flag is set default to Onone
I noticed in a follow-up patch that if you just swiftc without passing Onone
these flags are not set and sometimes happen to default to right thing ... or
not; as can be seen by the test cases modified. For example, at Onone we are
supposed to include an extra swift module "SwiftOnoneSupport".
2017-08-04 11:49:16 -07:00
swift-ci
747f79ca3b Merge remote-tracking branch 'origin/master' into master-next 2017-08-02 13:49:09 -07:00
Marcelo Fabri
d16cce3a94 [SourceKit] Add documentation range in structure (SR-2487) (#11264) 2017-08-02 13:39:49 -07:00
Jordan Rose
7efdfb4167 [ClangImporter] Fix macros defined in terms of other macros.
...which didn't do the right thing in the presence of ModuleMacro,
depending on the order the macros were referenced. Already covered by
test/ClangImporter/macros.swift, but it actually seems to improve the
behavior of some of the SourceKit tests as well.

Continuing rdar://problem/32199805, which is just "get macros working
with clang::ModuleMacro".
2017-07-26 15:42:31 -07:00
John Fairhurst
1f94eca80c [SourceKit] Add typealias to doc structure (#11143)
From https://bugs.swift.org/browse/SR-4828
2017-07-26 09:59:06 -07:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
David Farler
f450f0ccdf Revert "Preserve whitespace and comments during lexing as Trivia"
This reverts commit d6e2b58382.
2016-11-18 13:23:31 -08:00
David Farler
d6e2b58382 Preserve whitespace and comments during lexing as Trivia
Store leading a trailing "trivia" around a token, such as whitespace,
comments, doc comments, and escaping backticks. These are syntactically
important for preserving formatting when printing ASTs but don't
semantically affect the program.

Tokens take all trailing trivia up to, but not including, the next
newline. This is important to maintain checks that statements without
semicolon separators start on a new line, among other things.

Trivia are now data attached to the ends of tokens, not tokens
themselves.

Create a new Syntax sublibrary for upcoming immutable, persistent,
thread-safe ASTs, which will contain only the syntactic information
about source structure, as well as for generating new source code, and
structural editing. Proactively move swift::Token into there.

Since this patch is getting a bit large, a token fuzzer which checks
for round-trip equivlence with the workflow:

fuzzer => token stream => file1
  => Lexer => token stream => file 2 => diff(file1, file2)

Will arrive in a subsequent commit.

This patch does not change the grammar.
2016-11-15 16:11:57 -08:00
Xi Ge
25179e1769 update existing test. 2016-10-21 12:59:50 -07:00
Michael Ilseman
8923a12585 [ASTPrinter] Switch to new ParameterTypeFlags
Switch printing off of using Function's ExtInfo for autoclosure and
escaping, and onto the ParameterTypeFlags, which let us do precise and
accurate context-sensitive printing of these parameter type
attributes. This fixes a huge list of issues where we were printing
@escaping for things like optional ObjC completion handlers, among
many others. We now correctly print @escaping in more places, and
don't print it when it's not correct.

Also updates the dumper to be consistent and give a good view of the
AST as represented in memory. Tests updated, more involved testing
coming soon.
2016-09-22 12:24:02 -07:00
Ingmar Stein
1eb0556bc3 Update test data 2016-09-03 18:01:23 +02:00
Ingmar Stein
98240ab871 [ClangImporter] import compound macros independent of order
This patch fixes an importer problem which occurred for macros defined
in terms of two other macros which might not have been imported before.
For example, the macro CPU_TYPE_X86_64 (defined as CPU_TYPE_X86 |
CPU_ARCH_ABI64) in Foundation wasn't imported although the importing
logic was implemented.

importMacro is now called for each of the constituents before checking
the constant value.
2016-09-03 16:43:11 +02:00
Doug Gregor
b56bb3d344 [AST] Fix the source range of pattern bindings with accessors.
The source range didn’t include the accessors themselves, so it wasn’t covering its child nodes.
2016-09-02 16:30:08 -07:00
Jordan Rose
b4e6f45083 [ClangImporter] Don't bridge weak and unsafe_unretained properties.
...to value types. Do continue bridging BOOL to Bool and such.

If the Objective-C API author went out of their way to indicate
ownership, they're probably using the reference semantics for
something. Give them the benefit of the doubt and leave the properties
declared using reference types. (It's not that they wouldn't work
correctly using Any, but that it's obscuring the intended interface.
And any /specific/ bridged value types /might/ actually cause issues
by causing copies.)

There is one wrinkle here involving declarations in the "accessibility
protocols" on Apple platforms, which sometimes use methods and
sometimes properties. The Swift compiler already deals with these by
always importing these as methods, so treat these like any other
methods and use value types when relevant.

rdar://problem/27526957
2016-08-03 20:43:35 -07:00
John McCall
afdda3d107 Implement SE-0117.
One minor revision: this lifts the proposed restriction against
overriding a non-open method with an open one.  On reflection,
that was inconsistent with the existing rule permitting non-public
methods to be overridden with public ones.  The restriction on
subclassing a non-open class with an open class remains, and is
in fact consistent with the existing access rule.
2016-08-02 07:46:38 -07:00
Michael Ilseman
c37751ae96 [noescape by defaul] make noescape the default
This flips the switch to have @noescape be the default semantics for
function types in argument positions, for everything except property
setters. Property setters are naturally escaping, so they keep their
escaping-by-default behavior.

Adds contentual printing, and updates the test cases.

There is some further (non-source-breaking) work to be done for
SE-0103:

- We need the withoutActuallyEscaping function
- Improve diagnostics and QoI to at least @noescape's standards
- Deprecate / drop @noescape, right now we allow it
- Update internal code completion printing to be contextual
- Add more tests to explore tricky corner cases
- Small regressions in fixits in attr/attr_availability.swift
2016-07-29 13:49:08 -07:00
Joe Groff
5bfd6cc0c7 Update SourceKit tests for id-as-Any. 2016-07-25 06:40:36 -07:00
Slava Pestov
ddc51c5917 AST: Implement SE-0102, introducing new semantics for Never alongside @noreturn
No migrator support yet, and the code for @noreturn is still in
place.
2016-07-22 14:56:39 -07:00
Jordan Rose
bc83940301 Make pointer nullability explicit using Optional.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md

- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
  hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
  (like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
  optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
  parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.

I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)

The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
2016-04-11 20:06:38 -07:00
Jordan Rose
1c25faaec3 [test] Adjust SourceKit test for CF importing.
The test was supposed to use a CF type, but it wasn't updated
for the switch from a naming convention to an attribute. This
restores the original intent (and unfortunately slides all the
offsets).
2016-04-11 17:55:10 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Daniel Duan
7cabf3555b [Parser] update test for SE-0040 changes 2016-03-11 16:01:37 -08:00
Xi Ge
5168083bf3 ModulePrinting: Print new lines between members of a decl. 2016-03-11 12:26:04 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Chris Lattner
7daaa22d93 Completely reimplement/redesign the AST representation of parameters.
Parameters (to methods, initializers, accessors, subscripts, etc) have always been represented
as Pattern's (of a particular sort), stemming from an early design direction that was abandoned.
Being built on top of patterns leads to patterns being overly complicated (e.g. tuple patterns
have to have varargs and default parameters) and make working on parameter lists complicated
and error prone.  This might have been ok in 2015, but there is no way we can live like this in
2016.

Instead of using Patterns, carve out a new ParameterList and Parameter type to represent all the
parameter specific stuff.  This simplifies many things and allows a lot of simplifications.
Unfortunately, I wasn't able to do this very incrementally, so this is a huge patch.  The good
news is that it erases a ton of code, and the technical debt that went with it.  Ignoring test
suite changes, we have:
   77 files changed, 2359 insertions(+), 3221 deletions(-)

This patch also makes a bunch of wierd things dead, but I'll sweep those out in follow-on
patches.

Fixes <rdar://problem/22846558> No code completions in Foo( when Foo has error type
Fixes <rdar://problem/24026538> Slight regression in generated header, which I filed to go with 3a23d75.

Fixes an overloading bug involving default arguments and curried functions (see the diff to
Constraints/diagnostics.swift, which we now correctly accept).

Fixes cases where problems with parameters would get emitted multiple times, e.g. in the
test/Parse/subscripting.swift testcase.

The source range for ParamDecl now includes its type, which permutes some of the IDE / SourceModel tests
(for the better, I think).

Eliminates the bogus "type annotation missing in pattern" error message when a type isn't
specified for a parameter (see test/decl/func/functions.swift).

This now consistently parenthesizes argument lists in function types, which leads to many diffs in the
SILGen tests among others.

This does break the "sibling indentation" test in SourceKit/CodeFormat/indent-sibling.swift, and
I haven't been able to figure it out.  Given that this is experimental functionality anyway,
I'm just XFAILing the test for now.  i'll look at it separately from this mongo diff.
2015-12-31 19:24:46 -08:00
Chris Lattner
3a23d75a62 Fix a few test failures introduced by 666a42f.
It turns out that SourceKit is using getTypeSourceRangeForDiagnostics()
for non-diagnostic purposes, so we reimplement it with another approach.

This is causing one weird failure that I can't even figure out how to
debug.  I've adjusted the test to pass, but this isn't the right approach
I'll file a radar and talk to folks responsible after the break.
2015-12-30 11:35:30 -08:00
Max Moiseev
7c4a693c3c fixing OptionSetType related tests 2015-12-10 16:59:18 -08:00
Max Moiseev
2d2d8ff1ea fixing tests after massive renaming 2015-12-09 17:11:29 -08:00
Argyrios Kyrtzidis
8ff6a98a99 [sourcekit] Merge SourceKit into the Swift repo.
The code goes into its own sub-tree under 'tools' but tests go under 'test',
so that running 'check-swift' will also run all the SourceKit tests.

SourceKit is disabled on non-darwin platforms.
2015-11-05 01:09:08 -08:00