diff --git a/CHANGELOG.md b/CHANGELOG.md index 0042f6a..4f90ddc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to the "Biffy" extension will be documented in this file. Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. +## 1.6.0 +### Added +* Command to open a mapped file based on the GUID + ## 1.5.2 ### Changed * Running mapping on a bxml page, now saves and updates the corresponding content in the BIF-Source/mapped folder. diff --git a/README.md b/README.md index 2d5a406..fcd2559 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ This is the repository for VS Code extension for BIF. * Syntax highlighting * Block commenting (`Ctrl + K + C` and `Ctrl + K + U`) * Snippet completion +* Open premapped bxml view based in GUID ## Configuration diff --git a/package.json b/package.json index 97807d4..ebb44e9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Biffy", "description": "Language tools for BIF", "publisher": "spoorthi", - "version": "1.5.3", + "version": "1.6.0", "license": "SEE LICENSE IN LICENSE", "engines": { "vscode": "^1.30.0" @@ -22,7 +22,8 @@ }, "activationEvents": [ "onLanguage:bif", - "onCommand:biffy.mapObject" + "onCommand:biffy.mapObject", + "onCommand:biffy.openMappedFile" ], "main": "./out/src/extension", "icon": "images/icon.png", @@ -86,11 +87,15 @@ "commands": [ { "command": "biffy.mapObject", - "title": "Generate Merged Preview" + "title": "Biffy : Generate Merged Preview" }, { "command": "biffy.generateGuid", - "title": "Generate GUID" + "title": "Biffy : Generate GUID" + }, + { + "command": "biffy.openMappedFile", + "title": "Biffy : Open Mapped File" } ], "keybindings": [ diff --git a/src/extension.ts b/src/extension.ts index 6a438fd..843b274 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -52,5 +52,11 @@ export function activate(context: vscode.ExtensionContext): void { vscode.window.activeTextEditor.insertSnippet(new vscode.SnippetString(guid)); } }); + + vscode.commands.registerCommand('biffy.openMappedFile', async () => { + vscode.window.showInputBox({ prompt : "Which mapped file to open ?" }).then(value => { + bifMapObject.openMappedFile(value); + }); + }); } diff --git a/src/features/BifMapObject.ts b/src/features/BifMapObject.ts index d0882ce..c2b1592 100644 --- a/src/features/BifMapObject.ts +++ b/src/features/BifMapObject.ts @@ -1,5 +1,6 @@ import * as vscode from 'vscode' -import * as path from 'path' +import * as path from 'path'; +import * as fs from 'fs'; import Helper from '../utils/helper'; import { ITypeScriptServiceClient } from '../ITypeScriptServiceClient'; @@ -54,6 +55,30 @@ export default class BifMapObject { return path.basename(document.fileName); } + public openMappedFile(mappedId : string) { + if(this.helper.checkGuidValidity(mappedId)) { + var mappedFolderPath = path.join(this.bifSourcePath, "mapped"); + if(fs.existsSync(mappedFolderPath)) { + let file = fs.readdirSync(mappedFolderPath).filter(file => fs.statSync(path.join(mappedFolderPath, file)).isFile()).find(file => file.startsWith(mappedId)); + if(file) { + var filePath = path.join(mappedFolderPath, file); + vscode.workspace.openTextDocument(vscode.Uri.file(filePath)).then(document => { + vscode.window.showTextDocument(document).then(); + }); + } + else { + vscode.window.showErrorMessage("File not found in mapped folder : " + mappedId + ".bxml"); + } + } + else { + vscode.window.showErrorMessage("Mapped folder doesn't exist at " + mappedFolderPath); + } + } + else { + vscode.window.showErrorMessage("Input wasnt a valid guid"); + } + } + private isBXMLFile(mappedFileName) : boolean { var ext = mappedFileName.substr(mappedFileName.lastIndexOf('.') + 1); if(ext === "bxml") {