GP-5694 - Data Types - Updated the DataTypeQueryService to add more

useful method
This commit is contained in:
dragonmacher 2025-05-17 11:06:31 -04:00
parent d0c327973c
commit 6396a1a1e0
15 changed files with 251 additions and 66 deletions

View file

@ -25,6 +25,8 @@ import java.util.regex.Pattern;
import javax.help.UnsupportedOperationException;
import org.apache.commons.lang3.StringUtils;
import db.*;
import db.util.ErrorHandler;
import generic.jar.ResourceFile;
@ -2098,32 +2100,37 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
@Override
public void findDataTypes(String name, List<DataType> list) {
if (name == null || name.length() == 0) {
if (StringUtils.isBlank(name)) {
return;
}
if (name.equals(DataType.DEFAULT.getName())) {
list.add(DataType.DEFAULT);
return;
}
// ignore .conflict in both name and result matches
lock.acquire();
try {
buildSortedDataTypeList();
// Use exemplar datatype in root category without .conflict to position at start
// of possible matches
name = DataTypeUtilities.getNameWithoutConflict(name);
String baseName = DataTypeUtilities.getNameWithoutConflict(name);
DataType compareDataType =
new TypedefDataType(CategoryPath.ROOT, name, DataType.DEFAULT, this);
new TypedefDataType(CategoryPath.ROOT, baseName, DataType.DEFAULT, this);
int index = Collections.binarySearch(sortedDataTypes, compareDataType, nameComparator);
if (index < 0) {
// this allows us to find foo.conflict types
index = -index - 1;
}
// add all matches to list
while (index < sortedDataTypes.size()) {
DataType dt = sortedDataTypes.get(index);
if (!name.equals(DataTypeUtilities.getNameWithoutConflict(dt, false))) {
break;
String baseDtName = DataTypeUtilities.getNameWithoutConflict(dt, false);
if (!baseName.equals(baseDtName)) {
break; // not foo or foo.conflict
}
list.add(dt);
++index;
}
@ -2143,9 +2150,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
list.add(DataType.DEFAULT);
return;
}
if (monitor == null) {
monitor = TaskMonitor.DUMMY;
}
monitor = TaskMonitor.dummyIfNull(monitor);
Pattern regexp = UserSearchUtils.createSearchPattern(name, caseSensitive);
lock.acquire();
try {

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -698,7 +698,7 @@ public class DataTypeUtilities {
* @param dtName datatype name
* @param classConstraint type of datatype by its interface class (e.g., {@link Structure}).
* @param parentNamespacePreferred if true matching on parent namespace is
* enabled and preferred over match on actual namespace. This is relavent for
* enabled and preferred over match on actual namespace. This is relevant for
* class structure searching.
* @return preferred datatype match if found
*/

View file

@ -169,11 +169,10 @@ public interface DataTypeManager {
public Iterator<FunctionDefinition> getAllFunctionDefinitions();
/**
* Begin searching at the root category for all data types with the
* given name. Places all the data types in this data type manager
* with the given name into the list. Presence of {@code .conflict}
* extension will be ignored for both specified name and returned
* results.
* Begin searching at the root category for all data types with the given name. Places all the
* data types in this data type manager with the given name into the list. The presence of
* {@code .conflict} extension will be ignored and thus included in the results.
*
* @param name name of the data type (wildcards are not supported and will be treated
* as explicit search characters)
* @param list list that will be populated with matching DataType objects
@ -181,9 +180,13 @@ public interface DataTypeManager {
public void findDataTypes(String name, List<DataType> list);
/**
* Begin searching at the root category for all data types with names
* that match the given name that may contain wildcards using familiar globbing
* characters '*' and '?'.
* Begin searching at the root category for all data types with names that match the given name
* that may contain wildcards using familiar globbing characters '*' and '?'.
* <p>
* Unlike {@link #findDataTypes(String, List)}, data types with a {@code .conflict} extension
* will not be included in the results of this method unless they explicitly match the provided
* name.
*
* @param name name to match; may contain wildcards
* @param list list that will be populated with matching DataType objects
* @param caseSensitive true if the match is case sensitive
@ -421,7 +424,7 @@ public interface DataTypeManager {
* transaction is ended.
* <P>
* NOTE: Use of rollback ({@code commit=false} should be avoided unless absolutely
* neccessary since it will incur overhead to revert changes and may rollback multiple
* necessary since it will incur overhead to revert changes and may rollback multiple
* concurrent transactions if they exist.
* <P>
* NOTE: If this manager is part of a larger {@link DomainObject} its transactions may become
@ -630,7 +633,7 @@ public interface DataTypeManager {
public SourceArchive getLocalSourceArchive();
/**
* Change the given data type and its dependencies so thier source archive is set to
* Change the given data type and its dependencies so their source archive is set to
* given archive. Only those data types not already associated with a source archive
* will be changed.
*