Document Outline for JS files (VS2005)
Hi,
in VS.NET 2003 the "document outline" would display a list of all functions when a javascript file was open. This functionality worked very well and was super useful for me as many script files I use run to thousands of lines of code. Often I develop new functionality and need to find out if something or other exists that I can reuse, and the outline was great for this.
Has it been simply dropped from VS2005? Is there any way to get it back?
[479 byte] By [
dagjo] at [2008-2-4]
I have found this question while trying to solve the same problem. Doesn't anyone here know whether there is any option that can be set to allow document outline for a JavaScript file?
3rd this request! I can't believe they have just removed this functionality...
Yea I'm also really confused as to why this isn't a feature, especially since VS seams to be heading headfirst into web development and AJAX. Considering that most javascript files can have thousands of lines of code, not being able to navigate the file is maddening. I really hope something is done about this.
I, too, really miss this functionality in 2005, and this thread is the only place I've seen the problem referenced. There has to be a workaround, an add-in, something... but I haven't found anything.
It's a real hassle to edit large JS files in Visual Studio now. Shouldn't each new version of VS be better than the last? Or at least stay as capable? haha
I actually found an add-in to do this in VS 2005, which handles it pretty nicely. Right now that's what I'm using. Unfortunately it doesn't work with Orcas.
http://submain.com/?nav=products.smartoutline
It's still there... it is just called the "Script Explorer" windows now. When your debugger is attached to IExplorer process which is enabled for debugging choose the menu item Debug -> Windows -> Script Explorer ...
BOb
PilotBob wrote: |
It's still there... it is just called the "Script Explorer" windows now. When your debugger is attached to IExplorer process which is enabled for debugging choose the menu item Debug -> Windows -> Script Explorer ... BOb |
|
First of all, this doesn't actually work. I tried it out last night. The script explorer remains empty. Also, you can only see the script explorer when debugging, which is useless for when you actually want to write code. And finally, you need to be using IE to debug, and can't be using Firefox, for example. All in all, not a viable solution.
I was looking for it, for years now!!! And i cannot find anything like 2003 document outline window. If anyone know of how to list javascript functions please tell! The addon
http://submain.com/?nav=products.smartoutline does't do the trick (or at least i think so). And yes Script Explorer never worked as well!
Works!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thank you very much!
To all: installtion is a little bit weird
follow the instruction directly:
Copy and paste files
ScriptOutline.dll (it is hidden in bin folder for some reasons, but you must copy just this file NOT the folder)
ScriptOutline.AddIn (that is in the root of rar)
into directory
C:\Documents and Settings\<username>\My Documents\Visual Studio 2005\Addins (most likely you ll have to create the folder)
there are 20 more different files in the rar, but you need just these two (weird! but WORKS!)
Hmmm, it works for 10 out of my 13 .js files....still not bad, but other three shows just an empty window
- Maybe you can try to uncheck scriptoutline in Tools/Add-In Manager, then try to launch Scriptoutline, I sometimes have to do that for some files. I don't have any explication about that!
Do you mean lanching it from C:\Documents and Settings\<username>\My Documents\Visual Studio 2005\Addins? For some reasons it doesn't really launches for me from there...It is laso weird, that the fact if .js file will be parsed or not, does not depend on its content...that is if i ll put the code to different file that was already parsed, than it shows all the functions as they are suppose to be.
I don't know if anyone would be interested in this, but I decided to post it anyway. I just wrote a small macro that loops through an open document and collapses each of the functions. I cannot say that it is perfect, but it is a start to what I was looking for. Anyway, here is the vb code for the macro:
Option Strict Off
Option Explicit On
Imports System
Imports
EnvDTEImports
EnvDTE80Imports
System.DiagnosticsPublic
Module JavaScript Sub Collapse()
DTE.ActiveDocument.Selection.OutlineSection()
End Sub
Sub CollapseFunctions()
Dim iMin As Integer
Dim TS As TextSelection Dim MyDocument As String Dim sFunction As String Dim iStart As Integer Dim iEnd As Integer Dim iLength As Integer Dim FileName As String FileName = DTE.ActiveDocument.FullName
If (Right(FileName, 4) = "aspx") Or (Right(FileName, 2) = "js") Then TS = DTE.ActiveDocument.Selection
TS.StartOfDocument()
TS.EndOfDocument(
True) MyDocument = TS.Text
TS.StartOfDocument()
iLength = MyDocument.Length
iMin = 0
While ((iMin <= iLength) And (iMin <> -1)) iMin = CollapseFunction(iMin, TS, MyDocument, iLength)
End While End IfEnd Sub
Function CollapseFunction( _ ByVal iMin As Integer, _ ByVal TS As TextSelection, _ ByVal MyDocument As String, _ ByVal iLength As Integer _)
As Integer'' Dim sFunction As String Dim iStart As Integer Dim iEnd As Integer TS = DTE.ActiveDocument.Selection
TS.StartOfDocument()
TS.EndOfDocument(
True) MyDocument = TS.Text
TS.StartOfDocument()
iStart = MyDocument.IndexOf(
"function", iMin) If iStart = -1 Then CollapseFunction = -1
Exit Function End If Dim i As Integer Dim StartIsSet As Boolean Dim OpenCount As Integer i = iStart
OpenCount = 0
StartIsSet =
False While (i < iLength) If (MyDocument.Substring(i, 1) = "{") And (StartIsSet = False) Then iStart = i
StartIsSet =
True End If If MyDocument.Substring(i, 1) = "{" Then OpenCount += 1
End If If MyDocument.Substring(i, 1) = "}" Then OpenCount -= 1
End If If (MyDocument.Substring(i, 1) = "}") And (OpenCount = 0) Then iEnd = i + 1
CollapseFunction = iEnd + 1
Exit While End If i += 1
End While sFunction = MyDocument.Substring(iStart, (iEnd - iStart))
TS.FindText(sFunction)
TS.OutlineSection()
End FunctionEnd
ModuleLike I said, this is not perfect, but it is a step closer.