New Features: - New sidebar panel 'IFC Entity References' shows all locations where an entity is used - Ctrl+Click on any entity now updates BOTH hierarchy and references panels - Clicking items in hierarchy tree updates references panel (but keeps hierarchy view) - Command 'IFC: Find Entity References' to manually trigger reference search - Clickable reference items jump directly to that line in the file - Shows line numbers and reference icons for clarity Usage: - Ctrl+Click #13 → see what #13 depends on (hierarchy) AND where #13 is used (references) - Click #4 in hierarchy tree → jump to #4 and see where #4 is used - Both panels work together to give complete entity relationship view Makes it easy to understand both dependencies (what it uses) and usage (what uses it).
91 lines
No EOL
3.3 KiB
JavaScript
91 lines
No EOL
3.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.IfcReferencesProvider = void 0;
|
|
const vscode = require("vscode");
|
|
class IfcReferencesProvider {
|
|
_onDidChangeTreeData = new vscode.EventEmitter();
|
|
onDidChangeTreeData = this._onDidChangeTreeData.event;
|
|
references = [];
|
|
documentUri = null;
|
|
targetEntityId = null;
|
|
refresh() {
|
|
this._onDidChangeTreeData.fire();
|
|
}
|
|
async findReferences(entityId, document) {
|
|
this.targetEntityId = entityId;
|
|
this.documentUri = document.uri;
|
|
this.references = [];
|
|
const text = document.getText();
|
|
const lines = text.split('\n');
|
|
// Find all lines that reference this entity
|
|
lines.forEach((line, lineIndex) => {
|
|
// Skip the definition line itself
|
|
const defPattern = new RegExp(`^#${entityId}=`);
|
|
if (defPattern.test(line.trim())) {
|
|
return;
|
|
}
|
|
// Look for references to this entity
|
|
const refPattern = new RegExp(`#${entityId}\\b`, 'g');
|
|
if (refPattern.test(line)) {
|
|
// Find which entity this line belongs to
|
|
const entityMatch = /^#(\d+)=/.exec(line.trim());
|
|
const lineEntityId = entityMatch ? parseInt(entityMatch[1]) : 0;
|
|
this.references.push({
|
|
line: lineIndex,
|
|
entityId: lineEntityId,
|
|
fullText: line.trim()
|
|
});
|
|
}
|
|
});
|
|
this.refresh();
|
|
}
|
|
getTreeItem(element) {
|
|
return element;
|
|
}
|
|
getChildren(element) {
|
|
if (!this.targetEntityId || this.references.length === 0) {
|
|
return Promise.resolve([]);
|
|
}
|
|
if (!element) {
|
|
// Root level - show summary and all references
|
|
const items = this.references.map(ref => this.createTreeItem(ref));
|
|
return Promise.resolve(items);
|
|
}
|
|
return Promise.resolve([]);
|
|
}
|
|
createTreeItem(ref) {
|
|
const treeItem = new ReferenceTreeItem(ref, vscode.TreeItemCollapsibleState.None);
|
|
// Make it clickable - jump to line when clicked
|
|
if (this.documentUri) {
|
|
treeItem.command = {
|
|
command: 'vscode.open',
|
|
title: 'Go to Reference',
|
|
arguments: [
|
|
this.documentUri,
|
|
{
|
|
selection: new vscode.Range(new vscode.Position(ref.line, 0), new vscode.Position(ref.line, ref.fullText.length))
|
|
}
|
|
]
|
|
};
|
|
}
|
|
return treeItem;
|
|
}
|
|
getReferencesCount() {
|
|
return this.references.length;
|
|
}
|
|
}
|
|
exports.IfcReferencesProvider = IfcReferencesProvider;
|
|
class ReferenceTreeItem extends vscode.TreeItem {
|
|
reference;
|
|
collapsibleState;
|
|
constructor(reference, collapsibleState) {
|
|
super(reference.fullText, collapsibleState);
|
|
this.reference = reference;
|
|
this.collapsibleState = collapsibleState;
|
|
this.tooltip = reference.fullText;
|
|
this.description = `Line ${reference.line + 1}`;
|
|
// Add an icon to indicate it's a reference
|
|
this.iconPath = new vscode.ThemeIcon('references');
|
|
}
|
|
}
|
|
//# sourceMappingURL=ifcReferencesProvider.js.map
|