Code inspection for javascript function

Let's say I have a javascript function like this:

function SetActiveOrderPosition(orderId){
     var activeOrder = { };
}

How can I write custom pattern to convert this function to:

SetActiveOrderPosition = function(orderId){
     var activeOrder = { };
}


I need this because I am refactoring global functions into object level functions

2 comments

Hello Marco
     I'm afraid ReSharper's Structural Search and Replace doesn't support JavaScript yet. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

You should be able to achieve this with Visual Studio's built-in Find & Replace, using Regular Expressions:

  • Find what: function:b+{:i}:b*(
  • Replace with: \1 = function(
  • Find options: Use: Regular Expressions
  • Find options: Look at these file types: *.js


There's a reference for the perculiar Regex syntax that Visual Studio uses on MSDN:
http://msdn.microsoft.com/en-us/library/2k3te2cs(v=vs.100).aspx

0

Please sign in to leave a comment.