Skip to content

Commit e445197

Browse files
committed
chore: add activities post processor
1 parent 74d19e7 commit e445197

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rule:
2+
kind: user_type
3+
inside:
4+
kind: parameter
5+
regex: freeCancellationEndDateTime
6+
stopBy:
7+
kind: class_declaration
8+
regex: Builder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rule:
2+
kind: user_type
3+
pattern: $TYPE
4+
inside:
5+
any:
6+
- kind: class_parameter
7+
regex: freeCancellationEndDateTime
8+
- kind: nullable_type
9+
inside:
10+
kind: class_parameter
11+
regex: freeCancellationEndDateTime

customizations/generator/openapi/src/main/resources/post-processor/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {NonCancellableDateTimeRangeProcessor} from './processors/non-cancellable
55
import {PenaltyRuleProcessor} from './processors/penalty-rule-processor';
66
import {VendorLocationDetailsProcessor} from './processors/vendor-location-details-processor';
77
import {GetCarsListingsOperationParamsProcessor} from './processors/get-cars-listings-operation-params-processor';
8+
import {ActivitiesCancellationPolicyProcessor} from "./processors/activities-cancellation-policy-processor";
89

910
import * as path from 'path';
1011

@@ -34,4 +35,7 @@ switch (fileName) {
3435
case 'GetCarsListingsOperationParams':
3536
new GetCarsListingsOperationParamsProcessor().process(filePath);
3637
break;
38+
case 'ActivitiesCancellationPolicy':
39+
new ActivitiesCancellationPolicyProcessor().process(filePath);
40+
break;
3741
}
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 ActivitiesCancellationPolicyProcessor extends Processor {
6+
rules: RuleFunction[];
7+
id: String = 'car-cancellation-policy';
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-param-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-param-type');
27+
28+
return root.findAll(config).map(node => {
29+
return node.replace('java.time.LocalDateTime');
30+
});
31+
}
32+
}

0 commit comments

Comments
 (0)