Commit Graph

73 Commits

Author SHA1 Message Date
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
Xi Ge
3f20eb242d Refactoring: Moving the logic of collecting synthesized extensions to Analyzer. NFC. 2016-03-02 17:30:11 -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
Xi Ge
60be59953a ModulePrinting: Add the basic infrastructure to remove inapplicable synthesized extensions.
As the initial step, we remove any synthesized extensions requiring a tuple's conforming to nominals, which
never happens. This will remove multiple useless synthesized extensions for Dictionary.
2016-03-01 15:44:41 -08:00
Ben Langmuir
f0d306eb10 [ASTPrinter] Enforce pairing of pre/post decl callbacks
We can have multiple printDeclPre callbacks pending (e.g top-level-code
decls), so use a vector to ensure we don't lose the earlier callbacks.

We also may end up calling printDeclPost without forcing the
corresponding printDeclPre first if the decl doesn't actually print
anything (e.g. an if-config statement when skipping those). So add a
wrapper callPrintDeclPost that can check for this and skip both
callbacks.  In theory, we could handle this case by instead making all
ast nodes go through something like shouldPrint() and making an
invariant that something will be printed if and only if shouldPrint
returns true.  However, that is not an obvious win, because it forces us
to walk all the first-level statements and decls inside a top-level-code
decl to determine if anything will be printed, and it also means we can
never make local decisions about whether something will be printed.  For
now, I've chosen to maintain flexibility by recovering from unprinted
decls.

Finally, add a bunch of assertions to try to keep callbacks sane.
2016-02-29 14:59:58 -08:00
Ben Langmuir
86bc29cfc6 [SourceKit] Add type tags for parameters and return types
When the type is not just a reference to a nominal type, we still need
to be able to delineate it.

rdar://problem/24292226
2016-02-25 09:07:16 -08:00
Ben Langmuir
d3e98f52ef [SourceKit] Add parameter.name.local and parameter.name.external tags
... for the fully annotated declarations. More substructure more better.
This has to go through a callback mechanism similar to printDeclLoc and
printDeclPre since it should be scheduled after both of those are
printed.

rdar://problem/24292226
2016-02-24 15:26:46 -08:00
Ben Langmuir
3e9bfa137d [SourceKit] Add decl.var.parameters entries to the fully annotated decl
This is the first part of adding parameter substructure so that clients
can reason about more of the function declaration.

rdar://problem/24292226
2016-02-24 11:39:47 -08:00
Xi Ge
bf1436a367 ASTPrinter: Move the logic for collecting all module groups from SourceKit to an IDE API, NFC. 2016-02-22 11:50:34 -08:00
Xi Ge
1872214d40 Swif-ide-test: add a parameter to specify the group names to print. 2016-02-19 17:21:28 -08:00
Xi Ge
d4f704bb2f ASTPrinter: Add pre and post callbacks for printing synthesized extensions and call them.
This is necessary for jump to synthesized extensions in IDE.
2016-02-15 17:41:49 -08:00
Ben Langmuir
e327378b24 [SourceKit] Add annotation tags for decl names
This splits the printDeclNamEndLoc callback into NameEndLoc and
NameOrSignatureEndLoc variants to differentiate whether or not
signatures are included.  All existing clients move to
NameOrSignatureEndLoc to maintain the current behaviour. I'm still not
completely happy with how these are named, but I dont' have any better
ideas right now.

rdar://problem/24292226
2016-02-12 15:57:28 -08:00
Xi Ge
9aa3d01101 [Serialization] Avoid serializing source orders, trust deserialized decls in preserving such order. rdar://24610992
Thank Jordan for suggesting this.
2016-02-11 12:24:38 -08:00
Xi Ge
c97f115219 [ModulePrinter] When printing decls in a module group, we print them according to their source order.
Source order preserves semantic information better than printing alphabetically.
2016-02-10 17:46:49 -08:00
Xi Ge
7784ba959e ModulePrinter: allow module printer to print symbols from a specific group. 2016-02-09 11:49:16 -08:00
Xi Ge
0864b62e58 Simplify some code, NFC 2016-02-02 15:21:15 -08:00
Xi Ge
ae60159816 [ModulePrint] Add the initial implementation for printing synthesized extensions.
For a concrete type, members from its conforming protocols' extensions can be hard
to manually surface. In this commit, when printing Swift modules, we start to replicate these
extensions and synthesize them as if they are the concrete type's native extensions.

