Skip to content

Commit 8f22cbe

Browse files
committed
(GH-459) Consolidate debug features into a single feature
Previously there were two debug features, one for the factory and one for the configuration. This commit moves the functionality of the DebugConfiguration into the DebuggingFeature.
1 parent 98bcd4b commit 8f22cbe

File tree

3 files changed

+46
-63
lines changed

3 files changed

+46
-63
lines changed

src/extension.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { StdioConnectionHandler } from './handlers/stdio';
99
import { TcpConnectionHandler } from './handlers/tcp';
1010
import { IFeature } from './feature';
1111
import { DebuggingFeature } from './feature/DebuggingFeature';
12-
import { DebugConfigurationFeature } from './feature/DebugConfigurationFeature';
1312
import { FormatDocumentFeature } from './feature/FormatDocumentFeature';
1413
import { NodeGraphFeature } from './feature/NodeGraphFeature';
1514
import { PDKFeature } from './feature/PDKFeature';
@@ -70,7 +69,6 @@ export function activate(context: vscode.ExtensionContext) {
7069
}
7170

7271
extensionFeatures = [
73-
new DebugConfigurationFeature(logger, extContext),
7472
new FormatDocumentFeature(puppetLangID, connectionHandler, settings, logger, extContext),
7573
new NodeGraphFeature(puppetLangID, connectionHandler, logger, extContext),
7674
new PDKFeature(extContext, logger),

src/feature/DebugConfigurationFeature.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/feature/DebuggingFeature.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,50 @@ export class DebugAdapterDescriptorFactory implements vscode.DebugAdapterDescrip
9494
}
9595
}
9696

97+
export class DebugConfigurationProvider implements vscode.DebugConfigurationProvider {
98+
private debugType: string;
99+
private logger: ILogger;
100+
private context: vscode.ExtensionContext;
101+
102+
constructor(debugType:string, logger: ILogger, context: vscode.ExtensionContext) {
103+
this.debugType = debugType;
104+
this.logger = logger;
105+
this.context = context;
106+
}
107+
108+
public provideDebugConfigurations(
109+
folder: vscode.WorkspaceFolder | undefined,
110+
token?: vscode.CancellationToken
111+
): vscode.ProviderResult<vscode.DebugConfiguration[]> {
112+
return [ this.createLaunchConfigFromContext(folder) ];
113+
}
114+
115+
public resolveDebugConfiguration(
116+
folder: vscode.WorkspaceFolder | undefined,
117+
debugConfiguration: vscode.DebugConfiguration,
118+
token?: vscode.CancellationToken
119+
): vscode.ProviderResult<vscode.DebugConfiguration> {
120+
return debugConfiguration;
121+
}
122+
123+
private createLaunchConfigFromContext(folder: vscode.WorkspaceFolder | undefined): vscode.DebugConfiguration {
124+
let config = {
125+
type: this.debugType,
126+
request: 'launch',
127+
name: 'Puppet Apply current file',
128+
manifest: "${file}",
129+
args: [],
130+
noop: true,
131+
cwd: "${file}",
132+
};
133+
134+
return config;
135+
}
136+
}
137+
97138
export class DebuggingFeature implements IFeature {
98139
private factory: DebugAdapterDescriptorFactory;
140+
private provider: DebugConfigurationProvider;
99141

100142
constructor(
101143
debugType: string,
@@ -105,9 +147,13 @@ export class DebuggingFeature implements IFeature {
105147
logger: ILogger
106148
) {
107149
this.factory = new DebugAdapterDescriptorFactory(context, settings, config, logger);
150+
this.provider = new DebugConfigurationProvider(debugType, logger, context);
108151

109152
logger.debug("Registered DebugAdapterDescriptorFactory for " + debugType);
110153
context.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory(debugType, this.factory));
154+
155+
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider(debugType, this.provider));
156+
logger.debug("Registered DebugConfigurationProvider for " + debugType);
111157
}
112158

113159
public dispose(): any {

0 commit comments

Comments
 (0)