Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dduan/factorino
https://github.com/dduan/factorino
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dduan/factorino
- Owner: dduan
- Created: 2020-03-23T05:57:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-22T01:44:13.000Z (over 4 years ago)
- Last Synced: 2025-01-11T16:50:56.136Z (about 1 month ago)
- Language: Swift
- Size: 16.6 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Factorino
This is a command-line tool that refactors your Swift project.
**It's a working-in-progress. Use with caution (version control is your
friend)!**## Usage
All factorino commands operate under the concept of a [query](#query). For some
subcommands, you need to refine your query until it leads to a canonical
definition of a symbol, at which point the refactor will proceed.Currently, these commands are included:
| name | description | require canonical refinement |
| ------ | ----------------------------------------------------- | ---------------------------- |
| define | find the declaration of the symbol | no |
| occur | find references of the symbol | yes |
| rename | replace the occurrences of the symbol with a new name | yes |Here's some example of how this works (TODO: update output as it's implemented)
Let's try to find occurrences of a symbol. Usually, finding its definition is
a good place to start:```
fact define MyAwesomeClass
```If the output includes solely the declaration you expected, then we can move on
to finding it's occurrence:```
fact occur MyAwesomeClass
```Running the `define` subcommand is not required. However, if `fact define` would
have return multiple definitions, `define occur` would refuse to proceed. We can
tell Factorino which of the definition we want to look up by enhancing the
[query](#query):```
fact occur MyAwesomeClass --path Sources/Path/To/Source --line 4
```Here we specify the source (doesn't have to be complete, as long as it's part of
the actual path you want), and a line number, which hopefully is enough details
to distinguish the definition you want from others.`fact rename` requires similar refinement.
### Query
A query is composed of the following components:
- symbol name
- a (partial) path source file where the symbol occurs
- line number in the source file where the symbol occurs (1-based)
- column number in the source file where the symbol occurs (1-based)Imagine clicking on a symbol in an IDE. That's essentially what the query
conveys.Only symbol name is required in a query.
Alternative to those pieces of information, a query could also be an "USR", a
canonical reference to an occurrence to a symbol. Factorino includes the USR
of a symbol in its output. You can use it as the query, and skip the other
details:```
fact occur --usr USR
```## IndexStore powered
The underlying technology for this tool is [IndexStoreDB][], a build artifact
generated by systems such as SwiftPM, or Xcode. This index must be up-to-date
with your project in order for Factorino to operate correctly. In practice, this
means you probably need to build your project prior. You may explicitly tell
Factorino where the index for your project is by the `--index-store-path`
option. Otherwise Factorino will try its best to infer its location.[IndexStoreDB]: https://github.com/apple/indexstore-db