Rename outline view to symbols view

This commit is contained in:
Kevin Sawicki
2013-01-22 18:43:36 -08:00
parent f6e4e69e2b
commit 7addbaf893
12 changed files with 122 additions and 123 deletions

View File

@@ -1,21 +0,0 @@
DeferredAtomPackage = require 'deferred-atom-package'
module.exports =
class Outline extends DeferredAtomPackage
loadEvents: [
'outline-view:toggle-file-outline'
'outline-view:toggle-project-outline'
'outline-view:jump-to-declaration'
]
instanceClass: 'outline-view/src/outline-view'
onLoadEvent: (event, instance) ->
switch event.type
when 'outline-view:toggle-file-outline'
instance.toggleFileOutline()
when 'outline-view:toggle-project-outline'
instance.toggleProjectOutline()
when 'outline-view:jump-to-declaration'
instance.jumpToDeclaration()

View File

@@ -1,6 +0,0 @@
'.editor':
'meta-j': 'outline-view:toggle-file-outline'
'meta-.': 'outline-view:jump-to-declaration'
'body':
'meta-J': 'outline-view:toggle-project-outline'

View File

@@ -0,0 +1,21 @@
DeferredAtomPackage = require 'deferred-atom-package'
module.exports =
class Symbols extends DeferredAtomPackage
loadEvents: [
'symbols-view:toggle-file-symbols'
'symbols-view:toggle-project-symbols'
'symbols-view:jump-to-declaration'
]
instanceClass: 'symbols-view/src/symbols-view'
onLoadEvent: (event, instance) ->
switch event.type
when 'symbols-view:toggle-file-symbols'
instance.toggleFileSymbols()
when 'symbols-view:toggle-project-symbols'
instance.toggleProjectSymbols()
when 'symbols-view:jump-to-declaration'
instance.jumpToDeclaration()

View File

@@ -0,0 +1,6 @@
'.editor':
'meta-j': 'symbols-view:toggle-file-symbols'
'meta-.': 'symbols-view:jump-to-declaration'
'body':
'meta-J': 'symbols-view:toggle-project-symbols'

View File

