Kotlin: Format queries

This commit is contained in:
Ian Lynagh
2022-04-26 16:29:05 +01:00
parent efe3c0d1ea
commit 1a36b1ab53
3 changed files with 10 additions and 6 deletions

View File

@@ -76,7 +76,9 @@ class CollectionSizeMethod extends CollectionMethod {
/** A method that mutates the collection it belongs to. */
class CollectionMutator extends CollectionMethod {
CollectionMutator() { pragma[only_bind_into](this).getName().regexpMatch("add.*|remove.*|push|pop|clear") }
CollectionMutator() {
pragma[only_bind_into](this).getName().regexpMatch("add.*|remove.*|push|pop|clear")
}
}
/** A method call that mutates a collection. */
@@ -89,7 +91,9 @@ class CollectionMutation extends MethodAccess {
/** A method that queries the contents of a collection without mutating it. */
class CollectionQueryMethod extends CollectionMethod {
CollectionQueryMethod() { pragma[only_bind_into](this).getName().regexpMatch("contains|containsAll|get|size|peek") }
CollectionQueryMethod() {
pragma[only_bind_into](this).getName().regexpMatch("contains|containsAll|get|size|peek")
}
}
/** A `new` expression that allocates a fresh, empty collection. */

View File

@@ -45,9 +45,7 @@ abstract class GeneratedFile extends File { }
* A file detected as generated based on commonly-used marker comments.
*/
library class MarkerCommentGeneratedFile extends GeneratedFile {
MarkerCommentGeneratedFile() {
any(GeneratedFileMarker t).getFile() = this
}
MarkerCommentGeneratedFile() { any(GeneratedFileMarker t).getFile() = this }
}
/**

View File

@@ -59,7 +59,9 @@ class MapMutation extends MethodAccess {
/** A method that queries the contents of the map it belongs to without mutating it. */
class MapQueryMethod extends MapMethod {
MapQueryMethod() {
pragma[only_bind_into](this).getName().regexpMatch("get|containsKey|containsValue|entrySet|keySet|values|isEmpty|size")
pragma[only_bind_into](this)
.getName()
.regexpMatch("get|containsKey|containsValue|entrySet|keySet|values|isEmpty|size")
}
}