| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /** | 5 /** |
| 6 * This file contains code to generate serialization/deserialization logic for | 6 * This file contains code to generate serialization/deserialization logic for |
| 7 * summaries based on an "IDL" description of the summary format (written in | 7 * summaries based on an "IDL" description of the summary format (written in |
| 8 * stylized Dart). | 8 * stylized Dart). |
| 9 * | 9 * |
| 10 * For each class in the "IDL" input, two corresponding classes are generated: | 10 * For each class in the "IDL" input, two corresponding classes are generated: |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 _idl.classes[clsName] = cls; | 261 _idl.classes[clsName] = cls; |
| 262 String expectedBase = 'base.SummaryClass'; | 262 String expectedBase = 'base.SummaryClass'; |
| 263 if (decl.extendsClause == null || | 263 if (decl.extendsClause == null || |
| 264 decl.extendsClause.superclass.name.name != expectedBase) { | 264 decl.extendsClause.superclass.name.name != expectedBase) { |
| 265 throw new Exception( | 265 throw new Exception( |
| 266 'Class `$clsName` needs to extend `$expectedBase`'); | 266 'Class `$clsName` needs to extend `$expectedBase`'); |
| 267 } | 267 } |
| 268 for (ClassMember classMember in decl.members) { | 268 for (ClassMember classMember in decl.members) { |
| 269 if (classMember is MethodDeclaration && classMember.isGetter) { | 269 if (classMember is MethodDeclaration && classMember.isGetter) { |
| 270 String desc = '$clsName.${classMember.name.name}'; | 270 String desc = '$clsName.${classMember.name.name}'; |
| 271 if (classMember.returnType is! TypeName) { |
| 272 if (classMember.returnType == null) { |
| 273 throw new Exception('Class member needs a type: $desc'); |
| 274 } |
| 275 throw new Exception('Class member needs a class type: $desc'); |
| 276 } |
| 271 TypeName type = classMember.returnType; | 277 TypeName type = classMember.returnType; |
| 272 if (type == null) { | |
| 273 throw new Exception('Class member needs a type: $desc'); | |
| 274 } | |
| 275 bool isList = false; | 278 bool isList = false; |
| 276 if (type.name.name == 'List' && | 279 if (type.name.name == 'List' && |
| 277 type.typeArguments != null && | 280 type.typeArguments != null && |
| 278 type.typeArguments.arguments.length == 1) { | 281 type.typeArguments.arguments.length == 1) { |
| 279 isList = true; | 282 isList = true; |
| 280 type = type.typeArguments.arguments[0]; | 283 type = type.typeArguments.arguments[0]; |
| 281 } | 284 } |
| 282 if (type.typeArguments != null) { | 285 if (type.typeArguments != null) { |
| 283 throw new Exception('Cannot handle type arguments in `$type`'); | 286 throw new Exception('Cannot handle type arguments in `$type`'); |
| 284 } | 287 } |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 return token.lexeme.split('\n').map((String line) { | 1027 return token.lexeme.split('\n').map((String line) { |
| 1025 if (line.startsWith(indent)) { | 1028 if (line.startsWith(indent)) { |
| 1026 line = line.substring(indent.length); | 1029 line = line.substring(indent.length); |
| 1027 } | 1030 } |
| 1028 return line; | 1031 return line; |
| 1029 }).join('\n'); | 1032 }).join('\n'); |
| 1030 } | 1033 } |
| 1031 return null; | 1034 return null; |
| 1032 } | 1035 } |
| 1033 } | 1036 } |
| OLD | NEW |