Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: lib/merge.ts

Issue 2416003003: Update package name, update and lock clang-format and tslint versions, and format all source files … (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/main.ts ('k') | lib/type.ts » ('j') | package.json » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import ts = require('typescript'); 1 import ts = require('typescript');
2 import base = require('./base'); 2 import base = require('./base');
3 import {FacadeConverter} from './facade_converter'; 3 import {FacadeConverter} from './facade_converter';
4 4
5 /** 5 /**
6 * To support arbitrary d.ts files in Dart we often have to merge two TypeScript 6 * To support arbitrary d.ts files in Dart we often have to merge two TypeScript
7 * types into a single Dart type because Dart lacks features such as method 7 * types into a single Dart type because Dart lacks features such as method
8 * overloads, type aliases, and union types. 8 * overloads, type aliases, and union types.
9 */ 9 */
10 export class MergedType { 10 export class MergedType {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 nameIdentifier.text = Object.getOwnPropertyNames(this.name).join('_'); 125 nameIdentifier.text = Object.getOwnPropertyNames(this.name).join('_');
126 ret.name = nameIdentifier; 126 ret.name = nameIdentifier;
127 if (this.optional) { 127 if (this.optional) {
128 ret.questionToken = ts.createNode(ts.SyntaxKind.QuestionToken); 128 ret.questionToken = ts.createNode(ts.SyntaxKind.QuestionToken);
129 } 129 }
130 base.copyLocation(this.textRange, ret); 130 base.copyLocation(this.textRange, ret);
131 ret.type = this.type.toTypeNode(); 131 ret.type = this.type.toTypeNode();
132 return ret; 132 return ret;
133 } 133 }
134 134
135 setOptional() { this.optional = true; } 135 setOptional() {
136 this.optional = true;
137 }
136 138
137 private name: {[s: string]: boolean} = {}; 139 private name: {[s: string]: boolean} = {};
138 private type: MergedType; 140 private type: MergedType;
139 private optional: boolean = false; 141 private optional: boolean = false;
140 private textRange: ts.TextRange; 142 private textRange: ts.TextRange;
141 } 143 }
142 144
143 /** 145 /**
144 * Handle a parameter that is the result of merging parameter declarations from 146 * Handle a parameter that is the result of merging parameter declarations from
145 * multiple method overloads. 147 * multiple method overloads.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // In JavaScript you could just write new X() and create an 303 // In JavaScript you could just write new X() and create an
302 // instance of XStatic. We don't 304 // instance of XStatic. We don't
303 let typeRef = type as ts.TypeReferenceNode; 305 let typeRef = type as ts.TypeReferenceNode;
304 let typeName = typeRef.typeName; 306 let typeName = typeRef.typeName;
305 let symbol = fc.tc.getSymbolAtLocation(typeName); 307 let symbol = fc.tc.getSymbolAtLocation(typeName);
306 if (symbol == null) return; 308 if (symbol == null) return;
307 let decl = fc.getSymbolDeclaration(symbol, typeName); 309 let decl = fc.getSymbolDeclaration(symbol, typeName);
308 if (decl == null) return; 310 if (decl == null) return;
309 if (decl.kind !== ts.SyntaxKind.InterfaceDeclaration) return; 311 if (decl.kind !== ts.SyntaxKind.InterfaceDeclaration) return;
310 let interfaceDecl = decl as base.ExtendedInterfaceDeclaration; 312 let interfaceDecl = decl as base.ExtendedInterfaceDeclaration;
311 if (!interfaceDecl.members.some( 313 if (!interfaceDecl.members.some((member) => {
312 (member) => { return member.kind === ts.SyntaxKind.Const ructSignature; })) 314 return member.kind === ts.SyntaxKind.ConstructSignature;
315 }))
313 return; 316 return;
314 317
315 if (interfaceDecl.classLikeVariableDeclaration == null) { 318 if (interfaceDecl.classLikeVariableDeclaration == null) {
316 // We could add extra logic to be safer such as only infering that variable names 319 // We could add extra logic to be safer such as only infering that variable names
317 // are class like for cases where variable names are UpperCame lCase matching JS 320 // are class like for cases where variable names are UpperCame lCase matching JS
318 // conventions that a variable is a Class definition. 321 // conventions that a variable is a Class definition.
319 interfaceDecl.classLikeVariableDeclaration = declaration; 322 interfaceDecl.classLikeVariableDeclaration = declaration;
320 } 323 }
321 } 324 }
322 } 325 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 break; 486 break;
484 case ts.SyntaxKind.ModuleBlock: 487 case ts.SyntaxKind.ModuleBlock:
485 ts.forEachChild(n, (child) => gatherClasses(child, classes)); 488 ts.forEachChild(n, (child) => gatherClasses(child, classes));
486 break; 489 break;
487 default: 490 default:
488 break; 491 break;
489 } 492 }
490 } 493 }
491 gatherClasses(f, {}); 494 gatherClasses(f, {});
492 } 495 }
OLDNEW
« no previous file with comments | « lib/main.ts ('k') | lib/type.ts » ('j') | package.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698