Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INTERNAL] lib/processors/jsdoc: enhance list of built-in types and remove direct usage of taffydb #883

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/processors/jsdoc/lib/transformApiJson.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,10 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
"array",
"element",
"Element",
"Date",
"DomRef",
"jQuery.promise",
"QUnit.Assert",
"object",
"Object",
"object[]",
Expand Down
55 changes: 29 additions & 26 deletions lib/processors/jsdoc/lib/ui5/template/publish.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let conf = {};

let view;

let __db;
let __symbols;
let __longnames;
let __missingLongnames = {};

Expand Down Expand Up @@ -120,12 +120,10 @@ function merge(target, source) {
return target;
}

function lookup(longname /*, variant*/) {
let key = longname; // variant ? longname + "|" + variant : longname;
function lookup(key) {
if ( !Object.prototype.hasOwnProperty.call(__longnames, key) ) {
__missingLongnames[key] = (__missingLongnames[key] || 0) + 1;
let oResult = __db({longname: longname /*, variant: variant ? variant : {isUndefined: true}*/});
__longnames[key] = oResult.first();
__longnames[key] = __symbols.find((symbol) => symbol.longname === key);
}
return __longnames[key];
}
Expand Down Expand Up @@ -408,19 +406,21 @@ function publish(symbolSet) {
// create output dir
fs.mkPath(env.opts.destination);

// if ( symbolSet().count() < 20000 ) {
__symbols = symbolSet().get();

// if ( __symbols.length < 20000 ) {
// const rawSymbolsFile = path.join(env.opts.destination, "symbols-unpruned-ui5.json");
// info(`writing raw symbols to ${rawSymbolsFile}`);
// fs.writeFileSync(rawSymbolsFile, JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
// fs.writeFileSync(rawSymbolsFile, JSON.stringify(__symbols, filter, "\t"), 'utf8');
// }

info(`before prune: ${symbolSet().count()} symbols.`);
info(`before prune: ${__symbols.length} symbols.`);
symbolSet = helper.prune(symbolSet);
info(`after prune: ${symbolSet().count()} symbols.`);
__symbols = symbolSet().get();
info(`after prune: ${__symbols.length} symbols.`);

__db = symbolSet;
__longnames = {};
__db().each(function($) {
__symbols.forEach(function($) {
__longnames[$.longname] = $;
});

Expand Down Expand Up @@ -470,17 +470,17 @@ function publish(symbolSet) {
collectMembers();
mergeEventDocumentation();

if ( symbolSet().count() < 20000 ) {
if ( __symbols.length < 20000 ) {
const rawSymbolsFile = path.join(env.opts.destination, "symbols-pruned-ui5.json");
info(`writing raw symbols to ${rawSymbolsFile}`);
fs.writeFileSync(rawSymbolsFile, JSON.stringify(symbolSet().get(), filter, "\t"), 'utf8');
fs.writeFileSync(rawSymbolsFile, JSON.stringify(__symbols, filter, "\t"), 'utf8');
}

// used to allow Link to check the details of things being linked to
Link.symbolSet = symbolSet;

// get an array version of the symbol set, useful for filtering
const symbols = symbolSet().get();
const symbols = __symbols;

// -----

Expand Down Expand Up @@ -662,10 +662,10 @@ function publish(symbolSet) {
*/
function createNamespaceTree() {

info(`create namespace tree (${__db().count()} symbols)`);
info(`create namespace tree (${__symbols.length} symbols)`);

const aRootNamespaces = [];
const aTypes = __db(function() { return isFirstClassSymbol(this); }).get();
const aTypes = __symbols.filter((symbol) => isFirstClassSymbol(symbol));

for (let i = 0; i < aTypes.length; i++) { // loop with a for-loop as it can handle concurrent modifications

Expand All @@ -677,7 +677,7 @@ function createNamespaceTree() {
warning(`create missing namespace '${symbol.memberof}' (referenced by ${symbol.longname})`);
parent = makeNamespace(symbol.memberof);
__longnames[symbol.memberof] = parent;
__db.insert(parent);
__symbols.push(parent);
aTypes.push(parent); // concurrent modification: parent will be processed later in this loop
}
symbol.__ui5.parent = parent;
Expand Down Expand Up @@ -732,13 +732,13 @@ function createInheritanceTree() {
const newDoclet = new doclet.Doclet("/**\n * " + lines.join("\n * ") + "\n */", {});
newDoclet.__ui5 = {};
__longnames[longname] = newDoclet;
__db.insert(newDoclet);
__symbols.push(newDoclet);
return newDoclet;
}

info(`create inheritance tree (${__db().count()} symbols)`);
info(`create inheritance tree (${__symbols.length} symbols)`);

const oTypes = __db(function() { return supportsInheritance(this); });
const aTypes = __symbols.filter((symbol) => supportsInheritance(symbol));
const aRootTypes = [];

let oObject = lookup("Object");
Expand Down Expand Up @@ -780,7 +780,7 @@ function createInheritanceTree() {
}

// link them according to the inheritance infos
oTypes.each((oClass) => {
aTypes.forEach((oClass) => {

if ( oClass.longname === 'Object') {
return;
Expand Down Expand Up @@ -849,7 +849,7 @@ function createInheritanceTree() {

// check for cyclic inheritance (not supported)
// Note: the check needs to run bottom up, not top down as a typical cyclic dependency never will end at the root node
oTypes.each((oStartClass) => {
aTypes.forEach((oStartClass) => {
const visited = {};
function visit(oClass) {
if ( visited[oClass.longname] ) {
Expand All @@ -869,7 +869,7 @@ function createInheritanceTree() {
}

function collectMembers() {
__db().each(function($) {
__symbols.forEach(function($) {
if ( $.memberof ) {
const parent = lookup($.memberof);
if ( parent /* && supportsInheritance(parent) */ ) {
Expand All @@ -884,9 +884,9 @@ function mergeEventDocumentation() {

debug("merging JSDoc event documentation into UI5 metadata");

const oTypes = __db(function() { return isaClass(this); });
const aTypes = __symbols.filter((symbol) => isaClass(symbol));

oTypes.each((symbol) => {
aTypes.forEach((symbol) => {

const metadata = symbol.__ui5.metadata;
const members = symbol.__ui5.members;
Expand Down Expand Up @@ -2892,7 +2892,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
}
if ( omissibleParams.size > 0 ) {
throw new Error(`parameter(s) '${[...omissibleParams].join("' and '")}' specified as '@ui5-omissible-params' for '${member.name}' missing among the actual @params`);
}
}

exceptions(member);

Expand Down Expand Up @@ -3466,14 +3466,17 @@ const builtinTypes = {
WeakMap: true,

// Web APIs
AbortSignal:true,
Attr:true,
Blob:true,
DataTransfer:true,
Document:true,
DOMException:true,
Element:true,
Event:true,
File:true,
FileList:true,
Headers:true,
HTMLDocument:true,
HTMLElement:true,
Node:true,
Expand Down