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

Cannot import maven project from workspace #2999

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

snjeza
Copy link
Contributor

@snjeza snjeza commented Dec 12, 2023

@rgrunber rgrunber added this to the End December 2023 milestone Dec 12, 2023
@snjeza snjeza changed the title [performance] Cannot import maven project from workspace [WIP] [performance] Cannot import maven project from workspace Dec 12, 2023
@snjeza snjeza force-pushed the issue-2972 branch 2 times, most recently from 0d82fcd to 978b93e Compare December 13, 2023 16:06
@snjeza snjeza changed the title [WIP] [performance] Cannot import maven project from workspace [performance] Cannot import maven project from workspace Dec 13, 2023
@rgrunber rgrunber changed the title [performance] Cannot import maven project from workspace Cannot import maven project from workspace Dec 20, 2023
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

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

Seems to fix the issue for me. Just a few small things to fix.

Is it the case that JDTLS filesystem does not currently exclude any resources when performing operations ?

}

private void configureResourceFilters() {
IEclipsePreferences eclipsePreferences = InstanceScope.INSTANCE.getNode(JAVA_LS_PLUGIN_ID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just something to be aware of :
Although I'd have preferred making jdt.ls.filesystem directly depend on jdt.ls.core I'll allow this copying because in the long term , we have #2658, so we should avoid any link between this bundle and jdt.ls.core).

@snjeza
Copy link
Contributor Author

snjeza commented Dec 28, 2023

Is it the case that JDTLS filesystem does not currently exclude any resources when performing operations ?

Yes, it is.
This operation is slow -getProjectNameIfLocationIsProjectRoot

@snjeza
Copy link
Contributor Author

snjeza commented Dec 28, 2023

@rgrunber I have updated the PR.

@rgrunber
Copy link
Contributor

rgrunber commented Dec 29, 2023

Is it the case that JDTLS filesystem does not currently exclude any resources when performing operations ?

Yes, it is. This operation is slow -getProjectNameIfLocationIsProjectRoot

I completely agree. All those node_modules/** files are definitely the issue.
Screenshot from 2023-12-28 15-45-19

My question was more about why we need to manually exclude files (based on filters) when we configure filters at initialization. I would have hoped the filesystem API would do it for us.

project.createFilter(JDTLS_FILTER_TYPE, new FileInfoMatcherDescription(CORE_RESOURCES_MATCHER_ID, resourceFilter), IResource.BACKGROUND_REFRESH, monitor);
. We configure filters at initialization for all projects (except default).

The javadoc says :

Adds a new filter to this container. Filters restrict the set of files and directories
in the underlying file system that will be included as members of this container.

I haven't looked too deeply, so maybe the API doesn't work that way. Update: Maybe the resource model is independent of the filesystem model and manual filtering is the right approach.

@snjeza
Copy link
Contributor Author

snjeza commented Dec 29, 2023

I haven't looked too deeply, so maybe the API doesn't work that way.

The issue happens only when we import a project into a new workspace. In this case, getProjectNameIfLocationIsProjectRoot is called before we configure the project (and its filters)

@rgrunber
Copy link
Contributor

You're right 😐

projectsManager.initializeProjects(roots, subMonitor);
projectsManager.configureFilters(monitor);
. I guess it would get complicated to set the project filters in each kind of project importer :\

@snjeza
Copy link
Contributor Author

snjeza commented Dec 29, 2023

I guess it would get complicated to set the project filters in each kind of project importer :\

The project filters already work that way

Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

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

Overall looks good. I would just rename the commit message to make it clear we're basically re-implementing resource filtering in the filesystem implementation beause resource filtering isn't yet in place. Something like

JDT LS Filesystem should respect resource filtering

- Resource model filtering is set up after projects are imported, but
  some import operations (eg. Maven projects) could benefit from this

Once done, feel free to merge.

import java.util.Objects;
import java.util.regex.Pattern;

import org.eclipse.core.runtime.preferences.IEclipsePreferences;
Copy link
Contributor

Choose a reason for hiding this comment

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

You have some unused imports here. IEclipsePreferences and InstanceScope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


protected void setResourcePatterns() {
resourcePatterns = new ArrayList<>();
for (String element: resourceFilters.split("::")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you leave a space between element and :

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 124 to 125
for (String segment: path.segments()) {
for (Pattern pattern: JDTLSFilesystemActivator.getResourcePatterns()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Space between the element and the :.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

- Resource model filtering is set up after projects are imported, but
  some import operations (eg. Maven projects) could benefit from this
@snjeza
Copy link
Contributor Author

snjeza commented Jan 1, 2024

Overall looks good. I would just rename the commit message to make it clear we're basically re-implementing resource filtering in the filesystem implementation beause resource filtering isn't yet in place. Something like

Fixed

@snjeza snjeza merged commit b652bd2 into eclipse-jdtls:master Jan 2, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot import maven project from workspace
2 participants