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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java (-1 / +1 lines)
Lines 622-628 Link Here
622
	IPackageFragment pkg = root.createPackageFragment("p", false, null);
622
	IPackageFragment pkg = root.createPackageFragment("p", false, null);
623
	
623
	
624
	clearDeltas();
624
	clearDeltas();
625
	pkg.rename("q", false, null);
625
	pkg.getResource().move(new Path("/P/src/q"), false, null);
626
	
626
	
627
	assertDeltas(
627
	assertDeltas(
628
		"Unexpected deltas",
628
		"Unexpected deltas",
(-)src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java (+38 lines)
Lines 620-625 Link Here
620
	assertTrue("java should have subpackages",					java.hasSubpackages());
620
	assertTrue("java should have subpackages",					java.hasSubpackages());
621
	assertTrue("java.lang  should NOT have subpackages",			!lang.hasSubpackages());
621
	assertTrue("java.lang  should NOT have subpackages",			!lang.hasSubpackages());
622
}
622
}
623
/*
624
 * Ensures that the structure is known for a package fragment on the classpath.
625
 */
626
public void testPackageFragmentIsStructureKnown1() throws CoreException {
627
	IPackageFragment pkg = getPackageFragment("JavaProjectTests", "", "x");
628
	assertTrue("Structure of package 'x' should be known", pkg.isStructureKnown());
629
}
630
/*
631
 * Ensures that asking if the structure is known for a package fragment outside the classpath throws a JavaModelException.
632
 * (regression test for bug 138577 Package content disapear in package explorer)
633
 */
634
public void testPackageFragmentIsStructureKnown2() throws CoreException {
635
	try {
636
		createJavaProject("P");
637
		createFolder("/P/pack");
638
		IPackageFragment pkg = getPackage("/P/pack");
639
		editFile(
640
			"/P/.classpath",
641
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
642
			"<classpath>\n" + 
643
			"	<classpathentry excluding=\"pack/\" kind=\"src\" path=\"\"/>\n" + 
644
			"	<classpathentry kind=\"output\" path=\"\"/>\n" + 
645
			"</classpath>"
646
		);
647
		JavaModelException exception = null;
648
		try {
649
			pkg.isStructureKnown();
650
		} catch (JavaModelException e) {
651
			exception = e;
652
		}
653
		assertExceptionEquals(
654
			"Unexpected exception", 
655
			"pack [in <project root> [in P]] does not exist",
656
			exception);
657
	} finally {
658
		deleteProject("P");
659
	}
660
}
623
/**
661
/**
624
 * Test getting the non-java resources from a package fragment.
662
 * Test getting the non-java resources from a package fragment.
625
 */
663
 */
(-)src/org/eclipse/jdt/core/tests/model/ExistenceTests.java (+22 lines)
Lines 245-250 Link Here
245
	}
245
	}
246
}
246
}
247
/*
247
/*
248
 * Ensure that an excluded package fragment doesn't exist.
249
 * (regression test for bug 138577 Package content disapear in package explorer)
250
 */
251
public void testNonExistingPackageFragment3() throws CoreException {
252
	try {
253
		createJavaProject("P");
254
		createFolder("/P/pack");
255
		IPackageFragment pkg = getPackage("/P/pack");
256
		editFile(
257
			"/P/.classpath",
258
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
259
			"<classpath>\n" + 
260
			"	<classpathentry excluding=\"pack/\" kind=\"src\" path=\"\"/>\n" + 
261
			"	<classpathentry kind=\"output\" path=\"\"/>\n" + 
262
			"</classpath>"
263
		);
264
		assertFalse(	"pack should not exist", pkg.exists());
265
	} finally {
266
		deleteProject("P");
267
	}
268
}
269
/*
248
 * Ensure that a non-Java project doesn't exist.
270
 * Ensure that a non-Java project doesn't exist.
249
 * (regression test for bug 28545 JavaProject.exists() returns true if project doesn't have Java nature)
271
 * (regression test for bug 28545 JavaProject.exists() returns true if project doesn't have Java nature)
250
 */
272
 */
(-)model/org/eclipse/jdt/internal/core/PackageFragment.java (-1 / +8 lines)
Lines 65-72 Link Here
65
65
66
	// check whether this pkg can be opened
66
	// check whether this pkg can be opened
67
	if (!underlyingResource.isAccessible()) throw newNotPresentException();
67
	if (!underlyingResource.isAccessible()) throw newNotPresentException();
68
68
	
69
	// check that it is not excluded (https://bugs.eclipse.org/bugs/show_bug.cgi?id=138577)
69
	int kind = getKind();
70
	int kind = getKind();
71
	if (kind == IPackageFragmentRoot.K_SOURCE && Util.isExcluded(this)) 
72
		throw newNotPresentException();
73
70
74
71
	// add compilation units/class files from resources
75
	// add compilation units/class files from resources
72
	HashSet vChildren = new HashSet();
76
	HashSet vChildren = new HashSet();
Lines 162-167 Link Here
162
	return Util.equalArraysOrNull(this.names, other.names) &&
166
	return Util.equalArraysOrNull(this.names, other.names) &&
163
			this.parent.equals(other.parent);
167
			this.parent.equals(other.parent);
164
}
168
}
169
public boolean exists() {
170
	return super.exists() && !Util.isExcluded(this);
171
}
165
/**
172
/**
166
 * @see IPackageFragment#getClassFile(String)
173
 * @see IPackageFragment#getClassFile(String)
167
 * @exception IllegalArgumentException if the name does not end with ".class"
174
 * @exception IllegalArgumentException if the name does not end with ".class"

Return to bug 138577