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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java (+39 lines)
Lines 37-42 Link Here
37
public static Test suite() {
37
public static Test suite() {
38
    return buildTestSuite(PackageInfoTest.class);
38
    return buildTestSuite(PackageInfoTest.class);
39
}
39
}
40
41
//test for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=258145 : JME on duplicate package-info
42
public void test258145() throws JavaModelException {
43
    IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$
44
    env.addExternalJars(projectPath, Util.getJavaClassLibs());
45
    fullBuild(projectPath);
46
47
    // remove old package fragment root so that names don't collide
48
    env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$
49
50
    IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$
51
    env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
52
    
53
    IPath otherRoot = env.addPackageFragmentRoot(projectPath, "test"); //$NON-NLS-1$
54
    env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
55
56
    env.addPackage(root, "my.foo");
57
    env.addFile(root, "my/foo/package-info.java", //$NON-NLS-1$ //$NON-NLS-2$
58
    		"/**\n" +
59
            "* A demo package for foo.\n" +
60
            "*/\n" +
61
            "package my.foo;\n"
62
        );
63
    
64
    fullBuild(projectPath);
65
    
66
    env.addPackage(otherRoot, "my.foo");
67
    
68
    
69
    IPath otherPackageInfoPath = env.addFile(otherRoot, "my/foo/package-info.java", //$NON-NLS-1$ //$NON-NLS-2$
70
            "/**\n" +
71
            "* A demo package for foo.\n" +
72
            "*/\n" +
73
            "package my.foo;\n"
74
            );
75
76
    incrementalBuild(projectPath);
77
	expectingOnlySpecificProblemFor(otherPackageInfoPath, new Problem("my/foo/package-info.java", "The type package-info is already defined", otherPackageInfoPath, 0, 0, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
78
}
40
public void test001() throws JavaModelException {
79
public void test001() throws JavaModelException {
41
    IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$
80
    IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$
42
    env.addExternalJars(projectPath, Util.getJavaClassLibs());
81
    env.addExternalJars(projectPath, Util.getJavaClassLibs());
(-)model/org/eclipse/jdt/internal/core/SourceType.java (+21 lines)
Lines 22-27 Link Here
22
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
22
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
23
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
23
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
24
import org.eclipse.jdt.internal.compiler.lookup.Binding;
24
import org.eclipse.jdt.internal.compiler.lookup.Binding;
25
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
25
import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
26
import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
26
import org.eclipse.jdt.internal.core.util.MementoTokenizer;
27
import org.eclipse.jdt.internal.core.util.MementoTokenizer;
27
import org.eclipse.jdt.internal.core.util.Messages;
28
import org.eclipse.jdt.internal.core.util.Messages;
Lines 405-410 Link Here
405
	list.toArray(array);
406
	list.toArray(array);
406
	return array;
407
	return array;
407
}
408
}
409
410
/**
411
 * @see IMember
412
 */
413
public ISourceRange getNameRange() throws JavaModelException {
414
	try {
415
		return super.getNameRange();
416
	} catch (JavaModelException e) {
417
		if (e.getJavaModelStatus().getCode() != IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST) {
418
			throw e;
419
		}
420
		if (!CharOperation.equals(getElementName().toCharArray(), TypeConstants.PACKAGE_INFO_NAME)) {
421
			throw e;
422
		}
423
		// else silently swallow the exception as the synthetic interface type package-info has no
424
		// source range really. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=258145
425
		return new SourceRange(0, 1);
426
	}
427
}
428
408
/**
429
/**
409
 * @see IType
430
 * @see IType
410
 */
431
 */

Return to bug 258145