Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coffeescript integration #113

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/kernel-manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = KernelManager =
return kernels

getTrueLanguage: (language) ->
language = 'javascript' if language in ['coffeescript','closurescript','babel','typescript']
languageMappings = @getLanguageMappings()
matchingLanguageKeys = _.filter languageMappings, (trueLanguage, languageKey) ->
return languageKey.toLowerCase() == language.toLowerCase()
Expand All @@ -77,7 +78,6 @@ module.exports = KernelManager =
getKernelInfoForLanguage: (language) ->
kernels = @getAvailableKernels()
console.log "Available kernels:", kernels

language = @getTrueLanguage(language)

matchingKernels = _.filter kernels, (kernel) ->
Expand Down Expand Up @@ -125,14 +125,14 @@ module.exports = KernelManager =
execute: (language, code, onResults) ->
kernel = @getRunningKernelForLanguage(language)
if kernel?
kernel.execute(code, onResults)
kernel.execute(code, onResults, language)
else
throw "No such kernel!"

complete: (language, code, onResults) ->
kernel = @getRunningKernelForLanguage(language)
if kernel?
kernel.complete(code, onResults)
kernel.complete(code, onResults, language)
else
throw "No such kernel!"

Expand Down
13 changes: 10 additions & 3 deletions lib/kernel.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Kernel
@language = @kernelInfo.language.toLowerCase()
@executionCallbacks = {}
@watchCallbacks = []

@loadedExtensions = []
grammar = @getGrammarForLanguage(@language)
@watchSidebar = new WatchSidebar(this, grammar)
@statusView = new StatusView(@language)
Expand Down Expand Up @@ -145,15 +145,22 @@ class Kernel

@signedSend message, @shellSocket

execute: (code, onResults) ->
handleExtensions: (code, language) ->
if language == 'coffeescript'
if language not in @loadedExtensions
@_execute '%load_ext coffee', => @loadedeExtensions.push language
"%%coffee bare no-prompt\n"+code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main issue with this is that it flies in the face of the JavaScript kernel I'm currently using, ijavascript. It would be nice to unify the JS/Node kernels, otherwise we're going to have this special matrix of handlers for Hydrogen.

Then again, if there's a way we can tell which kernel is setup, we can defer to the right one.


execute: (code, onResults, language=@language) ->
requestId = "execute_" + uuid.v4()
code = @handleExtensions code, language
@_execute(code, requestId, onResults)

executeWatch: (code, onResults) ->
requestId = "watch_" + uuid.v4()
@_execute(code, requestId, onResults)

complete: (code, onResults) ->
complete: (code, onResults, language) ->
console.log "sending completion"

requestId = "complete_" + uuid.v4()
Expand Down