| OLD | NEW |
| 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 library entities; | 5 library entities; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 | 8 |
| 9 /// Abstract interface for entities. | 9 /// Abstract interface for entities. |
| 10 /// | 10 /// |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 abstract class FieldEntity extends MemberEntity {} | 112 abstract class FieldEntity extends MemberEntity {} |
| 113 | 113 |
| 114 /// Stripped down super interface for function like entities. | 114 /// Stripped down super interface for function like entities. |
| 115 /// | 115 /// |
| 116 /// Currently only [MethodElement] but later also kernel based Dart constructors | 116 /// Currently only [MethodElement] but later also kernel based Dart constructors |
| 117 /// and methods and/or Dart-in-JS function-like properties. | 117 /// and methods and/or Dart-in-JS function-like properties. |
| 118 abstract class FunctionEntity extends MemberEntity { | 118 abstract class FunctionEntity extends MemberEntity { |
| 119 /// Whether this function is external, i.e. the body is not defined in terms | 119 /// Whether this function is external, i.e. the body is not defined in terms |
| 120 /// of Dart code. | 120 /// of Dart code. |
| 121 bool get isExternal; | 121 bool get isExternal; |
| 122 |
| 123 /// The structure of the function parameters. |
| 124 ParameterStructure get parameterStructure; |
| 122 } | 125 } |
| 123 | 126 |
| 124 /// Stripped down super interface for constructor like entities. | 127 /// Stripped down super interface for constructor like entities. |
| 125 /// | 128 /// |
| 126 /// Currently only [ConstructorElement] but later also kernel based Dart | 129 /// Currently only [ConstructorElement] but later also kernel based Dart |
| 127 /// constructors and/or Dart-in-JS constructor-like properties. | 130 /// constructors and/or Dart-in-JS constructor-like properties. |
| 128 // TODO(johnniwinther): Remove factory constructors from the set of | 131 // TODO(johnniwinther): Remove factory constructors from the set of |
| 129 // constructors. | 132 // constructors. |
| 130 abstract class ConstructorEntity extends FunctionEntity { | 133 abstract class ConstructorEntity extends FunctionEntity { |
| 131 /// Whether this is a generative constructor, possibly redirecting. | 134 /// Whether this is a generative constructor, possibly redirecting. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 151 Entity get executableContext; | 154 Entity get executableContext; |
| 152 | 155 |
| 153 /// The outermost member that contains this element. | 156 /// The outermost member that contains this element. |
| 154 /// | 157 /// |
| 155 /// For top level, static or instance members, the member context is the | 158 /// For top level, static or instance members, the member context is the |
| 156 /// element itself. For parameters, local variables and nested closures, the | 159 /// element itself. For parameters, local variables and nested closures, the |
| 157 /// member context is the top level, static or instance member in which it is | 160 /// member context is the top level, static or instance member in which it is |
| 158 /// defined. | 161 /// defined. |
| 159 MemberEntity get memberContext; | 162 MemberEntity get memberContext; |
| 160 } | 163 } |
| 164 |
| 165 /// The structure of function parameters. |
| 166 class ParameterStructure { |
| 167 /// The number of required (positional) parameters. |
| 168 final int requiredParameters; |
| 169 |
| 170 /// The number of positional parameters. |
| 171 final int positionalParameters; |
| 172 |
| 173 /// The named parameters sorted alphabetically. |
| 174 final List<String> namedParameters; |
| 175 |
| 176 const ParameterStructure( |
| 177 this.requiredParameters, this.positionalParameters, this.namedParameters); |
| 178 |
| 179 const ParameterStructure.getter() : this(0, 0, const <String>[]); |
| 180 |
| 181 const ParameterStructure.setter() : this(1, 1, const <String>[]); |
| 182 |
| 183 /// The number of optional parameters (positional or named). |
| 184 int get optionalParameters => |
| 185 positionalParameters - requiredParameters + namedParameters.length; |
| 186 } |
| OLD | NEW |