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

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/PDECoreMessages.java (+12 lines)
Lines 301-306 Link Here
301
301
302
	public static String SearchablePluginsManager_createProjectTaskName;
302
	public static String SearchablePluginsManager_createProjectTaskName;
303
303
304
	public static String SourceEntryErrorReporter_0;
305
	public static String SourceEntryErrorReporter_1;
306
	public static String SourceEntryErrorReporter_10;
307
	public static String SourceEntryErrorReporter_2;
308
	public static String SourceEntryErrorReporter_3;
309
	public static String SourceEntryErrorReporter_4;
310
	public static String SourceEntryErrorReporter_5;
311
	public static String SourceEntryErrorReporter_6;
312
	public static String SourceEntryErrorReporter_7;
313
	public static String SourceEntryErrorReporter_8;
314
	public static String SourceEntryErrorReporter_9;
315
304
	public static String SourceEntryErrorReporter_DifferentTargetLibrary;
316
	public static String SourceEntryErrorReporter_DifferentTargetLibrary;
305
	public static String SourceEntryErrorReporter_DupeOutputFolder;
317
	public static String SourceEntryErrorReporter_DupeOutputFolder;
306
	public static String SourceEntryErrorReporter_DupeSourceFolder;
318
	public static String SourceEntryErrorReporter_DupeSourceFolder;
(-)src/org/eclipse/pde/internal/core/PreferenceInitializer.java (+1 lines)
Lines 71-76 Link Here
71
		prefs.putInt(CompilerFlags.P_BUILD_BIN_INCLUDES, CompilerFlags.WARNING);
71
		prefs.putInt(CompilerFlags.P_BUILD_BIN_INCLUDES, CompilerFlags.WARNING);
72
		prefs.putInt(CompilerFlags.P_BUILD_JAVA_COMPLIANCE, CompilerFlags.WARNING);
72
		prefs.putInt(CompilerFlags.P_BUILD_JAVA_COMPLIANCE, CompilerFlags.WARNING);
73
		prefs.putInt(CompilerFlags.P_BUILD_JAVA_COMPILER, CompilerFlags.IGNORE);
73
		prefs.putInt(CompilerFlags.P_BUILD_JAVA_COMPILER, CompilerFlags.IGNORE);
74
		prefs.putInt(CompilerFlags.P_BUILD_ENCODINGS, CompilerFlags.IGNORE);
74
75
75
		prefs.putInt(CompilerFlags.P_INCOMPATIBLE_ENV, CompilerFlags.WARNING);
76
		prefs.putInt(CompilerFlags.P_INCOMPATIBLE_ENV, CompilerFlags.WARNING);
76
		prefs.putInt(CompilerFlags.P_MISSING_EXPORT_PKGS, CompilerFlags.IGNORE);
77
		prefs.putInt(CompilerFlags.P_MISSING_EXPORT_PKGS, CompilerFlags.IGNORE);
(-)src/org/eclipse/pde/internal/core/pderesources.properties (+12 lines)
Lines 237-242 Link Here
237
237
238
SearchablePluginsManager_createProjectTaskName=Creating {0} project
238
SearchablePluginsManager_createProjectTaskName=Creating {0} project
239
239
240
SourceEntryErrorReporter_0=Workspace encoding ({0}) does not match specified default encoding ({1}) for library "{2}".
241
SourceEntryErrorReporter_1=Default encoding ({0}) for library "{1}" should be removed as the workspace does not specify an explicit encoding.
242
SourceEntryErrorReporter_10=Custom encoding ({0}) should be specified for "{1}" to match workspace settings.
243
SourceEntryErrorReporter_2=Only one default encoding can be specified for library "{0}".
244
SourceEntryErrorReporter_3=Custom encoding ({0}) should be removed for file or folder that does not exist: "{1}"
245
SourceEntryErrorReporter_4=Syntax error: expecting ''<path>[encoding]''
246
SourceEntryErrorReporter_5=Custom encodings should be removed for library "{0}" as the workspace settings does not specify any explicit encodings.
247
SourceEntryErrorReporter_6=Custom encoding ({0}) should be removed for "{0}" as the workspace does not specify an explicit encoding.
248
SourceEntryErrorReporter_7=Workspace encoding ({0}) for "{1}" does not match specified encoding ({2}).
249
SourceEntryErrorReporter_8=Custom encoding ({0}) should be specified for "{1}" to match workspace settings.
250
SourceEntryErrorReporter_9=Default encoding ({0}) should be specified for library "{1}" to match workspace settings.
251
240
SourceEntryErrorReporter_DifferentTargetLibrary=Source folders ''{0}'' share the same output folder but are targeted to different libraries.
252
SourceEntryErrorReporter_DifferentTargetLibrary=Source folders ''{0}'' share the same output folder but are targeted to different libraries.
241
SourceEntryErrorReporter_DupeOutputFolder=Multiple entries for output folder ''{0}'' in build entry ''{1}''. 
253
SourceEntryErrorReporter_DupeOutputFolder=Multiple entries for output folder ''{0}'' in build entry ''{1}''. 
242
SourceEntryErrorReporter_DupeSourceFolder=Multiple entries for source folder ''{0}'' in build entry ''{1}''.
254
SourceEntryErrorReporter_DupeSourceFolder=Multiple entries for source folder ''{0}'' in build entry ''{1}''.
(-)src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java (-20 / +3 lines)
Lines 114-119 Link Here
114
	protected int fMissingOutputLibSeverity;