@@ -1,17 +1,16 @@
RootView = require 'root-view'
OutlineView = require 'outline-view/src/outline-view'
TagGenerator = require 'outline-view/src/tag-generator'
SymbolsView = require 'symbols-view/src/symbols-view'
TagGenerator = require 'symbols-view/src/tag-generator'
fs = require 'fs'
describe "OutlineView", ->
[rootView, outlineView, setArraySpy] = []
describe "SymbolsView", ->
[rootView, symbolsView, setArraySpy] = []
beforeEach ->
rootView = new RootView(require.resolve('fixtures'))
atom.loadPackage("outline-view").getInstance()
outlineView = OutlineView.instance
symbolsView = atom.loadPackage("symbols-view").getInstance()
rootView.attachToDom()
setArraySpy = spyOn(outlineView, 'setArray').andCallThrough()
setArraySpy = spyOn(symbolsView, 'setArray').andCallThrough()
afterEach ->
rootView.deactivate()
@@ -20,67 +19,67 @@ describe "OutlineView", ->
describe "when tags can be generated for a file", ->
it "initially displays all JavaScript functions with line numbers", ->
rootView.open('sample.js')
expect(rootView.find('.outline-view')).not.toExist()
rootView.getActiveEditor().trigger "outline-view:toggle-file-outline"
expect(outlineView.find('.loading')).toHaveText 'Generating symbols...'
expect(rootView.find('.symbols-view')).not.toExist()
rootView.getActiveEditor().trigger "symbols-view:toggle-file-symbols"
expect(symbolsView.find('.loading')).toHaveText 'Generating symbols...'
waitsFor ->
setArraySpy.callCount > 0
runs ->
expect(outlineView.find('.loading')).toBeEmpty()
expect(rootView.find('.outline-view')).toExist()
expect(outlineView.list.children('li').length).toBe 2
expect(outlineView.list.children('li:first').find('.function-name')).toHaveText 'quicksort'
expect(outlineView.list.children('li:first').find('.function-details')).toHaveText 'Line 1'
expect(outlineView.list.children('li:last').find('.function-name')).toHaveText 'quicksort.sort'
expect(outlineView.list.children('li:last').find('.function-details')).toHaveText 'Line 2'
expect(outlineView).not.toHaveClass "error"
expect(outlineView.error).not.toBeVisible()
expect(symbolsView.find('.loading')).toBeEmpty()
expect(rootView.find('.symbols-view')).toExist()
expect(symbolsView.list.children('li').length).toBe 2
expect(symbolsView.list.children('li:first').find('.function-name')).toHaveText 'quicksort'
expect(symbolsView.list.children('li:first').find('.function-details')).toHaveText 'Line 1'
expect(symbolsView.list.children('li:last').find('.function-name')).toHaveText 'quicksort.sort'
expect(symbolsView.list.children('li:last').find('.function-details')).toHaveText 'Line 2'
expect(symbolsView).not.toHaveClass "error"
expect(symbolsView.error).not.toBeVisible()
it "displays error when no tags match text in mini-editor", ->
rootView.open('sample.js')
expect(rootView.find('.outline-view')).not.toExist()
rootView.getActiveEditor().trigger "outline-view:toggle-file-outline"
expect(rootView.find('.symbols-view')).not.toExist()
rootView.getActiveEditor().trigger "symbols-view:toggle-file-symbols"
waitsFor ->
setArraySpy.callCount > 0
runs ->
outlineView.miniEditor.setText("nothing will match this")
window.advanceClock(outlineView.inputThrottle)
symbolsView.miniEditor.setText("nothing will match this")
window.advanceClock(symbolsView.inputThrottle)
expect(rootView.find('.outline-view')).toExist()
expect(outlineView.list.children('li').length).toBe 0
expect(outlineView.error).toBeVisible()
expect(outlineView.error.text().length).toBeGreaterThan 0
expect(outlineView).toHaveClass "error"
expect(rootView.find('.symbols-view')).toExist()
expect(symbolsView.list.children('li').length).toBe 0
expect(symbolsView.error).toBeVisible()
expect(symbolsView.error.text().length).toBeGreaterThan 0
expect(symbolsView).toHaveClass "error"
# Should remove error
outlineView.miniEditor.setText("")
window.advanceClock(outlineView.inputThrottle)
symbolsView.miniEditor.setText("")
window.advanceClock(symbolsView.inputThrottle)
expect(outlineView.list.children('li').length).toBe 2
expect(outlineView).not.toHaveClass "error"
expect(outlineView.error).not.toBeVisible()
expect(symbolsView.list.children('li').length).toBe 2
expect(symbolsView).not.toHaveClass "error"
expect(symbolsView.error).not.toBeVisible()
describe "when tags can't be generated for a file", ->
it "shows an error message when no matching tags are found", ->
rootView.open('sample.txt')
expect(rootView.find('.outline-view')).not.toExist()
rootView.getActiveEditor().trigger "outline-view:toggle-file-outline"
setErrorSpy = spyOn(outlineView, "setError").andCallThrough()
expect(rootView.find('.symbols-view')).not.toExist()
rootView.getActiveEditor().trigger "symbols-view:toggle-file-symbols"
setErrorSpy = spyOn(symbolsView, "setError").andCallThrough()
waitsFor ->
setErrorSpy.callCount > 0
runs ->
expect(rootView.find('.outline-view')).toExist()
expect(outlineView.list.children('li').length).toBe 0
expect(outlineView.error).toBeVisible()
expect(outlineView.error.text().length).toBeGreaterThan 0
expect(outlineView).toHaveClass "error"
expect(outlineView.find('.loading')).not.toBeVisible()
expect(rootView.find('.symbols-view')).toExist()
expect(symbolsView.list.children('li').length).toBe 0
expect(symbolsView.error).toBeVisible()
expect(symbolsView.error.text().length).toBeGreaterThan 0
expect(symbolsView).toHaveClass "error"
expect(symbolsView.find('.loading')).not.toBeVisible()
it "moves the cursor to the selected function", ->
tags = []
@@ -95,11 +94,11 @@ describe "OutlineView", ->
runs ->
rootView.open('sample.js')
expect(rootView.getActiveEditor().getCursorBufferPosition()).toEqual [0,0]
expect(rootView.find('.outline-view')).not.toExist()
outlineView.setArray(tags)
outlineView.attach()
expect(rootView.find('.outline-view')).toExist()
outlineView.confirmed(tags[1])
expect(rootView.find('.symbols-view')).not.toExist()
symbolsView.setArray(tags)
symbolsView.attach()
expect(rootView.find('.symbols-view')).toExist()
symbolsView.confirmed(tags[1])
expect(rootView.getActiveEditor().getCursorBufferPosition()).toEqual [1,2]
describe "TagGenerator", ->
@@ -132,24 +131,24 @@ describe "OutlineView", ->
rootView.open("tagged.js")
editor = rootView.getActiveEditor()
editor.setCursorBufferPosition([0,2])
editor.trigger 'outline-view:jump-to-declaration'
editor.trigger 'symbols-view:jump-to-declaration'
expect(editor.getCursorBufferPosition()).toEqual [0,2]
it "moves the cursor to the declaration", ->
rootView.open("tagged.js")
editor = rootView.getActiveEditor()
editor.setCursorBufferPosition([6,24])
editor.trigger 'outline-view:jump-to-declaration'
editor.trigger 'symbols-view:jump-to-declaration'
expect(editor.getCursorBufferPosition()).toEqual [2,0]
it "displays matches when more than one exists and opens the selected match", ->
rootView.open("tagged.js")
editor = rootView.getActiveEditor()
editor.setCursorBufferPosition([8,14])
editor.trigger 'outline-view:jump-to-declaration'
expect(outlineView.list.children('li').length).toBe 2
expect(outlineView).toBeVisible()
outlineView.confirmed(outlineView.array[0])
editor.trigger 'symbols-view:jump-to-declaration'
expect(symbolsView.list.children('li').length).toBe 2
expect(symbolsView).toBeVisible()
symbolsView.confirmed(symbolsView.array[0])
expect(rootView.getActiveEditor().getPath()).toBe rootView.project.resolve("tagged-duplicate.js")
expect(rootView.getActiveEditor().getCursorBufferPosition()).toEqual [0,4]
@@ -164,27 +163,27 @@ describe "OutlineView", ->
rootView.open("tagged.js")
editor = rootView.getActiveEditor()
editor.setCursorBufferPosition([8,14])
editor.trigger 'outline-view:jump-to-declaration'
expect(outlineView.list.children('li').length).toBe 1
expect(outlineView.list.children('li:first').find('.function-name')).toHaveText 'tagged.js'
editor.trigger 'symbols-view:jump-to-declaration'
expect(symbolsView.list.children('li').length).toBe 1
expect(symbolsView.list.children('li:first').find('.function-name')).toHaveText 'tagged.js'
describe "project outline", ->
describe "project symbols", ->
it "displays all tags", ->
rootView.open("tagged.js")
expect(rootView.find('.outline-view')).not.toExist()
rootView.trigger "outline-view:toggle-project-outline"
expect(outlineView.find('.loading')).toHaveText 'Loading symbols...'
expect(rootView.find('.symbols-view')).not.toExist()
rootView.trigger "symbols-view:toggle-project-symbols"
expect(symbolsView.find('.loading')).toHaveText 'Loading symbols...'
waitsFor ->
setArraySpy.callCount > 0
runs ->
expect(outlineView.find('.loading')).toBeEmpty()
expect(rootView.find('.outline-view')).toExist()
expect(outlineView.list.children('li').length).toBe 4
expect(outlineView.list.children('li:first').find('.function-name')).toHaveText 'callMeMaybe'
expect(outlineView.list.children('li:first').find('.function-details')).toHaveText 'tagged.js'
expect(outlineView.list.children('li:last').find('.function-name')).toHaveText 'thisIsCrazy'
expect(outlineView.list.children('li:last').find('.function-details')).toHaveText 'tagged.js'
expect(outlineView).not.toHaveClass "error"
expect(outlineView.error).not.toBeVisible()
expect(symbolsView.find('.loading')).toBeEmpty()
expect(rootView.find('.symbols-view')).toExist()
expect(symbolsView.list.children('li').length).toBe 4
expect(symbolsView.list.children('li:first').find('.function-name')).toHaveText 'callMeMaybe'
expect(symbolsView.list.children('li:first').find('.function-details')).toHaveText 'tagged.js'
expect(symbolsView.list.children('li:last').find('.function-name')).toHaveText 'thisIsCrazy'
expect(symbolsView.list.children('li:last').find('.function-details')).toHaveText 'tagged.js'
expect(symbolsView).not.toHaveClass "error"
expect(symbolsView.error).not.toBeVisible()

