Commit Graph

14 Commits

Author SHA1 Message Date
Hamish Knight
af7134b884 Fully enable ExperimentalStringProcessing
Previously we would only enable by default when
`parseArgs` was called. However this wouldn't
enable it for clients such as LLDB, who provide
their own invocation. Switch the default to `true`
in the `LangOptions`, and remove some redundant
uses of `-enable-experimental-string-processing`.
The frontend flag remains, as it may be useful to
disable.

rdar://107419385
rdar://101765556
2023-03-31 18:10:39 +01:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Karoy Lorentey
d0e377e737 [utils] Use Python 2 compatible name for text=True 2022-03-08 12:03:56 -08:00
Karoy Lorentey
bcddc9b7b9 [utils] Force subprocess output to be read in text mode
In Python 3, subprocess output is read as binary data by default, which isn’t what we want.

Instead of reading process output as byte strings, then manually decoding them into strings, simply pass `text=True` to functions in the `subprocess` module, so that we get properly decoded strings right out the box.

This fixes places that forget to do the decoding step — most especially, the `update-checkout` script. That script prints Git output as byte strings, which leads to unreadable results.

Additionally, in shell.run, use the same pipe for capturing both stdout and stderr. The distinction is pretty pointless in this use case; however, keeping the two channels separate means that we lose the original ordering of printed messages, which does matter.
2022-03-07 16:59:36 -08:00
Richard Wei
65bffd7ad7 Add _MatchingEngine and _StringProcessing modules.
These modules are part of the experimental declarative string processing feature. If accepted to the Standard Library, _StringProcessing will be available via implicit import just like _Concurrency, though _MatchingEngine will still be hidden as an implementation detail.

`_MatchingEngine` will contain the general-purpose pattern matching engine ISA, bytecode, and executor. `_StringProcessing` will contain regular expression and pattern matching APIs whose implementation depends on the matching engine..

Also consolidates frontend flag `-enable-experimental-regex` as `-enable-experimental-string-processing`.

Resolves rdar://85478647.
2021-11-19 09:27:33 -08:00
Michael Gottesman
e2c1db5b64 [test] Change swift-refactor tooling to specify a resource-dir. 2021-09-02 14:08:24 -07:00
Hamish Knight
2887f4048e Have refactor-check-compiles pass down -I -sdk -target
Forward these flags to both swift-frontend and
swift-refactor.
2021-08-18 13:21:06 +01:00
Hamish Knight
b03c06f721 Don't error on placeholders for refactor-check-compiles
This allows us to test more cases that type-check
modulo placeholders.
2021-08-18 13:21:05 +01:00
Ben Barham
717a932a3f [Utils] Make sure to write the rewritten file in refactor-check-compiles
`ClangFileRewriterHelper` only outputs the rewritten buffer when it's
destroyed, but the consumers were never being freed. Cleanup the
lifetime management of the stream and consumers so that they're properly
destroyed.

Rename `DuplicatingSourceEditConsumer` to
`BroadcastingSourceEditConsumer` to better describe its purpose.
2021-06-03 21:11:00 +10:00
jiaren wang
68eb0d7087 [Refactoring] generate both '-dump-text' and dump-rewritten from a single swift-refactor invocation (SR-14587) 2021-05-27 16:29:59 +08:00
Ben Barham
762337cc9b [Refactoring] Add @completionHandlerAsync to sync function
When adding an async alternative, add the @completionHandlerAsync
attribute to the sync function. Check for this attribute in addition to
the name check, ie. convert a call if the callee has either
@completionHandlerAsync or a name that is completion-handler-like name.

The addition of the attribute is currently gated behind the experimental
concurrency flag.

Resolves rdar://77486504
2021-05-14 20:19:02 +10:00
Andrew Trick
9537b14404 Fix refactor-check-compiles.py for python3
Fixes:
    sys.stdout.write(dump_text_output)
TypeError: write() argument must be str, not bytes
2021-05-10 20:50:18 -07:00
Alex Hoppen
98e6680c85 [Refactoring] When adding an async alternative refactor the old method to call the async method using detach
Instead of leaving two copies of the same implementation, rewrite the old method with the completion handler to call the newly added `async` method.

Resolves rdar://74464833
2021-05-04 12:06:27 +02:00
Alex Hoppen
9916a6d5c7 [Refactoring] Add a drop-in replacement for swift-refactor which checks that the code compiles after refactoring 2021-04-30 23:48:23 +02:00