diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java index 27ac5e638a..eb6d97cfcf 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java @@ -185,7 +185,7 @@ protected IApiProblem createProblem(IReference reference, IJavaProject javaProje if (typeInProject != null) { type =typeInProject; } - if (type == null) { + if (type == null || Util.isTest(type)) { return null; } ICompilationUnit compilationUnit = type.getCompilationUnit(); diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java index 03cb66cf26..d1fc50f482 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java @@ -1547,7 +1547,7 @@ private void checkSinceTags(final Delta delta, final IApiComponent component) { return; } IMember member = Util.getIMember(delta, fJavaProject); - if (member == null || member.isBinary()) { + if (member == null || member.isBinary() || member instanceof IType iType && Util.isTest(iType)) { return; } ICompilationUnit cunit = member.getCompilationUnit(); diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java index 8f5291f031..4feca524b0 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java @@ -89,6 +89,7 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.core.Flags; +import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; @@ -2673,5 +2674,35 @@ public static IType findSourceTypeinJavaProject(IJavaProject javaProject, String return type; } + /** + * Returns whether the type is made available via a + * {@link IClasspathEntry#isTest() test classpath entry}. + * + * @param type the type in question. + * @return whether the type is made available via a test classpath entry. + */ + public static boolean isTest(IType type) { + try { + if (type != null) { + IPackageFragment packageFragment = type.getPackageFragment(); + if (packageFragment != null) { + IJavaElement parent = packageFragment.getParent(); + if (parent != null) { + IResource underlyingResource = parent.getUnderlyingResource(); + if (underlyingResource != null) { + IClasspathEntry classPathEntry = type.getJavaProject() + .getClasspathEntryFor(underlyingResource.getFullPath()); + if (classPathEntry.isTest()) { + return true; + } + } + } + } + } + } catch (JavaModelException e) { + // ignore + } + return false; + } }