Graduate 'flutter' domain from experimental, remove unused methods and fields.

We could also remove FlutterCorrections, because right now we don't
use it, but we will restore it soon as we get new Flutter domain
methods.

R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: I084fe5acbe5d854673c7247d734aeca1f8d721af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2019-07-08 22:03:24 +00:00 committed by commit-bot@chromium.org
parent a945888627
commit 8a1dcdae68
16 changed files with 279 additions and 1850 deletions

File diff suppressed because one or more lines are too long

View file

@ -276,20 +276,9 @@ const String EXECUTION_RESPONSE_MAP_URI_FILE = 'file';
const String EXECUTION_RESPONSE_MAP_URI_URI = 'uri';
const String FLUTTER_NOTIFICATION_OUTLINE = 'flutter.outline';
const String FLUTTER_NOTIFICATION_OUTLINE_FILE = 'file';
const String FLUTTER_NOTIFICATION_OUTLINE_INSTRUMENTED_CODE =
'instrumentedCode';
const String FLUTTER_NOTIFICATION_OUTLINE_OUTLINE = 'outline';
const String FLUTTER_REQUEST_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR =
'flutter.getChangeAddForDesignTimeConstructor';
const String FLUTTER_REQUEST_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR_FILE =
'file';
const String FLUTTER_REQUEST_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR_OFFSET =
'offset';
const String FLUTTER_REQUEST_SET_SUBSCRIPTIONS = 'flutter.setSubscriptions';
const String FLUTTER_REQUEST_SET_SUBSCRIPTIONS_SUBSCRIPTIONS = 'subscriptions';
const String
FLUTTER_RESPONSE_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR_CHANGE =
'change';
const String KYTHE_REQUEST_GET_KYTHE_ENTRIES = 'kythe.getKytheEntries';
const String KYTHE_REQUEST_GET_KYTHE_ENTRIES_FILE = 'file';
const String KYTHE_RESPONSE_GET_KYTHE_ENTRIES_ENTRIES = 'entries';

View file

