mirror of
https://github.com/Hopiu/annotate-extension.git
synced 2026-03-17 00:10:23 +00:00
Merge pull request #24 from Hopiu/expressionRegex
Updated functionExpressionRegex
This commit is contained in:
commit
83d32ddaef
1 changed files with 6 additions and 7 deletions
13
main.js
13
main.js
|
|
@ -81,7 +81,7 @@ define(function (require, exports, module) {
|
|||
functionDeclarationRegex = new RegExp('^[a-z0-9]*\\s*\\n*\\bfunction\\b\\s*' + REGEX_PATTERNS.jsVariable + '\\s*\\(\\s*(' +
|
||||
REGEX_PATTERNS.jsVariable + '\\s*,?)*\\s*\\)','g'),
|
||||
|
||||
functionExpresionRegex = new RegExp('^[a-z0-9]*\\s*\\n*(var)?\\s*'+ REGEX_PATTERNS.jsVariable + '\\s*=\\s*function\\s*\\(\\s*(' +
|
||||
functionExpresionRegex = new RegExp('^[a-z0-9]*\\s*\\n*(var|'+ REGEX_PATTERNS.jsVariable + '.)?\\s*'+ REGEX_PATTERNS.jsVariable + '\\s*=\\s*function\\s*\\(\\s*(' +
|
||||
REGEX_PATTERNS.jsVariable + '\\s*(,\\s*)?)*\\s*\\)\\s*','g');
|
||||
|
||||
pos.ch = 0;
|
||||
|
|
@ -100,17 +100,16 @@ define(function (require, exports, module) {
|
|||
var results = txtFrom.match(new RegExp(REGEX_PATTERNS.jsVariable,'g'));
|
||||
switch(true) {
|
||||
case functionExpresionRegex.test(txtFrom):
|
||||
|
||||
return {
|
||||
//check for 'var'
|
||||
name:results[results.indexOf('var') === -1 ? 0:1],
|
||||
params:results.slice(results.indexOf('var') === -1 ? 2:3),
|
||||
name:results[results.indexOf('function')-1],
|
||||
params:results.slice(results.indexOf('function')+1),
|
||||
prefix: getPrefix(txtFrom, results[0]),
|
||||
returnsValue:returnsValue
|
||||
};
|
||||
case functionDeclarationRegex.test(txtFrom):
|
||||
console.log(results[1]);
|
||||
return {
|
||||
//console.log(results[1]);
|
||||
return {
|
||||
name:results[1],
|
||||
params:results.slice(2),
|
||||
prefix: getPrefix(txtFrom, results[0]),
|
||||
|
|
@ -183,4 +182,4 @@ define(function (require, exports, module) {
|
|||
menu.addMenuDivider();
|
||||
menu.addMenuItem(COMMAND_ID);//"menu-edit-annotate",
|
||||
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue