apex-dev-tools / apex-ls

Apex language server library
Other
2 stars 1 forks source link

Improve unused messages for outer types #221

Closed kjonescertinia closed 1 year ago

kjonescertinia commented 1 year ago

This changes the messages used when reporting an outer type is used only by test code. For classes we suggest using @isTest or @SuppressWarnings('Unused') if they need to keep the code, for interface & enum its similar but you can't use @isTest.

As part this I have added a workaround for an issue in the dependency handling for enum constants. We model these constants as fields with a value of the enclosing enum type. The validation on ApexFieldDeclaration was then creating a dependency between the field and its enclosing enum type which caused issues for the unused analysis. The workaround simply disables validation for ApexFieldDeclaration used as constants. We really need a better way to determine if body declarations have a dependency on the enclosing types but that is significantly more work then this issue justifies.