Commit Graph

1423 Commits

Author SHA1 Message Date
Rintaro Ishizaki
8f8846342f [Tests] Disable a failing test case
While investigating

rdar://problem/72627583
2020-12-23 09:36:44 -08:00
Rintaro Ishizaki
8ef504acf3 Merge pull request #35050 from rintaro/ide-completion-rdar72198530
[CodeCompletion] Annotate 'async' functions/initializers in results
2020-12-18 09:29:07 -08:00
Xi Ge
c0e6204363 test: xfail failing sourcekitd tests in CI
rdar://72466352
2020-12-18 07:19:02 -08:00
Rintaro Ishizaki
4286c44e72 [CodeCompletion/SourceKit] Consolidate some chunk kinds
Consolidate ThrowsKeyword, RethrowsKeyword, and AsyncKeyword to
EffectsSpecifierKeyword.
Abolish 'key.throwsoffset' and 'key.throwslength' as they aren't used.
2020-12-14 12:25:30 -08:00
Nathan Hawes
6b1722e9de [test] Add missing requires line in test/SourceKit/CursorInfo/cursor_symbol_graph_objc.swift
It requires objc interop.
2020-12-12 14:38:41 +10:00
Nathan Hawes
388052b6ab [SymbolGraph][CursorInfo] Add option to SourceKit's CursorInfo request to include the SymbolGraph JSON
Adds a new 'key.retrieve_symbol_graph' option to the request. When set to 1 it
includes the JSON for a SymbolGraph containing a single node for the symbol at
the requested position.

This also extends the SymbolGraph library with a new entry point to get a graph
for a single symbol, and to additionally support type substitution to match the
existing CursorInfo behavior (e.g. so that when invoked on `first` in
`Array<Int>().first`, the type is given as `Int?` rather than `Element?`).

Resolves rdar://problem/70551509
2020-12-12 14:38:41 +10:00
Ben Barham
68f89d44de [SourceKit] Fix flakey VFS completion tests
These tests relied on timing between completion runs in order to check
that fast completion was working properly for completions in VFS files.
That is, they would assume that two runs happening one after another
without a sleep inbetween would always run fast completion.

However, that's not necessarily the case and there have been cases where
a dependency check happens despite its interval being fairly long
(multi-second).

This change emulates the same behaviour by changing the interval
between 0/100, which should prevent any timing issues.

Resolves rdar://72144331
2020-12-11 09:22:24 +10:00
Ben Barham
34ff514ab1 [SourceKit] Fix flakey completion tests
A previous change updated the checkdep tests to move the sleep before
copying over files. This fixed cases where the modification time would
be the same second as the dependency check. Unfortunately this
introduced a slightly different form of flakiness - if the sleep went
too long, the completion that was meant to re-use the AST would see that
it's time to check dependencies and thus skip the fast completion path.

One fix for that would be to add a smaller sleep before, a longer sleep
after, and increase the dependency check time. That increases the
runtime of the tests even further though, so instead just update the
timestamps manually to be in the past/future in order to invoke the path
we want to test. This also allows a 0 dependency check time (ie. always
check), which makes the tests even faster.

Resolves rdar://71861446
2020-12-10 14:51:55 +10:00
Rintaro Ishizaki
055dc66d3b [Frontend] Recover missing input file by dummy input buffer.
Also, continue trying opening files even if any of primary files are
missing so that the caller can know all files failed to open.

rdar://problem/33757793
2020-12-04 15:23:29 -08:00
Argyrios Kyrtzidis
07bc5ef8de Merge pull request #34798 from bnbarham/allow-errors-asserts
[Serialization] Fix crashes when allowing compiler errors in modules
2020-11-18 10:27:19 -08:00
Ben Barham
b07c06e839 [Serialization] Fix crashes when allowing compiler errors in modules 2020-11-18 12:35:21 +10:00
Ben Langmuir
f219b4a460 Merge pull request #34790 from benlangmuir/71468441
[test] Disable test failing rarely in CI until we can fix it
2020-11-17 16:49:15 -08:00
Ben Langmuir
9b93b54061 [test] Disable test failing rarely in CI until we can fix
rdar://71468441
2020-11-17 13:39:22 -08:00
Slava Pestov
96c9456ee8 Sema: Still diagnose '@objc' even if Foundation was imported
We checked for an import of a module named 'Foundation' before
checking if Objective-C interoperability was enabled, which
would lead to hilarious results.

Fixes <https://bugs.swift.org/browse/SR-13713> / <rdar://problem/70140319>.
2020-11-17 14:54:34 -05:00
Ben Barham
b0577b0641 Merge pull request #34472 from bnbarham/benb/allow-errors-69815975
[Serialization] Add an option to output modules regardless of errors
2020-11-11 08:30:18 +10:00
Ben Langmuir
51a75b7443 [test] Fix test/SourceKit/CursorInfo/invalid_offset
This test was intended to catch a crash on invalid offset, but in rare
cases it was failing spuriously, because the error message depends on
non-deterministic behaviour. It's sufficient for this test that it
doesn't crash.

rdar://63187529
2020-11-10 09:13:24 -08:00
Ben Barham
241559dc88 [Serialization] Add an option to output modules regardless of errors
Adds a new frontend option
"-experimental-allow-module-with-compiler-errors". If any compilation
errors occur while generating the .swiftmodule, this mode will skip SIL
entirely and only serialize the (likey invalid) AST.

This existence of this option during generation is serialized into the
resulting .swiftmodule. Errors found in deserialization are only allowed
if it is set.

Primarily intended for IDE requests (eg. indexing and code completion)
to ensure robust cross-module results, despite possible errors.

Resolves rdar://69815975
2020-11-10 14:47:22 +10:00
Anthony Latsis
4ce7a2d060 CodeCompletion: Annotate archetypes, generic parameters and dependent members 2020-10-27 14:39:52 +03:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
6a40a3a8aa [SE-0289] Add support for @resultBuilder.
"Function builders" are being renamed to "result builders". Add the
corresponding `@resultBuilder` attribute, with `@_functionBuilder` as
an alias for it, Update test cases to use @resultBuilder.
2020-10-20 13:24:51 -07:00
Alexis Laferrière
b87fd1230b [Index] Update test related to reporting extensions in system modules 2020-10-17 15:27:36 -07:00
Alexey Komnin
8615904f76 SR-13490: fix tests to align with new import sorting algorithm 2020-09-29 23:54:30 +03:00
Slava Pestov
85ae227465 ASTScope: Remove hacks for PatternBindingDecls with invalid source ranges 2020-09-22 02:06:32 -04:00
Slava Pestov
fa4f7dd664 Parse: Don't create PatternBindingDecls with overlapping source ranges
This was happening in the error recovery path when parsing accessors
on a pattern binding declaration that does not bind any variables, eg

let _: Int { 0 }
2020-09-22 00:16:54 -04:00
Rintaro Ishizaki
84f0c5723a [CodeCompletion] Calculate type relation when adding type annotation
Calculate and set the type relation in each result building logic which
knows the actual result type.

CodeCompletionResultBuilder couldn't know the actual result type. From
the declaration alone, it cannot know the correct result type because it
doesn't know how the declaration is used (e.g. calling? referencing by
compound name? curried?)
2020-09-16 22:04:50 -07:00
3405691582
88167e74d1 [test] diff --strip-trailing-cr is non-standard.
This flag is a GNU extension, and would cause misleading test failures
on other platforms where this extension is not available. However, the
necessity to switch line endings is only required on Windows when
testing. We could use sed to canonicalize line endings before comparing,
but that may cause higher amounts of filesystem traffic on Windows which
would slow down testing.

Instead, move the substitution for diff in SourceKit's lit.local.cfg up
to the top level, and conditionalize the substitution which has the flag
on Windows, but not on other platforms (where it should not be required).
2020-09-13 13:50:15 -04:00
Nathan Hawes
a1ef6e4dac Merge pull request #33749 from nathawes/new-member-completion
[CodeCompletion] Update member completion to handle ambiguous and invalid base expressions
2020-09-09 18:51:22 -07:00
Rintaro Ishizaki
77b4f75608 [SourceKit] Reorgantize code completion options
* Abolish 'reuseastcontext' per-request option
* Add 'MaxASTContextReuseCount' global configuration
2020-09-03 19:30:05 -07:00
Nathan Hawes
3850417035 [Test][CodeCompletion] Consistently check for the 'unknown' type relation when there's no expected type.
The tests were matching the previous implementation's output, which sometimes produced 'unknown' and sometimes 'unrelated' in cases where there was no expected type from the context.
2020-09-01 13:25:37 -07:00
Nathan Hawes
03b5296f70 [test] Update code completion test with improved type relation result. 2020-08-28 22:24:24 -07:00
swift_jenkins
466b0eee6e Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-26 14:16:52 -07:00
Rintaro Ishizaki
bf5fb4d2bb [CodeCompletion] Don't update VFS content hash map after each completion
This was not needed. The list of depenencies should not be changed
during fast-completion sessions.

This was also harmful because it calls stat(2) for all the dependency
files.

