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

Fix failed to find root path when workspace changes #1689

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

jdneo
Copy link
Contributor

@jdneo jdneo commented Mar 15, 2021

Fix a regression bug introduced in #1658

When debugging Java Language Server, and the workspace changed, a error message pops as below:

WeChat Screenshot_20210312163642

This is because some stale elements remains in the JDT workspace.

Signed-off-by: Sheng Chen [email protected]

@jdneo
Copy link
Contributor Author

jdneo commented Mar 15, 2021

test this please

@snjeza
Copy link
Contributor

snjeza commented Mar 15, 2021

Related issue - #1684

@jdneo
Copy link
Contributor Author

jdneo commented Mar 16, 2021

test this please

@@ -47,11 +47,12 @@ public void preferencesChange(Preferences oldPreferences, Preferences newPrefere

try {
IFolder workspaceLinkFolder = javaProject.getProject().getFolder(ProjectUtils.WORKSPACE_LINK);
if (!workspaceLinkFolder.exists()) {
IPath rootPath = ProjectUtils.findBelongedWorkspaceRoot(workspaceLinkFolder.getLocation());
Copy link
Contributor

Choose a reason for hiding this comment

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

if workspaceLinkFolder does not exist, what is returned by workspaceLinkFolder.getLocation()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends.

If it's the linked folder of an invisible project, it will return the linked folder path. If it's a visible project, it just appends _, for example: D:/Workspace/spring-petclinic/_

Why .exists() does not work is that, it just check if the handle of the resource exists, not check the real one. Below is part of the document copied from .exists():

IResource objects are lightweight handle objects used to access resources in the workspace. However, having a handle object does not necessarily mean the workspace really has such a resource.

@testforstephen testforstephen merged commit d72b545 into eclipse-jdtls:master Mar 16, 2021
@jdneo jdneo deleted the cs/rootPathChange branch March 16, 2021 04:48
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.

3 participants