Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbeaver/pro#2795 Editors for objects under a path with special symbols don't get restored #29993

Merged
merged 20 commits into from May 13, 2024

Conversation

serjiokov
Copy link
Contributor

The node path with spec symbol converted for comparison.

don't get restored

Fix path of restored node
Comment on lines 369 to 371
if (expectedNodePathName.contains(DBNModel.SLASH_ESCAPE_TOKEN)) {
expectedNodePathName = expectedNodePathName.replace(DBNModel.SLASH_ESCAPE_TOKEN, "/");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move outside the loop

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I believe this should be done somewhere else. Please take a look at where the path gets deserialized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @alexander-skoblikov has concerns about this change as well

Copy link
Contributor Author

@serjiokov serjiokov May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, the editor "expectedName" has a node path like %2F...%2F In other places node path convertation from %2F to / leads to a wrong segment identification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods normalize/denormalize were extracted to Utils.

Copy link
Member

@ShadelessFox ShadelessFox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normailizeNodePath -> escapeNodeId
deNormalizeNodePath -> unescapeNodeId
What do you think?

* @return - node path object
*/
public static NodePath decodeNodePath(@NotNull NodePath nodePath) {
if (!nodePath.toString().contains(DBNModel.PATTERN_ESCAPE_TOKEN)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodePath.toString() is also expensive.

Do not check NodePAth, check path String variable.

@Matvey16
Copy link
Member

We have another error if schema name contains %
Maybe it can be fixed in this PR too?

@@ -57,7 +57,7 @@
* (e.g. TreeViewer sometimes update only first TreeItem corresponding to model certain model object).
*/
public class DBNModel implements IResourceChangeListener {
public static final String SLASH_ESCAPE_TOKEN = "%2F";
public static final String PATTERN_ESCAPE_TOKEN = "%"; //$NON-NLS-1$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove it.

@@ -271,6 +271,9 @@ private static NodePath getNodePath(@NotNull String path) {
break;
}
}
if (path.contains(DBNModel.PATTERN_ESCAPE_TOKEN)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used here and assumes something about how paths are escaped. Check this within the decodeNodePath method and don't introduce new constants - it introduces unnecessary noise.

Comment on lines 43 to 45
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant imports

@@ -29,6 +29,7 @@
import org.jkiss.dbeaver.model.app.DBPProject;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults;
import org.jkiss.dbeaver.model.navigator.DBNModel.NodePath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant import

Comment on lines +331 to +332
NodePath nodePath = getNodePath(path);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant change

@@ -139,7 +139,8 @@ private static DBNNode legacyFindNodeByPath(

final List<String> pathItems = nodePath.pathItems;
for (int i = firstItem, itemsSize = pathItems.size(); i < itemsSize; i++) {
String item = pathItems.get(i).replace(DBNModel.SLASH_ESCAPE_TOKEN, "/");
//String item = pathItems.get(i).replace(DBNModel.SLASH_ESCAPE_TOKEN, "/");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code

@Matvey16
Copy link
Member

Verified

@serge-rider serge-rider merged commit 1457abe into devel May 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants