Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Merged
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
130 changes: 71 additions & 59 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,76 @@
},
"program": "./out/debugger/main.js",
"runtime": "node",
"configurationSnippets": [
{
"label": "Ruby: Debug Local File",
"body": {
"name": "Debug Local File",
"type": "Ruby",
"request": "launch",
"program": "^\"\\${workspaceRoot}/main.rb\""
}
},
{
"label": "Ruby: Listen for rdebug-ide",
"body": {
"name": "Listen for rdebug-ide",
"type": "Ruby",
"request": "attach",
"remoteHost": "127.0.0.1",
"remotePort": "1234",
"remoteWorkspaceRoot": "^\"\\${workspaceRoot}\""
}
},
{
"label": "Ruby: Rails server",
"body": {
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"program": "^\"\\${workspaceRoot}/bin/rails\"",
"args": [
"server"
]
}
},
{
"label": "Ruby: RSpec - all",
"body": {
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"program": "^\"\\${workspaceRoot}/bin/rspec\"",
"args": [
"-I",
"^\"\\${workspaceRoot}\""
]
}
},
{
"label": "Ruby: RSpec - active spec file only",
"body": {
"name": "RSpec - active spec file only",
"type": "Ruby",
"request": "launch",
"program": "^\"\\${workspaceRoot}/bin/rspec\"",
"args": [
"-I",
"^\"\\${workspaceRoot}\"",
"^\"\\${file}\""
]
}
},
{
"label": "Ruby: Cucumber",
"body": {
"name": "Cucumber",
"type": "Ruby",
"request": "launch",
"program": "^\"\\${workspaceRoot}/bin/cucumber\""
}
}
],
"configurationAttributes": {
"launch": {
"required": [
Expand Down Expand Up @@ -544,65 +614,7 @@
}
}
}
},
"initialConfigurations": [
{
"name": "Debug Local File",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/main.rb"
},
{
"name": "Listen for rdebug-ide",
"type": "Ruby",
"request": "attach",
"cwd": "${workspaceRoot}",
"remoteHost": "127.0.0.1",
"remotePort": "1234",
"remoteWorkspaceRoot": "${workspaceRoot}"
},
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server"
]
},
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rspec",
"args": [
"-I",
"${workspaceRoot}"
]
},
{
"name": "RSpec - active spec file only",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rspec",
"args": [
"-I",
"${workspaceRoot}",
"${file}"
]
},
{
"name": "Cucumber",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/cucumber"
}
]
}
}
]
}
Expand Down
75 changes: 75 additions & 0 deletions src/providers/configuration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import * as vscode from 'vscode';

export function registerConfigurationProvider(): void {
vscode.debug.registerDebugConfigurationProvider('Ruby', new RubyConfigurationProvider());
}

class RubyConfigurationProvider implements vscode.DebugConfigurationProvider {
public provideDebugConfigurations(
folder: vscode.WorkspaceFolder,
token: vscode.CancellationToken
): Thenable<vscode.DebugConfiguration[]> {
const names: string[] = rubyConfigurations.map(
(config: vscode.DebugConfiguration) => config.name
);

return vscode.window.showQuickPick(names).then((selected: string) => {
return [
rubyConfigurations.find((config: vscode.DebugConfiguration) => config.name === selected),
];
});
}

public resolveDebugConfiguration?(
folder: vscode.WorkspaceFolder | undefined,
debugConfiguration: vscode.DebugConfiguration
): vscode.ProviderResult<vscode.DebugConfiguration> {
const cwd: string = debugConfiguration.cwd || '${workspaceRoot}';

return { ...debugConfiguration, cwd };
}
}

const rubyConfigurations: vscode.DebugConfiguration[] = [
{
name: 'Debug Local File',
type: 'Ruby',
request: 'launch',
program: '${workspaceRoot}/main.rb',
},
{
name: 'Listen for rdebug-ide',
type: 'Ruby',
request: 'attach',
remoteHost: '127.0.0.1',
remotePort: '1234',
remoteWorkspaceRoot: '${workspaceRoot}',
},
{
name: 'Rails server',
type: 'Ruby',
request: 'launch',
program: '${workspaceRoot}/bin/rails',
args: ['server'],
},
{
name: 'RSpec - all',
type: 'Ruby',
request: 'launch',
program: '${workspaceRoot}/bin/rspec',
args: ['-I', '${workspaceRoot}'],
},
{
name: 'RSpec - active spec file only',
type: 'Ruby',
request: 'launch',
program: '${workspaceRoot}/bin/rspec',
args: ['-I', '${workspaceRoot}', '${file}'],
},
{
name: 'Cucumber',
type: 'Ruby',
request: 'launch',
program: '${workspaceRoot}/bin/cucumber',
},
];
2 changes: 2 additions & 0 deletions src/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as utils from './utils';

import languageConfiguration from './languageConfiguration';
import { registerCompletionProvider } from './providers/completion';
import { registerConfigurationProvider } from './providers/configuration';
import { registerFormatter } from './providers/formatter';
import { registerHighlightProvider } from './providers/highlight';
import { registerIntellisenseProvider } from './providers/intellisense';
Expand Down Expand Up @@ -34,6 +35,7 @@ export function activate(context: ExtensionContext): void {
// Register providers
registerCompletionProvider(context, DOCUMENT_SELECTOR);
registerFormatter(context, DOCUMENT_SELECTOR);
registerConfigurationProvider();

if (workspace.rootPath) {
registerLinters(context);
Expand Down