View | Details | Raw Unified | Return to bug 161129 | Differences between
and this patch

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-36 / +31 lines)
Lines 2204-2226 Link Here
2204
							this.bind("configure.invalidWarningConfiguration", warningOption)); //$NON-NLS-1$
2204
							this.bind("configure.invalidWarningConfiguration", warningOption)); //$NON-NLS-1$
2205
					}
2205
					}
2206
					int warnTokenStart;
2206
					int warnTokenStart;
2207
					boolean isEnabling, allowPlusOrMinus;
2207
					boolean isEnabling;
2208
					switch (warningOption.charAt(6)) {
2208
					switch (warningOption.charAt(6)) {
2209
						case '+' :
2209
						case '+' :
2210
							warnTokenStart = 7;
2210
							warnTokenStart = 7;
2211
							isEnabling = true;
2211
							isEnabling = true;
2212
							allowPlusOrMinus = true;
2213
							break;
2212
							break;
2214
						case '-' :
2213
						case '-' :
2215
							warnTokenStart = 7;
2214
							warnTokenStart = 7;
2216
							isEnabling = false; // specified warnings are disabled
2215
							isEnabling = false; // specified warnings are disabled
2217
							allowPlusOrMinus = true;
2218
							break;
2216
							break;
2219
						default:
2217
						default:
2220
							disableWarnings();
2218
							disableWarnings();
2221
							warnTokenStart = 6;
2219
							warnTokenStart = 6;
2222
							isEnabling = true;
2220
							isEnabling = true;
2223
							allowPlusOrMinus = false;
2224
					}
2221
					}
2225
2222
2226
					StringTokenizer tokenizer =
2223
					StringTokenizer tokenizer =
Lines 2236-2257 Link Here
2236
						tokenCounter++;
2233
						tokenCounter++;
2237
						switch(token.charAt(0)) {
2234
						switch(token.charAt(0)) {
2238
							case '+' :
2235
							case '+' :
2239
								if (allowPlusOrMinus) {
2236
								isEnabling = true;
2240
									isEnabling = true;
2237
								token = token.substring(1);
2241
									token = token.substring(1);
2242
								} else {
2243
									throw new IllegalArgumentException(
2244
											this.bind("configure.invalidUsageOfPlusOption", token)); //$NON-NLS-1$
2245
								}
2246
								break;
2238
								break;
2247
							case '-' :
2239
							case '-' :
2248
								if (allowPlusOrMinus) {
2240
								isEnabling = false;
2249
									isEnabling = false;
2241
								token = token.substring(1);
2250
									token = token.substring(1);
2251
								} else {
2252
									throw new IllegalArgumentException(
2253
											this.bind("configure.invalidUsageOfMinusOption", token)); //$NON-NLS-1$
2254
								}
2255
						}
2242
						}
2256
						handleWarningToken(token, isEnabling);
2243
						handleWarningToken(token, isEnabling);
2257
					}
2244
					}
Lines 2270-2292 Link Here
2270
							this.bind("configure.invalidErrorConfiguration", errorOption)); //$NON-NLS-1$
2257
							this.bind("configure.invalidErrorConfiguration", errorOption)); //$NON-NLS-1$
2271
					}
2258
					}
2272
					int errorTokenStart;
2259
					int errorTokenStart;
2273
					boolean isEnabling, allowPlusOrMinus;
2260
					boolean isEnabling;
2274
					switch (errorOption.charAt(5)) {
2261
					switch (errorOption.charAt(5)) {
2275
						case '+' :
2262
						case '+' :
2276
							errorTokenStart = 6;
2263
							errorTokenStart = 6;
2277
							isEnabling = true;
2264
							isEnabling = true;
2278
							allowPlusOrMinus = true;
2279
							break;
2265
							break;
2280
						case '-' :
2266
						case '-' :
2281
							errorTokenStart = 6;
2267
							errorTokenStart = 6;
2282
							isEnabling = false; // specified errors are disabled
2268
							isEnabling = false; // specified errors are disabled
2283
							allowPlusOrMinus = true;
2284
							break;
2269
							break;
2285
						default:
2270
						default:
2286
							disableErrors();
2271
							disableErrors();
2287
							errorTokenStart = 5;
2272
							errorTokenStart = 5;
2288
							isEnabling = true;
2273
							isEnabling = true;
2289
							allowPlusOrMinus = false;
2290
					}
2274
					}
2291
2275
2292
					StringTokenizer tokenizer =
2276
					StringTokenizer tokenizer =
Lines 2298-2319 Link Here
2298
						tokenCounter++;
2282
						tokenCounter++;
2299
						switch(token.charAt(0)) {
2283
						switch(token.charAt(0)) {
2300
							case '+' :
2284
							case '+' :
2301
								if (allowPlusOrMinus) {
2285
								isEnabling = true;
2302
									isEnabling = true;
2286
								token = token.substring(1);
2303
									token = token.substring(1);
2304
								} else {
2305
									throw new IllegalArgumentException(
2306
											this.bind("configure.invalidUsageOfPlusOption", token)); //$NON-NLS-1$
2307
								}
2308
								break;
2287
								break;
2309
							case '-' :
2288
							case '-' :
2310
								if (allowPlusOrMinus) {
2289
								isEnabling = false;
2311
									isEnabling = false;
2290
								token = token.substring(1);
2312
									token = token.substring(1);
2313
								} else {
2314
									throw new IllegalArgumentException(
2315
											this.bind("configure.invalidUsageOfMinusOption", token)); //$NON-NLS-1$
2316
								}
2317
								break;
2291
								break;
2318
						}
2292
						}
2319
						handleErrorToken(token, isEnabling);
2293
						handleErrorToken(token, isEnabling);
Lines 2838-2843 Link Here
2838
	}
2812
	}
2839
	this.options.put(CompilerOptions.OPTION_TaskTags, Util.EMPTY_STRING);
2813
	this.options.put(CompilerOptions.OPTION_TaskTags, Util.EMPTY_STRING);
2840
}
2814
}
2815
protected void enableAllWarnings() {
2816
	Object[] entries = this.options.entrySet().toArray();
2817
	for (int i = 0, max = entries.length; i < max; i++) {
2818
		Map.Entry entry = (Map.Entry) entries[i];
2819
		if (!(entry.getKey() instanceof String))
2820
			continue;
2821
		if (!(entry.getValue() instanceof String))
2822
			continue;
2823
		if (((String) entry.getValue()).equals(CompilerOptions.IGNORE)) {
2824
			this.options.put(entry.getKey(), CompilerOptions.WARNING);
2825
		}
2826
	}
2827
	this.options.put(CompilerOptions.OPTION_TaskTags, Util.EMPTY_STRING);
2828
}
2841
protected void disableErrors() {
2829
protected void disableErrors() {
2842
	Object[] entries = this.options.entrySet().toArray();
2830
	Object[] entries = this.options.entrySet().toArray();
2843
	for (int i = 0, max = entries.length; i < max; i++) {
2831
	for (int i = 0, max = entries.length; i < max; i++) {
Lines 3251-3256 Link Here
3251
				setSeverity(CompilerOptions.OPTION_ReportMethodCanBeStatic, severity, isEnabling);
3239
				setSeverity(CompilerOptions.OPTION_ReportMethodCanBeStatic, severity, isEnabling);
3252
				setSeverity(CompilerOptions.OPTION_ReportMethodCanBePotentiallyStatic, severity, isEnabling);
3240
				setSeverity(CompilerOptions.OPTION_ReportMethodCanBePotentiallyStatic, severity, isEnabling);
3253
				return;
3241
				return;
3242
			} else if (token.equals("all")) { //$NON-NLS-1$
3243
				if (isEnabling) {
3244
					enableAllWarnings();
3245
				} else {
3246
					disableWarnings();
3247
				}
3248
				return;
3254
			}
3249
			}
3255
			break;
3250
			break;
3256
		case 'b' :
3251
		case 'b' :
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (-2 / +1 lines)
Lines 66-73 Link Here
66
configure.invalidErrorConfiguration = invalid error configuration: ''{0}''
66
configure.invalidErrorConfiguration = invalid error configuration: ''{0}''
67
configure.invalidError = invalid error token: ''{0}''. Ignoring this error token and compiling
67
configure.invalidError = invalid error token: ''{0}''. Ignoring this error token and compiling
68
configure.invalidErrorOption = invalid error option: ''{0}''. Must specify an error token
68
configure.invalidErrorOption = invalid error option: ''{0}''. Must specify an error token
69
configure.invalidUsageOfPlusOption=usage of ''+'' for ''{0}'' is illegal there
70
configure.invalidUsageOfMinusOption=usage of ''-'' for ''{0}'' is illegal there
71
69
72
## configure.directoryNotExist = directory does not exist: {0}
70
## configure.directoryNotExist = directory does not exist: {0}
73
configure.unrecognizedOption = Unrecognized option : {0}
71
configure.unrecognizedOption = Unrecognized option : {0}
Lines 265-270 Link Here
265
\    -warn:<warnings separated by ,>    enable exactly the listed warnings\n\
263
\    -warn:<warnings separated by ,>    enable exactly the listed warnings\n\
266
\    -warn:+<warnings separated by ,>   enable additional warnings\n\
264
\    -warn:+<warnings separated by ,>   enable additional warnings\n\
267
\    -warn:-<warnings separated by ,>   disable specific warnings\n\
265
\    -warn:-<warnings separated by ,>   disable specific warnings\n\
266
\      all                  enable all warnings\n\
268
\      allDeadCode          dead code including trivial if(DEBUG) check\n\
267
\      allDeadCode          dead code including trivial if(DEBUG) check\n\
269
\      allDeprecation       deprecation including inside deprecated code\n\
268
\      allDeprecation       deprecation including inside deprecated code\n\
270
\      allJavadoc           invalid or missing javadoc\n\
269
\      allJavadoc           invalid or missing javadoc\n\
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-60 / +1 lines)
Lines 1659-1664 Link Here
1659
        "    -warn:<warnings separated by ,>    enable exactly the listed warnings\n" + 
1659
        "    -warn:<warnings separated by ,>    enable exactly the listed warnings\n" + 
1660
        "    -warn:+<warnings separated by ,>   enable additional warnings\n" + 
1660
        "    -warn:+<warnings separated by ,>   enable additional warnings\n" + 
1661
        "    -warn:-<warnings separated by ,>   disable specific warnings\n" + 
1661
        "    -warn:-<warnings separated by ,>   disable specific warnings\n" + 
1662
        "      all                  enable all warnings\n" + 
1662
        "      allDeadCode          dead code including trivial if(DEBUG) check\n" + 
1663
        "      allDeadCode          dead code including trivial if(DEBUG) check\n" + 
1663
        "      allDeprecation       deprecation including inside deprecated code\n" + 
1664
        "      allDeprecation       deprecation including inside deprecated code\n" + 
1664
        "      allJavadoc           invalid or missing javadoc\n" + 
1665
        "      allJavadoc           invalid or missing javadoc\n" + 
Lines 8510-8557 Link Here
8510
		"1 problem (1 warning)",
8511
		"1 problem (1 warning)",
8511
		true);
