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

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

Issue 2235373003: Fix summary handling of unresolved imports, exports, and parts. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Simplify `allowMissingFiles` Created 4 years, 4 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';
11 import 'package:analyzer/src/generated/utilities_dart.dart'; 11 import 'package:analyzer/src/generated/utilities_dart.dart';
12 import 'package:analyzer/src/summary/format.dart'; 12 import 'package:analyzer/src/summary/format.dart';
13 import 'package:analyzer/src/summary/idl.dart'; 13 import 'package:analyzer/src/summary/idl.dart';
14 14
15 /** 15 /**
16 * Information about an element that is actually put into index for some other 16 * Information about an element that is actually put into index for some other
17 * related element. For example for a synthetic getter this is the corresponding 17 * related element. For example for a synthetic getter this is the corresponding
18 * non-synthetic field and [IndexSyntheticElementKind.getter] as the [kind]. 18 * non-synthetic field and [IndexSyntheticElementKind.getter] as the [kind].
19 */ 19 */
20 class IndexElementInfo { 20 class IndexElementInfo {
21 final Element element; 21 final Element element;
22 final IndexSyntheticElementKind kind; 22 final IndexSyntheticElementKind kind;
23 23
24 factory IndexElementInfo(Element element) { 24 factory IndexElementInfo(Element element) {
25 IndexSyntheticElementKind kind = IndexSyntheticElementKind.notSynthetic; 25 IndexSyntheticElementKind kind = IndexSyntheticElementKind.notSynthetic;
26 if (element.isSynthetic) { 26 if (element is LibraryElement || element is CompilationUnitElement) {
27 kind = IndexSyntheticElementKind.unit;
28 } else if (element.isSynthetic) {
27 if (element is ConstructorElement) { 29 if (element is ConstructorElement) {
28 kind = IndexSyntheticElementKind.constructor; 30 kind = IndexSyntheticElementKind.constructor;
29 element = element.enclosingElement; 31 element = element.enclosingElement;
30 } else if (element is FunctionElement && element.name == 'loadLibrary') { 32 } else if (element is FunctionElement && element.name == 'loadLibrary') {
31 kind = IndexSyntheticElementKind.loadLibrary; 33 kind = IndexSyntheticElementKind.loadLibrary;
32 element = element.library; 34 element = element.library;
33 } else if (element is FieldElement) { 35 } else if (element is FieldElement) {
34 FieldElement field = element; 36 FieldElement field = element;
35 kind = IndexSyntheticElementKind.field; 37 kind = IndexSyntheticElementKind.field;
36 element = field.getter; 38 element = field.getter;
(...skipping 16 matching lines...) Expand all
53 } 55 }
54 } else if (element is TopLevelVariableElement) { 56 } else if (element is TopLevelVariableElement) {
55 TopLevelVariableElement property = element; 57 TopLevelVariableElement property = element;
56 kind = IndexSyntheticElementKind.topLevelVariable; 58 kind = IndexSyntheticElementKind.topLevelVariable;
57 element = property.getter; 59 element = property.getter;
58 element ??= property.setter; 60 element ??= property.setter;
59 } else { 61 } else {
60 throw new ArgumentError( 62 throw new ArgumentError(
61 'Unsupported synthetic element ${element.runtimeType}'); 63 'Unsupported synthetic element ${element.runtimeType}');
62 } 64 }
63 } else if (element is LibraryElement || element is CompilationUnitElement) {
64 kind = IndexSyntheticElementKind.unit;
65 } 65 }
66 return new IndexElementInfo._(element, kind); 66 return new IndexElementInfo._(element, kind);
67 } 67 }
68 68
69 IndexElementInfo._(this.element, this.kind); 69 IndexElementInfo._(this.element, this.kind);
70 } 70 }
71 71
72 /** 72 /**
73 * Object that gathers information about the whole package index and then uses 73 * Object that gathers information about the whole package index and then uses
74 * it to assemble a new [PackageIndexBuilder]. Call [indexUnit] on each 74 * it to assemble a new [PackageIndexBuilder]. Call [indexUnit] on each
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 usedNameOffsets: nameRelations.map((r) => r.offset).toList(), 899 usedNameOffsets: nameRelations.map((r) => r.offset).toList(),
900 usedNameIsQualifiedFlags: 900 usedNameIsQualifiedFlags:
901 nameRelations.map((r) => r.isQualified).toList()); 901 nameRelations.map((r) => r.isQualified).toList());
902 } 902 }
903 903
904 void defineName(String name, IndexNameKind kind, int offset) { 904 void defineName(String name, IndexNameKind kind, int offset) {
905 _StringInfo nameInfo = pkg._getStringInfo(name); 905 _StringInfo nameInfo = pkg._getStringInfo(name);
906 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset)); 906 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset));
907 } 907 }
908 } 908 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698