//TODO: switch expression candidate!
@Messages({
        "# {0} - variable name",
        "ERR_NeitherReadOrWritten=Variable {0} is neither read or written to",
        "# {0} - variable name",
        "ERR_NotWritten=Variable {0} is never written to",
        "# {0} - variable name",
        "ERR_NotRead=Variable {0} is never read",
        "# {0} - element name",
        "ERR_NotUsed={0} is never used",
        "ERR_NotUsedConstructor=Constructor is never used",
    })
    private static ErrorDescription convertUnused(HintContext ctx, UnusedDescription ud) {
        //TODO: switch expression candidate!
        String name = ud.unusedElement.getSimpleName().toString();
        String message;
        switch (ud.reason) {
            case NOT_WRITTEN_READ: message = Bundle.ERR_NeitherReadOrWritten(name); break;
            case NOT_WRITTEN: message = Bundle.ERR_NotWritten(name); break;
            case NOT_READ: message = Bundle.ERR_NotRead(name); break;
            case NOT_USED:
                if (ud.unusedElement.getKind() == ElementKind.CONSTRUCTOR) {
                    message = Bundle.ERR_NotUsedConstructor();
                } else {
                    message = Bundle.ERR_NotUsed(name);
                }
                break;
            default:
                throw new IllegalStateException("Unknown unused type: " + ud.reason);
        }
        return ErrorDescriptionFactory.forName(ctx, ud.unusedElementPath, message);
    }
})
private static ErrorDescription convertUnused(HintContext ctx, UnusedDescription ud) {
//TODO: switch expression candidate!
String name = ud.unusedElement.getSimpleName().toString();
String message;
"ERR_NeitherReadOrWritten=Variable {0} is neither read or written to",
"# {0} - variable name",
"ERR_NotWritten=Variable {0} is never written to",
"# {0} - variable name",
"ERR_NotRead=Variable {0} is never read",
"# {0} - element name",
"ERR_NotUsed={0} is never used",
"ERR_NotUsedConstructor=Constructor is never used",
})
private static ErrorDescription convertUnused(HintContext ctx, UnusedDescription ud) {
//TODO: switch expression candidate!
String name = ud.unusedElement.getSimpleName().toString();
String message;
switch (ud.reason) {
case NOT_WRITTEN_READ: message = Bundle.ERR_NeitherReadOrWritten(name); break;
case NOT_WRITTEN: message = Bundle.ERR_NotWritten(name); break;
case NOT_READ: message = Bundle.ERR_NotRead(name); break;
case NOT_USED:
if (ud.unusedElement.getKind() == ElementKind.CONSTRUCTOR) {
message = Bundle.ERR_NotUsedConstructor();
} else {
@Messages({
"# {0} - variable name",
"ERR_NeitherReadOrWritten=Variable {0} is neither read or written to",
"# {0} - variable name",
"ERR_NotWritten=Variable {0} is never written to",
"# {0} - variable name",
"ERR_NotRead=Variable {0} is never read",
"# {0} - element name",
"ERR_NotUsed={0} is never used",
"ERR_NotUsedConstructor=Constructor is never used",
})
private static ErrorDescription convertUnused(HintContext ctx, UnusedDescription ud) {
//TODO: switch expression candidate!
String name = ud.unusedElement.getSimpleName().toString();
String message;
switch (ud.reason) {
case NOT_WRITTEN_READ: message = Bundle.ERR_NeitherReadOrWritten(name); break;
case NOT_WRITTEN: message = Bundle.ERR_NotWritten(name); break;
case NOT_READ: message = Bundle.ERR_NotRead(name); break;
case NOT_USED:
if (ud.unusedElement.getKind() == ElementKind.CONSTRUCTOR) {
message = Bundle.ERR_NotUsedConstructor();
} else {
message = Bundle.ERR_NotUsed(name);
}
break;
default:
throw new IllegalStateException("Unknown unused type: " + ud.reason);
}
return ErrorDescriptionFactory.forName(ctx, ud.unusedElementPath, message);
}