#12182 Code cleanup

上级 57cca7d7
...@@ -30,10 +30,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils; ...@@ -30,10 +30,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.impl.struct.AbstractObjectReference; import org.jkiss.dbeaver.model.impl.struct.AbstractObjectReference;
import org.jkiss.dbeaver.model.impl.struct.RelationalObjectType; import org.jkiss.dbeaver.model.impl.struct.RelationalObjectType;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject; import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.model.struct.DBSObjectReference;
import org.jkiss.dbeaver.model.struct.DBSObjectType;
import org.jkiss.dbeaver.model.struct.DBSStructureAssistant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -129,7 +126,7 @@ public class SQLServerStructureAssistant implements DBSStructureAssistant<SQLSer ...@@ -129,7 +126,7 @@ public class SQLServerStructureAssistant implements DBSStructureAssistant<SQLSer
try (JDBCSession session = executionContext.openSession(monitor, DBCExecutionPurpose.META, "Find objects by name")) { try (JDBCSession session = executionContext.openSession(monitor, DBCExecutionPurpose.META, "Find objects by name")) {
List<DBSObjectReference> objects = new ArrayList<>(); List<DBSObjectReference> objects = new ArrayList<>();
if (params.getName().startsWith("#")) { if (params.getMask().startsWith("%#") || params.getMask().startsWith("#")) {
// Search temp tables // Search temp tables
searchTempTables(session, params, objects); searchTempTables(session, params, objects);
} else { } else {
......
...@@ -89,9 +89,8 @@ public class SQLSearchUtils ...@@ -89,9 +89,8 @@ public class SQLSearchUtils
if (structureAssistant != null) { if (structureAssistant != null) {
String objectNameMask = nameList.get(0); String objectNameMask = nameList.get(0);
DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams( DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams(
structureAssistant.getAutoCompleteObjectTypes(), structureAssistant.getAutoCompleteObjectTypes(),
identifierDetector.removeQuotes(objectNameMask), identifierDetector.removeQuotes(objectNameMask)
identifierDetector.removeQuotes(objectNameMask)
); );
params.setParentObject(sc); params.setParentObject(sc);
params.setCaseSensitive(identifierDetector.isQuoted(objectNameMask)); params.setCaseSensitive(identifierDetector.isQuoted(objectNameMask));
......
...@@ -743,9 +743,8 @@ public class SQLCompletionAnalyzer implements DBRRunnableParametrized<DBRProgres ...@@ -743,9 +743,8 @@ public class SQLCompletionAnalyzer implements DBRRunnableParametrized<DBRProgres
DBSStructureAssistant structureAssistant = DBUtils.getAdapter(DBSStructureAssistant.class, sc); DBSStructureAssistant structureAssistant = DBUtils.getAdapter(DBSStructureAssistant.class, sc);
if (structureAssistant != null) { if (structureAssistant != null) {
DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams( DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams(
structureAssistant.getAutoCompleteObjectTypes(), structureAssistant.getAutoCompleteObjectTypes(),
request.getWordDetector().removeQuotes(token), request.getWordDetector().removeQuotes(token)
request.getWordDetector().removeQuotes(token)
); );
params.setCaseSensitive(request.getWordDetector().isQuoted(token)); params.setCaseSensitive(request.getWordDetector().isQuoted(token));
params.setMaxResults(2); params.setMaxResults(2);
...@@ -1110,9 +1109,8 @@ public class SQLCompletionAnalyzer implements DBRRunnableParametrized<DBRProgres ...@@ -1110,9 +1109,8 @@ public class SQLCompletionAnalyzer implements DBRRunnableParametrized<DBRProgres
@NotNull Map<String, Object> params) throws DBException @NotNull Map<String, Object> params) throws DBException
{ {
DBSStructureAssistant.ObjectsSearchParams assistantParams = new DBSStructureAssistant.ObjectsSearchParams( DBSStructureAssistant.ObjectsSearchParams assistantParams = new DBSStructureAssistant.ObjectsSearchParams(
objectTypes == null ? assistant.getAutoCompleteObjectTypes() : objectTypes, objectTypes == null ? assistant.getAutoCompleteObjectTypes() : objectTypes,
objectName, makeObjectNameMask(objectName, rootSC)
makeObjectNameMask(objectName, rootSC)
); );
assistantParams.setParentObject(rootSC); assistantParams.setParentObject(rootSC);
assistantParams.setCaseSensitive(request.getWordDetector().isQuoted(objectName)); assistantParams.setCaseSensitive(request.getWordDetector().isQuoted(objectName));
......
...@@ -57,7 +57,6 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> { ...@@ -57,7 +57,6 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> {
* <li>{@code parentObject}: parent (schema or catalog)</li> * <li>{@code parentObject}: parent (schema or catalog)</li>
* <li>{@code objectTypes}: type of objects to search</li> * <li>{@code objectTypes}: type of objects to search</li>
* <li>{@code mask}: name mask</li> * <li>{@code mask}: name mask</li>
* <li>{@code mask}: original name</li>
* <li>{@code caseSensitive}: case sensitive search (ignored by some implementations)</li> * <li>{@code caseSensitive}: case sensitive search (ignored by some implementations)</li>
* <li>{@code globalSearch}: search in all available schemas/catalogs. If {@code false} then search with respect of active schema/catalog</li> * <li>{@code globalSearch}: search in all available schemas/catalogs. If {@code false} then search with respect of active schema/catalog</li>
* <li>{@code maxResults}: maximum number of results</li> * <li>{@code maxResults}: maximum number of results</li>
...@@ -66,9 +65,11 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> { ...@@ -66,9 +65,11 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> {
* </ul> * </ul>
*/ */
class ObjectsSearchParams { class ObjectsSearchParams {
@NotNull
private final DBSObjectType[] objectTypes; private final DBSObjectType[] objectTypes;
private String name; @NotNull
private String mask; private String mask;
@Nullable
private DBSObject parentObject; private DBSObject parentObject;
private int maxResults = Integer.MAX_VALUE; private int maxResults = Integer.MAX_VALUE;
private boolean caseSensitive; private boolean caseSensitive;
...@@ -76,9 +77,8 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> { ...@@ -76,9 +77,8 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> {
private boolean searchInDefinitions; private boolean searchInDefinitions;
private boolean globalSearch; private boolean globalSearch;
public ObjectsSearchParams(@NotNull DBSObjectType[] objectTypes, @NotNull String name, @NotNull String mask) { public ObjectsSearchParams(@NotNull DBSObjectType[] objectTypes, @NotNull String mask) {
this.objectTypes = objectTypes; this.objectTypes = objectTypes;
this.name = name;
this.mask = mask; this.mask = mask;
} }
...@@ -105,15 +105,6 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> { ...@@ -105,15 +105,6 @@ public interface DBSStructureAssistant<CONTEXT extends DBCExecutionContext> {
this.mask = mask; this.mask = mask;
} }
@NotNull
public String getName() {
return name;
}
public void setName(@NotNull String name) {
this.name = name;
}
public boolean isCaseSensitive() { public boolean isCaseSensitive() {
return caseSensitive; return caseSensitive;
} }
......
...@@ -301,9 +301,8 @@ public class SQLContextInformer ...@@ -301,9 +301,8 @@ public class SQLContextInformer
DBCExecutionContext executionContext = editor.getExecutionContext(); DBCExecutionContext executionContext = editor.getExecutionContext();
if (executionContext != null) { if (executionContext != null) {
DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams( DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams(
structureAssistant.getAutoCompleteObjectTypes(), structureAssistant.getAutoCompleteObjectTypes(),
containerNames[0], containerNames[0]
containerNames[0]
); );
params.setGlobalSearch(true); params.setGlobalSearch(true);
params.setMaxResults(1); params.setMaxResults(1);
...@@ -360,7 +359,7 @@ public class SQLContextInformer ...@@ -360,7 +359,7 @@ public class SQLContextInformer
DBSObjectType[] objectTypes = structureAssistant.getHyperlinkObjectTypes(); DBSObjectType[] objectTypes = structureAssistant.getHyperlinkObjectTypes();
DBCExecutionContext executionContext = editor.getExecutionContext(); DBCExecutionContext executionContext = editor.getExecutionContext();
if (executionContext != null) { if (executionContext != null) {
DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams(objectTypes, objectName, objectName); DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams(objectTypes, objectName);
params.setParentObject(container); params.setParentObject(container);
params.setCaseSensitive(caseSensitive); params.setCaseSensitive(caseSensitive);
params.setMaxResults(10); params.setMaxResults(10);
......
...@@ -368,9 +368,8 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog { ...@@ -368,9 +368,8 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
public void run(DBRProgressMonitor param) throws InvocationTargetException, InterruptedException { public void run(DBRProgressMonitor param) throws InvocationTargetException, InterruptedException {
try { try {
DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams( DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams(
typesToSearch.toArray(new DBSObjectType[0]), typesToSearch.toArray(new DBSObjectType[0]),
nameMask, nameMask
nameMask
); );
params.setParentObject(container); params.setParentObject(container);
params.setGlobalSearch(true); params.setGlobalSearch(true);
......
...@@ -444,9 +444,8 @@ public class SearchMetadataPage extends AbstractSearchPage { ...@@ -444,9 +444,8 @@ public class SearchMetadataPage extends AbstractSearchPage {
} }
DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams( DBSStructureAssistant.ObjectsSearchParams params = new DBSStructureAssistant.ObjectsSearchParams(
objectTypes.toArray(new DBSObjectType[0]), objectTypes.toArray(new DBSObjectType[0]),
nameMask, objectNameMask
objectNameMask
); );
params.setParentObject(parentObject); params.setParentObject(parentObject);
params.setCaseSensitive(caseSensitive); params.setCaseSensitive(caseSensitive);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册