Skip to content

Commit

Permalink
add new configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-kotulski committed Aug 1, 2024
1 parent 1f892db commit fd32504
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"]
}
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
],
"outFiles": [
"${workspaceFolder}/editor/dist/**/*.js"
],
}
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
73 changes: 73 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "watch",
"dependsOn": [
"npm: watch:tsc",
"npm: watch:esbuild"
],
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"options": {
"cwd": "${workspaceFolder}/editor/"
},
"script": "watch:esbuild",
"group": "build",
"problemMatcher": "$esbuild-watch",
"isBackground": true,
"label": "npm: watch:esbuild",
"presentation": {
"group": "watch",
"reveal": "never"
}
},
{
"type": "npm",
"options": {
"cwd": "${workspaceFolder}/editor/"
},
"script": "watch:tsc",
"group": "build",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"label": "npm: watch:tsc",
"presentation": {
"group": "watch",
"reveal": "never"
}
},
{
"type": "npm",
"options": {
"cwd": "${workspaceFolder}/editor/"
},
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": [
"npm: watch",
"npm: watch-tests"
],
"problemMatcher": []
}
]
}
5 changes: 3 additions & 2 deletions editor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 39 additions & 18 deletions editor/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
{
"name": "4d-debugger",
"displayName": "4D-Debugger",
"license": "4D",
"publisher": "4D",
"license": "4D",
"publisher": "4D",
"description": "",
"version": "0.0.1",
"engines": {
"vscode": "^1.90.0"
},
"repository": {
"type": "git",
"url": "https://github.com/4d/4D-Debugger-VSCode"
},
"type": "git",
"url": "https://github.com/4d/4D-Debugger-VSCode"
},
"categories": [
"Debuggers", "Programming Languages"
"Debuggers",
"Programming Languages"
],
"activationEvents": [
"onDebug"
"onDebug",
"onDebugResolve:4d",
"onDebugInitialConfigurations"
],
"main": "./dist/extension.js",
"contributes": {
"commands": [
],
"commands": [],
"breakpoints": [
{
"language": "4d"
Expand Down Expand Up @@ -50,7 +52,11 @@
"description": "Enable logging of the Debug Adapter Protocol.",
"default": true
},
"port":{
"args": {
"type": "array",
"description": "Arguments passed to the 4D server"
},
"port": {
"type": "number",
"description": "Port to connect to the 4D server",
"default": 19815
Expand All @@ -59,7 +65,8 @@
},
"attach": {
"required": [
"program"
"program",
"port"
],
"properties": {
"program": {
Expand All @@ -72,7 +79,7 @@
"description": "Enable logging of the Debug Adapter Protocol.",
"default": true
},
"port":{
"port": {
"type": "number",
"description": "Port to connect to the 4D server",
"default": 19815
Expand All @@ -83,21 +90,35 @@
"initialConfigurations": [
{
"type": "4d",
"request": "launch",
"name": "Ask for file name",
"request": "attach",
"name": "Attach",
"program": "${workspaceFolder}",
"port": 19815
}
],
"configurationSnippets": [
{
"label": "4D Debug: Attach",
"description": "Attach the 4D app to a remote debugger",
"body": {
"type": "4d",
"request": "attach",
"name": "Attach",
"program": "${workspaceFolder}",
"port": 19815
}
},
{
"label": "4D Debug: Launch",
"description": "A new configuration for 'debugging' a user selected markdown file.",
"description": "Attach the 4D app to a remote debugger",
"body": {
"type": "4d",
"request": "launch",
"name": "Ask for file name",
"program": "${workspaceFolder}"
"name": "Launch",
"program": "${workspaceFolder}",
"args": [
"--project"
]
}
}
]
Expand Down Expand Up @@ -130,4 +151,4 @@
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0"
}
}
}
47 changes: 22 additions & 25 deletions editor/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as vscode from 'vscode';
import { WorkspaceFolder, DebugConfiguration, ProviderResult, CancellationToken } from 'vscode';


const kPortNumber : number = 19815;
export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "4d-debug" is now active!');
activateMockDebug(context);
start(context);
}

// This method is called when your extension is deactivated
Expand All @@ -13,41 +13,37 @@ export function deactivate() {
}


export function activateMockDebug(context: vscode.ExtensionContext) {
export function start(context: vscode.ExtensionContext) {

const provider = new MockConfigurationProvider();
const provider = new ConfigurationProvider();
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('4d', provider));

context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('4d', {
provideDebugConfigurations(folder: WorkspaceFolder | undefined): ProviderResult<DebugConfiguration[]> {
console.log('provideDebugConfigurations', folder);
return [
{
name: "Dynamic Launch",
request: "launch",
name: "4D:Attach",
request: "attach",
type: "4d",
program: "${file}"
program: "${workspaceFolder}",
port: kPortNumber,
},
{
name: "Another Dynamic Launch",
name: "4D:Launch",
request: "launch",
type: "4d",
program: "${file}"
},
{
name: "4D Launch",
request: "launch",
type: "4d",
program: "${file}"
program: "${workspaceFolder}"
}
];
}
}, vscode.DebugConfigurationProviderTriggerKind.Dynamic));
let factory: vscode.DebugAdapterDescriptorFactory = new MockDebugAdapterServerDescriptorFactory();
let factory: vscode.DebugAdapterDescriptorFactory = new DebugAdapterServerDescriptorFactory();
context.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory('4d', factory));

}

class MockConfigurationProvider implements vscode.DebugConfigurationProvider {
class ConfigurationProvider implements vscode.DebugConfigurationProvider {

/**
* Message a debug configuration just before a debug session is being launched,
Expand All @@ -56,13 +52,15 @@ class MockConfigurationProvider implements vscode.DebugConfigurationProvider {
resolveDebugConfiguration(folder: WorkspaceFolder | undefined, config: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration> {

// if launch.json is missing or empty
console.log(config);
if (!config.type && !config.request && !config.name) {
const editor = vscode.window.activeTextEditor;
if (editor && editor.document.languageId === 'markdown') {
if (editor && editor.document.languageId === '4d') {
config.type = '4d';
config.name = 'Launch';
config.request = 'launch';
config.program = '${file}';
config.name = '4D:Attach';
config.request = 'attach';
config.port = kPortNumber;
config.program = '${workspaceFolder}';
config.stopOnEntry = true;
}
}
Expand All @@ -75,15 +73,14 @@ class MockConfigurationProvider implements vscode.DebugConfigurationProvider {

return config;
}
}


}


class MockDebugAdapterServerDescriptorFactory implements vscode.DebugAdapterDescriptorFactory {
class DebugAdapterServerDescriptorFactory implements vscode.DebugAdapterDescriptorFactory {

createDebugAdapterDescriptor(session: vscode.DebugSession, executable: vscode.DebugAdapterExecutable | undefined): vscode.ProviderResult<vscode.DebugAdapterDescriptor> {
let port = session?.configuration.port ?? 19815;
let port = session?.configuration.port ?? kPortNumber;
// make VS Code connect to debug server
return new vscode.DebugAdapterServer(port);
}
Expand Down

0 comments on commit fd32504

Please sign in to comment.