org.eclipse.cdt.managedbuilder.internal.macros
Class BuildMacroProvider

java.lang.Object
  extended by org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider
All Implemented Interfaces:
IMacroContextInfoProvider, IBuildMacroProvider

public class BuildMacroProvider
extends java.lang.Object
implements IBuildMacroProvider, IMacroContextInfoProvider

The default IBuildMacroProvider implementation

Since:
3.0

Field Summary
static MbsMacroSupplier fMbsMacroSupplier
           
 
Fields inherited from interface org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider
CONTEXT_CONFIGURATION, CONTEXT_ECLIPSEENV, CONTEXT_FILE, CONTEXT_INSTALLATIONS, CONTEXT_OPTION, CONTEXT_PROJECT, CONTEXT_TOOL, CONTEXT_WORKSPACE
 
Method Summary
 boolean areMacrosExpandedInBuildfile(IConfiguration cfg)
          answers whether the environment macros are to be expanded in the buildfile
static boolean canKeepMacrosInBuildfile(IBuilder builder)
          answers whether the given builder is capable of handling macros in the buildfile
static boolean canKeepMacrosInBuildfile(IConfiguration cfg)
          answers whether the builder used for the given configuration is capable of handling macros in the buildfile
 void checkIntegrity(int contextType, java.lang.Object contextData)
          checks the integrity of the Macros If there are inconsistencies, such as when a macro value refers to a nonexistent macro or when two macros refer to each other, this method will throw the BuildMacroException exception The BuildMacroException will contain the human-readable string describing the inconsistency and the array of the IBuildMacro interfaces that will represent the macros that caused the inconsistency.
 java.lang.String convertStringListToString(java.lang.String[] value, java.lang.String listDelimiter)
          converts StringList value into String of the following format: "< listDelimiter >< listDelimiter > ...
static java.lang.String createBuildfileMacroReference(java.lang.String name, IBuilder builder)
          creates a macro reference in the buildfile format for the given builder.
static java.lang.String createBuildfileMacroReference(java.lang.String name, IConfiguration cfg)
          creates a macro reference in the buildfile format for the builder used for the given configuration.
static CoreMacrosSupplier createCoreSupplier(IConfiguration cfg)
           
 boolean expandMacrosInBuildfile(IConfiguration cfg, boolean expand)
          sets whether the environment macros are to be expanded in the buildfile or not If a bulder does not support treating environment variables as its own ones this method has no effect Returns the result of this set operation.
 org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor getBuildfileMacroSubstitutor(IMacroContextInfo info, java.lang.String inexistentMacroValue, java.lang.String listDelimiter)
           
static BuildMacroProvider getDefault()
           
 IBuildMacro getMacro(java.lang.String macroName, int contextType, java.lang.Object contextData, boolean includeParentContexts)
          Returns reference to the IBuildMacro interface representing Macro of the specified name or null if there is there is no such macro
 IMacroContextInfo getMacroContextInfo(int contextType, java.lang.Object contextData)
           
 IBuildMacro[] getMacros(int contextType, java.lang.Object contextData, boolean includeParentContexts)
           
 org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor getMacroSubstitutor(IMacroContextInfo info, java.lang.String inexistentMacroValue, java.lang.String listDelimiter)
           
static IBuildMacro[] getReferencedExplitFileMacros(ITool tool)
          Returns the array of the explicit file macros, referenced in the tool's options (Explicit file macros are the file-specific macros, whose values are not provided by the tool-integrator.