@ -14443,210 +14443,6 @@ class FileKind implements Enum {
String toJson() => name;
}
/**
* flutter.getChangeAddForDesignTimeConstructor params
*
* {
* "file": FilePath
* "offset": int
* }
*
* Clients may not extend, implement or mix-in this class.
*/
class FlutterGetChangeAddForDesignTimeConstructorParams
implements RequestParams {
String _file;
int _offset;
/**
* The file containing the code of the class.
*/
String get file => _file;
/**
* The file containing the code of the class.
*/
void set file(String value) {
assert(value != null);
this._file = value;
}
/**
* The offset of the class in the code.
*/
int get offset => _offset;
/**
* The offset of the class in the code.
*/
void set offset(int value) {
assert(value != null);
this._offset = value;
}
FlutterGetChangeAddForDesignTimeConstructorParams(String file, int offset) {
this.file = file;
this.offset = offset;
}
factory FlutterGetChangeAddForDesignTimeConstructorParams.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object json) {
if (json == null) {
json = {};
}
if (json is Map) {
String file;
if (json.containsKey("file")) {
file = jsonDecoder.decodeString(jsonPath + ".file", json["file"]);
} else {
throw jsonDecoder.mismatch(jsonPath, "file");
}
int offset;
if (json.containsKey("offset")) {
offset = jsonDecoder.decodeInt(jsonPath + ".offset", json["offset"]);
} else {
throw jsonDecoder.mismatch(jsonPath, "offset");
}
return new FlutterGetChangeAddForDesignTimeConstructorParams(
file, offset);
} else {
throw jsonDecoder.mismatch(jsonPath,
"flutter.getChangeAddForDesignTimeConstructor params", json);
}
}
factory FlutterGetChangeAddForDesignTimeConstructorParams.fromRequest(
Request request) {
return new FlutterGetChangeAddForDesignTimeConstructorParams.fromJson(
new RequestDecoder(request), "params", request.params);
}
@override
Map<String, dynamic> toJson() {
Map<String, dynamic> result = {};
result["file"] = file;
result["offset"] = offset;
return result;
}
@override
Request toRequest(String id) {
return new Request(
id, "flutter.getChangeAddForDesignTimeConstructor", toJson());
}
@override
String toString() => json.encode(toJson());
@override
bool operator ==(other) {
if (other is FlutterGetChangeAddForDesignTimeConstructorParams) {
return file == other.file && offset == other.offset;
}
return false;
}
@override
int get hashCode {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, file.hashCode);
hash = JenkinsSmiHash.combine(hash, offset.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
/**
* flutter.getChangeAddForDesignTimeConstructor result
*
* {
* "change": SourceChange
* }
*
* Clients may not extend, implement or mix-in this class.
*/
class FlutterGetChangeAddForDesignTimeConstructorResult
implements ResponseResult {
SourceChange _change;
/**
* The change that adds the forDesignTime() constructor. If the change cannot
* be produced, an error is returned.
*/
SourceChange get change => _change;
/**
* The change that adds the forDesignTime() constructor. If the change cannot
* be produced, an error is returned.
*/
void set change(SourceChange value) {
assert(value != null);
this._change = value;
}
FlutterGetChangeAddForDesignTimeConstructorResult(SourceChange change) {
this.change = change;
}
factory FlutterGetChangeAddForDesignTimeConstructorResult.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object json) {
if (json == null) {
json = {};
}
if (json is Map) {
SourceChange change;
if (json.containsKey("change")) {
change = new SourceChange.fromJson(
jsonDecoder, jsonPath + ".change", json["change"]);
} else {
throw jsonDecoder.mismatch(jsonPath, "change");
}
return new FlutterGetChangeAddForDesignTimeConstructorResult(change);
} else {
throw jsonDecoder.mismatch(jsonPath,
"flutter.getChangeAddForDesignTimeConstructor result", json);
}
}
factory FlutterGetChangeAddForDesignTimeConstructorResult.fromResponse(
Response response) {
return new FlutterGetChangeAddForDesignTimeConstructorResult.fromJson(
new ResponseDecoder(REQUEST_ID_REFACTORING_KINDS.remove(response.id)),
"result",
response.result);
}
@override
Map<String, dynamic> toJson() {
Map<String, dynamic> result = {};
result["change"] = change.toJson();
return result;
}
@override
Response toResponse(String id) {
return new Response(id, result: toJson());
}
@override
String toString() => json.encode(toJson());
@override
bool operator ==(other) {
if (other is FlutterGetChangeAddForDesignTimeConstructorResult) {
return change == other.change;
}
return false;
}
@override
int get hashCode {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, change.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
/**
* FlutterOutline
*
@ -14663,12 +14459,6 @@ class FlutterGetChangeAddForDesignTimeConstructorResult
* "parentAssociationLabel": optional String
* "variableName": optional String
* "children": optional List<FlutterOutline>
* "id": optional int
* "isWidgetClass": optional bool
* "renderConstructor": optional String
* "stateClassName": optional String
* "stateOffset": optional int
* "stateLength": optional int
* }
*
* Clients may not extend, implement or mix-in this class.
@ -14698,18 +14488,6 @@ class FlutterOutline implements HasToJson {
List<FlutterOutline> _children;
int _id;
bool _isWidgetClass;
String _renderConstructor;
String _stateClassName;
int _stateOffset;
int _stateLength;
/**
* The kind of the node.
*/
@ -14881,102 +14659,6 @@ class FlutterOutline implements HasToJson {
this._children = value;
}
/**
* If the node is a widget, and it is instrumented, the unique identifier of
* this widget, that can be used to associate rendering information with this
* node.
*/
int get id => _id;
/**
* If the node is a widget, and it is instrumented, the unique identifier of
* this widget, that can be used to associate rendering information with this
* node.
*/
void set id(int value) {
this._id = value;
}
/**
* True if the node is a widget class, so it can potentially be rendered,
* even if it does not yet have the rendering constructor. This field is
* omitted if the node is not a widget class.
*/
bool get isWidgetClass => _isWidgetClass;
/**
* True if the node is a widget class, so it can potentially be rendered,
* even if it does not yet have the rendering constructor. This field is
* omitted if the node is not a widget class.
*/
void set isWidgetClass(bool value) {
this._isWidgetClass = value;
}
/**
* If the node is a widget class that can be rendered for IDE, the name of
* the constructor that should be used to instantiate the widget. Empty
* string for default constructor. Absent if the node is not a widget class
* that can be rendered.
*/
String get renderConstructor => _renderConstructor;
/**
* If the node is a widget class that can be rendered for IDE, the name of
* the constructor that should be used to instantiate the widget. Empty
* string for default constructor. Absent if the node is not a widget class
* that can be rendered.
*/
void set renderConstructor(String value) {
this._renderConstructor = value;
}
/**
* If the node is a StatefulWidget, and its state class is defined in the
* same file, the name of the state class.
*/
String get stateClassName => _stateClassName;
/**
* If the node is a StatefulWidget, and its state class is defined in the
* same file, the name of the state class.
*/
void set stateClassName(String value) {
this._stateClassName = value;
}
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the offset of the state class code in the
* file.
*/
int get stateOffset => _stateOffset;
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the offset of the state class code in the
* file.
*/
void set stateOffset(int value) {
this._stateOffset = value;
}
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the length of the state class code in the
* file.
*/
int get stateLength => _stateLength;
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the length of the state class code in the
* file.
*/
void set stateLength(int value) {
this._stateLength = value;
}
FlutterOutline(FlutterOutlineKind kind, int offset, int length,
int codeOffset, int codeLength,
{String label,
@ -14985,13 +14667,7 @@ class FlutterOutline implements HasToJson {
String className,
String parentAssociationLabel,
String variableName,
List<FlutterOutline> children,
int id,
bool isWidgetClass,
String renderConstructor,
String stateClassName,
int stateOffset,
int stateLength}) {
List<FlutterOutline> children}) {
this.kind = kind;
this.offset = offset;
this.length = length;
@ -15004,12 +14680,6 @@ class FlutterOutline implements HasToJson {
this.parentAssociationLabel = parentAssociationLabel;
this.variableName = variableName;
this.children = children;
this.id = id;
this.isWidgetClass = isWidgetClass;
this.renderConstructor = renderConstructor;
this.stateClassName = stateClassName;
this.stateOffset = stateOffset;
this.stateLength = stateLength;
}
factory FlutterOutline.fromJson(
@ -15093,35 +14763,6 @@ class FlutterOutline implements HasToJson {
(String jsonPath, Object json) =>
new FlutterOutline.fromJson(jsonDecoder, jsonPath, json));
}
int id;
if (json.containsKey("id")) {
id = jsonDecoder.decodeInt(jsonPath + ".id", json["id"]);
}
bool isWidgetClass;
if (json.containsKey("isWidgetClass")) {
isWidgetClass = jsonDecoder.decodeBool(
jsonPath + ".isWidgetClass", json["isWidgetClass"]);
}
String renderConstructor;
if (json.containsKey("renderConstructor")) {
renderConstructor = jsonDecoder.decodeString(
jsonPath + ".renderConstructor", json["renderConstructor"]);
}
String stateClassName;
if (json.containsKey("stateClassName")) {
stateClassName = jsonDecoder.decodeString(
jsonPath + ".stateClassName", json["stateClassName"]);
}
int stateOffset;
if (json.containsKey("stateOffset")) {
stateOffset = jsonDecoder.decodeInt(
jsonPath + ".stateOffset", json["stateOffset"]);
}
int stateLength;
if (json.containsKey("stateLength")) {
stateLength = jsonDecoder.decodeInt(
jsonPath + ".stateLength", json["stateLength"]);
}
return new FlutterOutline(kind, offset, length, codeOffset, codeLength,
label: label,
dartElement: dartElement,
@ -15129,13 +14770,7 @@ class FlutterOutline implements HasToJson {
className: className,
parentAssociationLabel: parentAssociationLabel,
variableName: variableName,
children: children,
id: id,
isWidgetClass: isWidgetClass,
renderConstructor: renderConstructor,
stateClassName: stateClassName,
stateOffset: stateOffset,
stateLength: stateLength);
children: children);
} else {
throw jsonDecoder.mismatch(jsonPath, "FlutterOutline", json);
}
@ -15173,24 +14808,6 @@ class FlutterOutline implements HasToJson {
result["children"] =
children.map((FlutterOutline value) => value.toJson()).toList();
}
if (id != null) {
result["id"] = id;
}
if (isWidgetClass != null) {
result["isWidgetClass"] = isWidgetClass;
}
if (renderConstructor != null) {
result["renderConstructor"] = renderConstructor;
}
if (stateClassName != null) {
result["stateClassName"] = stateClassName;
}
if (stateOffset != null) {
result["stateOffset"] = stateOffset;
}
if (stateLength != null) {
result["stateLength"] = stateLength;
}
return result;
}
@ -15216,13 +14833,7 @@ class FlutterOutline implements HasToJson {
parentAssociationLabel == other.parentAssociationLabel &&
variableName == other.variableName &&
listEqual(children, other.children,
(FlutterOutline a, FlutterOutline b) => a == b) &&
id == other.id &&
isWidgetClass == other.isWidgetClass &&
renderConstructor == other.renderConstructor &&
stateClassName == other.stateClassName &&
stateOffset == other.stateOffset &&
stateLength == other.stateLength;
(FlutterOutline a, FlutterOutline b) => a == b);
}
return false;
}
@ -15242,12 +14853,6 @@ class FlutterOutline implements HasToJson {
hash = JenkinsSmiHash.combine(hash, parentAssociationLabel.hashCode);
hash = JenkinsSmiHash.combine(hash, variableName.hashCode);
hash = JenkinsSmiHash.combine(hash, children.hashCode);
hash = JenkinsSmiHash.combine(hash, id.hashCode);
hash = JenkinsSmiHash.combine(hash, isWidgetClass.hashCode);
hash = JenkinsSmiHash.combine(hash, renderConstructor.hashCode);
hash = JenkinsSmiHash.combine(hash, stateClassName.hashCode);
hash = JenkinsSmiHash.combine(hash, stateOffset.hashCode);
hash = JenkinsSmiHash.combine(hash, stateLength.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
@ -15555,7 +15160,6 @@ class FlutterOutlineKind implements Enum {
* {
* "file": FilePath
* "outline": FlutterOutline
* "instrumentedCode": optional String
* }
*
* Clients may not extend, implement or mix-in this class.
@ -15565,8 +15169,6 @@ class FlutterOutlineParams implements HasToJson {
FlutterOutline _outline;
String _instrumentedCode;
/**
* The file with which the outline is associated.
*/
@ -15593,29 +15195,9 @@ class FlutterOutlineParams implements HasToJson {
this._outline = value;
}
/**
* If the file has Flutter widgets that can be rendered, this field has the
* instrumented content of the file, that allows associating widgets with
* corresponding outline nodes. If there are no widgets to render, this field
* is absent.
*/
String get instrumentedCode => _instrumentedCode;
/**
* If the file has Flutter widgets that can be rendered, this field has the
* instrumented content of the file, that allows associating widgets with
* corresponding outline nodes. If there are no widgets to render, this field
* is absent.
*/
void set instrumentedCode(String value) {
this._instrumentedCode = value;
}
FlutterOutlineParams(String file, FlutterOutline outline,
{String instrumentedCode}) {
FlutterOutlineParams(String file, FlutterOutline outline) {
this.file = file;
this.outline = outline;
this.instrumentedCode = instrumentedCode;
}
factory FlutterOutlineParams.fromJson(
@ -15637,13 +15219,7 @@ class FlutterOutlineParams implements HasToJson {
} else {
throw jsonDecoder.mismatch(jsonPath, "outline");
}
String instrumentedCode;
if (json.containsKey("instrumentedCode")) {
instrumentedCode = jsonDecoder.decodeString(
jsonPath + ".instrumentedCode", json["instrumentedCode"]);
}
return new FlutterOutlineParams(file, outline,
instrumentedCode: instrumentedCode);
return new FlutterOutlineParams(file, outline);
} else {
throw jsonDecoder.mismatch(jsonPath, "flutter.outline params", json);
}
@ -15659,9 +15235,6 @@ class FlutterOutlineParams implements HasToJson {
Map<String, dynamic> result = {};
result["file"] = file;
result["outline"] = outline.toJson();
if (instrumentedCode != null) {
result["instrumentedCode"] = instrumentedCode;
}
return result;
}
@ -15675,9 +15248,7 @@ class FlutterOutlineParams implements HasToJson {
@override
bool operator ==(other) {
if (other is FlutterOutlineParams) {
return file == other.file &&
outline == other.outline &&
instrumentedCode == other.instrumentedCode;
return file == other.file && outline == other.outline;
}
return false;
}
@ -15687,7 +15258,6 @@ class FlutterOutlineParams implements HasToJson {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, file.hashCode);
hash = JenkinsSmiHash.combine(hash, outline.hashCode);
hash = JenkinsSmiHash.combine(hash, instrumentedCode.hashCode);
return JenkinsSmiHash.finish(hash);
}
}

View file

@ -2,14 +2,10 @@
// 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/src/services/correction/util.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element;
import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
import 'package:meta/meta.dart';
class FlutterCorrections {
@ -39,37 +35,4 @@ class FlutterCorrections {
* Returns the EOL to use for this [CompilationUnit].
*/
String get eol => utils.endOfLine;
Future<SourceChange> addForDesignTimeConstructor() async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
final node = this.node;
if (node is ClassDeclaration) {
var className = node.name.name;
var location = utils.prepareNewConstructorLocation(node);
var changeBuilder = new DartChangeBuilder(resolveResult.session);
await changeBuilder.addFileEdit(resolveResult.path, (builder) {
builder.addInsertion(location.offset, (builder) {
builder.write(location.prefix);
// If there are no constructors, we need to add also default.
bool hasConstructors =
node.members.any((m) => m is ConstructorDeclaration);
if (!hasConstructors) {
builder.writeln('$className();');
builder.writeln();
builder.write(' ');
}
builder.writeln('factory $className.forDesignTime() {');
builder.writeln(' // TODO: add arguments');
builder.writeln(' return new $className();');
builder.write(' }');
builder.write(location.suffix);
});
});
return changeBuilder.sourceChange;
}
return null;
}
}

View file

@ -2,15 +2,11 @@
// 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/protocol/protocol_constants.dart';
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/domain_abstract.dart';
import 'package:analysis_server/src/flutter/flutter_correction.dart';
import 'package:analysis_server/src/protocol/protocol_internal.dart';
import 'package:analysis_server/src/protocol_server.dart';
import 'package:analyzer/dart/analysis/results.dart';
/**
* A [RequestHandler] that handles requests in the `flutter` domain.
@ -21,46 +17,10 @@ class FlutterDomainHandler extends AbstractRequestHandler {
*/
FlutterDomainHandler(AnalysisServer server) : super(server);
/**
* Implement the 'flutter.getChangeAddForDesignTimeConstructor' request.
*/
Future getChangeAddForDesignTimeConstructor(Request request) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
var params =
new FlutterGetChangeAddForDesignTimeConstructorParams.fromRequest(
request);
String file = params.file;
int offset = params.offset;
ResolvedUnitResult result = await server.getResolvedUnit(file);
if (result != null) {
var corrections = new FlutterCorrections(
resolveResult: result,
selectionOffset: offset,
selectionLength: 0,
);
SourceChange change = await corrections.addForDesignTimeConstructor();
if (change != null) {
server.sendResponse(
new FlutterGetChangeAddForDesignTimeConstructorResult(change)
.toResponse(request.id));
return;
}
}
server.sendResponse(
new Response.invalidParameter(request, 'file', 'No change'));
}
@override
Response handleRequest(Request request) {
try {
String requestName = request.method;
if (requestName ==
FLUTTER_REQUEST_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR) {
getChangeAddForDesignTimeConstructor(request);
return Response.DELAYED_RESPONSE;
}
if (requestName == FLUTTER_REQUEST_SET_SUBSCRIPTIONS) {
return setSubscriptions(request);
}

View file

@ -16,7 +16,6 @@ void sendFlutterNotificationOutline(
var params = new protocol.FlutterOutlineParams(
resolvedUnit.path,
outline,
instrumentedCode: computer.instrumentedCode,
);
server.sendNotification(params.toNotification());
});

View file

@ -4,44 +4,20 @@
import 'package:analysis_server/src/computer/computer_outline.dart';
import 'package:analysis_server/src/protocol_server.dart' as protocol;
import 'package:analysis_server/src/protocol_server.dart';
import 'package:analysis_server/src/utilities/flutter.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/generated/source.dart';
/// Computer for Flutter specific outlines.
class FlutterOutlineComputer {
static const CONSTRUCTOR_NAME = 'forDesignTime';
/// Code to append to the instrumented library code.
static const RENDER_APPEND = r'''
final flutterDesignerWidgets = <int, Widget>{};
T _registerWidgetInstance<T extends Widget>(int id, T widget) {
flutterDesignerWidgets[id] = widget;
return widget;
}
''';
final ResolvedUnitResult resolvedUnit;
Flutter flutter;
final List<protocol.FlutterOutline> _depthFirstOrder = [];
int nextWidgetId = 0;
/// This map is filled with information about widget classes that can be
/// rendered. Its keys are class name offsets.
final Map<int, _WidgetClass> widgets = {};
final List<protocol.SourceEdit> instrumentationEdits = [];
String instrumentedCode;
FlutterOutlineComputer(this.resolvedUnit);
protocol.FlutterOutline compute() {
@ -52,13 +28,6 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
flutter = Flutter.of(resolvedUnit);
// Find widget classes.
// IDEA plugin only supports rendering widgets in libraries.
var unitElement = resolvedUnit.unit.declaredElement;
if (unitElement.source == unitElement.librarySource) {
_findWidgets();
}
// Convert Dart outlines into Flutter outlines.
var flutterDartOutline = _convert(dartOutline);
@ -78,17 +47,6 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
}
}
// Compute instrumented code.
if (widgets.values.any((w) => w.hasDesignTimeConstructor)) {
_rewriteRelativeDirectives();
instrumentationEdits.sort((a, b) => b.offset - a.offset);
instrumentedCode = SourceEdit.applySequence(
resolvedUnit.content,
instrumentationEdits,
);
instrumentedCode += RENDER_APPEND;
}
return flutterDartOutline;
}
@ -137,14 +95,6 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
}
}
int _addInstrumentationEdits(Expression expression) {
int id = nextWidgetId++;
instrumentationEdits.add(new protocol.SourceEdit(
expression.offset, 0, '_registerWidgetInstance($id, '));
instrumentationEdits.add(new protocol.SourceEdit(expression.end, 0, ')'));
return id;
}
protocol.FlutterOutline _convert(protocol.Outline dartOutline) {
protocol.FlutterOutline flutterOutline = new protocol.FlutterOutline(
protocol.FlutterOutlineKind.DART_ELEMENT,
@ -157,20 +107,6 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
flutterOutline.children = dartOutline.children.map(_convert).toList();
}
// Fill rendering information for widget classes.
if (dartOutline.element.kind == protocol.ElementKind.CLASS) {
var widget = widgets[dartOutline.element.location.offset];
if (widget != null) {
flutterOutline.isWidgetClass = true;
if (widget.hasDesignTimeConstructor) {
flutterOutline.renderConstructor = CONSTRUCTOR_NAME;
}
flutterOutline.stateClassName = widget.state?.name?.name;
flutterOutline.stateOffset = widget.state?.offset;
flutterOutline.stateLength = widget.state?.length;
}
}
_depthFirstOrder.add(flutterOutline);
return flutterOutline;
}
@ -187,8 +123,6 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
String className = type.element.displayName;
if (node is InstanceCreationExpression) {
int id = _addInstrumentationEdits(node);
var attributes = <protocol.FlutterOutlineAttribute>[];
var children = <protocol.FlutterOutline>[];
for (var argument in node.argumentList.arguments) {
@ -256,8 +190,7 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
node.length,
className: className,
attributes: attributes,
children: children,
id: id);
children: children);
}
// A generic Widget typed expression.
@ -275,91 +208,14 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
label = _getShortLabel(node);
}
int id = _addInstrumentationEdits(node);
return new protocol.FlutterOutline(
kind, node.offset, node.length, node.offset, node.length,
className: className,
variableName: variableName,
label: label,
id: id);
className: className, variableName: variableName, label: label);
}
return null;
}
/// Return the `State` declaration for the given `StatefulWidget` declaration.
/// Return `null` if cannot be found.
ClassDeclaration _findState(ClassDeclaration widget) {
MethodDeclaration createStateMethod = widget.members.firstWhere(
(method) =>
method is MethodDeclaration &&
method.name.name == 'createState' &&
method.body != null,
orElse: () => null);
if (createStateMethod == null) {
return null;
}
DartType stateType;
{
FunctionBody buildBody = createStateMethod.body;
if (buildBody is ExpressionFunctionBody) {
stateType = buildBody.expression.staticType;
} else if (buildBody is BlockFunctionBody) {
List<Statement> statements = buildBody.block.statements;
if (statements.isNotEmpty) {
Statement lastStatement = statements.last;
if (lastStatement is ReturnStatement) {
stateType = lastStatement.expression?.staticType;
}
}
}
}
if (stateType == null) {
return null;
}
ClassElement stateElement;
if (stateType is InterfaceType && flutter.isState(stateType.element)) {
stateElement = stateType.element;
} else {
return null;
}
for (var stateNode in resolvedUnit.unit.declarations) {
if (stateNode is ClassDeclaration &&
stateNode.declaredElement == stateElement) {
return stateNode;
}
}
return null;
}
/// Fill [widgets] with information about classes that can be rendered.
void _findWidgets() {
for (var widget in resolvedUnit.unit.declarations) {
if (widget is ClassDeclaration) {
int nameOffset = widget.name.offset;
var designTimeConstructor = widget.getConstructor(CONSTRUCTOR_NAME);
bool hasDesignTimeConstructor = designTimeConstructor != null;
InterfaceType superType = widget.declaredElement.supertype;
if (flutter.isExactlyStatelessWidgetType(superType)) {
widgets[nameOffset] =
new _WidgetClass(nameOffset, hasDesignTimeConstructor);
} else if (flutter.isExactlyStatefulWidgetType(superType)) {
ClassDeclaration state = _findState(widget);
if (state != null) {
widgets[nameOffset] =
new _WidgetClass(nameOffset, hasDesignTimeConstructor, state);
}
}
}
}
}
String _getShortLabel(AstNode node) {
if (node is MethodInvocation) {
var buffer = new StringBuffer();
@ -381,25 +237,6 @@ T _registerWidgetInstance<T extends Widget>(int id, T widget) {
}
return node.toString();
}
/// The instrumented code is put into a temporary directory for Dart VM to
/// run. So, any relative URIs must be changed to corresponding absolute URIs.
void _rewriteRelativeDirectives() {
for (var directive in resolvedUnit.unit.directives) {
if (directive is UriBasedDirective) {
String uriContent = directive.uriContent;
Source source = directive.uriSource;
if (uriContent != null && source != null) {
try {
if (!Uri.parse(uriContent).isAbsolute) {
instrumentationEdits.add(new SourceEdit(directive.uri.offset,
directive.uri.length, "'${source.uri}'"));
}
} on FormatException {}
}
}
}
}
}
class _FlutterOutlineBuilder extends GeneralizingAstVisitor<void> {
@ -418,16 +255,3 @@ class _FlutterOutlineBuilder extends GeneralizingAstVisitor<void> {
}
}
}
/// Information about a Widget class that can be rendered.
class _WidgetClass {
final int nameOffset;
/// Is `true` if has `forDesignTime` constructor, so can be rendered.
final bool hasDesignTimeConstructor;
/// If a `StatefulWidget` with the `State` in the same file.
final ClassDeclaration state;
_WidgetClass(this.nameOffset, this.hasDesignTimeConstructor, [this.state]);
}

View file

@ -2580,40 +2580,6 @@ abstract class IntegrationTestMixin {
return new KytheGetKytheEntriesResult.fromJson(decoder, 'result', result);
}
/**
* Return the change that adds the forDesignTime() constructor for the widget
* class at the given offset.
*
* Parameters
*
* file: FilePath
*
* The file containing the code of the class.
*
* offset: int
*
* The offset of the class in the code.
*
* Returns
*
* change: SourceChange
*
* The change that adds the forDesignTime() constructor. If the change
* cannot be produced, an error is returned.
*/
Future<FlutterGetChangeAddForDesignTimeConstructorResult>
sendFlutterGetChangeAddForDesignTimeConstructor(
String file, int offset) async {
var params =
new FlutterGetChangeAddForDesignTimeConstructorParams(file, offset)
.toJson();
var result = await server.send(
"flutter.getChangeAddForDesignTimeConstructor", params);
ResponseDecoder decoder = new ResponseDecoder(null);
return new FlutterGetChangeAddForDesignTimeConstructorResult.fromJson(
decoder, 'result', result);
}
/**
* Subscribe for services that are specific to individual files. All previous
* subscriptions are replaced by the current set of subscriptions. If a given
@ -2670,13 +2636,6 @@ abstract class IntegrationTestMixin {
* outline: FlutterOutline
*
* The outline associated with the file.
*
* instrumentedCode: String (optional)
*
* If the file has Flutter widgets that can be rendered, this field has the
* instrumented content of the file, that allows associating widgets with
* corresponding outline nodes. If there are no widgets to render, this
* field is absent.
*/
Stream<FlutterOutlineParams> onFlutterOutline;

View file

@ -617,12 +617,6 @@ final Matcher isFilePath = isString;
* "parentAssociationLabel": optional String
* "variableName": optional String
* "children": optional List<FlutterOutline>
* "id": optional int
* "isWidgetClass": optional bool
* "renderConstructor": optional String
* "stateClassName": optional String
* "stateOffset": optional int
* "stateLength": optional int
* }
*/
final Matcher isFlutterOutline =
@ -639,13 +633,7 @@ final Matcher isFlutterOutline =
"className": isString,
"parentAssociationLabel": isString,
"variableName": isString,
"children": isListOf(isFlutterOutline),
"id": isInt,
"isWidgetClass": isBool,
"renderConstructor": isString,
"stateClassName": isString,
"stateOffset": isInt,
"stateLength": isInt
"children": isListOf(isFlutterOutline)
}));
/**
@ -3026,44 +3014,17 @@ final Matcher isExtractWidgetFeedback = new LazyMatcher(
final Matcher isExtractWidgetOptions = new LazyMatcher(
() => new MatchesJsonObject("extractWidget options", {"name": isString}));
/**
* flutter.getChangeAddForDesignTimeConstructor params
*
* {
* "file": FilePath
* "offset": int
* }
*/
final Matcher isFlutterGetChangeAddForDesignTimeConstructorParams =
new LazyMatcher(() => new MatchesJsonObject(
"flutter.getChangeAddForDesignTimeConstructor params",
{"file": isFilePath, "offset": isInt}));
/**
* flutter.getChangeAddForDesignTimeConstructor result
*
* {
* "change": SourceChange
* }
*/
final Matcher isFlutterGetChangeAddForDesignTimeConstructorResult =
new LazyMatcher(() => new MatchesJsonObject(
"flutter.getChangeAddForDesignTimeConstructor result",
{"change": isSourceChange}));
/**
* flutter.outline params
*
* {
* "file": FilePath
* "outline": FlutterOutline
* "instrumentedCode": optional String
* }
*/
final Matcher isFlutterOutlineParams = new LazyMatcher(() =>
new MatchesJsonObject("flutter.outline params",
{"file": isFilePath, "outline": isFlutterOutline},
optionalFields: {"instrumentedCode": isString}));
{"file": isFilePath, "outline": isFlutterOutline}));
/**
* flutter.setSubscriptions params

View file

@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/flutter/flutter_correction.dart';
import 'package:analysis_server/src/protocol_server.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@ -33,101 +32,26 @@ class FlutterCorrectionTest extends AbstractSingleUnitTest {
addFlutterPackage();
}
test_addForDesignTimeConstructor_BAD_notClass() async {
await resolveTestUnit('var v = 42;');
offset = findOffset('v =');
_createCorrections();
SourceChange change = await corrections.addForDesignTimeConstructor();
expect(change, isNull);
}
test_addForDesignTimeConstructor_OK_hasConstructor() async {
await resolveTestUnit('''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
MyWidget(String text);
Widget build(BuildContext context) {
return new Container();
}
}
''');
offset = findOffset('class MyWidget');
_createCorrections();
SourceChange change = await corrections.addForDesignTimeConstructor();
_assertChange(change, r'''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
MyWidget(String text);
factory MyWidget.forDesignTime() {
// TODO: add arguments
return new MyWidget();
}
Widget build(BuildContext context) {
return new Container();
}
}
''');
}
test_addForDesignTimeConstructor_OK_noConstructor() async {
await resolveTestUnit('''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
Widget build(BuildContext context) {
return new Container();
}
}
''');
offset = findOffset('class MyWidget');
_createCorrections();
SourceChange change = await corrections.addForDesignTimeConstructor();
_assertChange(change, r'''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
MyWidget();
factory MyWidget.forDesignTime() {
// TODO: add arguments
return new MyWidget();
}
Widget build(BuildContext context) {
return new Container();
}
}
''');
}
void _assertChange(SourceChange change, String expectedCode) {
expect(change, isNotNull);
List<SourceFileEdit> files = change.edits;
expect(files, hasLength(1));
expect(files[0].file, testFile);
List<SourceEdit> fileEdits = files[0].edits;
String resultCode = SourceEdit.applySequence(testCode, fileEdits);
if (resultCode != expectedCode) {
print(resultCode);
}
expect(resultCode, expectedCode);
}
void _createCorrections() {
corrections = new FlutterCorrections(
resolveResult: testAnalysisResult,
selectionOffset: offset,
selectionLength: length,
);
}
// void _assertChange(SourceChange change, String expectedCode) {
// expect(change, isNotNull);
//
// List<SourceFileEdit> files = change.edits;
// expect(files, hasLength(1));
// expect(files[0].file, testFile);
//
// List<SourceEdit> fileEdits = files[0].edits;
// String resultCode = SourceEdit.applySequence(testCode, fileEdits);
// if (resultCode != expectedCode) {
// print(resultCode);
// }
// expect(resultCode, expectedCode);
// }
//
// void _createCorrections() {
// corrections = new FlutterCorrections(
// resolveResult: testAnalysisResult,
// selectionOffset: offset,
// selectionLength: length,
// );
// }
}

View file

@ -420,276 +420,6 @@ class MyWidget extends StatelessWidget {
''');
}
test_render_BAD_noDesignTimeConstructor() async {
FlutterOutline unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Row();
}
}
''');
var myWidget = unitOutline.children[0];
expect(myWidget.isWidgetClass, isTrue);
expect(myWidget.renderConstructor, isNull);
expect(myWidget.stateClassName, isNull);
expect(myWidget.stateOffset, isNull);
expect(myWidget.stateLength, isNull);
expect(computer.instrumentedCode, isNull);
}
test_render_BAD_notWidget() async {
FlutterOutline unitOutline = await _computeOutline('''
class C {}
''');
var myWidget = unitOutline.children[0];
expect(myWidget.isWidgetClass, isNull);
expect(myWidget.renderConstructor, isNull);
expect(myWidget.stateClassName, isNull);
expect(myWidget.stateOffset, isNull);
expect(myWidget.stateLength, isNull);
expect(computer.instrumentedCode, isNull);
}
test_render_BAD_part() async {
// Use test.dart as a part of a library.
// Add the library to the driver so that it is analyzed before the part.
var libPath = newFile('/home/test/lib/test_lib.dart', content: r'''
part 'test.dart';
import 'package:flutter/widgets.dart';
''').path;
driver.addFile(libPath);
FlutterOutline unitOutline = await _computeOutline('''
part of 'test_lib.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return new Row();
}
}
''');
// Analysis is successful, no errors.
expect(resolveResult.errors, isEmpty);
// No instrumentation, because not a library.
expect(computer.instrumentedCode, isNull);
// There is forDesignTime() constructor, but we don't handle parts.
var myWidget = unitOutline.children[0];
expect(myWidget.isWidgetClass, isNull);
expect(myWidget.renderConstructor, isNull);
}
test_render_instrumentedCode_registerWidgets() async {
await _computeOutline('''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return new Row(
children: <Widget>[
new Text('aaa'),
new Text('bbb'),
],
);
}
}
''');
expect(
computer.instrumentedCode,
r'''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return _registerWidgetInstance(0, new Row(
children: <Widget>[
_registerWidgetInstance(1, new Text('aaa')),
_registerWidgetInstance(2, new Text('bbb')),
],
));
}
}
''' +
FlutterOutlineComputer.RENDER_APPEND);
}
test_render_instrumentedCode_rewriteUri_file() async {
newFile('/home/test/lib/my_lib.dart');
await _computeOutline('''
import 'package:flutter/widgets.dart';
import 'my_lib.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return new Container();
}
}
''');
expect(
computer.instrumentedCode,
'''
import 'package:flutter/widgets.dart';
import 'package:test/my_lib.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return _registerWidgetInstance(0, new Container());
}
}
''' +
FlutterOutlineComputer.RENDER_APPEND);
}
test_render_instrumentedCode_rewriteUri_package() async {
newFile('/home/test/lib/my_lib.dart');
await _computeOutline('''
import 'package:flutter/widgets.dart';
import 'my_lib.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return new Container();
}
}
''');
expect(
computer.instrumentedCode,
'''
import 'package:flutter/widgets.dart';
import 'package:test/my_lib.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return _registerWidgetInstance(0, new Container());
}
}
''' +
FlutterOutlineComputer.RENDER_APPEND);
}
test_render_stateful_createState_blockBody() async {
FlutterOutline unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';
class MyWidget extends StatefulWidget {
MyWidget.forDesignTime();
@override
MyWidgetState createState() {
return new MyWidgetState();
}
}
class MyWidgetState extends State<MyWidget> {
@override
Widget build(BuildContext context) {
return new Container(),
}
}
''');
var myWidget = unitOutline.children[0];
expect(myWidget.renderConstructor, 'forDesignTime');
expect(myWidget.stateClassName, 'MyWidgetState');
expect(myWidget.stateOffset, 192);
expect(myWidget.stateLength, 130);
}
test_render_stateful_createState_expressionBody() async {
FlutterOutline unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';
class MyWidget extends StatefulWidget {
MyWidget.forDesignTime();
@override
MyWidgetState createState() => new MyWidgetState();
}
class MyWidgetState extends State<MyWidget> {
@override
Widget build(BuildContext context) {
return new Container(),
}
}
''');
var myWidget = unitOutline.children[0];
expect(myWidget.isWidgetClass, isTrue);
expect(myWidget.renderConstructor, 'forDesignTime');
expect(myWidget.stateClassName, 'MyWidgetState');
expect(myWidget.stateOffset, 178);
expect(myWidget.stateLength, 130);
}
test_render_stateless() async {
FlutterOutline unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';
class MyWidget extends StatelessWidget {
MyWidget.forDesignTime();
@override
Widget build(BuildContext context) {
return new Row(
children: <Widget>[
new Text('aaa'),
new Text('bbb'),
],
);
}
}
''');
var myWidget = unitOutline.children[0];
expect(myWidget.isWidgetClass, isTrue);
expect(myWidget.renderConstructor, 'forDesignTime');
expect(myWidget.stateClassName, isNull);
expect(myWidget.stateOffset, isNull);
expect(myWidget.stateLength, isNull);
var build = myWidget.children[1];
var row = build.children[0];
expect(row.className, 'Row');
expect(row.id, 0);
var textA = row.children[0];
expect(textA.className, 'Text');
expect(textA.id, 1);
var textB = row.children[1];
expect(textB.className, 'Text');
expect(textB.id, 2);
}
test_variableName() async {
FlutterOutline unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';

View file

@ -778,17 +778,6 @@ public interface AnalysisServer {
*/
public void execution_setSubscriptions(List<String> subscriptions);
/**
* {@code flutter.getChangeAddForDesignTimeConstructor}
*
* Return the change that adds the forDesignTime() constructor for the widget class at the given
* offset.
*
* @param file The file containing the code of the class.
* @param offset The offset of the class in the code.
*/
public void flutter_getChangeAddForDesignTimeConstructor(String file, int offset, GetChangeAddForDesignTimeConstructorConsumer consumer);
/**
* {@code flutter.setSubscriptions}
*

View file

@ -103,47 +103,10 @@ public class FlutterOutline {
*/
private final List<FlutterOutline> children;
/**
* If the node is a widget, and it is instrumented, the unique identifier of this widget, that can
* be used to associate rendering information with this node.
*/
private final Integer id;
/**
* True if the node is a widget class, so it can potentially be rendered, even if it does not yet
* have the rendering constructor. This field is omitted if the node is not a widget class.
*/
private final Boolean isWidgetClass;
/**
* If the node is a widget class that can be rendered for IDE, the name of the constructor that
* should be used to instantiate the widget. Empty string for default constructor. Absent if the
* node is not a widget class that can be rendered.
*/
private final String renderConstructor;
/**
* If the node is a StatefulWidget, and its state class is defined in the same file, the name of
* the state class.
*/
private final String stateClassName;
/**
* If the node is a StatefulWidget that can be rendered, and its state class is defined in the same
* file, the offset of the state class code in the file.
*/
private final Integer stateOffset;
/**
* If the node is a StatefulWidget that can be rendered, and its state class is defined in the same
* file, the length of the state class code in the file.
*/
private final Integer stateLength;
/**
* Constructor for {@link FlutterOutline}.
*/
public FlutterOutline(String kind, int offset, int length, int codeOffset, int codeLength, String label, Element dartElement, List<FlutterOutlineAttribute> attributes, String className, String parentAssociationLabel, String variableName, List<FlutterOutline> children, Integer id, Boolean isWidgetClass, String renderConstructor, String stateClassName, Integer stateOffset, Integer stateLength) {
public FlutterOutline(String kind, int offset, int length, int codeOffset, int codeLength, String label, Element dartElement, List<FlutterOutlineAttribute> attributes, String className, String parentAssociationLabel, String variableName, List<FlutterOutline> children) {
this.kind = kind;
this.offset = offset;
this.length = length;
@ -156,12 +119,6 @@ public class FlutterOutline {
this.parentAssociationLabel = parentAssociationLabel;
this.variableName = variableName;
this.children = children;
this.id = id;
this.isWidgetClass = isWidgetClass;
this.renderConstructor = renderConstructor;
this.stateClassName = stateClassName;
this.stateOffset = stateOffset;
this.stateLength = stateLength;
}
@Override
@ -180,13 +137,7 @@ public class FlutterOutline {
ObjectUtilities.equals(other.className, className) &&
ObjectUtilities.equals(other.parentAssociationLabel, parentAssociationLabel) &&
ObjectUtilities.equals(other.variableName, variableName) &&
ObjectUtilities.equals(other.children, children) &&
ObjectUtilities.equals(other.id, id) &&
ObjectUtilities.equals(other.isWidgetClass, isWidgetClass) &&
ObjectUtilities.equals(other.renderConstructor, renderConstructor) &&
ObjectUtilities.equals(other.stateClassName, stateClassName) &&
ObjectUtilities.equals(other.stateOffset, stateOffset) &&
ObjectUtilities.equals(other.stateLength, stateLength);
ObjectUtilities.equals(other.children, children);
}
return false;
}
@ -204,13 +155,7 @@ public class FlutterOutline {
String parentAssociationLabel = jsonObject.get("parentAssociationLabel") == null ? null : jsonObject.get("parentAssociationLabel").getAsString();
String variableName = jsonObject.get("variableName") == null ? null : jsonObject.get("variableName").getAsString();
List<FlutterOutline> children = jsonObject.get("children") == null ? null : FlutterOutline.fromJsonArray(jsonObject.get("children").getAsJsonArray());
Integer id = jsonObject.get("id") == null ? null : jsonObject.get("id").getAsInt();
Boolean isWidgetClass = jsonObject.get("isWidgetClass") == null ? null : jsonObject.get("isWidgetClass").getAsBoolean();
String renderConstructor = jsonObject.get("renderConstructor") == null ? null : jsonObject.get("renderConstructor").getAsString();
String stateClassName = jsonObject.get("stateClassName") == null ? null : jsonObject.get("stateClassName").getAsString();
Integer stateOffset = jsonObject.get("stateOffset") == null ? null : jsonObject.get("stateOffset").getAsInt();
Integer stateLength = jsonObject.get("stateLength") == null ? null : jsonObject.get("stateLength").getAsInt();
return new FlutterOutline(kind, offset, length, codeOffset, codeLength, label, dartElement, attributes, className, parentAssociationLabel, variableName, children, id, isWidgetClass, renderConstructor, stateClassName, stateOffset, stateLength);
return new FlutterOutline(kind, offset, length, codeOffset, codeLength, label, dartElement, attributes, className, parentAssociationLabel, variableName, children);
}
public static List<FlutterOutline> fromJsonArray(JsonArray jsonArray) {
@ -271,22 +216,6 @@ public class FlutterOutline {
return dartElement;
}
/**
* If the node is a widget, and it is instrumented, the unique identifier of this widget, that can
* be used to associate rendering information with this node.
*/
public Integer getId() {
return id;
}
/**
* True if the node is a widget class, so it can potentially be rendered, even if it does not yet
* have the rendering constructor. This field is omitted if the node is not a widget class.
*/
public Boolean getIsWidgetClass() {
return isWidgetClass;
}
/**
* The kind of the node.
*/
@ -326,39 +255,6 @@ public class FlutterOutline {
return parentAssociationLabel;
}
/**
* If the node is a widget class that can be rendered for IDE, the name of the constructor that
* should be used to instantiate the widget. Empty string for default constructor. Absent if the
* node is not a widget class that can be rendered.
*/
public String getRenderConstructor() {
return renderConstructor;
}
/**
* If the node is a StatefulWidget, and its state class is defined in the same file, the name of
* the state class.
*/
public String getStateClassName() {
return stateClassName;
}
/**
* If the node is a StatefulWidget that can be rendered, and its state class is defined in the same
* file, the length of the state class code in the file.
*/
public Integer getStateLength() {
return stateLength;
}
/**
* If the node is a StatefulWidget that can be rendered, and its state class is defined in the same
* file, the offset of the state class code in the file.
*/
public Integer getStateOffset() {
return stateOffset;
}
/**
* If FlutterOutlineKind.VARIABLE, the name of the variable.
*/
@ -381,12 +277,6 @@ public class FlutterOutline {
builder.append(parentAssociationLabel);
builder.append(variableName);
builder.append(children);
builder.append(id);
builder.append(isWidgetClass);
builder.append(renderConstructor);
builder.append(stateClassName);
builder.append(stateOffset);
builder.append(stateLength);
return builder.toHashCode();
}
@ -426,24 +316,6 @@ public class FlutterOutline {
}
jsonObject.add("children", jsonArrayChildren);
}
if (id != null) {
jsonObject.addProperty("id", id);
}
if (isWidgetClass != null) {
jsonObject.addProperty("isWidgetClass", isWidgetClass);
}
if (renderConstructor != null) {
jsonObject.addProperty("renderConstructor", renderConstructor);
}
if (stateClassName != null) {
jsonObject.addProperty("stateClassName", stateClassName);
}
if (stateOffset != null) {
jsonObject.addProperty("stateOffset", stateOffset);
}
if (stateLength != null) {
jsonObject.addProperty("stateLength", stateLength);
}
return jsonObject;
}
@ -474,19 +346,7 @@ public class FlutterOutline {
builder.append("variableName=");
builder.append(variableName + ", ");
builder.append("children=");
builder.append(StringUtils.join(children, ", ") + ", ");
builder.append("id=");
builder.append(id + ", ");
builder.append("isWidgetClass=");
builder.append(isWidgetClass + ", ");
builder.append("renderConstructor=");
builder.append(renderConstructor + ", ");
builder.append("stateClassName=");
builder.append(stateClassName + ", ");
builder.append("stateOffset=");
builder.append(stateOffset + ", ");
builder.append("stateLength=");
builder.append(stateLength);
builder.append(StringUtils.join(children, ", "));
builder.append("]");
return builder.toString();
}

