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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 String baseContextId = new DateTime.now().millisecondsSinceEpoch.toRadixStri
ng(16); | 103 String baseContextId = new DateTime.now().millisecondsSinceEpoch.toRadixStri
ng(16); |
104 String contextId = baseContextId; | 104 String contextId = baseContextId; |
105 int index = 1; | 105 int index = 1; |
106 while (server.contextMap.containsKey(contextId)) { | 106 while (server.contextMap.containsKey(contextId)) { |
107 contextId = '$baseContextId-$index'; | 107 contextId = '$baseContextId-$index'; |
108 } | 108 } |
109 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); | 109 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); |
110 // TODO(brianwilkerson) Use the information from the request to set the | 110 // TODO(brianwilkerson) Use the information from the request to set the |
111 // source factory in the context. | 111 // source factory in the context. |
| 112 DirectoryBasedDartSdk sdk; |
| 113 try { |
| 114 sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDirectory)); |
| 115 } on Exception catch (e) { |
| 116 // TODO what error code should be returned here? |
| 117 return new Response(request.id, new RequestError( |
| 118 RequestError.CODE_SDK_ERROR, 'Failed to access sdk: $e')); |
| 119 } |
112 context.sourceFactory = new SourceFactory.con2([ | 120 context.sourceFactory = new SourceFactory.con2([ |
113 new DartUriResolver(new DirectoryBasedDartSdk(new JavaFile(sdkDirectory)))
, | 121 new DartUriResolver(sdk), |
114 new FileUriResolver(), | 122 new FileUriResolver(), |
115 // new PackageUriResolver(), | 123 // new PackageUriResolver(), |
116 ]); | 124 ]); |
117 server.contextMap[contextId] = context; | 125 server.contextMap[contextId] = context; |
118 | 126 |
119 Response response = new Response(request.id); | 127 Response response = new Response(request.id); |
120 response.setResult(CONTEXT_ID_RESULT, contextId); | 128 response.setResult(CONTEXT_ID_RESULT, contextId); |
121 return response; | 129 return response; |
122 } | 130 } |
123 | 131 |
(...skipping 23 matching lines...) Expand all Loading... |
147 | 155 |
148 /** | 156 /** |
149 * Return the version number of the analysis server. | 157 * Return the version number of the analysis server. |
150 */ | 158 */ |
151 Response version(Request request) { | 159 Response version(Request request) { |
152 Response response = new Response(request.id); | 160 Response response = new Response(request.id); |
153 response.setResult(VERSION_RESULT, '0.0.1'); | 161 response.setResult(VERSION_RESULT, '0.0.1'); |
154 return response; | 162 return response; |
155 } | 163 } |
156 } | 164 } |
OLD | NEW |