Пример #1
0
  AbstractConfigValue lookupSubst(
      ResolveContext context, SubstitutionExpression subst, int prefixLength)
      throws NotPossibleToResolve {
    context.trace(subst);
    try {
      // First we look up the full path, which means relative to the
      // included file if we were not a root file
      AbstractConfigValue result = findInObject(root, context, subst);

      if (result == null) {
        // Then we want to check relative to the root file. We don't
        // want the prefix we were included at to be used when looking
        // up env variables either.
        SubstitutionExpression unprefixed = subst.changePath(subst.path().subPath(prefixLength));

        // replace the debug trace path
        context.untrace();
        context.trace(unprefixed);

        if (prefixLength > 0) {
          result = findInObject(root, context, unprefixed);
        }

        if (result == null && context.options().getUseSystemEnvironment()) {
          result = findInObject(ConfigImpl.envVariablesAsConfigObject(), context, unprefixed);
        }
      }

      if (result != null) {
        result = context.resolve(result);
      }

      return result;
    } finally {
      context.untrace();
    }
  }