View file

@ -3141,39 +3141,10 @@
</result>
</request>
</domain>
<domain name="flutter" experimental="true">
<domain name="flutter">
<p>
The analysis domain contains APIs related to Flutter support.
</p>
<request method="getChangeAddForDesignTimeConstructor">
<p>
Return the change that adds the forDesignTime() constructor for the
widget class at the given offset.
</p>
<params>
<field name="file">
<ref>FilePath</ref>
<p>
The file containing the code of the class.
</p>
</field>
<field name="offset">
<ref>int</ref>
<p>
The offset of the class in the code.
</p>
</field>
</params>
<result>
<field name="change">
<ref>SourceChange</ref>
<p>
The change that adds the forDesignTime() constructor.
If the change cannot be produced, an error is returned.
</p>
</field>
</result>
</request>
<request method="setSubscriptions">
<p>
Subscribe for services that are specific to individual files.
@ -3227,7 +3198,7 @@
</field>
</params>
</request>
<notification event="outline" experimental="true">
<notification event="outline">
<p>
Reports the Flutter outline associated with a single file.
</p>
@ -3250,15 +3221,6 @@
The outline associated with the file.
</p>
</field>
<field name="instrumentedCode" optional="true">
<ref>String</ref>
<p>
If the file has Flutter widgets that can be rendered, this field
has the instrumented content of the file, that allows associating
widgets with corresponding outline nodes. If there are no widgets
to render, this field is absent.
</p>
</field>
</params>
</notification>
</domain>
@ -4080,7 +4042,7 @@
<value><code>PART</code></value>
</enum>
</type>
<type name="FlutterService" experimental="true">
<type name="FlutterService">
<p>
An enumeration of the services provided by the flutter domain that
are related to a specific list of files.
@ -4089,7 +4051,7 @@
<value><code>OUTLINE</code></value>
</enum>
</type>
<type name="FlutterOutline" experimental="true">
<type name="FlutterOutline">
<p>
An node in the Flutter specific outline structure of a file.
</p>
@ -4180,57 +4142,9 @@
children.
</p>
</field>
<field name="id" optional="true">
<ref>int</ref>
<p>
If the node is a widget, and it is instrumented, the unique identifier
of this widget, that can be used to associate rendering information
with this node.
</p>
</field>
<field name="isWidgetClass" optional="true">
<ref>bool</ref>
<p>
True if the node is a widget class, so it can potentially be
rendered, even if it does not yet have the rendering constructor.
This field is omitted if the node is not a widget class.
</p>
</field>
<field name="renderConstructor" optional="true">
<ref>String</ref>
<p>
If the node is a widget class that can be rendered for IDE, the name
of the constructor that should be used to instantiate the widget.
Empty string for default constructor. Absent if the node is not a
widget class that can be rendered.
</p>
</field>
<field name="stateClassName" optional="true">
<ref>String</ref>
<p>
If the node is a StatefulWidget, and its state class is defined in
the same file, the name of the state class.
</p>
</field>
<field name="stateOffset" optional="true">
<ref>int</ref>
<p>
If the node is a StatefulWidget that can be rendered, and its state
class is defined in the same file, the offset of the state class code
in the file.
</p>
</field>
<field name="stateLength" optional="true">
<ref>int</ref>
<p>
If the node is a StatefulWidget that can be rendered, and its state
class is defined in the same file, the length of the state class code
in the file.
</p>
</field>
</object>
</type>
<type name="FlutterOutlineAttribute" experimental="true">
<type name="FlutterOutlineAttribute">
<p>
An attribute for a FlutterOutline.
</p>
@ -4271,7 +4185,7 @@
</field>
</object>
</type>
<type name="FlutterOutlineKind" experimental="true">
<type name="FlutterOutlineKind">
<p>
An enumeration of the kinds of FlutterOutline elements. The list of kinds
might be expanded with time, clients must be able to handle new kinds

