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

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 2966313002: Remove ExecutableElement.localVariables altogether. (Closed)
Patch Set: Created 3 years, 5 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) 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 summary_resynthesizer; 5 library summary_resynthesizer;
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/standard_ast_factory.dart'; 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 819 }
820 820
821 @override 821 @override
822 AnalysisContext get context => enclosingElement.context; 822 AnalysisContext get context => enclosingElement.context;
823 823
824 @override 824 @override
825 ElementLocation get location => actualElement.location; 825 ElementLocation get location => actualElement.location;
826 } 826 }
827 827
828 /** 828 /**
829 * Local variable element that has been resynthesized from a summary. The
830 * actual element won't be constructed until it is requested. But properties
831 * [context] and [enclosingElement] can be used without creating the actual
832 * element.
833 */
834 class _DeferredLocalVariableElement extends LocalVariableElementHandle {
835 /**
836 * The executable element containing this element.
837 */
838 @override
839 final ExecutableElement enclosingElement;
840
841 /**
842 * The index of this variable within [ExecutableElement.localVariables].
843 */
844 final int _localIndex;
845
846 _DeferredLocalVariableElement(this.enclosingElement, this._localIndex)
847 : super(null, null);
848
849 @override
850 LocalVariableElement get actualElement =>
851 enclosingElement.localVariables[_localIndex];
852
853 @override
854 AnalysisContext get context => enclosingElement.context;
855
856 @override
857 ElementLocation get location => actualElement.location;
858 }
859
860 /**
861 * An instance of [_LibraryResynthesizer] is responsible for resynthesizing the 829 * An instance of [_LibraryResynthesizer] is responsible for resynthesizing the
862 * elements in a single library from that library's summary. 830 * elements in a single library from that library's summary.
863 */ 831 */
864 class _LibraryResynthesizer { 832 class _LibraryResynthesizer {
865 /** 833 /**
866 * The [SummaryResynthesizer] which is being used to obtain summaries. 834 * The [SummaryResynthesizer] which is being used to obtain summaries.
867 */ 835 */
868 final SummaryResynthesizer summaryResynthesizer; 836 final SummaryResynthesizer summaryResynthesizer;
869 837
870 /** 838 /**
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 case ReferenceKind.typedef: 1851 case ReferenceKind.typedef:
1884 element = new FunctionTypeAliasElementHandle( 1852 element = new FunctionTypeAliasElementHandle(
1885 summaryResynthesizer, location); 1853 summaryResynthesizer, location);
1886 isDeclarableType = true; 1854 isDeclarableType = true;
1887 break; 1855 break;
1888 case ReferenceKind.genericFunctionTypedef: 1856 case ReferenceKind.genericFunctionTypedef:
1889 element = new GenericTypeAliasElementHandle( 1857 element = new GenericTypeAliasElementHandle(
1890 summaryResynthesizer, location); 1858 summaryResynthesizer, location);
1891 isDeclarableType = true; 1859 isDeclarableType = true;
1892 break; 1860 break;
1893 case ReferenceKind.variable:
1894 Element enclosingElement = enclosingInfo.element;
1895 if (enclosingElement is ExecutableElement) {
1896 element = new _DeferredLocalVariableElement(
1897 enclosingElement, linkedReference.localIndex);
1898 } else {
1899 throw new StateError('Unexpected element enclosing variable:'
1900 ' ${enclosingElement.runtimeType}');
1901 }
1902 break;
1903 case ReferenceKind.function: 1861 case ReferenceKind.function:
1904 Element enclosingElement = enclosingInfo.element; 1862 Element enclosingElement = enclosingInfo.element;
1905 if (enclosingElement is VariableElement) { 1863 if (enclosingElement is VariableElement) {
1906 element = new _DeferredInitializerElement(enclosingElement); 1864 element = new _DeferredInitializerElement(enclosingElement);
1907 } else if (enclosingElement is ExecutableElement) { 1865 } else if (enclosingElement is ExecutableElement) {
1908 element = new _DeferredLocalFunctionElement( 1866 element = new _DeferredLocalFunctionElement(
1909 enclosingElement, linkedReference.localIndex); 1867 enclosingElement, linkedReference.localIndex);
1910 } else { 1868 } else {
1911 throw new StateError('Unexpected element enclosing function:' 1869 throw new StateError('Unexpected element enclosing function:'
1912 ' ${enclosingElement.runtimeType}'); 1870 ' ${enclosingElement.runtimeType}');
1913 } 1871 }
1914 break; 1872 break;
1915 case ReferenceKind.prefix: 1873 case ReferenceKind.prefix:
1916 element = new PrefixElementHandle(summaryResynthesizer, location); 1874 element = new PrefixElementHandle(summaryResynthesizer, location);
1917 break; 1875 break;
1876 case ReferenceKind.variable:
1918 case ReferenceKind.unresolved: 1877 case ReferenceKind.unresolved:
1919 break; 1878 break;
1920 } 1879 }
1921 } 1880 }
1922 result = new _ReferenceInfo(libraryResynthesizer, enclosingInfo, name, 1881 result = new _ReferenceInfo(libraryResynthesizer, enclosingInfo, name,
1923 isDeclarableType, element, type, numTypeParameters); 1882 isDeclarableType, element, type, numTypeParameters);
1924 referenceInfos[index] = result; 1883 referenceInfos[index] = result;
1925 } 1884 }
1926 return result; 1885 return result;
1927 } 1886 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 static String _getElementIdentifier(String name, ReferenceKind kind) { 1971 static String _getElementIdentifier(String name, ReferenceKind kind) {
2013 if (kind == ReferenceKind.topLevelPropertyAccessor || 1972 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2014 kind == ReferenceKind.propertyAccessor) { 1973 kind == ReferenceKind.propertyAccessor) {
2015 if (!name.endsWith('=')) { 1974 if (!name.endsWith('=')) {
2016 return name + '?'; 1975 return name + '?';
2017 } 1976 }
2018 } 1977 }
2019 return name; 1978 return name;
2020 } 1979 }
2021 } 1980 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/declaration_resolver.dart ('k') | pkg/analyzer/test/dart/element/builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698