當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript debugAdapter.Adapter類代碼示例

本文整理匯總了TypeScript中vs/workbench/parts/debug/node/debugAdapter.Adapter的典型用法代碼示例。如果您正苦於以下問題:TypeScript Adapter類的具體用法?TypeScript Adapter怎麽用?TypeScript Adapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Adapter類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('merge', () => {

		const da: IRawAdapter = {
			type: 'mock',
			win: {
				runtime: 'winRuntime'
			},
			linux: {
				runtime: 'linuxRuntime'
			},
			osx: {
				runtime: 'osxRuntime'
			},
			runtimeArgs: ['first arg'],
			program: 'mockprogram',
			args: ['arg']
		};

		adapter.merge(da, {
			name: 'my name',
			id: 'my_id',
			version: '1.0',
			publisher: 'mockPublisher',
			isBuiltin: true,
			extensionFolderPath: 'a/b/c/d',
			engines: null
		});

		return adapter.getAdapterExecutable(undefined, false).then(details => {
			assert.equal(details.command, platform.isLinux ? da.linux.runtime : platform.isMacintosh ? da.osx.runtime : da.win.runtime);
			assert.deepEqual(details.args, da.runtimeArgs.concat(['a/b/c/d/mockprogram'].concat(da.args)));
		});
	});
開發者ID:,項目名稱:,代碼行數:33,代碼來源:

示例2: suite