static IBuildMacro[] getReferencedExplitFileMacros(java.lang.String expression, int contextType, java.lang.Object contextData)
          Returns the array of the explicit file macros, referenced in the given string (Explicit file macros are the file-specific macros, whose values are not provided by the tool-integrator.
 IBuildMacroSupplier[] getSuppliers(int contextType, java.lang.Object contextData)
          This method is defined to be used primarily by the UI classes and should not be used by the tool-integrator
 ICdtVariable getVariable(java.lang.String macroName, int contextType, java.lang.Object contextData, boolean includeParentContexts)
           
 ICdtVariable[] getVariables(int contextType, java.lang.Object contextData, boolean includeParentContexts)
           
 boolean isStringListValue(java.lang.String value, int contextType, java.lang.Object contextData)
           
 java.lang.String[] resolveStringListValue(java.lang.String value, java.lang.String nonexistentMacrosValue, java.lang.String listDelimiter, int contextType, java.lang.Object contextData)
          if the string contains a value that can be treated as a StringList resolves it to arrays of strings otherwise throws the BuildMacroException exception
 java.lang.String[] resolveStringListValues(java.lang.String[] value, java.lang.String nonexistentMacrosValue, java.lang.String listDelimiter, int contextType, java.lang.Object contextData)
          resolves macros in the array of string-list values
 java.lang.String[] resolveStringListValuesToMakefileFormat(java.lang.String[] value, java.lang.String nonexistentMacrosValue, java.lang.String listDelimiter, int contextType, java.lang.Object contextData)
          resolves macros in the array of string-list values macros are resolved to the makefile format
 java.lang.String[] resolveStringListValueToMakefileFormat(java.lang.String value, java.lang.String nonexistentMacrosValue, java.lang.String listDelimiter, int contextType, java.lang.Object contextData)
          if the string contains a value that can be treated as a StringList resolves it to arrays of strings otherwise throws the BuildMacroException exception each string of the returned array will contain all macro references resolved in case of a user has specified to resolve the build macros, and will contain the string with the environment macro references unresolved and converted to the buildfile format otherwise
 java.lang.String resolveValue(java.lang.String value, java.lang.String nonexistentMacrosValue, java.lang.String listDelimiter, int contextType, java.lang.Object contextData)
          resolves all macros in the string.
 java.lang.String resolveValueToMakefileFormat(java.lang.String value, java.lang.String nonexistentMacrosValue, java.lang.String listDelimiter, int contextType, java.lang.Object contextData)
          resolves all macros in the string to the makefile format.
static IBuildMacro wrap(ICdtVariable var)
           
static IBuildMacro[] wrap(ICdtVariable[] vars)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fMbsMacroSupplier

public static MbsMacroSupplier fMbsMacroSupplier
Method Detail

getDefault

public static BuildMacroProvider getDefault()

getMacro

public IBuildMacro getMacro(java.lang.String macroName,
                            int contextType,
                            java.lang.Object contextData,
                            boolean includeParentContexts)
Description copied from interface: IBuildMacroProvider
Returns reference to the IBuildMacro interface representing Macro of the specified name or null if there is there is no such macro

Specified by:
getMacro in interface IBuildMacroProvider
Parameters:
macroName - macro name
contextType - represents the context type. Should be set to one of the the IBuildMacroProvider. CONTEXT_xxx constants
contextData - represents the additional data needed by the Build Macro Provider and Macro Suppliers in order to obtain the macro value. The type of the context data differs depending on the context type and can be one of the following: 1. IFileContextData interface � used to represent currently selected file context the IFileContextData interface is defined as follows: pulic interface IFileContextData{ IFile getFile(); IOption getOption(); } NOTE: the IFileContextData is passed that represents the current file and the option for that file because Macro Value Provider needs to know what option should be used as a context in case macro is not found for �current file� context 2. IOptionContextData interface used to represent the currently selected option context 3. IConfiguration � used to represent the currently selected configuration context 4. IProject � used to represent current project context 5. IWorkspace � used to represent current workspace context 6. null � to represent the CDT and Eclipse installation context 7. null � to represent process environment context

getMacros

public IBuildMacro[] getMacros(int contextType,
                               java.lang.Object contextData,
                               boolean includeParentContexts)
Specified by:
getMacros in interface IBuildMacroProvider
Returns:
the array of the IBuildMacro representing all available macros

createCoreSupplier

public static CoreMacrosSupplier createCoreSupplier(IConfiguration cfg)

getVariable

public ICdtVariable getVariable(java.lang.String macroName,
                                int contextType,
                                java.lang.Object contextData,
                                boolean includeParentContexts)
Specified by:
getVariable in interface IBuildMacroProvider

getVariables

public ICdtVariable[] getVariables(int contextType,
                                   java.lang.Object contextData,
                                   boolean includeParentContexts)
Specified by:
getVariables in interface IBuildMacroProvider
Returns:
the array of the IBuildMacro representing all available macros

getSuppliers

public IBuildMacroSupplier[] getSuppliers(int contextType,
                                          java.lang.Object contextData)
Description copied from interface: IBuildMacroProvider
This method is defined to be used primarily by the UI classes and should not be used by the tool-integrator

Specified by:
getSuppliers in interface IBuildMacroProvider
Returns:
the array of the provider-internal suppliers for the given context

getMacroContextInfo

public IMacroContextInfo getMacroContextInfo(int contextType,
                                             java.lang.Object contextData)
Specified by:
getMacroContextInfo in interface IMacroContextInfoProvider
Parameters:
contextType -
contextData -
Returns:

convertStringListToString

public java.lang.String convertStringListToString(java.lang.String[] value,
                                                  java.lang.String listDelimiter)
Description copied from interface: IBuildMacroProvider
converts StringList value into String of the following format: "< listDelimiter >< listDelimiter > ... "

Specified by:
convertStringListToString in interface IBuildMacroProvider

wrap

public static IBuildMacro wrap(ICdtVariable var)

wrap

public static IBuildMacro[] wrap(ICdtVariable[] vars)

resolveValue

public java.lang.String resolveValue(java.lang.String value,
                                     java.lang.String nonexistentMacrosValue,
                                     java.lang.String listDelimiter,
                                     int contextType,
                                     java.lang.Object contextData)
                              throws BuildMacroException
Description copied from interface: IBuildMacroProvider
resolves all macros in the string.

Specified by:
resolveValue in interface IBuildMacroProvider
Parameters:
value - the value to be resolved
nonexistentMacrosValue - specifies the value that inexistent macro references will be expanded to. If null the BuildMacroException is thrown in case the string to be resolved references inexistent macros
listDelimiter - if not null, StringList macros are expanded as �< listDelimiter >< listDelimiter > ... � otherwise the BuildMacroException is thrown in case the string to be resolved references string-list macros
contextType - context from which the macro search should be started
contextData - context data
Throws:
BuildMacroException

resolveStringListValue

public java.lang.String[] resolveStringListValue(java.lang.String value,
                                                 java.lang.String nonexistentMacrosValue,
                                                 java.lang.String listDelimiter,
                                                 int contextType,
                                                 java.lang.Object contextData)
                                          throws BuildMacroException
Description copied from interface: IBuildMacroProvider
if the string contains a value that can be treated as a StringList resolves it to arrays of strings otherwise throws the BuildMacroException exception

Specified by:
resolveStringListValue in interface IBuildMacroProvider
Throws:
BuildMacroException
See Also:
isStringListValue

resolveValueToMakefileFormat

public java.lang.String resolveValueToMakefileFormat(java.lang.String value,
                                                     java.lang.String nonexistentMacrosValue,
                                                     java.lang.String listDelimiter,
                                                     int contextType,
                                                     java.lang.Object contextData)
                                              throws BuildMacroException
Description copied from interface: IBuildMacroProvider
resolves all macros in the string to the makefile format. That is: 1. In case when a user has specified to resolve the environment build macros all macros get resolved in the string 2. In case when the a user has specified not to resolve the environment build macros all macros get resolved except the build environment macros (macros whose name conflicts with one of reserved macro names, or string-list macros always get resolved in the buildfile). Macro references that are kept unresolved are converted to the makefile format

Specified by:
resolveValueToMakefileFormat in interface IBuildMacroProvider
Parameters:
value - the value to be resolved
nonexistentMacrosValue - specifies the value that inexistent macro references will be expanded to. If null the BuildMacroException is thrown in case the string to be resolved references inexistent macros
listDelimiter - if not null, StringList macros are expanded as �< listDelimiter >< listDelimiter > ... � otherwise the BuildMacroException is thrown in case the string to be resolved references string-list macros
contextType - context from which the macro search should be started
contextData - context data
Throws:
BuildMacroException

resolveStringListValueToMakefileFormat

public java.lang.String[] resolveStringListValueToMakefileFormat(java.lang.String value,
                                                                 java.lang.String nonexistentMacrosValue,
                                                                 java.lang.String listDelimiter,
                                                                 int contextType,
                                                                 java.lang.Object contextData)
                                                          throws BuildMacroException
Description copied from interface: IBuildMacroProvider
if the string contains a value that can be treated as a StringList resolves it to arrays of strings otherwise throws the BuildMacroException exception each string of the returned array will contain all macro references resolved in case of a user has specified to resolve the build macros, and will contain the string with the environment macro references unresolved and converted to the buildfile format otherwise

Specified by:
resolveStringListValueToMakefileFormat in interface IBuildMacroProvider
Throws:
BuildMacroException
See Also:
isStringListValue

isStringListValue

public boolean isStringListValue(java.lang.String value,
                                 int contextType,
                                 java.lang.Object contextData)
                          throws BuildMacroException
Specified by:
isStringListValue in interface IBuildMacroProvider
Returns:
true if the specified expression can be treated as StringList 1. The string value is �${}�
Throws:
BuildMacroException

checkIntegrity

public void checkIntegrity(int contextType,
                           java.lang.Object contextData)
                    throws BuildMacroException
Description copied from interface: IBuildMacroProvider
checks the integrity of the Macros If there are inconsistencies, such as when a macro value refers to a nonexistent macro or when two macros refer to each other, this method will throw the BuildMacroException exception The BuildMacroException will contain the human-readable string describing the inconsistency and the array of the IBuildMacro interfaces that will represent the macros that caused the inconsistency. This information will be used in the UI to notify the user about the macro inconsistencies (see also the �User interface for viewing and editing Build Macros� section of this design)

Specified by:
checkIntegrity in interface IBuildMacroProvider
Throws:
BuildMacroException

getMacroSubstitutor

public org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor getMacroSubstitutor(IMacroContextInfo info,
                                                                                                  java.lang.String inexistentMacroValue,
                                                                                                  java.lang.String listDelimiter)

getBuildfileMacroSubstitutor

public org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor getBuildfileMacroSubstitutor(IMacroContextInfo info,
                                                                                            java.lang.String inexistentMacroValue,
                                                                                            java.lang.String listDelimiter)

areMacrosExpandedInBuildfile

public boolean areMacrosExpandedInBuildfile(IConfiguration cfg)
answers whether the environment macros are to be expanded in the buildfile

Parameters:
cfg -
Returns:

expandMacrosInBuildfile

public boolean expandMacrosInBuildfile(IConfiguration cfg,
                                       boolean expand)
sets whether the environment macros are to be expanded in the buildfile or not If a bulder does not support treating environment variables as its own ones this method has no effect Returns the result of this set operation. That is whether the environment macros are to be expanded in the buildfile

Parameters:
cfg -
expand -
Returns:

resolveStringListValues

public java.lang.String[] resolveStringListValues(java.lang.String[] value,
                                                  java.lang.String nonexistentMacrosValue,
                                                  java.lang.String listDelimiter,
                                                  int contextType,
                                                  java.lang.Object contextData)
                                           throws BuildMacroException
Description copied from interface: IBuildMacroProvider
resolves macros in the array of string-list values

Specified by:
resolveStringListValues in interface IBuildMacroProvider
Throws:
BuildMacroException
See Also:
isStringListValue

resolveStringListValuesToMakefileFormat

public java.lang.String[] resolveStringListValuesToMakefileFormat(java.lang.String[] value,
                                                                  java.lang.String nonexistentMacrosValue,
                                                                  java.lang.String listDelimiter,
                                                                  int contextType,
                                                                  java.lang.Object contextData)
                                                           throws BuildMacroException
Description copied from interface: IBuildMacroProvider
resolves macros in the array of string-list values macros are resolved to the makefile format

Specified by:
resolveStringListValuesToMakefileFormat in interface IBuildMacroProvider
Throws:
BuildMacroException
See Also:
isStringListValue

canKeepMacrosInBuildfile

public static boolean canKeepMacrosInBuildfile(IConfiguration cfg)
answers whether the builder used for the given configuration is capable of handling macros in the buildfile

Parameters:
cfg -
Returns:

canKeepMacrosInBuildfile

public static boolean canKeepMacrosInBuildfile(IBuilder builder)
answers whether the given builder is capable of handling macros in the buildfile

Parameters:
builder -
Returns:

createBuildfileMacroReference

public static java.lang.String createBuildfileMacroReference(java.lang.String name,
                                                             IBuilder builder)
creates a macro reference in the buildfile format for the given builder. If the builder can not treat macros, returns null

Parameters:
name -
builder -
Returns:
String

createBuildfileMacroReference

public static java.lang.String createBuildfileMacroReference(java.lang.String name,
                                                             IConfiguration cfg)
creates a macro reference in the buildfile format for the builder used for the given configuration. If the builder can not treat macros, returns null

Parameters:
name -
cfg -
Returns:
String

getReferencedExplitFileMacros

public static IBuildMacro[] getReferencedExplitFileMacros(ITool tool)
Returns the array of the explicit file macros, referenced in the tool's options (Explicit file macros are the file-specific macros, whose values are not provided by the tool-integrator. As a result these macros contain explicit values, but not the values specified in the format of the builder automatic variables and text functions)

Parameters:
tool -
Returns:

getReferencedExplitFileMacros

public static IBuildMacro[] getReferencedExplitFileMacros(java.lang.String expression,
                                                          int contextType,
                                                          java.lang.Object contextData)
Returns the array of the explicit file macros, referenced in the given string (Explicit file macros are the file-specific macros, whose values are not provided by the tool-integrator. As a result these macros contain explicit values, but not the values specified in the format of the builder automatic variables and text functions)

Parameters:
expression -
contextType -
contextData -
Returns: