mirror of
https://github.com/Hopiu/annotate-extension.git
synced 2026-05-15 18:23:08 +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
11
main.js
11
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*(' +
|
functionDeclarationRegex = new RegExp('^[a-z0-9]*\\s*\\n*\\bfunction\\b\\s*' + REGEX_PATTERNS.jsVariable + '\\s*\\(\\s*(' +
|
||||||
REGEX_PATTERNS.jsVariable + '\\s*,?)*\\s*\\)','g'),
|
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');
|
REGEX_PATTERNS.jsVariable + '\\s*(,\\s*)?)*\\s*\\)\\s*','g');
|
||||||
|
|
||||||
pos.ch = 0;
|
pos.ch = 0;
|
||||||
|
|
@ -100,17 +100,16 @@ define(function (require, exports, module) {
|
||||||
var results = txtFrom.match(new RegExp(REGEX_PATTERNS.jsVariable,'g'));
|
var results = txtFrom.match(new RegExp(REGEX_PATTERNS.jsVariable,'g'));
|
||||||
switch(true) {
|
switch(true) {
|
||||||
case functionExpresionRegex.test(txtFrom):
|
case functionExpresionRegex.test(txtFrom):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
//check for 'var'
|
//check for 'var'
|
||||||
name:results[results.indexOf('var') === -1 ? 0:1],
|
name:results[results.indexOf('function')-1],
|
||||||
params:results.slice(results.indexOf('var') === -1 ? 2:3),
|
params:results.slice(results.indexOf('function')+1),
|
||||||
prefix: getPrefix(txtFrom, results[0]),
|
prefix: getPrefix(txtFrom, results[0]),
|
||||||
returnsValue:returnsValue
|
returnsValue:returnsValue
|
||||||
};
|
};
|
||||||
case functionDeclarationRegex.test(txtFrom):
|
case functionDeclarationRegex.test(txtFrom):
|
||||||
console.log(results[1]);
|
//console.log(results[1]);
|
||||||
return {
|
return {
|
||||||
name:results[1],
|
name:results[1],
|
||||||
params:results.slice(2),
|
params:results.slice(2),
|
||||||
prefix: getPrefix(txtFrom, results[0]),
|
prefix: getPrefix(txtFrom, results[0]),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue