Skip to content

Commit 6fcdfb8

Browse files
chore: corrected the interface impl in apex
1 parent 48e180b commit 6fcdfb8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/migration/related/ApexMigration.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,27 @@ export class ApexMigration extends BaseRelatedObjectMigration {
283283
const implementsInterface = parser.implementsInterfaces;
284284
const tokenUpdates: TokenUpdater[] = [];
285285

286+
const hasCallable = implementsInterface.has(this.callableInterface);
287+
const hasVlocityOpenInterface2 = implementsInterface.has(this.vlocityOpenInterface2);
288+
const hasVlocityOpenInterface = implementsInterface.has(this.vlocityOpenInterface);
289+
286290
// Case 1: Already implements just System.Callable - no changes needed
287-
if (implementsInterface.has(this.callableInterface) && implementsInterface.size === 1) {
291+
if (hasCallable && implementsInterface.size === 1) {
288292
Logger.info(assessMessages.getMessage('fileAlreadyImplementsCallable', [file.name]));
289293
return tokenUpdates;
290294
}
291295

292-
// Case 2: Already implements multiple interfaces including Callable - keep only System.Callable
293-
if (implementsInterface.has(this.callableInterface) && implementsInterface.size > 1) {
296+
// Case 2: Multiple interfaces need to be replaced with System.Callable:
297+
// - Has System.Callable with other interfaces, OR
298+
// - Has both VlocityOpenInterface and VlocityOpenInterface2
299+
if ((hasCallable && implementsInterface.size > 1) || (hasVlocityOpenInterface2 && hasVlocityOpenInterface)) {
294300
Logger.logger.info(assessMessages.getMessage('apexFileHasMultipleInterfaces', [file.name]));
295301
// We need to identify the entire implements clause and replace it
296302
return this.replaceAllInterfaces(implementsInterface, tokenUpdates, parser, file.name);
297303
}
298304

299-
// Case 3: Implements VlocityOpenInterface2 - replace with System.Callable
300-
if (implementsInterface.has(this.vlocityOpenInterface2)) {
305+
// Case 3: Implements only VlocityOpenInterface2 - replace with System.Callable
306+
if (hasVlocityOpenInterface2) {
301307
Logger.logger.info(assessMessages.getMessage('apexFileImplementsVlocityOpenInterface2', [file.name]));
302308
const tokens = implementsInterface.get(this.vlocityOpenInterface2);
303309
tokenUpdates.push(new RangeTokenUpdate(CALLABLE, tokens[0], tokens[1]));
@@ -306,7 +312,9 @@ export class ApexMigration extends BaseRelatedObjectMigration {
306312
} else {
307313
Logger.logger.info(assessMessages.getMessage('apexFileAlreadyHasCallMethod', [file.name]));
308314
}
309-
} else if (implementsInterface.has(this.vlocityOpenInterface)) {
315+
}
316+
// Case 4: Implements only VlocityOpenInterface - replace with System.Callable
317+
else if (hasVlocityOpenInterface) {
310318
Logger.logger.info(assessMessages.getMessage('fileImplementsVlocityOpenInterface', [file.name]));
311319
const tokens = implementsInterface.get(this.vlocityOpenInterface);
312320
tokenUpdates.push(new RangeTokenUpdate(CALLABLE, tokens[0], tokens[1]));

0 commit comments

Comments
 (0)