Comments (4)
Sorry I didn't get your point.
If you need a rule to convert identifier, https://ast-grep.github.io/reference/yaml/transformation.html#convert can do that already.
from ast-grep.
convert can do that already
aah! also Use transform in Rewrite. but the docs have no full example
i just cant get this working... this should rename some_var
to someVar
ast-grep always shows the interactive screen, but it should just patch input.py
cat >input.py <<'EOF'
some_var = 1
print(some_var)
EOF
cat >rules.yaml <<'EOF'
id: fix-case
language: python
rule:
pattern: $X
kind: identifier
transform:
X2:
convert:
toCase: camelCase
source: $X
# edit: fix was missing
fix: $X2
EOF
ast-grep scan -U -r rules.yaml input.py
from ast-grep.
You also need a fix
field to apply the fix. https://ast-grep.github.io/reference/yaml/fix.html
id: fix-case
language: python
rule:
pattern: $X
kind: identifier
transform:
X2:
convert:
toCase: camelCase
source: $X
fix: $X2
Please read the doc. https://ast-grep.github.io/guide/rewrite-code.html
from ast-grep.
aah ^^ thanks : )
from ast-grep.
Related Issues (20)
- separate env from local utils, global utils, local rewrite and global rewrite HOT 1
- move fixer to RuleWithConstraints
- [refactor] remove MetaVarMatcher HOT 1
- [refactor] remove IndentSensitive trait
- [bug] Escape problem in String HOT 3
- [feature] improve rule parsing and error reporting HOT 1
- [feature] use php-only-language in php pattern HOT 1
- [feature] AST diff, with option to ignore variable/function name changes HOT 4
- [feature] simplify transformation and introduce `selector` HOT 4
- [feature] search function invocation without specifying arguments. HOT 1
- [feature] Verbose logging or some way to see what's happening
- [feature] Add TOML support
- [feature] Add Elm support HOT 1
- [feature] ignore empty rules in rules.yaml - allow trailing rule separator HOT 1
- Can input be avoided with "--update-all"?
- [bug] C++ matching doesn't work on function declaration body HOT 4
- [bug] Metavariables in C++ seem to depend on length HOT 2
- [bug] Rule file without 'message' property breaks LSP HOT 1
- Finding arbitrary HTML nodes that have specific attributes with specific value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ast-grep.