(prefix, match)
| 376 | const results = []; |
| 377 | |
| 378 | const objectSearchCallback = (prefix, match) => { |
| 379 | const name = match[4] |
| 380 | const fullname = (prefix ? prefix + "." : "") + name; |
| 381 | const fullnameLower = fullname.toLowerCase(); |
| 382 | if (fullnameLower.indexOf(object) < 0) return; |
| 383 | |
| 384 | let score = 0; |
| 385 | const parts = fullnameLower.split("."); |
| 386 | |
| 387 | // check for different match types: exact matches of full name or |
| 388 | // "last name" (i.e. last dotted part) |
| 389 | if (fullnameLower === object || parts.slice(-1)[0] === object) |
| 390 | score += Scorer.objNameMatch; |
| 391 | else if (parts.slice(-1)[0].indexOf(object) > -1) |
| 392 | score += Scorer.objPartialMatch; // matches in last name |
| 393 | |
| 394 | const objName = objNames[match[1]][2]; |
| 395 | const title = titles[match[0]]; |
| 396 | |
| 397 | // If more than one term searched for, we require other words to be |
| 398 | // found in the name/title/description |
| 399 | const otherTerms = new Set(objectTerms); |
| 400 | otherTerms.delete(object); |
| 401 | if (otherTerms.size > 0) { |
| 402 | const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase(); |
| 403 | if ( |
| 404 | [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0) |
| 405 | ) |
| 406 | return; |
| 407 | } |
| 408 | |
| 409 | let anchor = match[3]; |
| 410 | if (anchor === "") anchor = fullname; |
| 411 | else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname; |
| 412 | |
| 413 | const descr = objName + _(", in ") + title; |
| 414 | |
| 415 | // add custom score for some objects according to scorer |
| 416 | if (Scorer.objPrio.hasOwnProperty(match[2])) |
| 417 | score += Scorer.objPrio[match[2]]; |
| 418 | else score += Scorer.objPrioDefault; |
| 419 | |
| 420 | results.push([ |
| 421 | docNames[match[0]], |
| 422 | fullname, |
| 423 | "#" + anchor, |
| 424 | descr, |
| 425 | score, |
| 426 | filenames[match[0]], |
| 427 | ]); |
| 428 | }; |
| 429 | Object.keys(objects).forEach((prefix) => |
| 430 | objects[prefix].forEach((array) => |
| 431 | objectSearchCallback(prefix, array) |
no test coverage detected