mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 00:40:56 -05:00
Pass problem context to Aether
So Aether can craft better error messages. Bumping Aether to v0.2.39
This commit is contained in:
parent
04ec8c5222
commit
ce14f92979
4 changed files with 34 additions and 3 deletions
|
@ -20,6 +20,7 @@ module.exports.createAetherOptions = (options) ->
|
|||
jshint_E043: {level: 'ignore'} # https://github.com/codecombat/codecombat/issues/813 -- since we can't actually tell JSHint to really ignore things
|
||||
jshint_Unknown: {level: 'ignore'} # E043 also triggers Unknown, so ignore that, too
|
||||
aether_MissingThis: {level: 'error'}
|
||||
problemContext: options.problemContext
|
||||
#functionParameters: # TODOOOOO
|
||||
executionLimit: 1 * 1000 * 1000
|
||||
language: options.codeLanguage
|
||||
|
|
|
@ -132,7 +132,8 @@ module.exports = class Spell
|
|||
aceConfig = me.get('aceConfig') ? {}
|
||||
writable = @permissions.readwrite.length > 0
|
||||
skipProtectAPI = @skipProtectAPI or not writable
|
||||
aetherOptions = createAetherOptions functionName: @name, codeLanguage: @language, functionParameters: @parameters, skipProtectAPI: skipProtectAPI, includeFlow: @levelType is 'hero'
|
||||
problemContext = @createProblemContext thang
|
||||
aetherOptions = createAetherOptions functionName: @name, codeLanguage: @language, functionParameters: @parameters, skipProtectAPI: skipProtectAPI, includeFlow: @levelType is 'hero', problemContext: problemContext
|
||||
aether = new Aether aetherOptions
|
||||
if @worker
|
||||
workerMessage =
|
||||
|
@ -181,3 +182,32 @@ module.exports = class Spell
|
|||
@updateLanguageAether e.codeLanguage
|
||||
else
|
||||
console.error 'Spell onNewOpponentCode did not receive code', e
|
||||
|
||||
createProblemContext: (thang) ->
|
||||
# Create problemContext Aether can use to craft better error messages
|
||||
# stringReferences: values that should be referred to as a string instead of a variable (e.g. "Brak", not Brak)
|
||||
# thisMethods: methods available on the 'this' object
|
||||
# thisProperties: properties available on the 'this' object
|
||||
|
||||
# NOTE: Assuming the first createProblemContext call has everything we need, and we'll use that forevermore
|
||||
return @problemContext if @problemContext?
|
||||
|
||||
@problemContext = { stringReferences: [], thisMethods: [], thisProperties: [] }
|
||||
return @problemContext unless thang?
|
||||
|
||||
# Populate stringReferences
|
||||
for key, value of thang.world?.thangMap
|
||||
if (value.isAttackable or value.isSelectable) and value.id not in @problemContext.stringReferences
|
||||
@problemContext.stringReferences.push value.id
|
||||
|
||||
# Populate thisMethods and thisProperties
|
||||
if thang.programmableProperties?
|
||||
for prop in thang.programmableProperties
|
||||
if _.isFunction(thang[prop])
|
||||
@problemContext.thisMethods.push prop
|
||||
else
|
||||
@problemContext.thisProperties.push prop
|
||||
|
||||
# TODO: See SpellPaletteView.createPalette() for other interesting contextual properties
|
||||
|
||||
@problemContext
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"firepad": "~0.1.2",
|
||||
"marked": "~0.3.0",
|
||||
"moment": "~2.5.0",
|
||||
"aether": "~0.2.32",
|
||||
"aether": "~0.2.39",
|
||||
"underscore.string": "~2.3.3",
|
||||
"firebase": "~1.0.2",
|
||||
"catiline": "~2.9.3",
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
"redis": "",
|
||||
"webworker-threads": "~0.4.11",
|
||||
"node-gyp": "~0.13.0",
|
||||
"aether": "~0.2.32",
|
||||
"aether": "~0.2.39",
|
||||
"JASON": "~0.1.3",
|
||||
"JQDeferred": "~2.1.0"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue