ifc-language-server/client/node_modules/vscode-languageclient/lib/common/executeCommand.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

72 lines
2.9 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.ExecuteCommandFeature = void 0;
const vscode_1 = require("vscode");
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const UUID = require("./utils/uuid");
const features_1 = require("./features");
class ExecuteCommandFeature {
constructor(client) {
this._client = client;
this._commands = new Map();
}
getState() {
return { kind: 'workspace', id: this.registrationType.method, registrations: this._commands.size > 0 };
}
get registrationType() {
return vscode_languageserver_protocol_1.ExecuteCommandRequest.type;
}
fillClientCapabilities(capabilities) {
(0, features_1.ensure)((0, features_1.ensure)(capabilities, 'workspace'), 'executeCommand').dynamicRegistration = true;
}
initialize(capabilities) {
if (!capabilities.executeCommandProvider) {
return;
}
this.register({
id: UUID.generateUuid(),
registerOptions: Object.assign({}, capabilities.executeCommandProvider)
});
}
register(data) {
const client = this._client;
const middleware = client.middleware;
const executeCommand = (command, args) => {
let params = {
command,
arguments: args
};
return client.sendRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, params).then(undefined, (error) => {
return client.handleFailedRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, undefined, error, undefined);
});
};
if (data.registerOptions.commands) {
const disposables = [];
for (const command of data.registerOptions.commands) {
disposables.push(vscode_1.commands.registerCommand(command, (...args) => {
return middleware.executeCommand
? middleware.executeCommand(command, args, executeCommand)
: executeCommand(command, args);
}));
}
this._commands.set(data.id, disposables);
}
}
unregister(id) {
let disposables = this._commands.get(id);
if (disposables) {
disposables.forEach(disposable => disposable.dispose());
}
}
clear() {
this._commands.forEach((value) => {
value.forEach(disposable => disposable.dispose());
});
this._commands.clear();
}
}
exports.ExecuteCommandFeature = ExecuteCommandFeature;