Skip to content

Commit bc743b3

Browse files
committed
post-process GetCarsListingsOperationParams
1 parent a91a715 commit bc743b3

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rule:
2+
kind: user_type
3+
inside:
4+
any:
5+
- kind: parameter
6+
regex: pickupTime
7+
- kind: parameter
8+
regex: dropOffTime
9+
stopBy:
10+
kind: class_declaration
11+
regex: Builder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
rule:
2+
kind: user_type
3+
pattern: $TYPE
4+
inside:
5+
any:
6+
- kind: class_parameter
7+
regex: pickupTime
8+
- kind: class_parameter
9+
regex: dropOffTime
10+
- kind: nullable_type
11+
inside:
12+
any:
13+
- kind: class_parameter
14+
regex: pickupTime
15+
- kind: class_parameter
16+
regex: dropOffTime
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {Edit, NapiConfig, SgNode} from '@ast-grep/napi';
2+
import {Processor} from './processor';
3+
import {RuleFunction} from './shared.types';
4+
5+
export class NonCancellableDateTimeRangeProcessor extends Processor {
6+
rules: RuleFunction[];
7+
id: String = 'get-cars-listings-operation-params';
8+
9+
constructor() {
10+
super();
11+
this.rules = [
12+
this.changeClassParamType,
13+
this.changeBuilderMethodParamType,
14+
].map(rule => rule.bind(this));
15+
}
16+
17+
changeClassParamType(root: SgNode): Edit[] {
18+
const config = this.readRule('change-class-params-type');
19+
20+
return root.findAll(config).map(node => {
21+
return node.replace('java.time.LocalDateTime');
22+
});
23+
}
24+
25+
changeBuilderMethodParamType(root: SgNode): Edit[] {
26+
const config = this.readRule('change-builder-method-params-type');
27+
28+
return root.findAll(config).map(node => {
29+
return node.replace('java.time.LocalDateTime');
30+
});
31+
}
32+
}

0 commit comments

Comments
 (0)