mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Add detection of HTML/CSS/JS comments for entrypoints
This commit is contained in:
parent
592e57351c
commit
dd66a8c252
1 changed files with 14 additions and 10 deletions
|
@ -905,17 +905,19 @@ module.exports = class SpellView extends CocoView
|
||||||
if @_singleLineCommentRegex
|
if @_singleLineCommentRegex
|
||||||
@_singleLineCommentRegex.lastIndex = 0
|
@_singleLineCommentRegex.lastIndex = 0
|
||||||
return @_singleLineCommentRegex
|
return @_singleLineCommentRegex
|
||||||
commentStart = commentStarts[@spell.language] or '//'
|
if @spell.language is 'html'
|
||||||
@_singleLineCommentRegex = new RegExp "[ \t]*#{commentStart}[^\"'\n]*", 'g'
|
commentStart = "#{commentStarts.html}|#{commentStarts.css}|#{commentStarts.javascript}"
|
||||||
|
else
|
||||||
|
commentStart = commentStarts[@spell.language] or '//'
|
||||||
|
@_singleLineCommentRegex = new RegExp "[ \t]*(#{commentStart})[^\"'\n]*"
|
||||||
@_singleLineCommentRegex
|
@_singleLineCommentRegex
|
||||||
|
|
||||||
lineWithCodeRegex: ->
|
singleLineCommentOnlyRegex: ->
|
||||||
if @_lineWithCodeRegex
|
if @_singleLineCommentOnlyRegex
|
||||||
@_lineWithCodeRegex.lastIndex = 0
|
@_singleLineCommentOnlyRegex.lastIndex = 0
|
||||||
return @_lineWithCodeRegex
|
return @_singleLineCommentOnlyRegex
|
||||||
commentStart = commentStarts[@spell.language] or '//'
|
@_singleLineCommentOnlyRegex = new RegExp( '^' + @singleLineCommentRegex().source)
|
||||||
@_lineWithCodeRegex = new RegExp "^[ \t]*(?!( |]t|#{commentStart}))+", 'g'
|
@_singleLineCommentOnlyRegex
|
||||||
@_lineWithCodeRegex
|
|
||||||
|
|
||||||
commentOutMyCode: ->
|
commentOutMyCode: ->
|
||||||
prefix = if @spell.language is 'javascript' then 'return; ' else 'return '
|
prefix = if @spell.language is 'javascript' then 'return; ' else 'return '
|
||||||
|
@ -1113,7 +1115,7 @@ module.exports = class SpellView extends CocoView
|
||||||
session.removeGutterDecoration index, 'next-entry-point'
|
session.removeGutterDecoration index, 'next-entry-point'
|
||||||
|
|
||||||
lineHasComment = @singleLineCommentRegex().test line
|
lineHasComment = @singleLineCommentRegex().test line
|
||||||
lineHasCode = line.trim()[0] and not _.string.startsWith line.trim(), commentStart
|
lineHasCode = line.trim()[0] and not @singleLineCommentOnlyRegex().test line
|
||||||
lineIsBlank = /^[ \t]*$/.test line
|
lineIsBlank = /^[ \t]*$/.test line
|
||||||
lineHasExplicitMarker = line.indexOf('∆') isnt -1
|
lineHasExplicitMarker = line.indexOf('∆') isnt -1
|
||||||
|
|
||||||
|
@ -1283,6 +1285,7 @@ module.exports = class SpellView extends CocoView
|
||||||
@saveSpadeTimeout = null
|
@saveSpadeTimeout = null
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
# Note: These need to be double-escaped for insertion into regexes
|
||||||
commentStarts =
|
commentStarts =
|
||||||
javascript: '//'
|
javascript: '//'
|
||||||
python: '#'
|
python: '#'
|
||||||
|
@ -1290,3 +1293,4 @@ commentStarts =
|
||||||
lua: '--'
|
lua: '--'
|
||||||
java: '//'
|
java: '//'
|
||||||
html: '<!--'
|
html: '<!--'
|
||||||
|
css: '/\\*'
|
||||||
|
|
Loading…
Reference in a new issue