UNPKG

3.29 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Variable = void 0;
4class Variable {
5 constructor(name, nameRange, range, modifier, modifierRange, substitutionParameter, substitutionRange, defined, buildVariable, stringValue) {
6 this.name = name;
7 this.nameRange = nameRange;
8 this.range = range;
9 this.modifier = modifier;
10 this.modifierRange = modifierRange;
11 this.substitutionParameter = substitutionParameter;
12 this.substitutionRange = substitutionRange;
13 this.defined = defined;
14 this.buildVariable = buildVariable;
15 this.stringValue = stringValue;
16 }
17 toString() {
18 return this.stringValue;
19 }
20 getName() {
21 return this.name;
22 }
23 getNameRange() {
24 return this.nameRange;
25 }
26 /**
27 * Returns the range of the entire variable. This includes the symbols for
28 * the declaration of the variable such as the $, {, and } symbols.
29 *
30 * @return the range in the document that this variable encompasses in its
31 * entirety
32 */
33 getRange() {
34 return this.range;
35 }
36 /**
37 * Returns the modifier character that has been set for
38 * specifying how this variable should be expanded and resolved.
39 * If this variable is ${variable:+value} then the modifier
40 * character is '+'. Will be the empty string if the variable is
41 * declared as ${variable:}. Otherwise, will be null if this
42 * variable will not use variable substitution at all (such as
43 * ${variable} or $variable).
44 *
45 * @return this variable's modifier character, or the empty
46 * string if it does not have one, or null if this
47 * variable will not use variable substitution
48 */
49 getModifier() {
50 return this.modifier;
51 }
52 getModifierRange() {
53 return this.modifierRange;
54 }
55 /**
56 * Returns the parameter that will be used for substitution if
57 * this variable uses modifiers to define how its value should be
58 * resolved. If this variable is ${variable:+value} then the
59 * substitution value will be 'value'. Will be the empty string
60 * if the variable is declared as ${variable:+} or some other
61 * variant where the only thing that follows the modifier
62 * character (excluding considerations of escape characters and
63 * so on) is the variable's closing bracket. May be null if this
64 * variable does not have a modifier character defined (such as
65 * ${variable} or $variable).
66 *
67 * @return this variable's substitution parameter, or the empty
68 * string if it does not have one, or null if there is
69 * not one defined
70 */
71 getSubstitutionParameter() {
72 return this.substitutionParameter;
73 }
74 getSubstitutionRange() {
75 return this.substitutionRange;
76 }
77 /**
78 * Returns whether this variable has been defined or not.
79 *
80 * @return true if this variable has been defined, false otherwise
81 */
82 isDefined() {
83 return this.defined;
84 }
85 isBuildVariable() {
86 return this.buildVariable === true;
87 }
88 isEnvironmentVariable() {
89 return this.buildVariable === false;
90 }
91}
92exports.Variable = Variable;