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

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

Issue 1816583002: Issue 26034#3. Fix for indexing references to synthetic fields. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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) 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/token.dart'; 6 import 'package:analyzer/dart/ast/token.dart';
7 import 'package:analyzer/dart/ast/visitor.dart'; 7 import 'package:analyzer/dart/ast/visitor.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/element/member.dart'; 10 import 'package:analyzer/src/dart/element/member.dart';
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 */ 200 */
201 static ElementInfo newElementInfo(int unitId, Element element) { 201 static ElementInfo newElementInfo(int unitId, Element element) {
202 IndexSyntheticElementKind kind = IndexSyntheticElementKind.notSynthetic; 202 IndexSyntheticElementKind kind = IndexSyntheticElementKind.notSynthetic;
203 if (element.isSynthetic) { 203 if (element.isSynthetic) {
204 if (element is ConstructorElement) { 204 if (element is ConstructorElement) {
205 kind = IndexSyntheticElementKind.constructor; 205 kind = IndexSyntheticElementKind.constructor;
206 element = element.enclosingElement; 206 element = element.enclosingElement;
207 } else if (element is FunctionElement && element.name == 'loadLibrary') { 207 } else if (element is FunctionElement && element.name == 'loadLibrary') {
208 kind = IndexSyntheticElementKind.loadLibrary; 208 kind = IndexSyntheticElementKind.loadLibrary;
209 element = element.library; 209 element = element.library;
210 } else if (element is FieldElement) {
211 FieldElement field = element;
212 kind = IndexSyntheticElementKind.field;
213 element = field.getter;
214 element ??= field.setter;
210 } else if (element is PropertyAccessorElement) { 215 } else if (element is PropertyAccessorElement) {
211 PropertyAccessorElement accessor = element; 216 PropertyAccessorElement accessor = element;
212 Element enclosing = element.enclosingElement; 217 Element enclosing = element.enclosingElement;
213 bool isEnumGetter = enclosing is ClassElement && enclosing.isEnum; 218 bool isEnumGetter = enclosing is ClassElement && enclosing.isEnum;
214 if (isEnumGetter && accessor.name == 'index') { 219 if (isEnumGetter && accessor.name == 'index') {
215 kind = IndexSyntheticElementKind.enumIndex; 220 kind = IndexSyntheticElementKind.enumIndex;
216 element = enclosing; 221 element = enclosing;
217 } else if (isEnumGetter && accessor.name == 'values') { 222 } else if (isEnumGetter && accessor.name == 'values') {
218 kind = IndexSyntheticElementKind.enumValues; 223 kind = IndexSyntheticElementKind.enumValues;
219 element = enclosing; 224 element = enclosing;
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 usedNameOffsets: nameRelations.map((r) => r.offset).toList(), 805 usedNameOffsets: nameRelations.map((r) => r.offset).toList(),
801 usedNameIsQualifiedFlags: 806 usedNameIsQualifiedFlags:
802 nameRelations.map((r) => r.isQualified).toList()); 807 nameRelations.map((r) => r.isQualified).toList());
803 } 808 }
804 809
805 void defineName(String name, IndexNameKind kind, int offset) { 810 void defineName(String name, IndexNameKind kind, int offset) {
806 _StringInfo nameInfo = pkg._getStringInfo(name); 811 _StringInfo nameInfo = pkg._getStringInfo(name);
807 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset)); 812 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset));
808 } 813 }
809 } 814 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/test/src/summary/index_unit_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698