mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-14 05:55:00 -04:00
Fixed selective includeFlow.
This commit is contained in:
parent
af965ccb93
commit
af43f18c23
3 changed files with 19 additions and 7 deletions
app/views/play/level/tome
|
@ -21,6 +21,9 @@ module.exports = class DebugView extends View
|
|||
@ace = options.ace
|
||||
@thang = options.thang
|
||||
@variableStates = {}
|
||||
@globals = {Math: Math, _: _} # ... add more as documented
|
||||
for className, klass of serializedClasses
|
||||
@globals[className] = klass
|
||||
@onMouseMove = _.throttle @onMouseMove, 25
|
||||
|
||||
afterRender: ->
|
||||
|
@ -35,7 +38,7 @@ module.exports = class DebugView extends View
|
|||
pos = e.getDocumentPosition()
|
||||
endOfDoc = pos.row is @ace.getSession().getDocument().getLength() - 1
|
||||
it = new TokenIterator e.editor.session, pos.row, pos.column
|
||||
isIdentifier = (t) -> t and (t.type is 'identifier' or t.value is 'this' or window[t.value])
|
||||
isIdentifier = (t) => t and (t.type is 'identifier' or t.value is 'this' or @globals[t.value])
|
||||
while it.getCurrentTokenRow() is pos.row and not isIdentifier(token = it.getCurrentToken())
|
||||
it.stepBackward()
|
||||
break unless token
|
||||
|
@ -54,7 +57,7 @@ module.exports = class DebugView extends View
|
|||
token = prev
|
||||
start = it.getCurrentTokenColumn()
|
||||
chain.unshift token.value
|
||||
if token and (token.value of @variableStates or token.value is "this" or window[token.value])
|
||||
if token and (token.value of @variableStates or token.value is "this" or @globals[token.value])
|
||||
@variableChain = chain
|
||||
offsetX = e.domEvent.offsetX ? e.clientX - $(e.domEvent.target).offset().left
|
||||
offsetY = e.domEvent.offsetY ? e.clientY - $(e.domEvent.target).offset().top
|
||||
|
@ -132,7 +135,7 @@ module.exports = class DebugView extends View
|
|||
value = @thang
|
||||
else if i is 0
|
||||
value = @variableStates[prop]
|
||||
if typeof value is "undefined" then value = window[prop]
|
||||
if typeof value is "undefined" then value = @globals[prop]
|
||||
else
|
||||
value = value[prop]
|
||||
keys.push prop
|
||||
|
|
|
@ -452,11 +452,11 @@ module.exports = class SpellView extends View
|
|||
markerRange.end.detach()
|
||||
@aceSession.removeMarker markerRange.id
|
||||
@markerRanges = []
|
||||
@debugView.setVariableStates {}
|
||||
@aceSession.removeGutterDecoration row, 'executing' for row in [0 ... @aceSession.getLength()]
|
||||
$(@ace.container).find('.ace_gutter-cell.executing').removeClass('executing')
|
||||
if not executed.length or (@spell.name is "plan" and @spellThang.castAether.metrics.statementsExecuted < 20)
|
||||
@toolbarView?.toggleFlow false
|
||||
@debugView.setVariableStates {}
|
||||
return
|
||||
lastExecuted = _.last executed
|
||||
@toolbarView?.toggleFlow true
|
||||
|
@ -464,6 +464,7 @@ module.exports = class SpellView extends View
|
|||
@toolbarView?.setCallState states[currentCallIndex], statementIndex, currentCallIndex, @spellThang.castAether.metrics
|
||||
marked = {}
|
||||
lastExecuted = lastExecuted[0 .. @toolbarView.statementIndex] if @toolbarView?.statementIndex?
|
||||
gotVariableStates = false
|
||||
for state, i in lastExecuted
|
||||
[start, end] = state.range
|
||||
clazz = if i is lastExecuted.length - 1 then 'executing' else 'executed'
|
||||
|
@ -473,6 +474,7 @@ module.exports = class SpellView extends View
|
|||
markerType = "fullLine"
|
||||
else
|
||||
@debugView.setVariableStates state.variables
|
||||
gotVariableStates = true
|
||||
markerType = "text"
|
||||
markerRange = new Range start.row, start.col, end.row, end.col
|
||||
markerRange.start = @aceDoc.createAnchor markerRange.start
|
||||
|
@ -480,6 +482,7 @@ module.exports = class SpellView extends View
|
|||
markerRange.id = @aceSession.addMarker markerRange, clazz, markerType
|
||||
@markerRanges.push markerRange
|
||||
@aceSession.addGutterDecoration start.row, clazz if clazz is 'executing'
|
||||
@debugView.setVariableStates {} unless gotVariableStates
|
||||
null
|
||||
|
||||
highlightComments: ->
|
||||
|
|
|
@ -151,9 +151,15 @@ module.exports = class TomeView extends View
|
|||
@cast()
|
||||
|
||||
cast: ->
|
||||
for spellKey, spell of @spells
|
||||
for thangID, spellThang of spell.thangs
|
||||
spellThang.aether.options.includeFlow = spellThang.aether.originalOptions.includeFlow = spellThang is @spellView?.spellThang
|
||||
if @options.levelID is 'project-dota'
|
||||
# For performance reasons, only includeFlow on the currently Thang.
|
||||
for spellKey, spell of @spells
|
||||
for thangID, spellThang of spell.thangs
|
||||
hadFlow = Boolean spellThang.aether.options.includeFlow
|
||||
willHaveFlow = spellThang is @spellView?.spellThang
|
||||
spellThang.aether.options.includeFlow = spellThang.aether.originalOptions.includeFlow = willHaveFlow
|
||||
spellThang.aether.transpile spell.source unless hadFlow is willHaveFlow
|
||||
#console.log "set includeFlow to", spellThang.aether.options.includeFlow, "for", thangID, "of", spellKey
|
||||
Backbone.Mediator.publish 'tome:cast-spells', spells: @spells
|
||||
|
||||
onToggleSpellList: (e) ->
|
||||
|
|
Loading…
Add table
Reference in a new issue