Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend rust support #58

Merged
merged 2 commits into from
Jul 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions dumb-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,15 @@

;; rust
(:type "variable" :supports ("ag" "grep") :language "rust"
:regex "\\blet\\s+(mut\\s+)?JJJ(:\\s*[^=\\n]+)?\\s*=\\s*[^=\\n]+"
:regex "\\blet\\s+(\\\([^=\\n]*)?(mut\s+)?JJJ([^=\\n]*\\\))?(:\\s*[^=\\n]+)?\\s*=\\s*[^=\\n]+"
:tests ("let test = 1234;"
"let test: u32 = 1234;"
"let test: Vec<u32> = Vec::new();"
"let mut test = 1234;"
"let mut test: Vec<u32> = Vec::new();"))
"let mut test: Vec<u32> = Vec::new();"
"let (a, test, b) = (1, 2, 3);"
"let (a, mut test, mut b) = (1, 2, 3);"
"let (mut a, mut test): (u32, usize) = (1, 2);"))

(:type "variable" :supports ("ag" "grep") :language "rust"
:regex "\\bconst\\s+JJJ:\\s*[^=\\n]+\\s*=[^=\\n]+"
Expand All @@ -359,25 +362,34 @@
(:type "variable" :supports ("ag" "grep") :language "rust"
:regex "\\bfn\\s+.+\\s*\\\((.+,\\s+)?JJJ:\\s*[^=\\n]+\\s*(,\\s*.+)*\\\)"
:tests ("fn abc(test: u32) -> u32 {"
"fn abc(x: u32, y: u32, test: Vec<u32>, z: Vec<Foo>)"))
"fn abc(x: u32, y: u32, test: Vec<u32>, z: Vec<Foo>)"
"fn abc(x: u32, y: u32, test: &mut Vec<u32>, z: Vec<Foo>)"))

;; "if let" and "while let" desugaring
(:type "variable" :supports ("ag" "grep") :language "rust"
:regex "(if|while)\\s+let\\s+\\w+\\\((mut\\s+)?JJJ\\\)\\s*=\\s*[^=\\n]+\\s*{"
:regex "(if|while)\\s+let\\s+([^=\\n]+)?(mut\\s+)?JJJ([^=\\n\\\(]+)?\\s*=\\s*[^=\\n]+"
:tests ("if let Some(test) = abc() {"
"if let Some(mut test) = abc() {"
"if let Ok(test) = abc() {"
"if let Ok(mut test) = abc() {"
"if let Foo(mut test) = foo {"
"if let test = abc() {"
"if let Some(test) = abc()"
"if let Some((a, test, b)) = abc()"
"while let Some(test) = abc() {"
"while let Some(mut test) = abc() {"
"while let Ok(test) = abc() {"
"while let Ok(mut test) = abc() {"
"while let Foo(mut test) = foo {"))
"while let Ok(mut test) = abc() {")
:not ("while let test(foo) = abc() {"))

(:type "function" :supports ("ag" "grep") :language "rust"
:regex "\\bfn\\s+JJJ\\s*\\\("
:tests ("fn test(asdf: u32)" "fn test()" "pub fn test()"))

(:type "function" :supports ("ag" "grep") :language "rust"
:regex "\\bmacro_rules!\\s+JJJ"
:tests ("macro_rules! test"))

(:type "type" :supports ("ag" "grep") :language "rust"
:regex "struct\\s+JJJ\\s*[{\\\(]?"
:tests ("struct test(u32, u32)"
Expand All @@ -398,7 +410,11 @@
:tests ("impl test {"
"impl abc::test {"
"impl std::io::Read for test {"
"impl std::io::Read for abc::test {")))
"impl std::io::Read for abc::test {"))

(:type "type" :supports ("ag" "grep") :language "rust"
:regex "mod\\s+JJJ\\s*{?"
:tests ("mod test;" "pub mod test {")))

"List of regex patttern templates organized by language
and type to use for generating the grep command"
Expand Down