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

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

Issue 1897843003: Support for extract property for methods. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 3133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3144 3144
3145 @override 3145 @override
3146 ConstructorElementForLink get asConstructor => null; 3146 ConstructorElementForLink get asConstructor => null;
3147 3147
3148 @override 3148 @override
3149 ConstVariableNode get asConstVariable => _constNode; 3149 ConstVariableNode get asConstVariable => _constNode;
3150 3150
3151 @override 3151 @override
3152 DartType get asStaticType { 3152 DartType get asStaticType {
3153 Element element = this.element; 3153 Element element = this.element;
3154 if (element is PropertyAccessorElement && element.isGetter) { 3154 if (element is PropertyAccessorElement) {
3155 return element.returnType; 3155 if (element.isGetter) {
3156 return element.returnType;
3157 }
3158 return DynamicTypeImpl.instance;
3156 } 3159 }
3157 // TODO(paulberry): implement. 3160 if (element is MethodElement) {
3161 return element.type;
3162 }
3158 return DynamicTypeImpl.instance; 3163 return DynamicTypeImpl.instance;
3159 } 3164 }
3160 3165
3161 @override 3166 @override
3162 TypeInferenceNode get asTypeInferenceNode { 3167 TypeInferenceNode get asTypeInferenceNode {
3163 // TODO(paulberry): implement. 3168 // TODO(paulberry): implement.
3164 return null; 3169 return null;
3165 } 3170 }
3166 3171
3167 @override 3172 @override
3168 DartType buildType(DartType getTypeArgument(int i), 3173 DartType buildType(DartType getTypeArgument(int i),
3169 List<int> implicitFunctionTypeIndices) => 3174 List<int> implicitFunctionTypeIndices) =>
3170 DynamicTypeImpl.instance; 3175 DynamicTypeImpl.instance;
3171 3176
3172 @override 3177 @override
3173 ReferenceableElementForLink getContainedName(String name) { 3178 ReferenceableElementForLink getContainedName(String name) {
3174 if (element != null) { 3179 if (element != null) {
3175 DartType type = asStaticType; 3180 DartType type = asStaticType;
3176 if (type is InterfaceType) { 3181 if (type is InterfaceType) {
3177 Element nameElement = type.lookUpGetter(name, element.library); 3182 Element nameElement = type.lookUpGetter(name, element.library);
3183 nameElement ??= type.lookUpMethod(name, element.library);
3178 return new NonstaticMemberElementForLink(nameElement, _constNode); 3184 return new NonstaticMemberElementForLink(nameElement, _constNode);
3179 } 3185 }
3180 } 3186 }
3181 return this; 3187 return this;
3182 } 3188 }
3183 } 3189 }
3184 3190
3185 /** 3191 /**
3186 * Element representing a function or method parameter resynthesized 3192 * Element representing a function or method parameter resynthesized
3187 * from a summary during linking. 3193 * from a summary during linking.
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
4162 /** 4168 /**
4163 * Return the contained element with the given [name], or `null` if the lookup 4169 * Return the contained element with the given [name], or `null` if the lookup
4164 * fails. Currently only static types are supported in the linker, so lookup 4170 * fails. Currently only static types are supported in the linker, so lookup
4165 * is performed only in the strong mode. 4171 * is performed only in the strong mode.
4166 */ 4172 */
4167 Element _getContainedElement(String name) { 4173 Element _getContainedElement(String name) {
4168 Linker linker = compilationUnit.library._linker; 4174 Linker linker = compilationUnit.library._linker;
4169 if (linker.strongMode) { 4175 if (linker.strongMode) {
4170 DartType type = asStaticType; 4176 DartType type = asStaticType;
4171 if (type is InterfaceType) { 4177 if (type is InterfaceType) {
4172 return type.lookUpGetter(name, compilationUnit.library); 4178 Element result = type.lookUpGetter(name, compilationUnit.library);
4179 result ??= type.lookUpMethod(name, compilationUnit.library);
4180 return result;
4173 } 4181 }
4174 } 4182 }
4175 // TODO(scheglov): implement for propagated types 4183 // TODO(scheglov): implement for propagated types
4176 return null; 4184 return null;
4177 } 4185 }
4178 } 4186 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698