Let API properties declare their return values should be captured.

Auto complete will know when to add a variable asingment.
This commit is contained in:
Rob 2015-10-29 15:06:42 -04:00
parent 6a28de7c05
commit f0e1fc1f77
2 changed files with 17 additions and 0 deletions
app
schemas/models
views/play/level/tome

View file

@ -97,6 +97,15 @@ PropertyDocumentationSchema = c.object {
description: 'How important this property is to autocomplete.'
minimum: 0
default: 1.0
userShouldCaptureReturn:
type: 'object'
title: 'User Should Capture Return'
properties:
variableName:
type: 'string'
title: 'Variable Name'
description: 'Variable name this property is autocompleted into.'
default: 'result'
DependencySchema = c.object {
title: 'Component Dependency'

View file

@ -445,6 +445,14 @@ module.exports = class SpellView extends CocoView
else
snippetEntries.push entry
if doc.userShouldCaptureReturn
varName = doc.userShouldCaptureReturn.variableName ? 'result'
entry.captureReturn = switch e.language
when 'io' then varName + ' := '
when 'javascript' then 'var ' + varName + ' = '
when 'clojure' then '(let [' + varName + ' '
else varName + ' = '
# TODO: Generalize this snippet replacement
# TODO: Where should this logic live, and what format should it be in?
if attackEntry?