Commit Graph

295 Commits

Author SHA1 Message Date
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
Xi Ge
7bd01b5ad1 [SourceKit] Never try to report mangled names for archetypes without contexts. rdar://28094209 2016-10-24 16:56:32 -07:00
Xi Ge
0443a4dc46 [SourceKit] for cursor-info request, printing underlying types instead of namelias type. rdar://28216890 (#5339) 2016-10-17 22:18:59 -07:00
Slava Pestov
cfe9e6a3de IDE: Use GenericSignatures and interface types (mostly)
There was a ton of complicated logic here to work around
two problems:

- Same-type constraints were not represented properly in
  RequirementReprs, requiring us to store them in strong form
  and parse them out when printing type interfaces.

- The TypeBase::getAllGenericArgs() method did not do the
  right thing for members of protocols and protocol extensions,
  and so instead of simple calls to Type::subst(), we had
  an elaborate 'ArchetypeTransformer' abstraction repeated
  in two places.

Rewrite this code to use GenericSignatures and
GenericFunctionType instead of old-school GenericParamLists
and PolymorphicFunctionType.

This changes the code completion and AST printer output
slightly. A few of the changes are actually fixes for cases
where the old code didn't handle substitutions properly.
A few others are subjective, for example a generic parameter
list of the form <T : Proto> now prints as <T where T : Proto>.

We can add heuristics to make the output whatever we want
here; the important thing is that now we're using modern
abstractions.
2016-10-02 23:49:15 -04:00
practicalswift
7e89679404 [gardening] Fix recently introduced typos. 2016-07-24 22:32:40 +02:00
Alex Hoppen
4aa6485ba0 [Printer] Rename ArchetypeTransformer to TypeTransformer
The ArchetypeTransformer isn't actually limited to transforming archetypes
but can transform arbitrary types. Thus, we can rename it to TypeTransformer
2016-07-20 10:55:50 +02:00
Ben Langmuir
18be066651 [sourcekit] Synchronize cursor-info requests on generated interfaces
Cursor info requires access to the underlying AST, which is not
thread-safe. This manifest as crashes when performing concurrent
cursor-info requests on the same generated interface. We already
prevented concurrent cursor-infos on regular Swift files by using the
ASTManager, but generated interfaces use the InterfaceGenContext which
may use either an ASTUnit or its own internal CompilerInstance.

rdar://problem/27311624
2016-07-13 16:35:23 -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
David Farler
a9297eed9f Rename llvm::markup namespace to swift::markup
This was naming was cargoed from long ago and this functionality isn't
directly related to LLVM, it's specific to Swift.
2016-04-10 13:46:25 -07:00
swift-ci
5701926d5a Merge pull request #1969 from jpsim/unused-param-printAnnotatedDeclaration 2016-04-09 14:21:46 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Ben Langmuir
4d9c9f6098 Move SourceEntityWalker into libAST NFC
It fits right in among our other AST walkers and lets us use it lower in
the stack than libIDE.
2016-04-01 14:14:06 -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
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
JP Simard
d2662ee71c remove unused parameter in printAnnotatedDeclaration 2016-03-30 17:32:15 -07:00
Xi Ge
33c53a12eb ASTPrinter: Pass the bracket options to pre and post printing callbacks.
Need this for rdar://24912860
2016-03-22 14:49:22 -07:00
Xi Ge
3dd149ab99 [SourceKit] CursorInfo: The result of cursor info for a module name starts to include group names in that module. 2016-03-21 17:20:18 -07:00
Ben Langmuir
187bc9fbb9 [CursorInfo] Annotate tuple types in fully annotated decl
We already annotate the elements, this just adds annotations around the
outer parentheses, including when the tuple is unit.

rdar://problem/25147925
2016-03-21 16:31:52 -07:00
Xi Ge
2c75cfba39 [SourceKit] Similar with what we do for module printing, for quick help, elevate the doc-comment from conformances if the decl itself does not have associated doc-comment. rdar://24409720 2016-03-21 15:05:02 -07:00
Ben Langmuir
47d2c24078 [IDE] Factor code that looks up USRs into getDeclFromUSR 2016-03-16 15:43:02 -07:00