Closed Sinark closed 8 years ago
This doesn't look like standard JavaScript to me. What language are you using?
php
Alright, in that case the problem is that you define the arguments on separate lines. Whiles that looks nice, the extension is currently not built to detect it as I am using a Regex that runs on each line individually to find function declarations.
I don't really know how to include detection for this kind of coding style, but it should at least not produce false entries, which seems to be the case in your screenshot.
for my needs I adapted the code in PHP.js. Is not a very optimal code, but for me it work for the moment
function getOutlineList(text, showArguments, showUnnamed) {
var lines = text.split("\n");
var i = 0;
lines.forEach(function (line, index) {
// Search specific with function not new line.
var tst = line.indexOf( 'function');
if( -1 != tst){
var ii = index + 1;
var jj = 0;
var test = true;
var tmp = '';
while( test==true){
var search = lines[ii].replace( /\t\s/g,'');
if( -1==search.indexOf( '){') && 0==jj){
test = false;
}
else if( -1==search.indexOf( '){') ){
jj++;
ii++;
tmp = tmp + search;
}
else{
lines[index] = lines[index] + tmp +search; // merge line function with line argument for next parse
lines[ii] = ''; // Remove line
test = false;
tmp = '';
}
// To avoid a loop when INFINY problem
if( jj>=20){
test = false;
}
}
i++;
}
});
var regex = /(?:([\w$]+)\s*[=:]\s*)?(public|protected|private)?\s*(static)?\s*function(?:\s+(?:&\s*)?([\w]+))?\s*(\(.*\))/g;
var result = [];
lines.forEach(function (line, index) {
var match = regex.exec(line);
while (match !== null) {
var name = (match[1] || match[4] || "").trim();
var vis = match[2] || defaultVisibilty;
var isStatic = match[3] === "static";
var args = showArguments ? match[5] : "";
match = regex.exec(line);
if (name.length === 0) {
if (showUnnamed) {
name = unnamedPlaceholder;
vis = "unnamed";
} else {
continue;
}
}
result.push(createListEntry(name, args, vis, isStatic, index, line.length));
}
});
return result;
}
Update to 12:31 // FIx a litle bug
Hello, when a create a function/method in class in the Bracket, the output outline don’t show correctly function
ex :