rdar://problem/67773257
2020-08-26 09:56:36 -07:00
swift_jenkins
9ab003bcf9 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-14 15:14:01 -07:00
Rintaro Ishizaki
f4ae514802 Merge pull request #33475 from rintaro/ide-completion-inactiveifconfig-rdar67027408
[CodeCompletion] Parse #if block containing CC token as active
2020-08-14 15:02:09 -07:00
Rintaro Ishizaki
dd6046ba16 [CodeCompletion] Stop recording interface hash when searching CC token 2020-08-14 10:33:53 -07:00
swift-ci
670f798134 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-13 15:43:17 -07:00
Ben Barham
77c70e9fe6 [SourceKit/CodeFormat] Indent lines in multi-line strings
When the multi-line string is unterminated, the indentation of a line
will be the same as the first previous line that had contents, unless
that line is the line containing the start quotes. In that case the
indentation will be:
  - the same as the start quote indentation, if the quotes are the only
    contents on the line, or
  - an extra indentation level to the start quote line otherwise

Lines within a terminated multi-line string or lines with content will
only ever be indented if their current indentation is invalid (ie. their
indentation level is less than that of their end quotes).

This rule is to prevent any signficant (and possibly unintended)
whitespace being added to existing strings during a whole file/range
format - Xcode does not remove whitespace from whitespace-only lines by
default. This could be improved if the reformat was sent the actual
range rather than a line at a time. Different indentation could then be
chosen if the range was in fact a single line.

Resolves rdar://32181422
2020-08-13 12:35:57 +10:00
swift-ci
bab4706e94 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-30 14:03:22 -07:00
Rintaro Ishizaki
facabd8010 Merge pull request #33200 from rintaro/ide-completion-rdar66301353
[CodeCompletion] Fix issue in dependency checking for the editing file
2020-07-30 14:02:03 -07:00
Rintaro Ishizaki
2f4dcf3e2f [CodeCompletion] Fix issue in dependency checking for the editing file
'SM.getCodeCompletionBufferID()' returns the buffer ID of the previous
code completion. 'CI.getCodeCompletionFile()->getBufferID()' always
returns the original source buffer ID of the current file in the main
module. The latter is needed for excluding buffer ID for dependency checking.

rdar://problem/66301353
2020-07-30 09:27:58 -07:00
swift-ci
a76254f2ff Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-30 09:03:30 -07:00
Argyrios Kyrtzidis
324ccb576e [SourceKit] Fix issue where CompletionCheckDependencyInterval is set to 0 when the global config request is sent
Fixes rdar://66309544
2020-07-29 21:44:09 -07:00
swift-ci
c22b1f580b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-21 16:24:01 -07:00
Nathan Hawes
f7820f5a35 Merge pull request #33031 from nathawes/dont-synthesize-extension-members-in-subclasses
[SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
2020-07-21 16:09:41 -07:00
Nathan Hawes
e68ab1da8e [SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
The Base class already includes them, so don't duplicate them in its
subclasses. Also stops us including members from extensions of the base class
itself.

Resolves rdar://problem/50960433
2020-07-21 11:53:06 -07:00
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
Rintaro Ishizaki
a6b9815d07 Merge pull request #32946 from rintaro/ide-completion-rdar65692922
[CodeCompletion] Fast completion inside function builder function
2020-07-17 11:27:08 -07:00
Rintaro Ishizaki
e953e523a0 [CodeCompletion] Fast completion inside function builder function
`PreCheckFunctionBuilderRequest` applies `PreCheckExpression` to the
expressions inside the function body. Previously it used to receive only
`AnyFunctionRef` (`FunctionDecl` or `ClosureExpr`) as the parameter.
However, when fast-completion kicks-in, it replaces the body of the
function, then tries to call `PreCheckFunctionBuilderRequest` again, with
the same function decl as before. It used to return cached "Success"
result, but it didn't actually apply `PreCheckExpression`. So any
`UnresolvedDeclRefExpr` remained unresolved.

In this patch, make `PreCheckFunctionBuilderRequest` receive "body" of the
function as well, so it doesn't return the cached result for the *previous*
body.

rdar://problem/65692922
2020-07-16 23:38:49 -07:00
Ben Langmuir
209a7b3813 Revert "Merge pull request #32628 from benlangmuir/sema-repeat"
This reverts commit 35eab3e3a8, reversing
changes made to d5a549a9e4.

This caused an unexpected regression.

rdar://65554791
2020-07-14 17:00:02 -07:00
Rintaro Ishizaki
185317f722 Merge pull request #32779 from rintaro/ide-completion-closureplaceholder-rdar63607976
[PlaceholderExpansion] Omit return type in closure signature
2020-07-09 21:20:25 -07:00