"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/dgeni/common/class-inheritance.ts" between
components-12.0.3.tar.gz and components-12.0.4.tar.gz

About: components offers Component infrastructure and Material Design components for Angular.

class-inheritance.ts  (components-12.0.3):class-inheritance.ts  (components-12.0.4)
// tslint:disable:no-bitwise // tslint:disable:no-bitwise
import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc';
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExpor tDoc'; import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExpor tDoc';
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassL ikeExportDoc'; import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassL ikeExportDoc';
import {InterfaceExportDoc} from 'dgeni-packages/typescript/api-doc-types/Interf aceExportDoc'; import {InterfaceExportDoc} from 'dgeni-packages/typescript/api-doc-types/Interf aceExportDoc';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
/** Type describing class like documents which have been created through inherit
ance. */
export type InheritanceCreatedClassLikeDoc = ClassLikeExportDoc &
{_inheritanceCreated?: true};
/** Whether the given API doc has been created through inheritance. */
export function isInheritanceCreatedDoc(doc: ApiDoc): doc is ClassLikeExportDoc
{
// For member docs, we look if the containing API doc has been created through
// inheritance.
if (doc instanceof MemberDoc) {
return isInheritanceCreatedDoc(doc.containerDoc);
}
return doc instanceof ClassLikeExportDoc &&
(doc as InheritanceCreatedClassLikeDoc)._inheritanceCreated === true;
}
/** Gets all class like export documents which the given doc inherits from. */ /** Gets all class like export documents which the given doc inherits from. */
export function getInheritedDocsOfClass( export function getInheritedDocsOfClass(
doc: ClassLikeExportDoc, doc: ClassLikeExportDoc,
exportSymbolsToDocsMap: Map<ts.Symbol, ClassLikeExportDoc>): ClassLikeExport Doc[] { exportSymbolsToDocsMap: Map<ts.Symbol, ClassLikeExportDoc>): ClassLikeExport Doc[] {
const result: ClassLikeExportDoc[] = []; const result: ClassLikeExportDoc[] = [];
const typeChecker = doc.typeChecker; const typeChecker = doc.typeChecker;
for (let info of doc.extendsClauses) { for (let info of doc.extendsClauses) {
if (info.doc) { if (info.doc) {
result.push(info.doc, ...getInheritedDocsOfClass(info.doc, exportSymbolsTo DocsMap)); result.push(info.doc, ...getInheritedDocsOfClass(info.doc, exportSymbolsTo DocsMap));
skipping to change at line 66 skipping to change at line 84
(res, t) => [...res, ...getClassLikeDocsFromType(t, baseDoc, exportSymbo lsToDocsMap)], (res, t) => [...res, ...getClassLikeDocsFromType(t, baseDoc, exportSymbo lsToDocsMap)],
[] as ClassLikeExportDoc[]); [] as ClassLikeExportDoc[]);
} else if (symbol) { } else if (symbol) {
// If the given symbol has already been registered within Dgeni, we use the // If the given symbol has already been registered within Dgeni, we use the
// existing symbol instead of creating a new one. The dgeni typescript packa ge // existing symbol instead of creating a new one. The dgeni typescript packa ge
// keeps track of all exported symbols and their corresponding docs. See: // keeps track of all exported symbols and their corresponding docs. See:
// dgeni-packages/blob/master/typescript/src/processors/linkInheritedDocs.ts // dgeni-packages/blob/master/typescript/src/processors/linkInheritedDocs.ts
if (exportSymbolsToDocsMap.has(symbol)) { if (exportSymbolsToDocsMap.has(symbol)) {
return [exportSymbolsToDocsMap.get(symbol)!]; return [exportSymbolsToDocsMap.get(symbol)!];
} }
let createdDoc: ClassLikeExportDoc|null = null; let createdDoc: InheritanceCreatedClassLikeDoc|null = null;
if ((symbol.flags & ts.SymbolFlags.Class) !== 0) { if ((symbol.flags & ts.SymbolFlags.Class) !== 0) {
createdDoc = new ClassExportDoc(baseDoc.host, baseDoc.moduleDoc, symbol, a liasSymbol); createdDoc = new ClassExportDoc(baseDoc.host, baseDoc.moduleDoc, symbol, a liasSymbol);
} else if ((symbol.flags & ts.SymbolFlags.Interface) !== 0) { } else if ((symbol.flags & ts.SymbolFlags.Interface) !== 0) {
createdDoc = new InterfaceExportDoc(baseDoc.host, baseDoc.moduleDoc, symbo l, aliasSymbol); createdDoc = new InterfaceExportDoc(baseDoc.host, baseDoc.moduleDoc, symbo l, aliasSymbol);
} }
// If a new document has been created, add it to the shared symbol
// docs map and return it.
if (createdDoc) { if (createdDoc) {
// Mark the created document. This allows us to distinguish between docume
nts which
// have been resolved by Dgeni automatically, and docs which are manually
resolved.
createdDoc._inheritanceCreated = true;
// If a new document has been created, add it to the shared symbol.
exportSymbolsToDocsMap.set(aliasSymbol || symbol, createdDoc); exportSymbolsToDocsMap.set(aliasSymbol || symbol, createdDoc);
return [createdDoc]; return [createdDoc];
} }
} }
return []; return [];
} }
 End of changes. 5 change blocks. 
3 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)