View File

@@ -1,18 +1,18 @@
{$$} = require 'space-pen'
SelectList = require 'select-list'
TagGenerator = require 'outline-view/src/tag-generator'
TagReader = require 'outline-view/src/tag-reader'
TagGenerator = require 'symbols-view/src/tag-generator'
TagReader = require 'symbols-view/src/tag-reader'
Point = require 'point'
fs = require 'fs'
$ = require 'jquery'
module.exports =
class OutlineView extends SelectList
class SymbolsView extends SelectList
@activate: (rootView) ->
@instance = new OutlineView(rootView)
@instance = new SymbolsView(rootView)
@viewClass: -> "#{super} outline-view"
@viewClass: -> "#{super} symbols-view"
filterKey: 'name'
@@ -31,14 +31,14 @@ class OutlineView extends SelectList
@div text, class: 'function-details'
@div class: 'clear-float'
toggleFileOutline: ->
toggleFileSymbols: ->
if @hasParent()
@cancel()
else
@populateFileOutline()
@populateFileSymbols()
@attach()
populateFileOutline: ->
populateFileSymbols: ->
tags = []
callback = (tag) -> tags.push tag
path = @rootView.getActiveEditor().getPath()
@@ -53,14 +53,14 @@ class OutlineView extends SelectList
@setError("No symbols found")
setTimeout (=> @detach()), 2000
toggleProjectOutline: ->
toggleProjectSymbols: ->
if @hasParent()
@cancel()
else
@populateProjectOutline()
@populateProjectSymbols()
@attach()
populateProjectOutline: ->
populateProjectSymbols: ->
@setLoading("Loading symbols...")
TagReader.getAllTags(@rootView.project).done (tags) =>
if tags.length > 0

