-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Purple no folder VS Code debugging support (#645)
* Handle configuration resolving for no folder (purple) instances falling back to launch (Xdebug 3) configuration. * When resolving debug configuration search path for php, warn user about missing executable and offer to open settings with filter. * Trigger start debug from editor title. * No folder debugging description on README.md * Use special command to trigger debugging of no-folder PHP files. * Changelog. * Ignore extension.ts from codecov. Co-authored-by: Damjan Cvetko <[email protected]>
- Loading branch information
Showing
9 changed files
with
145 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore: | ||
- 'src/extension.ts' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as vscode from 'vscode' | ||
import { WorkspaceFolder, DebugConfiguration, ProviderResult, CancellationToken } from 'vscode' | ||
import { LaunchRequestArguments } from './phpDebug' | ||
import * as which from 'which' | ||
|
||
export function activate(context: vscode.ExtensionContext) { | ||
context.subscriptions.push( | ||
vscode.debug.registerDebugConfigurationProvider('php', { | ||
async resolveDebugConfiguration( | ||
folder: WorkspaceFolder | undefined, | ||
debugConfiguration: DebugConfiguration & LaunchRequestArguments, | ||
token?: CancellationToken | ||
): Promise<ProviderResult<DebugConfiguration>> { | ||
if (!debugConfiguration.type && !debugConfiguration.request && !debugConfiguration.name) { | ||
const editor = vscode.window.activeTextEditor | ||
if (editor && editor.document.languageId === 'php') { | ||
debugConfiguration.type = 'php' | ||
debugConfiguration.name = 'Launch (dynamic)' | ||
debugConfiguration.request = 'launch' | ||
debugConfiguration.program = '${file}' | ||
debugConfiguration.cwd = '${fileDirname}' | ||
debugConfiguration.port = 0 | ||
debugConfiguration.runtimeArgs = ['-dxdebug.start_with_request=yes'] | ||
debugConfiguration.env = { | ||
XDEBUG_MODE: 'debug,develop', | ||
XDEBUG_CONFIG: 'client_port=${port}', | ||
} | ||
// debugConfiguration.stopOnEntry = true | ||
} | ||
} | ||
if (debugConfiguration.program && !debugConfiguration.runtimeExecutable) { | ||
// See if we have runtimeExecutable configured | ||
const conf = vscode.workspace.getConfiguration('php') | ||
const executablePath = | ||
conf.get<string>('executablePath') || conf.get<string>('validate.executablePath') | ||
if (executablePath) { | ||
debugConfiguration.runtimeExecutable = executablePath | ||
} | ||
// See if it's in path | ||
if (!debugConfiguration.runtimeExecutable) { | ||
try { | ||
await which.default('php') | ||
} catch (e) { | ||
const selected = await vscode.window.showErrorMessage( | ||
'PHP executable not found. Install PHP and add it to your PATH or set the php.executablePath setting', | ||
'Open settings' | ||
) | ||
if (selected === 'Open settings') { | ||
await vscode.commands.executeCommand('workbench.action.openGlobalSettings', { | ||
query: 'php.executablePath', | ||
}) | ||
return undefined | ||
} | ||
} | ||
} | ||
} | ||
return debugConfiguration | ||
}, | ||
}) | ||
) | ||
|
||
context.subscriptions.push( | ||
vscode.commands.registerCommand('php.debug.debugPhpFile', async (uri: vscode.Uri) => { | ||
vscode.debug.startDebugging(undefined, { type: '', name: '', request: '' }) | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters