Project build data via classpath listener from JDT

This commit is contained in:
aboyko
2022-11-15 18:52:32 -05:00
parent 6bcaef95eb
commit ed4eef0e0a
24 changed files with 242 additions and 101 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pivotal, Inc.
* Copyright (c) 2019, 2022 Pivotal, Inc.
* 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
@@ -19,12 +19,14 @@ public abstract class AbstractJavaProject implements IJavaProject, Disposable {
private final IClasspath classpath;
private final URI uri;
private final IProjectBuild projectBuild;
private ClasspathIndex index;
public AbstractJavaProject(URI uri, IClasspath classpath) {
public AbstractJavaProject(URI uri, IClasspath classpath, IProjectBuild projectBuild) {
this.uri = uri;
this.classpath = classpath;
this.projectBuild = projectBuild;
}
@Override
public IClasspath getClasspath() {
@@ -67,5 +69,10 @@ public abstract class AbstractJavaProject implements IJavaProject, Disposable {
public String toString() {
return "JavaProject("+uri+")";
}
@Override
public IProjectBuild getProjectBuild() {
return projectBuild;
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2019 Pivotal, Inc.
* Copyright (c) 2017, 2022 Pivotal, Inc.
* 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
@@ -17,6 +17,7 @@ public interface IJavaProject {
final static String PROJECT_CACHE_FOLDER = ".sts4-cache";
IClasspath getClasspath();
IProjectBuild getProjectBuild();
ClasspathIndex getIndex();
URI getLocationUri();
boolean exists();

View File

@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2022 VMware, Inc.
* 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
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.java;
import java.net.URI;
public interface IProjectBuild {
String getType();
URI getBuildFile();
static IProjectBuild create(String type, URI buildFile) {
return new IProjectBuild() {
@Override
public String getType() {
return type;
}
@Override
public URI getBuildFile() {
return buildFile;
}
};
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2019 Pivotal, Inc.
* Copyright (c) 2018, 2022 Pivotal, Inc.
* 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
@@ -23,8 +23,8 @@ public class JavaProject extends AbstractJavaProject {
private final FileObserver fileObserver;
private final JavadocProviderFactory javadocProviderFactory;
public JavaProject(FileObserver fileObserver, URI uri, IClasspath classpath, JavadocService javadocService) {
super(uri, classpath);
public JavaProject(FileObserver fileObserver, URI uri, IClasspath classpath, JavadocService javadocService, IProjectBuild projectBuild) {
super(uri, classpath, projectBuild);
this.fileObserver = fileObserver;
this.javadocProviderFactory = (classpathResource) -> {
CPE cpe = IClasspathUtil.findEntryForBinaryRoot(classpath, classpathResource);

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pivotal, Inc.
* Copyright (c) 2019, 2022 Pivotal, Inc.
* 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
@@ -21,8 +21,8 @@ public class JdtLsJavaProject extends AbstractJavaProject {
final private STS4LanguageClient client;
final private ProjectObserver projectObserver;
public JdtLsJavaProject(STS4LanguageClient client, URI uri, IClasspath classpath, ProjectObserver projectObserver) {
super(uri, classpath);
public JdtLsJavaProject(STS4LanguageClient client, URI uri, IClasspath classpath, ProjectObserver projectObserver, IProjectBuild projectBuild) {
super(uri, classpath, projectBuild);
this.client = client;
this.projectObserver = projectObserver;
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 Pivotal, Inc.
* Copyright (c) 2017, 2022 Pivotal, Inc.
* 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
@@ -29,8 +29,8 @@ public class LegacyJavaProject extends JavaProject {
final protected Path projectDataCache;
public LegacyJavaProject(FileObserver fileObserver, URI loactionUri, Path projectDataCache, IClasspath classpath, JavadocService javadocService) {
super(fileObserver, loactionUri, classpath, javadocService);
public LegacyJavaProject(FileObserver fileObserver, URI loactionUri, Path projectDataCache, IClasspath classpath, JavadocService javadocService, IProjectBuild projectBuild) {
super(fileObserver, loactionUri, classpath, javadocService, projectBuild);
this.projectDataCache = projectDataCache;
}