Lines 1745-1750
Link Here
|
1745 |
* @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine |
1745 |
* @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine |
1746 |
*/ |
1746 |
*/ |
1747 |
public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){ |
1747 |
public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){ |
|
|
1748 |
return validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer); |
1749 |
} |
1750 |
|
1751 |
private static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, IClasspathContainer entryContainer, boolean checkSourceAttachment, boolean referredByContainer){ |
1748 |
|
1752 |
|
1749 |
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
1753 |
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
1750 |
IPath path = entry.getPath(); |
1754 |
IPath path = entry.getPath(); |
Lines 1796-1802
Link Here
|
1796 |
if (description == null) description = path.makeRelative().toString(); |
1800 |
if (description == null) description = path.makeRelative().toString(); |
1797 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path); |
1801 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path); |
1798 |
} |
1802 |
} |
1799 |
IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, checkSourceAttachment, true/*referred by container*/); |
1803 |
IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, container, checkSourceAttachment, true/*referred by container*/); |
1800 |
if (!containerEntryStatus.isOK()){ |
1804 |
if (!containerEntryStatus.isOK()){ |
1801 |
return containerEntryStatus; |
1805 |
return containerEntryStatus; |
1802 |
} |
1806 |
} |
Lines 1825-1831
Link Here
|
1825 |
} |
1829 |
} |
1826 |
|
1830 |
|
1827 |
// get validation status |
1831 |
// get validation status |
1828 |
IJavaModelStatus status = validateClasspathEntry(project, entry, checkSourceAttachment, false/*not referred by container*/); |
1832 |
IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, false/*not referred by container*/); |
1829 |
if (!status.isOK()) return status; |
1833 |
if (!status.isOK()) return status; |
1830 |
|
1834 |
|
1831 |
// return deprecation status if any |
1835 |
// return deprecation status if any |
Lines 1846-1853
Link Here
|
1846 |
// do not validate entries from Class-Path: in manifest |
1850 |
// do not validate entries from Class-Path: in manifest |
1847 |
// (these entries are considered optional since the user cannot act on them) |
1851 |
// (these entries are considered optional since the user cannot act on them) |
1848 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252392 |
1852 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252392 |
1849 |
|
1853 |
String containerName = entryContainer != null ? entryContainer.getDescription() : null; |
1850 |
IJavaModelStatus status = validateLibraryEntry(path, project, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg); |
1854 |
IJavaModelStatus status = validateLibraryEntry(path, project, containerName, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg); |
1851 |
if (!status.isOK()) |
1855 |
if (!status.isOK()) |
1852 |
return status; |
1856 |
return status; |
1853 |
break; |
1857 |
break; |
Lines 1916-1922
Link Here
|
1916 |
return JavaModelStatus.VERIFIED_OK; |
1920 |
return JavaModelStatus.VERIFIED_OK; |
1917 |
} |
1921 |
} |
1918 |
|
1922 |
|
1919 |
private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, IPath sourceAttachment, String entryPathMsg) { |
1923 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=232816, now we have the facility to include a container |
|
|
1924 |
// name in diagnostics. |
1925 |
private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, String containerName, IPath sourceAttachment, String entryPathMsg) { |
1920 |
if (path.isAbsolute() && !path.isEmpty()) { |
1926 |
if (path.isAbsolute() && !path.isEmpty()) { |
1921 |
Object target = JavaModel.getTarget(path, true); |
1927 |
Object target = JavaModel.getTarget(path, true); |
1922 |
if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) { |
1928 |
if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) { |
Lines 1955-1965
Link Here
|
1955 |
} else { |
1961 |
} else { |
1956 |
boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists(); |
1962 |
boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists(); |
1957 |
if (isExternal) { |
1963 |
if (isExternal) { |
1958 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {path.toOSString(), project.getElementName()})); |
1964 |
if (containerName != null) { |
|
|
1965 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibraryInContainer, new String[] {path.toOSString(), containerName, project.getElementName()})); |
1966 |
} else { |
1967 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {path.toOSString(), project.getElementName()})); |
1968 |
} |
1959 |
} else { |
1969 |
} else { |
1960 |
if (entryPathMsg == null) |
1970 |
if (entryPathMsg == null) |
1961 |
entryPathMsg = project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString(); |
1971 |
entryPathMsg = project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString(); |
1962 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {entryPathMsg, project.getElementName()})); |
1972 |
if (containerName != null) { |
|
|
1973 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibraryInContainer, new String[] {entryPathMsg, containerName, project.getElementName()})); |
1974 |
} else { |
1975 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {entryPathMsg, project.getElementName()})); |
1976 |
} |
1963 |
} |
1977 |
} |
1964 |
} |
1978 |
} |
1965 |
} else { |
1979 |
} else { |