|
3 | 3 | import org.klar.cli.error.diagnostic.KcDiagnosticCode; |
4 | 4 | import org.klar.cli.error.diagnostic.KcDiagnosticColors; |
5 | 5 |
|
6 | | -public class KcInvalidFileType extends KcCliException{ |
7 | | - private final String fileName; |
8 | | - |
9 | | - public KcInvalidFileType(KcDiagnosticCode code, String command, String fix, String fileName){ |
10 | | - super(code, command, fix); |
11 | | - |
12 | | - this.fileName = fileName; |
13 | | - } |
14 | | - |
15 | | - @Override |
16 | | - public String format() { |
17 | | - StringBuilder sb = new StringBuilder(); |
18 | | - sb.append(KcDiagnosticColors.structure("[K:")) |
19 | | - .append(KcDiagnosticColors.cliErrorCode(code.name())) |
20 | | - .append(KcDiagnosticColors.structure("] ")) |
21 | | - .append(KcDiagnosticColors.neutral(code.name)) |
22 | | - .append("\n"); |
23 | | - |
24 | | - // ERROR (Lexical) discreto, só informativo |
25 | | - sb.append(KcDiagnosticColors.structure("ERROR (" + code.phase.name() + ")")) |
26 | | - .append("\n"); |
27 | | - |
28 | | - sb.append(KcDiagnosticColors.structure("at input file")) |
29 | | - .append("\n\n"); |
30 | | - |
31 | | - sb.append(KcDiagnosticColors.structure("The file '")).append(KcDiagnosticColors.neutral(fileName)).append(KcDiagnosticColors.structure("' is not a Klang source file.")) |
32 | | - .append("\n\n"); |
33 | | - |
34 | | - sb.append(KcDiagnosticColors.structure("Cause:")) |
35 | | - .append("\n ") |
36 | | - .append(KcDiagnosticColors.neutral("Klar only processes files with the extensions '.kl' and '.klar'.")) |
37 | | - .append("\n\n"); |
38 | | - |
39 | | - sb.append(KcDiagnosticColors.structure("Fix:")) |
40 | | - .append("\n ") |
41 | | - .append(KcDiagnosticColors.neutral("Rename the file or select a valid '.kl' or '.klar' source.")) |
42 | | - .append("\n\n"); |
43 | | - |
44 | | - sb.append(KcDiagnosticColors.structure("Example:")) |
45 | | - .append("\n ") |
46 | | - .append(KcDiagnosticColors.neutral("kc " + this.command +" program.kl")); |
47 | | - |
48 | | - return sb.toString(); |
49 | | - } |
| 6 | +public class KcInvalidFileType extends KcCliException { |
| 7 | + private final String fileName; |
| 8 | + |
| 9 | + public KcInvalidFileType(KcDiagnosticCode code, String command, String fix, String fileName) { |
| 10 | + super(code, command, fix); |
| 11 | + |
| 12 | + this.fileName = fileName; |
| 13 | + } |
| 14 | + |
| 15 | + @Override |
| 16 | + public String format() { |
| 17 | + StringBuilder sb = new StringBuilder(); |
| 18 | + sb.append(KcDiagnosticColors.structure("[K:")) |
| 19 | + .append(KcDiagnosticColors.cliErrorCode(code.name())) |
| 20 | + .append(KcDiagnosticColors.structure("] ")) |
| 21 | + .append(KcDiagnosticColors.neutral(code.name)) |
| 22 | + .append("\n"); |
| 23 | + |
| 24 | + // ERROR (Lexical) discreto, só informativo |
| 25 | + sb.append(KcDiagnosticColors.structure("ERROR (" + code.phase.name() + ")")) |
| 26 | + .append("\n"); |
| 27 | + |
| 28 | + sb.append(KcDiagnosticColors.structure("at input file")) |
| 29 | + .append("\n\n"); |
| 30 | + |
| 31 | + sb.append(KcDiagnosticColors.structure("The file '")).append(KcDiagnosticColors.neutral(fileName)) |
| 32 | + .append(KcDiagnosticColors.structure("' is not a Klar source file.")) |
| 33 | + .append("\n\n"); |
| 34 | + |
| 35 | + sb.append(KcDiagnosticColors.structure("Cause:")) |
| 36 | + .append("\n ") |
| 37 | + .append(KcDiagnosticColors.neutral("Klar only processes files with the extensions '.kl' and '.klar'.")) |
| 38 | + .append("\n\n"); |
| 39 | + |
| 40 | + sb.append(KcDiagnosticColors.structure("Fix:")) |
| 41 | + .append("\n ") |
| 42 | + .append(KcDiagnosticColors.neutral("Rename the file or select a valid '.kl' or '.klar' source.")) |
| 43 | + .append("\n\n"); |
| 44 | + |
| 45 | + sb.append(KcDiagnosticColors.structure("Example:")) |
| 46 | + .append("\n ") |
| 47 | + .append(KcDiagnosticColors.neutral("kc " + this.command + " program.kl")); |
| 48 | + |
| 49 | + return sb.toString(); |
| 50 | + } |
50 | 51 | } |
0 commit comments