| 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 test.analysis_server; | 5 library test.analysis_server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 AnalysisError analysisError = | 137 AnalysisError analysisError = |
| 138 new AnalysisError.con1(source, errorCode, ['foo', 'bar', 'baz']); | 138 new AnalysisError.con1(source, errorCode, ['foo', 'bar', 'baz']); |
| 139 Map<String, Object> json = AnalysisServer.errorToJson(analysisError); | 139 Map<String, Object> json = AnalysisServer.errorToJson(analysisError); |
| 140 | 140 |
| 141 expect(json['message'], | 141 expect(json['message'], |
| 142 equals("The name 'foo' is defined in the libraries 'bar' and 'baz'")); | 142 equals("The name 'foo' is defined in the libraries 'bar' and 'baz'")); |
| 143 } | 143 } |
| 144 | 144 |
| 145 static void errorToJson_noCorrection() { | 145 static void errorToJson_noCorrection() { |
| 146 MockSource source = new MockSource(); | 146 MockSource source = new MockSource(); |
| 147 source.when(callsTo('get encoding')).alwaysReturn('foo.dart'); | 147 source.when(callsTo('get fullName')).alwaysReturn('foo.dart'); |
| 148 CompileTimeErrorCode errorCode = | 148 CompileTimeErrorCode errorCode = |
| 149 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER; | 149 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER; |
| 150 AnalysisError analysisError = | 150 AnalysisError analysisError = |
| 151 new AnalysisError.con2(source, 10, 5, errorCode, ['Foo']); | 151 new AnalysisError.con2(source, 10, 5, errorCode, ['Foo']); |
| 152 Map<String, Object> json = AnalysisServer.errorToJson(analysisError); | 152 Map<String, Object> json = AnalysisServer.errorToJson(analysisError); |
| 153 expect(json, hasLength(5)); | 153 expect(json, hasLength(5)); |
| 154 expect(json['source'], equals('foo.dart')); | 154 expect(json['file'], equals('foo.dart')); |
| 155 expect(json['errorCode'], equals(errorCode.ordinal)); | 155 expect(json['errorCode'], 'CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_C
ONST_SUPER'); |
| 156 expect(json['offset'], equals(analysisError.offset)); | 156 expect(json['offset'], equals(analysisError.offset)); |
| 157 expect(json['length'], equals(analysisError.length)); | 157 expect(json['length'], equals(analysisError.length)); |
| 158 expect(json['message'], equals(errorCode.message.replaceAll('%s', 'Foo'))); | 158 expect(json['message'], equals(errorCode.message.replaceAll('%s', 'Foo'))); |
| 159 } | 159 } |
| 160 | 160 |
| 161 static void errorToJson_withCorrection() { | 161 static void errorToJson_withCorrection() { |
| 162 MockSource source = new MockSource(); | 162 MockSource source = new MockSource(); |
| 163 source.when(callsTo('get encoding')).alwaysReturn('foo.dart'); | 163 source.when(callsTo('get encoding')).alwaysReturn('foo.dart'); |
| 164 | 164 |
| 165 // TODO(paulberry): in principle we should test an error or hint that uses | 165 // TODO(paulberry): in principle we should test an error or hint that uses |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 @override | 211 @override |
| 212 Response handleRequest(Request request) { | 212 Response handleRequest(Request request) { |
| 213 if (request.method == 'echo') { | 213 if (request.method == 'echo') { |
| 214 var response = new Response(request.id); | 214 var response = new Response(request.id); |
| 215 response.setResult('echo', true); | 215 response.setResult('echo', true); |
| 216 return response; | 216 return response; |
| 217 } | 217 } |
| 218 return null; | 218 return null; |
| 219 } | 219 } |
| 220 } | 220 } |
| OLD | NEW |