Skip to content

Commit

Permalink
fixed and improved variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Apr 9, 2024
1 parent f8d4f1d commit 4601632
Show file tree
Hide file tree
Showing 8 changed files with 442 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,14 @@ private String resolve(String value, Object src, int recursion, Object rootSrc,
StringBuilder sb = new StringBuilder(value.length() + EXTRA_CAPACITY);
do {
String variableName = matcher.group(2);
String variableValue = resolvedVars.getValue(variableName);
String variableValue = resolvedVars.getValue(variableName, false);
if (variableValue == null) {
this.context.warning("Undefined variable {} in '{}={}' for root '{}={}'", variableName, src, value, rootSrc,
rootValue);
continue;
}
EnvironmentVariables lowestFound = findVariable(variableName);
boolean isNotSelfReferencing = lowestFound == null || !lowestFound.getFlat(variableName).equals(value);

if (isNotSelfReferencing) {
if ((lowestFound == null) || !lowestFound.getFlat(variableName).equals(value)) {
// looking for "variableName" starting from resolved upwards the hierarchy
String replacement = resolvedVars.resolve(variableValue, variableName, recursion, rootSrc, rootValue,
resolvedVars);
Expand Down Expand Up @@ -254,9 +252,12 @@ private String resolve(String value, Object src, int recursion, Object rootSrc,
* default values.
*
* @param name the name of the variable to get.
* @param ignoreDefaultValue - {@code true} if the {@link VariableDefinition#getDefaultValue(IdeContext) default
* value} of a potential {@link VariableDefinition} shall be ignored, {@code false} to return default instead
* of {@code null}.
* @return the value of the variable.
*/
protected String getValue(String name) {
protected String getValue(String name, boolean ignoreDefaultValue) {

VariableDefinition<?> var = IdeVariables.get(name);
String value;
Expand All @@ -268,9 +269,11 @@ protected String getValue(String name) {
if ((value == null) && (var != null)) {
String key = var.getName();
if (!name.equals(key)) {
// try new name (e.g. IDE_TOOLS or IDE_HOME) if no value could be found by given legacy name (e.g.
// DEVON_IDE_TOOLS or DEVON_IDE_HOME)
value = this.parent.get(key);
}
if (value == null) {
if ((value == null) && !ignoreDefaultValue) {
value = var.getDefaultValueAsString(this.context);
}
}
Expand Down
Loading

0 comments on commit 4601632

Please sign in to comment.