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

Side by Side Diff: pkg/analysis_server/lib/src/context_manager.dart

Issue 1444983002: Optimize 'isWithin'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/util/absolute_path.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library context.directory.manager; 5 library context.directory.manager;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:core' hide Resource; 10 import 'dart:core' hide Resource;
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 _checkForPackagespecUpdate(path, info, info.folder); 1172 _checkForPackagespecUpdate(path, info, info.folder);
1173 _checkForAnalysisOptionsUpdate(path, info, event.type); 1173 _checkForAnalysisOptionsUpdate(path, info, event.type);
1174 } 1174 }
1175 1175
1176 /** 1176 /**
1177 * Determine whether the given [path], when interpreted relative to the 1177 * Determine whether the given [path], when interpreted relative to the
1178 * context root [root], contains a folder whose name starts with '.'. 1178 * context root [root], contains a folder whose name starts with '.'.
1179 */ 1179 */
1180 bool _isContainedInDotFolder(String root, String path) { 1180 bool _isContainedInDotFolder(String root, String path) {
1181 String pathDir = absolutePathContext.dirname(path); 1181 String pathDir = absolutePathContext.dirname(path);
1182 String suffixPath = absolutePathContext.suffix(pathDir, root); 1182 String suffixPath = absolutePathContext.suffix(root, pathDir);
1183 if (suffixPath == null) { 1183 if (suffixPath == null) {
1184 return false; 1184 return false;
1185 } 1185 }
1186 for (String pathComponent in absolutePathContext.split(suffixPath)) { 1186 for (String pathComponent in absolutePathContext.split(suffixPath)) {
1187 if (pathComponent.startsWith('.') && 1187 if (pathComponent.startsWith('.') &&
1188 pathComponent != '.' && 1188 pathComponent != '.' &&
1189 pathComponent != '..') { 1189 pathComponent != '..') {
1190 return true; 1190 return true;
1191 } 1191 }
1192 } 1192 }
(...skipping 15 matching lines...) Expand all
1208 } 1208 }
1209 return path == excludedPath; 1209 return path == excludedPath;
1210 }); 1210 });
1211 } 1211 }
1212 1212
1213 /** 1213 /**
1214 * Determine whether the given [path], when interpreted relative to the 1214 * Determine whether the given [path], when interpreted relative to the
1215 * context root [root], contains a 'packages' folder. 1215 * context root [root], contains a 'packages' folder.
1216 */ 1216 */
1217 bool _isInPackagesDir(String root, String path) { 1217 bool _isInPackagesDir(String root, String path) {
1218 String suffixPath = absolutePathContext.suffix(path, root); 1218 String suffixPath = absolutePathContext.suffix(root, path);
1219 if (suffixPath == null) { 1219 if (suffixPath == null) {
1220 return false; 1220 return false;
1221 } 1221 }
1222 List<String> pathParts = absolutePathContext.split(suffixPath); 1222 List<String> pathParts = absolutePathContext.split(suffixPath);
1223 return pathParts.contains(PACKAGES_NAME); 1223 return pathParts.contains(PACKAGES_NAME);
1224 } 1224 }
1225 1225
1226 /** 1226 /**
1227 * Determine whether the given [path] is in the direct 'doc' folder of the 1227 * Determine whether the given [path] is in the direct 'doc' folder of the
1228 * context root [root]. 1228 * context root [root].
1229 */ 1229 */
1230 bool _isInTopLevelDocDir(String root, String path) { 1230 bool _isInTopLevelDocDir(String root, String path) {
1231 String suffixPath = absolutePathContext.suffix(path, root); 1231 String suffixPath = absolutePathContext.suffix(root, path);
1232 if (suffixPath == null) { 1232 if (suffixPath == null) {
1233 return false; 1233 return false;
1234 } 1234 }
1235 return suffixPath == DOC_DIR_NAME || 1235 return suffixPath == DOC_DIR_NAME ||
1236 suffixPath.startsWith(DOC_DIR_NAME + absolutePathContext.separator); 1236 suffixPath.startsWith(DOC_DIR_NAME + absolutePathContext.separator);
1237 } 1237 }
1238 1238
1239 bool _isPackagespec(String path) => 1239 bool _isPackagespec(String path) =>
1240 absolutePathContext.basename(path) == PACKAGE_SPEC_NAME; 1240 absolutePathContext.basename(path) == PACKAGE_SPEC_NAME;
1241 1241
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 var path = resourceProvider.pathContext.fromUri(uri); 1469 var path = resourceProvider.pathContext.fromUri(uri);
1470 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; 1470 packageMap[name] = <Folder>[resourceProvider.getFolder(path)];
1471 } 1471 }
1472 }); 1472 });
1473 return <UriResolver>[new SdkExtUriResolver(packageMap)]; 1473 return <UriResolver>[new SdkExtUriResolver(packageMap)];
1474 } else { 1474 } else {
1475 return const <UriResolver>[]; 1475 return const <UriResolver>[];
1476 } 1476 }
1477 } 1477 }
1478 } 1478 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/util/absolute_path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698