Skip to content

Commit

Permalink
Migrate type
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Nov 18, 2023
1 parent 1f57754 commit 7eda891
Show file tree
Hide file tree
Showing 13 changed files with 256 additions and 40 deletions.
10 changes: 0 additions & 10 deletions packages/cursorless-engine/src/languages/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ const nodeMatchers: Partial<
childRangeSelector(["argument_list", ";"], []),
),
),
type: trailingMatcher([
"generic_type.type_arguments.type_identifier",
"generic_type.type_identifier",
"generic_type.scoped_type_identifier.type_identifier",
"type_identifier",
"local_variable_declaration[type]",
"array_creation_expression[type]",
"formal_parameter[type]",
"method_declaration[type]",
]),
value: leadingMatcher(
[
"*[declarator][value]",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
languageId: java
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 2, character: 12}
active: {line: 2, character: 12}
- anchor: {line: 3, character: 12}
active: {line: 3, character: 12}
- anchor: {line: 2, character: 42}
active: {line: 2, character: 42}
- anchor: {line: 3, character: 36}
active: {line: 3, character: 36}
marks: {}
finalState:
documentContents: |-
public class MyClass {
private MyClass () {
map = new ();
list = new ();
}
}
selections:
- anchor: {line: 2, character: 12}
active: {line: 2, character: 12}
- anchor: {line: 2, character: 23}
active: {line: 2, character: 23}
- anchor: {line: 3, character: 12}
active: {line: 3, character: 12}
- anchor: {line: 3, character: 24}
active: {line: 3, character: 24}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 2, character: 32}
active: {line: 2, character: 32}
- anchor: {line: 3, character: 25}
active: {line: 3, character: 25}
marks: {}
finalState:
documentContents: |-
public class MyClass {
private MyClass () {
map = new HashMap<String, String>();
list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 2, character: 12}
active: {line: 2, character: 12}
- anchor: {line: 3, character: 12}
active: {line: 3, character: 12}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
languageId: java
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: |-
public class MyClass {
private MyClass (String hello) {
int[] values = new int[5];
}
}
selections:
- anchor: {line: 2, character: 27}
active: {line: 2, character: 27}
marks: {}
finalState:
documentContents: |-
public class MyClass {
private MyClass (String hello) {
int[] values = new [5];
}
}
selections:
- anchor: {line: 2, character: 27}
active: {line: 2, character: 27}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
languageId: java
command:
version: 6
spokenForm: change type
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: |-
public class MyClass {
public void myFunk() {
}
}
selections:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 8}
marks: {}
finalState:
documentContents: |-
public class MyClass {
public myFunk() {
}
}
selections:
- anchor: {line: 1, character: 11}
active: {line: 1, character: 11}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
languageId: java
command:
version: 1
spokenForm: take type gust
action: setSelection
spokenForm: change type gust
action: clearAndSetSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
Expand All @@ -27,9 +27,9 @@ finalState:
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
List<> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
- anchor: {line: 3, character: 13}
active: {line: 3, character: 13}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
languageId: java
command:
version: 1
spokenForm: take type gust
action: setSelection
spokenForm: change type gust
action: clearAndSetSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
Expand All @@ -27,9 +27,9 @@ finalState:
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
}
}
selections:
- anchor: {line: 3, character: 32}
active: {line: 3, character: 49}
- anchor: {line: 3, character: 42}
active: {line: 3, character: 42}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
languageId: java
command:
version: 1
spokenForm: take type sun
action: setSelection
spokenForm: change type sun
action: clearAndSetSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
Expand All @@ -26,10 +26,10 @@ finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
Map<, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 27}
- anchor: {line: 2, character: 12}
active: {line: 2, character: 12}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
languageId: java
command:
version: 1
spokenForm: take type sun
action: setSelection
spokenForm: change type sun
action: clearAndSetSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
Expand All @@ -26,10 +26,10 @@ finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<String, >();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 2, character: 38}
active: {line: 2, character: 61}
- anchor: {line: 2, character: 54}
active: {line: 2, character: 54}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
languageId: java
command:
version: 1
spokenForm: take type trap
action: setSelection
spokenForm: change type trap
action: clearAndSetSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
Expand All @@ -26,10 +26,10 @@ finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
Map<String, > map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 27}
- anchor: {line: 2, character: 20}
active: {line: 2, character: 20}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
languageId: java
command:
version: 1
spokenForm: take type trap
action: setSelection
spokenForm: change type trap
action: clearAndSetSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
Expand All @@ -26,10 +26,10 @@ finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 2, character: 38}
active: {line: 2, character: 61}
- anchor: {line: 2, character: 46}
active: {line: 2, character: 46}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
languageId: java
command:
version: 6
spokenForm: take type
action:
name: setSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: type}
usePrePhraseSnapshot: true
initialState:
documentContents: |-
public class MyClass {
public void myFunk(int value) {
}
}
selections:
- anchor: {line: 1, character: 30}
active: {line: 1, character: 30}
marks: {}
finalState:
documentContents: |-
public class MyClass {
public void myFunk(int value) {
}
}
selections:
- anchor: {line: 1, character: 23}
active: {line: 1, character: 26}
41 changes: 41 additions & 0 deletions queries/java.scm
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,44 @@
(assignment_expression
left: (_) @name
) @_.domain

;;!! Map<String, String>
;;! ^^^^^^^ ^^^^^^
(type_arguments
(type_identifier) @type
)

;;!! List<String> list = value;
;;! ^^^^^^^^^^^^
;;! --------------------------
(local_variable_declaration
type: (_) @type
) @_.domain

;;!! name = new ArrayList<String>();
;;! ^^^^^^^^^^^^^^^^^
;;! -----------------------
(object_creation_expression
type: (_) @type
) @_.domain

;;!! name = new int[5];
;;! ^^^
;;! ----------
(array_creation_expression
type: (_) @type
) @_.domain

;;!! void myFunk(int value) {}
;;! ^^^
;;! ---------
(formal_parameter
type: (_) @type
) @_.domain

;;!! int size() {}
;;! ^^^
;;! -------------
(method_declaration
type: (_) @type
) @_.domain

0 comments on commit 7eda891

Please sign in to comment.