UNPKG

1.13 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ParserDirective = void 0;
4const main_1 = require("./main");
5const line_1 = require("./line");
6class ParserDirective extends line_1.Line {
7 constructor(document, range, nameRange, valueRange) {
8 super(document, range);
9 this.nameRange = nameRange;
10 this.valueRange = valueRange;
11 }
12 toString() {
13 return "# " + this.getName() + '=' + this.getValue();
14 }
15 getNameRange() {
16 return this.nameRange;
17 }
18 getValueRange() {
19 return this.valueRange;
20 }
21 getName() {
22 return this.document.getText().substring(this.document.offsetAt(this.nameRange.start), this.document.offsetAt(this.nameRange.end));
23 }
24 getValue() {
25 return this.document.getText().substring(this.document.offsetAt(this.valueRange.start), this.document.offsetAt(this.valueRange.end));
26 }
27 getDirective() {
28 const directive = main_1.Directive[this.getName().toLowerCase()];
29 return directive === undefined ? null : directive;
30 }
31}
32exports.ParserDirective = ParserDirective;