Class CdtVariableResolver
- java.lang.Object
-
- org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver
-
public class CdtVariableResolver extends Object
Utility class to resolve macro and variable references. Provides fixture to parse ${macro} expressions and replace macros with actual values usingIVariableSubstitutor
.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description static String
VAR_ARCH_TYPE
static String
VAR_CDT_VERSION
static String
VAR_CONFIG_DESCRIPTION
static String
VAR_CONFIG_NAME
static String
VAR_DIRECTORY_DELIMITER
static String
VAR_ECLIPSE_VERSION
static String
VAR_HOST_ARCH_NAME
static String
VAR_HOST_OS_NAME
static String
VAR_OS_TYPE
static String
VAR_PATH_DELIMITER
static String
VAR_PROJ_DIR_PATH
static String
VAR_PROJ_NAME
static String
VAR_WORKSPACE_DIR_PATH
static String
VARIABLE_PREFIX
static char
VARIABLE_SUFFIX
-
Constructor Summary
Constructors Constructor Description CdtVariableResolver()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
checkIntegrity(IVariableContextInfo info, IVariableSubstitutor substitutor)
Checks the macros integrity for the given context.static void
checkVariables(String string, IVariableSubstitutor substitutor)
Deprecated.UseresolveToString(java.lang.String, org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor)
which would do full nested expansion.static String
convertStringListToString(String[] value, String listDelimiter)
Converts list of strings to one string using given string as delimiter, i.e -> "string1:string2:string3"static String
createVariableReference(String name)
Constructs a macro reference given the macro name e.g.static boolean
isStringListVariable(int macroType)
Test for String-list type of macro.static String[]
resolveStringListValues(String[] values, IVariableSubstitutor substitutor, boolean ignoreErrors)
Resolves array of macros usingsubstitutor
to pull macro's list of values.static String
resolveToString(String string, IVariableSubstitutor substitutor)
Resolves macros of kind ${Macro} in the given string by calling the macro substitutor for each macro reference found.static String[]
resolveToStringList(String string, IVariableSubstitutor substitutor)
Resolves macro ${ListMacro} in the given String to the String-list using substitutor to pull macro's list of values.
-
-
-
Field Detail
-
VAR_CONFIG_NAME
public static final String VAR_CONFIG_NAME
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_CONFIG_DESCRIPTION
public static final String VAR_CONFIG_DESCRIPTION
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_PROJ_NAME
public static final String VAR_PROJ_NAME
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_PROJ_DIR_PATH
public static final String VAR_PROJ_DIR_PATH
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_WORKSPACE_DIR_PATH
public static final String VAR_WORKSPACE_DIR_PATH
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_DIRECTORY_DELIMITER
public static final String VAR_DIRECTORY_DELIMITER
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_PATH_DELIMITER
public static final String VAR_PATH_DELIMITER
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_ECLIPSE_VERSION
public static final String VAR_ECLIPSE_VERSION
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_CDT_VERSION
public static final String VAR_CDT_VERSION
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_HOST_OS_NAME
public static final String VAR_HOST_OS_NAME
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_HOST_ARCH_NAME
public static final String VAR_HOST_ARCH_NAME
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_OS_TYPE
public static final String VAR_OS_TYPE
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VAR_ARCH_TYPE
public static final String VAR_ARCH_TYPE
- Since:
- 5.5
- See Also:
- Constant Field Values
-
VARIABLE_PREFIX
public static final String VARIABLE_PREFIX
- See Also:
- Constant Field Values
-
VARIABLE_SUFFIX
public static final char VARIABLE_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
convertStringListToString
public static String convertStringListToString(String[] value, 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 String resolveToString(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 toPattern
'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.
-
checkVariables
@Deprecated public static void checkVariables(String string, IVariableSubstitutor substitutor) throws CdtVariableException
Deprecated.UseresolveToString(java.lang.String, org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor)
which would do full nested expansion.finds the macro references in the given string and calls the macro substitutor for each macro found this could be used for obtaining the list of macros referenced in the given string, etc.- Parameters:
string
-substitutor
-- Throws:
CdtVariableException
-
resolveStringListValues
public static String[] resolveStringListValues(String[] values, IVariableSubstitutor substitutor, boolean ignoreErrors) throws CdtVariableException
Resolves array of macros usingsubstitutor
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
- - iftrue
then exceptions are caught and ignored.- Returns:
- array of resolved values.
- Throws:
CdtVariableException
- if substitutor throwsCdtVariableException
andignoreErrors
=null
.
-
resolveToStringList
public static String[] resolveToStringList(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.
-
checkIntegrity
public static void checkIntegrity(IVariableContextInfo info, IVariableSubstitutor substitutor) throws CdtVariableException
Checks the macros integrity for the given context. If test failsCdtVariableException
is thrown.- Parameters:
info
- - context information to acquire list of available macros.substitutor
- - macro resolution provider to retrieve macro values.- Throws:
CdtVariableException
- propagated up ifsubstitutor
throws.
-
-