Comments (5)
This is fixed in tree-sitter/tree-sitter-rust#218
But it is blocked by https://github.com/tree-sitter/tree-sitter-typescript/blob/master/Cargo.toml#L29
More context: tree-sitter/tree-sitter-typescript#289
from ast-grep.
tree-sitter does not report string literal's content.
![image](https://private-user-images.githubusercontent.com/2883231/322993419-2be54d01-06cb-405f-b527-83c53fcb3f26.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTM3MzU5ODcsIm5iZiI6MTcxMzczNTY4NywicGF0aCI6Ii8yODgzMjMxLzMyMjk5MzQxOS0yYmU1NGQwMS0wNmNiLTQwNWYtYjUyNy04M2M1M2ZjYjNmMjYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDQyMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA0MjFUMjE0MTI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWNhMDE3Zjk4ZjA0MTEwZTQ2OWU0MWE5YTlhMTc0MmYwODU5OGI2NzlhYjZjZjA1MzVlMjJhNTI1YjYwOTlhMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.RpNtE_U2jc5ShGdbEjkFmetdFT20Nq4Mv5cTs1HjFAs)
So both "foo"
and "bar"
has the same structure like
string_literal
" opening quote
" closing quote
from ast-grep.
You can use this workaround
rule:
pattern: $E.with_meaning($D, $STR)
constraints:
STR: { regex: '^"meaning"$'}
from ast-grep.
Thanks for the explanation, @HerringtonDarkholme
from ast-grep.
Related Issues (20)
- [refactor] merge CombinedScan::scan and CombinedScan::diff
- [feature] support ast-grep-ignore suppression in LSP scanning
- [feature] TypeScript types for Rules in NAPI
- [bug] php(alpha) can not match pattern HOT 2
- [feature] search in git changed files HOT 2
- [bug] `fn $FUNC($$$ARGS) { $$$ }` does not match the function item of Rust HOT 1
- [feature] generate a warning or error if an invalid kind or field is used
- [bug] Matching string literals in Rust inner attributes behaves strangely HOT 12
- [feature] Add a way to override rule severities from the CLI HOT 3
- [feature] support glob path match in CLI. HOT 1
- report undefined meta variable
- analyze meta variables defined in pattern
- export meta variables defined in transform
- export meta variables defined in constraints/rules
- define the resolution order of meta variables
- export used meta-var in transform
- report undefined meta-var in fix
- Allow to use meta variable captured outside of rewrite rule inside the rewriter HOT 2
- export meta var in constraints HOT 1
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.