autocomplete

This commit is contained in:
Dominik Kundel 2014-06-16 14:29:01 +01:00
parent e756c83d9e
commit 25a0447d77
2 changed files with 6 additions and 49 deletions

View file

@ -43,8 +43,6 @@ module.exports = class SpellPaletteView extends View
createPalette: -> createPalette: ->
lcs = @supermodel.getModels LevelComponent lcs = @supermodel.getModels LevelComponent
console.log 'IMPORTANT', lcs
Backbone.Mediator.publish 'tome:update-snippets', lcs: lcs
allDocs = {} allDocs = {}
for lc in lcs for lc in lcs
for doc in (lc.get('propertyDocumentation') ? []) for doc in (lc.get('propertyDocumentation') ? [])
@ -78,6 +76,8 @@ module.exports = class SpellPaletteView extends View
tabbify = count >= 10 tabbify = count >= 10
@entries = [] @entries = []
Backbone.Mediator.publish 'tome:update-snippets', propGroups: propGroups, allDocs: allDocs
for owner, props of propGroups for owner, props of propGroups
for prop in props for prop in props
doc = _.find (allDocs['__' + prop] ? []), (doc) -> doc = _.find (allDocs['__' + prop] ? []), (doc) ->

View file

@ -171,54 +171,13 @@ module.exports = class SpellView extends View
@ace.clearSelection() @ace.clearSelection()
addZatannaSnippets: (e) -> addZatannaSnippets: (e) ->
# window.sm = @supermodel
# window.lcM = LevelComponent
# lcs = @supermodel.getModels LevelComponent
# console.log '!!!'
lcs = e.lcs
allDocs = {}
# console.log 'lcs', lcs
for lc in lcs
for doc in (lc.get('propertyDocumentation') ? [])
# console.log '::::'
# console.log 'docX', doc
doc = _.clone doc
allDocs['__' + doc.name] ?= []
allDocs['__' + doc.name].push doc
if doc.type is 'snippet' then doc.owner = 'snippets'
@options.programmable = true
if @options.programmable
propStorage =
'this': 'programmableProperties'
more: 'moreProgrammableProperties'
Math: 'programmableMathProperties'
Array: 'programmableArrayProperties'
Object: 'programmableObjectProperties'
String: 'programmableStringProperties'
Vector: 'programmableVectorProperties'
snippets: 'programmableSnippets'
else
propStorage =
'this': 'apiProperties'
# console.log 'thang', @thang
propGroups = {}
for owner, storage of propStorage
props = _.reject @thang[storage] ? [], (prop) -> prop[0] is '_'
propGroups[owner] = _.sortBy(props).slice()
# console.log 'groups', propGroups
# console.log 'docs', allDocs
snippetEntries = [] snippetEntries = []
for owner, props of propGroups for owner, props of e.propGroups
for prop in props for prop in props
doc = _.find (allDocs['__' + prop] ? []), (doc) -> doc = _.find (e.allDocs['__' + prop] ? []), (doc) ->
return true if doc.owner is owner return true if doc.owner is owner
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this') return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
console.log 'could not find doc for', prop, 'from', allDocs['__' + prop], 'for', owner, 'of', propGroups unless doc console.log 'could not find doc for', prop, 'from', e.allDocs['__' + prop], 'for', owner, 'of', propGroups unless doc
# console.log 'doc', doc
doc ?= prop doc ?= prop
if doc.snippets? if doc.snippets?
entry = entry =
@ -227,11 +186,9 @@ module.exports = class SpellView extends View
tabTrigger: doc.snippets[@spell.language].tab tabTrigger: doc.snippets[@spell.language].tab
snippetEntries.push entry snippetEntries.push entry
# console.log '??'
window.zatanna = @zatanna window.zatanna = @zatanna
window.snippetEntries = snippetEntries window.snippetEntries = snippetEntries
@zatanna.addSnippets snippetEntries, @spell.language
# @zatanna.addSnippets snippetEntries
onMultiplayerChanged: -> onMultiplayerChanged: ->
if @session.get('multiplayer') if @session.get('multiplayer')