Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
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 |
newPath = workspaceLocation; |
|
|
1015 |
} else { |
1016 |
newPath = path.removeFirstSegments(i); |
1017 |
} |
1015 |
} else { |
1018 |
} else { |
1016 |
newPath = path.removeFirstSegments(i); |
1019 |
if (newPath.segmentCount() > 0) { |
|
|
1020 |
newPath = newPath.removeLastSegments(1); |
1021 |
} else { |
1022 |
newPath = workspaceLocation; |
1023 |
} |
1017 |
} |
1024 |
} |
1018 |
} else { |
1025 |
} else if (newPath != null) { |
1019 |
if (newPath.segmentCount() > 0) { |
1026 |
if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { |
1020 |
newPath = newPath.removeLastSegments(1); |
1027 |
newPath = new Path(segment).makeAbsolute(); |
1021 |
} else { |
1028 |
} else { |
1022 |
workspaceLocation = workspaceRoot.getLocation(); |
1029 |
newPath = newPath.append(segment); |
1023 |
newPath = workspaceLocation; |
|
|
1024 |
} |
1030 |
} |
1025 |
} |
1031 |
} |
1026 |
} else if (newPath != null) { |
1032 |
} |
1027 |
if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { |
1033 |
} |
1028 |
newPath = new Path(segment).makeAbsolute(); |
1034 |
else { |
1029 |
} else { |
1035 |
for (int i = 0, length = path.segmentCount(); i < length; i++) { |
|
|
1036 |
String segment = path.segment(i); |
1037 |
if (DOT_DOT.equals(segment)) { |
1038 |
if (newPath == null){ |
1039 |
newPath = reference; |
1040 |
} |
1041 |
if (newPath.segmentCount() > 0) { |
1042 |
newPath = newPath.removeLastSegments(1); |
1043 |
} |
1044 |
} else if (newPath != null) { |
1030 |
newPath = newPath.append(segment); |
1045 |
newPath = newPath.append(segment); |
1031 |
} |
1046 |
} |
1032 |
} |
1047 |
} |
1033 |
} |
1048 |
} |
1034 |
if (newPath == null) |
1049 |
if (newPath == null) |
Lines 1419-1426
Link Here
|
1419 |
return buffer.toString(); |
1434 |
return buffer.toString(); |
1420 |
} |
1435 |
} |
1421 |
|
1436 |
|
1422 |
public ClasspathEntry resolvedDotDot() { |
1437 |
public ClasspathEntry resolvedDotDot(IPath reference) { |
1423 |
IPath resolvedPath = resolveDotDot(this.path); |
1438 |
IPath resolvedPath = resolveDotDot(reference, this.path); |
1424 |
if (resolvedPath == this.path) |
1439 |
if (resolvedPath == this.path) |
1425 |
return this; |
1440 |
return this; |
1426 |
return new ClasspathEntry( |
1441 |
return new ClasspathEntry( |
Lines 1919-1925
Link Here
|
1919 |
|
1934 |
|
1920 |
// library entry check |
1935 |
// library entry check |
1921 |
case IClasspathEntry.CPE_LIBRARY : |
1936 |
case IClasspathEntry.CPE_LIBRARY : |
1922 |
path = ClasspathEntry.resolveDotDot(path); |
1937 |
path = ClasspathEntry.resolveDotDot(project.getProject().getLocation(), path); |
1923 |
|
1938 |
|
1924 |
// do not validate entries from Class-Path: in manifest |
1939 |
// do not validate entries from Class-Path: in manifest |
1925 |
// (these entries are considered optional since the user cannot act on them) |
1940 |
// (these entries are considered optional since the user cannot act on them) |