Commit Graph

58 Commits

Author SHA1 Message Date
Alex Hoppen
1b8840fcff [incrParse] Perform a full reparse of the file if needed for formatting 2018-07-18 13:35:11 -07:00
Alex Hoppen
57ccdd89b6 [incrParse] Add validation of incremental parsing
If enabled using the environment variable
SOURCEKIT_INCREMENTAL_PARSE_VALIDATION, the incrementally parsed syntax
tree will be compared to the from-scratch parsing syntax tree. If they
differ a warning is emitted and log files showing the difference written
to a temporary directory.
2018-07-18 13:35:11 -07:00
Alex Hoppen
fcc5a6b424 [libSyntax] Enable incremental parsing for syntax tree based syntax coloring 2018-07-17 14:17:58 -07:00
Alex Hoppen
c8a3957ba2 [SourceKit] Add option to force the SyntaxMap to be generated via the syntax tree 2018-07-13 17:57:00 -07:00
Alex Hoppen
6e12a634a1 [SourceKit] Move all options into a common options struct
With more options coming for incremental syntax parsing, the list of
arguments will grow way to large and unhandy, so just extract them into
one common struct.
2018-06-28 20:26:05 -07:00
Vedant Kumar
d910e5a5c2 [SourceKit] Disable expensive SIL options (#17306)
Disable the sanitizers and code coverage when building a swift
invocation for the purpose of collecting diagnostics.

This should speed up diagnostic generation and reduce exposure to
compiler bugs.

rdar://40955900
2018-06-18 14:43:27 -07:00
Ben Langmuir
23ab43c941 [sourcekitd] Change compile notifications to pass a single args string
... instead of an array of compiler arguments. This is good enough
for seeing what's going on, and it saves significant time for long
argument strings, because it doesn't create and destroy so many
xpc strings, and more of the string copying that happens is on a large
contiguous string instead of many small strings.

rdar://39538847
2018-04-19 13:59:27 -07:00
Ben Langmuir
31eae3675b [sourcekitd] Remove XPCTracing
This code was an experiment in how to collect information after a crash,
that did not end up being used.  It's unclear how much it has bitrotted
at this point, since it has no tests and was not designed with automated
testing in mind.  Parts of it interfere with some changes I want to make
to the underlying tracing mechanism, so I am finally removing it.  This
also lets us remove the buffer copying in the parts of tracing used by
the compile notifications, improving performance.

For rdar://39538847
2018-04-19 11:52:38 -07:00
Argyrios Kyrtzidis
455e87bd96 [SourceKit] For the swift header interface request, accept the swift version as a string
This is so we can pass the version as "4.2".

rdar://38673625
2018-03-22 16:32:24 -07:00
Xi Ge
37f352fe41 sourcekitd: build Swift syntax tree more lazily than collecting parsed tokens. (#14578)
Before this patch, we have one flag (KeepSyntaxInfo) to turn on two syntax
functionalities of parser: (1) collecting parsed tokens for coloring and
(2) building syntax trees. Since sourcekitd is the only consumer of either of these
functionalities, sourcekitd by default always enables such flag.
However, empirical results show (2) is both heavier and less-frequently
needed than (1). Therefore, separating the flag to two flags makes more
sense, where CollectParsedToken controls (1) and BuildSyntaxTree
controls (2).

CollectingParsedToken is always enabled by sourcekitd because
formatting and syntax-coloring need it; however BuildSyntaxTree should
be explicitly switched on by sourcekitd clients.

resolves: rdar://problem/37483076
2018-02-13 16:27:12 -08:00
Huon Wilson
cb60dbeee2 [IDE] Teach type checker about conditional conformance extensions.
Before conditional conformances, the archetypes in conformance
extensions (i.e. extension Foo: SomeProtocol) were equivalent to those
in the type decl, with the same protocol bounds and so on. The code for
printing "synthesized" members relied on this fact. This commit teaches
that code to deal with archetypes in the conditional conformance
extension when required.

Fixes rdar://problem/36553066 and SR-6930.
2018-02-13 17:37:15 +11:00
Ben Langmuir
9c7d9235de [sourcekitd] Add a request to get statistics from the service
... and add a few basic statistics about the number of requests, ASTs
built, etc.  The Statistic type is loosely based on the one from LLVM,
but suitable for using without DEBUG macros and using SourceKit UIdents
to identify the statistic.  The easiest way to add a new statistic is to
add it to SwiftStatistics.def in the SwiftLangSupport.
2017-10-05 12:34:49 -07:00
Marcelo Fabri
2bf49b0151 [SourceKit] Add range for attributes in a structure (SR-5587) (#11750) 2017-09-20 15:54:42 -07:00
Xi Ge
7f29b362d6 SourceKitd: Rename SemaToken to ResolvedCursorInfo. NFC (#11680) 2017-08-29 15:34:15 -07:00
Argyrios Kyrtzidis
60a91bb736 [refactoring] Upstreaming the implementation for Swift local refactoring (#11568)
[refactoring] Upstreaming the implementation for Swift local refactoring
2017-08-22 16:50:16 -07:00
Ben Langmuir
0258839815 [code-completion] Add leading-dot completion for enums
When using completion options that will allow the lone "." completion,
provide that result when in contexts that expect an enum type.  Note:
this is a crappy approximationg for whether the type can have "implicit
member expression" syntax, since uninhabited enums should not support
it, and many non-enum types should.  However, it is currently expensive
to compute the accurate answer and this approximation is good enough for
some clients.

rdar://problem/31260505
2017-07-19 11:34:01 -07:00
Nathan Hawes
ecfa9ebfca [interface-gen] Rename AreSwiftArgs -> UsingSwiftArgs throughout 2017-07-13 15:37:17 -07:00
Nathan Hawes
3de0ea7e1b [interface-gen] Support passing Swift compiler arguments for header file interface generation
Resolves rdar://problem/33249361.
2017-07-13 14:21:06 -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
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
0d97dd4992 [SourceKit] Add a new request to translate markup text to its XML equivalence. rdar://30587403 (#8088)
Required fields:
- "key.request": "source.request.convert.markup.xml"
- "key.sourcetext": "markup text"

Expected response:
- "key.sourcetext": "xml text"
2017-03-14 15:13:43 -07:00
Xi Ge
b32424953e [SourceKit] Add a new request to translate from Objc names to Swift names and vice versa.
Extensive cross-language tooling support needs to bridge decl names between two different languages more freely. This SourceKit request is designed to translate Objc names to Swift names and vice versa. Working similarly to cursor-info requisition, the name translation request requires a Swift reference to a Swift/Clang decl, and the preferred name to translate from, and language kind that the given name belongs to. If the translation succeeds, SourceKit service responds with the corresponding name than belongs to the other kind of language.

Newly introduced keys:

“key.namekind": “source.lang.name.kind.objc” | "source.lang.name.kind.swift"
“key.basename”: “name"
“key.argnames”: [“name"]
“key.selectorpieces”: [“name[:]"]

This commit only implements translation from Objc to Swift.
2017-02-10 17:50:12 -08:00
Argyrios Kyrtzidis
db8ec19f55 [index] Use the index symbol types and APIs from the clang header.
This avoids duplication and centralizes handling of symbols.
2017-01-10 14:49:07 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Xi Ge
4fe46c0a77 [SourceKit][CursorInfo] Add two optional fields when configuring curso-infor request, key.length and key.actionable. NFC
This serves as a skeleton for future extensions on cursor info request.
2017-01-04 13:38:25 -08:00
practicalswift
9d0b2abfc2 [gardening] Normalize end-of-namespace comments 2016-12-17 22:29:07 +01: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
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
Luke Larson
74e0498015 Revert "Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs."
This reverts commit 62d1fa760c.
2016-07-19 15:18:17 -07:00
Mishal Shah
62d1fa760c Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-07-19 22:31:34 +02:00
Xi Ge
2a860100a5 [SourceKit] Implement a new SourceKit request to generate the interface for a given type. rdar://27306890 (#3586)
This patch allows SourceKit to generate the interface for a given type specified by its mangled name.
Type interface is refined decl printing with type parameters localized and unusable members hidden.

Required field:
   "key.request": "source.request.editor.open.interface.swifttype"
   "key.usr": the mangled name of the given type.
2016-07-18 18:05:47 -07:00
Xi Ge
a7e4cfd042 [SourceKit] Report container type USRs in the response to cursor-info request.
Typically, users jump to type-specific interface from a member of that type, for
instance, a.getSomething(). To generate the interface, we need to report the USR
of the container type of "getSomething()", which is the USR for the type of a,
 when cursor info is requested for this function call.
2016-07-12 15:50:18 -07:00
Xi Ge
a5e51a3494 [SourceKit] In CursorInfo response, include the mangle name of the type of the underlying decl.
The mangled name of the type is identical to those for debugger. These
mangled names allow us to reconstruct the type from AST and generate interface
specifically for that type.

Related rdar://27306890
2016-07-12 13:10:58 -07:00
Brian Croom
fac744067c [SourceKit] Remove dependency of SwiftLang on Core 2016-06-22 13:04:37 -04:00
Argyrios Kyrtzidis
af21c7d4b1 [SourceKit] Move UIDsFromDeclAttributes function to SwiftLangSupport header so it can be re-used, NFC. 2016-05-05 16:44:34 -07:00
Ben Langmuir
6096b8b93c [index] Make IndexSymbol's subkind into a bitset
This follows a similar change to clang indexing, and will allow us to
add overlapping sub kinds such as "UnitTest", etc.
2016-04-29 19:04:26 -07:00
Ben Langmuir
ad269b0e1f [index] Move core indexing code out of SourceKit
Leaving only the SourceKit-specific code (e.g. UID generation) behind in
SourceKit.

rdar://problem/22348041
2016-04-14 13:13:54 -07:00
Ben Langmuir
bfa5a1f67f [index] Factor out the dependency between the core indexing walker and SourceKit
The goal is to be able to move the core IndexSwiftASTWalker code out of
SourceKit, leaving only the serialization bits behind.

Mostly this replaces some direct uses of UIdent strings with explicit
enums, and then adds the translation code to produce those enums and to
convert them into UIdents in SourceKit.

rdar://problem/22348041
2016-04-14 13:13:49 -07:00
Xi Ge
adc65bf609 [SourceKit] DocInfo: Simplify the type parameter names inside fully annotated decls. 2016-04-01 11:55:06 -07:00
Xi Ge
8afcf65fa2 [SourceKit] DocInfo: Update the UIdent for synthesized extensions to respect the synthesized targets instead of the original extended types. 2016-03-31 18:12:53 -07:00
Xi Ge
16a23d79b4 [SourceKit] DocInfo: Update the printed doc comment for synthesized extensions therefore it reflects the synthesized targets explicitly. rdar://25439820 2016-03-31 17:53:21 -07:00
Xi Ge
fda0751cae [SourceKit] In interface-gen request, allow clients to send SourceKit an interested USR from which we can infer the group name. 2016-03-23 17:26:44 -07:00
Ben Langmuir
65719e8ce0 Merge pull request #1686 from regnerjr/swift-format_SR-146
[SourceKit] Move Code Formatting Logic to libIDE
2016-03-21 13:52:09 -07:00
John Regner
e63678579b [SourceKit] Moved Formatting files into place in libIDE 2016-03-18 21:19:57 -07:00
John Regner
43cc6ffafc [SourceKit] Move to functions swift::ide namespace
Moved getTrimmedTextForLine &  getExpandedIndentForLine
This help reduce the coupling to SwiftEditor Document and allows us
to format any text, whether or not is currently in an editor doc.
2016-03-18 20:58:17 -07:00
John Regner
3283a8cc03 [SourceKit] Pass Text around more.
This helps de-couple us from the Swift Editor Document.
2016-03-18 20:51:18 -07:00
John Regner
8f728f31ad [SourceKit] Decouple SwiftEditorDocument from Formatting
Move FormatContext & FormatWalker into new file.
Move CodeFormatOptions out of SwiftEditorDocument.
Move functions getTrimmedLineOffset & getLineOffset
out of SwiftEditor Document.
Rename Offset of Line functions
Declaring that the get the offset of some line index is more clear.
2016-03-18 20:51:16 -07:00
Ben Langmuir
d36708838b [SourceKit] Allow cursorinfo to take a USR instead of an offset
This eventually calls the code from ReconstructType to try to find the
Decl for a USR. For now, only works in a file, not a generated
interface.

rdar://problem/25017817
2016-03-16 09:42:02 -07:00
Ben Langmuir
1a83912c4e [SourceKit] Add fully annotated declaration to DocInfo requests
Also expose the printing function as a SwiftLangSupport static method.
Ideally we could move this into libIDE, but it currently depends on the
UIdent visitor to get decl-specific tag names and it's not obvious how
we should hoist/abstract that out in a nice way.

rdar://problem/24292226
rdar://problem/24292304
2016-02-25 20:12:13 -08:00
Xi Ge
dfd0a86986 [SourceKit] Teach SourceKit to recognized USRs for synthesized extensions.
So that IDE can jump to the synthesized extensions instead of the actual extensions.
2016-02-16 17:22:58 -08:00