Read boot properties metadata from project dependencies
This commit is contained in:
@@ -23,7 +23,6 @@ import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.lsp4e.server.StreamConnectionProvider;
|
||||
import org.eclipse.lsp4j.DidChangeConfigurationParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
@@ -32,7 +31,6 @@ import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.springsource.ide.eclipse.commons.livexp.core.ValueListener;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
|
||||
@@ -178,7 +178,7 @@ public class SimpleTextDocumentService implements TextDocumentService {
|
||||
if (url!=null) {
|
||||
String text = params.getTextDocument().getText();
|
||||
TrackedDocument td = createDocument(url, languageId, version, text).open();
|
||||
// Log.info("Opened "+td.getOpenCount()+" times: "+url);
|
||||
Log.info("Opened "+td.getOpenCount()+" times: "+url);
|
||||
TextDocument doc = td.getDocument();
|
||||
TextDocumentContentChangeEvent change = new TextDocumentContentChangeEvent() {
|
||||
@Override
|
||||
|
||||
@@ -20,11 +20,13 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jdt.core.IPackageFragmentRoot;
|
||||
import org.eclipse.jdt.core.JavaCore;
|
||||
import org.eclipse.jdt.internal.core.JavaProject;
|
||||
import org.springframework.tooling.jdt.ls.commons.Logger;
|
||||
import org.springframework.tooling.jdt.ls.commons.classpath.Classpath.CPE;
|
||||
@@ -96,20 +98,26 @@ public class ClasspathUtil {
|
||||
break;
|
||||
}
|
||||
case Classpath.ENTRY_KIND_SOURCE: {
|
||||
IPath sourcePath = entry.getPath();
|
||||
//log("source entry =" + sourcePath);
|
||||
IPath absoluteSourcePath = resolveWorkspacePath(sourcePath);
|
||||
//log("absoluteSourcePath =" + absoluteSourcePath);
|
||||
if (absoluteSourcePath!=null) {
|
||||
IPath of = entry.getOutputLocation();
|
||||
//log("outputFolder =" + of);
|
||||
IPath absoluteOutFolder;
|
||||
if (of!=null) {
|
||||
absoluteOutFolder = resolveWorkspacePath(of);
|
||||
} else {
|
||||
absoluteOutFolder = resolveWorkspacePath(javaProject.getOutputLocation());
|
||||
if (entry.getEntryKind()==IClasspathEntry.CPE_PROJECT) {
|
||||
IPath projectPath = entry.getPath();
|
||||
logger.log("project entry "+projectPath);
|
||||
resolveProjectOutputFolder(projectPath, cpEntries, logger);
|
||||
} else {
|
||||
IPath sourcePath = entry.getPath();
|
||||
//log("source entry =" + sourcePath);
|
||||
IPath absoluteSourcePath = resolveWorkspacePath(sourcePath);
|
||||
//log("absoluteSourcePath =" + absoluteSourcePath);
|
||||
if (absoluteSourcePath!=null) {
|
||||
IPath of = entry.getOutputLocation();
|
||||
//log("outputFolder =" + of);
|
||||
IPath absoluteOutFolder;
|
||||
if (of!=null) {
|
||||
absoluteOutFolder = resolveWorkspacePath(of);
|
||||
} else {
|
||||
absoluteOutFolder = resolveWorkspacePath(javaProject.getOutputLocation());
|
||||
}
|
||||
cpEntries.add(CPE.source(absoluteSourcePath.toFile(), absoluteOutFolder.toFile()));
|
||||
}
|
||||
cpEntries.add(CPE.source(absoluteSourcePath.toFile(), absoluteOutFolder.toFile()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -123,6 +131,24 @@ public class ClasspathUtil {
|
||||
return classpath;
|
||||
}
|
||||
|
||||
private static void resolveProjectOutputFolder(IPath projectPath, List<CPE> cpEntries, Logger logger) {
|
||||
try {
|
||||
if (projectPath.segmentCount()==1) {
|
||||
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectPath.segment(0));
|
||||
if (p.isAccessible()) {
|
||||
IJavaProject jp = JavaCore.create(p);
|
||||
IPath outputFolder = jp.getOutputLocation();
|
||||
if (outputFolder!=null) {
|
||||
outputFolder = resolveWorkspacePath(outputFolder);
|
||||
cpEntries.add(CPE.binary(outputFolder.toFile().getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static IPath resolveWorkspacePath(IPath path) {
|
||||
if (path.segmentCount()>0) {
|
||||
String projectName = path.segment(0);
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
package org.springframework.ide.vscode.boot.metadata;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@@ -11,19 +11,16 @@
|
||||
package org.springframework.ide.vscode.boot.metadata;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.ide.vscode.boot.metadata.util.Listener;
|
||||
import org.springframework.ide.vscode.boot.metadata.util.ListenerManager;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Support for Reconciling, Content Assist and Hover Text in spring properties
|
||||
|
||||
Reference in New Issue
Block a user