OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, the Dart project authors. | 2 * Copyright (c) 2013, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 url = url.substring(0, index + 1); | 62 url = url.substring(0, index + 1); |
63 } | 63 } |
64 | 64 |
65 url += URIUtilities.uriEncode(relPath); | 65 url += URIUtilities.uriEncode(relPath); |
66 | 66 |
67 return url; | 67 return url; |
68 } | 68 } |
69 | 69 |
70 @Override | 70 @Override |
71 public String getUrlRegexForResource(IResource resource) { | 71 public String getUrlRegexForResource(IResource resource) { |
72 String relPath = calcRelPath(getSourceContainer(), resource); | 72 IContainer container = getSourceContainer(); |
73 | 73 |
74 if (relPath == null) { | 74 String relPath = calcRelPath(container, resource); |
75 return null; | 75 |
| 76 if (relPath != null) { |
| 77 return URIUtilities.uriEncode(relPath); |
76 } | 78 } |
77 | 79 |
78 return URIUtilities.uriEncode(relPath); | 80 // Check for package or self-reference links. |
| 81 if (container.getProject().equals(resource.getProject())) { |
| 82 String path = resource.getFullPath().toString(); |
| 83 |
| 84 if (path.contains("/packages/") || path.contains("/lib/")) { |
| 85 if (path.startsWith("/")) { |
| 86 path = path.substring(1); |
| 87 } |
| 88 |
| 89 return URIUtilities.uriEncode(path); |
| 90 } |
| 91 } |
| 92 |
| 93 return null; |
79 } | 94 } |
80 | 95 |
81 @Override | 96 @Override |
82 public IResource resolveUrl(String url) { | 97 public IResource resolveUrl(String url) { |
83 try { | 98 try { |
84 URI uri = new URI(url); | 99 URI uri = new URI(url); |
85 String filePath = uri.getPath(); | 100 String filePath = uri.getPath(); |
86 IContainer sourceDirectory = getSourceContainer(); | 101 IContainer sourceDirectory = getSourceContainer(); |
87 | 102 |
88 if (sourceDirectory == null) { | 103 if (sourceDirectory == null) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return container; | 149 return container; |
135 } else { | 150 } else { |
136 return wrapper.getProject(); | 151 return wrapper.getProject(); |
137 } | 152 } |
138 } | 153 } |
139 | 154 |
140 private String getUrl() { | 155 private String getUrl() { |
141 return wrapper.getUrl(); | 156 return wrapper.getUrl(); |
142 } | 157 } |
143 } | 158 } |
OLD | NEW |