8512
		true);
8512
}
8513
}
8513
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518
8514
// variant
8515
public void test214_warn_options() {
8516
	// same source as 153, skip default checks
8517
	this.runNegativeTest(
8518
		new String[] {
8519
			"X.java",
8520
			"public class X {\n" +
8521
			"	public static void foo() {\n" +
8522
			"     String s = null;\n" +
8523
			"     s.toString();\n" +
8524
			"     String u;\n" +
8525
			"   }\n" +
8526
			"}",
8527
		},
8528
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
8529
		+ " -warn:null,-unused -proc:none -d \"" + OUTPUT_DIR + "\"",
8530
		"",
8531
		"usage of \'-\' for \'-unused\' is illegal there\n",
8532
		true);
8533
}
8534
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518
8535
// variant
8536
public void test215_warn_options() {
8537
	// same source as 153, skip default checks
8538
	this.runNegativeTest(
8539
		new String[] {
8540
			"X.java",
8541
			"public class X {\n" +
8542
			"	public static void foo() {\n" +
8543
			"     String s = null;\n" +
8544
			"     s.toString();\n" +
8545
			"     String u;\n" +
8546
			"   }\n" +
8547
			"}",
8548
		},
8549
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
8550
		+ " -warn:null,+unused -proc:none -d \"" + OUTPUT_DIR + "\"",
8551
		"",
8552
		"usage of \'+\' for \'+unused\' is illegal there\n",
8553
		true);
8554
}
8555
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=211588
8514
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=211588
8556
// variant - check impact of javadoc upon other warnings
8515
// variant - check impact of javadoc upon other warnings
8557
public void _test216a_warn_options() {
8516
public void _test216a_warn_options() {
Lines 11398-11421 Link Here
11398
		true);
11357
		true);
11399
}
11358
}
11400
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=280784
11359
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=280784
11401
public void test295(){
11402
	this.runNegativeTest(
11403
		new String[] {
11404
			"src/X.java",
11405
			"public class X {\n" +
11406
			"}",
11407
		},
11408
		"\"" + OUTPUT_DIR +  File.separator + "src/X.java\""
11409
		+ " -cp \"" + LIB_DIR + "\""
11410
		+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
11411
		+ " -1.5 -g -preserveAllLocals"
11412
		+ " -proceedOnError -referenceInfo -err:raw,+discouraged"
11413
		+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
11414
		"",
11415
		"usage of \'+\' for \'+discouraged\' is illegal there\n",
11416
		true);
11417
}
11418
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=280784
11419
public void test296(){
11360
public void test296(){
11420
	this.runNegativeTest(
11361
	this.runNegativeTest(
11421
		new String[] {
11362
		new String[] {

Return to bug 161129