View file

@ -276,20 +276,9 @@ const String EXECUTION_RESPONSE_MAP_URI_FILE = 'file';
const String EXECUTION_RESPONSE_MAP_URI_URI = 'uri';
const String FLUTTER_NOTIFICATION_OUTLINE = 'flutter.outline';
const String FLUTTER_NOTIFICATION_OUTLINE_FILE = 'file';
const String FLUTTER_NOTIFICATION_OUTLINE_INSTRUMENTED_CODE =
'instrumentedCode';
const String FLUTTER_NOTIFICATION_OUTLINE_OUTLINE = 'outline';
const String FLUTTER_REQUEST_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR =
'flutter.getChangeAddForDesignTimeConstructor';
const String FLUTTER_REQUEST_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR_FILE =
'file';
const String FLUTTER_REQUEST_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR_OFFSET =
'offset';
const String FLUTTER_REQUEST_SET_SUBSCRIPTIONS = 'flutter.setSubscriptions';
const String FLUTTER_REQUEST_SET_SUBSCRIPTIONS_SUBSCRIPTIONS = 'subscriptions';
const String
FLUTTER_RESPONSE_GET_CHANGE_ADD_FOR_DESIGN_TIME_CONSTRUCTOR_CHANGE =
'change';
const String KYTHE_REQUEST_GET_KYTHE_ENTRIES = 'kythe.getKytheEntries';
const String KYTHE_REQUEST_GET_KYTHE_ENTRIES_FILE = 'file';
const String KYTHE_RESPONSE_GET_KYTHE_ENTRIES_ENTRIES = 'entries';

