Skip to content

Commit 561b17e

Browse files
authored
Merge pull request #7 from CodinGame/allow-no-source-file
Allow no source file
2 parents fafb46f + e347ddc commit 561b17e

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Diff for: src/main/java/com/codingame/codemachine/compiler/java/CodinGameJavaCompiler.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public static void main(String... args) throws IOException {
2424

2525
List<String> files = new ArrayList<>();
2626
List<String> options = new ArrayList<>();
27-
27+
2828
for (int i = 0; i < args.length; ++i) {
2929
String arg = args[i];
30-
30+
3131
if (arg.startsWith("-")) {
3232
int paramCount = compiler.isSupportedOption(arg);
3333
if (paramCount < 0) {
@@ -46,7 +46,7 @@ public static void main(String... args) throws IOException {
4646
files.add(arg);
4747
}
4848
}
49-
49+
5050
if (!files.isEmpty()) {
5151
Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromStrings(files);
5252
JavaCompiler.CompilationTask task =
@@ -68,12 +68,12 @@ public static void main(String... args) throws IOException {
6868
case OTHER:
6969
continue;
7070
}
71-
71+
7272
if (diagnostic.getLineNumber() >= 0 && diagnostic.getColumnNumber() >= 0) {
7373
LineNumberReader reader = new LineNumberReader(new StringReader(diagnostic.getSource().getCharContent(true).toString()));
7474
String line = reader.lines().skip(diagnostic.getLineNumber() - 1).limit(1).findAny().get();
75-
76-
System.err.println(String.format("%s:%d: %s: %s\n%s\n%"+diagnostic.getColumnNumber()+"s",
75+
76+
System.err.println(String.format("%s:%d: %s: %s\n%s\n%"+diagnostic.getColumnNumber()+"s",
7777
diagnostic.getSource().getName(),
7878
diagnostic.getLineNumber(),
7979
diagnostic.getKind().name().toLowerCase(),
@@ -82,13 +82,13 @@ public static void main(String... args) throws IOException {
8282
"^"
8383
));
8484
} else {
85-
System.err.println(String.format("%s: %s: %s",
85+
System.err.println(String.format("%s: %s: %s",
8686
diagnostic.getSource().getName(),
8787
diagnostic.getKind().name().toLowerCase(),
8888
diagnostic.getMessage(null)
8989
));
9090
}
91-
91+
9292
if (files.contains(diagnostic.getSource().getName())) {
9393
System.out.println(String.format("CG> annotate --type \"%s\" --file \"%s\" --position \"%s\" --message \"%s\"",
9494
type,
@@ -99,10 +99,8 @@ public static void main(String... args) throws IOException {
9999
}
100100
}
101101
resultCode = success ? 0 : 1;
102-
}
103-
else {
104-
System.err.println("no source file");
105-
resultCode = 2;
102+
} else {
103+
resultCode = 0;
106104
}
107105
}
108106

Diff for: src/main/resources/cgjavac

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

3-
echo "CG> redirect-streams --input err compilation"
3+
echo "TECHIO> redirect-streams --input err compilation"
44

55
java -jar /usr/src/codingame/java-compiler/java-compiler.jar "$@"
66
compilationExitCode=$?
77

8-
echo "CG> redirect-streams --reset --input err compilation"
8+
echo "TECHIO> redirect-streams --reset --input err compilation"
99

1010
exit $compilationExitCode

0 commit comments

Comments
 (0)