Comments (2)
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.
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
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 neal.