Skip to content

Commit 89c7834

Browse files
committed
Fix flutter
1 parent 9de0f86 commit 89c7834

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

lib/src/model.dart

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,29 @@ class Accessor extends ModelElement
269269
}
270270

271271
GetterSetterCombo get enclosingCombo {
272-
if (_enclosingCombo == null) if (enclosingElement is Class) {
273-
// TODO(jcollins-g): this side effect is rather hacky. Make sure
274-
// enclosingCombo always gets set at accessor creation time, somehow, to
275-
// avoid this.
276-
// TODO(jcollins-g): This also doesn't work for private accessors sometimes.
277-
(enclosingElement as Class).allInstanceProperties;
278-
}
279-
assert(_enclosingCombo != null);
272+
if (_enclosingCombo == null) {
273+
if (enclosingElement is Class) {
274+
// TODO(jcollins-g): this side effect is rather hacky. Make sure
275+
// enclosingCombo always gets set at accessor creation time, somehow, to
276+
// avoid this.
277+
// TODO(jcollins-g): This also doesn't work for private accessors sometimes.
278+
(enclosingElement as Class).allFields;
279+
}
280+
/*
281+
if (_enclosingCombo == null && isSynthetic) {
282+
// Synthetic accessors sometimes don't have enclosing combos. Pretend
283+
// for hyperlinks.
284+
1+1;
285+
}*/
286+
assert(_enclosingCombo != null);
287+
}
280288
return _enclosingCombo;
281289
}
282290

283291
/// Call exactly once to set the enclosing combo for this Accessor.
284-
void set enclosingCombo(GetterSetterCombo combo) {
292+
set enclosingCombo(GetterSetterCombo combo) {
285293
assert(_enclosingCombo == null || combo == _enclosingCombo);
294+
assert(combo != null);
286295
_enclosingCombo = combo;
287296
}
288297

@@ -310,10 +319,7 @@ class Accessor extends ModelElement
310319
@override
311320
String get computeDocumentationComment {
312321
if (isSynthetic) {
313-
String docComment = new ModelElement.fromElement(
314-
(element as PropertyAccessorElement).variable, package)
315-
.element
316-
.documentationComment;
322+
String docComment = (element as PropertyAccessorElement).variable.documentationComment;
317323
// If we're a setter, only display something if we have something different than the getter.
318324
// TODO(jcollins-g): modify analyzer to do this itself?
319325
if (isGetter ||
@@ -534,7 +540,7 @@ class Class extends ModelElement
534540

535541
List<Field> get constants {
536542
if (_constants != null) return _constants;
537-
_constants = _allFields.where((f) => f.isConst).toList(growable: false)
543+
_constants = allFields.where((f) => f.isConst).toList(growable: false)
538544
..sort(byName);
539545

540546
return _constants;
@@ -802,7 +808,7 @@ class Class extends ModelElement
802808

803809
List<Field> get inheritedProperties {
804810
if (_inheritedProperties == null) {
805-
_inheritedProperties = _allFields.where((f) => f.isInherited).toList()
811+
_inheritedProperties = allFields.where((f) => f.isInherited).toList()
806812
..sort(byName);
807813
}
808814
return _inheritedProperties;
@@ -827,7 +833,7 @@ class Class extends ModelElement
827833

828834
List<Field> get instanceProperties {
829835
if (_instanceFields != null) return _instanceFields;
830-
_instanceFields = _allFields
836+
_instanceFields = allFields
831837
.where((f) => !f.isStatic && !f.isInherited && !f.isConst)
832838
.toList(growable: false)
833839
..sort(byName);
@@ -924,7 +930,7 @@ class Class extends ModelElement
924930

925931
List<Field> get staticProperties {
926932
if (_staticFields != null) return _staticFields;
927-
_staticFields = _allFields
933+
_staticFields = allFields
928934
.where((f) => f.isStatic)
929935
.where((f) => !f.isConst)
930936
.toList(growable: false)
@@ -981,7 +987,7 @@ class Class extends ModelElement
981987

982988
ElementType get supertype => _supertype;
983989

984-
List<Field> get _allFields {
990+
List<Field> get allFields {
985991
if (_fields != null) return _fields;
986992
_fields = [];
987993
Map<String, ExecutableElement> cmap =
@@ -1090,6 +1096,8 @@ class Class extends ModelElement
10901096
// TODO(jcollins-g): Navigation is probably still confusing for
10911097
// half-inherited fields when traversing the inheritance tree. Make
10921098
// this better, somehow.
1099+
if (f.name == 'target' && name == 'HitTestEntry')
1100+
1+1;
10931101
field = new ModelElement.from(f, library, getter: getter, setter: setter);
10941102
}
10951103
_fields.add(field);
@@ -2610,6 +2618,8 @@ abstract class ModelElement extends Canonicalization
26102618
} else if (e.enclosingElement.isEnum) {
26112619
newModelElement = new EnumField(e, library, getter, setter);
26122620
} else {
2621+
if (e.name == 'target' && e.enclosingElement.name == 'HitTestEntry' && library.name == 'hit_test')
2622+
1+1;
26132623
newModelElement = new Field(e, library, getter, setter);
26142624
}
26152625
} else {
@@ -2642,6 +2652,8 @@ abstract class ModelElement extends Canonicalization
26422652
..addAll(library.constants);
26432653
newModelElement = allVariables.firstWhere((v) => v.element == e);
26442654
} else {
2655+
if (e.name == 'kAlwaysDismissedAnimation')
2656+
1+1;
26452657
newModelElement = new TopLevelVariable(e, library, getter, setter);
26462658
}
26472659
}
@@ -2683,10 +2695,7 @@ abstract class ModelElement extends Canonicalization
26832695
}
26842696
}
26852697
if (newModelElement is GetterSetterCombo) {
2686-
if (getter != null) {
2687-
assert(
2688-
getter == null || newModelElement?.getter?.enclosingCombo != null);
2689-
}
2698+
assert(getter == null || newModelElement?.getter?.enclosingCombo != null);
26902699
assert(setter == null || newModelElement?.setter?.enclosingCombo != null);
26912700
}
26922701

@@ -4726,8 +4735,14 @@ class TopLevelVariable extends ModelElement
47264735
TopLevelVariable(TopLevelVariableElement element, Library library,
47274736
this.getter, this.setter)
47284737
: super(element, library, null) {
4729-
if (getter != null) getter.enclosingCombo = this;
4730-
if (setter != null) setter.enclosingCombo = this;
4738+
if (getter != null) {
4739+
getter.enclosingCombo = this;
4740+
assert(getter.enclosingCombo != null);
4741+
}
4742+
if (setter != null) {
4743+
setter.enclosingCombo = this;
4744+
assert(setter.enclosingCombo != null);
4745+
}
47314746
}
47324747

47334748
@override

lib/src/warnings.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ abstract class Locatable {
9999
Tuple2<int, int> get lineAndColumn;
100100

101101
Set<String> get locationPieces {
102-
return new Set()
103-
..addAll(element.location
102+
return new Set.from(element.location
104103
.toString()
105104
.split(locationSplitter)
106105
.where((s) => s.isNotEmpty));

0 commit comments

Comments
 (0)