Rename path variables to prevent collisions

This commit is contained in:
Kevin Sawicki
2013-06-12 17:16:10 -07:00
parent 54558c863d
commit 10f92836e6
2 changed files with 18 additions and 20 deletions

View File

@@ -40,8 +40,8 @@ describe "Project", ->
newEditSessionHandler = jasmine.createSpy('newEditSessionHandler')
project.on 'edit-session-created', newEditSessionHandler
fooOpener = (path, options) -> { foo: path, options } if path?.match(/\.foo/)
barOpener = (path) -> { bar: path } if path?.match(/^bar:\/\//)
fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/)
barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//)
Project.registerOpener(fooOpener)
Project.registerOpener(barOpener)
@@ -212,8 +212,7 @@ describe "Project", ->
it "calls the callback with all regex matches in all files in the project", ->
matches = []
waitsForPromise ->
project.scan /(a)+/, ({path, match, range}) ->
matches.push({path, match, range})
project.scan /(a)+/, (match) -> matches.push(match)
runs ->
expect(matches[0]).toEqual
@@ -229,8 +228,7 @@ describe "Project", ->
it "works with with escaped literals (like $ and ^)", ->
matches = []
waitsForPromise ->
project.scan /\$\w+/, ({path, match, range}) ->
matches.push({path, match, range})
project.scan /\$\w+/, (match) -> matches.push(match)
runs ->
expect(matches.length).toBe 1
@@ -295,9 +293,9 @@ describe "Project", ->
paths = []
matches = []
waitsForPromise ->
project.scan /match/, ({path, match, range}) ->
paths.push(path)
matches.push(match)
project.scan /match/, (result) ->
paths.push(result.path)
matches.push(result.match)
runs ->
expect(paths.length).toBe 0
@@ -311,9 +309,9 @@ describe "Project", ->
paths = []
matches = []
waitsForPromise ->
project.scan /match this/, ({path, match, range}) ->
paths.push(path)
matches.push(match)
project.scan /match this/, (result) ->
paths.push(result.path)
matches.push(result.match)
runs ->
expect(paths.length).toBe 1
@@ -328,9 +326,9 @@ describe "Project", ->
paths = []
matches = []
waitsForPromise ->
project.scan /match/, ({path, match, range}) ->
paths.push(path)
matches.push(match)
project.scan /match/, (result) ->
paths.push(result.path)
matches.push(result.match)
runs ->
expect(paths.length).toBe 0

View File

@@ -223,20 +223,20 @@ class Project
scan: (regex, iterator) ->
bufferedData = ""
state = 'readingPath'
path = null
filePath = null
readPath = (line) ->
if /^[0-9,; ]+:/.test(line)
state = 'readingLines'
else if /^:/.test line
path = line.substr(1)
filePath = line.substr(1)
else
path += ('\n' + line)
filePath += ('\n' + line)
readLine = (line) ->
if line.length == 0
state = 'readingPath'
path = null
filePath = null
else
colonIndex = line.indexOf(':')
matchInfo = line.substring(0, colonIndex)
@@ -251,7 +251,7 @@ class Project
for [column, length] in matchPositions
range = new Range([row, column], [row, column + length])
match = lineText.substr(column, length)
iterator({path, range, match})
iterator({path: filePath, range, match})
deferred = $.Deferred()
errors = []