Git Product home page Git Product logo

Comments (5)

HerringtonDarkholme avatar HerringtonDarkholme commented on July 3, 2024 1

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.

HerringtonDarkholme avatar HerringtonDarkholme commented on July 3, 2024

tree-sitter does not report string literal's content.

image

So both "foo" and "bar" has the same structure like

string_literal
  " opening quote
  " closing quote

from ast-grep.

HerringtonDarkholme avatar HerringtonDarkholme commented on July 3, 2024

You can use this workaround

rule:
  pattern: $E.with_meaning($D, $STR)
constraints:
  STR: { regex: '^"meaning"$'}

https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1c3QiLCJxdWVyeSI6IiRFLndpdGhfbWVhbmluZygkRCwgXCJtZWFuaW5nXCIpIiwicmV3cml0ZSI6IiRFLndpdGhfbWVhbmluZygkRCwgbWVhbmluZzo6TUVTU0FHRSkiLCJjb25maWciOiIjIFlBTUwgUnVsZSBpcyBtb3JlIHBvd2VyZnVsIVxuIyBodHRwczovL2FzdC1ncmVwLmdpdGh1Yi5pby9ndWlkZS9ydWxlLWNvbmZpZy5odG1sI3J1bGVcbnJ1bGU6XG4gIHBhdHRlcm46ICRFLndpdGhfbWVhbmluZygkRCwgJFNUUilcbmZpeDpcbiAgbG9nZ2VyLmxvZygkQSlcbmNvbnN0cmFpbnRzOlxuICBTVFI6IHsgcmVnZXg6ICdeXCJtZWFuaW5nXCIkJ30iLCJzb3VyY2UiOiJmbiB0ZXN0KCkge1xuICAgIHNjaGVtYS53aXRoX21lYW5pbmcoRk9PLCBcIm1lYW5pbmdcIik7XG4gICAgc2NoZW1hLndpdGhfbWVhbmluZyhGT08sIFwic2VydmljZVwiKTtcbn0ifQ==

from ast-grep.

bruceg avatar bruceg commented on July 3, 2024

Thanks for the explanation, @HerringtonDarkholme

from ast-grep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.