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

Side by Side Diff: pkg/analysis_server/lib/src/services/index/index.dart

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Created 4 years 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 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/src/services/index/index_unit.dart'; 7 import 'package:analysis_server/src/services/index/index_unit.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/ast/resolution_accessors.dart';
9 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; 11 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
11 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
12 import 'package:analyzer/src/summary/format.dart'; 13 import 'package:analyzer/src/summary/format.dart';
13 import 'package:analyzer/src/summary/idl.dart'; 14 import 'package:analyzer/src/summary/idl.dart';
14 import 'package:collection/collection.dart'; 15 import 'package:collection/collection.dart';
15 16
16 /** 17 /**
17 * Return a new [Index] instance that keeps information in memory. 18 * Return a new [Index] instance that keeps information in memory.
18 */ 19 */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 Future<List<Location>> getUnresolvedMemberReferences(String name) { 74 Future<List<Location>> getUnresolvedMemberReferences(String name) {
74 return _mergeLocations((_ContextIndex index) { 75 return _mergeLocations((_ContextIndex index) {
75 return index.getUnresolvedMemberReferences(name); 76 return index.getUnresolvedMemberReferences(name);
76 }); 77 });
77 } 78 }
78 79
79 /** 80 /**
80 * Index declarations in the given partially resolved [unit]. 81 * Index declarations in the given partially resolved [unit].
81 */ 82 */
82 void indexDeclarations(CompilationUnit unit) { 83 void indexDeclarations(CompilationUnit unit) {
83 if (unit?.element?.library == null) { 84 if (unit == null) {
84 return; 85 return;
85 } 86 }
86 AnalysisContext context = unit.element.context; 87 CompilationUnitElement compilationUnitElement =
88 elementForCompilationUnit(unit);
89 if (compilationUnitElement?.library == null) {
90 return;
91 }
92 AnalysisContext context = compilationUnitElement.context;
87 _getContextIndex(context).indexDeclarations(unit); 93 _getContextIndex(context).indexDeclarations(unit);
88 } 94 }
89 95
90 /** 96 /**
91 * Index the given fully resolved [unit]. 97 * Index the given fully resolved [unit].
92 */ 98 */
93 void indexUnit(CompilationUnit unit) { 99 void indexUnit(CompilationUnit unit) {
94 if (unit?.element?.library == null) { 100 if (unit == null) {
95 return; 101 return;
96 } 102 }
97 AnalysisContext context = unit.element.context; 103 CompilationUnitElement compilationUnitElement =
104 elementForCompilationUnit(unit);
105 if (compilationUnitElement?.library == null) {
106 return;
107 }
108 AnalysisContext context = compilationUnitElement.context;
98 _getContextIndex(context).indexUnit(unit); 109 _getContextIndex(context).indexUnit(unit);
99 } 110 }
100 111
101 /** 112 /**
102 * Remove all index information for the given [context]. 113 * Remove all index information for the given [context].
103 */ 114 */
104 void removeContext(AnalysisContext context) { 115 void removeContext(AnalysisContext context) {
105 _contextIndexMap.remove(context); 116 _contextIndexMap.remove(context);
106 } 117 }
107 118
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 unitUnitUri, 641 unitUnitUri,
631 unitIndex.usedNameKinds[i], 642 unitIndex.usedNameKinds[i],
632 unitIndex.usedNameOffsets[i], 643 unitIndex.usedNameOffsets[i],
633 name.length, 644 name.length,
634 unitIndex.usedNameIsQualifiedFlags[i], 645 unitIndex.usedNameIsQualifiedFlags[i],
635 false)); 646 false));
636 } 647 }
637 return locations; 648 return locations;
638 } 649 }
639 } 650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698