shortenFullyQualifiedTypes does not shorten all the fully qualified types #3039
Copy link
Copy link
Open
Description
Summary
shortenFullyQualifiedTypes shortens a fully-qualified reference into the simple name of a type declared in the same compilation unit. The result does not compile.
Reproducer
spotless-gradle-plugin 8.10.1, with shortenFullyQualifiedTypes as one of the steps:
Test example 1:
import java.lang.management.BufferPoolMXBean;
import java.util.List;
public class ClassA
{
public void methodA()
{
final List<BufferPoolMXBean> pools = java.lang.management.ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
}
}Actual behavior of example 1:
Type java.lang.management.ManagementFactory used in code is not shortened.
Test example 2:
public class classB {
final List<CustomTypeProperty> connectionProps = List.of(new CustomTypeProperty().name("host")
.type(pkg.models.CustomTypeProperty.TypeEnum.STRING));
}Actual behavior of example 2:
Type pkg.models.CustomTypeProperty used in code is not shortened.
Expected behavior
All FQT should be shortened.
FYI @maxandersen
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
shortenFullyQualifiedTypes: shorten FQTs in expression context (diffp…