PRL-PRG / scalafix-rule-workshop

A framework repository to create and test scalafix rules
2 stars 0 forks source link

Queries #58

Closed fikovnik closed 6 years ago

fikovnik commented 6 years ago

It is work in progress, but have a look at it.

The interesting part is in QueriesTest.scala

fikovnik commented 6 years ago
   val m: Matcher[CallSite] =
      and(
        isSynthetic,
        declaration(
          isImplicit,
          kind(in("def".r, "class".r)),
          signature(
            parameterLists(
              or(
                inOrderOnly(
                  and(!isImplicit, parameters(size(1)))
                ),
                inOrderOnly(
                  parameters(size(1)),
                  isImplicit
                )
              )
            )
          )
        )
      )

    println(m.description)
(is synthetic) && (declaration that ((is implicit) && (kind that is in [matches Regex("def"), matches Regex("class")])) && (signature value that parameterLists that (contains in order only [(is not implicit) && (parameters that size that is 1)]) || (contains in order only [parameters that size that is 1, is implicit])))