mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Don't compute 'dart:core' LibraryElement during completion.
AnalysisResult already has TypeProvider, which can give us Object type. R=brianwilkerson@google.com, danrubel@google.com BUG= Review-Url: https://codereview.chromium.org/2946643002 .
This commit is contained in:
parent
e0216fef7f
commit
f9dc588a27
2 changed files with 9 additions and 33 deletions
|
@ -45,11 +45,6 @@ abstract class DartCompletionContributor {
|
|||
* Clients may not extend, implement or mix-in this class.
|
||||
*/
|
||||
abstract class DartCompletionRequest extends CompletionRequest {
|
||||
/**
|
||||
* Return the dart:core library element
|
||||
*/
|
||||
LibraryElement get coreLib;
|
||||
|
||||
/**
|
||||
* Return the expression to the right of the "dot" or "dot dot",
|
||||
* or `null` if this is not a "dot" completion (e.g. `foo.b`).
|
||||
|
|
|
@ -14,7 +14,6 @@ import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
|
|||
import 'package:analysis_server/src/services/completion/dart/contribution_sorter.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/standard_ast_factory.dart';
|
||||
import 'package:analyzer/dart/ast/standard_resolution_map.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
|
@ -105,7 +104,10 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
|
|||
final AnalysisResult result;
|
||||
|
||||
@override
|
||||
final LibraryElement coreLib;
|
||||
final ResourceProvider resourceProvider;
|
||||
|
||||
@override
|
||||
final InterfaceType objectType;
|
||||
|
||||
@override
|
||||
final Source source;
|
||||
|
@ -119,17 +121,9 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
|
|||
@override
|
||||
Source librarySource;
|
||||
|
||||
@override
|
||||
final ResourceProvider resourceProvider;
|
||||
|
||||
@override
|
||||
CompletionTarget target;
|
||||
|
||||
/**
|
||||
* The [DartType] for Object in dart:core
|
||||
*/
|
||||
InterfaceType _objectType;
|
||||
|
||||
OpType _opType;
|
||||
|
||||
final CompletionRequest _originalRequest;
|
||||
|
@ -139,7 +133,7 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
|
|||
DartCompletionRequestImpl._(
|
||||
this.result,
|
||||
this.resourceProvider,
|
||||
this.coreLib,
|
||||
this.objectType,
|
||||
this.librarySource,
|
||||
this.source,
|
||||
this.offset,
|
||||
|
@ -167,14 +161,6 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
InterfaceType get objectType {
|
||||
if (_objectType == null) {
|
||||
_objectType = coreLib.getType('Object').type;
|
||||
}
|
||||
return _objectType;
|
||||
}
|
||||
|
||||
OpType get opType {
|
||||
if (_opType == null) {
|
||||
_opType = new OpType.forCompletion(target, offset);
|
||||
|
@ -237,19 +223,14 @@ class DartCompletionRequestImpl implements DartCompletionRequest {
|
|||
const BUILD_REQUEST_TAG = 'build DartCompletionRequest';
|
||||
performance.logStartTime(BUILD_REQUEST_TAG);
|
||||
|
||||
Source libSource;
|
||||
CompilationUnit unit;
|
||||
unit = request.result.unit;
|
||||
// TODO(scheglov) support for parts
|
||||
libSource = resolutionMap.elementDeclaredByCompilationUnit(unit).source;
|
||||
|
||||
LibraryElement coreLib =
|
||||
await request.result.driver.getLibraryByUri('dart:core');
|
||||
CompilationUnit unit = request.result.unit;
|
||||
Source libSource = unit.element.library.source;
|
||||
InterfaceType objectType = request.result.typeProvider.objectType;
|
||||
|
||||
DartCompletionRequestImpl dartRequest = new DartCompletionRequestImpl._(
|
||||
request.result,
|
||||
request.resourceProvider,
|
||||
coreLib,
|
||||
objectType,
|
||||
libSource,
|
||||
request.source,
|
||||
request.offset,
|
||||
|
|
Loading…
Reference in a new issue