Skip to content

Commit

Permalink
rewind
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante committed Sep 13, 2024
1 parent d057581 commit 43e4152
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions crates/core/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8848,9 +8848,10 @@ fn matches_java_imports() {
|language java
|
|or {
| `import $_` => `generic import`,
| `import org.springframework.mock.$_` => `spring mock import`,
| `import org.springframework.$_` => `spring import`,
| `import $import;` where {
| $import <: contains `org.springframework`
| } => `spring import`,
| `import $_;` => `generic import`,
|}
|"#
.trim_margin()
Expand All @@ -8861,18 +8862,18 @@ fn matches_java_imports() {
|import org.springframework.mock.web.MockHttpServletRequest;
|import org.junit.Test;
|import org.junit.runner.RunWith;
|import org.springframework.mock.web.MockHttpServletRequest;
|import org.springframework.mine.web.MockHttpServletRequest;
|"#
.trim_margin()
.unwrap()
.to_owned(),
expected: r#"
|package com.example.test;
|
|spring import
|generic import
|spring mock import
|generic import
|spring mock import
|spring import
|"#
.trim_margin()
.unwrap()
Expand Down
1 change: 1 addition & 0 deletions crates/language/src/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl Language for Java {
fn snippet_context_strings(&self) -> &[(&'static str, &'static str)] {
&[
("", ""),
("import ", ";"),
("GRIT_VAR = ", ";"),
("class GRIT_CLASS { ", " }"),
("class GRIT_CLASS { ", " GRIT_FUNCTION() {} }"),
Expand Down
6 changes: 3 additions & 3 deletions resources/language-metavariables/tree-sitter-java/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,13 +795,13 @@ module.exports = grammar({
seq(field('annotations', repeat($._annotation)), 'package', field('package', $._name), ';'),

import_declaration: ($) =>
prec(PREC.DECL, seq(
seq(
'import',
optional('static'),
field('package', choice($._name, $.grit_metavariable)),
field('package', $._name),
optional(seq('.', $.asterisk)),
';',
)),
),

asterisk: ($) => '*',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ module.exports = grammar({
token.immediate(
seq(
'\\',
choice(/[^xu0-7]/, /[0-7]{1,3}/, /x[0-9a-fA-F]{2}/, /u[0-9a-fA-F]{4}/, /u{[0-9a-fA-F]+}/),
choice(/[^xu0-7]/, /[0-7]{1,3}/, /x[0-9a-fA-F]{2}/, /u[0-9a-fA-F]{4}/, /u[0-9a-fA-F]+/),
),
),

Expand Down

0 comments on commit 43e4152

Please sign in to comment.