View | Details | Raw Unified | Return to bug 216772
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (+21 lines)
Lines 1726-1731 Link Here
1726
		return this.cache.getExistingElement(element);
1726
		return this.cache.getExistingElement(element);
1727
	}
1727
	}
1728
1728
1729
	public HashSet getExternalWorkingCopyProjects() {
1730
		synchronized (this.perWorkingCopyInfos) {
1731
			HashSet result = null;
1732
			Iterator values = this.perWorkingCopyInfos.values().iterator();
1733
			while (values.hasNext()) {
1734
				Map ownerCopies = (Map) values.next();
1735
				Iterator workingCopies = ownerCopies.keySet().iterator();
1736
				while (workingCopies.hasNext()) {
1737
					ICompilationUnit workingCopy = (ICompilationUnit) workingCopies.next();
1738
					IJavaProject project = workingCopy.getJavaProject();
1739
					if (project.getElementName().equals(ExternalJavaProject.EXTERNAL_PROJECT_NAME)) {
1740
						if (result == null)
1741
							result = new HashSet();
1742
						result.add(project);
1743
					}
1744
				}
1745
			}
1746
			return result;
1747
		}
1748
	}
1749
	
1729
	/**
1750
	/**
1730
	 * Get workspace eclipse preference for JavaCore plug-in.
1751
	 * Get workspace eclipse preference for JavaCore plug-in.
1731
	 */
1752
	 */
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (+17 lines)
Lines 705-712 Link Here
705
		try {
705
		try {
706
			if (monitor != null) monitor.beginTask("", 1); //$NON-NLS-1$
706
			if (monitor != null) monitor.beginTask("", 1); //$NON-NLS-1$
707
707
708
			boolean hasExternalWorkingCopyProject = false;
708
			for (int i = 0, length = elementsScope.length; i < length; i++) {
709
			for (int i = 0, length = elementsScope.length; i < length; i++) {
710
				IJavaElement element = elementsScope[i];
709
				this.state.addForRefresh(elementsScope[i]);
711
				this.state.addForRefresh(elementsScope[i]);
712
				if (element.getElementType() == IJavaElement.JAVA_MODEL) {
713
					// ensure external working copies' projects' caches are reset
714
					HashSet projects = JavaModelManager.getJavaModelManager().getExternalWorkingCopyProjects();
715
					if (projects != null) {
716
						hasExternalWorkingCopyProject = true;
717
						Iterator iterator = projects.iterator();
718
						while (iterator.hasNext()) {
719
							JavaProject project = (JavaProject) iterator.next();
720
							project.resetCaches();
721
						}
722
					}
723
				}
710
			}
724
			}
711
			HashSet elementsToRefresh = this.state.removeExternalElementsToRefresh();
725
			HashSet elementsToRefresh = this.state.removeExternalElementsToRefresh();
712
			boolean hasDelta = elementsToRefresh != null && createExternalArchiveDelta(elementsToRefresh, monitor);
726
			boolean hasDelta = elementsToRefresh != null && createExternalArchiveDelta(elementsToRefresh, monitor);
Lines 744-749 Link Here
744
				if (this.currentDelta != null) { // if delta has not been fired while creating markers
758
				if (this.currentDelta != null) { // if delta has not been fired while creating markers
745
					this.fire(this.currentDelta, DEFAULT_CHANGE_EVENT);
759
					this.fire(this.currentDelta, DEFAULT_CHANGE_EVENT);
746
				}
760
				}
761
			} else if (hasExternalWorkingCopyProject) {
762
				// flush jar type cache
763
				JavaModelManager.getJavaModelManager().resetJarTypeCache();
747
			}
764
			}
748
		} finally {
765
		} finally {
749
			this.currentDelta = null;
766
			this.currentDelta = null;
(-)src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java (+48 lines)
Lines 1623-1628 Link Here
1623
}
1623
}
1624
1624
1625
/*
1625
/*
1626
 * Ensures that an error is detected after refreshing external archives used by
1627
 * an external working copy.
1628
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=216772 )
1629
 */
1630
public void testExternal3() throws Exception {
1631
	try {
1632
		this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp()
1633
		this.workingCopy = null;
1634
		this.problemRequestor =  new ProblemRequestor();
1635
		createJar(new String[] {
1636
			"p/Lib.java",
1637
			"package p;\n" +
1638
			"public class Lib {\n" +
1639
			"}"
1640
		}, getExternalResourcePath("lib.jar"));
1641
		IClasspathEntry[] classpath = new IClasspathEntry[] {
1642
			JavaCore.newLibraryEntry(getExternalJCLPath(), null, null),
1643
			JavaCore.newLibraryEntry(new Path(getExternalResourcePath("lib.jar")), null, null)
1644
		};
1645
		this.workingCopy = newExternalWorkingCopy("External.java", classpath, this.problemRequestor,
1646
			"public class External {\n"+
1647
			"	p.Lib field;\n"+
1648
			"}\n"
1649
		);
1650
		this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null/*no owner*/, null);
1651
	
1652
		createJar(new String[] {
1653
			"p/Lib2.java",
1654
			"package p;\n" +
1655
			"public class Lib2 {\n" +
1656
			"}"
1657
		}, getExternalResourcePath("lib.jar"));
1658
		getJavaModel().refreshExternalArchives(null, null);
1659
		this.problemRequestor.reset();
1660
		this.workingCopy.reconcile(ICompilationUnit.NO_AST, true/*force problem detection*/, null/*no owner*/, null);
1661
		assertProblems(
1662
			"Unexpected problems",
1663
			"----------\n" + 
1664
			"1. ERROR in / /External.java\n" + 
1665
			"p.Lib cannot be resolved to a type\n" + 
1666
			"----------\n"
1667
		);
1668
	} finally {
1669
		deleteExternalResource("lib.jar");
1670
	}
1671
}
1672
1673
/*
1626
 * Ensures that included part of prereq project are visible
1674
 * Ensures that included part of prereq project are visible
1627
 */
1675
 */
1628
public void testIncludePartOfAnotherProject1() throws CoreException {
1676
public void testIncludePartOfAnotherProject1() throws CoreException {

Return to bug 216772