Commit Graph

45 Commits

Author SHA1 Message Date
Dylan Sturgeon
ce55a854b9 Emit references to shadowed variables in if-let shorthands as variables when indexing locals is enabled.
Track the original-decl/captured decl as part of the symbol passed to the IndexConsumer. This allows the Rename consumer to check if the symbol is a shadowed reference to a decl being renamed, without the index skipping the other relevant output when visiting shadowing variables.

https://github.com/swiftlang/swift/issues/76805
2024-10-22 16:43:24 -07:00
Alex Hoppen
1a67c61d19 [RelatedIdents] Fix an assertion failure if two invalid declarations have the same base name
For example, the following declarations have the same USR with a single ERROR_TYPE parameter despite being distinct declarations.

```swift
func bar(body: Invalid) {}
func bar(ignoreCase: Bool, body: Invalid) {}
```

We originally intended to check the USR so that local rename behaves more like global rename, which also looks symbols up by USR. But the above example proves that assumption wrong.

rdar://126803702
2024-05-07 18:17:11 -07:00
Artem Chikin
e0275f4f0e [Explicit Module Builds] Do not attempt to re-load module dependency from
interface for index.

An explicit module build compile is unable to do so because it does not have
access to the interfaces. Doing this in the first place is a workaround for a
known bug, which will require to be solved at the root cause instead (e.g.
Deserialization Safety feature).

Resolves rdar://113165898
2023-08-25 16:34:09 -07:00
Ben Barham
38d2b96e6d [NFC] Small Index.cpp cleanups 2022-09-20 13:06:47 -07:00
Tony Allevato
4d16c43d21 Add -index-include-locals flag.
When this flag is passed, index store data emitted during a build
will also contain definitions/references for local symbols.
2022-07-11 14:08:07 -07:00
David Goldman
63c88b97f1 Add -index-ignore-clang-modules flag
This flag avoids indexing import clang modules (pcms), behaving
similar to `-index-ignore-system-modules` except for PCMs.
2022-05-17 19:41:26 -04:00
David Goldman
c232ed2913 Support hermetic indexing information
Swiftc port of https://github.com/apple/llvm-project/pull/4207.

This introduces a new flag, `-file-prefix-map` which can be used
instead of the existing `-debug-prefix-map` and `-coverage-prefix-map`
flags, and also remaps paths in index information currently.
2022-05-16 11:00:14 -04:00
Varun Gandhi
52dcd47456 [NFC] Remove redundant includes for llvm/ADT/SmallString.h. 2020-05-31 13:07:45 -07:00
Nathan Hawes
a785fa6cee [Frontend][Index] Add frontend option to skip indexing the stdlib (for test performance)
Several tests related to indexing system modules were taking a considerable
amount of time (100+ seconds in the worst case) indexing the standard library.
This adds a frontend option to skip it and updates those tests to pass it.
2020-03-25 14:36:23 -07:00
Michael Wyman
70e38937e3 Return Optional<> offset from getLineColAndOffset. 2019-08-27 11:08:53 -07:00
Michael Wyman
bd10f2a7c9 Address PR feedback. IndexSymbol.offset is now an llvm::Optional<unsigned>, getOffsetInBuffer is now replaced by returning a tuple with the offset from getLineColAndOffset (renamed from getLineCol). 2019-08-27 10:53:49 -07:00
Michael Wyman
89f89ab3e0 Make symbol info only store symbol occurrence offset, not start/end offset. The rest can be determined from the source manager by finding the token's SourceLoc. 2019-08-26 10:20:36 -07:00
Michael Wyman
a355af2890 Make Swift indexing code capture symbol start/end offset within the current source file. 2019-08-12 14:39:31 -07:00
Xi Ge
ab86991958 IDE: move two AST traversal utilities from libIndex to IDE type checking. NFC 2019-07-18 16:17:10 -07:00
Argyrios Kyrtzidis
3332b37d00 [Index/SourceKit] Remove the code related to calculating a module hash from the indexing walker
This has been an unnecessary code path for a long time now and should be removed particularly because it triggers wasteful `stat` calls.

rdar://51523161
2019-06-21 17:09:12 -07:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Bruno Rocha
bf84b297f8 [SourceKit] Allow module references to be indexed (#19243)
Module references get indexed as a 'module' symbol; they get USRs similar to how clang would assign a USR for a module reference.

JIRA: https://bugs.swift.org/browse/SR-8677
2018-09-28 12:21:38 -07:00
David Farler
645aaad551 [index/build] Upstream indexing while building changes
This patch upstreams previously AppleInternal changes for
indexing while building.
2017-06-29 16:20:06 -07:00
Nathan Hawes
4ff254de97 Move canDeclProvideDefaultImplementationFor() from libIDE into libIndex 2017-04-27 23:23:45 -07:00
Nathan Hawes
8ad6aa4e0d [migrator] Add pass for API type changes
This handles optionality changes and type rewrites in function param and return types and constructor param and failability types.
Resolves rdar://problem/31766010
2017-04-27 22:19:52 -07:00
practicalswift
40cf4d183d [gardening] Use consistent spacing after if, for and while 2017-04-14 17:35:36 +02:00
Nathan Hawes
a57fd2a4b0 [indexer] Add an option to index local symbols too, and a new index::indexDeclContext() entry point
Resolves rdar://problem/31433002.
2017-04-12 09:04:03 -07:00
Xi Ge
936b4a25da Revert "Index: Expose the logic for deciding whether to index a symbol. NFC. (#8438)"
We currently don't need this logic elsewhere, thus it's good to give
indexer some privacy.
2017-04-01 10:39:36 -07:00
Xi Ge
9e6d584b60 Index: Expose the logic for deciding whether to index a symbol. NFC. (#8438) 2017-03-30 14:00:44 -07:00
Nathan Hawes
7b75cf792c [indexer] Index parameter definitions with a distinct external argument label too (but not their refs)
Parameter defs with a separate external argument label are marked with the 'Local' symbol property.
This ensures the indexer has enough information for clients to match up a function's argument labels with its child parameter definitions.
Resolves rdar://problem/31039915.
2017-03-14 16:12:48 -07:00
Argyrios Kyrtzidis
a13289835e [index] For extensions, relate the symbol reference that gets extended and base references with the extension symbol.
They were getting related with the original extended symbol, which was incorrect.
2017-02-19 18:19:39 -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
Nathan Hawes
563bc04da1 Merge pull request #6677 from nathawes/swift-indexing
Add roles and relations for Swift indexing
2017-01-09 14:48:35 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Nathan Hawes
8c45e20d3f [indexer] Add relations to IndexSymbol add a -print-indexed-symbols option to swift-ide-test for testing 2017-01-05 15:01:53 -08:00
Nathan Hawes
7f582c420d [indexer] When visiting a NominalTypeDecl, cover the type references in the where clause and generic param inheritance too.
Also rename ASTWalker::shouldWalkIntoFunctionGenericParams() to shouldWalkIntoGenericParams() since it's now used when walking NominalTypeDecl (not just AbstractFunctionDecl).
2017-01-05 14:54:59 -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
Ben Langmuir
5525319d5c [index] Add finish() hook to the index consumer API
Since the memory underlying returned USRs is guaranteed to last until
the indexing action completes, add a finish() hook so that clients can
trigger an action at the end of indexing but before the memory goes
away.
2016-06-09 09:43:41 -07:00
Argyrios Kyrtzidis
ec042460fe [SourceKit] Report attributes of decls for the indexing request. 2016-05-05 16:44:34 -07:00
Ben Langmuir
ad34f89d5b [index] Add UnitTest SymbolSubKind and collapse the IndexSymbol inheritance
Fold UnitTest into the subkind, now that it's a bitself, and then remove
the unnecessary inheritance for IndexSymbol and its SourceKit indexing
equivalent.
2016-04-29 19:04:27 -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
ef4e84b8d6 [index] Subsume CallRefIndexSymbol into IndexSymbol
Eventually we should just have one IndexSymbol, with all the
information. Once we kill FuncDeclIndexSymbol and can get rid of the
enum,  we will regain most of the bytes we lost by inlining receiverUSR.
2016-04-29 19:04:26 -07:00
Ben Langmuir
50eeeb7430 [index] Add 'call' and 'isDynamic' roles 2016-04-29 19:04:25 -07:00
Ben Langmuir
1b1320b9f1 [index] Thread through SymbolRoleSet as a generalization of "bool isRef"
As a first step toward having more detailed "role" information, thread
through a SymbolRole bitset.  For now it just contains the existing ref
vs. definition status.
2016-04-29 19:04:24 -07:00
Ben Langmuir
5523266715 [index] Remove unreachable materializeForSet case in indexer
We already had it marked unreachable in SourceKit, so lift that up into
the libIndex and remove the unnecessary enum case.
2016-04-28 16:51:03 -07:00
Ben Langmuir
db381525d0 [index] Remove unused local/param variables from index kinds
We don't index local variables or parameters, so remove the index symbol
kinds.
2016-04-28 16:51:02 -07:00
Ben Langmuir
e977d4bd54 [index] Remove import.sourcefile kind from indexing
We don't support importing source files in source code, and they only
showed up in the index under failure conditions.
2016-04-28 16:51:01 -07:00
Ben Langmuir
8f17b13f61 [index] Cache USR and name for decls
We were calculating these for every decl-occurrence, but we really only
need them once per decl.
2016-04-25 13:29:27 -07:00
Ben Langmuir
8dad7f7803 [index] Split the indexModule entry point for indexSourceFile NFC
Having a single interface for source files and modules and having to
pass in a buffer id was a crappy API. This splits the interface to take
either a Module or a SourceFile and handles the buffer id stuff
internally.
2016-04-15 16:27:30 -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