Extensions have a src and specs directory now. Move existing extension specs.

Move the extensions spec code inside of the extension's spec directory. Move source code to the extension's src directory
This commit is contained in:
Corey Johnson
2012-10-25 11:45:58 -07:00
parent 6870f21ca5
commit 2af29c9934
68 changed files with 346 additions and 84 deletions

View File

@@ -1,4 +1,12 @@
fs = require 'fs'
require 'spec-helper'
require path for path in fs.listTree(window.resourcePath + "/spec") when /-spec\.coffee$/.test path
# Run extension specs
for extensionPath in fs.listTree(require.resolve("extensions"))
for path in fs.listTree(fs.join(extensionPath, "spec")) when /-spec\.coffee$/.test path
require path
# Run core specs
for path in fs.listTree(require.resolve("spec")) when /-spec\.coffee$/.test path
require path

View File

@@ -74,7 +74,7 @@ windowAdditions =
throw new Error("Extension '#{name}' does not exist at path '#{extensionPath}'") unless fs.exists(extensionPath)
extension = rootView.activateExtension(require(extensionPath), config)
extensionKeymapPath = fs.join(fs.directory(extensionPath), "keymap.coffee")
extensionKeymapPath = fs.join(fs.directory(extensionPath), "src/keymap.coffee")
require extensionKeymapPath if fs.exists(extensionKeymapPath)
extension
catch e

View File

@@ -1 +1 @@
module.exports = require 'autocomplete/autocomplete.coffee'
module.exports = require 'autocomplete/src/autocomplete.coffee'

View File

@@ -1,14 +1,14 @@
{
var CompositeCommand = require('command-panel/commands/composite-command')
var Substitution = require('command-panel/commands/substitution');
var ZeroAddress = require('command-panel/commands/zero-address');
var EofAddress = require('command-panel/commands/eof-address');
var LineAddress = require('command-panel/commands/line-address');
var AddressRange = require('command-panel/commands/address-range');
var CurrentSelectionAddress = require('command-panel/commands/current-selection-address')
var RegexAddress = require('command-panel/commands/regex-address')
var SelectAllMatches = require('command-panel/commands/select-all-matches')
var SelectAllMatchesInProject = require('command-panel/commands/select-all-matches-in-project')
var CompositeCommand = require('command-panel/src/commands/composite-command')
var Substitution = require('command-panel/src/commands/substitution');
var ZeroAddress = require('command-panel/src/commands/zero-address');
var EofAddress = require('command-panel/src/commands/eof-address');
var LineAddress = require('command-panel/src/commands/line-address');
var AddressRange = require('command-panel/src/commands/address-range');
var CurrentSelectionAddress = require('command-panel/src/commands/current-selection-address')
var RegexAddress = require('command-panel/src/commands/regex-address')
var SelectAllMatches = require('command-panel/src/commands/select-all-matches')
var SelectAllMatchesInProject = require('command-panel/src/commands/select-all-matches-in-project')
}
start = expressions:(expression+) {

View File

@@ -1 +1 @@
module.exports = require 'command-panel/command-panel'
module.exports = require 'command-panel/src/command-panel'

View File

@@ -1,4 +1,4 @@
CommandInterpreter = require 'command-panel/command-interpreter'
CommandInterpreter = require 'command-panel/src/command-interpreter'
Project = require 'project'
Buffer = require 'buffer'
EditSession = require 'edit-session'

View File

@@ -1,8 +1,8 @@
{View, $$$} = require 'space-pen'
CommandInterpreter = require 'command-panel/command-interpreter'
RegexAddress = require 'command-panel/commands/regex-address'
CompositeCommand = require 'command-panel/commands/composite-command'
PreviewList = require 'command-panel/preview-list'
CommandInterpreter = require 'command-panel/src/command-interpreter'
RegexAddress = require 'command-panel/src/commands/regex-address'
CompositeCommand = require 'command-panel/src/commands/composite-command'
PreviewList = require 'command-panel/src/preview-list'
Editor = require 'editor'
{SyntaxError} = require('pegjs').parser

View File

@@ -1,4 +1,4 @@
Address = require 'command-panel/commands/address'
Address = require 'command-panel/src/commands/address'
Range = require 'range'
module.exports =

View File

@@ -1,5 +1,5 @@
Command = require 'command-panel/commands/command'
Operation = require 'command-panel/operation'
Command = require 'command-panel/src/commands/command'
Operation = require 'command-panel/src/operation'
$ = require 'jquery'
module.exports =

View File

@@ -1,4 +1,4 @@
Address = require 'command-panel/commands/address'
Address = require 'command-panel/src/commands/address'
Range = require 'range'
module.exports =

View File

@@ -1,4 +1,4 @@
Address = require 'command-panel/commands/address'
Address = require 'command-panel/src/commands/address'
Range = require 'range'
module.exports =

View File

@@ -1,4 +1,4 @@
Address = require 'command-panel/commands/address'
Address = require 'command-panel/src/commands/address'
Range = require 'range'
module.exports =

View File

@@ -1,4 +1,4 @@
Address = require 'command-panel/commands/address'
Address = require 'command-panel/src/commands/address'
Range = require 'range'
module.exports =

View File

@@ -1,5 +1,5 @@
Command = require 'command-panel/commands/command'
Operation = require 'command-panel/operation'
Command = require 'command-panel/src/commands/command'
Operation = require 'command-panel/src/operation'
$ = require 'jquery'
module.exports =

View File

@@ -1,5 +1,5 @@
Command = require 'command-panel/commands/command'
Operation = require 'command-panel/operation'
Command = require 'command-panel/src/commands/command'
Operation = require 'command-panel/src/operation'
$ = require 'jquery'
module.exports =

View File

@@ -1,5 +1,5 @@
Command = require 'command-panel/commands/command'
Operation = require 'command-panel/operation'
Command = require 'command-panel/src/commands/command'
Operation = require 'command-panel/src/operation'
$ = require 'jquery'
module.exports =

View File

@@ -1,4 +1,4 @@
Address = require 'command-panel/commands/address'
Address = require 'command-panel/src/commands/address'
Range = require 'range'
module.exports =

View File

@@ -1 +1 @@
module.exports = require 'event-palette/event-palette'
module.exports = require 'event-palette/src/event-palette'

View File

@@ -1 +1 @@
module.exports = require 'fuzzy-finder/fuzzy-finder'
module.exports = require 'fuzzy-finder/src/fuzzy-finder'

View File

@@ -1 +0,0 @@
module.exports = require 'keybindings-view/keybindings-view'

View File

@@ -1,33 +0,0 @@
{$$} = require 'space-pen'
ScrollView = require 'scroll-view'
module.exports =
class KeybindingsView extends ScrollView
@activate: (rootView, state) ->
requireStylesheet 'keybinding-view.css'
@instance = new this(rootView)
@content: (rootView) ->
@div class: 'keybindings-view', tabindex: -1, =>
@ul outlet: 'keybindingList'
initialize: (@rootView) ->
super
@rootView.on 'keybindings-view:attach', => @attach()
@on 'keybindings-view:detach', => @detach()
attach: ->
@keybindingList.empty()
@keybindingList.append $$ ->
for keystroke, command of rootView.activeKeybindings()
@li =>
@span class: 'keystroke', "#{keystroke}"
@span ":"
@span "#{command}"
@rootView.append(this)
@focus()
detach: ->
super()
@rootView.focus()

View File

@@ -1,5 +0,0 @@
window.keymap.bindKeys '*',
'ctrl-?': 'keybindings-view:attach'
window.keymap.bindKeys ".keybindings-view",
'escape': 'keybindings-view:detach'

View File

@@ -1 +1 @@
module.exports = require 'markdown-preview/markdown-preview'
module.exports = require 'markdown-preview/src/markdown-preview'

View File

@@ -1 +1 @@
module.exports = require 'extensions/snippets/snippets.coffee'
module.exports = require 'snippets/src/snippets.coffee'

View File

@@ -1,5 +1,5 @@
{
var Snippet = require('extensions/snippets/snippet');
var Snippet = require('snippets/src/snippet');
var Point = require('point');
}

View File

@@ -1,7 +1,7 @@
fs = require 'fs'
PEG = require 'pegjs'
_ = require 'underscore'
SnippetExpansion = require 'snippets/snippet-expansion'
SnippetExpansion = require 'snippets/src/snippet-expansion'
module.exports =
name: 'Snippets'

View File

@@ -0,0 +1 @@
module.exports = require 'strip-trailing-whitespace/src/strip-trailing-whitespace'

View File

@@ -1 +1 @@
module.exports = require 'tree-view/tree-view'
module.exports = require 'tree-view/src/tree-view'

View File

@@ -1,5 +1,5 @@
{View, $$} = require 'space-pen'
FileView = require 'tree-view/file-view'
FileView = require 'tree-view/src/file-view'
Directory = require 'directory'
$ = require 'jquery'

View File

@@ -0,0 +1,292 @@
{View, $$} = require 'space-pen'
ScrollView = require 'scroll-view'
Directory = require 'directory'
DirectoryView = require 'tree-view/src/directory-view'
FileView = require 'tree-view/src/file-view'
Dialog = require 'tree-view/src/dialog'
Native = require 'native'
fs = require 'fs'
$ = require 'jquery'
_ = require 'underscore'
module.exports =
class TreeView extends ScrollView
@activate: (rootView, state) ->
requireStylesheet 'tree-view.css'
if state
@instance = TreeView.deserialize(state, rootView)
else
@instance = new TreeView(rootView)
@instance.attach()
@deactivate: () ->
@instance.deactivate()
@serialize: ->
@instance.serialize()
@content: (rootView) ->
@div class: 'tree-view tool-panel', tabindex: -1, =>
if rootView.project.getRootDirectory()
@subview 'root', new DirectoryView(directory: rootView.project.getRootDirectory(), isExpanded: true)
@deserialize: (state, rootView) ->
treeView = new TreeView(rootView)
treeView.root.deserializeEntryExpansionStates(state.directoryExpansionStates)
treeView.selectEntryForPath(state.selectedPath)
treeView.focusAfterAttach = state.hasFocus
treeView.scrollTopAfterAttach = state.scrollTop
treeView.attach() if state.attached
treeView
root: null
focusAfterAttach: false
scrollTopAfterAttach: -1
selectedPath: null
initialize: (@rootView) ->
super
@on 'click', '.entry', (e) => @entryClicked(e)
@command 'core:move-up', => @moveUp()
@command 'core:move-down', => @moveDown()
@command 'core:close', => @detatch()
@command 'tree-view:expand-directory', => @expandDirectory()
@command 'tree-view:collapse-directory', => @collapseDirectory()
@command 'tree-view:open-selected-entry', => @openSelectedEntry(true)
@command 'tree-view:move', => @moveSelectedEntry()
@command 'tree-view:add', => @add()
@command 'tree-view:remove', => @removeSelectedEntry()
@command 'tool-panel:unfocus', => @rootView.focus()
@command 'tree-view:directory-modified', =>
if @hasFocus()
@selectEntryForPath(@selectedPath) if @selectedPath
else
@selectActiveFile()
@rootView.command 'tree-view:toggle', => @toggle()
@rootView.command 'tree-view:reveal-active-file', => @revealActiveFile()
@rootView.on 'active-editor-path-change', => @selectActiveFile()
@rootView.project.on 'path-change', => @updateRoot()
@selectEntry(@root) if @root
afterAttach: (onDom) ->
@focus() if @focusAfterAttach
@scrollTop(@scrollTopAfterAttach) if @scrollTopAfterAttach > 0
serialize: ->
directoryExpansionStates: @root?.serializeEntryExpansionStates()
selectedPath: @selectedEntry()?.getPath()
hasFocus: @hasFocus()
attached: @hasParent()
scrollTop: @scrollTop()
deactivate: ->
@root?.unwatchEntries()
toggle: ->
if @hasFocus()
@detach()
else
if @hasParent()
@focus()
else
@attach()
attach: ->
@rootView.horizontal.prepend(this)
@focus()
detach: ->
@scrollTopAfterAttach = @scrollTop()
super
@rootView.focus()
hasFocus: ->
@is(':focus')
entryClicked: (e) ->
entry = $(e.currentTarget).view()
switch e.originalEvent?.detail ? 1
when 1
@selectEntry(entry)
@openSelectedEntry(false) if (entry instanceof FileView)
when 2
if entry.is('.selected.file')
@rootView.getActiveEditor().focus()
else if entry.is('.selected.directory')
entry.toggleExpansion()
false
updateRoot: ->
@root?.remove()
if @rootView.project.getRootDirectory()
@root = new DirectoryView(directory: @rootView.project.getRootDirectory(), isExpanded: true)
@append(@root)
else
@root = null
selectActiveFile: ->
activeFilePath = @rootView.getActiveEditor()?.getPath()
@selectEntryForPath(activeFilePath) if activeFilePath
revealActiveFile: ->
@attach()
@focus()
return unless activeFilePath = @rootView.getActiveEditor()?.getPath()
project = @rootView.project
activePathComponents = project.relativize(activeFilePath).split('/')
currentPath = project.getPath().replace(/\/$/, '')
for pathComponent in activePathComponents
currentPath += '/' + pathComponent
entry = @entryForPath(currentPath)
if entry.hasClass('directory')
entry.expand()
else
@selectEntry(entry)
entryForPath: (path) ->
fn = (bestMatchEntry, element) ->
entry = $(element).view()
regex = new RegExp("^" + _.escapeRegExp(entry.getPath()))
if regex.test(path) and entry.getPath().length > bestMatchEntry.getPath().length
entry
else
bestMatchEntry
@find(".entry").toArray().reduce(fn, @root)
selectEntryForPath: (path) ->
@selectEntry(@entryForPath(path))
moveDown: ->
selectedEntry = @selectedEntry()
if selectedEntry
if selectedEntry.is('.expanded.directory')
return if @selectEntry(selectedEntry.find('.entry:first'))
until @selectEntry(selectedEntry.next())
selectedEntry = selectedEntry.parents('.entry:first')
break unless selectedEntry.length
else
@selectEntry(@root)
@scrollToEntry(@selectedEntry())
moveUp: ->
selectedEntry = @selectedEntry()
if selectedEntry
if previousEntry = @selectEntry(selectedEntry.prev())
if previousEntry.is('.expanded.directory')
@selectEntry(previousEntry.find('.entry:last'))
else
@selectEntry(selectedEntry.parents('.directory').first())
else
@selectEntry(@find('.entry').last())
@scrollToEntry(@selectedEntry())
expandDirectory: ->
selectedEntry = @selectedEntry()
selectedEntry.view().expand() if (selectedEntry instanceof DirectoryView)
collapseDirectory: ->
selectedEntry = @selectedEntry()
if directory = selectedEntry.closest('.expanded.directory').view()
directory.collapse()
@selectEntry(directory)
openSelectedEntry: (changeFocus) ->
selectedEntry = @selectedEntry()
if (selectedEntry instanceof DirectoryView)
selectedEntry.view().toggleExpansion()
else if (selectedEntry instanceof FileView)
@rootView.open(selectedEntry.getPath(), { changeFocus })
moveSelectedEntry: ->
entry = @selectedEntry()
return unless entry
oldPath = entry.getPath()
dialog = new Dialog
prompt: "Enter the new path for the file:"
path: @rootView.project.relativize(oldPath)
select: true
onConfirm: (newPath) =>
newPath = @rootView.project.resolve(newPath)
directoryPath = fs.directory(newPath)
try
fs.makeTree(directoryPath) unless fs.exists(directoryPath)
fs.move(oldPath, newPath)
dialog.close()
catch e
dialog.showError("Error: " + e.message + " Try a different path:")
@rootView.append(dialog)
removeSelectedEntry: ->
entry = @selectedEntry()
return unless entry
entryType = if entry instanceof DirectoryView then "directory" else "file"
atom.confirm(
"Are you sure you would like to delete the selected #{entryType}?",
"You are deleting #{entry.getPath()}",
"Move to Trash", (=> Native.moveToTrash(entry.getPath())),
"Cancel", null
"Delete", (=> fs.remove(entry.getPath()))
)
add: ->
selectedPath = @selectedEntry().getPath()
directoryPath = if fs.isFile(selectedPath) then fs.directory(selectedPath) else selectedPath
relativeDirectoryPath = @rootView.project.relativize(directoryPath)
relativeDirectoryPath += '/' if relativeDirectoryPath.length > 0
dialog = new Dialog
prompt: "Enter the path for the new file/directory. Directories end with '/':"
path: relativeDirectoryPath
select: false
onConfirm: (relativePath) =>
endsWithDirectorySeparator = /\/$/.test(relativePath)
path = @rootView.project.resolve(relativePath)
try
if fs.exists(path)
pathType = if fs.isFile(path) then "file" else "directory"
dialog.showError("Error: A #{pathType} already exists at path '#{path}'. Try a different path:")
else if endsWithDirectorySeparator
fs.makeTree(path)
dialog.cancel()
@entryForPath(path).buildEntries()
@selectEntryForPath(path)
else
fs.write(path, "")
@rootView.open(path)
dialog.close()
catch e
dialog.showError("Error: " + e.message + " Try a different path:")
@rootView.append(dialog)
selectedEntry: ->
@find('.selected')?.view()
selectEntry: (entry) ->
return false unless entry.get(0)
entry = entry.view() unless entry instanceof View
@selectedPath = entry.getPath()
@find('.selected').removeClass('selected')
entry.addClass('selected')
scrollToEntry: (entry) ->
displayElement = if (entry instanceof DirectoryView) then entry.header else entry
top = @scrollTop() + displayElement.position().top
bottom = top + displayElement.outerHeight()
if bottom > @scrollBottom()
@scrollBottom(bottom)
if top < @scrollTop()
@scrollTop(top)

View File

@@ -1,8 +1,8 @@
_ = require 'underscore'
$ = require 'jquery'
operators = require 'vim-mode/operators'
commands = require 'vim-mode/commands'
motions = require 'vim-mode/motions'
operators = require 'vim-mode/src/operators'
commands = require 'vim-mode/src/commands'
motions = require 'vim-mode/src/motions'
module.exports =
class VimMode

View File

@@ -1 +1 @@
module.exports = require 'wrap-guide/wrap-guide'
module.exports = require 'wrap-guide/src/wrap-guide'