-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically detect jars in lib/ folder
... in the root directory of standalone files / invisible projects - a file watcher on lib/** is added for invisible projects - source for foo.jar is automatically detected if there's a foo-sources.jar in the lib/ folder - multiple file events are handled so that classpath modifications are minimized Signed-off-by: Fred Bricon <fbricon@gmail.com>
- Loading branch information
Showing
16 changed files
with
763 additions
and
65 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
28 changes: 28 additions & 0 deletions
28
...jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/DefaultProjectBuildSupport.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,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 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 v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.managers; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
|
||
public class DefaultProjectBuildSupport extends EclipseBuildSupport implements IBuildSupport { | ||
|
||
private ProjectsManager projectManager; | ||
|
||
public DefaultProjectBuildSupport(ProjectsManager projectManager) { | ||
this.projectManager = projectManager; | ||
} | ||
|
||
@Override | ||
public boolean applies(IProject project) { | ||
return projectManager.getDefaultProject().equals(project); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...clipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/EclipseBuildSupport.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,52 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 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 v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.managers; | ||
|
||
import java.util.Set; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.runtime.IPath; | ||
|
||
import com.google.common.collect.Sets; | ||
|
||
public class EclipseBuildSupport implements IBuildSupport { | ||
|
||
private Set<String> files = Sets.newHashSet(".classpath", ".project", ".factorypath"); | ||
private Set<String> folders = Sets.newHashSet(".settings"); | ||
|
||
@Override | ||
public boolean applies(IProject project) { | ||
return true; //all projects are Eclipse projects | ||
} | ||
|
||
@Override | ||
public boolean isBuildFile(IResource resource) { | ||
if (resource == null || resource.getProject() == null) { | ||
return false; | ||
} | ||
IProject project = resource.getProject(); | ||
for (String file : files) { | ||
if (resource.equals(project.getFolder(file))) { | ||
return true; | ||
} | ||
} | ||
IPath path = resource.getFullPath(); | ||
for (String folder : folders) { | ||
IPath folderPath = project.getFolder(folder).getFullPath(); | ||
if (folderPath.isPrefixOf(path)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
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
62 changes: 62 additions & 0 deletions
62
...t.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/InvisibleProjectBuildSupport.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,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 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 v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.managers; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.jdt.core.JavaCore; | ||
import org.eclipse.jdt.ls.core.internal.ProjectUtils; | ||
import org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.CHANGE_TYPE; | ||
|
||
/** | ||
* @author Fred Bricon | ||
* | ||
*/ | ||
public class InvisibleProjectBuildSupport extends EclipseBuildSupport implements IBuildSupport { | ||
|
||
static final String LIB_FOLDER = "lib"; | ||
|
||
private UpdateClasspathJob updateClasspathJob; | ||
|
||
public InvisibleProjectBuildSupport() { | ||
this(UpdateClasspathJob.getInstance()); | ||
} | ||
|
||
public InvisibleProjectBuildSupport(UpdateClasspathJob updateClasspathJob) { | ||
this.updateClasspathJob = updateClasspathJob; | ||
} | ||
|
||
@Override | ||
public boolean applies(IProject project) { | ||
return project != null && project.isAccessible() && !ProjectUtils.isVisibleProject(project); | ||
} | ||
|
||
@Override | ||
public boolean fileChanged(IResource resource, CHANGE_TYPE changeType, IProgressMonitor monitor) throws CoreException { | ||
if (resource == null || !applies(resource.getProject())) { | ||
return false; | ||
} | ||
refresh(resource, changeType, monitor); | ||
IProject invisibleProject = resource.getProject(); | ||
IPath realFolderPath = invisibleProject.getFolder(ProjectUtils.WORKSPACE_LINK).getLocation(); | ||
if (realFolderPath != null) { | ||
IPath libFolderPath = realFolderPath.append(LIB_FOLDER); | ||
if (libFolderPath.isPrefixOf(resource.getLocation())) { | ||
updateClasspathJob.updateClasspath(JavaCore.create(invisibleProject), libFolderPath); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
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
Oops, something went wrong.