Commit Graph

1494 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
231add1c2e [SourceKit] Ignore the index-store-path flag for the sourcekitd requests
It was active for clang PCH/module creation coming from sourcekitd which was unnecessary index-store data creation.
2017-07-06 11:04:19 -07:00
Xi Ge
b8cf32f1e9 Revert "[syntax-coloring] Rework the syntax map to use offset + length and simplify the delta logic" (#10633)
Resolving rdar://32988175.
2017-06-27 12:28:41 -07:00
Harlan
e89e7f58b2 [Parse] [Syntax] Simplify TupleTypeRepr parsing and add attributes for Syntax (#8298)
* Simplify TupleTypeRepr parsing

This patch introduces a TupleTypeReprElement struct that holds the
locations for all relevant bits of tuple elements. It removes the
NameLoc and UnderscoreLoc arrays from TupleTypeReprElement in favor of
holding each of these on TupleTypeReprElement. These extra bits of info
are required for full-fidelity representation in the Syntax library.

* Remove TupleTypeReprBitfields and move EllipsisLoc out of TrailingObjects

* Update users of TupleTypeRepr

* Don't resize the elts if we're going to push_back

* getType -> getElementType

* Move ellipsis back into TrailingObjects.

* Move NumElements into TupleTypeReprBitfields
2017-06-27 10:54:47 -07:00
Xi Ge
63aeb0123e SourceKit: Refactor Kinds UIDs to ProtocolUIDs.def. (#10604)
"Kind" is a frequently appearing concept in SourceKitD. This patch
refactors the definitions of these "Kinds" and their associated values
 into the single protocol file. Ideally, we should structurally define Kinds instead of this
flat list.
2017-06-27 10:51:48 -07:00
Xi Ge
351ffabf1a CursorInfo: silence a warning after recently introducing a new enum case. (#10412) 2017-06-20 15:32:27 -07:00
Argyrios Kyrtzidis
0cfc56ec04 [SourceKit] If diagnostics are 'stale' for a particular snapshot then ignore them and only return the syntactic parser diagnostics (#10388)
This makes sure that diagnostics returned for a particular state of source buffer are consistent and accurate.
rdar://32769873
2017-06-20 12:26:32 -07:00
Xi Ge
1ea4d9ff98 CursorInfo: Teach SemaLocResolver to recognize the start of an expression, if the location cannot be further refined to other kind, e.g. a reference. rdar://32749670 2017-06-19 13:28:36 -07:00
Nathan Hawes
9ec658ae7f Merge pull request #10289 from nathawes/rdar32148117-multiline-syntax-coloring-issues
[syntax-coloring] Rework the syntax map to use offset + length and simplify the delta logic
2017-06-19 13:26:26 -07:00
Nathan Hawes
3791e12895 [syntax-coloring] Remove early exit from delta logic when there are no new highlighted tokens but are removed ones, and take account of the range of the mismatching token in the previous syntax map
We still need to adjust the affected range to the line boundaries and return all
tokens on the line when there are no new tokens, as the client will clear all
tokens on that line in its copy of the syntax map leaving the other tokens
unhighlighted. We also need to extend the affected range to include the ranges
of the mismatched tokens from the previous syntaxmap, so their highlighting will
be cleared.

Also add more comments to better document the new syntax map structure and
behaviour.
2017-06-19 11:45:08 -07:00
Ben Langmuir
61a151989a [code-completion] Add filter rules for description in addition filter-name
The filter name isn't helpful if you want to make rules about specific
overloads - e.g. only show the [Int] subscript on Array.

rdar://problem/28920034
2017-06-15 16:32:29 -07:00
Nathan Hawes
1158137d95 [syntax-coloring] Fix incorrectly reporting a no-op when a token is removed 2017-06-15 13:16:04 -07:00
Nathan Hawes
09cb55ebf3 [syntax-coloring] Rework the syntax map to use offset+length rather than start/end line+column and simplify the delta logic
This patch changes the syntax map data structure it uses to be offset based
rather than line/col based in order to avoid calling getLineAndColumn for the
start and end offset of every token. This removes the 30% of time spent in
getLineAndColumn for this request in large files (rdar://problem/28965123).

The logic for returning the affected range and the token ranges to highlight
following an edit also made several assumptions that no longer hold. This
patch changes it to compare the syntax maps from before and after the edit,
find the first mismtaching tokens from the start and end of the syntax maps
and return the tokens in that range (adjusted to line boundaries). This fixes
syntax highlighting issues with interpolated multi-line strings
(rdar://problem/32148117) and block comments.

With the above changes the per-keystroke time spent for syntax highlighting
(with sematic info disabled) dropped from ~80ms to just under 50ms for a
12KLOC file.
2017-06-15 13:15:43 -07:00
Robert Widmann
3e2bbfe904 [Gardening] Cleanup TokenKinds.def (#10034)
* [Parse] Refactored internal structure of Tokens.def and documented usage.

Added a level of structure to the macro definitions to allow Swift
keywords to be cleanly accessed separately from SIL and Swift keywords
together. Documented structure and usage.

* [Parse] Made use of new guarantees and abstractions in Tokens.def

Used guarantees about undefining macros after import and new
SWIFT_KEYWORD abstraction to simplify usage of the Token.def
imports.

* Gardening
2017-06-01 15:08:48 -07:00
Alex Hoppen
58c956a29a [Misc] Preparations for removal of getName on ValueDecl
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:13:24 -07:00
Jordan Rose
c0ccdb1626 Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName`
instead of an `Identifier`. All places that will continue to be
expecting an `Identifier` are changed to call `getBaseIdentifier` which
will later assert that the `DeclName` is actually backed by an
identifier and not a special name.

For transitional purposes, a conversion operator from `DeclBaseName` to
`Identifier` has been added that will be removed again once migration
to DeclBaseName has been completed in other parts of the compiler.

Unify approach to printing declaration names

Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:55:03 -07:00
Nathan Hawes
e5426ecfa5 Revert "[SyntaxColor] Improve highligting of multiline strings"
This reverts commit 86d0fc37bc.
This was causing a performance regression.

Resolves rdar://problem/32434045
2017-05-26 16:46:03 -07:00
Robert Widmann
4f35068772 Implement @_downgrade_exhaustivity_check
Dispatch requests the ability to add a new case, but to treat missing
instances of that case in patterns as warnings instead of errors.  It is
still an error to make reference to the annotated case in at least one
pattern then not cover the rest of the space, but it is not an error
to omit the space of patterns referencing the case entirely.

This attribute is private and uglified to intentionally discourage
its use outside just this one use case.
2017-05-25 12:51:17 -07:00
Argyrios Kyrtzidis
8f8c87ef41 Merge pull request #9854 from akyrtzi/sourcekit-sil-diags-opts
[SourceKit] Make sure to propagate the SIL options from the compiler invocation when doing performSILGeneration() to get the SIL diagnostics
2017-05-22 19:54:24 -07:00
Argyrios Kyrtzidis
323c07e562 [SourceKit] Make sure to propagate the SIL options from the compiler invocation when doing performSILGeneration() to get the SIL diagnostics
rdar://32329669
2017-05-22 18:27:41 -07:00
Nathan Hawes
56fb4a5d9f [SyntaxColor] Improve highligting of multiline strings
Multiline strings (and multiline tokens in general) were not well supported by the existing highlighting logic. Edits
on one line can make tokens appear/disappear on previous and later lines, which broke assumptions in the existing
logic, and left odd ranges of source unhighlighted or out of date. This patch accounts for these changes, and also
changes unterminated  multiline (and regular strings) to still be highlighted as strings, so the rest of the
file doesn't look like plain text.

Resolves rdar://problem/32148117.
2017-05-22 16:53:32 -07:00
Xi Ge
d6b4c3e77b RangeInfo: unbox switch statement to ensure all branches agree on return information. rdar://32289109 (#9788) 2017-05-19 14:36:56 -07:00
Xi Ge
83183abc38 RangeInfo: Add a new range info kind that describes part of a parent expression. rdar://32039874 (#9707) 2017-05-17 14:21:47 -07:00
Xi Ge
9c6e3bd398 RangeInfo: Use CharSourceRange to represent the selected range, NFC. rdar://32225277 (#9660) 2017-05-16 15:45:30 -07:00
Ben Langmuir
c89d024cd2 [sourcekitd] When searching for a clang decl, look at overrides
Allows us to do name-transation on an override of a clang decl.

rdar://problem/32187817
2017-05-14 15:05:35 -07:00
Ben Langmuir
8aaf2d64ed [sourcekitd] Take the colons out of name-translation API
This makes us more lenient about what we accept for Objective-C
selectors by allowing you to include or not include the trailing colons.
We don't actually need that information, because we have access to the
declaration, so it was only being used for validation, which made the
API harder to use for clients that didn't carefully track zero vs
one-arg selector names.

Also remove the colons from the response, and instead add a bit to say
whether it is a zero-arg or one-arg selector.  This makes the response
easier to use for clients that don't care about this information, and
more consistent with the change to the input.

rdar://problem/32177934
2017-05-14 09:57:12 -07:00
Ben Langmuir
773434416f Merge pull request #9395 from benlangmuir/no-cancel-cursor
[cursor-info] Add a way to opt out of automatic request cancellation
2017-05-08 13:28:55 -07:00
Xi Ge
166d388de0 RangeInfo: stuff a bit about whether the selected range exits. (#9389) 2017-05-08 13:28:32 -07:00
Ben Langmuir
d13b1c719f [cursor-info] Add a way to opt out of automatic request cancellation
The OncePerASTToken machinery lets us automatically cancel "stale"
requests after a new one comes in.  This avoid wasting time processing
requests that have been superceded, which is common for cursor-info, but
sometimes you really want to get results even later, so this commit adds
a way to opt out of the cancellation.

Incidentally, disable cancellation of name translation, which doesn't
really make sense and no one should be relying on that.

rdar://problem/31905379
2017-05-08 12:01:33 -07:00
Michael Gottesman
86620aaa7e Merge pull request #9318 from practicalswift/redundant-types-in-casts
[gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
2017-05-05 13:37:12 -07:00
Ben Langmuir
651bb4c506 [cursor-info] Tweak check to not report parent_loc on locals in body
We were checking only for the specific loc of the declaration of the
param, but that didn't handle references to a local parameter inside the
body.

rdar://problem/32019195
2017-05-05 10:51:30 -07:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
Argyrios Kyrtzidis
896c4645df [SourceKit] Accept swift_version in requests and use to set the swift version for interface generation of an ObjC header
rdar://31432960
2017-05-04 16:53:00 -07:00
Xi Ge
e9f014a446 [SourceKit] Avoid reporting parent locations for internal only parameter names. rdar://30702790 2017-05-04 12:57:14 -07:00
Argyrios Kyrtzidis
40c89048ba [index] Make sure that we index implicit constructors
These can be explicitely referenced so we should index their definitions as well
2017-04-29 19:14:03 -07:00
Norio Nomura
3da7926a5e Revert "Revert "Enable SourceKit tests if building SourceKit""
This reverts commit a383adf9df.
2017-04-26 21:16:36 +09:00
Ben Langmuir
7e5dd1fa01 [sourcekitd] Allow mising name pieces preferred names
With the interpretation that they mean to retain whatever the name
piece was in the original name.
2017-04-25 15:25:53 -07:00
Arnold Schwaighofer
a383adf9df Revert "Enable SourceKit tests if building SourceKit" 2017-04-24 17:59:03 -07:00
Alex Blewitt
71987b90b2 Merge pull request #8485 from norio-nomura/enable-sourcekit-test
Enable SourceKit tests if building SourceKit
2017-04-24 17:37:30 +01:00
practicalswift
797c2d8118 [gardening] Fix end of namespace comments 2017-04-20 22:01:01 +02:00
practicalswift
5b9267b8b4 [gardening] Use override as appropriate 2017-04-20 13:47:10 +02:00
practicalswift
a596961187 [gardening] Make parameter name comments match actual parameter names 2017-04-20 13:47:10 +02:00
practicalswift
431e5a1440 [gardening] Use consistent end of namespace comments 2017-04-20 13:47:10 +02:00
practicalswift
b8ca098949 Merge pull request #8742 from practicalswift/gardening-20170413
[gardening] Use consistent headers. Remove redundant includes. Remove unused methods. Fix typos, etc.
2017-04-15 18:59:30 +02:00
Maxwell Swadling
93d485e4f7 Changed handleDiagnostic to take a format string and format args instead of the formatted string
This allows diagnostic consumers to modify the way formatting of diagnostics is performed.
rdar://problem/31305854
2017-04-14 11:28:04 -07:00
practicalswift
40cf4d183d [gardening] Use consistent spacing after if, for and while 2017-04-14 17:35:36 +02:00
Slava Pestov
d49f8fb6d9 AST: Introduce primitive AnyObject type
Add a 'hasExplicitAnyObject()' bit to ProtocolCompositionType
to represent canonical composition types containing '& AnyObject'.

Serialize this bit and take it into account when building
ExistentialLayouts.

Rename ProtocolCompositionType::getProtocols() to getMembers()
since it can contain classes now, and update a few usages that
need further attention with FIXMEs or asserts.

For now, nothing actually constructs these types, and they will
trigger arounds asserts. Upcoming patches will introduce support
for this.
2017-04-13 21:17:05 -07:00
swift-ci
03edb54884 Merge pull request #8677 from nkcsgexi/report-submodule 2017-04-10 18:25:06 -07:00
Xi Ge
a6f14faca6 SourceKit/DocSupport: Report sub-module information, if any, for top-level decls imported from clang. rdar://31415030 2017-04-10 17:48:50 -07:00
Norio Nomura
8ca7c1dd80 [SourceKit] Fix “Assertion `!GlibcModuleMapPath.empty()' failed” on Linux
https://bugs.swift.org/browse/SR-4490
2017-04-07 16:28:03 +09:00
Norio Nomura
278c9de5d4 [SourceKit] Fix doc_swift_module*.swift test fails on Linux
https://bugs.swift.org/browse/SR-4490
2017-04-07 16:28:01 +09:00