-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Add Swift programming language #2734
base: main
Are you sure you want to change the base?
Conversation
- Introduced `swiftScopeSupport` to manage language-specific scope features. - Updated `languageScopeSupport` to include Swift support. - Created a new file for Swift scope support definitions.
- Expanded `swiftScopeSupport` to include new language-specific features such as `collectionKey`, `className.iteration`, and `type.protocol`. - Updated handling of ternary operators and introduced Swift-specific conditions like `condition.guard`. - Added a new query file `swift.scm` to define grammar rules for Swift, covering statements, declarations, and control flow constructs.
- Updated `swiftScopeSupport` to use `key.mapPair` and `key.mapPair.iteration` instead of `collectionKey` and its iteration counterpart. - Modified the corresponding grammar rules in `swift.scm` to reflect these changes, ensuring proper handling of dictionary key-value pairs.
…tter query file. Here are the key changes made: 1. In swift.ts: Removed all iteration-specific scopes Simplified to use base scope types only Removed unsupported Swift-specific scopes Kept only standard scope types that are documented and used across languages In swift.scm: Removed @textFragment annotations Simplified function declarations to use standard @namedFunction Updated dictionary key-value pairs to use standard @key and @value Removed iteration-specific scopes Updated argument handling to use @argument.actual and @argument.formal Removed operator-specific annotations Simplified branch and condition handling Removed all iteration scopes for blocks, classes, and file-level
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.
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
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 |
Also you can't just make up your own scopes for the capture names. Cursorless has no idea what to do with |
okay, thank you very much I followed the advice to start small, and made function declaration work |
Glad to hear it! |
…array, dictionary, and regex declarations
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: |
…ling in swift.scm
oh you might need to say |
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 # 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/ |
Checklist