mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GT-3434 - Refactored Namespace.NAMESPACE_DELIMITER to be shorter;
deprecated the old name
This commit is contained in:
parent
7ad8505dcf
commit
d96ee82856
25 changed files with 58 additions and 45 deletions
|
@ -29,7 +29,7 @@ import ghidra.util.exception.*;
|
|||
* <a id="examples"></a>
|
||||
* Example string format:
|
||||
* <ul>
|
||||
* <li>global{@link Namespace#NAMESPACE_DELIMITER ::}child1{@link Namespace#NAMESPACE_DELIMITER ::}child2
|
||||
* <li>global{@link Namespace#DELIMITER ::}child1{@link Namespace#DELIMITER ::}child2
|
||||
* <li>child1
|
||||
* </ul>
|
||||
* <a id="assumptions"></a>
|
||||
|
@ -69,7 +69,7 @@ public class NamespaceUtils {
|
|||
String str = new String();
|
||||
while (namespace != null && !(namespace instanceof GlobalNamespace) &&
|
||||
!(namespace instanceof Library)) {
|
||||
str = namespace.getName() + Namespace.NAMESPACE_DELIMITER + str;
|
||||
str = namespace.getName() + Namespace.DELIMITER + str;
|
||||
namespace = namespace.getParentNamespace();
|
||||
}
|
||||
return str;
|
||||
|
@ -90,7 +90,7 @@ public class NamespaceUtils {
|
|||
str = getNamespacePathWithoutLibrary(namespace);
|
||||
}
|
||||
else if (namespace != null && !(namespace instanceof GlobalNamespace)) {
|
||||
str = namespace.getName(true) + Namespace.NAMESPACE_DELIMITER;
|
||||
str = namespace.getName(true) + Namespace.DELIMITER;
|
||||
}
|
||||
str += symbolName;
|
||||
return str;
|
||||
|
@ -107,7 +107,7 @@ public class NamespaceUtils {
|
|||
*/
|
||||
@Deprecated
|
||||
public static List<String> splitNamespacePath(String path) {
|
||||
return Arrays.asList(path.trim().split(Namespace.NAMESPACE_DELIMITER));
|
||||
return Arrays.asList(path.trim().split(Namespace.DELIMITER));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -172,7 +172,7 @@ public class SymbolPath implements Comparable<SymbolPath> {
|
|||
*/
|
||||
public String getPath() {
|
||||
if (parentPath != null) {
|
||||
return parentPath.getPath() + Namespace.NAMESPACE_DELIMITER + symbolName;
|
||||
return parentPath.getPath() + Namespace.DELIMITER + symbolName;
|
||||
}
|
||||
return symbolName;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SymbolPathParser {
|
|||
throw new IllegalArgumentException(
|
||||
"Symbol list must contain at least one symbol name!");
|
||||
}
|
||||
if (name.indexOf(Namespace.NAMESPACE_DELIMITER) == -1) {
|
||||
if (name.indexOf(Namespace.DELIMITER) == -1) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(name);
|
||||
return list;
|
||||
|
|
|
@ -383,7 +383,7 @@ public class DataTypeUtilities {
|
|||
public static DataType findNamespaceQualifiedDataType(DataTypeManager dataTypeManager,
|
||||
String dtNameWithNamespace, Class<? extends DataType> classConstraint) {
|
||||
|
||||
String[] splitName = dtNameWithNamespace.split(Namespace.NAMESPACE_DELIMITER);
|
||||
String[] splitName = dtNameWithNamespace.split(Namespace.DELIMITER);
|
||||
String dtName = splitName[splitName.length - 1];
|
||||
|
||||
return findDataType(dataTypeManager, dtName, classConstraint,
|
||||
|
|
|
@ -193,7 +193,7 @@ public class ExternalLocationDB implements ExternalLocation {
|
|||
if (label == null) {
|
||||
setName(getLibrary(), null, SourceType.DEFAULT);
|
||||
}
|
||||
else if (label.indexOf(Namespace.NAMESPACE_DELIMITER) < 0) {
|
||||
else if (label.indexOf(Namespace.DELIMITER) < 0) {
|
||||
// if label does not include namespace keep current namespace
|
||||
setName(symbol.getParentNamespace(), label, source);
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public abstract class SymbolDB extends DatabaseObject implements Symbol {
|
|||
Namespace ns = getParentNamespace();
|
||||
if (!(ns instanceof GlobalNamespace)) {
|
||||
String nsPath = ns.getName(true);
|
||||
symName = nsPath + Namespace.NAMESPACE_DELIMITER + symName;
|
||||
symName = nsPath + Namespace.DELIMITER + symName;
|
||||
}
|
||||
}
|
||||
return symName;
|
||||
|
|
|
@ -193,7 +193,7 @@ public class PointerDataType extends BuiltIn implements Pointer {
|
|||
|
||||
String symName = symbol.getName();
|
||||
symName = SymbolUtilities.getCleanSymbolName(symName, ref.getToAddress());
|
||||
symName = symName.replace(Namespace.NAMESPACE_DELIMITER, "_");
|
||||
symName = symName.replace(Namespace.DELIMITER, "_");
|
||||
return POINTER_LABEL_PREFIX + "_" + symName;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,39 +21,51 @@ import ghidra.util.exception.DuplicateNameException;
|
|||
import ghidra.util.exception.InvalidInputException;
|
||||
|
||||
/**
|
||||
* The Namespace interface.
|
||||
* The Namespace interface
|
||||
*/
|
||||
|
||||
public interface Namespace {
|
||||
static final long GLOBAL_NAMESPACE_ID = 0;
|
||||
/**
|
||||
* The delimiter that is used to separate namespace nodes in a namespace
|
||||
* string. For example, "Global::child1::symbolName"
|
||||
*/
|
||||
public static final String DELIMITER = "::";
|
||||
|
||||
/**
|
||||
* Replaced by {@link #DELIMITER}
|
||||
* @deprecated use {@link #DELIMITER}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String NAMESPACE_DELIMITER = "::";
|
||||
|
||||
/**
|
||||
* Get the symbol for this namespace; Note: The global namespace will return null
|
||||
* @return the symbol for this namespace; Note: The global namespace will return null
|
||||
*/
|
||||
public Symbol getSymbol();
|
||||
|
||||
/**
|
||||
* Returns true if this namespace is external (i.e., associated with a Library)
|
||||
* @return true if this namespace is external (i.e., associated with a Library)
|
||||
*/
|
||||
public boolean isExternal();
|
||||
|
||||
/**
|
||||
* Get the name of the symbol for this scope.
|
||||
* Get the name of the symbol for this scope
|
||||
* @return the name of the symbol for this scope
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name.
|
||||
* Returns the fully qualified name
|
||||
* @param includeNamespacePath true to include the namespace in the returned name
|
||||
* @return the fully qualified name
|
||||
*/
|
||||
public String getName(boolean includeNamespacePath);
|
||||
|
||||
/**
|
||||
* Return the namespace id;
|
||||
* Return the namespace id
|
||||
* @return the namespace id
|
||||
*/
|
||||
public long getID();
|
||||
|
||||
|
@ -66,6 +78,7 @@ public interface Namespace {
|
|||
/**
|
||||
* Get the address set for this namespace. Note: The body of a namespace (currently
|
||||
* only used by the function namespace) is restricted it Integer.MAX_VALUE.
|
||||
* @return the address set for this namespace
|
||||
*/
|
||||
public AddressSetView getBody();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue