Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2005, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 104-120
Link Here
|
104 |
|
104 |
|
105 |
protected ArrayList fProblemList = new ArrayList(); |
105 |
protected ArrayList fProblemList = new ArrayList(); |
106 |
protected int fBuildSeverity; |
106 |
protected int fBuildSeverity; |
107 |
private int fClasspathSeverity; |
107 |
protected int fClasspathSeverity; |
|
|
108 |
protected int fJavaComplSeverity; |
109 |
protected int fSrcInclSeverity; |
110 |
protected int fBinInclSeverity; |
111 |
protected int fMissingOutputLibSeverity; |
112 |
protected int fSrcLibSeverity; |
113 |
protected int fOututLibSeverity; |
108 |
|
114 |
|
109 |
public BuildErrorReporter(IFile buildFile) { |
115 |
public BuildErrorReporter(IFile buildFile) { |
110 |
super(buildFile); |
116 |
super(buildFile); |
|
|
117 |
fBuildSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD); |
118 |
fClasspathSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_UNRESOLVED_IMPORTS); |
119 |
fMissingOutputLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_MISSING_OUTPUT); |
120 |
fSrcLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SOURCE_LIBRARY); |
121 |
fOututLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_OUTPUT_LIBRARY); |
122 |
fJavaComplSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_JAVA_COMPLIANCE); |
123 |
fSrcInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SRC_INCLUDES); |
124 |
fBinInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_BIN_INCLUDES); |
111 |
} |
125 |
} |
112 |
|
126 |
|
113 |
public void validate(IProgressMonitor monitor) { |
127 |
public void validate(IProgressMonitor monitor) { |
114 |
fBuildSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD); |
128 |
/*if (fBuildSeverity == CompilerFlags.IGNORE && fClasspathSeverity == CompilerFlags.IGNORE) |
115 |
fClasspathSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_UNRESOLVED_IMPORTS); |
129 |
return;*/ |
116 |
if (fBuildSeverity == CompilerFlags.IGNORE && fClasspathSeverity == CompilerFlags.IGNORE) |
|
|
117 |
return; |
118 |
WorkspaceBuildModel wbm = new WorkspaceBuildModel(fFile); |
130 |
WorkspaceBuildModel wbm = new WorkspaceBuildModel(fFile); |
119 |
wbm.load(); |
131 |
wbm.load(); |
120 |
if (!wbm.isLoaded()) |
132 |
if (!wbm.isLoaded()) |
Lines 192-207
Link Here
|
192 |
validateDependencyManagement(bundleList); |
204 |
validateDependencyManagement(bundleList); |
193 |
} |
205 |
} |
194 |
|
206 |
|
195 |
// rest of validation relies on build flag |
|
|
196 |
if (fBuildSeverity == CompilerFlags.IGNORE) |
197 |
return; |
198 |
|
199 |
if (jarsExtra != null) |
207 |
if (jarsExtra != null) |
200 |
validateJarsExtraClasspath(jarsExtra); |
208 |
validateJarsExtraClasspath(jarsExtra); |
201 |
validateIncludes(binIncludes, sourceEntryKeys); |
209 |
validateIncludes(binIncludes, sourceEntryKeys, fBinInclSeverity); |
202 |
validateIncludes(binExcludes, sourceEntryKeys); |
210 |
validateIncludes(binExcludes, sourceEntryKeys, fBinInclSeverity); |
203 |
validateIncludes(srcIncludes, sourceEntryKeys); |
211 |
validateIncludes(srcIncludes, sourceEntryKeys, fSrcInclSeverity); |
204 |
validateIncludes(srcExcludes, sourceEntryKeys); |
212 |
validateIncludes(srcExcludes, sourceEntryKeys, fSrcInclSeverity); |
205 |
validateSourceFoldersInSrcIncludes(srcIncludes); |
213 |
validateSourceFoldersInSrcIncludes(srcIncludes); |
206 |
|
214 |
|
207 |
try { |
215 |
try { |
Lines 210-216
Link Here
|
210 |
IClasspathEntry[] cpes = jp.getRawClasspath(); |
218 |
IClasspathEntry[] cpes = jp.getRawClasspath(); |
211 |
validateMissingLibraries(sourceEntryKeys, cpes); |
219 |
validateMissingLibraries(sourceEntryKeys, cpes); |
212 |
validateSourceEntries(sourceEntries, cpes); |
220 |
validateSourceEntries(sourceEntries, cpes); |
213 |
SourceEntryErrorReporter srcEntryErrReporter = new SourceEntryErrorReporter(fFile, fBuildSeverity); |
221 |
SourceEntryErrorReporter srcEntryErrReporter = new SourceEntryErrorReporter(fFile); |
214 |
srcEntryErrReporter.initialize(sourceEntries, outputEntries, cpes, fProject); |
222 |
srcEntryErrReporter.initialize(sourceEntries, outputEntries, cpes, fProject); |
215 |
srcEntryErrReporter.validate(); |
223 |
srcEntryErrReporter.validate(); |
216 |
ArrayList problems = srcEntryErrReporter.getProblemList(); |
224 |
ArrayList problems = srcEntryErrReporter.getProblemList(); |
Lines 292-321
Link Here
|
292 |
if (projectJavaCompatibility != null) { |
300 |
if (projectJavaCompatibility != null) { |
293 |
if (jreCompilationProfileEntry == null) { |
301 |
if (jreCompilationProfileEntry == null) { |
294 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
302 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
295 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_EE); |
303 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
296 |
} else { |
304 |
} else { |
297 |
if (!projectJavaCompatibility.equalsIgnoreCase(jreCompilationProfileEntry.getTokens()[0])) { |
305 |
if (!projectJavaCompatibility.equalsIgnoreCase(jreCompilationProfileEntry.getTokens()[0])) { |
298 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
306 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
299 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_REPLACE, PDEMarkerFactory.CAT_EE); |
307 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
300 |
} |
308 |
} |
301 |
} |
309 |
} |
302 |
} else { |
310 |
} else { |
303 |
if (javacSourceEntry == null) { |
311 |
if (javacSourceEntry == null) { |
304 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
312 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
305 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_EE); |
313 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
306 |
} else { |
314 |
} else { |
307 |
if (!projectSourceCompatibility.equalsIgnoreCase(javacSourceEntry.getTokens()[0])) { |
315 |
if (!projectSourceCompatibility.equalsIgnoreCase(javacSourceEntry.getTokens()[0])) { |
308 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
316 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
309 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_REPLACE, PDEMarkerFactory.CAT_EE); |
317 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
310 |
} |
318 |
} |
311 |
} |
319 |
} |
312 |
if (javacTargetEntry == null) { |
320 |
if (javacTargetEntry == null) { |
313 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
321 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
314 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_EE); |
322 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
315 |
} else { |
323 |
} else { |
316 |
if (!projectClassCompatibility.equalsIgnoreCase(javacTargetEntry.getTokens()[0])) { |
324 |
if (!projectClassCompatibility.equalsIgnoreCase(javacTargetEntry.getTokens()[0])) { |
317 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
325 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
318 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_REPLACE, PDEMarkerFactory.CAT_EE); |
326 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
319 |
} |
327 |
} |
320 |
} |
328 |
} |
321 |
} |
329 |
} |
Lines 341-347
Link Here
|
341 |
if (javacWarningsEntry == null) { |
349 |
if (javacWarningsEntry == null) { |
342 |
if (warningToken.length() > 0) { |
350 |
if (warningToken.length() > 0) { |
343 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_WARNINGS_PREFIX, PDECoreMessages.BuildErrorReporter_DisallowIdentifiers); |
351 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_WARNINGS_PREFIX, PDECoreMessages.BuildErrorReporter_DisallowIdentifiers); |
344 |
prepareError(JAVAC_WARNINGS_ENTRY, warningToken, message, PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_EE); |
352 |
prepareError(JAVAC_WARNINGS_ENTRY, warningToken, message, PDEMarkerFactory.B_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
345 |
} |
353 |
} |
346 |
} else { |
354 |
} else { |
347 |
if (javacWarningsEntry.contains(ASSERT_IDENTIFIER) || javacWarningsEntry.contains('+' + ASSERT_IDENTIFIER) || javacWarningsEntry.contains('-' + ASSERT_IDENTIFIER)) { |
355 |
if (javacWarningsEntry.contains(ASSERT_IDENTIFIER) || javacWarningsEntry.contains('+' + ASSERT_IDENTIFIER) || javacWarningsEntry.contains('-' + ASSERT_IDENTIFIER)) { |
Lines 355-361
Link Here
|
355 |
warningToken = join(assertToken, enumToken); |
363 |
warningToken = join(assertToken, enumToken); |
356 |
if (warningToken.length() > 0) { |
364 |
if (warningToken.length() > 0) { |
357 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_WARNINGS_PREFIX, PDECoreMessages.BuildErrorReporter_DisallowIdentifiers); |
365 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_WARNINGS_PREFIX, PDECoreMessages.BuildErrorReporter_DisallowIdentifiers); |
358 |
prepareError(JAVAC_WARNINGS_ENTRY, warningToken, message, PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_EE); |
366 |
prepareError(JAVAC_WARNINGS_ENTRY, warningToken, message, PDEMarkerFactory.B_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
359 |
} |
367 |
} |
360 |
} |
368 |
} |
361 |
} |
369 |
} |
Lines 486-492
Link Here
|
486 |
} |
494 |
} |
487 |
|
495 |
|
488 |
if (!exists) { |
496 |
if (!exists) { |
489 |
prepareError(PROPERTY_BIN_INCLUDES, key, NLS.bind(PDECoreMessages.BuildErrorReporter_binIncludesMissing, key), PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_FATAL); |
497 |
prepareError(PROPERTY_BIN_INCLUDES, key, NLS.bind(PDECoreMessages.BuildErrorReporter_binIncludesMissing, key), PDEMarkerFactory.B_ADDDITION, fBinInclSeverity, PDEMarkerFactory.CAT_FATAL); |
490 |
} |
498 |
} |
491 |
} |
499 |
} |
492 |
|
500 |
|
Lines 550-556
Link Here
|
550 |
found = true; |
558 |
found = true; |
551 |
} |
559 |
} |
552 |
if (!found) |
560 |
if (!found) |
553 |
prepareError(PROPERTY_BIN_INCLUDES, key, NLS.bind(PDECoreMessages.BuildErrorReporter_binIncludesMissing, key), PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_FATAL); |
561 |
prepareError(PROPERTY_BIN_INCLUDES, key, NLS.bind(PDECoreMessages.BuildErrorReporter_binIncludesMissing, key), PDEMarkerFactory.B_ADDDITION, fBinInclSeverity, PDEMarkerFactory.CAT_FATAL); |
554 |
} |
562 |
} |
555 |
} |
563 |
} |
556 |
|
564 |
|
Lines 565-571
Link Here
|
565 |
for (int i = 0; i < cpes.length; i++) { |
573 |
for (int i = 0; i < cpes.length; i++) { |
566 |
if (cpes[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { |
574 |
if (cpes[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { |
567 |
if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) |
575 |
if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) |
568 |
prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, PDEMarkerFactory.CAT_OTHER); |
576 |
prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, fSrcInclSeverity, PDEMarkerFactory.CAT_OTHER); |
569 |
break; |
577 |
break; |
570 |
} |
578 |
} |
571 |
} |
579 |
} |
Lines 579-585
Link Here
|
579 |
for (int j = 0; j < cpes.length; j++) { |
587 |
for (int j = 0; j < cpes.length; j++) { |
580 |
if (cpes[j].getEntryKind() == IClasspathEntry.CPE_SOURCE) { |
588 |
if (cpes[j].getEntryKind() == IClasspathEntry.CPE_SOURCE) { |
581 |
if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) |
589 |
if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) |
582 |
prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, PDEMarkerFactory.CAT_OTHER); |
590 |
prepareError(DEF_SOURCE_ENTRY, null, PDECoreMessages.BuildErrorReporter_sourceMissing, PDEMarkerFactory.NO_RESOLUTION, fSrcInclSeverity, PDEMarkerFactory.CAT_OTHER); |
583 |
break; |
591 |
break; |
584 |
} |
592 |
} |
585 |
} |
593 |
} |
Lines 650-658
Link Here
|
650 |
return; |
658 |
return; |
651 |
if (sourceEntries.size() == 1) { |
659 |
if (sourceEntries.size() == 1) { |
652 |
String name = ((IBuildEntry) sourceEntries.get(0)).getName(); |
660 |
String name = ((IBuildEntry) sourceEntries.get(0)).getName(); |
653 |
prepareError(name, null, NLS.bind(PDECoreMessages.BuildErrorReporter_classpathEntryMissing1, unlistedEntries, name), PDEMarkerFactory.B_SOURCE_ADDITION, PDEMarkerFactory.CAT_OTHER); |
661 |
prepareError(name, null, NLS.bind(PDECoreMessages.BuildErrorReporter_classpathEntryMissing1, unlistedEntries, name), PDEMarkerFactory.B_SOURCE_ADDITION, fSrcLibSeverity, PDEMarkerFactory.CAT_OTHER); |
654 |
} else |
662 |
} else |
655 |
prepareError(DEF_SOURCE_ENTRY, null, NLS.bind(PDECoreMessages.BuildErrorReporter_classpathEntryMissing, unlistedEntries), PDEMarkerFactory.B_SOURCE_ADDITION, PDEMarkerFactory.CAT_OTHER); |
663 |
prepareError(DEF_SOURCE_ENTRY, null, NLS.bind(PDECoreMessages.BuildErrorReporter_classpathEntryMissing, unlistedEntries), PDEMarkerFactory.B_SOURCE_ADDITION, fSrcLibSeverity, PDEMarkerFactory.CAT_OTHER); |
656 |
|
664 |
|
657 |
} |
665 |
} |
658 |
|
666 |
|
Lines 689-701
Link Here
|
689 |
} |
697 |
} |
690 |
|
698 |
|
691 |
if (errorMessage != null) { |
699 |
if (errorMessage != null) { |
692 |
prepareError(includes.getName(), tokens[i], errorMessage, PDEMarkerFactory.B_REMOVAL, PDEMarkerFactory.CAT_OTHER); |
700 |
prepareError(includes.getName(), tokens[i], errorMessage, PDEMarkerFactory.B_REMOVAL, fSrcInclSeverity, PDEMarkerFactory.CAT_OTHER); |
693 |
} |
701 |
} |
694 |
} |
702 |
} |
695 |
|
703 |
|
696 |
} |
704 |
} |
697 |
|
705 |
|
698 |
private void validateIncludes(IBuildEntry includes, ArrayList sourceIncludes) { |
706 |
private void validateIncludes(IBuildEntry includes, ArrayList sourceIncludes, int severity) { |
699 |
if (includes == null) |
707 |
if (includes == null) |
700 |
return; |
708 |
return; |
701 |
String[] tokens = includes.getTokens(); |
709 |
String[] tokens = includes.getTokens(); |
Lines 730-736
Link Here
|
730 |
} |
738 |
} |
731 |
|
739 |
|
732 |
if (message != null) |
740 |
if (message != null) |
733 |
prepareError(includes.getName(), token, message, fixId, PDEMarkerFactory.CAT_OTHER); |
741 |
prepareError(includes.getName(), token, message, fixId, severity, PDEMarkerFactory.CAT_OTHER); |
734 |
} |
742 |
} |
735 |
} |
743 |
} |
736 |
|
744 |
|