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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java (-5 / +8 lines)
Lines 201-207 Link Here
201
			ReferenceCollection refs = (ReferenceCollection) valueTable[i];
201
			ReferenceCollection refs = (ReferenceCollection) valueTable[i];
202
			if (refs.includes(internedQualifiedNames, internedSimpleNames)) {
202
			if (refs.includes(internedQualifiedNames, internedSimpleNames)) {
203
				IFile file = javaBuilder.currentProject.getFile(typeLocator);
203
				IFile file = javaBuilder.currentProject.getFile(typeLocator);
204
				SourceFile sourceFile = findSourceFile(file);
204
				SourceFile sourceFile = findSourceFile(file, true);
205
				if (sourceFile == null) continue next;
205
				if (sourceFile == null) continue next;
206
				if (sourceFiles.contains(sourceFile)) continue next;
206
				if (sourceFiles.contains(sourceFile)) continue next;
207
				if (compiledAllAtOnce && previousSourceFiles != null && previousSourceFiles.contains(sourceFile))
207
				if (compiledAllAtOnce && previousSourceFiles != null && previousSourceFiles.contains(sourceFile))
Lines 306-321 Link Here
306
	// delete generated files and recompile any affected source files
306
	// delete generated files and recompile any affected source files
307
	try {
307
	try {
308
		for (int j = deletedGeneratedFiles.length; --j >= 0;) {
308
		for (int j = deletedGeneratedFiles.length; --j >= 0;) {
309
			SourceFile sourceFile = findSourceFile(deletedGeneratedFiles[j]);
309
			IFile deletedFile = deletedGeneratedFiles[j];
310
			if (sourceFile == null) continue;
310
			if (deletedFile.exists()) continue; // only delete .class files for source files that were actually deleted
311
312
			SourceFile sourceFile = findSourceFile(deletedFile, false);
311
			String typeLocator = sourceFile.typeLocator();
313
			String typeLocator = sourceFile.typeLocator();
312
			int mdSegmentCount = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount();
314
			int mdSegmentCount = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount();
313
			IPath typePath = sourceFile.resource.getFullPath().removeFirstSegments(mdSegmentCount).removeFileExtension();
315
			IPath typePath = sourceFile.resource.getFullPath().removeFirstSegments(mdSegmentCount).removeFileExtension();
316
			addDependentsOf(typePath, true); // add dependents of the source file since its now deleted
317
			previousSourceFiles = null; // existing source files did not see it as deleted since they were compiled before it was
314
			char[][] definedTypeNames = newState.getDefinedTypeNamesFor(typeLocator);
318
			char[][] definedTypeNames = newState.getDefinedTypeNamesFor(typeLocator);
315
			if (definedTypeNames == null) { // defined a single type matching typePath
319
			if (definedTypeNames == null) { // defined a single type matching typePath
316
				removeClassFile(typePath, sourceFile.sourceLocation.binaryFolder);
320
				removeClassFile(typePath, sourceFile.sourceLocation.binaryFolder);
317
			} else {
321
			} else {
318
				addDependentsOf(typePath, true); // add dependents of the source file since it may be involved in a name collision
319
				if (definedTypeNames.length > 0) { // skip it if it failed to successfully define a type
322
				if (definedTypeNames.length > 0) { // skip it if it failed to successfully define a type
320
					IPath packagePath = typePath.removeLastSegments(1);
323
					IPath packagePath = typePath.removeLastSegments(1);
321
					for (int d = 0, l = definedTypeNames.length; d < l; d++)
324
					for (int d = 0, l = definedTypeNames.length; d < l; d++)
Lines 692-698 Link Here
692
		IFile[] addedGeneratedFiles = result.addedFiles;
695
		IFile[] addedGeneratedFiles = result.addedFiles;
693
		if (addedGeneratedFiles != null) {
696
		if (addedGeneratedFiles != null) {
694
			for (int j = addedGeneratedFiles.length; --j >= 0;) {
697
			for (int j = addedGeneratedFiles.length; --j >= 0;) {
695
				SourceFile sourceFile = findSourceFile(addedGeneratedFiles[j]);
698
				SourceFile sourceFile = findSourceFile(addedGeneratedFiles[j], true);
696
				if (sourceFile != null && !sourceFiles.contains(sourceFile))
699
				if (sourceFile != null && !sourceFiles.contains(sourceFile))
697
					this.sourceFiles.add(sourceFile);
700
					this.sourceFiles.add(sourceFile);
698
			}
701
			}
(-)model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java (-4 / +4 lines)
Lines 385-392 Link Here
385
	// no op by default
385
	// no op by default
386
}
386
}
387
387
388
protected SourceFile findSourceFile(IFile file) {
388
protected SourceFile findSourceFile(IFile file, boolean mustExist) {
389
	if (!file.exists()) return null;
389
	if (mustExist && !file.exists()) return null;
390
390
391
	// assumes the file exists in at least one of the source folders & is not excluded
391
	// assumes the file exists in at least one of the source folders & is not excluded
392
	ClasspathMultiDirectory md = sourceLocations[0];
392
	ClasspathMultiDirectory md = sourceLocations[0];
Lines 443-449 Link Here
443
 * @see org.eclipse.jdt.internal.core.builder.ICompilationUnitLocator#fromIFile(org.eclipse.core.resources.IFile)
443
 * @see org.eclipse.jdt.internal.core.builder.ICompilationUnitLocator#fromIFile(org.eclipse.core.resources.IFile)
444
 */
444
 */
445
public ICompilationUnit fromIFile(IFile file) {
445
public ICompilationUnit fromIFile(IFile file) {
446
	return findSourceFile(file);
446
	return findSourceFile(file, true);
447
}
447
}
448
448
449
protected void initializeAnnotationProcessorManager(Compiler newCompiler) {
449
protected void initializeAnnotationProcessorManager(Compiler newCompiler) {
Lines 541-547 Link Here
541
		IFile[] addedGeneratedFiles = result.addedFiles;
541
		IFile[] addedGeneratedFiles = result.addedFiles;
542
		if (addedGeneratedFiles != null) {
542
		if (addedGeneratedFiles != null) {
543
			for (int j = addedGeneratedFiles.length; --j >= 0;) {
543
			for (int j = addedGeneratedFiles.length; --j >= 0;) {
544
				SourceFile sourceFile = findSourceFile(addedGeneratedFiles[j]);
544
				SourceFile sourceFile = findSourceFile(addedGeneratedFiles[j], true);
545
				if (sourceFile == null) continue;
545
				if (sourceFile == null) continue;
546
				if (uniqueFiles == null) {
546
				if (uniqueFiles == null) {
547
					uniqueFiles = new SimpleSet(unitsAboutToCompile.length + 3);
547
					uniqueFiles = new SimpleSet(unitsAboutToCompile.length + 3);

Return to bug 163733