| 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 computer.highlights2; | 5 library computer.highlights2; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 11 import 'package:analyzer/dart/ast/visitor.dart'; |
| 11 import 'package:analyzer/dart/element/element.dart'; | 12 import 'package:analyzer/dart/element/element.dart'; |
| 12 import 'package:analyzer/dart/element/type.dart'; | 13 import 'package:analyzer/dart/element/type.dart'; |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * A computer for [HighlightRegion]s in a Dart [CompilationUnit]. | 16 * A computer for [HighlightRegion]s in a Dart [CompilationUnit]. |
| 16 */ | 17 */ |
| 17 class DartUnitHighlightsComputer2 { | 18 class DartUnitHighlightsComputer2 { |
| 18 final CompilationUnit _unit; | 19 final CompilationUnit _unit; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 Token a, Token b, HighlightRegionType type) { | 422 Token a, Token b, HighlightRegionType type) { |
| 422 int offset = a.offset; | 423 int offset = a.offset; |
| 423 int end = b.end; | 424 int end = b.end; |
| 424 _addRegion(offset, end - offset, type); | 425 _addRegion(offset, end - offset, type); |
| 425 } | 426 } |
| 426 | 427 |
| 427 static bool _isDynamicExpression(Expression e) { | 428 static bool _isDynamicExpression(Expression e) { |
| 428 if (e is SimpleIdentifier && e.staticElement is PrefixElement) { | 429 if (e is SimpleIdentifier && e.staticElement is PrefixElement) { |
| 429 return false; | 430 return false; |
| 430 } | 431 } |
| 431 return e.bestType.isDynamic; | 432 return resolutionMap.bestTypeForExpression(e).isDynamic; |
| 432 } | 433 } |
| 433 } | 434 } |
| 434 | 435 |
| 435 /** | 436 /** |
| 436 * An AST visitor for [DartUnitHighlightsComputer2]. | 437 * An AST visitor for [DartUnitHighlightsComputer2]. |
| 437 */ | 438 */ |
| 438 class _DartUnitHighlightsComputerVisitor2 extends RecursiveAstVisitor<Object> { | 439 class _DartUnitHighlightsComputerVisitor2 extends RecursiveAstVisitor<Object> { |
| 439 final DartUnitHighlightsComputer2 computer; | 440 final DartUnitHighlightsComputer2 computer; |
| 440 | 441 |
| 441 _DartUnitHighlightsComputerVisitor2(this.computer); | 442 _DartUnitHighlightsComputerVisitor2(this.computer); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 void _addRegions_functionBody(FunctionBody node) { | 814 void _addRegions_functionBody(FunctionBody node) { |
| 814 Token keyword = node.keyword; | 815 Token keyword = node.keyword; |
| 815 if (keyword != null) { | 816 if (keyword != null) { |
| 816 Token star = node.star; | 817 Token star = node.star; |
| 817 int offset = keyword.offset; | 818 int offset = keyword.offset; |
| 818 int end = star != null ? star.end : keyword.end; | 819 int end = star != null ? star.end : keyword.end; |
| 819 computer._addRegion(offset, end - offset, HighlightRegionType.BUILT_IN); | 820 computer._addRegion(offset, end - offset, HighlightRegionType.BUILT_IN); |
| 820 } | 821 } |
| 821 } | 822 } |
| 822 } | 823 } |
| OLD | NEW |