suite('Debug - Adapter', () => {
	let adapter: Adapter;
	const extensionFolderPath = 'a/b/c/';
	const rawAdapter = {
		type: 'mock',
		label: 'Mock Debug',
		enableBreakpointsFor: { 'languageIds': ['markdown'] },
		program: './out/mock/mockDebug.js',
		args: ['arg1', 'arg2'],
		configurationAttributes: {
			launch: {
				required: ['program'],
				properties: {
					program: {
						'type': 'string',
						'description': 'Workspace relative path to a text file.',
						'default': 'readme.md'
					}
				}
			}
		},
		variables: null,
		initialConfigurations: [
			{
				name: 'Mock-Debug',
				type: 'mock',
				request: 'launch',
				program: 'readme.md'
			}
		]
	};

	setup(() => {
		adapter = new Adapter(rawAdapter, { extensionFolderPath, id: 'adapter', name: 'myAdapter', version: '1.0.0', publisher: 'vscode', isBuiltin: false, engines: null },
			null, new TestConfigurationService(), null);
	});

	teardown(() => {
		adapter = null;
	});

	test('attributes', () => {
		assert.equal(adapter.type, rawAdapter.type);
		assert.equal(adapter.label, rawAdapter.label);

		return adapter.getAdapterExecutable(undefined, false).then(details => {
			assert.equal(details.command, paths.join(extensionFolderPath, rawAdapter.program));
			assert.deepEqual(details.args, rawAdapter.args);
		});
	});

	test('schema attributes', () => {
		const schemaAttribute = adapter.getSchemaAttributes()[0];
		assert.notDeepEqual(schemaAttribute, rawAdapter.configurationAttributes);
		Object.keys(rawAdapter.configurationAttributes.launch).forEach(key => {
			assert.deepEqual(schemaAttribute[key], rawAdapter.configurationAttributes.launch[key]);
		});

		assert.equal(schemaAttribute['additionalProperties'], false);
		assert.equal(!!schemaAttribute['properties']['request'], true);
		assert.equal(!!schemaAttribute['properties']['name'], true);
		assert.equal(!!schemaAttribute['properties']['type'], true);
		assert.equal(!!schemaAttribute['properties']['preLaunchTask'], true);
	});

	test('merge', () => {

		const da: IRawAdapter = {
			type: 'mock',
			win: {
				runtime: 'winRuntime'
			},
			linux: {
				runtime: 'linuxRuntime'
			},
			osx: {
				runtime: 'osxRuntime'
			},
			runtimeArgs: ['first arg'],
			program: 'mockprogram',
			args: ['arg']
		};

		adapter.merge(da, {
			name: 'my name',
			id: 'my_id',
			version: '1.0',
			publisher: 'mockPublisher',
			isBuiltin: true,
			extensionFolderPath: 'a/b/c/d',
			engines: null
		});

		return adapter.getAdapterExecutable(undefined, false).then(details => {
			assert.equal(details.command, platform.isLinux ? da.linux.runtime : platform.isMacintosh ? da.osx.runtime : da.win.runtime);
			assert.deepEqual(details.args, da.runtimeArgs.concat(['a/b/c/d/mockprogram'].concat(da.args)));
		});
	});

	test('initial config file content', () => {
//.........這裏部分代碼省略.........
開發者ID:,項目名稱:,代碼行數:101,代碼來源:

示例3: suite

suite('Debug - Adapter', () => {
	var adapter: Adapter;
	var extensionFolderPath = 'a/b/c/';
	var rawAdapter = {
		type: 'mock',
		label: 'Mock Debug',
		enableBreakpointsFor: { 'languageIds': [ 'markdown' ] },
		program: './out/mock/mockDebug.js',
		win: {
			runtime: 'winRuntime'
		},
		linux: {
			runtime: 'linuxRuntime'
		},
		osx: {
			runtime: 'osxRuntime'
		},
		configurationAttributes: {
			launch: {
				required: [ 'program' ],
				properties: {
					program: {
						'type': 'string',
						'description': 'Workspace relative path to a text file.',
						'default': 'readme.md'
					}
				}
			}
		},

		initialConfigurations: [
			{
				name: 'Mock-Debug',
				type: 'mock',
				request: 'launch',
				program: 'readme.md'
			}
		]
	}

	setup(() => {
		adapter = new Adapter(rawAdapter, null, { extensionFolderPath, id: 'adapter', name: 'myAdapter', version: '1.0.0', publisher: 'vscode', isBuiltin: false, engines: null });
	});

	teardown(() => {
		adapter = null;
	});

	test('adapter attributes', () => {
		assert.equal(adapter.type, rawAdapter.type);
		assert.equal(adapter.label, rawAdapter.label);
		assert.equal(adapter.program, paths.join(extensionFolderPath, rawAdapter.program));
		assert.equal(adapter.runtime, platform.isLinux ? rawAdapter.linux.runtime : platform.isMacintosh ? rawAdapter.osx.runtime : rawAdapter.win.runtime);
		assert.deepEqual(adapter.initialConfigurations, rawAdapter.initialConfigurations);
	});

	test('schema attributes', () => {
		const schemaAttribute = adapter.getSchemaAttributes()[0];
		assert.notDeepEqual(schemaAttribute, rawAdapter.configurationAttributes);
		Object.keys(rawAdapter.configurationAttributes.launch).forEach(key => {
			assert.deepEqual(schemaAttribute[key], rawAdapter.configurationAttributes.launch[key]);
		});

		assert.equal(schemaAttribute['additionalProperties'], false);
		assert.equal(!!schemaAttribute['properties']['request'], true);
		assert.equal(!!schemaAttribute['properties']['name'], true);
		assert.equal(!!schemaAttribute['properties']['type'], true);
		assert.equal(!!schemaAttribute['properties']['preLaunchTask'], true);
	});
});
開發者ID:JackWangCUMT,項目名稱:vscode,代碼行數:70,代碼來源:debugAdapter.test.ts

示例4:

	test('initial config file content', () => {
		adapter.getInitialConfigurationContent(null).then(content => {
			const expected = ['{',
				'	"version": "0.2.0",',
				'	"configurations": [',
				'		{',
				'			"name": "Mock-Debug",',
				'			"type": "mock",',
				'			"request": "launch",',
				'			"program": "readme.md"',
				'		}',
				'	]',
				'}'].join('\n');
			assert.equal(content, expected);
		}, err => assert.fail());
	});
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例5:

	test('merge', () => {
		const runtimeArgs = ['first arg'];
		adapter.merge({
			type: 'mock',
			runtimeArgs,
			program: 'mockprogram'
		}, {
				name: 'my name',
				id: 'my_id',
				version: '1.0',
				publisher: 'mockPublisher',
				isBuiltin: true,
				extensionFolderPath: 'a/b/c/d',
				engines: null
			});

		assert.deepEqual(adapter.runtimeArgs, runtimeArgs);
		assert.equal(adapter.program, 'a/b/c/d/mockprogram');
	});
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:19,代碼來源:debugAdapter.test.ts

示例6:

	test('initial config file content', () => {

		const expected = ['{',
			'	// Use IntelliSense to learn about possible attributes.',
			'	// Hover to view descriptions of existing attributes.',
			'	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387',
			'	"version": "0.2.0",',
			'	"configurations": [',
			'		{',
			'			"name": "Mock-Debug",',
			'			"type": "mock",',
			'			"request": "launch",',
			'			"program": "readme.md"',
			'		}',
			'	]',
			'}'].join('\n');

		return adapter.getInitialConfigurationContent().then(content => {
			assert.equal(content, expected);
		}, err => assert.fail());
	});
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:21,代碼來源:debugAdapter.test.ts


注:本文中的vs/workbench/parts/debug/node/debugAdapter.Adapter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。