UNPKG

@abaplint/core

Version:
70 lines 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Highlight = void 0; const _abap_object_1 = require("../objects/_abap_object"); const syntax_1 = require("../abap/5_syntax/syntax"); const _lsp_utils_1 = require("./_lsp_utils"); class Highlight { constructor(reg) { this.reg = reg; } listDefinitionPositions(textDocument) { const spaghetti = this.runSyntax(textDocument); if (spaghetti === undefined) { return []; } const defs = spaghetti.listDefinitions(textDocument.uri); const ret = []; for (const d of defs) { ret.push(_lsp_utils_1.LSPUtils.tokenToRange(d.identifier.getToken())); } return ret; } listReadPositions(textDocument) { const spaghetti = this.runSyntax(textDocument); if (spaghetti === undefined) { return []; } const reads = spaghetti.listReadPositions(textDocument.uri); const ret = []; for (const d of reads) { ret.push(_lsp_utils_1.LSPUtils.tokenToRange(d.getToken())); } return ret; } listWritePositions(textDocument) { const spaghetti = this.runSyntax(textDocument); if (spaghetti === undefined) { return []; } const writes = spaghetti.listWritePositions(textDocument.uri); const ret = []; for (const d of writes) { ret.push(_lsp_utils_1.LSPUtils.tokenToRange(d.getToken())); } return ret; } //////////////////////// runSyntax(textDocument) { const obj = this.findObject(textDocument); if (obj === undefined) { return undefined; } return new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti; } findObject(textDocument) { const file = _lsp_utils_1.LSPUtils.getABAPFile(this.reg, textDocument.uri); if (file === undefined) { return undefined; } const obj = this.reg.getObject(file.getObjectType(), file.getObjectName()); if (obj instanceof _abap_object_1.ABAPObject) { return obj; } else { return undefined; } } } exports.Highlight = Highlight; //# sourceMappingURL=highlight.js.map