Lines 44-50
Link Here
|
44 |
|
44 |
|
45 |
private static final String DEF_SOURCE_ENTRY = PROPERTY_SOURCE_PREFIX + '.'; |
45 |
private static final String DEF_SOURCE_ENTRY = PROPERTY_SOURCE_PREFIX + '.'; |
46 |
private static final String[] RESERVED_NAMES = new String[] {"meta-inf", "osgi-inf", ICoreConstants.BUILD_FILENAME_DESCRIPTOR, ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR, "plugin.properties"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
46 |
private static final String[] RESERVED_NAMES = new String[] {"meta-inf", "osgi-inf", ICoreConstants.BUILD_FILENAME_DESCRIPTOR, ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR, "plugin.properties"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
47 |
private static final String JAVAC_WARNINGS_ENTRY = PROPERTY_JAVAC_WARNINGS_PREFIX + '.'; |
47 |
|
48 |
private static final String ASSERT_IDENTIFIER = "assertIdentifier"; //$NON-NLS-1$ |
48 |
private static final String ASSERT_IDENTIFIER = "assertIdentifier"; //$NON-NLS-1$ |
49 |
private static final String ENUM_IDENTIFIER = "enumIdentifier"; //$NON-NLS-1$ |
49 |
private static final String ENUM_IDENTIFIER = "enumIdentifier"; //$NON-NLS-1$ |
50 |
|
50 |
|
Lines 106-112
Link Here
|
106 |
protected ArrayList fProblemList = new ArrayList(); |
106 |
protected ArrayList fProblemList = new ArrayList(); |
107 |
protected int fBuildSeverity; |
107 |
protected int fBuildSeverity; |
108 |
protected int fClasspathSeverity; |
108 |
protected int fClasspathSeverity; |
109 |
protected int fJavaComplSeverity; |
109 |
protected int fJavaComplianceSeverity; |
|
|
110 |
protected int fJavaCompilerSeverity; |
110 |
protected int fSrcInclSeverity; |
111 |
protected int fSrcInclSeverity; |
111 |
protected int fBinInclSeverity; |
112 |
protected int fBinInclSeverity; |
112 |
protected int fMissingOutputLibSeverity; |
113 |
protected int fMissingOutputLibSeverity; |
Lines 120-126
Link Here
|
120 |
fMissingOutputLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_MISSING_OUTPUT); |
121 |
fMissingOutputLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_MISSING_OUTPUT); |
121 |
fSrcLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SOURCE_LIBRARY); |
122 |
fSrcLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SOURCE_LIBRARY); |
122 |
fOututLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_OUTPUT_LIBRARY); |
123 |
fOututLibSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_OUTPUT_LIBRARY); |
123 |
fJavaComplSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_JAVA_COMPLIANCE); |
124 |
fJavaComplianceSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_JAVA_COMPLIANCE); |
|
|
125 |
fJavaCompilerSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_JAVA_COMPILER); |
124 |
fSrcInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SRC_INCLUDES); |
126 |
fSrcInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SRC_INCLUDES); |
125 |
fBinInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_BIN_INCLUDES); |
127 |
fBinInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_BIN_INCLUDES); |
126 |
} |
128 |
} |
Lines 151-157
Link Here
|
151 |
IBuildEntry javacSource = null; |
153 |
IBuildEntry javacSource = null; |
152 |
IBuildEntry javacTarget = null; |
154 |
IBuildEntry javacTarget = null; |
153 |
IBuildEntry jreCompilationProfile = null; |
155 |
IBuildEntry jreCompilationProfile = null; |
154 |
IBuildEntry javacWarnings = null; |
156 |
IBuildEntry javaProjectWarnings = null; |
|
|
157 |
ArrayList javacWarnings = new ArrayList(); |
158 |
ArrayList javacErrors = new ArrayList(); |
155 |
ArrayList sourceEntries = new ArrayList(1); |
159 |
ArrayList sourceEntries = new ArrayList(1); |
156 |
ArrayList sourceEntryKeys = new ArrayList(1); |
160 |
ArrayList sourceEntryKeys = new ArrayList(1); |
157 |
ArrayList outputEntries = new ArrayList(1); |
161 |
ArrayList outputEntries = new ArrayList(1); |
Lines 173-182
Link Here
|
173 |
javacSource = entries[i]; |
177 |
javacSource = entries[i]; |
174 |
else if (name.equals(PROPERTY_JAVAC_TARGET)) |
178 |
else if (name.equals(PROPERTY_JAVAC_TARGET)) |
175 |
javacTarget = entries[i]; |
179 |
javacTarget = entries[i]; |
176 |
else if (name.equals(JAVAC_WARNINGS_ENTRY)) |
180 |
else if (name.equals(PROPERTY_USE_PROJECT_WARNINGS)) |
177 |
javacWarnings = entries[i]; |
181 |
javaProjectWarnings = entries[i]; |
178 |
else if (name.equals(PROPERTY_JRE_COMPILATION_PROFILE)) |
182 |
else if (name.equals(PROPERTY_JRE_COMPILATION_PROFILE)) |
179 |
jreCompilationProfile = entries[i]; |
183 |
jreCompilationProfile = entries[i]; |
|
|
184 |
else if (name.startsWith(PROPERTY_JAVAC_WARNINGS_PREFIX)) |
185 |
javacWarnings.add(entries[i]); |
186 |
else if (name.startsWith(PROPERTY_JAVAC_ERRORS_PREFIX)) |
187 |
javacErrors.add(entries[i]); |
180 |
else if (name.startsWith(PROPERTY_SOURCE_PREFIX)) |
188 |
else if (name.startsWith(PROPERTY_SOURCE_PREFIX)) |
181 |
sourceEntries.add(entries[i]); |
189 |
sourceEntries.add(entries[i]); |
182 |
else if (name.startsWith(PROPERTY_OUTPUT_PREFIX)) |
190 |
else if (name.startsWith(PROPERTY_OUTPUT_PREFIX)) |
Lines 236-245
Link Here
|
236 |
|
244 |
|
237 |
validateMissingSourceInBinIncludes(binIncludes, sourceEntryKeys, build); |
245 |
validateMissingSourceInBinIncludes(binIncludes, sourceEntryKeys, build); |
238 |
validateBinIncludes(binIncludes); |
246 |
validateBinIncludes(binIncludes); |
239 |
try { |
247 |
validateExecutionEnvironment(javacSource, javacTarget, jreCompilationProfile); |
240 |
validateExecutionEnvironment(javacSource, javacTarget, javacWarnings, jreCompilationProfile); |
248 |
validateJavaComplianceSettings(javacWarnings, javacErrors, getSourceLibraries(sourceEntries)); |
241 |
} catch (CoreException e) { |
249 |
validateJavaCompilerSettings(javaProjectWarnings); |
242 |
} |
|
|
243 |
//validateDefaultEncoding(sourceEntries, encodingEntries); |
250 |
//validateDefaultEncoding(sourceEntries, encodingEntries); |
244 |
} |
251 |
} |
245 |
|
252 |
|
Lines 262-267
Link Here
|
262 |
// } |
269 |
// } |
263 |
|
270 |
|
264 |
/** |
271 |
/** |
|
|
272 |
* Given a list of source library entries, returns the list of library names. |
273 |
* |
274 |
* @param sourceEntries list of IBuildEntry source entries |
275 |
* @return list of library names |
276 |
*/ |
277 |
private List getSourceLibraries(List sourceEntries) { |
278 |
List libraries = new ArrayList(); |
279 |
for (Iterator iterator = sourceEntries.iterator(); iterator.hasNext();) { |
280 |
IBuildEntry sourceEntry = (IBuildEntry) iterator.next(); |
281 |
String libName = sourceEntry.getName().substring(PROPERTY_SOURCE_PREFIX.length()); |
282 |
libraries.add(libName); |
283 |
} |
284 |
return libraries; |
285 |
} |
286 |
|
287 |
/** |
265 |
* Matches the javacSource, javacTarget, javacWarnings and jre.compilation.prile entries in build.properties with the |
288 |
* Matches the javacSource, javacTarget, javacWarnings and jre.compilation.prile entries in build.properties with the |
266 |
* project specific Java Compiler properties and reports the errors founds. |
289 |
* project specific Java Compiler properties and reports the errors founds. |
267 |
* |
290 |
* |
Lines 270-279
Link Here
|
270 |
* @param javacWarningsEntry |
293 |
* @param javacWarningsEntry |
271 |
* @param jreCompilationProfileEntry |
294 |
* @param jreCompilationProfileEntry |
272 |
*/ |
295 |
*/ |
273 |
private void validateExecutionEnvironment(IBuildEntry javacSourceEntry, IBuildEntry javacTargetEntry, IBuildEntry javacWarningsEntry, IBuildEntry jreCompilationProfileEntry) throws CoreException { |
296 |
private void validateExecutionEnvironment(IBuildEntry javacSourceEntry, IBuildEntry javacTargetEntry, IBuildEntry jreCompilationProfileEntry) { |
274 |
// if there is no source to compile, don't worry about compiler settings |
297 |
// if there is no source to compile, don't worry about compiler settings |
275 |
IJavaProject project = JavaCore.create(fProject); |
298 |
IJavaProject project = JavaCore.create(fProject); |
276 |
IClasspathEntry[] classpath = project.getRawClasspath(); |
299 |
IClasspathEntry[] classpath = null; |
|
|
300 |
try { |
301 |
classpath = project.getRawClasspath(); |
302 |
} catch (JavaModelException e) { |
303 |
PDECore.log(e); |
304 |
return; |
305 |
} |
277 |
boolean source = false; |
306 |
boolean source = false; |
278 |
for (int i = 0; i < classpath.length; i++) { |
307 |
for (int i = 0; i < classpath.length; i++) { |
279 |
IClasspathEntry cpe = classpath[i]; |
308 |
IClasspathEntry cpe = classpath[i]; |
Lines 318-347
Link Here
|
318 |
if (projectJavaCompatibility != null) { |
347 |
if (projectJavaCompatibility != null) { |
319 |
if (jreCompilationProfileEntry == null) { |
348 |
if (jreCompilationProfileEntry == null) { |
320 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
349 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
321 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
350 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
322 |
} else { |
351 |
} else { |
323 |
if (!projectJavaCompatibility.equalsIgnoreCase(jreCompilationProfileEntry.getTokens()[0])) { |
352 |
if (!projectJavaCompatibility.equalsIgnoreCase(jreCompilationProfileEntry.getTokens()[0])) { |
324 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
353 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JRE_COMPILATION_PROFILE, PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel); |
325 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
354 |
prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
326 |
} |
355 |
} |
327 |
} |
356 |
} |
328 |
} else { |
357 |
} else { |
329 |
if (javacSourceEntry == null) { |
358 |
if (javacSourceEntry == null) { |
330 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
359 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
331 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
360 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
332 |
} else { |
361 |
} else { |
333 |
if (!projectSourceCompatibility.equalsIgnoreCase(javacSourceEntry.getTokens()[0])) { |
362 |
if (!projectSourceCompatibility.equalsIgnoreCase(javacSourceEntry.getTokens()[0])) { |
334 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
363 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility); |
335 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
364 |
prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
336 |
} |
365 |
} |
337 |
} |
366 |
} |
338 |
if (javacTargetEntry == null) { |
367 |
if (javacTargetEntry == null) { |
339 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
368 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
340 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
369 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
341 |
} else { |
370 |
} else { |
342 |
if (!projectClassCompatibility.equalsIgnoreCase(javacTargetEntry.getTokens()[0])) { |
371 |
if (!projectClassCompatibility.equalsIgnoreCase(javacTargetEntry.getTokens()[0])) { |
343 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
372 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_TARGET, PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility); |
344 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
373 |
prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message, PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
345 |
} |
374 |
} |
346 |
} |
375 |
} |
347 |
} |
376 |
} |
Lines 351-402
Link Here
|
351 |
return; |
380 |
return; |
352 |
} |
381 |
} |
353 |
|
382 |
|
354 |
//look for assertIdentifier and enumIdentifier entries in javacWarnings. If any is present let it be, if not warn. |
|
|
355 |
String assertIdentifier = node.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, ""); //$NON-NLS-1$ |
356 |
String enumIdentifier = node.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, ""); //$NON-NLS-1$ |
357 |
String assertToken = ""; //$NON-NLS-1$ |
358 |
String enumToken = ""; //$NON-NLS-1$ |
359 |
|
360 |
if (JavaCore.IGNORE.equalsIgnoreCase(assertIdentifier)) { |
361 |
assertToken = '-' + ASSERT_IDENTIFIER; |
362 |
} |
363 |
if (JavaCore.IGNORE.equalsIgnoreCase(enumIdentifier)) { |
364 |
enumToken = '-' + ENUM_IDENTIFIER; |
365 |
} |
366 |
String warningToken = join(assertToken, enumToken); |
367 |
if (javacWarningsEntry == null) { |
368 |
if (warningToken.length() > 0) { |
369 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_WARNINGS_PREFIX, PDECoreMessages.BuildErrorReporter_DisallowIdentifiers); |
370 |
prepareError(JAVAC_WARNINGS_ENTRY, warningToken, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
371 |
} |
372 |
} else { |
373 |
if (javacWarningsEntry.contains(ASSERT_IDENTIFIER) || javacWarningsEntry.contains('+' + ASSERT_IDENTIFIER) || javacWarningsEntry.contains('-' + ASSERT_IDENTIFIER)) { |
374 |
//assertIdentifier entry already present |
375 |
assertToken = ""; //$NON-NLS-1$ |
376 |
} |
377 |
if (javacWarningsEntry.contains(ENUM_IDENTIFIER) || javacWarningsEntry.contains('+' + ENUM_IDENTIFIER) || javacWarningsEntry.contains('-' + ENUM_IDENTIFIER)) { |
378 |
//enumIdentifier entry already present |
379 |
enumToken = ""; //$NON-NLS-1$ |
380 |
} |
381 |
warningToken = join(assertToken, enumToken); |
382 |
if (warningToken.length() > 0) { |
383 |
message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_WARNINGS_PREFIX, PDECoreMessages.BuildErrorReporter_DisallowIdentifiers); |
384 |
prepareError(JAVAC_WARNINGS_ENTRY, warningToken, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplSeverity, PDEMarkerFactory.CAT_EE); |
385 |
} |
386 |
} |
387 |
} |
383 |
} |
388 |
} |
384 |
} |
389 |
|
385 |
|
390 |
private String join(String token1, String token2) { |
|
|
391 |
StringBuffer result = new StringBuffer(token1); |
392 |
if (token2.length() > 0) { |
393 |
if (result.length() > 0) |
394 |
result.append(','); |
395 |
result.append(token2); |
396 |
} |
397 |
return result.toString(); |
398 |
} |
399 |
|
400 |
private String findMatchingEE(String srcCompatibility, String clsCompatibility, boolean ee) { |
386 |
private String findMatchingEE(String srcCompatibility, String clsCompatibility, boolean ee) { |
401 |
String executionEnv = null; |
387 |
String executionEnv = null; |
402 |
String complaince = null; |
388 |
String complaince = null; |
Lines 786-791
Link Here
|
786 |
|
772 |
|
787 |
} |
773 |
} |
788 |
|
774 |
|
|
|
775 |
/** |
776 |
* Matches the javacWarnings and javacErrors entries in build.properties with the |
777 |
* project specific Java compliance properties and reports the errors found. Since java |
778 |
* compiler settings are set on a per project basis, any special javacWarnings/javacErrors |
779 |
* must be set for each library. |
780 |
* |
781 |
* @param javacWarningsEntries list of build entries with the java compiler warnings prefix javacWarnings. |
782 |
* @param javacErrorsEntries list of build entries with the java compiler errors prefix javacErrors. |
783 |
* @param libraryNames list of String library names |
784 |
*/ |
785 |
private void validateJavaComplianceSettings(ArrayList javacWarningsEntries, ArrayList javacErrorsEntries, List libraryNames) { |
786 |
// Check if there are project specific compliance settings |
787 |
ProjectScope projectContext = new ProjectScope(fProject); |
788 |
IEclipsePreferences node = projectContext.getNode(JavaCore.PLUGIN_ID); |
789 |
String projectComplianceLevel = node.get(JavaCore.COMPILER_COMPLIANCE, ""); //$NON-NLS-1$ |
790 |
|
791 |
if (projectComplianceLevel.length() > 0) { //project has specific properties enabled |
792 |
|
793 |
List complianceWarnSettings = new ArrayList(3); |
794 |
List complianceErrorSettings = new ArrayList(3); |
795 |
|
796 |
//look for assertIdentifier and enumIdentifier entries in javacWarnings. If any is present let it be, if not warn. |
797 |
String assertIdentifier = node.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, ""); //$NON-NLS-1$ |
798 |
if (JavaCore.ERROR.equalsIgnoreCase(assertIdentifier)) { |
799 |
complianceErrorSettings.add(ASSERT_IDENTIFIER); |
800 |
} else if (JavaCore.WARNING.equalsIgnoreCase(assertIdentifier)) { |
801 |
complianceWarnSettings.add(ASSERT_IDENTIFIER); |
802 |
} |
803 |
|
804 |
String enumIdentifier = node.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, ""); //$NON-NLS-1$ |
805 |
if (JavaCore.ERROR.equalsIgnoreCase(enumIdentifier)) { |
806 |
complianceErrorSettings.add(ENUM_IDENTIFIER); |
807 |
} else if (JavaCore.WARNING.equalsIgnoreCase(enumIdentifier)) { |
808 |
complianceWarnSettings.add(ENUM_IDENTIFIER); |
809 |
} |
810 |
|
811 |
// If a warnings entry is required, make sure there is one for each library with the correct content |
812 |
if (complianceWarnSettings.size() > 0) { |
813 |
for (Iterator iterator = libraryNames.iterator(); iterator.hasNext();) { |
814 |
String libName = (String) iterator.next(); |
815 |
IBuildEntry matchingEntry = null; |
816 |
for (Iterator iterator2 = javacWarningsEntries.iterator(); iterator2.hasNext();) { |
817 |
IBuildEntry candidate = (IBuildEntry) iterator2.next(); |
818 |
if (candidate.getName().equals(PROPERTY_JAVAC_WARNINGS_PREFIX + libName)) { |
819 |
matchingEntry = candidate; |
820 |
break; |
821 |
} |
822 |
} |
823 |
if (matchingEntry == null) { |
824 |
String missingTokens = ""; //$NON-NLS-1$ |
825 |
for (Iterator iterator2 = complianceWarnSettings.iterator(); iterator2.hasNext();) { |
826 |
String currentIdentifier = (String) iterator2.next(); |
827 |
missingTokens = join(missingTokens, '-' + currentIdentifier); |
828 |
} |
829 |
String message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_WARNINGS_PREFIX + libName); |
830 |
prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
831 |
} else { |
832 |
String missingTokens = ""; //$NON-NLS-1$ |
833 |
for (Iterator iterator2 = complianceWarnSettings.iterator(); iterator2.hasNext();) { |
834 |
String currentIdentifier = (String) iterator2.next(); |
835 |
if (!matchingEntry.contains(currentIdentifier) && !matchingEntry.contains('+' + currentIdentifier) && !matchingEntry.contains('-' + currentIdentifier)) { |
836 |
join(missingTokens, '-' + currentIdentifier); |
837 |
} |
838 |
} |
839 |
if (missingTokens.length() > 0) { |
840 |
String message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_WARNINGS_PREFIX + libName); |
841 |
prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
842 |
} |
843 |
} |
844 |
} |
845 |
} |
846 |
|
847 |
// If a warnings entry is required, make sure there is one for each library with the correct content |
848 |
if (complianceErrorSettings.size() > 0) { |
849 |
for (Iterator iterator = libraryNames.iterator(); iterator.hasNext();) { |
850 |
String libName = (String) iterator.next(); |
851 |
IBuildEntry matchingEntry = null; |
852 |
for (Iterator iterator2 = javacErrorsEntries.iterator(); iterator2.hasNext();) { |
853 |
IBuildEntry candidate = (IBuildEntry) iterator2.next(); |
854 |
if (candidate.getName().equals(PROPERTY_JAVAC_ERRORS_PREFIX + libName)) { |
855 |
matchingEntry = candidate; |
856 |
break; |
857 |
} |
858 |
} |
859 |
if (matchingEntry == null) { |
860 |
String message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_ERRORS_PREFIX + libName); |
861 |
prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, null, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
862 |
} else { |
863 |
String missingTokens = ""; //$NON-NLS-1$ |
864 |
for (Iterator iterator2 = complianceErrorSettings.iterator(); iterator2.hasNext();) { |
865 |
String currentIdentifier = (String) iterator2.next(); |
866 |
if (!matchingEntry.contains(currentIdentifier) && !matchingEntry.contains('+' + currentIdentifier) && !matchingEntry.contains('-' + currentIdentifier)) { |
867 |
missingTokens = join(missingTokens, '-' + currentIdentifier); |
868 |
} |
869 |
} |
870 |
if (missingTokens.length() > 0) { |
871 |
String message = NLS.bind(PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_ERRORS_PREFIX + libName); |
872 |
prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, missingTokens, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE); |
873 |
} |
874 |
} |
875 |
} |
876 |
} |
877 |
} |
878 |
} |
879 |
|
880 |
/** |
881 |
* |
882 |
* |
883 |
* @param useJavaProjectSettings a build entry for using the project's compiler warning preferences file |
884 |
*/ |
885 |
private void validateJavaCompilerSettings(IBuildEntry useJavaProjectSettings) { |
886 |
// Check if the project has compiler warnings set |
887 |
IJavaProject project = JavaCore.create(fProject); |
888 |
Map options = project.getOptions(false); |
889 |
// If project specific options are turned on, all options will be stored. Only need to check if at least one compiler option is set. Currently using the second option on the property page. |
890 |
if (options.containsKey(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS)) { |
891 |
if (useJavaProjectSettings != null) { |
892 |
boolean entryCorrect = false; |
893 |
String[] tokens = useJavaProjectSettings.getTokens(); |
894 |
if (tokens != null && tokens.length == 1) { |
895 |
IPath prefFile = new Path(tokens[0]); |
896 |
if (prefFile.isAbsolute()) { |
897 |
entryCorrect = prefFile.toFile().exists(); |
898 |
} else { |
899 |
entryCorrect = fProject.getFile(prefFile).exists(); |
900 |
} |
901 |
} |
902 |
if (!entryCorrect) { |
903 |
// TODO Doesn't work with flexible bundle root |
904 |
IFile prefFile = fProject.getFile(new Path(".settings").append(JavaCore.PLUGIN_ID + ".prefs")); //$NON-NLS-1$ //$NON-NLS-2$ |
905 |
String token = prefFile.exists() ? prefFile.getProjectRelativePath().toString() : null; |
906 |
String message = NLS.bind(PDECoreMessages.BuildErrorReporter_buildEntryMissingValidPath, PROPERTY_USE_PROJECT_WARNINGS); |
907 |
prepareError(PROPERTY_USE_PROJECT_WARNINGS, token, message, PDEMarkerFactory.B_REPLACE, fJavaCompilerSeverity, PDEMarkerFactory.CAT_EE); |
908 |
} |
909 |
} else { |
910 |
// TODO Doesn't work with flexible bundle root |
911 |
IFile prefFile = fProject.getFile(new Path(".settings").append(JavaCore.PLUGIN_ID + ".prefs")); //$NON-NLS-1$ //$NON-NLS-2$ |
912 |
String token = prefFile.exists() ? prefFile.getProjectRelativePath().toString() : null; |
913 |
String message = NLS.bind(PDECoreMessages.BuildErrorReporter_buildEntryMissingProjectSpecificSettings, PROPERTY_USE_PROJECT_WARNINGS); |
914 |
prepareError(PROPERTY_USE_PROJECT_WARNINGS, token, message, PDEMarkerFactory.B_JAVA_ADDDITION, fJavaCompilerSeverity, PDEMarkerFactory.CAT_EE); |
915 |
} |
916 |
} else if (useJavaProjectSettings != null) { |
917 |
String message = NLS.bind(PDECoreMessages.BuildErrorReporter_buildEntryInvalidWhenNoProjectSettings, PROPERTY_USE_PROJECT_WARNINGS); |
918 |
prepareError(PROPERTY_USE_PROJECT_WARNINGS, null, message, PDEMarkerFactory.B_REMOVAL, fJavaCompilerSeverity, PDEMarkerFactory.CAT_EE); |
919 |
} |
920 |
} |
921 |
|
922 |
/** |
923 |
* Joins the given tokens into a single string with a comma separator. If either of |
924 |
* the tokens are null or of length 0, the other string will be returned |
925 |
* |
926 |
* @param token1 first string |
927 |
* @param token2 second string |
928 |
* @return concatenated string |
929 |
*/ |
930 |
private String join(String token1, String token2) { |
931 |
StringBuffer result = new StringBuffer(); |
932 |
if (token1 != null && token1.length() > 0) { |
933 |
result.append(token1); |
934 |
} |
935 |
if (token2 != null && token2.length() > 0) { |
936 |
if (result.length() > 0) |
937 |
result.append(','); |
938 |
result.append(token2); |
939 |
} |
940 |
return result.toString(); |
941 |
} |
942 |
|
789 |
private BuildModel prepareTextBuildModel(IProgressMonitor monitor) { |
943 |
private BuildModel prepareTextBuildModel(IProgressMonitor monitor) { |
790 |
try { |
944 |
try { |
791 |
IDocument doc = createDocument(fFile); |
945 |
IDocument doc = createDocument(fFile); |