diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-27 16:09:35 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-27 16:09:35 +0100 |
| commit | a96141a3ea9d1b11ef4cdc924216d8979689e6f0 (patch) | |
| tree | 0192bdd4e63f3fb3c9172faae35bf8b08c8c957d /src/model/methods.rs | |
| parent | 2e039cb052fcb768027053cbf02ce396f6d7a6be (diff) | |
Autocomplete methods
Diffstat (limited to 'src/model/methods.rs')
| -rw-r--r-- | src/model/methods.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/model/methods.rs b/src/model/methods.rs index 173b95fe..1671a5c4 100644 --- a/src/model/methods.rs +++ b/src/model/methods.rs @@ -210,3 +210,36 @@ pub fn is_accessor(method: &str) -> bool { fn missing_method(type_name: &str, method: &str) -> String { format!("type {type_name} has no method `{method}`") } + +/// List the available methods for a type. +pub fn methods_on(type_name: &str) -> &[&'static str] { + match type_name { + "color" => &["lighten", "darken", "negate"], + "string" => &[ + "len", + "at", + "contains", + "ends-with", + "find", + "first", + "last", + "match", + "matches", + "position", + "replace", + "slice", + "split", + "starts-with", + "trim", + ], + "array" => &[ + "all", "any", "at", "contains", "filter", "find", "first", "flatten", "fold", + "insert", "join", "last", "len", "map", "pop", "position", "push", "remove", + "rev", "slice", "sorted", + ], + "dictionary" => &["at", "insert", "keys", "len", "pairs", "remove", "values"], + "function" => &["where", "with"], + "arguments" => &["named", "pos"], + _ => &[], + } +} |
