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

Include generic in java type definition #372

Merged
merged 9 commits into from
Dec 10, 2021
2 changes: 2 additions & 0 deletions src/languages/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
name: ["*[declarator][name]", "*[name]", "formal_parameter.identifier!"],
namedFunction: ["method_declaration", "constructor_declaration"],
type: trailingMatcher([
"generic_type.type_arguments.type_identifier",
"generic_type.type_identifier",
"type_identifier",
"local_variable_declaration[type]",
"array_creation_expression[type]",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not worth rewriting all these tests, but I thought we had aligned on "clear" instead of "take" to make these tests easier to read. Makes it a bit painful having to manually count offsets to figure out what the test is doing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're completely correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fwiw I'm planning a rework of the tests to make modifier tests clearer / more compact, and then the "clear" / "take" thing won't matter. Not sure if I've already filed an issue but I will at some point

Copy link
Member Author

@AndreasArvidsson AndreasArvidsson Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds really useful

command:
version: 1
spokenForm: take type blue look
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: blue, character: l}
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: 38}
active: {line: 2, character: 61}
marks:
blue.l:
start: {line: 3, character: 8}
end: {line: 3, character: 12}
finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
thatMark:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: blue, character: l}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type gust
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: g}
initialState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
marks:
default.g:
start: {line: 3, character: 13}
end: {line: 3, character: 19}
finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
thatMark:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: g}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type gust
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: g}
initialState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 3, character: 32}
active: {line: 3, character: 49}
marks:
default.g:
start: {line: 3, character: 42}
end: {line: 3, character: 48}
finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
AndreasArvidsson marked this conversation as resolved.
Show resolved Hide resolved
}
}
selections:
- anchor: {line: 3, character: 32}
active: {line: 3, character: 49}
thatMark:
- anchor: {line: 3, character: 32}
active: {line: 3, character: 49}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: g}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type harp
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: h}
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: 8}
active: {line: 2, character: 27}
marks:
default.h:
start: {line: 2, character: 38}
end: {line: 2, character: 45}
finalState:
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: 38}
active: {line: 2, character: 61}
thatMark:
- anchor: {line: 2, character: 38}
active: {line: 2, character: 61}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: h}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type look
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: l}
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: 27}
active: {line: 2, character: 27}
marks:
default.l:
start: {line: 3, character: 21}
end: {line: 3, character: 25}
finalState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
thatMark:
- anchor: {line: 3, character: 8}
active: {line: 3, character: 20}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: l}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
39 changes: 39 additions & 0 deletions src/test/suite/fixtures/recorded/languages/java/takeTypePit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type pit
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: p}
initialState:
documentContents: |-
public class MyClass {
private MyClass () {
Map<String, String> map = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
}
}
selections:
- anchor: {line: 3, character: 52}
active: {line: 3, character: 52}
marks:
default.p:
start: {line: 2, character: 8}
end: {line: 2, character: 11}
finalState:
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: 8}
active: {line: 2, character: 27}
thatMark:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 27}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: p}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type soon
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: s}
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: 8}
active: {line: 2, character: 27}
marks:
default.s:
start: {line: 2, character: 12}
end: {line: 2, character: 18}
finalState:
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: 8}
active: {line: 2, character: 27}
thatMark:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 27}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type soon
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: s}
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: 38}
active: {line: 2, character: 61}
marks:
default.s:
start: {line: 2, character: 54}
end: {line: 2, character: 60}
finalState:
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: 38}
active: {line: 2, character: 61}
thatMark:
- anchor: {line: 2, character: 38}
active: {line: 2, character: 61}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: java
command:
version: 1
spokenForm: take type trap
action: setSelection
targets:
- type: primitive
modifier: {type: containingScope, scopeType: type, includeSiblings: false}
mark: {type: decoratedSymbol, symbolColor: default, character: t}
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: 8}
active: {line: 2, character: 27}
marks:
default.t:
start: {line: 2, character: 20}
end: {line: 2, character: 26}
finalState:
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: 8}
active: {line: 2, character: 27}
thatMark:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 27}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: t}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: type, includeSiblings: false}}]
Loading