https://github.com/daniel-beard/sws
A limited semantic search for Swift files
https://github.com/daniel-beard/sws
ast command-line-tool search swift swift-syntax
Last synced: about 1 year ago
JSON representation
A limited semantic search for Swift files
- Host: GitHub
- URL: https://github.com/daniel-beard/sws
- Owner: daniel-beard
- License: mit
- Created: 2023-01-04T22:06:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-22T18:58:44.000Z (over 3 years ago)
- Last Synced: 2025-02-05T01:28:14.398Z (over 1 year ago)
- Topics: ast, command-line-tool, search, swift, swift-syntax
- Language: Swift
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftSearcher
A limited semantic search for Swift codebases.
```
sws 'func:/deletingPrefix/'
Searching 8 files
./SwiftSearcherCore/SwiftSearcher.swift 94:5
Done in: 13.663769ms
```
## Implemented Search Syntax
- Each search is comprised of a matcher and and optional filter.
- A matcher determines the type of AST node we are searching for, and filters further filter results.
- The syntax is `{matcher}|{filter}`
### Implemented matchers
- `func`, `struct`, `class`
- You can optionally specify a Swift Regex to search by the node identifier.
- E.g. All classes ending with "Manager": `class:/Manager$/`
### Implemented filters
- `modifiers`:
- Search a matched nodes modifiers as a regex.
- Example: Matching a function that specifies `private` or `internal`: `func:/myFunc/|modifiers:/private|internal/`
## Proposed Search Syntax
Note: These are proposed search terms, and may not all be implemented yet.
```
func:/my.*/
func:/myFunc/|parent:struct:/MyStruct/
func:/myFunc/|returning:/String/
struct|implementing:/MyProcotol/
func|modifiers:/private/
class|modifiers:/internal/
```
## TODO
- [ ] Add tests