Class DataTypeMerger<T extends DataType>
- Type Parameters:
T- The specific type of datatype being merged.
- Direct Known Subclasses:
EnumMerger, StructureMerger, UnionMerger
The basic pattern is to create a merger with the two datatypes to be merged and then call
the merge() method to produce the new datatype that is the merger of the two original
datatypes. The new datatype will have the same name and category path of the first original
datatype.
Even if the merge is able to successfully complete and return a new datatype, the merge may
have associated warnings that can be retrieved by calling getWarnings(). The intent
is that the warning messages can be presented to the user before applying the new datatype.
Typically, after merging the two datatypes, the client will replace the first datatype with the merged datatype (it already has the same name and category). Then all uses of the second datatype will be replaced with updated first datatype.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanUpgrade(DataType from, DataType to) Checks if one datatype can can be upgraded to a another during a merge operation.protected abstract voiddoMerge()protected voidGenerates a DataTypeMergeException with the given error message.Returns any warnings that were generated by a call to the merge() method.booleanReturns true if there are any warnings.protected StringJoins two comment strings unless they are identical or one is null or blank.final Tmerge()Merge the two datatypes that this object was created with into a new datatype.protected voidprotected DataTypepickBestTypeForMerge(DataType type1, DataType type2) protected voidAdds a warning to the list of warnings.
-
Field Details
-
working
-
other
-
-
Constructor Details
-
DataTypeMerger
-
-
Method Details
-
merge
Merge the two datatypes that this object was created with into a new datatype.- Returns:
- the the new merged datatype.
- Throws:
DataTypeMergeException- thrown if the merge was unable to complete due to some conflict.
-
doMerge
- Throws:
DataTypeMergeException
-
getWarnings
-
hasWarnings
public boolean hasWarnings()Returns true if there are any warnings.- Returns:
- true if there are any warnings
-
warning
Adds a warning to the list of warnings.- Parameters:
message- the warning message to add
-
error
Generates a DataTypeMergeException with the given error message.- Parameters:
message- the error message- Throws:
DataTypeMergeException- with the given message
-
join
-
pickBestTypeForMerge
-
canUpgrade
Checks if one datatype can can be upgraded to a another during a merge operation. In this context, upgrade means that one datatype is often a stand-in for another because there wasn't initially enough information to get the correct type. For example, any undefined type of some size is a stand-in for any other datatype of that size, so undefined types can always be upgraded to another type of the same size. Another case is integer types are often mistaken for pointers, integer types can be upgraded to pointers.- Parameters:
from- the datatype to test if it can be updatedto- the dataType to that is the possible upgrade- Returns:
- true if typically the from dataType can be reasonably upgraded to the to datatype
-
mergeDescription
protected void mergeDescription()
-