mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Use class methods to create native object shims
CoffeeScript 1.5 complains if a constructor has a returns a value.
This commit is contained in:
@@ -24,7 +24,7 @@ class Git
|
||||
ignore: 1 << 14
|
||||
|
||||
constructor: (path, options={}) ->
|
||||
@repo = new GitRepository(path)
|
||||
@repo = GitRepository.open(path)
|
||||
refreshIndexOnFocus = options.refreshIndexOnFocus ? true
|
||||
if refreshIndexOnFocus
|
||||
$ = require 'jquery'
|
||||
|
||||
@@ -30,13 +30,13 @@ class LanguageMode
|
||||
|
||||
buffer = @editSession.buffer
|
||||
commentStartRegexString = _.escapeRegExp(commentStartString).replace(/(\s+)$/, '($1)?')
|
||||
commentStartRegex = new OnigRegExp("^(\\s*)(#{commentStartRegexString})")
|
||||
commentStartRegex = OnigRegExp.create("^(\\s*)(#{commentStartRegexString})")
|
||||
shouldUncomment = commentStartRegex.test(buffer.lineForRow(start))
|
||||
|
||||
if commentEndString = syntax.getProperty(scopes, "editor.commentEnd")
|
||||
if shouldUncomment
|
||||
commentEndRegexString = _.escapeRegExp(commentEndString).replace(/^(\s+)/, '($1)?')
|
||||
commentEndRegex = new OnigRegExp("(#{commentEndRegexString})(\\s*)$")
|
||||
commentEndRegex = OnigRegExp.create("(#{commentEndRegexString})(\\s*)$")
|
||||
startMatch = commentStartRegex.search(buffer.lineForRow(start))
|
||||
endMatch = commentEndRegex.search(buffer.lineForRow(end))
|
||||
if startMatch and endMatch
|
||||
@@ -152,12 +152,12 @@ class LanguageMode
|
||||
|
||||
increaseIndentRegexForScopes: (scopes) ->
|
||||
if increaseIndentPattern = syntax.getProperty(scopes, 'editor.increaseIndentPattern')
|
||||
new OnigRegExp(increaseIndentPattern)
|
||||
OnigRegExp.create(increaseIndentPattern)
|
||||
|
||||
decreaseIndentRegexForScopes: (scopes) ->
|
||||
if decreaseIndentPattern = syntax.getProperty(scopes, 'editor.decreaseIndentPattern')
|
||||
new OnigRegExp(decreaseIndentPattern)
|
||||
OnigRegExp.create(decreaseIndentPattern)
|
||||
|
||||
foldEndRegexForScopes: (scopes) ->
|
||||
if foldEndPattern = syntax.getProperty(scopes, 'editor.foldEndPattern')
|
||||
new OnigRegExp(foldEndPattern)
|
||||
OnigRegExp.create(foldEndPattern)
|
||||
|
||||
@@ -28,7 +28,7 @@ class TextMateGrammar
|
||||
constructor: ({ @name, @fileTypes, @scopeName, patterns, repository, @foldingStopMarker, firstLineMatch}) ->
|
||||
@initialRule = new Rule(this, {@scopeName, patterns})
|
||||
@repository = {}
|
||||
@firstLineRegex = new OnigRegExp(firstLineMatch) if firstLineMatch
|
||||
@firstLineRegex = OnigRegExp.create(firstLineMatch) if firstLineMatch
|
||||
@fileTypes ?= []
|
||||
|
||||
for name, data of repository
|
||||
@@ -111,7 +111,7 @@ class Rule
|
||||
regex = pattern.regexSource
|
||||
regexes.push regex if regex
|
||||
|
||||
regexScanner = new OnigScanner(regexes)
|
||||
regexScanner = OnigScanner.create(regexes)
|
||||
regexScanner.patterns = patterns
|
||||
@scannersByBaseGrammarName[baseGrammar.name] = regexScanner unless anchored
|
||||
regexScanner
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
module.exports =
|
||||
class GitRepository
|
||||
constructor: (path) ->
|
||||
@open: (path) ->
|
||||
unless repo = $git.getRepository(path)
|
||||
throw new Error("No Git repository found searching path: #{path}")
|
||||
repo.constructor = GitRepository
|
||||
repo.__proto__ = GitRepository.prototype
|
||||
return repo
|
||||
repo
|
||||
|
||||
getHead: $git.getHead
|
||||
getPath: $git.getPath
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
module.exports =
|
||||
class OnigRegExp
|
||||
constructor: (source) ->
|
||||
@create: (source) ->
|
||||
regexp = $onigRegExp.buildOnigRegExp(source);
|
||||
regexp.constructor = OnigRegExp
|
||||
regexp.__proto__ = OnigRegExp.prototype
|
||||
regexp.source = source
|
||||
return regexp
|
||||
regexp
|
||||
|
||||
search: $onigRegExp.search
|
||||
test: $onigRegExp.test
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module.exports =
|
||||
class OnigScanner
|
||||
constructor: (sources) ->
|
||||
@create: (sources) ->
|
||||
scanner = $onigScanner.buildScanner(sources)
|
||||
scanner.constructor = OnigScanner
|
||||
scanner.__proto__ = OnigScanner.prototype
|
||||
scanner.sources = sources
|
||||
return scanner
|
||||
scanner
|
||||
|
||||
findNextMatch: $onigScanner.findNextMatch
|
||||
|
||||
Reference in New Issue
Block a user