Clean up dead code in quick assist support

Change-Id: I983c78a9ad131e5ae35a83abf2f455608b3ae835
Reviewed-on: https://dart-review.googlesource.com/52060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2018-04-20 14:23:29 +00:00 committed by commit-bot@chromium.org
parent 10b441b16b
commit 9a7168a2bf
6 changed files with 6 additions and 181 deletions

View file

@ -2,10 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart'
show SourceChange;
import 'package:analyzer_plugin/utilities/assist/assist.dart';
@ -16,11 +12,6 @@ import 'package:analyzer_plugin/utilities/assist/assist.dart';
* Clients may not extend, implement or mix-in this class.
*/
class Assist {
/**
* An empty list of assists.
*/
static const List<Assist> EMPTY_LIST = const <Assist>[];
/**
* A comparator that can be used to sort assists by their relevance. The most
* relevant assists will be sorted before assists with a lower relevance.
@ -53,42 +44,3 @@ class Assist {
return 'Assist(kind=$kind, change=$change)';
}
}
/**
* An object used to provide context information for [AssistContributor]s.
*
* Clients may not extend, implement or mix-in this class.
*/
abstract class AssistContext {
/**
* The analysis driver used to access analysis results.
*/
AnalysisDriver get analysisDriver;
/**
* The length of the selection.
*/
int get selectionLength;
/**
* The start of the selection.
*/
int get selectionOffset;
/**
* The source to get assists in.
*/
Source get source;
}
/**
* An object used to produce assists for a specific location.
*
* Clients may implement this class when implementing plugins.
*/
abstract class AssistContributor {
/**
* Completes with a list of assists for the given [context].
*/
Future<List<Assist>> computeAssists(AssistContext context);
}

View file

@ -2,18 +2,12 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/src/dart/analysis/ast_provider_driver.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/element/ast_provider.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
/**
* An object used to provide context information for [DartAssistContributor]s.
* An object used to provide context information for Dart assist contributors.
*
* Clients may not extend, implement or mix-in this class.
*/
@ -23,11 +17,6 @@ abstract class DartAssistContext {
*/
AnalysisDriver get analysisDriver;
/**
* The provider for parsed or resolved ASTs.
*/
AstProvider get astProvider;
/**
* The length of the selection.
*/
@ -48,60 +37,3 @@ abstract class DartAssistContext {
*/
CompilationUnit get unit;
}
/**
* An [AssistContributor] that can be used to contribute assists for Dart files.
*
* Clients may extend this class when implementing plugins.
*/
abstract class DartAssistContributor implements AssistContributor {
@override
Future<List<Assist>> computeAssists(AssistContext context) async {
AnalysisDriver driver = context.analysisDriver;
Source source = context.source;
if (!AnalysisEngine.isDartFileName(source.fullName)) {
return Assist.EMPTY_LIST;
}
CompilationUnit unit = (await driver.getResult(source.fullName)).unit;
if (unit == null) {
return Assist.EMPTY_LIST;
}
DartAssistContext dartContext = new _DartAssistContextImpl(
new AstProviderForDriver(driver), context, unit);
return internalComputeAssists(dartContext);
}
/**
* Completes with a list of assists for the given [context].
*/
Future<List<Assist>> internalComputeAssists(DartAssistContext context);
}
/**
* The implementation of [DartAssistContext].
*
* Clients may not extend, implement or mix-in this class.
*/
class _DartAssistContextImpl implements DartAssistContext {
@override
final AstProvider astProvider;
final AssistContext _context;
@override
final CompilationUnit unit;
_DartAssistContextImpl(this.astProvider, this._context, this.unit);
@override
AnalysisDriver get analysisDriver => _context.analysisDriver;
@override
int get selectionLength => _context.selectionLength;
@override
int get selectionOffset => _context.selectionOffset;
@override
Source get source => _context.source;
}

View file

@ -169,12 +169,7 @@ class EditDomainHandler extends AbstractRequestHandler {
CompilationUnitElement compilationUnitElement =
resolutionMap.elementDeclaredByCompilationUnit(unit);
DartAssistContext dartAssistContext = new _DartAssistContextForValues(
compilationUnitElement.source,
offset,
length,
driver,
new AstProviderForDriver(driver),
unit);
compilationUnitElement.source, offset, length, driver, unit);
try {
AssistProcessor processor = new AssistProcessor(dartAssistContext);
List<Assist> assists = await processor.compute();
@ -651,14 +646,11 @@ class _DartAssistContextForValues implements DartAssistContext {
@override
final AnalysisDriver analysisDriver;
@override
final AstProvider astProvider;
@override
final CompilationUnit unit;
_DartAssistContextForValues(this.source, this.selectionOffset,
this.selectionLength, this.analysisDriver, this.astProvider, this.unit);
this.selectionLength, this.analysisDriver, this.unit);
}
/**

View file

@ -2,37 +2,12 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer_plugin/utilities/assist/assist.dart';
/**
* The implementation of [AssistContext].
*/
class AssistContextImpl implements AssistContext {
@override
final AnalysisDriver analysisDriver;
@override
final Source source;
@override
final int selectionOffset;
@override
final int selectionLength;
AssistContextImpl(this.analysisDriver, this.source, this.selectionOffset,
this.selectionLength);
}
/**
* An enumeration of possible assist kinds.
*/
class DartAssistKind {
static const ADD_PART_DIRECTIVE = const AssistKind(
'dart.assist.addPartDirective', 30, "Add 'part' directive");
static const ADD_TYPE_ANNOTATION = const AssistKind(
'dart.assist.addTypeAnnotation', 30, "Add type annotation");
static const ASSIGN_TO_LOCAL_VARIABLE = const AssistKind(
@ -87,8 +62,6 @@ class DartAssistKind {
const AssistKind('dart.assist.encapsulateField', 30, "Encapsulate field");
static const EXCHANGE_OPERANDS =
const AssistKind('dart.assist.exchangeOperands', 30, "Exchange operands");
static const EXTRACT_CLASS = const AssistKind(
'dart.assist.extractClass', 30, "Extract class into file '{0}'");
static const FLUTTER_CONVERT_TO_CHILDREN = const AssistKind(
'dart.assist.flutter.convert.childToChildren',
30,

View file

@ -64,8 +64,6 @@ class AssistProcessor {
CompilationUnitElement unitElement;
LibraryElement unitLibraryElement;
String unitLibraryFile;
String unitLibraryFolder;
int selectionOffset;
int selectionLength;
@ -93,8 +91,6 @@ class AssistProcessor {
unitLibraryElement = resolutionMap
.elementDeclaredByCompilationUnit(dartContext.unit)
.library;
unitLibraryFile = unitLibraryElement.source.fullName;
unitLibraryFolder = dirname(unitLibraryFile);
// selection
selectionOffset = dartContext.selectionOffset;
selectionLength = dartContext.selectionLength;
@ -3132,21 +3128,6 @@ class AssistProcessor {
}
}
/**
* An [AssistContributor] that provides the default set of assists.
*/
class DefaultAssistContributor extends DartAssistContributor {
@override
Future<List<Assist>> internalComputeAssists(DartAssistContext context) async {
try {
AssistProcessor processor = new AssistProcessor(context);
return processor.compute();
} on CancelCorrectionException {
return Assist.EMPTY_LIST;
}
}
}
class _SimpleIdentifierRecursiveAstVisitor extends RecursiveAstVisitor {
final _SimpleIdentifierVisitor visitor;

View file

@ -11,9 +11,7 @@ import 'package:analysis_server/src/services/correction/assist_internal.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/analysis/ast_provider_driver.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/element/ast_provider.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
@ -5769,8 +5767,8 @@ main() {
CompilationUnitElement testUnitElement =
resolutionMap.elementDeclaredByCompilationUnit(testUnit);
DartAssistContext assistContext;
assistContext = new _DartAssistContextForValues(testUnitElement.source,
offset, length, driver, new AstProviderForDriver(driver), testUnit);
assistContext = new _DartAssistContextForValues(
testUnitElement.source, offset, length, driver, testUnit);
AssistProcessor processor = new AssistProcessor(assistContext);
return await processor.compute();
}
@ -5808,12 +5806,9 @@ class _DartAssistContextForValues implements DartAssistContext {
@override
final AnalysisDriver analysisDriver;
@override
final AstProvider astProvider;
@override
final CompilationUnit unit;
_DartAssistContextForValues(this.source, this.selectionOffset,
this.selectionLength, this.analysisDriver, this.astProvider, this.unit);
this.selectionLength, this.analysisDriver, this.unit);
}