Lines 1002-1035
Link Here
|
1002 |
/* |
1002 |
/* |
1003 |
* Resolves the ".." in the given path. Returns the given path if it contains no ".." segment. |
1003 |
* Resolves the ".." in the given path. Returns the given path if it contains no ".." segment. |
1004 |
*/ |
1004 |
*/ |
1005 |
public static IPath resolveDotDot(IPath path) { |
1005 |
public static IPath resolveDotDot(IPath root, IPath path) { |
1006 |
IPath newPath = null; |
1006 |
IPath newPath = null; |
1007 |
IPath workspaceLocation = null; |
|
|
1008 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
1007 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
1009 |
String segment = path.segment(i); |
1008 |
String segment = path.segment(i); |
1010 |
if (DOT_DOT.equals(segment)) { |
1009 |
if (DOT_DOT.equals(segment)) { |
1011 |
if (newPath == null) { |
1010 |
if (newPath == null){ |
1012 |
if (i == 0) { |
1011 |
newPath = root; |
1013 |
workspaceLocation = workspaceRoot.getLocation(); |
|
|
1014 |
newPath = workspaceLocation; |
1015 |
} else { |
1016 |
newPath = path.removeFirstSegments(i); |
1017 |
} |
1018 |
} else { |
1019 |
if (newPath.segmentCount() > 0) { |
1020 |
newPath = newPath.removeLastSegments(1); |
1021 |
} else { |
1022 |
workspaceLocation = workspaceRoot.getLocation(); |
1023 |
newPath = workspaceLocation; |
1024 |
} |
1025 |
} |
1012 |
} |
|
|
1013 |
if (newPath.segmentCount() > 0) { |
1014 |
newPath = newPath.removeLastSegments(1); |
1015 |
} |
1026 |
} else if (newPath != null) { |
1016 |
} else if (newPath != null) { |
1027 |
if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { |
1017 |
newPath = newPath.append(segment); |
1028 |
newPath = new Path(segment).makeAbsolute(); |
1018 |
} |
1029 |
} else { |
|
|
1030 |
newPath = newPath.append(segment); |
1031 |
} |
1032 |
} |
1033 |
} |
1019 |
} |
1034 |
if (newPath == null) |
1020 |
if (newPath == null) |
1035 |
return path; |
1021 |
return path; |
Lines 1419-1426
Link Here
|
1419 |
return buffer.toString(); |
1405 |
return buffer.toString(); |
1420 |
} |
1406 |
} |
1421 |
|
1407 |
|
1422 |
public ClasspathEntry resolvedDotDot() { |
1408 |
public ClasspathEntry resolvedDotDot(IPath root) { |
1423 |
IPath resolvedPath = resolveDotDot(this.path); |
1409 |
IPath resolvedPath = resolveDotDot(root, this.path); |
1424 |
if (resolvedPath == this.path) |
1410 |
if (resolvedPath == this.path) |
1425 |
return this; |
1411 |
return this; |
1426 |
return new ClasspathEntry( |
1412 |
return new ClasspathEntry( |
Lines 1919-1925
Link Here
|
1919 |
|
1905 |
|
1920 |
// library entry check |
1906 |
// library entry check |
1921 |
case IClasspathEntry.CPE_LIBRARY : |
1907 |
case IClasspathEntry.CPE_LIBRARY : |
1922 |
path = ClasspathEntry.resolveDotDot(path); |
1908 |
path = ClasspathEntry.resolveDotDot(project.getProject().getLocation(), path); |
1923 |
|
1909 |
|
1924 |
// do not validate entries from Class-Path: in manifest |
1910 |
// do not validate entries from Class-Path: in manifest |
1925 |
// (these entries are considered optional since the user cannot act on them) |
1911 |
// (these entries are considered optional since the user cannot act on them) |