-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use linked resource instead of filesystem
For all metadata files, except the .project (which may be harder to move), use linked resources instead of filesystem hack which can return invalid locations through standard API. This copies some logic from the org.eclipse.jdt.ls.filesystem to ProjectsManager, because we cannot have the filesystem bundle requiring and referencing the main jdt.ls bundle as this would cause bundle/class cycle and loading error. This also remove the InvisibleProjectMetadataTest.testMetadataFileLocation() test because creating a new project in Eclipse workspace now enforces creation of a .settings/org.eclipse.core.resources.prefs file. Where the metadata for the invisible project is stored doesn't matter as it is internal anyway. Also removes some usage of gson types which can cause conflicts when multiple versions are loaded.
- Loading branch information
1 parent
810f806
commit 0dd82bd
Showing
14 changed files
with
324 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...dt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/WorkspaceOperationsWithLink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.managers; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.buildship.core.internal.workspace.DefaultWorkspaceOperations; | ||
import org.eclipse.buildship.core.internal.workspace.WorkspaceOperations; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IProjectDescription; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin; | ||
|
||
import com.google.common.base.Optional; | ||
import com.google.common.collect.ImmutableList; | ||
|
||
public class WorkspaceOperationsWithLink implements WorkspaceOperations { | ||
|
||
private final WorkspaceOperations delegate = new DefaultWorkspaceOperations(); | ||
|
||
@Override | ||
public ImmutableList<IProject> getAllProjects() { | ||
return delegate.getAllProjects(); | ||
} | ||
|
||
@Override | ||
public Optional<IProject> findProjectByName(String name) { | ||
return delegate.findProjectByName(name); | ||
} | ||
|
||
@Override | ||
public Optional<IProject> findProjectByLocation(File location) { | ||
return delegate.findProjectByLocation(location); | ||
} | ||
|
||
@Override | ||
public Optional<IProjectDescription> findProjectDescriptor(File location, IProgressMonitor monitor) { | ||
return delegate.findProjectDescriptor(location, monitor); | ||
} | ||
|
||
@Override | ||
public IProject createProject(String name, File location, List<String> natureIds, IProgressMonitor monitor) { | ||
IProject res = delegate.createProject(name, location, natureIds, monitor); | ||
if (!ProjectsManager.generatesMetadataFilesAtProjectRoot()) { | ||
try { | ||
ProjectsManager.linkResources(res); | ||
} catch (CoreException ex) { | ||
JavaLanguageServerPlugin.logException(ex); | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
@Override | ||
public IProject includeProject(IProjectDescription projectDescription, List<String> extraNatureIds, IProgressMonitor monitor) { | ||
return delegate.includeProject(projectDescription, extraNatureIds, monitor); | ||
} | ||
|
||
@Override | ||
public void refreshProject(IProject project, IProgressMonitor monitor) { | ||
delegate.refreshProject(project, monitor); | ||
} | ||
|
||
@Override | ||
public void addNature(IProject project, String natureId, IProgressMonitor monitor) { | ||
delegate.addNature(project, natureId, monitor); | ||
} | ||
|
||
@Override | ||
public void removeNature(IProject project, String natureId, IProgressMonitor monitor) { | ||
delegate.removeNature(project, natureId, monitor); | ||
} | ||
|
||
@Override | ||
public void addBuildCommand(IProject project, String name, Map<String, String> arguments, IProgressMonitor monitor) { | ||
delegate.addBuildCommand(project, name, arguments, monitor); | ||
} | ||
|
||
@Override | ||
public void removeBuildCommand(IProject project, String name, IProgressMonitor monitor) { | ||
delegate.removeBuildCommand(project, name, monitor); | ||
} | ||
|
||
@Override | ||
public void validateProjectName(String name, File location) { | ||
delegate.validateProjectName(name, location); | ||
} | ||
|
||
@Override | ||
public IProject renameProject(IProject project, String newName, IProgressMonitor monitor) { | ||
return delegate.renameProject(project, newName, monitor); | ||
} | ||
|
||
@Override | ||
public boolean isNatureRecognizedByEclipse(String natureId) { | ||
return delegate.isNatureRecognizedByEclipse(natureId); | ||
} | ||
|
||
@Override | ||
public boolean isWtpInstalled() { | ||
return delegate.isWtpInstalled(); | ||
} | ||
} |
Oops, something went wrong.