File tree Expand file tree Collapse file tree 2 files changed +115
-0
lines changed Expand file tree Collapse file tree 2 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ ; Run the main function
2+ (
3+ (package_declaration
4+ (scoped_identifier) @java_package_name
5+ )
6+ (class_declaration
7+ (modifiers) @class -modifier
8+ (#match? @class -modifier "public")
9+ name: (identifier) @java_class_name
10+ body: (class_body
11+ (method_declaration
12+ (modifiers) @modifier
13+ name: (identifier) @run
14+ (#eq? @run "main")
15+ (#match? @modifier "public")
16+ (#match? @modifier "static")
17+ )
18+ )
19+ ) @_
20+ (#set! tag java-main)
21+ )
22+
23+ ; Run the main class
24+ (
25+ (package_declaration
26+ (scoped_identifier) @java_package_name
27+ )
28+ (class_declaration
29+ (modifiers) @class -modifier
30+ (#match? @class -modifier "public")
31+ name: (identifier) @java_class_name @run
32+ body: (class_body
33+ (method_declaration
34+ (modifiers) @modifier
35+ name: (identifier) @method_name
36+ (#eq? @method_name "main")
37+ (#match? @modifier "public")
38+ (#match? @modifier "static")
39+ )
40+ )
41+ ) @_
42+ (#set! tag java-main)
43+ )
44+
45+ ; Run test function
46+ (
47+ (package_declaration
48+ (scoped_identifier) @java_package_name
49+ )
50+ (class_declaration
51+ name: (identifier) @java_class_name
52+ body: (class_body
53+ (method_declaration
54+ (modifiers
55+ (marker_annotation
56+ name: (identifier) @annotation_name
57+ )
58+ )
59+ name: (identifier) @run @java_method_name
60+ (#eq? @annotation_name "Test")
61+ )
62+ )
63+ ) @_
64+ (#set! tag java-test-method)
65+ )
66+
67+ ; Run test class
68+ (
69+ (package_declaration
70+ (scoped_identifier) @java_package_name
71+ )
72+ (class_declaration
73+ name: (identifier) @java_class_name @run
74+ body: (class_body
75+ (method_declaration
76+ (modifiers
77+ (marker_annotation
78+ name: (identifier) @annotation_name
79+ )
80+ )
81+ (#eq? @annotation_name "Test")
82+ )
83+ )
84+ ) @_
85+ (#set! tag java-test-class)
86+ )
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "label" : " Run $ZED_CUSTOM_java_class_name" ,
4+ "command" : " c=\" $ZED_CUSTOM_java_package_name.$ZED_CUSTOM_java_class_name\" ; if [ -f pom.xml ]; then mvn clean compile exec:java -Dexec.mainClass=$c; elif [ -f gradlew ]; then ./gradlew run -PmainClass=$c; else >&2 echo 'No build system found'; exit 1; fi;" ,
5+ "use_new_terminal" : false ,
6+ "reveal" : " always" ,
7+ "tags" : [" java-main" ]
8+ },
9+ {
10+ "label" : " Test $ZED_CUSTOM_java_class_name.$ZED_CUSTOM_java_method_name" ,
11+ "command" : " c=\" $ZED_CUSTOM_java_package_name.$ZED_CUSTOM_java_class_name\" ; m=\" $ZED_CUSTOM_java_method_name\" ; if [ -f pom.xml ]; then mvn clean test -Dtest=\" $c#$m\" ; elif [ -f gradlew ]; then ./gradlew test --tests $c.$m; else >&2 echo 'No build system found'; exit 1; fi;" ,
12+ "use_new_terminal" : false ,
13+ "reveal" : " always" ,
14+ "tags" : [" java-test-method" ]
15+ },
16+ {
17+ "label" : " Test class $ZED_CUSTOM_java_class_name" ,
18+ "command" : " c=\" $ZED_CUSTOM_java_package_name.$ZED_CUSTOM_java_class_name\" ; if [ -f pom.xml ]; then mvn clean test -Dtest=\" $c\" ; elif [ -f gradlew ]; then ./gradlew test --tests $c; else >&2 echo 'No build system found'; exit 1; fi;" ,
19+ "use_new_terminal" : false ,
20+ "reveal" : " always" ,
21+ "tags" : [" java-test-class" ]
22+ },
23+ {
24+ "label" : " Run tests" ,
25+ "command" : " if [ -f pom.xml ]; then mvn clean test; elif [ -f gradlew ]; then ./gradlew test; else >&2 echo 'No build system found'; exit 1; fi;" ,
26+ "use_new_terminal" : false ,
27+ "reveal" : " always"
28+ }
29+ ]
You can’t perform that action at this time.
0 commit comments