Lines 954-987
Link Here
|
954 |
/* |
954 |
/* |
955 |
* Resolves the ".." in the given path. Returns the given path if it contains no ".." segment. |
955 |
* Resolves the ".." in the given path. Returns the given path if it contains no ".." segment. |
956 |
*/ |
956 |
*/ |
957 |
public static IPath resolveDotDot(IPath path) { |
957 |
public static IPath resolveDotDot(IPath root, IPath path) { |
958 |
IPath newPath = null; |
958 |
IPath newPath = null; |
959 |
IWorkspaceRoot root = null; |
|
|
960 |
IPath workspaceLocation = null; |
961 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
959 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
962 |
String segment = path.segment(i); |
960 |
String segment = path.segment(i); |
963 |
if (DOT_DOT.equals(segment)) { |
961 |
if (DOT_DOT.equals(segment)) { |
964 |
if (newPath == null) { |
962 |
if (newPath == null){ |
965 |
if (i == 0) { |
963 |
newPath = root; |
966 |
workspaceLocation = (root = ResourcesPlugin.getWorkspace().getRoot()).getLocation(); |
|
|
967 |
newPath = workspaceLocation; |
968 |
} else { |
969 |
newPath = path.removeFirstSegments(i); |
970 |
} |
971 |
} else { |
972 |
if (newPath.segmentCount() > 0) { |
973 |
newPath = newPath.removeLastSegments(1); |
974 |
} else { |
975 |
workspaceLocation = (root = ResourcesPlugin.getWorkspace().getRoot()).getLocation(); |
976 |
newPath = workspaceLocation; |
977 |
} |
978 |
} |
964 |
} |
979 |
} else if (newPath != null) { |
965 |
if (newPath.segmentCount() > 0) { |
980 |
if (newPath.equals(workspaceLocation) && root.getProject(segment).isAccessible()) { |
966 |
newPath = newPath.removeLastSegments(1); |
981 |
newPath = new Path(segment).makeAbsolute(); |
|
|
982 |
} else { |
983 |
newPath = newPath.append(segment); |
984 |
} |
967 |
} |
|
|
968 |
} else if (newPath != null) { |
969 |
newPath = newPath.append(segment); |
985 |
} |
970 |
} |
986 |
} |
971 |
} |
987 |
if (newPath == null) |
972 |
if (newPath == null) |
Lines 1367-1374
Link Here
|
1367 |
return buffer.toString(); |
1352 |
return buffer.toString(); |
1368 |
} |
1353 |
} |
1369 |
|
1354 |
|
1370 |
public ClasspathEntry resolvedDotDot() { |
1355 |
public ClasspathEntry resolvedDotDot(IPath root) { |
1371 |
IPath resolvedPath = resolveDotDot(this.path); |
1356 |
IPath resolvedPath = resolveDotDot(root, this.path); |
1372 |
if (resolvedPath == this.path) |
1357 |
if (resolvedPath == this.path) |
1373 |
return this; |
1358 |
return this; |
1374 |
return new ClasspathEntry( |
1359 |
return new ClasspathEntry( |
Lines 1861-1867
Link Here
|
1861 |
|
1846 |
|
1862 |
// library entry check |
1847 |
// library entry check |
1863 |
case IClasspathEntry.CPE_LIBRARY : |
1848 |
case IClasspathEntry.CPE_LIBRARY : |
1864 |
path = ClasspathEntry.resolveDotDot(path); |
1849 |
path = ClasspathEntry.resolveDotDot(project.getProject().getLocation(), path); |
1865 |
|
1850 |
|
1866 |
// do not validate entries from Class-Path: in manifest |
1851 |
// do not validate entries from Class-Path: in manifest |
1867 |
// (these entries are considered optional since the user cannot act on them) |
1852 |
// (these entries are considered optional since the user cannot act on them) |