114
	protected int fMissingOutputLibSeverity;
115
	protected int fSrcLibSeverity;
115
	protected int fSrcLibSeverity;
116
	protected int fOututLibSeverity;
116
	protected int fOututLibSeverity;
117
	protected int fEncodingSeverity;
117
118
118
	public BuildErrorReporter(IFile buildFile) {
119
	public BuildErrorReporter(IFile buildFile) {
119
		super(buildFile);
120
		super(buildFile);
Lines 126-131 Link Here
126
		fJavaCompilerSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_JAVA_COMPILER);
127
		fJavaCompilerSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_JAVA_COMPILER);
127
		fSrcInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SRC_INCLUDES);
128
		fSrcInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_SRC_INCLUDES);
128
		fBinInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_BIN_INCLUDES);
129
		fBinInclSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_BIN_INCLUDES);
130
		fEncodingSeverity = CompilerFlags.getFlag(fFile.getProject(), CompilerFlags.P_BUILD_ENCODINGS);
129
	}
131
	}
130
132
131
	public void validate(IProgressMonitor monitor) {
133
	public void validate(IProgressMonitor monitor) {
Lines 228-234 Link Here
228
				IClasspathEntry[] cpes = jp.getRawClasspath();
230
				IClasspathEntry[] cpes = jp.getRawClasspath();
229
				validateMissingLibraries(sourceEntryKeys, cpes);
231
				validateMissingLibraries(sourceEntryKeys, cpes);
230
				validateSourceEntries(sourceEntries, cpes);
232
				validateSourceEntries(sourceEntries, cpes);
231
				SourceEntryErrorReporter srcEntryErrReporter = new SourceEntryErrorReporter(fFile);
233
				SourceEntryErrorReporter srcEntryErrReporter = new SourceEntryErrorReporter(fFile, build);
232
				srcEntryErrReporter.initialize(sourceEntries, outputEntries, cpes, fProject);
234
				srcEntryErrReporter.initialize(sourceEntries, outputEntries, cpes, fProject);
233
				srcEntryErrReporter.validate();
235
				srcEntryErrReporter.validate();
234
				ArrayList problems = srcEntryErrReporter.getProblemList();
236
				ArrayList problems = srcEntryErrReporter.getProblemList();
Lines 246-272 Link Here
246
		validateBinIncludes(binIncludes);
248
		validateBinIncludes(binIncludes);
247
		validateExecutionEnvironment(javacSource, javacTarget, jreCompilationProfile, javacWarnings, javacErrors, getSourceLibraries(sourceEntries));
249
		validateExecutionEnvironment(javacSource, javacTarget, jreCompilationProfile, javacWarnings, javacErrors, getSourceLibraries(sourceEntries));
248
		validateJavaCompilerSettings(javaProjectWarnings);
250
		validateJavaCompilerSettings(javaProjectWarnings);
249
		//validateDefaultEncoding(sourceEntries, encodingEntries);
250
	}
251
	}
251
252
252
//	private void validateDefaultEncoding(ArrayList sourceEntries, Map encodingEntries) {
253
//		String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
254
//		for (int i = 0; i < sourceEntries.size(); i++) {
255
//			try {
256
//				String name = ((IBuildEntry) sourceEntries.get(i)).getName();
257
//				String library = name.substring(name.indexOf('.') + 1, name.length());
258
//				String encoding = fProject.getDefaultCharset(false);
259
//				String encodingId = PROPERTY_JAVAC_DEFAULT_ENCODING_PREFIX + library;
260
//				String libraryEncoding = (String) encodingEntries.get(encodingId);
261
//				if (encoding != null && !defaultEncoding.equalsIgnoreCase(encoding) && libraryEncoding == null) {
262
//					prepareError(encodingId, encoding, NLS.bind(PDECoreMessages.BuildErrorReporter_defaultEncodingMissing, new Object[] {defaultEncoding, encoding}), PDEMarkerFactory.B_ADDDITION, PDEMarkerFactory.CAT_OTHER);
263
//				}
264
//			} catch (CoreException e) {
265
//				PDECore.logException(e);
266
//			}
267
//		}
268
//	}
269
270
	/**
253
	/**
271
	 * Given a list of source library entries, returns the list of library names.
254
	 * Given a list of source library entries, returns the list of library names.
272
	 * 
255
	 * 
(-)src/org/eclipse/pde/internal/core/builders/CompilerFlags.java (+1 lines)
Lines 61-66 Link Here
61
	public static final String P_BUILD_BIN_INCLUDES = "compilers.p.build.bin.includes"; //$NON-NLS-1$
61
	public static final String P_BUILD_BIN_INCLUDES = "compilers.p.build.bin.includes"; //$NON-NLS-1$
62
	public static final String P_BUILD_JAVA_COMPLIANCE = "compilers.p.build.java.compliance"; //$NON-NLS-1$
62
	public static final String P_BUILD_JAVA_COMPLIANCE = "compilers.p.build.java.compliance"; //$NON-NLS-1$
63
	public static final String P_BUILD_JAVA_COMPILER = "compilers.p.build.java.compiler"; //$NON-NLS-1$
63
	public static final String P_BUILD_JAVA_COMPILER = "compilers.p.build.java.compiler"; //$NON-NLS-1$
64
	public static final String P_BUILD_ENCODINGS = "compilers.p.build.encodings"; //$NON-NLS-1$
64
	public static final String P_INCOMPATIBLE_ENV = "compilers.incompatible-environment"; //$NON-NLS-1$
65
	public static final String P_INCOMPATIBLE_ENV = "compilers.incompatible-environment"; //$NON-NLS-1$
65
	public static final String P_MISSING_EXPORT_PKGS = "compilers.p.missing-packages"; //$NON-NLS-1$
66
	public static final String P_MISSING_EXPORT_PKGS = "compilers.p.missing-packages"; //$NON-NLS-1$
66
	public static final String P_DEPRECATED = "compilers.p.deprecated"; //$NON-NLS-1$
67
	public static final String P_DEPRECATED = "compilers.p.deprecated"; //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/core/builders/SourceEntryErrorReporter.java (-3 / +320 lines)
Lines 11-28 Link Here
11
package org.eclipse.pde.internal.core.builders;
11
package org.eclipse.pde.internal.core.builders;
12
12
13
import java.util.*;
13
import java.util.*;
14
import java.util.Map.Entry;
14
import org.eclipse.core.resources.*;
15
import org.eclipse.core.resources.*;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.Path;
17
import org.eclipse.jdt.core.*;
17
import org.eclipse.jdt.core.*;
18
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.pde.core.build.IBuild;
19
import org.eclipse.pde.core.build.IBuildEntry;
20
import org.eclipse.pde.core.build.IBuildEntry;
21
import org.eclipse.pde.internal.core.PDECore;
20
import org.eclipse.pde.internal.core.PDECoreMessages;
22
import org.eclipse.pde.internal.core.PDECoreMessages;
23
import org.eclipse.pde.internal.core.project.PDEProject;
21
24
22
public class SourceEntryErrorReporter extends BuildErrorReporter {
25
public class SourceEntryErrorReporter extends BuildErrorReporter {
23
26
24
	public SourceEntryErrorReporter(IFile file) {
27
	public SourceEntryErrorReporter(IFile file, IBuild model) {
25
		super(file);
28
		super(file);
29
		fBuild = model;
26
	}
30
	}
27
31
28
	class ProjectFolder {
32
	class ProjectFolder {
Lines 131-138 Link Here
131
135
132
	}
136
	}
133
137
138
	/**
139
	 * Represents a default or custom encoding property for a resource
140
	 * within a library.
141
	 */
142
	class EncodingEntry {
143
144
		private String fEncoding;
145
		private IResource fResource;
146
147
		/**
148
		 * Constructs an encoding entry for the given resource.
149
		 * 
150
		 * @param resource resource
151
		 * @param encoding the encoding identifier
152
		 */
153
		EncodingEntry(IResource resource, String encoding) {
154
			fEncoding = encoding;
155
			fResource = resource;
156
		}
157
158
		/**
159
		 * Returns the explicit encoding for this entry.
160
		 * 
161
		 * @return explicit encoding
162
		 */
163
		public String getEncoding() {
164
			return fEncoding;
165
		}
166
167
		/**
168
		 * Returns the resource this encoding is associated with.
169
		 * 
170
		 * @return associated resource 
171
		 */
172
		public IResource getResource() {
173
			return fResource;
174
		}
175
176
		/* (non-Javadoc)
177
		 * @see java.lang.Object#toString()
178
		 */
179
		public String toString() {
180
			return getValue();
181
		}
182
183
		/* (non-Javadoc)
184
		 * @see java.lang.Object#equals(java.lang.Object)
185
		 */
186
		public boolean equals(Object obj) {
187
			if (obj instanceof EncodingEntry) {
188
				EncodingEntry other = (EncodingEntry) obj;
189
				return other.fEncoding.equals(fEncoding) && other.fResource.equals(fResource);
190
			}
191
			return false;
192
		}
193
194
		/* (non-Javadoc)
195
		 * @see java.lang.Object#hashCode()
196
		 */
197
		public int hashCode() {
198
			return fEncoding.hashCode() + fResource.hashCode();
199
		}
200
201
		/**
202
		 * Returns the generated value of this entry for the build.properties file.
203
		 * 
204
		 * @return value to enter into build.properties
205
		 */
206
		String getValue() {
207
			StringBuffer buf = new StringBuffer();
208
			IContainer root = PDEProject.getBundleRoot(fResource.getProject());
209
			buf.append(fResource.getFullPath().makeRelativeTo(root.getFullPath()).makeAbsolute());
210
			buf.append('[');
211
			buf.append(fEncoding);
212
			buf.append(']');
213
			return buf.toString();
214
		}
215
216
	}
217
218
	/**
219
	 * Visits a source folder gathering encodings.
220
	 */
221
	class Visitor implements IResourceVisitor {
222
223
		String[] fLibs = null;
224
225
		Visitor(SourceFolder folder) {
226
			ArrayList list = folder.getLibs();
227
			fLibs = (String[]) list.toArray(new String[list.size()]);
228
		}
229
230
		/* (non-Javadoc)
231
		 * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource)
232
		 */
233
		public boolean visit(IResource resource) throws CoreException {
234
			String encoding = null;
235
			switch (resource.getType()) {
236
				case IResource.FOLDER :
237
					encoding = ((IFolder) resource).getDefaultCharset(false);
238
					break;
239
				case IResource.FILE :
240
					IFile file = (IFile) resource;
241
					// only worry about .java files
242
					if (file.getFileExtension().equals("java")) { //$NON-NLS-1$
243
						encoding = file.getCharset(false);
244
					}
245
					break;
246
			}
247
			if (encoding != null) {
248
				EncodingEntry entry = new EncodingEntry(resource, encoding);
249
				for (int i = 0; i < fLibs.length; i++) {
250
					String lib = fLibs[i];
251
					List encodings = (List) fCustomEncodings.get(lib);
252
					if (encodings == null) {
253
						encodings = new ArrayList();
254
						fCustomEncodings.put(lib, encodings);
255
					}
256
					encodings.add(entry);
257
				}
258
			}
259
			return true;
260
		}
261
262
	}
263
134
	private HashMap fSourceFolderMap = new HashMap(4);
264
	private HashMap fSourceFolderMap = new HashMap(4);
135
	private HashMap fOutputFolderMap = new HashMap(4);
265
	private HashMap fOutputFolderMap = new HashMap(4);
266
	private IBuild fBuild = null;
267
268
	/**
269
	 * Maps library name to default encoding for that library (or not present if there is no
270
	 * explicit default encoding specified). 
271
	 */
272
	Map fDefaultLibraryEncodings = new HashMap();
273
274
	/**
275
	 * Maps library name to custom {@link EncodingEntry}'s for this library.
276
	 */
277
	Map fCustomEncodings = new HashMap();
136
278
137
	public void initialize(ArrayList sourceEntries, ArrayList outputEntries, IClasspathEntry[] cpes, IProject project) {
279
	public void initialize(ArrayList sourceEntries, ArrayList outputEntries, IClasspathEntry[] cpes, IProject project) {
138
280
Lines 297-302 Link Here
297
			}
439
			}
298
		}
440
		}
299
441
442
		List toValidate = new ArrayList(); // list of source folders to perform encoding validation on
300
		for (Iterator iterator = fSourceFolderMap.keySet().iterator(); iterator.hasNext();) {
443
		for (Iterator iterator = fSourceFolderMap.keySet().iterator(); iterator.hasNext();) {
301
			IPath sourcePath = (IPath) iterator.next();
444
			IPath sourcePath = (IPath) iterator.next();
302
			SourceFolder sourceFolder = (SourceFolder) fSourceFolderMap.get(sourcePath);
445
			SourceFolder sourceFolder = (SourceFolder) fSourceFolderMap.get(sourcePath);
Lines 339-344 Link Here
339
					String message = NLS.bind(PDECoreMessages.SourceEntryErrorReporter_DupeSourceFolder, sourcePath.toString(), PROPERTY_SOURCE_PREFIX + sourceFolder.getDupeLibName());
482
					String message = NLS.bind(PDECoreMessages.SourceEntryErrorReporter_DupeSourceFolder, sourcePath.toString(), PROPERTY_SOURCE_PREFIX + sourceFolder.getDupeLibName());
340
					prepareError(PROPERTY_SOURCE_PREFIX + sourceFolder.getDupeLibName(), sourceFolder.getToken(), message, PDEMarkerFactory.NO_RESOLUTION, fSrcLibSeverity, PDEMarkerFactory.CAT_OTHER);
483
					prepareError(PROPERTY_SOURCE_PREFIX + sourceFolder.getDupeLibName(), sourceFolder.getToken(), message, PDEMarkerFactory.NO_RESOLUTION, fSrcLibSeverity, PDEMarkerFactory.CAT_OTHER);
341
				}
484
				}
