Lines 1002-1034
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 reference, IPath path) { |
1006 |
IPath newPath = null; |
1006 |
IPath newPath = null; |
1007 |
IPath workspaceLocation = null; |
1007 |
IPath workspaceLocation = workspaceRoot.getLocation(); |
1008 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
1008 |
if (reference == null || workspaceLocation.isPrefixOf(reference)) { |
1009 |
String segment = path.segment(i); |
1009 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
1010 |
if (DOT_DOT.equals(segment)) { |
1010 |
String segment = path.segment(i); |
1011 |
if (newPath == null) { |
1011 |
if (DOT_DOT.equals(segment)) { |
1012 |
if (i == 0) { |
1012 |
if (newPath == null) { |
1013 |
workspaceLocation = workspaceRoot.getLocation(); |
1013 |
if (i == 0) { |
1014 |
newPath = workspaceLocation; |
1014 |
workspaceLocation = workspaceRoot.getLocation(); |
|
|
1015 |
newPath = workspaceLocation; |
1016 |
} else { |
1017 |
newPath = path.removeFirstSegments(i); |
1018 |
} |
1015 |
} else { |
1019 |
} else { |
1016 |
newPath = path.removeFirstSegments(i); |
1020 |
if (newPath.segmentCount() > 0) { |
|
|
1021 |
newPath = newPath.removeLastSegments(1); |
1022 |
} else { |
1023 |
workspaceLocation = workspaceRoot.getLocation(); |
1024 |
newPath = workspaceLocation; |
1025 |
} |
1017 |
} |
1026 |
} |
1018 |
} else { |
1027 |
} else if (newPath != null) { |
1019 |
if (newPath.segmentCount() > 0) { |
1028 |
if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { |
1020 |
newPath = newPath.removeLastSegments(1); |
1029 |
newPath = new Path(segment).makeAbsolute(); |
1021 |
} else { |
1030 |
} else { |
1022 |
workspaceLocation = workspaceRoot.getLocation(); |
1031 |
newPath = newPath.append(segment); |
1023 |
newPath = workspaceLocation; |
|
|
1024 |
} |
1032 |
} |
1025 |
} |
1033 |
} |
1026 |
} else if (newPath != null) { |
1034 |
} |
1027 |
if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { |
1035 |
} |
1028 |
newPath = new Path(segment).makeAbsolute(); |
1036 |
else { |
1029 |
} else { |
1037 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
|
|
1038 |
String segment = path.segment(i); |
1039 |
if (DOT_DOT.equals(segment)) { |
1040 |
if (newPath == null){ |
1041 |
newPath = reference; |
1042 |
} |
1043 |
if (newPath.segmentCount() > 0) { |
1044 |
newPath = newPath.removeLastSegments(1); |
1045 |
} |
1046 |
} else if (newPath != null) { |
1030 |
newPath = newPath.append(segment); |
1047 |
newPath = newPath.append(segment); |
1031 |
} |
1048 |
} |
1032 |
} |
1049 |
} |
1033 |
} |
1050 |
} |
1034 |
if (newPath == null) |
1051 |
if (newPath == null) |
Lines 1419-1426
Link Here
|
1419 |
return buffer.toString(); |
1436 |
return buffer.toString(); |
1420 |
} |
1437 |
} |
1421 |
|
1438 |
|
1422 |
public ClasspathEntry resolvedDotDot() { |
1439 |
public ClasspathEntry resolvedDotDot(IPath reference) { |
1423 |
IPath resolvedPath = resolveDotDot(this.path); |
1440 |
IPath resolvedPath = resolveDotDot(reference, this.path); |
1424 |
if (resolvedPath == this.path) |
1441 |
if (resolvedPath == this.path) |
1425 |
return this; |
1442 |
return this; |
1426 |
return new ClasspathEntry( |
1443 |
return new ClasspathEntry( |
Lines 1919-1925
Link Here
|
1919 |
|
1936 |
|
1920 |
// library entry check |
1937 |
// library entry check |
1921 |
case IClasspathEntry.CPE_LIBRARY : |
1938 |
case IClasspathEntry.CPE_LIBRARY : |
1922 |
path = ClasspathEntry.resolveDotDot(path); |
1939 |
path = ClasspathEntry.resolveDotDot(project.getProject().getLocation(), path); |
1923 |
|
1940 |
|
1924 |
// do not validate entries from Class-Path: in manifest |
1941 |
// do not validate entries from Class-Path: in manifest |
1925 |
// (these entries are considered optional since the user cannot act on them) |
1942 |
// (these entries are considered optional since the user cannot act on them) |