| 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.server; | 5 library domain.server; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/protocol.dart'; | 8 import 'package:analysis_server/src/protocol.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/java_io.dart'; | 10 import 'package:analyzer/src/generated/java_io.dart'; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 return null; | 86 return null; |
| 87 } | 87 } |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * Create a new context in which analysis can be performed. The context that | 90 * Create a new context in which analysis can be performed. The context that |
| 91 * is created will persist until server.deleteContext is used to delete it. | 91 * is created will persist until server.deleteContext is used to delete it. |
| 92 * Clients, therefore, are responsible for managing the lifetime of contexts. | 92 * Clients, therefore, are responsible for managing the lifetime of contexts. |
| 93 */ | 93 */ |
| 94 Response createContext(Request request) { | 94 Response createContext(Request request) { |
| 95 String sdkDirectory = request.getRequiredParameter(SDK_DIRECTORY_PARAM); | 95 String sdkDirectory = request.getRequiredParameter(SDK_DIRECTORY_PARAM).asSt
ring(); |
| 96 Map<String, String> packageMap = request.getParameter(PACKAGE_MAP_PARAM); | 96 Map<String, String> packageMap = request.getParameter(PACKAGE_MAP_PARAM, {})
.asStringMap(); |
| 97 | 97 |
| 98 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM); | 98 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM).asString()
; |
| 99 if (server.contextMap.containsKey(contextId)) { | 99 if (server.contextMap.containsKey(contextId)) { |
| 100 return new Response.contextAlreadyExists(request); | 100 return new Response.contextAlreadyExists(request); |
| 101 } | 101 } |
| 102 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); | 102 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); |
| 103 // TODO(brianwilkerson) Use the information from the request to set the | 103 // TODO(brianwilkerson) Use the information from the request to set the |
| 104 // source factory in the context. | 104 // source factory in the context. |
| 105 DirectoryBasedDartSdk sdk; | 105 DirectoryBasedDartSdk sdk; |
| 106 try { | 106 try { |
| 107 sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDirectory)); | 107 sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDirectory)); |
| 108 } on Exception catch (e) { | 108 } on Exception catch (e) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 119 | 119 |
| 120 Response response = new Response(request.id); | 120 Response response = new Response(request.id); |
| 121 return response; | 121 return response; |
| 122 } | 122 } |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * Delete the context with the given id. Future attempts to use the context id | 125 * Delete the context with the given id. Future attempts to use the context id |
| 126 * will result in an error being returned. | 126 * will result in an error being returned. |
| 127 */ | 127 */ |
| 128 Response deleteContext(Request request) { | 128 Response deleteContext(Request request) { |
| 129 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM); | 129 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM).asString()
; |
| 130 | 130 |
| 131 AnalysisContext removedContext = server.contextMap.remove(contextId); | 131 AnalysisContext removedContext = server.contextMap.remove(contextId); |
| 132 if (removedContext == null) { | 132 if (removedContext == null) { |
| 133 return new Response.contextDoesNotExist(request); | 133 return new Response.contextDoesNotExist(request); |
| 134 } | 134 } |
| 135 Response response = new Response(request.id); | 135 Response response = new Response(request.id); |
| 136 return response; | 136 return response; |
| 137 } | 137 } |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * Cleanly shutdown the analysis server. | 140 * Cleanly shutdown the analysis server. |
| 141 */ | 141 */ |
| 142 Response shutdown(Request request) { | 142 Response shutdown(Request request) { |
| 143 server.running = false; | 143 server.running = false; |
| 144 Response response = new Response(request.id); | 144 Response response = new Response(request.id); |
| 145 return response; | 145 return response; |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * Return the version number of the analysis server. | 149 * Return the version number of the analysis server. |
| 150 */ | 150 */ |
| 151 Response version(Request request) { | 151 Response version(Request request) { |
| 152 Response response = new Response(request.id); | 152 Response response = new Response(request.id); |
| 153 response.setResult(VERSION_RESULT, '0.0.1'); | 153 response.setResult(VERSION_RESULT, '0.0.1'); |
| 154 return response; | 154 return response; |
| 155 } | 155 } |
| 156 } | 156 } |
| OLD | NEW |