Add Swift programming language
Checklist
- [ ] I have added tests
- [ ] I have updated the docs and cheatsheet
- [ ] I have not broken the cheatsheet
Currently I see the following error when I look at the console. I couldn't figure it out yet why Swift cannot be found in the language definitions.
{
"type": "primitive",
"mark": {
"type": "cursor"
},
"modifiers": [
{
"type": "containingScope",
"scopeType": {
"type": "statement"
}
}
]
}
extensionHostProcess.js:163
Error: Expected language definition entry is missing for languageId swift
at _LanguageDefinitionsImpl.get (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/languages/LanguageDefinitions.ts:157:13)
at ScopeHandlerFactoryImpl.maybeCreate (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts:127:12)
at ContainingScopeStage.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts:37:51)
at /Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:264:49
at Array.flatMap (<anonymous>)
at /Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:264:23
at Array.forEach (<anonymous>)
at processModifierStages (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:263:18)
at TargetPipeline.processPrimitiveTarget (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:241:12)
at TargetPipeline.processTarget (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:99:21)
at TargetPipeline.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:86:29)
at TargetPipelineRunner.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:59:7)
at CommandRunnerImpl.getTargets (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/core/commandRunner/CommandRunnerImpl.ts:236:32)
at CommandRunnerImpl.runAction (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/core/commandRunner/CommandRunnerImpl.ts:224:32)
at CommandRunnerImpl.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/core/commandRunner/CommandRunnerImpl.ts:80:20)
at runCommand (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/runCommand.ts:74:20)
at runCommandWrapper (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/src/registerCommands.ts:43:14)
at cw.h (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:115:32825)
extensionHostProcess.js:163
Currently I see the following error when I look at the console. I couldn't figure it out yet why Swift cannot be found in the language definitions.
{ "type": "primitive", "mark": { "type": "cursor" }, "modifiers": [ { "type": "containingScope", "scopeType": { "type": "statement" } } ] } extensionHostProcess.js:163 Error: Expected language definition entry is missing for languageId swift at _LanguageDefinitionsImpl.get (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/languages/LanguageDefinitions.ts:157:13) at ScopeHandlerFactoryImpl.maybeCreate (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts:127:12) at ContainingScopeStage.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts:37:51) at /Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:264:49 at Array.flatMap (<anonymous>) at /Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:264:23 at Array.forEach (<anonymous>) at processModifierStages (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:263:18) at TargetPipeline.processPrimitiveTarget (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:241:12) at TargetPipeline.processTarget (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:99:21) at TargetPipeline.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:86:29) at TargetPipelineRunner.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts:59:7) at CommandRunnerImpl.getTargets (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/core/commandRunner/CommandRunnerImpl.ts:236:32) at CommandRunnerImpl.runAction (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/core/commandRunner/CommandRunnerImpl.ts:224:32) at CommandRunnerImpl.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/core/commandRunner/CommandRunnerImpl.ts:80:20) at runCommand (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-engine/src/runCommand.ts:74:20) at runCommandWrapper (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/src/registerCommands.ts:43:14) at cw.h (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:115:32825) extensionHostProcess.js:163
It looks like load language has never run. https://github.com/cursorless-dev/cursorless/blob/6c1e0ce7b4eba81a744fdd724cfe44d27807306f/packages/cursorless-engine/src/languages/LanguageDefinitions.ts#L130
Or this code ran, but it was an error. Whenever the cursorless extension starts up have a look at the log.
below is what I see in the first start
Activating tree-sitter...
extensionHostProcess.js:163
Creating communication dir /var/folders/_z/hg3p0pxs2fn7z1985xlhlt5c0000gn/T/vscode-command-server-501
extensionHostProcess.js:163
taking snapshot
when I say "take state" I see the following error. the error code is the same but I think the files mentioned are different
{
"version": 7,
"spokenForm": "take state",
"usePrePhraseSnapshot": true,
"action": {
"name": "setSelection",
"target": {
"type": "primitive",
"modifiers": [
{
"type": "containingScope",
"scopeType": {
"type": "statement"
}
}
]
}
}
}
extensionHostProcess.js:163
taking snapshot
extensionHostProcess.js:163
Full target:
extensionHostProcess.js:163
{
"type": "primitive",
"mark": {
"type": "cursor"
},
"modifiers": [
{
"type": "containingScope",
"scopeType": {
"type": "statement"
}
}
]
}
extensionHostProcess.js:163
Error: Expected language definition entry is missing for languageId swift
at _LanguageDefinitionsImpl.get (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:33609:13)
at ScopeHandlerFactoryImpl.maybeCreate (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:28502:41)
at ContainingScopeStage.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:33880:51)
at /Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:34184:49
at Array.flatMap (<anonymous>)
at /Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:34184:23
at Array.forEach (<anonymous>)
at processModifierStages (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:34183:18)
at TargetPipeline.processPrimitiveTarget (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:34176:12)
at TargetPipeline.processTarget (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:34074:21)
at TargetPipeline.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:34062:29)
at TargetPipelineRunner.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:34037:7)
at CommandRunnerImpl.getTargets (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:40666:32)
at CommandRunnerImpl.runAction (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:40658:32)
at CommandRunnerImpl.run (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:40544:20)
at async runCommand (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:40960:20)
at async runCommandWrapper (/Users/atacan/Developer/Repositories/cursorless-dev-cursorless/packages/cursorless-vscode/dist/extension.cjs:59429:14)
at async cw.h (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:115:32825)
extensionHostProcess.js:163
When I run this code I get the following:
Also you can't just make up your own scopes for the capture names. Cursorless has no idea what to do with @struct, @enum etc.
When I run this code I get the following:
interesting I don't see the red text
When I run this code I get the following:
interesting I don't see the red text
Restart. Clean and recompile.
okay, thank you very much I followed the advice to start small, and made function declaration work
Glad to hear it!
You'll want to re-run step 6 now that you have things working, as the tests are currently actually checking to ensure things are still broken, so they'll fail in CI now
You'll want to re-run step 6 now that you have things working, as the tests are currently actually checking to ensure things are still broken, so they'll fail in CI now
In that step, I say the command "debug edit subset" Then, I get the "testSubsetGrep.properties does not exist on this computer" error because, in the repository, I don't see such a file: cursorless/packages/test-harness/testSubsetGrep.properties'
oh you might need to say "debug generate subset" the first time sorry; worth a quick docs PR saying you need to do that the first time if that's the case
I generated that file. Below is the content of it. But strangely, now when I say "cursorless record scope" I don't see 'swift' in the opened dropdown. But when I run the extension the scopes for Swift works and I don't see any error message.
Also, I assumed "Update fixtures subset" meant to be "VSCode: Update test fixtures (subset)" in the launch.json
# This file contains the grep strings to pass to Mocha when running a subset of tests.
# These grep strings will be used with the "Run test subset" launch configuration.
# See https://mochajs.org/#-grep-regexp-g-regexp for supported syntax.
#
# One regular expression per line.
# Tests matching any of the regular expressions will be run.
languages/swift/
Sorry for a late reply.
I generated that file. Below is the content of it. But strangely, now when I say "cursorless record scope" I don't see 'swift' in the opened dropdown. But when I run the extension the scopes for Swift works and I don't see any error message.
Did you use that voice command when debugging cursorless? First picked the Vscode: Run launch option and then say "Cursorless record scope" in the new window.
Also, I assumed "Update fixtures subset" meant to be "VSCode: Update test fixtures (subset)" in the
launch.json
Correct