Credit to Doug for suggesting this practice.
2016-02-02 14:53:21 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
021a186c23 Fix typos. 2015-12-28 18:30:15 +01:00
Xi Ge
bef5b4301d [SourceKit][PrintObjcHeader] Avoid printing the same Swift decl twice.
Clang and Swift decls likely have many-to-one mappings; for instance,
a RecordDecl and a TypedefDecl in Clang are both imported as the same Swift
NominalTypeDecl. This commit reduces duplication when we print Clang decls in
Swift. rdar://23275959
2015-12-07 16:24:23 -08:00
Xi Ge
20e1d6231d [ASTPrinter] Expose shouldPrint() as global function. NFC
Swift SVN r32817
2015-10-22 00:41:33 +00:00
Xi Ge
e1331252a3 [ClangModulePrint] If skipping an unavailable decl, skipping its following regular comments too. rdar://20092567
This only works for Clang-imported but unavailable decls, but not for Clang decls that
are not imported.

Swift SVN r32769
2015-10-20 00:19:40 +00:00
Argyrios Kyrtzidis
0bb52f0621 [IDE] Fix the 'preamble' top-comment printing when printing the swift source interface.
It erroneously printed out accessibility keyword of the first decl and did not take into
account comment whitespacing.

Swift SVN r30933
2015-08-02 20:46:38 +00:00
Xi Ge
af589ebaa7 [InterfacePrinting] Print missing import decls from Swift module instance. rdar://20695897
Swift SVN r30588
2015-07-24 20:44:21 +00:00
Xi Ge
0ad59157ae Revert "[InterfacePrinting] Print stdlib internal protocols whose names start with no '_'"
This reverts commit ca7c1e5692bdd51cb0800be42c964462a3c84436.

Swift SVN r30191
2015-07-14 18:39:49 +00:00
Xi Ge
a6e43171e3 [InterfacePrinting] Print stdlib internal protocols whose names start with no '_'
rdar://21515803

Swift SVN r30178
2015-07-14 00:30:45 +00:00
Xi Ge
1eac2874b1 [InterfacePrinting] Move utf8 sanitizer from SourceKit to ASTPrinter.
We sanitize comments by replacing invalid utf8 subsequence with � .

Swift SVN r30031
2015-07-09 18:26:02 +00:00
Xi Ge
6f33efd5f9 [InterfacePrinting] Printing non-doc comments at the beginning of a file, rdar://21710187.
When printing the interface extracted from a Swift file, we print every comments before
Swift code starts.

Swift SVN r29989
2015-07-08 20:10:57 +00:00
Argyrios Kyrtzidis
9917e74533 [IDE] Support printing the header interface for a header, that belongs to a clang module
that the clang invocation is importing.

Fully addresses rdar://21067984

Swift SVN r28962
2015-05-23 08:14:59 +00:00
Argyrios Kyrtzidis
3df7a35683 [IDE] Speed up header interface printing.
Instead of importing everything and filtering later (so all of clang modules get deserialized and associated Swift decls get created),
lazily import as Swift decls only the Clang decls that we need from a particular header.

This also fixes printing ObjC categories in the header as Swift extensions.

Swift SVN r28358
2015-05-09 02:03:51 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
Argyrios Kyrtzidis
a586753f0f [IDE] Implement generating the Swift interface for an C/ObjC header
This translates clang arguments to swift ones, uses the bridging header
functionality to parse the provided file, and re-uses part of the module interface
printing implementation to print an interface for the header.

Part of rdar://19939192

Swift SVN r28062
2015-05-02 01:17:45 +00:00
Jordan Rose
f74bc7122c Split getAccessibility() into getFormalAccess() and getEffectiveAccess().
Currently a no-op, but effective access for entities within the current
module will soon need to take testability into account. This declaration:

  internal func foo() {}

has a formal access of 'internal', but an effective access of 'public' if
we're in a testable mode.

Part of rdar://problem/17732115 (testability)

Swift SVN r26472
2015-03-24 02:16:58 +00:00
Ben Langmuir
c1ff9744c9 module interface gen: print extensions of nested types
Also print the extensions for nested types (either nested within a
nominal type decl, or within another extension).  This fixes printing
the String.UTF*View.Index types in the generated module interface for
the stdlib

Swift SVN r25352
2015-02-17 15:50:49 +00:00
Argyrios Kyrtzidis
c1984e15e7 [IDE] Make sure we don't print duplicate imports, due to getting imports for both a clang module and its overlay.
rdar://16608500

Swift SVN r23730
2014-12-05 06:01:06 +00:00
Argyrios Kyrtzidis
d039fb6369 [AST] Move ide::findUnderlyingClangModule() to Module::findUnderlyingClangModule() so that the ASTPrinter can use it.
Swift SVN r23691
2014-12-04 20:17:03 +00:00
Argyrios Kyrtzidis
1552772a15 [AST] Move ModuleEntity from libIDE to libAST so that the ASTPrinter can use it.
Swift SVN r23680
2014-12-04 05:52:16 +00:00
Ben Langmuir
e9e1666ab0 Update for upstream LLVM changes
* removal of StringMap's GetOrCreateValue
* SmallSet::insert now returns a pair like std::set

Swift SVN r23435
2014-11-19 16:49:30 +00:00
Jordan Rose
167d2f4bbb Include extensions in ClangModuleUnit::getTopLevelDecls.
We don't do this very efficiently, but it does work. And now that it's working,
drop some special cases in module interface printing -- just always print
Clang decls in Clang source order.

Swift SVN r21901
2014-09-12 02:54:50 +00:00
Doug Gregor
f52c6789db Track the minimum deployment target and use it for 'unavailable' computations.
Swift SVN r20955
2014-08-02 18:05:45 +00:00
Argyrios Kyrtzidis
3175251bb1 [IDE] Handle annotation of clang submodule imports properly.
rdar://17780613

Swift SVN r20595
2014-07-26 20:58:19 +00:00
Jordan Rose
a2af37a19b Split PrintOptions::printEverything into printEverything and printVerbose.
The former is for debugging, the latter is for detailed presentation to users.
swift -print-ast will continue using printEverything, as will swift-ide-test,
but all other features should use printVerbose.

Swift SVN r20432
2014-07-23 22:28:55 +00:00
Dmitri Hrybenko
1007ef3f95 Module interface printing: add an option to filter declarations based on
access control

Swift SVN r20399
2014-07-23 15:03:58 +00:00
Argyrios Kyrtzidis
7b62fa0c44 [ASTPrinter] Introduce a callback invoked after printing the name of the declaration (the signature for functions).
Swift SVN r19973
2014-07-15 05:56:54 +00:00
Argyrios Kyrtzidis
bb66d6dd1a [IDE] Don't show '@transparent' in the module interface.
rdar://16804855

Swift SVN r17350
2014-05-04 01:24:55 +00:00
Argyrios Kyrtzidis
9151996c9f [IDE] Don't show "import SwiftShims" in the stdlib interface.
Swift SVN r17344
2014-05-04 00:26:34 +00:00
Dmitri Hrybenko
739c495282 AST printer: use identifier escaping
rdar://16233153


Swift SVN r16933
2014-04-27 17:25:24 +00:00
Dmitri Hrybenko
a526517cec Module interface printing: print all sub-sub-modules when instructed to do so
<<Darwin>>->isModuleVisible(<<Darwin.*>>) returns false for some reason,
and I am not sure if this is correct or not.


Swift SVN r16520
2014-04-18 14:14:20 +00:00
Argyrios Kyrtzidis
0ccc83db54 [IDE/ModuleInterface] Print a blank line between top-level Swift declarations.
Swift SVN r16442
2014-04-17 05:10:46 +00:00
Argyrios Kyrtzidis
a9ea63a7f7 [IDE/ModuleInterface] Adjust the indentation of regular comments to match the current indentation level.
Swift SVN r16362
2014-04-15 06:27:40 +00:00