Git Product home page Git Product logo

Comments (2)

tadeuzagallo avatar tadeuzagallo commented on August 25, 2024

Hey, you're right, I forgot to add this feature to the documentation, sorry about that. The rule you pointed to is indeed the one example in the repo about it. The idea is that you are allowed to declare local boolean variables, and then you can modify then within whatever matcher you wish. e.g. in your case, you could have has_protocol and has_class both initialised to false, and when you match your class declaration you set has_class to true and similar with the protocol. Finally you add a condition, e.g. condition(has_class && has_protocol) { fail("...") }

However, as I wrote this, I realised you might run into another problem, which is that right now you must specify a top-level matcher, e.g. you can only declare variables after you matched a given node, which is unfortunate. In that case, you couldn't match both a class and a protocol at the top-level. I've filed #10 for that, and I'll look into it pretty soon.

If that makes things clearer and you want to send a PR, that would be great 😃 otherwise, I'll add it to the docs before cutting a new version pretty soon.

PS: sorry for the delay, for some reason I can't seem to get notifications for this repo.

from neal.

interstateone avatar interstateone commented on August 25, 2024

No worries about the delay, thanks for the thorough reply. The issue with top-level matchers was what I was seeing, so that makes sense. 👍

from neal.

Related Issues (9)

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.