Commit Graph

115 Commits

Author SHA1 Message Date
Xi Ge
243ec5ac86 Name translation: Allow type name translation when cursor points to constructor call. rdar://33163114 (#10872) 2017-07-11 12:46:52 -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
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
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
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
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
Xi Ge
e9f014a446 [SourceKit] Avoid reporting parent locations for internal only parameter names. rdar://30702790 2017-05-04 12:57:14 -07: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
practicalswift
797c2d8118 [gardening] Fix end of namespace comments 2017-04-20 22:01:01 +02:00
practicalswift
a596961187 [gardening] Make parameter name comments match actual parameter names 2017-04-20 13:47:10 +02:00
Nathan Hawes
534ec7ed87 Merge pull request #8569 from nathawes/rdar30248264-cursorinfo-invalid-base-type
[cursor-info] Fix crash due to invalid base type in the PrintOptions passed to the AST printer
2017-04-06 17:11:33 -07:00
Nathan Hawes
53e1bdc1e3 [cursor-info] Fix crash due to invalid base type in the PrintOptions passed to the AST printer
Resolves rdar://problem/30248264
Also added test cases for rdar://problem/30292429 (already fixed)
2017-04-06 16:04:07 -07:00
Xi Ge
1fcbc90f5f [SourceKit] Use offset to indicate the locations of parameters' parents to facilitate subsequent cursor-info requests. 2017-04-04 17:32:30 -07:00
Xi Ge
f669afff50 [SourceKit] When reporting the cursor info for parameter decls, report the locations of the function-like entities they belong to. rdar://30702790 (#8541) 2017-04-04 15:24:36 -07:00
swift-ci
a460cbbd28 Merge pull request #8516 from nkcsgexi/asan-scope 2017-04-03 16:26:22 -07:00
Xi Ge
6f6d4fc50e SourceKit: Fix a stack-use-after-scope issue found by ASAN. rdar://31117311 2017-04-03 15:10:33 -07:00
Xi Ge
9e76187829 SourceKit: Simplify some unnecessary vector size initializations. NFC (#8502) 2017-04-03 13:51:37 -07:00
Xi Ge
1827fb1436 RangeInfo: Report RValue type if a decl reference is of read-only LValue type. (#8300) 2017-03-23 15:52:54 -07:00
Alex Hoppen
1b7055db5a [Gardening] Change calls of getName().isOperator() to isOperator() 2017-03-10 09:06:20 +00:00
practicalswift
3367d05ee2 [gardening] Remove unused variable OverUSROffs 2017-02-24 09:38:00 +01:00
Xi Ge
c62ec0c116 SourceKit: Introduce a new enum class to describe the kind of resolved sema token kind. NFC (#7657) 2017-02-20 23:18:54 -08:00
Xi Ge
03a17e1f06 Cleanup: Move Swift to ObjC name translation API to libAST to allow larger audience body. NFC (#7586) 2017-02-17 22:09:25 -08:00
David Farler
677e03df85 [SourceKit] Vend the localization key found in documentation comments
If a documentation comment has a - LocalizationKey: field, strip it
out of the documentation body and report it in cursor/doc info with
the key "key.localization_key".

rdar://problem/30383329
2017-02-17 17:54:15 -08:00
Xi Ge
b1c5c995a1 [IDE][Utils] Add an IDE stream utility. (#7546)
This provides a stream utility for writing to a underlying string buffer multiple string pieces and retrieve them later as StringRef when the underlying buffer is stable.
2017-02-16 17:29:42 -08:00
Xi Ge
143c5a5d82 Address @jrose-apple's code review comments (#7474) 2017-02-14 18:41:21 -08:00
Xi Ge
055da1fbfb [SourceKit] Teach name translation request to translate Swift names to ObjC ones (by using PrintAsObjC). (#7449) 2017-02-14 14:25:52 -08: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
Xi Ge
6b699d8855 SourceEntityWalker: keep track of type reference in extension declarations' openings. (#7192)
This is necessary when we want to differentiate between type reference
on extension declaration's start, e.g "extension A {}", and other
references of "A". NFC on existing functionality.
2017-02-01 17:09:01 -08:00
Argyrios Kyrtzidis
da1328f04b [sourcekit] Fix assertion hit when doing cursor-info on a subscript parameter declaration.
Fixes rdar:/30060622
2017-01-17 14:56:36 -08:00
Brian Gesiak
663b92ece9 [AST] Completely replace Module with ModuleDecl
The typedef `swift::Module` was a temporary solution that allowed
`swift::Module` to be renamed to `swift::ModuleDecl` without requiring
every single callsite to be modified.

Modify all the callsites, and get rid of the typedef.
2017-01-08 00:36:08 -05: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
Xi Ge
14f968a5ed SourceEntityWalker: Add a parameter to visitDeclReference() describing the kind of the reference under visit. NFC 2016-12-20 14:30:02 -08:00
Doug Gregor
bcde6567d5 [AST] Introduce DeclContext::mapType(Into|OutOf)Context()
Use them to eliminate some more instances of getSelfTypeInContext().
2016-12-02 15:31:04 -08:00
Slava Pestov
7b59e75d34 IDE: hasType() => hasInterfaceType() 2016-11-29 03:05:31 -07:00
Jiang Jiang
8fc75457c3 [SourceKit] Fix a warning in SwiftSourceDocInfo.cpp
tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp:1042:13: warning: unused variable 'CompIns' [-Wunused-variable]
      auto &CompIns = AstUnit->getCompilerInstance();
            ^
1 warning generated.

Introduced by 5e8d8da380.
2016-11-24 18:29:18 -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
0c95a3bd1d AST: Correctly set PrintAST::CurrentType
When printing a nested type, make sure we call getMemberSubstitutions()
with the correct DeclContext.
2016-11-19 22:53:53 -08:00
Slava Pestov
2e901cb4f9 AST: Clean up PrintOptions a bit 2016-11-19 22:53:53 -08:00
Xi Ge
5e8d8da380 [Test] Add range-info test driver to swift-ide-test. NFC 2016-11-15 13:48:15 -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
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