Java Code Examples for com.strobel.assembler.metadata.TypeReference#getPackageName()

The following examples show how to use com.strobel.assembler.metadata.TypeReference#getPackageName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DecompilerLinkProvider.java    From Luyten with Apache License 2.0 6 votes vote down vote up
private TypeReference getMostOuterTypeRefBySlowLookuping(TypeReference typeRef) {
	String name = typeRef.getName();
	if (name == null)
		return typeRef;
	String packageName = typeRef.getPackageName();
	if (packageName == null)
		return typeRef;
	String[] nameParts = name.split("\\$");
	String newName = "";
	String sep = "";
	for (int i = 0; i < nameParts.length - 1; i++) {
		newName = newName + sep + nameParts[i];
		sep = "$";
		String newInternalName = packageName.replaceAll("\\.", "/") + "/" + newName;
		TypeReference newTypeRef = metadataSystem.lookupType(newInternalName);
		if (newTypeRef != null) {
			TypeDefinition newTypeDef = newTypeRef.resolve();
			if (newTypeDef != null) {
				return newTypeRef;
			}
		}
	}
	return typeRef;
}
 
Example 2
Source File: DecompilerLinkProvider.java    From Luyten with Apache License 2.0 5 votes vote down vote up
private String getPathAndTypeStr(TypeReference typeRef) {
	String name = typeRef.getName();
	String packageStr = typeRef.getPackageName();
	TypeReference mostOuterTypeRef = getMostOuterTypeRef(typeRef);
	String mostOuterTypeName = mostOuterTypeRef.getName();
	if (name != null && packageStr != null && mostOuterTypeName != null && name.trim().length() > 0
			&& mostOuterTypeName.trim().length() > 0) {
		String pathStr = packageStr.replaceAll("\\.", "/") + "/" + mostOuterTypeName;
		String typeStr = packageStr + "." + name.replace(".", "$");
		return pathStr + "|" + typeStr;
	}
	return null;
}