ifc-language-server/client/out/test/helper.js
Ryan Schultz 8afacf268a Implemented a working Language Server Protocol (LSP) for IFC files with:
- Hover provider showing entity information and type
- Go-to-definition (F12) for entity references
- Basic IFC file validation (ISO-10303-21 header check)
- Entity parsing with regex-based detection
- Proper CommonJS module system (avoiding ES module issues)

This replaces the broken baseline from ifc-developer-tools which had:
- Non-functional ES module configuration
- Circular dependency issues
- Parser crashes
- Non-working PositionVisitor

Built on Microsoft's LSP example template for a clean, maintainable foundation.

Next: Add hierarchical entity dependency tree in hover tooltip."
2025-12-07 10:20:07 -06:00

43 lines
No EOL
1.8 KiB
JavaScript

"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDocUri = exports.getDocPath = exports.platformEol = exports.documentEol = exports.editor = exports.doc = void 0;
exports.activate = activate;
exports.setTestContent = setTestContent;
const vscode = require("vscode");
const path = require("path");
/**
* Activates the vscode.lsp-sample extension
*/
async function activate(docUri) {
// The extensionId is `publisher.name` from package.json
const ext = vscode.extensions.getExtension('vscode-samples.lsp-sample');
await ext.activate();
try {
exports.doc = await vscode.workspace.openTextDocument(docUri);
exports.editor = await vscode.window.showTextDocument(exports.doc);
await sleep(2000); // Wait for server activation
}
catch (e) {
console.error(e);
}
}
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const getDocPath = (p) => {
return path.resolve(__dirname, '../../testFixture', p);
};
exports.getDocPath = getDocPath;
const getDocUri = (p) => {
return vscode.Uri.file((0, exports.getDocPath)(p));
};
exports.getDocUri = getDocUri;
async function setTestContent(content) {
const all = new vscode.Range(exports.doc.positionAt(0), exports.doc.positionAt(exports.doc.getText().length));
return exports.editor.edit(eb => eb.replace(all, content));
}
//# sourceMappingURL=helper.js.map