| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analysis_server.src.status.validator; | 5 library analysis_server.src.status.validator; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 */ | 57 */ |
| 58 bool get hasDifference => _buffer.length > 0; | 58 bool get hasDifference => _buffer.length > 0; |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Compare the [expected] and [actual] elements. The results of the comparison | 61 * Compare the [expected] and [actual] elements. The results of the comparison |
| 62 * can be accessed via the [hasDifference] and [description] getters. | 62 * can be accessed via the [hasDifference] and [description] getters. |
| 63 */ | 63 */ |
| 64 void compareElements(Element expected, Element actual) { | 64 void compareElements(Element expected, Element actual) { |
| 65 if (expected == null) { | 65 if (expected == null) { |
| 66 if (actual != null) { | 66 if (actual != null) { |
| 67 _writeMismatch(expected, actual, (Element element) { | 67 _writeMismatch(expected, actual, (Object element) { |
| 68 return element == null ? 'null' : 'non null ${element.runtimeType}'; | 68 return element == null ? 'null' : 'non null ${element.runtimeType}'; |
| 69 }); | 69 }); |
| 70 } | 70 } |
| 71 } else if (actual == null) { | 71 } else if (actual == null) { |
| 72 _writeMismatch(expected, actual, (Element element) { | 72 _writeMismatch(expected, actual, (Object element) { |
| 73 return element == null ? 'null' : 'non null ${element.runtimeType}'; | 73 return element == null ? 'null' : 'non null ${element.runtimeType}'; |
| 74 }); | 74 }); |
| 75 } else if (expected is ClassElement && actual is ClassElement) { | 75 } else if (expected is ClassElement && actual is ClassElement) { |
| 76 _compareClassElements(expected, actual); | 76 _compareClassElements(expected, actual); |
| 77 } else if (expected is CompilationUnitElement && | 77 } else if (expected is CompilationUnitElement && |
| 78 actual is CompilationUnitElement) { | 78 actual is CompilationUnitElement) { |
| 79 _compareCompilationUnitElements(expected, actual); | 79 _compareCompilationUnitElements(expected, actual); |
| 80 } else if (expected is ConstructorElement && actual is ConstructorElement) { | 80 } else if (expected is ConstructorElement && actual is ConstructorElement) { |
| 81 _compareConstructorElements(expected, actual); | 81 _compareConstructorElements(expected, actual); |
| 82 } else if (expected is ExportElement && actual is ExportElement) { | 82 } else if (expected is ExportElement && actual is ExportElement) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 void _compareClassElements(ClassElement expected, ClassElement actual) { | 129 void _compareClassElements(ClassElement expected, ClassElement actual) { |
| 130 _compareGenericElements(expected, actual); | 130 _compareGenericElements(expected, actual); |
| 131 // | 131 // |
| 132 // Compare attributes. | 132 // Compare attributes. |
| 133 // | 133 // |
| 134 if (expected.hasReferenceToSuper != actual.hasReferenceToSuper) { | 134 if (expected.hasReferenceToSuper != actual.hasReferenceToSuper) { |
| 135 _writeMismatch( | 135 _writeMismatch( |
| 136 expected, | 136 expected, |
| 137 actual, | 137 actual, |
| 138 (ClassElement element) => element.hasReferenceToSuper | 138 (Object element) => (element as ClassElement).hasReferenceToSuper |
| 139 ? 'a class that references super' | 139 ? 'a class that references super' |
| 140 : 'a class that does not reference super'); | 140 : 'a class that does not reference super'); |
| 141 } | 141 } |
| 142 if (expected.isAbstract != actual.isAbstract) { | 142 if (expected.isAbstract != actual.isAbstract) { |
| 143 _writeMismatch( | 143 _writeMismatch( |
| 144 expected, | 144 expected, |
| 145 actual, | 145 actual, |
| 146 (ClassElement element) => | 146 (Object element) => (element as ClassElement).isAbstract |
| 147 element.isAbstract ? 'an abstract class' : 'a concrete class'); | 147 ? 'an abstract class' |
| 148 : 'a concrete class'); |
| 148 } | 149 } |
| 149 if (expected.isEnum != actual.isEnum || | 150 if (expected.isEnum != actual.isEnum || |
| 150 expected.isMixinApplication != actual.isMixinApplication) { | 151 expected.isMixinApplication != actual.isMixinApplication) { |
| 151 _writeMismatch( | 152 _writeMismatch(expected, actual, (Object element) { |
| 152 expected, | 153 ClassElement classElement = element as ClassElement; |
| 153 actual, | 154 return classElement.isEnum |
| 154 (ClassElement element) => element.isEnum | 155 ? 'an enum' |
| 155 ? 'an enum' | 156 : (classElement.isMixinApplication |
| 156 : (element.isMixinApplication | 157 ? 'a mixin application' |
| 157 ? 'a mixin application' | 158 : 'a class'); |
| 158 : 'a class')); | 159 }); |
| 159 } | 160 } |
| 160 if (expected.isOrInheritsProxy != actual.isOrInheritsProxy) { | 161 if (expected.isOrInheritsProxy != actual.isOrInheritsProxy) { |
| 161 _writeMismatch( | 162 _writeMismatch( |
| 162 expected, | 163 expected, |
| 163 actual, | 164 actual, |
| 164 (ClassElement element) => element.isOrInheritsProxy | 165 (Object element) => (element as ClassElement).isOrInheritsProxy |
| 165 ? 'a class that is marked as a proxy' | 166 ? 'a class that is marked as a proxy' |
| 166 : 'a class that is not marked as a proxy'); | 167 : 'a class that is not marked as a proxy'); |
| 167 } | 168 } |
| 168 if (expected.isValidMixin != actual.isValidMixin) { | 169 if (expected.isValidMixin != actual.isValidMixin) { |
| 169 _writeMismatch( | 170 _writeMismatch( |
| 170 expected, | 171 expected, |
| 171 actual, | 172 actual, |
| 172 (ClassElement element) => | 173 (Object element) => (element as ClassElement).isValidMixin |
| 173 element.isValidMixin ? 'a valid mixin' : 'an invalid mixin'); | 174 ? 'a valid mixin' |
| 175 : 'an invalid mixin'); |
| 174 } | 176 } |
| 175 _compareTypes('supertype', expected.supertype, actual.supertype); | 177 _compareTypes('supertype', expected.supertype, actual.supertype); |
| 176 _compareTypeLists('mixin', expected.mixins, actual.mixins); | 178 _compareTypeLists('mixin', expected.mixins, actual.mixins); |
| 177 _compareTypeLists('interface', expected.interfaces, actual.interfaces); | 179 _compareTypeLists('interface', expected.interfaces, actual.interfaces); |
| 178 // | 180 // |
| 179 // Compare children. | 181 // Compare children. |
| 180 // | 182 // |
| 181 _compareElementLists(expected.accessors, actual.accessors); | 183 _compareElementLists(expected.accessors, actual.accessors); |
| 182 _compareElementLists(expected.constructors, actual.constructors); | 184 _compareElementLists(expected.constructors, actual.constructors); |
| 183 _compareElementLists(expected.fields, actual.fields); | 185 _compareElementLists(expected.fields, actual.fields); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 203 void _compareConstructorElements( | 205 void _compareConstructorElements( |
| 204 ConstructorElement expected, ConstructorElement actual) { | 206 ConstructorElement expected, ConstructorElement actual) { |
| 205 _compareExecutableElements(expected, actual, 'constructor'); | 207 _compareExecutableElements(expected, actual, 'constructor'); |
| 206 // | 208 // |
| 207 // Compare attributes. | 209 // Compare attributes. |
| 208 // | 210 // |
| 209 if (expected.isConst != actual.isConst) { | 211 if (expected.isConst != actual.isConst) { |
| 210 _writeMismatch( | 212 _writeMismatch( |
| 211 expected, | 213 expected, |
| 212 actual, | 214 actual, |
| 213 (ConstructorElement element) => element.isConst | 215 (Object element) => (element as ConstructorElement).isConst |
| 214 ? 'a const constructor' | 216 ? 'a const constructor' |
| 215 : 'a non-const constructor'); | 217 : 'a non-const constructor'); |
| 216 } | 218 } |
| 217 if (expected.isFactory != actual.isFactory) { | 219 if (expected.isFactory != actual.isFactory) { |
| 218 _writeMismatch( | 220 _writeMismatch( |
| 219 expected, | 221 expected, |
| 220 actual, | 222 actual, |
| 221 (ConstructorElement element) => element.isFactory | 223 (Object element) => (element as ConstructorElement).isFactory |
| 222 ? 'a factory constructor' | 224 ? 'a factory constructor' |
| 223 : 'a non-factory constructor'); | 225 : 'a non-factory constructor'); |
| 224 } | 226 } |
| 225 if (expected.periodOffset != actual.periodOffset) { | 227 if (expected.periodOffset != actual.periodOffset) { |
| 226 _write('Expected a period offset of '); | 228 _write('Expected a period offset of '); |
| 227 _write(expected.periodOffset); | 229 _write(expected.periodOffset); |
| 228 _write('; found '); | 230 _write('; found '); |
| 229 _writeln(actual.periodOffset); | 231 _writeln(actual.periodOffset); |
| 230 } | 232 } |
| 231 if ((expected.redirectedConstructor == null) != | 233 if ((expected.redirectedConstructor == null) != |
| 232 (actual.redirectedConstructor == null)) { | 234 (actual.redirectedConstructor == null)) { |
| 233 _writeMismatch( | 235 _writeMismatch( |
| 234 expected, | 236 expected, |
| 235 actual, | 237 actual, |
| 236 (ConstructorElement element) => element.redirectedConstructor == null | 238 (Object element) => |
| 237 ? 'a redirecting constructor' | 239 (element as ConstructorElement).redirectedConstructor == null |
| 238 : 'a non-redirecting constructor'); | 240 ? 'a redirecting constructor' |
| 241 : 'a non-redirecting constructor'); |
| 239 } | 242 } |
| 240 } | 243 } |
| 241 | 244 |
| 242 void _compareElementLists(List expected, List actual) { | 245 void _compareElementLists(List expected, List actual) { |
| 243 Set<Element> extraElements = new HashSet<Element>(); | 246 Set<Element> extraElements = new HashSet<Element>(); |
| 244 Map<Element, Element> commonElements = new HashMap<Element, Element>(); | 247 Map<Element, Element> commonElements = new HashMap<Element, Element>(); |
| 245 | 248 |
| 246 Map<String, Element> expectedElements = new HashMap<String, Element>(); | 249 Map<String, Element> expectedElements = new HashMap<String, Element>(); |
| 247 for (Element expectedElement in expected) { | 250 for (Element expectedElement in expected) { |
| 248 expectedElements[expectedElement.name] = expectedElement; | 251 expectedElements[expectedElement.name] = expectedElement; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 void _compareExecutableElements( | 288 void _compareExecutableElements( |
| 286 ExecutableElement expected, ExecutableElement actual, String kind) { | 289 ExecutableElement expected, ExecutableElement actual, String kind) { |
| 287 _compareGenericElements(expected, actual); | 290 _compareGenericElements(expected, actual); |
| 288 // | 291 // |
| 289 // Compare attributes. | 292 // Compare attributes. |
| 290 // | 293 // |
| 291 if (expected.hasImplicitReturnType != actual.hasImplicitReturnType) { | 294 if (expected.hasImplicitReturnType != actual.hasImplicitReturnType) { |
| 292 _writeMismatch( | 295 _writeMismatch( |
| 293 expected, | 296 expected, |
| 294 actual, | 297 actual, |
| 295 (ExecutableElement element) => element.hasImplicitReturnType | 298 (Object element) => |
| 296 ? 'an implicit return type' | 299 (element as ExecutableElement).hasImplicitReturnType |
| 297 : 'an explicit return type'); | 300 ? 'an implicit return type' |
| 301 : 'an explicit return type'); |
| 298 } | 302 } |
| 299 if (expected.isAbstract != actual.isAbstract) { | 303 if (expected.isAbstract != actual.isAbstract) { |
| 300 _writeMismatch( | 304 _writeMismatch( |
| 301 expected, | 305 expected, |
| 302 actual, | 306 actual, |
| 303 (ExecutableElement element) => | 307 (Object element) => (element as ExecutableElement).isAbstract |
| 304 element.isAbstract ? 'an abstract $kind' : 'a concrete $kind'); | 308 ? 'an abstract $kind' |
| 309 : 'a concrete $kind'); |
| 305 } | 310 } |
| 306 if (expected.isAsynchronous != actual.isAsynchronous) { | 311 if (expected.isAsynchronous != actual.isAsynchronous) { |
| 307 _writeMismatch( | 312 _writeMismatch( |
| 308 expected, | 313 expected, |
| 309 actual, | 314 actual, |
| 310 (ExecutableElement element) => element.isAsynchronous | 315 (Object element) => (element as ExecutableElement).isAsynchronous |
| 311 ? 'an asynchronous $kind' | 316 ? 'an asynchronous $kind' |
| 312 : 'a synchronous $kind'); | 317 : 'a synchronous $kind'); |
| 313 } | 318 } |
| 314 if (expected.isExternal != actual.isExternal) { | 319 if (expected.isExternal != actual.isExternal) { |
| 315 _writeMismatch( | 320 _writeMismatch( |
| 316 expected, | 321 expected, |
| 317 actual, | 322 actual, |
| 318 (ExecutableElement element) => element.isExternal | 323 (Object element) => (element as ExecutableElement).isExternal |
| 319 ? 'an external $kind' | 324 ? 'an external $kind' |
| 320 : 'a non-external $kind'); | 325 : 'a non-external $kind'); |
| 321 } | 326 } |
| 322 if (expected.isGenerator != actual.isGenerator) { | 327 if (expected.isGenerator != actual.isGenerator) { |
| 323 _writeMismatch( | 328 _writeMismatch( |
| 324 expected, | 329 expected, |
| 325 actual, | 330 actual, |
| 326 (ExecutableElement element) => element.isGenerator | 331 (Object element) => (element as ExecutableElement).isGenerator |
| 327 ? 'a generator $kind' | 332 ? 'a generator $kind' |
| 328 : 'a non-generator $kind'); | 333 : 'a non-generator $kind'); |
| 329 } | 334 } |
| 330 if (expected.isOperator != actual.isOperator) { | 335 if (expected.isOperator != actual.isOperator) { |
| 331 _writeMismatch( | 336 _writeMismatch( |
| 332 expected, | 337 expected, |
| 333 actual, | 338 actual, |
| 334 (ExecutableElement element) => | 339 (Object element) => (element as ExecutableElement).isOperator |
| 335 element.isOperator ? 'an operator' : 'a non-operator $kind'); | 340 ? 'an operator' |
| 341 : 'a non-operator $kind'); |
| 336 } | 342 } |
| 337 if (expected.isStatic != actual.isStatic) { | 343 if (expected.isStatic != actual.isStatic) { |
| 338 _writeMismatch( | 344 _writeMismatch( |
| 339 expected, | 345 expected, |
| 340 actual, | 346 actual, |
| 341 (ExecutableElement element) => | 347 (Object element) => (element as ExecutableElement).isStatic |
| 342 element.isStatic ? 'a static $kind' : 'an instance $kind'); | 348 ? 'a static $kind' |
| 349 : 'an instance $kind'); |
| 343 } | 350 } |
| 344 if ((expected.returnType == null) != (actual.returnType == null)) { | 351 if ((expected.returnType == null) != (actual.returnType == null)) { |
| 345 _writeMismatch( | 352 _writeMismatch( |
| 346 expected, | 353 expected, |
| 347 actual, | 354 actual, |
| 348 (ExecutableElement element) => element.returnType == null | 355 (Object element) => (element as ExecutableElement).returnType == null |
| 349 ? 'a $kind with no return type' | 356 ? 'a $kind with no return type' |
| 350 : 'a $kind with a return type'); | 357 : 'a $kind with a return type'); |
| 351 } else { | 358 } else { |
| 352 _compareTypes('return type', expected.returnType, actual.returnType); | 359 _compareTypes('return type', expected.returnType, actual.returnType); |
| 353 } | 360 } |
| 354 // | 361 // |
| 355 // Compare children. | 362 // Compare children. |
| 356 // | 363 // |
| 357 _compareElementLists(expected.functions, actual.functions); | 364 _compareElementLists(expected.functions, actual.functions); |
| 358 _compareElementLists(expected.labels, actual.labels); | 365 _compareElementLists(expected.labels, actual.labels); |
| 359 _compareElementLists(expected.localVariables, actual.localVariables); | 366 _compareElementLists(expected.localVariables, actual.localVariables); |
| 360 _compareElementLists(expected.parameters, actual.parameters); | 367 _compareElementLists(expected.parameters, actual.parameters); |
| 361 _compareElementLists(expected.typeParameters, actual.typeParameters); | 368 _compareElementLists(expected.typeParameters, actual.typeParameters); |
| 362 } | 369 } |
| 363 | 370 |
| 364 void _compareExportElements(ExportElement expected, ExportElement actual) { | 371 void _compareExportElements(ExportElement expected, ExportElement actual) { |
| 365 _compareUriReferencedElements(expected, actual); | 372 _compareUriReferencedElements(expected, actual); |
| 366 // | 373 // |
| 367 // Compare attributes. | 374 // Compare attributes. |
| 368 // | 375 // |
| 369 if ((expected.exportedLibrary == null) != | 376 if ((expected.exportedLibrary == null) != |
| 370 (actual.exportedLibrary == null)) { | 377 (actual.exportedLibrary == null)) { |
| 371 // TODO(brianwilkerson) Check for more than existence? | 378 // TODO(brianwilkerson) Check for more than existence? |
| 372 _writeMismatch( | 379 _writeMismatch(expected, actual, (Object element) { |
| 373 expected, | 380 ExportElement exportElement = element as ExportElement; |
| 374 actual, | 381 return exportElement.exportedLibrary == null |
| 375 (ExportElement element) => element.exportedLibrary == null | 382 ? 'unresolved uri' |
| 376 ? 'unresolved uri' | 383 : 'uri resolved to ${exportElement.exportedLibrary.source.fullName}'
; |
| 377 : 'uri resolved to ${element.exportedLibrary.source.fullName}'); | 384 }); |
| 378 } | 385 } |
| 379 // | 386 // |
| 380 // Compare children. | 387 // Compare children. |
| 381 // | 388 // |
| 382 _compareElementLists(expected.combinators, actual.combinators); | 389 _compareElementLists(expected.combinators, actual.combinators); |
| 383 } | 390 } |
| 384 | 391 |
| 385 void _compareFieldElements(FieldElement expected, FieldElement actual) { | 392 void _compareFieldElements(FieldElement expected, FieldElement actual) { |
| 386 _comparePropertyInducingElements(expected, actual, 'field'); | 393 _comparePropertyInducingElements(expected, actual, 'field'); |
| 387 // | 394 // |
| 388 // Compare attributes. | 395 // Compare attributes. |
| 389 // | 396 // |
| 390 if (expected.isEnumConstant != actual.isEnumConstant) { | 397 if (expected.isEnumConstant != actual.isEnumConstant) { |
| 391 _writeMismatch( | 398 _writeMismatch( |
| 392 expected, | 399 expected, |
| 393 actual, | 400 actual, |
| 394 (FieldElement element) => | 401 (Object element) => (element as FieldElement).isEnumConstant |
| 395 element.isEnumConstant ? 'an enum constant' : 'a normal field'); | 402 ? 'an enum constant' |
| 403 : 'a normal field'); |
| 396 } | 404 } |
| 397 } | 405 } |
| 398 | 406 |
| 399 void _compareFieldFormalParameterElements( | 407 void _compareFieldFormalParameterElements( |
| 400 FieldFormalParameterElement expected, | 408 FieldFormalParameterElement expected, |
| 401 FieldFormalParameterElement actual) { | 409 FieldFormalParameterElement actual) { |
| 402 // TODO(brianwilkerson) Implement this | 410 // TODO(brianwilkerson) Implement this |
| 403 _compareGenericElements(expected, actual); | 411 _compareGenericElements(expected, actual); |
| 404 } | 412 } |
| 405 | 413 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 436 | 444 |
| 437 void _compareImportElements(ImportElement expected, ImportElement actual) { | 445 void _compareImportElements(ImportElement expected, ImportElement actual) { |
| 438 _compareUriReferencedElements(expected, actual); | 446 _compareUriReferencedElements(expected, actual); |
| 439 // | 447 // |
| 440 // Compare attributes. | 448 // Compare attributes. |
| 441 // | 449 // |
| 442 if (expected.isDeferred != actual.isDeferred) { | 450 if (expected.isDeferred != actual.isDeferred) { |
| 443 _writeMismatch( | 451 _writeMismatch( |
| 444 expected, | 452 expected, |
| 445 actual, | 453 actual, |
| 446 (ImportElement element) => element.isDeferred | 454 (Object element) => (element as ImportElement).isDeferred |
| 447 ? 'a deferred import' | 455 ? 'a deferred import' |
| 448 : 'a non-deferred import'); | 456 : 'a non-deferred import'); |
| 449 } | 457 } |
| 450 if ((expected.importedLibrary == null) != | 458 if ((expected.importedLibrary == null) != |
| 451 (actual.importedLibrary == null)) { | 459 (actual.importedLibrary == null)) { |
| 452 _writeMismatch( | 460 _writeMismatch(expected, actual, (Object element) { |
| 453 expected, | 461 ImportElement importElement = element as ImportElement; |
| 454 actual, | 462 return importElement.importedLibrary == null |
| 455 (ImportElement element) => element.importedLibrary == null | 463 ? 'unresolved uri' |
| 456 ? 'unresolved uri' | 464 : 'uri resolved to ${importElement.importedLibrary.source.fullName}'
; |
| 457 : 'uri resolved to ${element.importedLibrary.source.fullName}'); | 465 }); |
| 458 } | 466 } |
| 459 if ((expected.prefix == null) != (actual.prefix == null)) { | 467 if ((expected.prefix == null) != (actual.prefix == null)) { |
| 460 _writeMismatch( | 468 _writeMismatch(expected, actual, (Object element) { |
| 461 expected, | 469 ImportElement importElement = element as ImportElement; |
| 462 actual, | 470 return importElement.prefix == null |
| 463 (ImportElement element) => element.prefix == null | 471 ? 'no prefix' |
| 464 ? 'no prefix' | 472 : 'a prefix named ${importElement.prefix.name}'; |
| 465 : 'a prefix named ${element.prefix.name}'); | 473 }); |
| 466 } | 474 } |
| 467 if (expected.prefixOffset != actual.prefixOffset) { | 475 if (expected.prefixOffset != actual.prefixOffset) { |
| 468 _write('Expected a prefix offset of '); | 476 _write('Expected a prefix offset of '); |
| 469 _write(expected.prefixOffset); | 477 _write(expected.prefixOffset); |
| 470 _write('; found '); | 478 _write('; found '); |
| 471 _writeln(actual.prefixOffset); | 479 _writeln(actual.prefixOffset); |
| 472 } | 480 } |
| 473 // | 481 // |
| 474 // Compare children. | 482 // Compare children. |
| 475 // | 483 // |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 void _compareMethodElements(MethodElement expected, MethodElement actual) { | 520 void _compareMethodElements(MethodElement expected, MethodElement actual) { |
| 513 // TODO(brianwilkerson) Implement this | 521 // TODO(brianwilkerson) Implement this |
| 514 _compareExecutableElements(expected, actual, 'method'); | 522 _compareExecutableElements(expected, actual, 'method'); |
| 515 // | 523 // |
| 516 // Compare attributes. | 524 // Compare attributes. |
| 517 // | 525 // |
| 518 if (expected.isStatic != actual.isStatic) { | 526 if (expected.isStatic != actual.isStatic) { |
| 519 _writeMismatch( | 527 _writeMismatch( |
| 520 expected, | 528 expected, |
| 521 actual, | 529 actual, |
| 522 (FieldElement element) => | 530 (Object element) => (element as FieldElement).isStatic |
| 523 element.isStatic ? 'a static field' : 'an instance field'); | 531 ? 'a static field' |
| 532 : 'an instance field'); |
| 524 } | 533 } |
| 525 } | 534 } |
| 526 | 535 |
| 527 void _compareMultiplyDefinedElements( | 536 void _compareMultiplyDefinedElements( |
| 528 MultiplyDefinedElement expected, MultiplyDefinedElement actual) { | 537 MultiplyDefinedElement expected, MultiplyDefinedElement actual) { |
| 529 // TODO(brianwilkerson) Implement this | 538 // TODO(brianwilkerson) Implement this |
| 530 } | 539 } |
| 531 | 540 |
| 532 void _compareParameterElements( | 541 void _compareParameterElements( |
| 533 ParameterElement expected, ParameterElement actual) { | 542 ParameterElement expected, ParameterElement actual) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 VariableElement expected, VariableElement actual, String kind) { | 685 VariableElement expected, VariableElement actual, String kind) { |
| 677 _compareGenericElements(expected, actual); | 686 _compareGenericElements(expected, actual); |
| 678 // | 687 // |
| 679 // Compare attributes. | 688 // Compare attributes. |
| 680 // | 689 // |
| 681 if ((expected.constantValue == null) != (actual.constantValue == null)) { | 690 if ((expected.constantValue == null) != (actual.constantValue == null)) { |
| 682 // TODO(brianwilkerson) Check for more than existence. | 691 // TODO(brianwilkerson) Check for more than existence. |
| 683 _writeMismatch( | 692 _writeMismatch( |
| 684 expected, | 693 expected, |
| 685 actual, | 694 actual, |
| 686 (VariableElement element) => element.constantValue == null | 695 (Object element) => (element as VariableElement).constantValue == null |
| 687 ? 'a $kind with no constant value' | 696 ? 'a $kind with no constant value' |
| 688 : 'a $kind with a constant value'); | 697 : 'a $kind with a constant value'); |
| 689 } | 698 } |
| 690 if (expected.hasImplicitType != actual.hasImplicitType) { | 699 if (expected.hasImplicitType != actual.hasImplicitType) { |
| 691 _writeMismatch( | 700 _writeMismatch( |
| 692 expected, | 701 expected, |
| 693 actual, | 702 actual, |
| 694 (VariableElement element) => element.hasImplicitType | 703 (Object element) => (element as VariableElement).hasImplicitType |
| 695 ? 'a $kind with an implicit type' | 704 ? 'a $kind with an implicit type' |
| 696 : 'a $kind with an explicit type'); | 705 : 'a $kind with an explicit type'); |
| 697 } | 706 } |
| 698 if (expected.isConst != actual.isConst) { | 707 if (expected.isConst != actual.isConst) { |
| 699 _writeMismatch( | 708 _writeMismatch( |
| 700 expected, | 709 expected, |
| 701 actual, | 710 actual, |
| 702 (VariableElement element) => | 711 (Object element) => (element as VariableElement).isConst |
| 703 element.isConst ? 'a const $kind' : 'a non-const $kind'); | 712 ? 'a const $kind' |
| 713 : 'a non-const $kind'); |
| 704 } | 714 } |
| 705 if (expected.isFinal != actual.isFinal) { | 715 if (expected.isFinal != actual.isFinal) { |
| 706 _writeMismatch( | 716 _writeMismatch( |
| 707 expected, | 717 expected, |
| 708 actual, | 718 actual, |
| 709 (VariableElement element) => | 719 (Object element) => (element as VariableElement).isFinal |
| 710 element.isFinal ? 'a final $kind' : 'a non-final $kind'); | 720 ? 'a final $kind' |
| 721 : 'a non-final $kind'); |
| 711 } | 722 } |
| 712 if (expected.isStatic != actual.isStatic) { | 723 if (expected.isStatic != actual.isStatic) { |
| 713 _writeMismatch( | 724 _writeMismatch( |
| 714 expected, | 725 expected, |
| 715 actual, | 726 actual, |
| 716 (VariableElement element) => | 727 (Object element) => (element as VariableElement).isStatic |
| 717 element.isStatic ? 'a static $kind' : 'an instance $kind'); | 728 ? 'a static $kind' |
| 729 : 'an instance $kind'); |
| 718 } | 730 } |
| 719 // | 731 // |
| 720 // Compare children. | 732 // Compare children. |
| 721 // | 733 // |
| 722 compareElements(expected.initializer, actual.initializer); | 734 compareElements(expected.initializer, actual.initializer); |
| 723 } | 735 } |
| 724 | 736 |
| 725 void _write(Object value) { | 737 void _write(Object value) { |
| 726 if (_needsLineBreak) { | 738 if (_needsLineBreak) { |
| 727 _buffer.write('</p><p>'); | 739 _buffer.write('</p><p>'); |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 * Determine whether or not there is any interesting difference between the | 1773 * Determine whether or not there is any interesting difference between the |
| 1762 * original and cloned values. | 1774 * original and cloned values. |
| 1763 */ | 1775 */ |
| 1764 void _performComparison() { | 1776 void _performComparison() { |
| 1765 StringBuffer buffer = new StringBuffer(); | 1777 StringBuffer buffer = new StringBuffer(); |
| 1766 if (!_compareObjects(cloneValue, originalValue, buffer)) { | 1778 if (!_compareObjects(cloneValue, originalValue, buffer)) { |
| 1767 description = buffer.toString(); | 1779 description = buffer.toString(); |
| 1768 } | 1780 } |
| 1769 } | 1781 } |
| 1770 } | 1782 } |
| OLD | NEW |