Class CdtVariableResolver


  • public class CdtVariableResolver
    extends java.lang.Object
    Utility class to resolve macro and variable references. Provides fixture to parse ${macro} expressions and replace macros with actual values using IVariableSubstitutor.
    Since:
    3.0
    • Field Detail

      • VAR_CONFIG_NAME

        public static final java.lang.String VAR_CONFIG_NAME
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_CONFIG_DESCRIPTION

        public static final java.lang.String VAR_CONFIG_DESCRIPTION
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_PROJ_NAME

        public static final java.lang.String VAR_PROJ_NAME
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_PROJ_DIR_PATH

        public static final java.lang.String VAR_PROJ_DIR_PATH
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_WORKSPACE_DIR_PATH

        public static final java.lang.String VAR_WORKSPACE_DIR_PATH
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_DIRECTORY_DELIMITER

        public static final java.lang.String VAR_DIRECTORY_DELIMITER
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_PATH_DELIMITER

        public static final java.lang.String VAR_PATH_DELIMITER
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_ECLIPSE_VERSION

        public static final java.lang.String VAR_ECLIPSE_VERSION
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_CDT_VERSION

        public static final java.lang.String VAR_CDT_VERSION
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_HOST_OS_NAME

        public static final java.lang.String VAR_HOST_OS_NAME
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_HOST_ARCH_NAME

        public static final java.lang.String VAR_HOST_ARCH_NAME
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_OS_TYPE

        public static final java.lang.String VAR_OS_TYPE
        Since:
        5.5
        See Also:
        Constant Field Values
      • VAR_ARCH_TYPE

        public static final java.lang.String VAR_ARCH_TYPE
        Since:
        5.5
        See Also:
        Constant Field Values
    • Constructor Detail

      • CdtVariableResolver

        public CdtVariableResolver()
    • Method Detail

      • convertStringListToString

        public static java.lang.String convertStringListToString​(java.lang.String[] value,
                                                                 java.lang.String listDelimiter)
        Converts list of strings to one string using given string as delimiter, i.e -> "string1:string2:string3"
        Parameters:
        value - - list of strings to convert.
        listDelimiter - - delimiter.
        Returns:
        all strings from the list separated with given delimiter.
      • resolveToString

        public static java.lang.String resolveToString​(java.lang.String string,
                                                       IVariableSubstitutor substitutor)
                                                throws CdtVariableException
        Resolves macros of kind ${Macro} in the given string by calling the macro substitutor for each macro reference found. Macros can be inside one another like ${workspace_loc:/${ProjName}/} but resolved just once. No recursive macro names are allowed. It is not possible to prevent macros from expanding. For historical reasons (See Bug 571472), macros that are multi-line according to Pattern's Line Terminators are not expanded.
        Parameters:
        string - - macro expression.
        substitutor - - macro resolution provider to retrieve macro values.
        Returns:
        resolved string
        Throws:
        CdtVariableException - if substitutor can't handle the macro and returns null or throws.
      • resolveStringListValues

        public static java.lang.String[] resolveStringListValues​(java.lang.String[] values,
                                                                 IVariableSubstitutor substitutor,
                                                                 boolean ignoreErrors)
                                                          throws CdtVariableException
        Resolves array of macros using substitutor to pull macro's list of values. Note that each macro of input array can in turn provide list of values and the resulting array combines all of them.
        Parameters:
        values - - input array of macros.
        substitutor - - macro resolution provider to retrieve macro values.
        ignoreErrors - - if true then exceptions are caught and ignored.
        Returns:
        array of resolved values.
        Throws:
        CdtVariableException - if substitutor throws CdtVariableException and ignoreErrors=null.
      • resolveToStringList

        public static java.lang.String[] resolveToStringList​(java.lang.String string,
                                                             IVariableSubstitutor substitutor)
                                                      throws CdtVariableException
        Resolves macro ${ListMacro} in the given String to the String-list using substitutor to pull macro's list of values. If the provided string is not exactly a single macro it is treated as macro expression and result is put into the first element of resulting array.
        Parameters:
        string - - input string.
        substitutor - - macro resolution provider to retrieve macro values.
        Returns:
        array of resolved values.
        Throws:
        CdtVariableException - if substitutor can't handle the macro and returns null or throws.
      • isStringListVariable

        public static boolean isStringListVariable​(int macroType)
        Test for String-list type of macro.
        Parameters:
        macroType - - type of tested macro.
        Returns:
        true if the given macro is a String-list macro.
      • createVariableReference

        public static java.lang.String createVariableReference​(java.lang.String name)
        Constructs a macro reference given the macro name e.g. if the "macro1" name is passed, returns "${macro1}"
        Parameters:
        name - - macro name.
        Returns:
        macro variable in form "${macro}"