UNPKG

alm

Version:

The best IDE for TypeScript

53 lines (52 loc) 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils = require("../../../../common/utils"); var typescriptDir = require("../core/typeScriptDir"); var fsu = require("../../../utils/fsu"); var transformers = require("./transformers"); /** We just use the *active* project if any */ var activeProject = require("../activeProject"); var getProject = activeProject.GetProject.getCurrentIfAny; function getTopLevelModuleNames(query) { var project = getProject(); var getNodeKind = ts.getNodeKind; var files = []; for (var _i = 0, _a = project.getProjectSourceFiles().filter(function (f) { return !typescriptDir.isFileInTypeScriptDir(f.fileName); }); _i < _a.length; _i++) { var sourceFile = _a[_i]; var _b = transformers.transformSourceFile(sourceFile), comment = _b.comment, subItems = _b.subItems, icon = _b.icon, location_1 = _b.location; var filePath = sourceFile.fileName; var name_1 = fsu.removeExt(fsu.makeRelativePath(project.configFile.projectFileDirectory, filePath).substr(2)); files.push({ name: name_1, icon: icon, comment: comment, subItems: subItems, location: location_1, }); } /** sort by filePath */ files.sort(function (a, b) { return a.name.localeCompare(b.name); }); var result = { files: files }; return utils.resolve(result); } exports.getTopLevelModuleNames = getTopLevelModuleNames; /** * If a file is edited and you are showing the documentation for the file, * Its not a bad idea to call this function for updated information */ function getUpdatedModuleInformation(query) { var project = getProject(); var sourceFile = project.getProjectSourceFiles().find(function (sf) { return sf.fileName == query.filePath; }); var _a = transformers.transformSourceFile(sourceFile), comment = _a.comment, subItems = _a.subItems, icon = _a.icon, location = _a.location; var filePath = sourceFile.fileName; var name = fsu.removeExt(fsu.makeRelativePath(project.configFile.projectFileDirectory, filePath).substr(2)); var result = { name: name, icon: icon, comment: comment, subItems: subItems, location: location, }; return utils.resolve(result); } exports.getUpdatedModuleInformation = getUpdatedModuleInformation;