Bug 496137 - [compiler][batch] support INFO problem severity
Problem summary should include infos as well.
Change-Id: Ib8b5c2ccd040819cb31f7b9e1a222e4f79977bab
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 6a16a3a..c0d0c32 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -2099,7 +2099,7 @@
" <classpaths>NORMALIZED SECTION</classpaths>\n" +
" <sources>\n" +
" <source output=\"---OUTPUT_DIR_PLACEHOLDER---\" path=\"---OUTPUT_DIR_PLACEHOLDER---" + File.separator + "X.java\">\n" +
- " <problems errors=\"1\" problems=\"1\" warnings=\"0\">\n" +
+ " <problems errors=\"1\" infos=\"0\" problems=\"1\" warnings=\"0\">\n" +
" <problem categoryID=\"40\" charEnd=\"28\" charStart=\"25\" id=\"UndefinedType\" line=\"3\" problemID=\"16777218\" severity=\"ERROR\">\n" +
" <message value=\"Zork cannot be resolved to a type\"/>\n" +
" <source_context sourceEnd=\"3\" sourceStart=\"0\" value=\"Zork z;\"/>\n" +
@@ -2112,7 +2112,7 @@
" </source>\n" +
" </sources>\n" +
" <stats>\n" +
- " <problem_summary errors=\"1\" problems=\"1\" tasks=\"0\" warnings=\"0\"/>\n" +
+ " <problem_summary errors=\"1\" infos=\"0\" problems=\"1\" tasks=\"0\" warnings=\"0\"/>\n" +
" </stats>\n" +
"</compiler>\n";
String normalizedExpectedLogContents =
@@ -11675,7 +11675,7 @@
" ^\n" +
"The value of the field X.i is not used\n" +
"----------\n" +
- "2 problems (1 error, 1 warning)\n",
+ "2 problems (1 error, 0 warnings, 1 info)\n",
true);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
@@ -11766,7 +11766,7 @@
" ^\n" +
"The value of the field X.i is not used\n" +
"----------\n" +
- "2 problems (1 error, 1 warning)\n",
+ "2 problems (1 error, 0 warnings, 1 info)\n",
true);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index 77841a6..acbad8e 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -134,6 +134,7 @@
private static final String NUMBER_OF_PROBLEMS = "problems"; //$NON-NLS-1$
private static final String NUMBER_OF_TASKS = "tasks"; //$NON-NLS-1$
private static final String NUMBER_OF_WARNINGS = "warnings"; //$NON-NLS-1$
+ private static final String NUMBER_OF_INFOS = "infos"; //$NON-NLS-1$
private static final String OPTION = "option"; //$NON-NLS-1$
private static final String OPTIONS = "options"; //$NON-NLS-1$
private static final String OUTPUT = "output"; //$NON-NLS-1$
@@ -636,6 +637,7 @@
if (count != 0) {
int errors = 0;
int warnings = 0;
+ int infos = 0;
for (int i = 0; i < count; i++) {
CategorizedProblem problem = (CategorizedProblem) problems.get(i);
if (problem != null) {
@@ -645,14 +647,17 @@
if (problem.isError()) {
errors++;
currentMain.globalErrorsCount++;
- } else if (problem.isWarning()) {
+ } else if (problem.isInfo()) {
+ currentMain.globalInfoCount++;
+ infos++;
+ } else {
currentMain.globalWarningsCount++;
warnings++;
}
}
}
if ((this.tagBits & Logger.XML) != 0) {
- if ((errors + warnings) != 0) {
+ if ((errors + warnings + infos) != 0) {
startLoggingExtraProblems(count);
for (int i = 0; i < count; i++) {
CategorizedProblem problem = (CategorizedProblem) problems.get(i);
@@ -812,6 +817,7 @@
if (count != 0) {
int errors = 0;
int warnings = 0;
+ int infos = 0;
int tasks = 0;
for (int i = 0; i < count; i++) {
CategorizedProblem problem = problems[i];
@@ -826,6 +832,9 @@
} else if (problem.getID() == IProblem.Task) {
currentMain.globalTasksCount++;
tasks++;
+ } else if (problem.isInfo()) {
+ currentMain.globalInfoCount++;
+ infos++;
} else {
currentMain.globalWarningsCount++;
warnings++;
@@ -833,8 +842,8 @@
}
}
if ((this.tagBits & Logger.XML) != 0) {
- if ((errors + warnings) != 0) {
- startLoggingProblems(errors, warnings);
+ if ((errors + warnings + infos) != 0) {
+ startLoggingProblems(errors, warnings, infos);
for (int i = 0; i < count; i++) {
CategorizedProblem problem = problems[i];
if (problem!= null) {
@@ -868,12 +877,13 @@
* @param globalWarningsCount
*/
public void logProblemsSummary(int globalProblemsCount,
- int globalErrorsCount, int globalWarningsCount, int globalTasksCount) {
+ int globalErrorsCount, int globalWarningsCount, int globalInfoCount, int globalTasksCount) {
if ((this.tagBits & Logger.XML) != 0) {
// generate xml
this.parameters.put(Logger.NUMBER_OF_PROBLEMS, Integer.valueOf(globalProblemsCount));
this.parameters.put(Logger.NUMBER_OF_ERRORS, Integer.valueOf(globalErrorsCount));
this.parameters.put(Logger.NUMBER_OF_WARNINGS, Integer.valueOf(globalWarningsCount));
+ this.parameters.put(Logger.NUMBER_OF_INFOS, Integer.valueOf(globalInfoCount));
this.parameters.put(Logger.NUMBER_OF_TASKS, Integer.valueOf(globalTasksCount));
printTag(Logger.PROBLEM_SUMMARY, this.parameters, true, true);
}
@@ -881,6 +891,8 @@
String message = null;
if (globalErrorsCount == 1) {
message = this.main.bind("compile.oneError"); //$NON-NLS-1$
+ } else if (globalInfoCount == 1) {
+ message = this.main.bind("compile.oneInfo"); //$NON-NLS-1$
} else {
message = this.main.bind("compile.oneWarning"); //$NON-NLS-1$
}
@@ -888,6 +900,7 @@
} else {
String errorMessage = null;
String warningMessage = null;
+ String infoMessage = null;
if (globalErrorsCount > 0) {
if (globalErrorsCount == 1) {
errorMessage = this.main.bind("compile.oneError"); //$NON-NLS-1$
@@ -903,26 +916,42 @@
warningMessage = this.main.bind("compile.severalWarnings", String.valueOf(warningsNumber)); //$NON-NLS-1$
}
}
- if (errorMessage == null || warningMessage == null) {
- if (errorMessage == null) {
- printErr(this.main.bind(
- "compile.severalProblemsErrorsOrWarnings", //$NON-NLS-1$
- String.valueOf(globalProblemsCount),
- warningMessage));
- } else {
- printErr(this.main.bind(
- "compile.severalProblemsErrorsOrWarnings", //$NON-NLS-1$
- String.valueOf(globalProblemsCount),
- errorMessage));
- }
- } else {
+ if (globalInfoCount == 1) {
+ infoMessage = this.main.bind("compile.oneInfo"); //$NON-NLS-1$
+ } else if (globalInfoCount > 1) {
+ infoMessage = this.main.bind("compile.severalInfos", String.valueOf(warningsNumber)); //$NON-NLS-1$
+ }
+ if (globalProblemsCount == globalInfoCount || globalProblemsCount == globalErrorsCount || globalProblemsCount == globalWarningsCount) {
+ String msg = errorMessage != null ? errorMessage : warningMessage != null ? warningMessage : infoMessage;
printErr(this.main.bind(
- "compile.severalProblemsErrorsAndWarnings", //$NON-NLS-1$
- new String[] {
- String.valueOf(globalProblemsCount),
- errorMessage,
- warningMessage
- }));
+ "compile.severalProblemsErrorsOrWarnings", //$NON-NLS-1$
+ String.valueOf(globalProblemsCount),
+ msg));
+ } else {
+ if (globalInfoCount == 0) {
+ printErr(this.main.bind(
+ "compile.severalProblemsErrorsAndWarnings", //$NON-NLS-1$
+ new String[] {
+ String.valueOf(globalProblemsCount),
+ errorMessage,
+ warningMessage
+ }));
+ } else {
+ if (errorMessage == null) {
+ errorMessage = this.main.bind("compile.severalErrors", String.valueOf(globalErrorsCount)); //$NON-NLS-1$
+ }
+ if (warningMessage == null) {
+ warningMessage = this.main.bind("compile.severalWarnings", String.valueOf(warningsNumber)); //$NON-NLS-1$
+ }
+ printErr(this.main.bind(
+ "compile.severalProblems", //$NON-NLS-1$
+ new String[] {
+ String.valueOf(globalProblemsCount),
+ errorMessage,
+ warningMessage,
+ infoMessage
+ }));
+ }
}
}
if ((this.tagBits & Logger.XML) == 0) {
@@ -1165,7 +1194,8 @@
logTiming(compilerStats);
}
if (this.main.globalProblemsCount > 0) {
- logProblemsSummary(this.main.globalProblemsCount, this.main.globalErrorsCount, this.main.globalWarningsCount, this.main.globalTasksCount);
+ logProblemsSummary(this.main.globalProblemsCount, this.main.globalErrorsCount, this.main.globalWarningsCount,
+ this.main.globalInfoCount, this.main.globalTasksCount);
}
if (this.main.exportedClassFilesCounter != 0
&& (this.main.showProgress || isTimed || this.main.verbose)) {
@@ -1225,10 +1255,11 @@
* Used to start logging problems.
* Only use in xml mode.
*/
- private void startLoggingProblems(int errors, int warnings) {
+ private void startLoggingProblems(int errors, int warnings, int infos) {
this.parameters.put(Logger.NUMBER_OF_PROBLEMS, Integer.valueOf(errors + warnings));
this.parameters.put(Logger.NUMBER_OF_ERRORS, Integer.valueOf(errors));
this.parameters.put(Logger.NUMBER_OF_WARNINGS, Integer.valueOf(warnings));
+ this.parameters.put(Logger.NUMBER_OF_INFOS, Integer.valueOf(infos));
printTag(Logger.PROBLEMS, this.parameters, true, false);
}
@@ -1334,6 +1365,7 @@
public int globalProblemsCount;
public int globalTasksCount;
public int globalWarningsCount;
+ public int globalInfoCount;
private File javaHomeCache;
@@ -1696,6 +1728,7 @@
this.globalProblemsCount = 0;
this.globalErrorsCount = 0;
this.globalWarningsCount = 0;
+ this.globalInfoCount = 0;
this.globalTasksCount = 0;
this.exportedClassFilesCounter = 0;
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
index 72140d7..61a6c01 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -42,10 +42,13 @@
compile.oneProblem = 1 problem ({0})
compile.severalProblemsErrorsOrWarnings = {0} problems ({1})
compile.severalProblemsErrorsAndWarnings = {0} problems ({1}, {2})
+compile.severalProblems = {0} problems ({1}, {2}, {3})
compile.oneError = 1 error
compile.severalErrors = {0} errors
compile.oneWarning = 1 warning
compile.severalWarnings = {0} warnings
+compile.oneInfo = 1 info
+compile.severalInfos = {0} info
compile.oneClassFileGenerated = [1 .class file generated]
compile.severalClassFilesGenerated = [{0} .class files generated]
diff --git a/org.eclipse.jdt.core/schema/compiler.dtd b/org.eclipse.jdt.core/schema/compiler.dtd
index 7d989a3..e83ee0a 100644
--- a/org.eclipse.jdt.core/schema/compiler.dtd
+++ b/org.eclipse.jdt.core/schema/compiler.dtd
@@ -39,6 +39,7 @@
<!ATTLIST problems problems CDATA #REQUIRED
errors CDATA #REQUIRED
warnings CDATA #REQUIRED
+ infos CDATA #REQUIRED
>
<!ATTLIST tasks tasks CDATA #REQUIRED>
<!ATTLIST problem charEnd CDATA #REQUIRED
@@ -73,6 +74,7 @@
<!ATTLIST problem_summary problems CDATA #REQUIRED
errors CDATA #REQUIRED
warnings CDATA #REQUIRED
+ infos CDATA #REQUIRED
tasks CDATA #REQUIRED
>
<!ATTLIST number_of_classfiles value CDATA #REQUIRED>