View File

@@ -8,7 +8,7 @@
"tabs.css",
"wrap-guide.css",
"status-bar.css",
"outline-view.css",
"symbols-view.css",
"markdown-preview.css",
"fuzzy-finder.css",
"command-panel.css",
@@ -16,4 +16,4 @@
"command-logger.css",
"autocomplete.css"
]
}
}

View File

@@ -1,29 +1,29 @@
.outline-view {
.symbols-view {
width: 50%;
margin-left: -25%;
}
.outline-view ol {
.symbols-view ol {
max-height: 300px;
}
.outline-view ol li {
.symbols-view ol li {
padding: 2px;
border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.outline-view ol .function-name {
.symbols-view ol .function-name {
float: left;
display: inline-block;
margin-right: .5em;
margin: 4px 0;
}
.outline-view li .right {
.symbols-view li .right {
float: right;
}
.outline-view ol .function-details {
.symbols-view ol .function-details {
display: inline-block;
margin: 4px 0;
margin-right: .5em;

View File

@@ -8,7 +8,7 @@
"tabs.css",
"wrap-guide.css",
"status-bar.css",
"outline-view.css",
"symbols-view.css",
"markdown-preview.css",
"fuzzy-finder.css",
"command-panel.css",
@@ -16,4 +16,4 @@
"command-logger.css",
"autocomplete.css"
]
}
}

View File

@@ -1,29 +1,29 @@
.outline-view {
.symbols-view {
width: 50%;
margin-left: -25%;
}
.outline-view ol {
.symbols-view ol {
max-height: 300px;
}
.outline-view ol li {
.symbols-view ol li {
padding: 2px;
border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.outline-view ol .function-name {
.symbols-view ol .function-name {
float: left;
display: inline-block;
margin-right: .5em;
margin: 4px 0;
}
.outline-view li .right {
.symbols-view li .right {
float: right;
}
.outline-view ol .function-details {
.symbols-view ol .function-details {
display: inline-block;
margin: 4px 0;
margin-right: .5em;