Index: pkg/analysis_server/lib/src/domain_execution.dart |
diff --git a/pkg/analysis_server/lib/src/domain_execution.dart b/pkg/analysis_server/lib/src/domain_execution.dart |
index 586b65971f945c4c9eb9c0f2bceba0fe4221f412..dc307e9df24d4280eddf83eea263a55903772686 100644 |
--- a/pkg/analysis_server/lib/src/domain_execution.dart |
+++ b/pkg/analysis_server/lib/src/domain_execution.dart |
@@ -10,6 +10,7 @@ import 'dart:collection'; |
import 'package:analysis_server/src/analysis_server.dart'; |
import 'package:analysis_server/src/constants.dart'; |
import 'package:analysis_server/src/protocol.dart'; |
+import 'package:analyzer/file_system/file_system.dart'; |
import 'package:analyzer/src/generated/engine.dart'; |
import 'package:analyzer/src/generated/source.dart'; |
@@ -98,19 +99,36 @@ class ExecutionDomainHandler implements RequestHandler { |
'There is no execution context with an id of $contextId'); |
} |
AnalysisContext context = server.getAnalysisContext(path); |
- if (params.file != null) { |
- if (params.uri != null) { |
+ if (context == null) { |
+ return new Response.invalidExecutionContext(request, contextId); |
+ } |
+ String file = params.file; |
+ String uri = params.uri; |
+ if (file != null) { |
+ if (uri != null) { |
return new Response.invalidParameter( |
request, |
'file', |
'Either file or uri must be provided, but not both'); |
} |
- Source source = server.getSource(params.file); |
- String uri = context.sourceFactory.restoreUri(source).toString(); |
+ Resource resource = server.resourceProvider.getResource(file); |
+ if (!resource.exists) { |
+ return new Response.invalidParameter(request, 'file', 'The file must exist'); |
+ } else if (resource is! File) { |
+ return new Response.invalidParameter(request, 'file', 'The file must be a file'); |
Paul Berry
2015/02/06 03:55:33
This seems like a confusing error message. Consid
Brian Wilkerson
2015/02/06 15:49:00
Done
|
+ } |
+ Source source = server.getSource(file); |
+ uri = context.sourceFactory.restoreUri(source).toString(); |
return new ExecutionMapUriResult(uri: uri).toResponse(request.id); |
- } else if (params.uri != null) { |
- Source source = context.sourceFactory.forUri(params.uri); |
- String file = source.fullName; |
+ } else if (uri != null) { |
+ Source source = context.sourceFactory.forUri(uri); |
+ if (source == null) { |
+ return new Response.invalidParameter( |
+ request, |
+ 'uri', |
+ 'The uri must be a valid URI'); |
Paul Berry
2015/02/06 03:55:33
Similarly, this will be formatted as "Invalid para
Brian Wilkerson
2015/02/06 15:49:00
Done
|
+ } |
+ file = source.fullName; |
return new ExecutionMapUriResult(file: file).toResponse(request.id); |
} |
return new Response.invalidParameter( |