| OLD | NEW |
| 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 domain.execution; | 5 library domain.execution; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:core'; | 9 import 'dart:core'; |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 */ | 90 */ |
| 91 Response mapUri(Request request) { | 91 Response mapUri(Request request) { |
| 92 ExecutionMapUriParams params = | 92 ExecutionMapUriParams params = |
| 93 new ExecutionMapUriParams.fromRequest(request); | 93 new ExecutionMapUriParams.fromRequest(request); |
| 94 String contextId = params.id; | 94 String contextId = params.id; |
| 95 String path = contextMap[contextId]; | 95 String path = contextMap[contextId]; |
| 96 if (path == null) { | 96 if (path == null) { |
| 97 return new Response.invalidParameter(request, 'id', | 97 return new Response.invalidParameter(request, 'id', |
| 98 'There is no execution context with an id of $contextId'); | 98 'There is no execution context with an id of $contextId'); |
| 99 } | 99 } |
| 100 AnalysisContext context = server.getContainingContext(path); | 100 |
| 101 if (context == null) { | 101 SourceFactory sourceFactory; |
| 102 return new Response.invalidExecutionContext(request, contextId); | 102 if (server.options.enableNewAnalysisDriver) { |
| 103 var driver = server.getAnalysisDriver(path); |
| 104 if (driver == null) { |
| 105 return new Response.invalidExecutionContext(request, contextId); |
| 106 } |
| 107 sourceFactory = driver.sourceFactory; |
| 108 } else { |
| 109 AnalysisContext context = server.getContainingContext(path); |
| 110 if (context == null) { |
| 111 return new Response.invalidExecutionContext(request, contextId); |
| 112 } |
| 113 sourceFactory = context.sourceFactory; |
| 103 } | 114 } |
| 115 |
| 104 String file = params.file; | 116 String file = params.file; |
| 105 String uri = params.uri; | 117 String uri = params.uri; |
| 106 if (file != null) { | 118 if (file != null) { |
| 107 if (uri != null) { | 119 if (uri != null) { |
| 108 return new Response.invalidParameter(request, 'file', | 120 return new Response.invalidParameter(request, 'file', |
| 109 'Either file or uri must be provided, but not both'); | 121 'Either file or uri must be provided, but not both'); |
| 110 } | 122 } |
| 111 Resource resource = server.resourceProvider.getResource(file); | 123 Resource resource = server.resourceProvider.getResource(file); |
| 112 if (!resource.exists) { | 124 if (!resource.exists) { |
| 113 return new Response.invalidParameter(request, 'file', 'Must exist'); | 125 return new Response.invalidParameter(request, 'file', 'Must exist'); |
| 114 } else if (resource is! File) { | 126 } else if (resource is! File) { |
| 115 return new Response.invalidParameter( | 127 return new Response.invalidParameter( |
| 116 request, 'file', 'Must not refer to a directory'); | 128 request, 'file', 'Must not refer to a directory'); |
| 117 } | 129 } |
| 118 ContextSourcePair contextSource = server.getContextSourcePair(file); | 130 ContextSourcePair contextSource = server.getContextSourcePair(file); |
| 119 Source source = contextSource.source; | 131 Source source = contextSource.source; |
| 120 if (source.uriKind != UriKind.FILE_URI) { | 132 if (source.uriKind != UriKind.FILE_URI) { |
| 121 uri = source.uri.toString(); | 133 uri = source.uri.toString(); |
| 122 } else { | 134 } else { |
| 123 uri = context.sourceFactory.restoreUri(source).toString(); | 135 uri = sourceFactory.restoreUri(source).toString(); |
| 124 } | 136 } |
| 125 return new ExecutionMapUriResult(uri: uri).toResponse(request.id); | 137 return new ExecutionMapUriResult(uri: uri).toResponse(request.id); |
| 126 } else if (uri != null) { | 138 } else if (uri != null) { |
| 127 Source source = context.sourceFactory.forUri(uri); | 139 Source source = sourceFactory.forUri(uri); |
| 128 if (source == null) { | 140 if (source == null) { |
| 129 return new Response.invalidParameter(request, 'uri', 'Invalid URI'); | 141 return new Response.invalidParameter(request, 'uri', 'Invalid URI'); |
| 130 } | 142 } |
| 131 file = source.fullName; | 143 file = source.fullName; |
| 132 return new ExecutionMapUriResult(file: file).toResponse(request.id); | 144 return new ExecutionMapUriResult(file: file).toResponse(request.id); |
| 133 } | 145 } |
| 134 return new Response.invalidParameter( | 146 return new Response.invalidParameter( |
| 135 request, 'file', 'Either file or uri must be provided'); | 147 request, 'file', 'Either file or uri must be provided'); |
| 136 } | 148 } |
| 137 | 149 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (_isInAnalysisRoot(filePath)) { | 247 if (_isInAnalysisRoot(filePath)) { |
| 236 server.sendNotification( | 248 server.sendNotification( |
| 237 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()); | 249 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()); |
| 238 } | 250 } |
| 239 } | 251 } |
| 240 | 252 |
| 241 static List<String> _getFullNames(List<Source> sources) { | 253 static List<String> _getFullNames(List<Source> sources) { |
| 242 return sources.map((Source source) => source.fullName).toList(); | 254 return sources.map((Source source) => source.fullName).toList(); |
| 243 } | 255 } |
| 244 } | 256 } |
| OLD | NEW |