Fix primitive types not showing up
This commit is contained in:
@@ -381,13 +381,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function min(a, b) {
|
|
||||||
if (a < b) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractGenerics(val) {
|
function extractGenerics(val) {
|
||||||
val = val.toLowerCase();
|
val = val.toLowerCase();
|
||||||
if (val.indexOf('<') !== -1) {
|
if (val.indexOf('<') !== -1) {
|
||||||
@@ -425,7 +418,7 @@
|
|||||||
}
|
}
|
||||||
if (lev.pos !== -1) {
|
if (lev.pos !== -1) {
|
||||||
elems.splice(lev.pos, 1);
|
elems.splice(lev.pos, 1);
|
||||||
lev_distance = min(lev.lev, lev_distance);
|
lev_distance = Math.min(lev.lev, lev_distance);
|
||||||
} else {
|
} else {
|
||||||
return MAX_LEV_DISTANCE + 1;
|
return MAX_LEV_DISTANCE + 1;
|
||||||
}
|
}
|
||||||
@@ -488,11 +481,12 @@
|
|||||||
var new_lev = levenshtein(obj.name, val.name);
|
var new_lev = levenshtein(obj.name, val.name);
|
||||||
if (new_lev < lev_distance) {
|
if (new_lev < lev_distance) {
|
||||||
if ((lev = checkGenerics(obj, val)) <= MAX_LEV_DISTANCE) {
|
if ((lev = checkGenerics(obj, val)) <= MAX_LEV_DISTANCE) {
|
||||||
lev_distance = min(min(new_lev, lev), lev_distance);
|
lev_distance = Math.min(Math.min(new_lev, lev), lev_distance);
|
||||||
}
|
}
|
||||||
} else if (obj.generics && obj.generics.length > 0) {
|
} else if (obj.generics && obj.generics.length > 0) {
|
||||||
for (var x = 0; x < obj.generics.length; ++x) {
|
for (var x = 0; x < obj.generics.length; ++x) {
|
||||||
lev_distance = min(levenshtein(obj.generics[x], val.name), lev_distance);
|
lev_distance = Math.min(levenshtein(obj.generics[x], val.name),
|
||||||
|
lev_distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Now whatever happens, the returned distance is "less good" so we should mark it
|
// Now whatever happens, the returned distance is "less good" so we should mark it
|
||||||
@@ -509,7 +503,7 @@
|
|||||||
if (literalSearch === true && tmp === true) {
|
if (literalSearch === true && tmp === true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
lev_distance = min(tmp, lev_distance);
|
lev_distance = Math.min(tmp, lev_distance);
|
||||||
if (lev_distance === 0) {
|
if (lev_distance === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -526,7 +520,7 @@
|
|||||||
if (literalSearch === true && tmp === true) {
|
if (literalSearch === true && tmp === true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
lev_distance = min(tmp, lev_distance);
|
lev_distance = Math.min(tmp, lev_distance);
|
||||||
if (lev_distance === 0) {
|
if (lev_distance === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -567,18 +561,20 @@
|
|||||||
var in_args = findArg(searchIndex[i], val, true);
|
var in_args = findArg(searchIndex[i], val, true);
|
||||||
var returned = checkReturned(searchIndex[i], val, true);
|
var returned = checkReturned(searchIndex[i], val, true);
|
||||||
var ty = searchIndex[i];
|
var ty = searchIndex[i];
|
||||||
|
var fullId = itemTypes[ty.ty] + ty.path + ty.name;
|
||||||
|
|
||||||
if (searchWords[i] === val.name) {
|
if (searchWords[i] === val.name) {
|
||||||
// filter type: ... queries
|
// filter type: ... queries
|
||||||
if (typePassesFilter(typeFilter, searchIndex[i].ty) &&
|
if (typePassesFilter(typeFilter, searchIndex[i].ty) &&
|
||||||
results[ty.path + ty.name] === undefined)
|
results[fullId] === undefined)
|
||||||
{
|
{
|
||||||
results[ty.path + ty.name] = {id: i, index: -1};
|
results[fullId] = {id: i, index: -1};
|
||||||
results_length += 1;
|
results_length += 1;
|
||||||
}
|
}
|
||||||
} else if ((in_args === true || returned === true) &&
|
} else if ((in_args === true || returned === true) &&
|
||||||
typePassesFilter(typeFilter, searchIndex[i].ty)) {
|
typePassesFilter(typeFilter, searchIndex[i].ty)) {
|
||||||
if (results[ty.path + ty.name] === undefined) {
|
if (results[fullId] === undefined) {
|
||||||
results[ty.path + ty.name] = {
|
results[fullId] = {
|
||||||
id: i,
|
id: i,
|
||||||
index: -1,
|
index: -1,
|
||||||
dontValidate: true,
|
dontValidate: true,
|
||||||
@@ -588,10 +584,10 @@
|
|||||||
results_length += 1;
|
results_length += 1;
|
||||||
} else {
|
} else {
|
||||||
if (in_args === true) {
|
if (in_args === true) {
|
||||||
results[ty.path + ty.name].in_args = true;
|
results[fullId].in_args = true;
|
||||||
}
|
}
|
||||||
if (returned === true) {
|
if (returned === true) {
|
||||||
results[ty.path + ty.name].returned = true;
|
results[fullId].returned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,6 +616,7 @@
|
|||||||
if (!type) {
|
if (!type) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
var fullId = itemTypes[ty.ty] + ty.path + ty.name;
|
||||||
|
|
||||||
// allow searching for void (no output) functions as well
|
// allow searching for void (no output) functions as well
|
||||||
var typeOutput = type.output ? type.output.name : "";
|
var typeOutput = type.output ? type.output.name : "";
|
||||||
@@ -638,15 +635,15 @@
|
|||||||
in_args = allFound;
|
in_args = allFound;
|
||||||
}
|
}
|
||||||
if (in_args === true || returned === true || module === true) {
|
if (in_args === true || returned === true || module === true) {
|
||||||
if (results[ty.path + ty.name] !== undefined) {
|
if (results[fullId] !== undefined) {
|
||||||
if (returned === true) {
|
if (returned === true) {
|
||||||
results[ty.path + ty.name].returned = true;
|
results[fullId].returned = true;
|
||||||
}
|
}
|
||||||
if (in_args === true) {
|
if (in_args === true) {
|
||||||
results[ty.path + ty.name].in_args = true;
|
results[fullId].in_args = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
results[ty.path + ty.name] = {
|
results[fullId] = {
|
||||||
id: i,
|
id: i,
|
||||||
index: -1,
|
index: -1,
|
||||||
dontValidate: true,
|
dontValidate: true,
|
||||||
@@ -681,48 +678,49 @@
|
|||||||
var index = -1;
|
var index = -1;
|
||||||
// we want lev results to go lower than others
|
// we want lev results to go lower than others
|
||||||
var lev = MAX_LEV_DISTANCE;
|
var lev = MAX_LEV_DISTANCE;
|
||||||
|
var fullId = itemTypes[ty.ty] + ty.path + ty.name;
|
||||||
|
|
||||||
if (searchWords[j].indexOf(split[i]) > -1 ||
|
if (searchWords[j].indexOf(split[i]) > -1 ||
|
||||||
searchWords[j].indexOf(val) > -1 ||
|
searchWords[j].indexOf(val) > -1 ||
|
||||||
searchWords[j].replace(/_/g, "").indexOf(val) > -1)
|
searchWords[j].replace(/_/g, "").indexOf(val) > -1)
|
||||||
{
|
{
|
||||||
// filter type: ... queries
|
// filter type: ... queries
|
||||||
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
|
if (typePassesFilter(typeFilter, ty) &&
|
||||||
results[ty.path + ty.name] === undefined) {
|
results[fullId] === undefined) {
|
||||||
index = searchWords[j].replace(/_/g, "").indexOf(val);
|
index = searchWords[j].replace(/_/g, "").indexOf(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((lev_distance = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) {
|
if ((lev_distance = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) {
|
||||||
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
|
if (typePassesFilter(typeFilter, ty) &&
|
||||||
(results[ty.path + ty.name] === undefined ||
|
(results[fullId] === undefined ||
|
||||||
results[ty.path + ty.name].lev > lev_distance)) {
|
results[fullId].lev > lev_distance)) {
|
||||||
lev = min(lev, lev_distance);
|
lev = Math.min(lev, lev_distance);
|
||||||
index = 0;
|
index = Math.max(0, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((lev_distance = findArg(searchIndex[j], valGenerics))
|
if ((lev_distance = findArg(searchIndex[j], valGenerics))
|
||||||
<= MAX_LEV_DISTANCE) {
|
<= MAX_LEV_DISTANCE) {
|
||||||
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
|
if (typePassesFilter(typeFilter, ty) &&
|
||||||
(results[ty.path + ty.name] === undefined ||
|
(results[fullId] === undefined ||
|
||||||
results[ty.path + ty.name].lev > lev_distance)) {
|
results[fullId].lev > lev_distance)) {
|
||||||
in_args = true;
|
in_args = true;
|
||||||
lev = min(lev_distance, lev);
|
lev = Math.min(lev_distance, lev);
|
||||||
index = 0;
|
index = Math.max(0, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((lev_distance = checkReturned(searchIndex[j], valGenerics)) <=
|
if ((lev_distance = checkReturned(searchIndex[j], valGenerics)) <=
|
||||||
MAX_LEV_DISTANCE) {
|
MAX_LEV_DISTANCE) {
|
||||||
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
|
if (typePassesFilter(typeFilter, ty) &&
|
||||||
(results[ty.path + ty.name] === undefined ||
|
(results[fullId] === undefined ||
|
||||||
results[ty.path + ty.name].lev > lev_distance)) {
|
results[fullId].lev > lev_distance)) {
|
||||||
returned = true;
|
returned = true;
|
||||||
lev = min(lev_distance, lev);
|
lev = Math.min(lev_distance, lev);
|
||||||
index = 0;
|
index = Math.max(0, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
if (results[ty.path + ty.name] === undefined) {
|
if (results[fullId] === undefined) {
|
||||||
results[ty.path + ty.name] = {
|
results[fullId] = {
|
||||||
id: j,
|
id: j,
|
||||||
index: index,
|
index: index,
|
||||||
lev: lev,
|
lev: lev,
|
||||||
@@ -731,14 +729,14 @@
|
|||||||
};
|
};
|
||||||
results_length += 1;
|
results_length += 1;
|
||||||
} else {
|
} else {
|
||||||
if (results[ty.path + ty.name].lev > lev) {
|
if (results[fullId].lev > lev) {
|
||||||
results[ty.path + ty.name].lev = lev;
|
results[fullId].lev = lev;
|
||||||
}
|
}
|
||||||
if (in_args === true) {
|
if (in_args === true) {
|
||||||
results[ty.path + ty.name].in_args = true;
|
results[fullId].in_args = true;
|
||||||
}
|
}
|
||||||
if (returned === true) {
|
if (returned === true) {
|
||||||
results[ty.path + ty.name].returned = true;
|
results[fullId].returned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user