Commit Graph

1994 Commits

Author SHA1 Message Date
Slava Pestov
087fe173eb IDE: Rework TypeReconstruction to not rely on PolymorphicFunctionType 2016-11-29 03:05:33 -07:00
Slava Pestov
7b59e75d34 IDE: hasType() => hasInterfaceType() 2016-11-29 03:05:31 -07:00
Slava Pestov
6c63514bb4 IDE: getType() => getInterfaceType() 2016-11-29 03:05:26 -07:00
Slava Pestov
69e7cca64f AST: Remove ConstructorDecl::getResultType() 2016-11-29 03:05:22 -07:00
practicalswift
0b34f20318 Merge pull request #5962 from practicalswift/add-missing-license-headers
[gardening] Add missing licensing headers.
2016-11-29 09:40:39 +01:00
practicalswift
5bc293cc09 [gardening] Add missing licensing headers. 2016-11-28 21:40:06 +01:00
Doug Gregor
e656ca1dbc [AST] Compress ArchetypeType's storage slightly.
The "associated type" and "name" fields are mutually independent,
because one can recover the name from the associated type.
2016-11-28 11:25:45 -08:00
Graydon Hoare
7c1dc18b64 Revert "Give all declarations an explicit interface type" 2016-11-24 09:55:27 -08:00
Slava Pestov
6db43138fa AST: Remove ConstructorDecl::getResultType() 2016-11-24 02:35:30 -05:00
practicalswift
2fe4254cb7 Merge pull request #5878 from practicalswift/https-swift-org
[gardening] Use the correct base URL (https://swift.org) in references to the Swift website
2016-11-22 09:17:57 +01:00
swift-ci
597b6b4254 Merge pull request #5807 from benlangmuir/cc-invalid-op 2016-11-20 11:36:11 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Slava Pestov
2e901cb4f9 AST: Clean up PrintOptions a bit 2016-11-19 22:53:53 -08: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
c46c423da5 Revert "Fix ASan container-overflow in CodeFormatter"
This reverts commit 430c0abd2f.
2016-11-18 13:23:31 -08:00
Bob Wilson
6ca7872ba5 Merge remote-tracking branch 'origin/master' into master-next 2016-11-16 22:12:23 -08:00
swift-ci
10531cd75d Merge pull request #5829 from bitjammer/syntax 2016-11-16 17:34:20 -08:00
David Farler
430c0abd2f Fix ASan container-overflow in CodeFormatter
I made an overzealous rebase earlier that caused a bad std::vector
iterator to be indirected.
2016-11-16 16:56:14 -08:00
David Farler
ff98e5fd81 Merge pull request #5811 from bitjammer/syntax
Preserve source trivia in the lexer
2016-11-16 11:47:32 -08:00
Bob Wilson
f10ae47b9f Merge remote-tracking branch 'origin/master' into master-next 2016-11-15 17:32:28 -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
Ben Langmuir
5c801752fd [code-completion] Fix a crash on invalid operator decls
We cache failures in the operator maps, so handle null pointers when
walking them for code-completion.

rdar://problem/29275272
2016-11-15 14:35:21 -08:00
Xi Ge
5e8d8da380 [Test] Add range-info test driver to swift-ide-test. NFC 2016-11-15 13:48:15 -08:00
swift-ci
3161a772f4 Merge pull request #5686 from nkcsgexi/range-info-assertion 2016-11-08 12:58:36 -08:00
Xi Ge
0e7b13a96e [SourceKit] Lessen assertion in the range resolver walker to allow early stop. rdar://29159963 2016-11-08 11:22:24 -08:00
Nathan Hawes
a380158ccf Merge pull request #5674 from nathawes/keyword-as-arglabel-syntax-coloring-fixes
[SyntaxColor] Restrict the keywords colored as identifiers to just those that can be used as argument labels
2016-11-08 10:33:52 -08:00
Xi Ge
d6f8f142a7 [SourceKit] Teach range-info request to recognize single declaration and multi-statements. (#5672) 2016-11-07 16:54:48 -08:00
Nathan Hawes
d257f1dd36 [SyntaxColor] Restrict the keywords colored as identifiers to just those that can be used as argument labels. rdar://problem/29098176
Most keywords can be used as argument labels. When they are they shouldn't be
colored as a keyword. This patch fixes three issues with this:
-  keywords as local argument labels (where an external label was also present)
were still colored as keywords
- 'let', 'var', and 'inout' cannot be used as argument labels, but were colored
as identifiers rather than keywords when used like one
- the check to see if a keyword token is being used as an argument label wasn't
quite restrictive enough, e.g. treating the 'let's in 'case (let x, let y):' as
identifiers.
2016-11-07 10:47:04 -08:00
Daniel Duan
e5fc320a21 Merge pull request #5548 from dduan/indent_switch_case_block
[swift-format] add option to indent switch block
2016-11-04 00:35:46 -07:00
Daniel Duan
d0de084a79 [swift-format] add option to indent switch block
add a boolean option to indent switch's block:

```
// with -indent-switch-case
switch xyz {
  case .x:
    doSomething()
}
```

```
// without -indent-switch-case
switch xyz {
case .x:
  doSomething()
}
```
2016-11-03 19:48:41 -07:00
Xi Ge
ac3411234d [SourceKit] The initial implementation of range-info request.
Like cursor-info, range info (""source.request.cursorinfo"") answers some
questions clients have for a code snippet under selection, for instance, the type of a selected
expression. This commit implements this new quest kind and provides two
simple information about the selected code: (1) the kind of the
snippet, currently limited to single-statement and expression; and (2)
the type of the selected expression. Gradually, we will enrich the
response to provide more insight into the selected code snippet.
2016-11-03 16:07:04 -07:00
Ben Langmuir
32f131e9ab [code-completion] Handle func-reference syntax for optional expected type
The underlying type-check was correct, but I forgot to consider it in
the outer code, and embarassingly never tested this case.

rdar://problem/28435922
2016-10-28 13:41:45 -07:00
Bob Wilson
5c4f517824 Checkpoint fixes for llvm r284966 (TimeValue) 2016-10-28 12:09:57 -07:00
Bob Wilson
b227f45b7e Merge remote-tracking branch 'origin/master' into master-next 2016-10-27 22:28:28 -07:00
Ben Langmuir
569687ea07 Merge pull request #5350 from benlangmuir/slow-regex
[sourcekitd] Replace a slow std::regex with custom parsing
2016-10-18 12:45:33 -07:00
Ben Langmuir
f07457834a [sourcekitd] Replace a slow std::regex with custom parsing
This gave a roughly 40-45% improvement in sourcekitd's incremental
syntax-only parse time in files with a lot of doc comments (test case
was ~6000 lines, with ~780 lines being doc comments). This is on the
critical path for every edit.

While there were a few smaller improvements we could have made to the
original code, ultimately std::regex is slow, and it was better to just
use a custom parser for these simple patterns.

rdar://problem/28809397
2016-10-18 11:29:25 -07:00
Bob Wilson
1caba3e209 Merge remote-tracking branch 'origin/master' into master-next 2016-10-17 11:52:21 -07:00
Bob Wilson
36f7c548b8 Use Clang's LangOptions::isCompilingModule accessor.
Clang r279794 changed the LangOpts interface to prevent direct access
to the CompilingModules bitfield.
2016-10-15 11:02:19 -07:00
Doug Gregor
6ce4be96f1 Merge pull request #5261 from DougGregor/type-checker-extra-constraints
[Type checker] Eliminate generation of useless constraints NFC.
2016-10-13 13:40:09 -07:00
Doug Gregor
735ef839e2 [Code completion] Suppress vacuous infix operator completions.
With the previous type-checker change, we end up with some vacuous
infix operator completions, where the right-hand side and result type
are *both* type variables. Suppress these; they aren't useful to the
developer.
2016-10-13 10:16:20 -07:00
Bob Wilson
7a45dd7208 Merge pull request #5263 from bob-wilson/code-completion-failure
Use std::function to fix unsafe use of llvm::function_ref.
2016-10-12 19:42:22 -07:00
Bob Wilson
dfa207b7ae Use std::function to fix unsafe use of llvm::function_ref.
This was exposed by building with a recent version of clang. Without this
change, the following tests were failing:

    Swift(macosx-x86_64) :: IDE/complete_assignment.swift
    Swift(macosx-x86_64) :: IDE/complete_enum_elements.swift
    Swift(macosx-x86_64) :: IDE/complete_stmt_controlling_expr.swift
    Swift(macosx-x86_64) :: SourceKit/CodeComplete/complete_structure.swift

I did not narrow it down to which uses of DeclFilter were problematic.
The global variables certainly do not seem like a good place to use a
function_ref. rdar://problem/28699882
2016-10-12 16:44:11 -07:00
Xi Ge
e5d77911a2 [SourceKit] Indent property getters disregarding of empty bodies. rdar://28049927 (#5246)
[SourceKit] Indentation: when the indented line starts with open brace and the
line before starts with a leading declaration keywords, we never add
indentation level on the brace. rdar://28049927
2016-10-11 19:23:29 -07:00
Xi Ge
4d946f4918 [SyntaxModel] Improve the performance of searching URLs in comments (#5214)
[SyntaxModel] When searching URLs in doc comments, reduce the number of protocol name comparisons by looking ahead more characters, NFC. rdar://28298506

Searching URL in doc comments can be expensive. We used to look for
every colon as an indicator of potential URLs. However, this is not
efficient enough. Suggested by Ben, we further divide protocols into
categories so that most protocols can use "://" as an indicator of its
existence.

Not sure whether this is enough to close the radar, but I believe it is
a valuable performance improvement anyway.
2016-10-10 14:42:40 -07:00
Ben Langmuir
114d836737 Merge pull request #5183 from benlangmuir/cc-inst-curry-ref
[code-completion] Fix type-relation check on implicitly curried instance methods
2016-10-07 15:46:32 -07:00
Ben Langmuir
a6934d1e6d [code-completion] Fix type-relation check on implicitly curried instance methods
We strip the first input type on instance methods like,
struct S { func foo(T) -> U } // (S)->(T)->U

but we should not do that when it's actually a curried instance method,
such as S.foo.
2016-10-07 13:55:13 -07:00
Doug Gregor
50341da32b Use "TypeBase::hasError()" rather than "is<ErrorType>()" where needed.
In most places where we were checking "is<ErrorType>()", we now mean
"any error occurred". The few exceptions are in associated type
inference, code completion, and expression diagnostics, where we might
still work with partial errors.
2016-10-07 10:58:23 -07:00
Doug Gregor
66e20116f2 Extend ErrorType with an "original type" and use it to clean up substitution.
Type::subst()'s "IgnoreMissing" option was fairly unprincipled, dropping
unsubstituted types into the resulting AST without any indication
whatsoever that anything went wrong. Replace this notion with a new
form of ErrorType that explicitly tracks which substituted type caused
the problem. It's still an ErrorType, but it prints like the
substituted type (which is important for code completion) and allows
us to step back to the substituted type if needed (which is used by
associated type inference). Then, allow Type::subst(), when the new
UseErrorTypes flag is passed, to form partially-substituted types that
contain errors, which both code completion and associated type
inference relied on.

Over time, I hope we can use error-types-with-original-types more
often to eliminate "<<error type>>" from diagnostics and teach
Type::subst() never to return a "null" type. Clients can check
"hasError()" to deal with failure cases rather than checking null.
2016-10-06 16:40:28 -07:00
Ben Langmuir
d2e2d5fe84 [code-completion] Complete as function reference when the type matches
If we're completing in a context that expects a function type, try to
match methods/functions as function references before trying them as
calls.  This means that

func take(_: (Int)->()) {}
func foo(a: Int) {}
take(#^A^#)  // completes foo(a:)  instead of foo(a: {#value#})

Note: doesn't yet work with generic types.

rdar://problem/28435922
2016-10-05 14:25:38 -07:00
Enrico Granata
532d106f08 Add enough logic to TypeReconstruction to allow LLDB to discover the type of methods in protocol extensions, such as e.g.
extension Collection {
  func group<Key: Hashable>(f: Key) -> Key {...}
}

I have a matching test case for this over in LLDB
2016-10-05 10:47:49 -07:00