Extract method doesn't generate proper signature when return type is XXX.YYY where XXX is not in the class you are refactoring
This could be by design but I found it counterintuitive
Given this code fragment in class Foo
protected PatientsService.GenomicPatientRequest getGenomicPatientRequest() {
PatientsService.GenomicPatientRequest request = new PatientsService.GenomicPatientRequest();
for (Asset recollectableAsset: this.dropshipRecollectAssets) {
request.withRequestKey(new PatientsService.GenomicPatientRequestKey()
.withSourceId(recollectableAsset.Product2.Kit_Partner_Id__c)
.withUserId(recollectableAsset.UserId__c));
}
return request;
}
If I refactor (Extract Method
) the expression:
new PatientsService.GenomicPatientRequestKey()
.withSourceId(recollectableAsset.Product2.Kit_Partner_Id__c)
.withUserId(recollectableAsset.UserId__c)
The dialog shows the proper return type as PatientsService.GenomicPatientRequestKey
but the emitted code omits the top level class PatientsService
and generates this (omitting the top level class name PatientsService
as part of the return type):
private GenomicPatientRequestKey getGenomicPatientRequestKey(Asset recollectableAsset) {
return new PatientsService.GenomicPatientRequestKey()
.withSourceId(recollectableAsset.Product2.Kit_Partner_Id__c)
.withUserId(recollectableAsset.UserId__c);
}
Comments (5)
-
repo owner -
reporter The point of insertion is in an inner class
Foo.Bar
, the referenced return type is an inner class in a separate outer classPatientsService.cls
-
repo owner Yeah, that would be a bug. Let me play with it a bit and see why it's not using the fully-qualified name from that point of insertion.
-
repo owner Easily reproduced. Fix committed for inclusion in the next build. Currently planning on releasing tomorrow morning, but if that doesn't happen for some reason, it'll push to next Monday due to a Thursday-Sunday outage this week.
-
repo owner - changed status to resolved
Delivered in 2.1.9.0.
- Log in to comment
Hmmmm...it should only omit the top-level class portion if the inner class is accessible by that name from the point of insertion, i.e., either in the same top-level class or in a subclass where the inner class is visible. Sounds like that's not the case here, though, no? Assuming it's not, hopefully this will be easy to reproduce and fix.