Commit Graph

173 Commits

Author SHA1 Message Date
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
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
1b08d83b6f [SourceKit] Annotate class method dynamic Self return types
Pass through the original Type in addition to the TypeDecl so that we
can distinguish DynamicSelfType with underlying ClassType from just any
old ClassType.

rdar://problem/25158493
2016-03-14 19:43:54 -07:00
Xi Ge
c22e9bcf53 ModulePrinting: Merge synthesized extensions' bodies if they have the common constraints. 2016-03-10 17:50:24 -08:00
Ben Langmuir
e752de0d20 [SourceKit] Print and annotate the raw value expression of enum elements
For now, only do this in SourceKit (printQuickHelpDeclaration), but
there are probably other printing modes that should do this.

rdar://problem/24292226
2016-03-07 12:36:47 -08:00
Ben Langmuir
3d424b5e96 [SourceKit] Annotate tuple types and nested function types
Move the type callbacks into the respective type/typerepr printers so
taht we get these callbacks even when we print the type directly, or in
a nested fashion.  Also make the returntype more explicit than just
"inside a function type", since visiting the function type currently
visits the input argument tuple (which is different than e.g. the
function *decl* printing, which walks the parameter list explicitly).

rdar://problem/24292226
2016-03-07 10:13:01 -08:00
Ben Langmuir
1ea2d46a04 [SourceKit] Add builtin attribute tags
As promised, tag the whole attribute include all of its 'parameters'.

rdar://problem/24292226
2016-03-03 21:20:14 -08:00
Ben Langmuir
ba702b846f [SourceKit] Add tags for attribute names
As a first foray into annotating attribute, add tags around attribute
names. For now, treat any decl-modifiers as keywords. We will also want
to wrap the whole attribute (including any parameters) into tags as
well, but that will require more work in the callback hanlding.

Also factor the attribute printing to handle any special cases early,
which will simplify wrapping attributes in tags, since we can then just
put the whole switch intside the pre/post callbacks.

rdar://problem/24292226
2016-03-03 18:39:21 -08:00
Ben Langmuir
f61a241dfc [ASTPrinter] Rename parameter callback to widen scope NFC
I want to start using this for other things like function types and
attributes, so rename it to reflect the new scope. I'm not really happy
with "PrintStructureKind", etc. but haven't come up with anything
better so far.
2016-03-03 18:39:20 -08:00
Xi Ge
8bde763ba2 IDETypeChecking: make parameter consistently pass reference. NFC 2016-03-03 18:02:13 -08:00
Ben Langmuir
65f0e7eb94 [SourceKit] Add annotation tags for generic type requirements
Each requirement gets tagged. We could also tag the whole where clause
if we need to, but so far it hasn't been interesting.

rdar://problem/24292226
2016-03-03 16:11:07 -08:00
Ben Langmuir
c934315315 [SourceKit] Update terminology in generic parameter tag names
And add a test that does cursor info on the generic parameter itself,
not just on the parent decl context.

rdar://problem/24292226
2016-03-03 13:34:16 -08:00
Ben Langmuir
f848fcb7d1 [SourceKit] Update doc comment for fully annotated decl changes
It's nice to match the actual behaviour.
2016-03-03 12:53:49 -08:00
Ben Langmuir
1182e41e01 [SourceKit] Add tags for generic parameters to annotated decl
Like typerefs, we want to show the USR in the tag.

rdar://problem/24292226
2016-03-03 12:47:09 -08:00
Ben Langmuir
d88d5052aa [SourceKit] Use keyword name context to add syntaxtype.keyword tags
We can now markup most keyword uses.  Still missing access control
keywords.

rdar://problem/24292226
2016-03-02 18:20:59 -08:00
Xi Ge
bafe60e91b Refactoring: move IsInSynthesizedExtension to Analyzer. NFC. 2016-03-02 17:30:11 -08:00
Xi Ge
65a3aade7e [SourceKit] Cursor info: for extension decls, the cursor info query always returns the extended nominal's group name. 2016-03-02 17:30:11 -08:00
Xi Ge
8f1c239d01 [SourceKit] Cursor info: remove type interface since no clients are using it. rdar://24920331 2016-03-02 12:28:02 -08:00
Ben Langmuir
1168aa0342 [SourceKit] Put SourceDocInfo ASTPrinters into anonymous namespaces NFC 2016-03-02 11:01:21 -08:00
Ben Langmuir
1b22116639 [SourceKit] Refactor parameter printing to use its own callbacks NFC
The current approach of visiting the param decl won't work when we want
to visit the parameters of function *types*, or when visiting tuple
elements (which aren't themselves decls).

rdar://problem/24292226
2016-03-02 11:01:11 -08:00
Ben Langmuir
8955cdc644 [SourceKit] Add decl.var.type tags in property declarations
These Type::print can just reuse the printTypeLoc logic even if they
don't have a TypeRepr.

rdar://problem/24292226
2016-03-01 16:49:33 -08:00
Ben Langmuir
b4469d88dc [SourceKit] Replace decl.name with syntaxtype.keyword as appropriate
We aren't ready to start marking up all keywords yet, but start by
replacing the cases where we currently have decl.name.

rdar://problem/24292226
2016-03-01 15:35:26 -08:00
Ben Langmuir
10c8250352 [SourceKit] Rename local/external to name/argument_label in annotation
rdar://problem/24292226
2016-03-01 15:16:40 -08:00