485
486
				toValidate.add(sourceFolder);
342
			}
487
			}
343
		}
488
		}
344
489
Lines 348-353 Link Here
348
			String message = NLS.bind(PDECoreMessages.SourceEntryErrorReporter_MissingOutputEntry, errorEntry.get(errorEntry.fSsrcFolders), PROPERTY_OUTPUT_PREFIX + libName);
493
			String message = NLS.bind(PDECoreMessages.SourceEntryErrorReporter_MissingOutputEntry, errorEntry.get(errorEntry.fSsrcFolders), PROPERTY_OUTPUT_PREFIX + libName);
349
			prepareError(PROPERTY_OUTPUT_PREFIX + libName, errorEntry.get(errorEntry.fOutputFolders), message, PDEMarkerFactory.B_ADDITION, fMissingOutputLibSeverity, PDEMarkerFactory.CAT_OTHER);
494
			prepareError(PROPERTY_OUTPUT_PREFIX + libName, errorEntry.get(errorEntry.fOutputFolders), message, PDEMarkerFactory.B_ADDITION, fMissingOutputLibSeverity, PDEMarkerFactory.CAT_OTHER);
350
		}
495
		}
496
497
		// validate workspace encodings with those specified in build.properties
498
499
		if (fEncodingSeverity == CompilerFlags.ERROR || fEncodingSeverity == CompilerFlags.WARNING) {
500
			// build map of expected encodings
501
			Iterator iterator = toValidate.iterator();
502
			while (iterator.hasNext()) {
503
				SourceFolder sourceFolder = (SourceFolder) iterator.next();
504
				IPath sourcePath = sourceFolder.getPath();
505
				IFolder folder = fProject.getFolder(sourcePath);
506
				try {
507
					ArrayList list = sourceFolder.getLibs();
508
					String[] libs = (String[]) list.toArray(new String[list.size()]);
509
					String encoding = getExplicitEncoding(folder);
510
					if (encoding != null) {
511
						for (int i = 0; i < libs.length; i++) {
512
							fDefaultLibraryEncodings.put(libs[i], encoding);
513
						}
514
					}
515
					folder.accept(new Visitor(sourceFolder));
516
				} catch (CoreException e) {
517
					// Can't validate if unable to retrieve encoding
518
					PDECore.log(e);
519
				}
520
521
			}
522
523
			// Compare to encodings specified in build.properties (if any)
524
			IBuildEntry[] entries = fBuild.getBuildEntries();
525
			for (int i = 0; i < entries.length; i++) {
526
				IBuildEntry entry = entries[i];
527
				String name = entry.getName();
528
				if (name.startsWith(PROPERTY_JAVAC_DEFAULT_ENCODING_PREFIX)) {
529
					String lib = name.substring(PROPERTY_JAVAC_DEFAULT_ENCODING_PREFIX.length());
530
					String[] tokens = entry.getTokens();
531
					if (tokens.length > 0) {
532
						if (tokens.length == 1) {
533
							// compare
534
							String specified = tokens[0];
535
							String expected = (String) fDefaultLibraryEncodings.remove(lib);
536
							if (expected != null) {
537
								if (!specified.equals(expected)) {
538
									prepareError(name, specified, NLS.bind(PDECoreMessages.SourceEntryErrorReporter_0, new String[] {expected, specified, lib}), PDEMarkerFactory.NO_RESOLUTION, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
539
								}
540
							} else {
541
								// encoding is specified, but workspace does not specify one
542
								prepareError(name, null, NLS.bind(PDECoreMessages.SourceEntryErrorReporter_1, new String[] {specified, lib}), PDEMarkerFactory.B_REMOVAL, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
543
							}
544
						} else {
545
							// syntax error
546
							fDefaultLibraryEncodings.remove(lib);
547
							prepareError(name, null, NLS.bind(PDECoreMessages.SourceEntryErrorReporter_2, lib), PDEMarkerFactory.NO_RESOLUTION, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
548
						}
549
					}
550
				} else if (name.startsWith(PROPERTY_JAVAC_CUSTOM_ENCODINGS_PREFIX)) {
551
					IContainer bundleRoot = PDEProject.getBundleRoot(fProject);
552
					String lib = name.substring(PROPERTY_JAVAC_CUSTOM_ENCODINGS_PREFIX.length());
553
					String[] tokens = entry.getTokens();
554
					if (tokens.length > 0) {
555
						List encodings = new ArrayList();
556
						for (int j = 0; j < tokens.length; j++) {
557
							String special = tokens[j];
558
							int index = special.indexOf('[');
559
							if (index >= 0 && special.endsWith("]")) { //$NON-NLS-1$
560
								String path = special.substring(0, index);
561
								String encoding = special.substring(index + 1, special.length() - 1);
562
								IResource member = bundleRoot.findMember(path);
563
								if (member == null) {
564
									// error - missing resource
565
									String message = NLS.bind(PDECoreMessages.SourceEntryErrorReporter_3, new String[] {encoding, path});
566
									prepareError(name, special, message, PDEMarkerFactory.B_REMOVAL, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
567
								} else {
568
									encodings.add(new EncodingEntry(member, encoding));
569
								}
570
							} else {
571
								// syntax error - invalid
572
								String message = PDECoreMessages.SourceEntryErrorReporter_4;
573
								prepareError(name, special, message, PDEMarkerFactory.NO_RESOLUTION, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
574
							}
575
						}
576
						// compare with workspace encodings
577
						List workspace = (List) fCustomEncodings.remove(lib);
578
						if (workspace == null) {
579
							prepareError(name, null, NLS.bind(PDECoreMessages.SourceEntryErrorReporter_5, lib), PDEMarkerFactory.B_REMOVAL, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
580
						} else {
581
							Map map = new HashMap();
582
							Iterator iter = workspace.iterator();
583
							while (iter.hasNext()) {
584
								EncodingEntry ee = (EncodingEntry) iter.next();
585
								map.put(ee.getResource(), ee.getEncoding());
586
							}
587
							iter = encodings.iterator();
588
							while (iter.hasNext()) {
589
								EncodingEntry ee = (EncodingEntry) iter.next();
590
								String specified = ee.getEncoding();
591
								String expected = (String) map.remove(ee.getResource());
592
								if (expected == null) {
593
									prepareError(name, ee.getValue(), NLS.bind(PDECoreMessages.SourceEntryErrorReporter_6, new String[] {expected, ee.getResource().getProjectRelativePath().toString()}), PDEMarkerFactory.B_REMOVAL, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
594
								} else {
595
									if (!specified.equals(expected)) {
596
										prepareError(name, ee.getValue(), NLS.bind(PDECoreMessages.SourceEntryErrorReporter_7, new String[] {expected, ee.getResource().getProjectRelativePath().toString(), specified}), PDEMarkerFactory.NO_RESOLUTION, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
597
									}
598
								}
599
							}
600
							// anything left in the workspace map?
601
							if (!map.isEmpty()) {
602
								iter = map.entrySet().iterator();
603
								while (iter.hasNext()) {
604
									Entry en = (Entry) iter.next();
605
									IResource res = (IResource) en.getKey();
606
									String expected = (String) en.getValue();
607
									EncodingEntry missing = new EncodingEntry(res, expected);
608
									String m = NLS.bind(PDECoreMessages.SourceEntryErrorReporter_8, new String[] {expected, res.getProjectRelativePath().toString()});
609
									prepareError(name, missing.getValue(), m, PDEMarkerFactory.B_ADDITION, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
610
								}
611
							}
612
						}
613
					}
614
615
				}
616
			}
617
618
			// check for unspecified default encodings
619
			Iterator iter = fDefaultLibraryEncodings.entrySet().iterator();
620
			while (iter.hasNext()) {
621
				Entry entry = (Entry) iter.next();
622
				String lib = (String) entry.getKey();
623
				String expected = (String) entry.getValue();
624
				prepareError(PROPERTY_JAVAC_DEFAULT_ENCODING_PREFIX + lib, expected, NLS.bind(PDECoreMessages.SourceEntryErrorReporter_9, new String[] {expected, lib}), PDEMarkerFactory.B_ADDITION, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
625
			}
626
627
			// check for unspecified custom encodings
628
			iter = fCustomEncodings.entrySet().iterator();
629
			while (iter.hasNext()) {
630
				Entry entry = (Entry) iter.next();
631
				String lib = (String) entry.getKey();
632
				List encodings = (List) entry.getValue();
633
				Iterator iterator2 = encodings.iterator();
634
				while (iterator2.hasNext()) {
635
					EncodingEntry encoding = (EncodingEntry) iterator2.next();
636
					String m = NLS.bind(PDECoreMessages.SourceEntryErrorReporter_10, new String[] {encoding.getEncoding(), encoding.getResource().getProjectRelativePath().toString()});
637
					prepareError(PROPERTY_JAVAC_CUSTOM_ENCODINGS_PREFIX + lib, encoding.getValue(), m, PDEMarkerFactory.B_ADDITION, fEncodingSeverity, PDEMarkerFactory.CAT_OTHER);
638
				}
639
			}
640
		}
641
	}
642
643
	/**
644
	 * Returns any explicit encoding set on the given container or one of its parents
645
	 * up to and including its project.
646
	 * 
647
	 * @param container container
648
	 * @return any explicit encoding or <code>null</code> if none
649
	 * @throws CoreException
650
	 */
651
	private String getExplicitEncoding(IContainer container) throws CoreException {
652
		String encoding = container.getDefaultCharset(false);
653
		if (encoding == null) {
654
			IContainer parent = container.getParent();
655
			if (parent != null) {
656
				switch (parent.getType()) {
657
					case IResource.FOLDER :
658
						return getExplicitEncoding(parent);
659
					case IResource.PROJECT :
660
						return getExplicitEncoding(parent);
661
					default :
662
						// don't consider workspace encoding
663
						return null;
664
				}
665
			}
666
		}
667
		return encoding;
351
	}
668
	}
352
669
353
	private String join(ProjectFolder[] folders) {
670
	private String join(ProjectFolder[] folders) {
(-)src/org/eclipse/pde/internal/ui/PDEUIMessages.java (+1 lines)
Lines 103-108 Link Here
103
	public static String PDECompilersConfigurationBlock_4;
103
	public static String PDECompilersConfigurationBlock_4;
104
	public static String PDECompilersConfigurationBlock_5;
104
	public static String PDECompilersConfigurationBlock_5;
105
	public static String PDECompilersConfigurationBlock_6;
105
	public static String PDECompilersConfigurationBlock_6;
106
	public static String PDECompilersConfigurationBlock_7;
106
107
107
	public static String PDECompilersConfigurationBlock_general;
108
	public static String PDECompilersConfigurationBlock_general;
108
	public static String PDECompilersConfigurationBlock_versioning;
109
	public static String PDECompilersConfigurationBlock_versioning;
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (+1 lines)
Lines 61-66 Link Here
61
PDECompilersConfigurationBlock_4=Problems with 'src.inclu&des' entry:
61
PDECompilersConfigurationBlock_4=Problems with 'src.inclu&des' entry:
62
PDECompilersConfigurationBlock_5=Missing or incompatible &Java compliance properties:
62
PDECompilersConfigurationBlock_5=Missing or incompatible &Java compliance properties:
63
PDECompilersConfigurationBlock_6=Missing project specific Java compiler settings:
63
PDECompilersConfigurationBlock_6=Missing project specific Java compiler settings:
64
PDECompilersConfigurationBlock_7=Missing or incorrect file encodings
64
PDECompilersConfigurationBlock_general=General
65
PDECompilersConfigurationBlock_general=General
65
PDECompilersConfigurationBlock_versioning=Versioning
66
PDECompilersConfigurationBlock_versioning=Versioning
66
PDECompilersConfigurationBlock_references=References
67
PDECompilersConfigurationBlock_references=References
(-)src/org/eclipse/pde/internal/ui/preferences/PDECompilersConfigurationBlock.java (-2 / +3 lines)
Lines 215-220 Link Here
215
	private static final Key KEY_P_BUILD_BIN_INCLUDES = getPDEPrefKey(CompilerFlags.P_BUILD_BIN_INCLUDES);
215
	private static final Key KEY_P_BUILD_BIN_INCLUDES = getPDEPrefKey(CompilerFlags.P_BUILD_BIN_INCLUDES);
216
	private static final Key KEY_P_BUILD_JAVA_COMPLIANCE = getPDEPrefKey(CompilerFlags.P_BUILD_JAVA_COMPLIANCE);
216
	private static final Key KEY_P_BUILD_JAVA_COMPLIANCE = getPDEPrefKey(CompilerFlags.P_BUILD_JAVA_COMPLIANCE);
217
	private static final Key KEY_P_BUILD_JAVA_COMPILER = getPDEPrefKey(CompilerFlags.P_BUILD_JAVA_COMPILER);
217
	private static final Key KEY_P_BUILD_JAVA_COMPILER = getPDEPrefKey(CompilerFlags.P_BUILD_JAVA_COMPILER);
218
	private static final Key KEY_P_BUILD_ENCODINGS = getPDEPrefKey(CompilerFlags.P_BUILD_ENCODINGS);
218
	private static final Key KEY_P_BUILD = getPDEPrefKey(CompilerFlags.P_BUILD);
219
	private static final Key KEY_P_BUILD = getPDEPrefKey(CompilerFlags.P_BUILD);
219
220
220
	// versioning
221
	// versioning
Lines 228-234 Link Here
228
229
229
	private static String[] SEVERITIES = {PDEUIMessages.PDECompilersConfigurationBlock_error, PDEUIMessages.PDECompilersConfigurationBlock_warning, PDEUIMessages.PDECompilersConfigurationBlock_ignore};
230
	private static String[] SEVERITIES = {PDEUIMessages.PDECompilersConfigurationBlock_error, PDEUIMessages.PDECompilersConfigurationBlock_warning, PDEUIMessages.PDECompilersConfigurationBlock_ignore};
230
231
231
	private static Key[] fgAllKeys = {KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS, KEY_P_BUILD, KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY, KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE, KEY_P_BUILD_JAVA_COMPILER, KEY_P_INTERNAL, KEY_P_DEPRECATED, KEY_P_DISCOURAGED_CLASS, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_EXPORT_PKGS, KEY_P_NO_REQUIRED_ATT, KEY_P_NOT_EXTERNALIZED, KEY_P_UNKNOWN_ATTRIBUTE, KEY_P_UNKNOWN_CLASS, KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_IDENTIFIER, KEY_P_UNKNOWN_RESOURCE, KEY_P_UNRESOLVED_EX_POINTS, KEY_P_UNRESOLVED_IMPORTS, KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG, KEY_P_VERSION_REQ_BUNDLE, KEY_S_CREATE_DOCS, KEY_S_DOC_FOLDER, KEY_S_OPEN_TAGS};
232
	private static Key[] fgAllKeys = {KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS, KEY_P_BUILD, KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY, KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE, KEY_P_BUILD_JAVA_COMPILER, KEY_P_BUILD_ENCODINGS, KEY_P_INTERNAL, KEY_P_DEPRECATED, KEY_P_DISCOURAGED_CLASS, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_EXPORT_PKGS, KEY_P_NO_REQUIRED_ATT, KEY_P_NOT_EXTERNALIZED, KEY_P_UNKNOWN_ATTRIBUTE, KEY_P_UNKNOWN_CLASS, KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_IDENTIFIER, KEY_P_UNKNOWN_RESOURCE, KEY_P_UNRESOLVED_EX_POINTS, KEY_P_UNRESOLVED_IMPORTS, KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG, KEY_P_VERSION_REQ_BUNDLE, KEY_S_CREATE_DOCS, KEY_S_DOC_FOLDER, KEY_S_OPEN_TAGS};
232
233
233
	/**
234
	/**
234
	 * Constant representing the {@link IDialogSettings} section for this block
235
	 * Constant representing the {@link IDialogSettings} section for this block
Lines 521-527 Link Here
521
				initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_no_required_att, PDEUIMessages.CompilersConfigurationTab_incompatEnv, PDEUIMessages.compilers_p_exported_pkgs}, new Key[] {KEY_P_NO_REQUIRED_ATT, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_EXPORT_PKGS}, CompilerFlags.PLUGIN_FLAGS);
522
				initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_no_required_att, PDEUIMessages.CompilersConfigurationTab_incompatEnv, PDEUIMessages.compilers_p_exported_pkgs}, new Key[] {KEY_P_NO_REQUIRED_ATT, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_EXPORT_PKGS}, CompilerFlags.PLUGIN_FLAGS);
522
				//build.properties
523
				//build.properties
523
				client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_build);
524
				client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_build);
524
				initializeComboControls(client, new String[] {PDEUIMessages.PDECompilersConfigurationBlock_1, PDEUIMessages.PDECompilersConfigurationBlock_2, PDEUIMessages.PDECompilersConfigurationBlock_0, PDEUIMessages.PDECompilersConfigurationBlock_3, PDEUIMessages.PDECompilersConfigurationBlock_4, PDEUIMessages.PDECompilersConfigurationBlock_5, PDEUIMessages.PDECompilersConfigurationBlock_6, PDEUIMessages.CompilersConfigurationTab_buildPropertiesErrors}, new Key[] {KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY, KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE, KEY_P_BUILD_JAVA_COMPILER, KEY_P_BUILD}, CompilerFlags.PLUGIN_FLAGS);
525
				initializeComboControls(client, new String[] {PDEUIMessages.PDECompilersConfigurationBlock_1, PDEUIMessages.PDECompilersConfigurationBlock_2, PDEUIMessages.PDECompilersConfigurationBlock_0, PDEUIMessages.PDECompilersConfigurationBlock_3, PDEUIMessages.PDECompilersConfigurationBlock_4, PDEUIMessages.PDECompilersConfigurationBlock_5, PDEUIMessages.PDECompilersConfigurationBlock_6, PDEUIMessages.PDECompilersConfigurationBlock_7, PDEUIMessages.CompilersConfigurationTab_buildPropertiesErrors}, new Key[] {KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY, KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE, KEY_P_BUILD_JAVA_COMPILER, KEY_P_BUILD_ENCODINGS, KEY_P_BUILD}, CompilerFlags.PLUGIN_FLAGS);
525
				// Versioning
526
				// Versioning
526
				client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_versioning);
527
				client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_versioning);
527
				initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_missing_require_bundle, PDEUIMessages.compilers_p_missing_exp_pkg, PDEUIMessages.compilers_p_missing_imp_pkg}, new Key[] {KEY_P_VERSION_REQ_BUNDLE, KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG}, CompilerFlags.PLUGIN_FLAGS);
528
				initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_missing_require_bundle, PDEUIMessages.compilers_p_missing_exp_pkg, PDEUIMessages.compilers_p_missing_imp_pkg}, new Key[] {KEY_P_VERSION_REQ_BUNDLE, KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG}, CompilerFlags.PLUGIN_FLAGS);

Return to bug 155015