View file

@ -14443,210 +14443,6 @@ class FileKind implements Enum {
String toJson() => name;
}
/**
* flutter.getChangeAddForDesignTimeConstructor params
*
* {
* "file": FilePath
* "offset": int
* }
*
* Clients may not extend, implement or mix-in this class.
*/
class FlutterGetChangeAddForDesignTimeConstructorParams
implements RequestParams {
String _file;
int _offset;
/**
* The file containing the code of the class.
*/
String get file => _file;
/**
* The file containing the code of the class.
*/
void set file(String value) {
assert(value != null);
this._file = value;
}
/**
* The offset of the class in the code.
*/
int get offset => _offset;
/**
* The offset of the class in the code.
*/
void set offset(int value) {
assert(value != null);
this._offset = value;
}
FlutterGetChangeAddForDesignTimeConstructorParams(String file, int offset) {
this.file = file;
this.offset = offset;
}
factory FlutterGetChangeAddForDesignTimeConstructorParams.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object json) {
if (json == null) {
json = {};
}
if (json is Map) {
String file;
if (json.containsKey("file")) {
file = jsonDecoder.decodeString(jsonPath + ".file", json["file"]);
} else {
throw jsonDecoder.mismatch(jsonPath, "file");
}
int offset;
if (json.containsKey("offset")) {
offset = jsonDecoder.decodeInt(jsonPath + ".offset", json["offset"]);
} else {
throw jsonDecoder.mismatch(jsonPath, "offset");
}
return new FlutterGetChangeAddForDesignTimeConstructorParams(
file, offset);
} else {
throw jsonDecoder.mismatch(jsonPath,
"flutter.getChangeAddForDesignTimeConstructor params", json);
}
}
factory FlutterGetChangeAddForDesignTimeConstructorParams.fromRequest(
Request request) {
return new FlutterGetChangeAddForDesignTimeConstructorParams.fromJson(
new RequestDecoder(request), "params", request.params);
}
@override
Map<String, dynamic> toJson() {
Map<String, dynamic> result = {};
result["file"] = file;
result["offset"] = offset;
return result;
}
@override
Request toRequest(String id) {
return new Request(
id, "flutter.getChangeAddForDesignTimeConstructor", toJson());
}
@override
String toString() => json.encode(toJson());
@override
bool operator ==(other) {
if (other is FlutterGetChangeAddForDesignTimeConstructorParams) {
return file == other.file && offset == other.offset;
}
return false;
}
@override
int get hashCode {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, file.hashCode);
hash = JenkinsSmiHash.combine(hash, offset.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
/**
* flutter.getChangeAddForDesignTimeConstructor result
*
* {
* "change": SourceChange
* }
*
* Clients may not extend, implement or mix-in this class.
*/
class FlutterGetChangeAddForDesignTimeConstructorResult
implements ResponseResult {
SourceChange _change;
/**
* The change that adds the forDesignTime() constructor. If the change cannot
* be produced, an error is returned.
*/
SourceChange get change => _change;
/**
* The change that adds the forDesignTime() constructor. If the change cannot
* be produced, an error is returned.
*/
void set change(SourceChange value) {
assert(value != null);
this._change = value;
}
FlutterGetChangeAddForDesignTimeConstructorResult(SourceChange change) {
this.change = change;
}
factory FlutterGetChangeAddForDesignTimeConstructorResult.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object json) {
if (json == null) {
json = {};
}
if (json is Map) {
SourceChange change;
if (json.containsKey("change")) {
change = new SourceChange.fromJson(
jsonDecoder, jsonPath + ".change", json["change"]);
} else {
throw jsonDecoder.mismatch(jsonPath, "change");
}
return new FlutterGetChangeAddForDesignTimeConstructorResult(change);
} else {
throw jsonDecoder.mismatch(jsonPath,
"flutter.getChangeAddForDesignTimeConstructor result", json);
}
}
factory FlutterGetChangeAddForDesignTimeConstructorResult.fromResponse(
Response response) {
return new FlutterGetChangeAddForDesignTimeConstructorResult.fromJson(
new ResponseDecoder(REQUEST_ID_REFACTORING_KINDS.remove(response.id)),
"result",
response.result);
}
@override
Map<String, dynamic> toJson() {
Map<String, dynamic> result = {};
result["change"] = change.toJson();
return result;
}
@override
Response toResponse(String id) {
return new Response(id, result: toJson());
}
@override
String toString() => json.encode(toJson());
@override
bool operator ==(other) {
if (other is FlutterGetChangeAddForDesignTimeConstructorResult) {
return change == other.change;
}
return false;
}
@override
int get hashCode {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, change.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
/**
* FlutterOutline
*
@ -14663,12 +14459,6 @@ class FlutterGetChangeAddForDesignTimeConstructorResult
* "parentAssociationLabel": optional String
* "variableName": optional String
* "children": optional List<FlutterOutline>
* "id": optional int
* "isWidgetClass": optional bool
* "renderConstructor": optional String
* "stateClassName": optional String
* "stateOffset": optional int
* "stateLength": optional int
* }
*
* Clients may not extend, implement or mix-in this class.
@ -14698,18 +14488,6 @@ class FlutterOutline implements HasToJson {
List<FlutterOutline> _children;
int _id;
bool _isWidgetClass;
String _renderConstructor;
String _stateClassName;
int _stateOffset;
int _stateLength;
/**
* The kind of the node.
*/
@ -14881,102 +14659,6 @@ class FlutterOutline implements HasToJson {
this._children = value;
}
/**
* If the node is a widget, and it is instrumented, the unique identifier of
* this widget, that can be used to associate rendering information with this
* node.
*/
int get id => _id;
/**
* If the node is a widget, and it is instrumented, the unique identifier of
* this widget, that can be used to associate rendering information with this
* node.
*/
void set id(int value) {
this._id = value;
}
/**
* True if the node is a widget class, so it can potentially be rendered,
* even if it does not yet have the rendering constructor. This field is
* omitted if the node is not a widget class.
*/
bool get isWidgetClass => _isWidgetClass;
/**
* True if the node is a widget class, so it can potentially be rendered,
* even if it does not yet have the rendering constructor. This field is
* omitted if the node is not a widget class.
*/
void set isWidgetClass(bool value) {
this._isWidgetClass = value;
}
/**
* If the node is a widget class that can be rendered for IDE, the name of
* the constructor that should be used to instantiate the widget. Empty
* string for default constructor. Absent if the node is not a widget class
* that can be rendered.
*/
String get renderConstructor => _renderConstructor;
/**
* If the node is a widget class that can be rendered for IDE, the name of
* the constructor that should be used to instantiate the widget. Empty
* string for default constructor. Absent if the node is not a widget class
* that can be rendered.
*/
void set renderConstructor(String value) {
this._renderConstructor = value;
}
/**
* If the node is a StatefulWidget, and its state class is defined in the
* same file, the name of the state class.
*/
String get stateClassName => _stateClassName;
/**
* If the node is a StatefulWidget, and its state class is defined in the
* same file, the name of the state class.
*/
void set stateClassName(String value) {
this._stateClassName = value;
}
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the offset of the state class code in the
* file.
*/
int get stateOffset => _stateOffset;
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the offset of the state class code in the
* file.
*/
void set stateOffset(int value) {
this._stateOffset = value;
}
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the length of the state class code in the
* file.
*/
int get stateLength => _stateLength;
/**
* If the node is a StatefulWidget that can be rendered, and its state class
* is defined in the same file, the length of the state class code in the
* file.
*/
void set stateLength(int value) {
this._stateLength = value;
}
FlutterOutline(FlutterOutlineKind kind, int offset, int length,
int codeOffset, int codeLength,
{String label,
@ -14985,13 +14667,7 @@ class FlutterOutline implements HasToJson {
String className,
String parentAssociationLabel,
String variableName,
List<FlutterOutline> children,
int id,
bool isWidgetClass,
String renderConstructor,
String stateClassName,
int stateOffset,
int stateLength}) {
List<FlutterOutline> children}) {
this.kind = kind;
this.offset = offset;
this.length = length;
@ -15004,12 +14680,6 @@ class FlutterOutline implements HasToJson {
this.parentAssociationLabel = parentAssociationLabel;
this.variableName = variableName;
this.children = children;
this.id = id;
this.isWidgetClass = isWidgetClass;
this.renderConstructor = renderConstructor;
this.stateClassName = stateClassName;
this.stateOffset = stateOffset;
this.stateLength = stateLength;
}
factory FlutterOutline.fromJson(
@ -15093,35 +14763,6 @@ class FlutterOutline implements HasToJson {
(String jsonPath, Object json) =>
new FlutterOutline.fromJson(jsonDecoder, jsonPath, json));
}
int id;
if (json.containsKey("id")) {
id = jsonDecoder.decodeInt(jsonPath + ".id", json["id"]);
}
bool isWidgetClass;
if (json.containsKey("isWidgetClass")) {
isWidgetClass = jsonDecoder.decodeBool(
jsonPath + ".isWidgetClass", json["isWidgetClass"]);
}
String renderConstructor;
if (json.containsKey("renderConstructor")) {
renderConstructor = jsonDecoder.decodeString(
jsonPath + ".renderConstructor", json["renderConstructor"]);
}
String stateClassName;
if (json.containsKey("stateClassName")) {
stateClassName = jsonDecoder.decodeString(
jsonPath + ".stateClassName", json["stateClassName"]);
}
int stateOffset;
if (json.containsKey("stateOffset")) {
stateOffset = jsonDecoder.decodeInt(
jsonPath + ".stateOffset", json["stateOffset"]);
}
int stateLength;
if (json.containsKey("stateLength")) {
stateLength = jsonDecoder.decodeInt(
jsonPath + ".stateLength", json["stateLength"]);
}
return new FlutterOutline(kind, offset, length, codeOffset, codeLength,
label: label,
dartElement: dartElement,
@ -15129,13 +14770,7 @@ class FlutterOutline implements HasToJson {
className: className,
parentAssociationLabel: parentAssociationLabel,
variableName: variableName,
children: children,
id: id,
isWidgetClass: isWidgetClass,
renderConstructor: renderConstructor,
stateClassName: stateClassName,
stateOffset: stateOffset,
stateLength: stateLength);
children: children);
} else {
throw jsonDecoder.mismatch(jsonPath, "FlutterOutline", json);
}
@ -15173,24 +14808,6 @@ class FlutterOutline implements HasToJson {
result["children"] =
children.map((FlutterOutline value) => value.toJson()).toList();
}
if (id != null) {
result["id"] = id;
}
if (isWidgetClass != null) {
result["isWidgetClass"] = isWidgetClass;
}
if (renderConstructor != null) {
result["renderConstructor"] = renderConstructor;
}
if (stateClassName != null) {
result["stateClassName"] = stateClassName;
}
if (stateOffset != null) {
result["stateOffset"] = stateOffset;
}
if (stateLength != null) {
result["stateLength"] = stateLength;
}
return result;
}
@ -15216,13 +14833,7 @@ class FlutterOutline implements HasToJson {
parentAssociationLabel == other.parentAssociationLabel &&
variableName == other.variableName &&
listEqual(children, other.children,
(FlutterOutline a, FlutterOutline b) => a == b) &&
id == other.id &&
isWidgetClass == other.isWidgetClass &&
renderConstructor == other.renderConstructor &&
stateClassName == other.stateClassName &&
stateOffset == other.stateOffset &&
stateLength == other.stateLength;
(FlutterOutline a, FlutterOutline b) => a == b);
}
return false;
}
@ -15242,12 +14853,6 @@ class FlutterOutline implements HasToJson {
hash = JenkinsSmiHash.combine(hash, parentAssociationLabel.hashCode);
hash = JenkinsSmiHash.combine(hash, variableName.hashCode);
hash = JenkinsSmiHash.combine(hash, children.hashCode);
hash = JenkinsSmiHash.combine(hash, id.hashCode);
hash = JenkinsSmiHash.combine(hash, isWidgetClass.hashCode);
hash = JenkinsSmiHash.combine(hash, renderConstructor.hashCode);
hash = JenkinsSmiHash.combine(hash, stateClassName.hashCode);
hash = JenkinsSmiHash.combine(hash, stateOffset.hashCode);
hash = JenkinsSmiHash.combine(hash, stateLength.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
@ -15555,7 +15160,6 @@ class FlutterOutlineKind implements Enum {
* {
* "file": FilePath
* "outline": FlutterOutline
* "instrumentedCode": optional String
* }
*
* Clients may not extend, implement or mix-in this class.
@ -15565,8 +15169,6 @@ class FlutterOutlineParams implements HasToJson {
FlutterOutline _outline;
String _instrumentedCode;
/**
* The file with which the outline is associated.
*/
@ -15593,29 +15195,9 @@ class FlutterOutlineParams implements HasToJson {
this._outline = value;
}
/**
* If the file has Flutter widgets that can be rendered, this field has the
* instrumented content of the file, that allows associating widgets with
* corresponding outline nodes. If there are no widgets to render, this field
* is absent.
*/
String get instrumentedCode => _instrumentedCode;
/**
* If the file has Flutter widgets that can be rendered, this field has the
* instrumented content of the file, that allows associating widgets with
* corresponding outline nodes. If there are no widgets to render, this field
* is absent.
*/
void set instrumentedCode(String value) {
this._instrumentedCode = value;
}
FlutterOutlineParams(String file, FlutterOutline outline,
{String instrumentedCode}) {
FlutterOutlineParams(String file, FlutterOutline outline) {
this.file = file;
this.outline = outline;
this.instrumentedCode = instrumentedCode;
}
factory FlutterOutlineParams.fromJson(
@ -15637,13 +15219,7 @@ class FlutterOutlineParams implements HasToJson {
} else {
throw jsonDecoder.mismatch(jsonPath, "outline");
}
String instrumentedCode;
if (json.containsKey("instrumentedCode")) {
instrumentedCode = jsonDecoder.decodeString(
jsonPath + ".instrumentedCode", json["instrumentedCode"]);
}
return new FlutterOutlineParams(file, outline,
instrumentedCode: instrumentedCode);
return new FlutterOutlineParams(file, outline);
} else {
throw jsonDecoder.mismatch(jsonPath, "flutter.outline params", json);
}
@ -15659,9 +15235,6 @@ class FlutterOutlineParams implements HasToJson {
Map<String, dynamic> result = {};
result["file"] = file;
result["outline"] = outline.toJson();
if (instrumentedCode != null) {
result["instrumentedCode"] = instrumentedCode;
}
return result;
}
@ -15675,9 +15248,7 @@ class FlutterOutlineParams implements HasToJson {
@override
bool operator ==(other) {
if (other is FlutterOutlineParams) {
return file == other.file &&
outline == other.outline &&
instrumentedCode == other.instrumentedCode;
return file == other.file && outline == other.outline;
}
return false;
}
@ -15687,7 +15258,6 @@ class FlutterOutlineParams implements HasToJson {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, file.hashCode);
hash = JenkinsSmiHash.combine(hash, outline.hashCode);
hash = JenkinsSmiHash.combine(hash, instrumentedCode.hashCode);
return JenkinsSmiHash.finish(hash);
}
}