Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: pkg/analyzer/lib/src/dart/element/builder.dart

Issue 1690783002: Set visible ranges for local variables/functions to the ranges of enclosing blocks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 analyzer.src.dart.element.builder; 5 library analyzer.src.dart.element.builder;
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/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 element.typeParameters = holder.typeParameters; 688 element.typeParameters = holder.typeParameters;
689 if (body.isAsynchronous) { 689 if (body.isAsynchronous) {
690 element.asynchronous = true; 690 element.asynchronous = true;
691 } 691 }
692 if (body.isGenerator) { 692 if (body.isGenerator) {
693 element.generator = true; 693 element.generator = true;
694 } 694 }
695 if (_inFunction) { 695 if (_inFunction) {
696 Block enclosingBlock = node.getAncestor((node) => node is Block); 696 Block enclosingBlock = node.getAncestor((node) => node is Block);
697 if (enclosingBlock != null) { 697 if (enclosingBlock != null) {
698 int functionEnd = node.offset + node.length; 698 element.setVisibleRange(enclosingBlock.offset, enclosingBlock.length );
699 int blockEnd = enclosingBlock.offset + enclosingBlock.length;
700 element.setVisibleRange(functionEnd, blockEnd - functionEnd - 1);
701 } 699 }
702 } 700 }
703 if (node.returnType == null) { 701 if (node.returnType == null) {
704 element.hasImplicitReturnType = true; 702 element.hasImplicitReturnType = true;
705 } 703 }
706 _currentHolder.addFunction(element); 704 _currentHolder.addFunction(element);
707 expression.element = element; 705 expression.element = element;
708 functionName.staticElement = element; 706 functionName.staticElement = element;
709 } else { 707 } else {
710 SimpleIdentifier propertyNameNode = node.name; 708 SimpleIdentifier propertyNameNode = node.name;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 element.typeParameters = holder.typeParameters; 807 element.typeParameters = holder.typeParameters;
810 if (body.isAsynchronous) { 808 if (body.isAsynchronous) {
811 element.asynchronous = true; 809 element.asynchronous = true;
812 } 810 }
813 if (body.isGenerator) { 811 if (body.isGenerator) {
814 element.generator = true; 812 element.generator = true;
815 } 813 }
816 if (_inFunction) { 814 if (_inFunction) {
817 Block enclosingBlock = node.getAncestor((node) => node is Block); 815 Block enclosingBlock = node.getAncestor((node) => node is Block);
818 if (enclosingBlock != null) { 816 if (enclosingBlock != null) {
819 int functionEnd = node.offset + node.length; 817 element.setVisibleRange(enclosingBlock.offset, enclosingBlock.length);
820 int blockEnd = enclosingBlock.offset + enclosingBlock.length;
821 element.setVisibleRange(functionEnd, blockEnd - functionEnd - 1);
822 } 818 }
823 } 819 }
824 if (_functionTypesToFix != null) { 820 if (_functionTypesToFix != null) {
825 _functionTypesToFix.add(element); 821 _functionTypesToFix.add(element);
826 } else { 822 } else {
827 element.type = new FunctionTypeImpl(element); 823 element.type = new FunctionTypeImpl(element);
828 } 824 }
829 element.hasImplicitReturnType = true; 825 element.hasImplicitReturnType = true;
830 _currentHolder.addFunction(element); 826 _currentHolder.addFunction(element);
831 node.element = element; 827 node.element = element;
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 return null; 1451 return null;
1456 } 1452 }
1457 1453
1458 /** 1454 /**
1459 * Return the lexical identifiers associated with the given [identifiers]. 1455 * Return the lexical identifiers associated with the given [identifiers].
1460 */ 1456 */
1461 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { 1457 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) {
1462 return identifiers.map((identifier) => identifier.name).toList(); 1458 return identifiers.map((identifier) => identifier.name).toList();
1463 } 1459 }
1464 } 1460 }
OLDNEW
« pkg/analyzer/lib/dart/element/element.dart ('K') | « pkg/analyzer/lib/dart/element/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698