| 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/constants.dart'; | 8 import 'package:analysis_server/src/constants.dart'; |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 * Subscribe for services. | 51 * Subscribe for services. |
| 52 * | 52 * |
| 53 * All previous subscriptions are replaced by the given set of subscriptions. | 53 * All previous subscriptions are replaced by the given set of subscriptions. |
| 54 */ | 54 */ |
| 55 Response setSubscriptions(Request request) { | 55 Response setSubscriptions(Request request) { |
| 56 server.serverServices = | 56 server.serverServices = |
| 57 new ServerSetSubscriptionsParams.fromRequest(request).subscriptions.toSe
t(); | 57 new ServerSetSubscriptionsParams.fromRequest(request).subscriptions.toSe
t(); |
| 58 return new ServerSetSubscriptionsResult().toResponse(request.id); | 58 return new ServerSetSubscriptionsResult().toResponse(request.id); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // TODO(scheglov) remove or move to the 'analysis' domain | |
| 62 // /** | |
| 63 // * Create a new context in which analysis can be performed. The context that | |
| 64 // * is created will persist until server.deleteContext is used to delete it. | |
| 65 // * Clients, therefore, are responsible for managing the lifetime of contexts
. | |
| 66 // */ | |
| 67 // Response createContext(Request request) { | |
| 68 // String sdkDirectory = request.getRequiredParameter(SDK_DIRECTORY_PARAM).as
String(); | |
| 69 // Map<String, String> packageMap = request.getParameter(PACKAGE_MAP_PARAM, {
}).asStringMap(); | |
| 70 // | |
| 71 // String contextId = request.getRequiredParameter(AnalysisServer.CONTEXT_ID_
PARAM).asString(); | |
| 72 // if (server.contextMap.containsKey(contextId)) { | |
| 73 // return new Response.contextAlreadyExists(request); | |
| 74 // } | |
| 75 // AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); | |
| 76 // // TODO(brianwilkerson) Use the information from the request to set the | |
| 77 // // source factory in the context. | |
| 78 // DirectoryBasedDartSdk sdk; | |
| 79 // try { | |
| 80 // sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDirectory)); | |
| 81 // } on Exception catch (e) { | |
| 82 // // TODO what error code should be returned here? | |
| 83 // return new Response(request.id, new RequestError( | |
| 84 // RequestError.CODE_SDK_ERROR, 'Failed to access sdk: $e')); | |
| 85 // } | |
| 86 // context.sourceFactory = new SourceFactory([ | |
| 87 // new DartUriResolver(sdk), | |
| 88 // new FileUriResolver(), | |
| 89 // // new PackageUriResolver(), | |
| 90 // ]); | |
| 91 // server.contextMap[contextId] = context; | |
| 92 // server.contextIdMap[context] = contextId; | |
| 93 // | |
| 94 // Response response = new Response(request.id); | |
| 95 // return response; | |
| 96 // } | |
| 97 // | |
| 98 // /** | |
| 99 // * Delete the context with the given id. Future attempts to use the context
id | |
| 100 // * will result in an error being returned. | |
| 101 // */ | |
| 102 // Response deleteContext(Request request) { | |
| 103 // String contextId = request.getRequiredParameter(AnalysisServer.CONTEXT_ID_
PARAM).asString(); | |
| 104 // | |
| 105 // AnalysisContext removedContext = server.contextMap.remove(contextId); | |
| 106 // if (removedContext == null) { | |
| 107 // return new Response.contextDoesNotExist(request); | |
| 108 // } | |
| 109 // server.contextIdMap.remove(removedContext); | |
| 110 // Response response = new Response(request.id); | |
| 111 // return response; | |
| 112 // } | |
| 113 | |
| 114 /** | 61 /** |
| 115 * Cleanly shutdown the analysis server. | 62 * Cleanly shutdown the analysis server. |
| 116 */ | 63 */ |
| 117 Response shutdown(Request request) { | 64 Response shutdown(Request request) { |
| 118 server.shutdown(); | 65 server.shutdown(); |
| 119 Response response = new ServerShutdownResult().toResponse(request.id); | 66 Response response = new ServerShutdownResult().toResponse(request.id); |
| 120 return response; | 67 return response; |
| 121 } | 68 } |
| 122 } | 69 } |
| OLD | NEW |