1 | "use strict";
|
2 |
|
3 |
|
4 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
5 | if (k2 === undefined) k2 = k;
|
6 | var desc = Object.getOwnPropertyDescriptor(m, k);
|
7 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
8 | desc = { enumerable: true, get: function() { return m[k]; } };
|
9 | }
|
10 | Object.defineProperty(o, k2, desc);
|
11 | }) : (function(o, m, k, k2) {
|
12 | if (k2 === undefined) k2 = k;
|
13 | o[k2] = m[k];
|
14 | }));
|
15 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
16 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
17 | }) : function(o, v) {
|
18 | o["default"] = v;
|
19 | });
|
20 | var __importStar = (this && this.__importStar) || function (mod) {
|
21 | if (mod && mod.__esModule) return mod;
|
22 | var result = {};
|
23 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
24 | __setModuleDefault(result, mod);
|
25 | return result;
|
26 | };
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | exports.SourceFileLocationFormatter = void 0;
|
29 | const path = __importStar(require("path"));
|
30 | const node_core_library_1 = require("@rushstack/node-core-library");
|
31 | class SourceFileLocationFormatter {
|
32 | |
33 |
|
34 |
|
35 |
|
36 | static formatDeclaration(node, workingPackageFolderPath) {
|
37 | const sourceFile = node.getSourceFile();
|
38 | const lineAndCharacter = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
39 | return SourceFileLocationFormatter.formatPath(sourceFile.fileName, {
|
40 | sourceFileLine: lineAndCharacter.line + 1,
|
41 | sourceFileColumn: lineAndCharacter.character + 1,
|
42 | workingPackageFolderPath
|
43 | });
|
44 | }
|
45 | static formatPath(sourceFilePath, options) {
|
46 | if (!options) {
|
47 | options = {};
|
48 | }
|
49 | let result = '';
|
50 |
|
51 | let scrubbedPath = sourceFilePath;
|
52 | if (options.workingPackageFolderPath) {
|
53 |
|
54 | if (node_core_library_1.Path.isUnderOrEqual(sourceFilePath, options.workingPackageFolderPath)) {
|
55 | scrubbedPath = path.relative(options.workingPackageFolderPath, sourceFilePath);
|
56 | }
|
57 | }
|
58 |
|
59 | scrubbedPath = node_core_library_1.Text.replaceAll(scrubbedPath, '\\', '/');
|
60 | result += scrubbedPath;
|
61 | if (options.sourceFileLine) {
|
62 | result += `:${options.sourceFileLine}`;
|
63 | if (options.sourceFileColumn) {
|
64 | result += `:${options.sourceFileColumn}`;
|
65 | }
|
66 | }
|
67 | return result;
|
68 | }
|
69 | }
|
70 | exports.SourceFileLocationFormatter = SourceFileLocationFormatter;
|
71 |
|
\ | No newline at end of file |