Class CdtVariableResolver
java.lang.Object
org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver
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 Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final char
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkIntegrity
(IVariableContextInfo info, IVariableSubstitutor substitutor) Checks the macros integrity for the given context.static void
checkVariables
(String string, IVariableSubstitutor substitutor) Deprecated.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
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 Details
-
VAR_CONFIG_NAME
- Since:
- 5.5
- See Also:
-
VAR_CONFIG_DESCRIPTION
- Since:
- 5.5
- See Also:
-
VAR_PROJ_NAME
- Since:
- 5.5
- See Also:
-
VAR_PROJ_DIR_PATH
- Since:
- 5.5
- See Also:
-
VAR_WORKSPACE_DIR_PATH
- Since:
- 5.5
- See Also:
-
VAR_DIRECTORY_DELIMITER
- Since:
- 5.5
- See Also:
-
VAR_PATH_DELIMITER
- Since:
- 5.5
- See Also:
-
VAR_ECLIPSE_VERSION
- Since:
- 5.5
- See Also:
-
VAR_CDT_VERSION
- Since:
- 5.5
- See Also:
-
VAR_HOST_OS_NAME
- Since:
- 5.5
- See Also:
-
VAR_HOST_ARCH_NAME
- Since:
- 5.5
- See Also:
-
VAR_OS_TYPE
- Since:
- 5.5
- See Also:
-
VAR_ARCH_TYPE
- Since:
- 5.5
- See Also:
-
VARIABLE_PREFIX
- See Also:
-
VARIABLE_SUFFIX
public static final char VARIABLE_SUFFIX- See Also:
-
-
Constructor Details
-
CdtVariableResolver
public CdtVariableResolver()
-
-
Method Details
-
convertStringListToString
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.
-
createVariableReference
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}"
-
resolveToString(java.lang.String, org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor)
which would do full nested expansion.