Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/util/ResourceUtil.java

Issue 284123007: Merge r36248 into trunk. (Closed) Base URL: https://dart.googlecode.com/svn/trunk/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 } 110 }
111 111
112 /** 112 /**
113 * Answer the Eclipse resource associated with the specified file or <code>nul l</code> if none 113 * Answer the Eclipse resource associated with the specified file or <code>nul l</code> if none
114 */ 114 */
115 public static IResource getResource(File file) { 115 public static IResource getResource(File file) {
116 if (file == null) { 116 if (file == null) {
117 return null; 117 return null;
118 } 118 }
119 return getResource(getCanonicalUri(file)); 119 if (file.isDirectory()) {
120 return getResource(getCanonicalUri(file));
121 } else {
122 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
123 IFile[] files = workspaceRoot.findFilesForLocationURI(file.toURI());
124 if (files.length == 0) {
125 return null;
126 }
127 return files[0];
128 }
120 } 129 }
121 130
122 /** 131 /**
123 * Return the resource associated with the given URI, or <code>null</code> if the URI does not 132 * Return the resource associated with the given URI, or <code>null</code> if the URI does not
124 * correspond to an existing resource. 133 * correspond to an existing resource.
125 * 134 *
126 * @param uri the URI representing the resource to be returned 135 * @param uri the URI representing the resource to be returned
127 * @return the resource associated with the given URI 136 * @return the resource associated with the given URI
128 */ 137 */
129 public static IResource getResource(URI uri) { 138 public static IResource getResource(URI uri) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 249 }
241 } 250 }
242 return resourceMap; 251 return resourceMap;
243 } 252 }
244 } 253 }
245 254
246 // No instances 255 // No instances
247 private ResourceUtil() { 256 private ResourceUtil() {
248 } 257 }
249 } 258 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698