extensions/extension-editing/src/extensionEditingMain.ts/createNamedNodeLookUp
	export async function createNamedNodeLookUp(str: string): Promise<NamedNodeLookUp> {

		const ts = await import('typescript');

		const sourceFile = ts.createSourceFile('fake.d.ts', str, ts.ScriptTarget.Latest);

		const identifiers: string[] = [];
		const spans: number[] = [];

		ts.forEachChild(sourceFile, function visit(node: ts.Node) {
			const declIdent = (<ts.NamedDeclaration>node).name;
			if (declIdent && declIdent.kind === ts.SyntaxKind.Identifier) {
				identifiers.push((<ts.Identifier>declIdent).text);
				spans.push(node.pos, node.end);
			}
			ts.forEachChild(node, visit);
		});

		return function (dottedName: string): number {
			let start = -1;
			let end = Number.MAX_VALUE;

			for (let name of dottedName.split('.')) {
				let idx: number = -1;
				while ((idx = identifiers.indexOf(name, idx + 1)) >= 0) {
					let myStart = spans[2 * idx];
					let myEnd = spans[2 * idx + 1];
					if (myStart >= start && myEnd <= end) {
						start = myStart;
						end = myEnd;
						break;
					}
				}
				if (idx < 0) {
					return -1;
				}
			}
			return start;
		};
	}