reorganize names and package locations around symbol and index caches

This commit is contained in:
Martin Lippert
2023-07-11 12:27:53 +02:00
parent 9bf67c9f4e
commit 7dfbad709f
28 changed files with 245 additions and 235 deletions

View File

@@ -41,6 +41,9 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
import org.springframework.ide.vscode.boot.common.RelaxedNameConfig;
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheOnDisc;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.JavaDefinitionHandler;
import org.springframework.ide.vscode.boot.java.handlers.BootJavaCodeActionProvider;
import org.springframework.ide.vscode.boot.java.handlers.BootJavaProjectReconcilerScheduler;
@@ -62,9 +65,6 @@ import org.springframework.ide.vscode.boot.java.reconcilers.JavaReconciler;
import org.springframework.ide.vscode.boot.java.reconcilers.JdtReconciler;
import org.springframework.ide.vscode.boot.java.rewrite.RewriteRecipeRepository;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheOnDisc;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.java.value.PropertyValueAnnotationDefProvider;
import org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsService;
import org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache;
@@ -138,11 +138,11 @@ public class BootLanguageServerBootApp {
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
@Bean
SymbolCache symbolCache(BootLsConfigProperties props) {
IndexCache symbolCache(BootLsConfigProperties props) {
if (props.isSymbolCacheEnabled()) {
return new SymbolCacheOnDisc(new File(props.getSymbolCacheDir()));
return new IndexCacheOnDisc(new File(props.getSymbolCacheDir()));
} else {
return new SymbolCacheVoid();
return new IndexCacheVoid();
}
}

View File

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.ide.vscode.boot.factories.SpringFactoriesLanguageServerComponents;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
@@ -30,7 +31,6 @@ import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDa
import org.springframework.ide.vscode.boot.java.rewrite.RewriteRecipeRepository;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.ServerUtils;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider;
import org.springframework.ide.vscode.boot.properties.BootPropertiesLanguageServerComponents;
import org.springframework.ide.vscode.boot.xml.SpringXMLLanguageServerComponents;
@@ -66,7 +66,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
@Autowired YamlASTProvider parser;
@Autowired YamlStructureProvider yamlStructureProvider;
@Autowired YamlAssistContextProvider yamlAssistContextProvider;
@Autowired SymbolCache symbolCache;
@Autowired IndexCache symbolCache;
@Autowired SpringProcessLiveDataProvider liveDataProvider;
@Autowired ApplicationContext appContext;
@Autowired BootJavaConfig config;

View File

@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup;
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
@@ -56,7 +57,6 @@ import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava;
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerXML;
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerXMLNamespaceHandler;
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerXMLNamespaceHandlerBeans;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolHandler;
import org.springframework.ide.vscode.boot.java.utils.SymbolIndexConfig;
import org.springframework.ide.vscode.commons.java.IJavaProject;
@@ -91,7 +91,7 @@ public class SpringSymbolIndex implements InitializingBean, SpringIndex {
@Autowired BootJavaConfig config;
@Autowired BootLanguageServerParams params;
@Autowired AnnotationHierarchyAwareLookup<SymbolProvider> specificProviders;
@Autowired SymbolCache cache;
@Autowired IndexCache cache;
@Autowired FutureProjectFinder futureProjectFinder;
@Autowired SpringMetamodelIndex springIndex;

View File

@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.boot.app;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.java.Annotations;
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup;
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolProvider;
@@ -22,13 +23,12 @@ import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
import org.springframework.ide.vscode.boot.java.requestmapping.RequestMappingSymbolProvider;
import org.springframework.ide.vscode.boot.java.requestmapping.WebfluxRouterSymbolProvider;
import org.springframework.ide.vscode.boot.java.utils.RestrictedDefaultSymbolProvider;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
@Configuration(proxyBeanMethods = false)
public class SpringSymbolIndexerConfig {
@Bean
AnnotationHierarchyAwareLookup<SymbolProvider> symbolProviders(SymbolCache cache) {
AnnotationHierarchyAwareLookup<SymbolProvider> symbolProviders(IndexCache cache) {
AnnotationHierarchyAwareLookup<SymbolProvider> providers = new AnnotationHierarchyAwareLookup<>();
RequestMappingSymbolProvider requestMappingSymbolProvider = new RequestMappingSymbolProvider();

View File

@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 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
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.index.cache;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
import com.google.common.collect.Multimap;
/**
* @author Martin Lippert
*/
public interface IndexCache {
void store(IndexCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies);
Pair<CachedSymbol[], Multimap<String, String>> retrieve(IndexCacheKey cacheKey, String[] files);
void update(IndexCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies);
void update(IndexCacheKey cacheKey, String[] files, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies);
void remove(IndexCacheKey cacheKey);
void removeFile(IndexCacheKey symbolCacheKey, String file);
default CachedSymbol[] retrieveSymbols(IndexCacheKey cacheKey, String[] files) {
Pair<CachedSymbol[], Multimap<String, String>> r = retrieve(cacheKey, files);
return r!=null ? r.getLeft() : null;
}
long getModificationTimestamp(IndexCacheKey cacheKey, String docURI);
}

View File

@@ -8,19 +8,19 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils;
package org.springframework.ide.vscode.boot.index.cache;
/**
* @author Martin Lippert
*/
public class SymbolCacheKey {
public class IndexCacheKey {
private static final String SEPARATOR = "-";
private final String primaryIdentifier;
private final String version;
public SymbolCacheKey(String primaryIdentifier, String version) {
public IndexCacheKey(String primaryIdentifier, String version) {
this.primaryIdentifier = primaryIdentifier;
this.version = version;
}
@@ -56,11 +56,11 @@ public class SymbolCacheKey {
if (getClass() != obj.getClass())
return false;
SymbolCacheKey other = (SymbolCacheKey) obj;
IndexCacheKey other = (IndexCacheKey) obj;
return this.toString().equals(other.toString());
}
public static SymbolCacheKey parse(String fileName) {
public static IndexCacheKey parse(String fileName) {
if (fileName != null && fileName.length() > 0) {
int separatorIndex = fileName.lastIndexOf(SEPARATOR);
if (separatorIndex > 0) {
@@ -72,7 +72,7 @@ public class SymbolCacheKey {
version = version.substring(0, fileextensionIndex);
}
return new SymbolCacheKey(primary, version);
return new IndexCacheKey(primary, version);
}
}
return null;

View File

@@ -8,7 +8,7 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils;
package org.springframework.ide.vscode.boot.index.cache;
import java.io.File;
import java.io.FileReader;
@@ -34,6 +34,7 @@ import org.eclipse.lsp4j.Location;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
import org.springframework.ide.vscode.commons.util.UriUtil;
@@ -57,14 +58,14 @@ import com.google.gson.stream.JsonReader;
/**
* @author Martin Lippert
*/
public class SymbolCacheOnDisc implements SymbolCache {
public class IndexCacheOnDisc implements IndexCache {
private final File cacheDirectory;
private final Map<SymbolCacheKey, CacheStore> stores;
private final Map<IndexCacheKey, CacheStore> stores;
private static final Logger log = LoggerFactory.getLogger(SymbolCacheOnDisc.class);
private static final Logger log = LoggerFactory.getLogger(IndexCacheOnDisc.class);
public SymbolCacheOnDisc(File cacheDirectory) {
public IndexCacheOnDisc(File cacheDirectory) {
this.cacheDirectory = cacheDirectory;
this.stores = new ConcurrentHashMap<>();
@@ -78,7 +79,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
}
@Override
public void store(SymbolCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
public void store(IndexCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
if (dependencies==null) {
dependencies = ImmutableMultimap.of();
}
@@ -98,7 +99,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
}
@Override
public Pair<CachedSymbol[], Multimap<String, String>> retrieve(SymbolCacheKey cacheKey, String[] files) {
public Pair<CachedSymbol[], Multimap<String, String>> retrieve(IndexCacheKey cacheKey, String[] files) {
File cacheStore = new File(cacheDirectory, cacheKey.toString() + ".json");
if (cacheStore.exists()) {
@@ -142,7 +143,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
}
@Override
public void removeFile(SymbolCacheKey cacheKey, String file) {
public void removeFile(IndexCacheKey cacheKey, String file) {
CacheStore cacheStore = this.stores.get(cacheKey);
if (cacheStore != null) {
String docURI = UriUtil.toUri(new File(file)).toASCIIString();
@@ -160,7 +161,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
}
@Override
public void remove(SymbolCacheKey cacheKey) {
public void remove(IndexCacheKey cacheKey) {
File cacheStore = new File(cacheDirectory, cacheKey.toString() + ".json");
if (cacheStore.exists()) {
cacheStore.delete();
@@ -169,7 +170,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
}
@Override
public void update(SymbolCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies) {
public void update(IndexCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies) {
if (dependencies == null) {
dependencies = ImmutableSet.of();
}
@@ -199,7 +200,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
}
@Override
public void update(SymbolCacheKey cacheKey, String[] files, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
public void update(IndexCacheKey cacheKey, String[] files, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
if (dependencies == null) {
dependencies = ImmutableMultimap.of();
}
@@ -241,7 +242,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
}
@Override
public long getModificationTimestamp(SymbolCacheKey cacheKey, String file) {
public long getModificationTimestamp(IndexCacheKey cacheKey, String file) {
CacheStore cacheStore = this.stores.get(cacheKey);
if (cacheStore != null) {
@@ -254,7 +255,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
return 0;
}
private void save(SymbolCacheKey cacheKey, List<CachedSymbol> generatedSymbols,
private void save(IndexCacheKey cacheKey, List<CachedSymbol> generatedSymbols,
SortedMap<String, Long> timestampedFiles, Map<String, Collection<String>> dependencies) {
CacheStore store = new CacheStore(timestampedFiles, generatedSymbols, dependencies);
this.stores.put(cacheKey, store);
@@ -282,12 +283,12 @@ public class SymbolCacheOnDisc implements SymbolCache {
return true;
}
private void cleanupCacheFiles(SymbolCacheKey cacheKey) {
private void cleanupCacheFiles(IndexCacheKey cacheKey) {
File[] cacheFiles = this.cacheDirectory.listFiles();
for (int i = 0; i < cacheFiles.length; i++) {
String fileName = cacheFiles[i].getName();
SymbolCacheKey key = SymbolCacheKey.parse(fileName);
IndexCacheKey key = IndexCacheKey.parse(fileName);
if (key != null && !key.equals(cacheKey)
&& key.getPrimaryIdentifier().equals(cacheKey.getPrimaryIdentifier())) {

View File

@@ -8,47 +8,48 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils;
package org.springframework.ide.vscode.boot.index.cache;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
import com.google.common.collect.Multimap;
/**
* @author Martin Lippert
*/
public class SymbolCacheVoid implements SymbolCache {
public class IndexCacheVoid implements IndexCache {
@Override
public void store(SymbolCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String,String> dependencies) {
public void store(IndexCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String,String> dependencies) {
}
@Override
public Pair<CachedSymbol[], Multimap<String, String>> retrieve(SymbolCacheKey cacheKey, String[] files) {
public Pair<CachedSymbol[], Multimap<String, String>> retrieve(IndexCacheKey cacheKey, String[] files) {
return null;
}
@Override
public void update(SymbolCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies) {
public void update(IndexCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies) {
}
@Override
public void update(SymbolCacheKey cacheKey, String[] file, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
public void update(IndexCacheKey cacheKey, String[] file, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
}
@Override
public void remove(SymbolCacheKey cacheKey) {
public void remove(IndexCacheKey cacheKey) {
}
@Override
public void removeFile(SymbolCacheKey symbolCacheKey, String file) {
public void removeFile(IndexCacheKey symbolCacheKey, String file) {
}
@Override
public long getModificationTimestamp(SymbolCacheKey cacheKey, String docURI) {
public long getModificationTimestamp(IndexCacheKey cacheKey, String docURI) {
return 0;
}

View File

@@ -34,6 +34,8 @@ import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheKey;
import org.springframework.ide.vscode.boot.java.beans.BeanUtils;
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolProvider;
@@ -69,9 +71,9 @@ public class SpringFactoriesIndexer implements SpringIndexer {
);
private final SymbolHandler symbolHandler;
private final SymbolCache cache;
private final IndexCache cache;
public SpringFactoriesIndexer(SymbolHandler symbolHandler, SymbolCache cache) {
public SpringFactoriesIndexer(SymbolHandler symbolHandler, IndexCache cache) {
super();
this.symbolHandler = symbolHandler;
this.cache = cache;
@@ -142,7 +144,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
return fqName;
}
private SymbolCacheKey getCacheKey(IJavaProject project) {
private IndexCacheKey getCacheKey(IJavaProject project) {
String filesIndentifier = getFiles(project).stream()
.filter(f -> Files.isRegularFile(f))
.map(f -> {
@@ -154,7 +156,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
}
})
.collect(Collectors.joining(","));
return new SymbolCacheKey(project.getElementName() + "-factories-", DigestUtils.md5Hex(filesIndentifier).toUpperCase());
return new IndexCacheKey(project.getElementName() + "-factories-", DigestUtils.md5Hex(filesIndentifier).toUpperCase());
}
@@ -166,7 +168,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
log.info("scan factories files for symbols for project: " + project.getElementName() + " - no. of files: " + files.size());
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
CachedSymbol[] symbols = this.cache.retrieveSymbols(cacheKey, filesStr);
if (symbols == null) {
@@ -238,7 +240,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
@Override
public void removeProject(IJavaProject project) throws Exception {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
this.cache.remove(cacheKey);
}
@@ -252,7 +254,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
if (!outputFolders.stream().anyMatch(out -> path.startsWith(out))) {
List<CachedSymbol> generatedSymbols = scanFile(path);
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
String file = new File(new URI(docURI)).getAbsolutePath();
this.cache.update(cacheKey, file, updatedDoc.getLastModified(), generatedSymbols, null);
@@ -264,7 +266,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
@Override
public void updateFiles(IJavaProject project, DocumentDescriptor[] updatedDocs) throws Exception {
SymbolCacheKey key = getCacheKey(project);
IndexCacheKey key = getCacheKey(project);
List<Path> outputFolders = IClasspathUtil.getOutputFolders(project.getClasspath()).map(f -> f.toPath()).collect(Collectors.toList());
for (DocumentDescriptor d : updatedDocs) {
Path path = Paths.get(URI.create(d.getDocURI()));
@@ -281,7 +283,7 @@ public class SpringFactoriesIndexer implements SpringIndexer {
@Override
public void removeFiles(IJavaProject project, String[] docURIs) throws Exception {
SymbolCacheKey key = getCacheKey(project);
IndexCacheKey key = getCacheKey(project);
for (String docUri : docURIs) {
String file = new File(new URI(docUri)).getAbsolutePath();
cache.removeFile(key, file);

View File

@@ -48,6 +48,8 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheKey;
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies;
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup;
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
@@ -80,14 +82,14 @@ public class SpringIndexerJava implements SpringIndexer {
private final SymbolHandler symbolHandler;
private final AnnotationHierarchyAwareLookup<SymbolProvider> symbolProviders;
private final SymbolCache cache;
private final IndexCache cache;
private final JavaProjectFinder projectFinder;
private boolean scanTestJavaSources = false;
private FileScanListener fileScanListener = null; //used by test code only
private final SpringIndexerJavaDependencyTracker dependencyTracker = new SpringIndexerJavaDependencyTracker();
public SpringIndexerJava(SymbolHandler symbolHandler, AnnotationHierarchyAwareLookup<SymbolProvider> symbolProviders, SymbolCache cache,
public SpringIndexerJava(SymbolHandler symbolHandler, AnnotationHierarchyAwareLookup<SymbolProvider> symbolProviders, IndexCache cache,
JavaProjectFinder projectFimder) {
this.symbolHandler = symbolHandler;
this.symbolProviders = symbolProviders;
@@ -124,13 +126,13 @@ public class SpringIndexerJava implements SpringIndexer {
@Override
public void removeProject(IJavaProject project) throws Exception {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
this.cache.remove(cacheKey);
}
@Override
public void updateFile(IJavaProject project, DocumentDescriptor updatedDoc, String content) throws Exception {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
if (updatedDoc != null && shouldProcessDocument(project, updatedDoc.getDocURI())
&& isCacheOutdated(cacheKey, updatedDoc.getDocURI(), updatedDoc.getLastModified())) {
this.symbolHandler.removeSymbols(project, updatedDoc.getDocURI());
@@ -153,7 +155,7 @@ public class SpringIndexerJava implements SpringIndexer {
@Override
public void removeFiles(IJavaProject project, String[] docURIs) throws Exception {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
for (String docURI : docURIs) {
String file = new File(new URI(docURI)).getAbsolutePath();
@@ -162,7 +164,7 @@ public class SpringIndexerJava implements SpringIndexer {
}
private DocumentDescriptor[] filterDocuments(IJavaProject project, DocumentDescriptor[] updatedDocs) {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
return Arrays.stream(updatedDocs).filter(doc -> shouldProcessDocument(project, doc.getDocURI()))
.filter(doc -> isCacheOutdated(cacheKey, doc.getDocURI(), doc.getLastModified())).toArray(DocumentDescriptor[]::new);
}
@@ -180,7 +182,7 @@ public class SpringIndexerJava implements SpringIndexer {
}
}
private boolean isCacheOutdated(SymbolCacheKey cacheKey, String docURI, long modifiedTimestamp) {
private boolean isCacheOutdated(IndexCacheKey cacheKey, String docURI, long modifiedTimestamp) {
long cachedModificationTImestamp = this.cache.getModificationTimestamp(cacheKey, UriUtil.toFileString(docURI));
return modifiedTimestamp > cachedModificationTImestamp;
}
@@ -223,7 +225,7 @@ public class SpringIndexerJava implements SpringIndexer {
scanAST(context);
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
this.cache.update(cacheKey, file, lastModified, generatedSymbols, context.getDependencies());
// dependencyTracker.dump();
@@ -318,7 +320,7 @@ public class SpringIndexerJava implements SpringIndexer {
Bean[] beans = generatedSymbols.stream().filter(cachedSymbol -> cachedSymbol.getBean() != null).map(cachedSymbol -> cachedSymbol.getBean()).toArray(Bean[]::new);
symbolHandler.addSymbols(project, symbols, beans);
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
this.cache.update(cacheKey, javaFiles, lastModified, generatedSymbols, dependencies);
return scannedTypes;
@@ -356,7 +358,7 @@ public class SpringIndexerJava implements SpringIndexer {
}
private void scanFiles(IJavaProject project, String[] javaFiles) throws Exception {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
Pair<CachedSymbol[], Multimap<String, String>> cached = this.cache.retrieve(cacheKey, javaFiles);
CachedSymbol[] symbols;
@@ -606,7 +608,7 @@ public class SpringIndexerJava implements SpringIndexer {
.toArray(String[]::new);
}
private SymbolCacheKey getCacheKey(IJavaProject project) {
private IndexCacheKey getCacheKey(IJavaProject project) {
IClasspath classpath = project.getClasspath();
Stream<File> classpathEntries = IClasspathUtil.getAllBinaryRoots(classpath).stream();
@@ -615,7 +617,7 @@ public class SpringIndexerJava implements SpringIndexer {
.map(file -> file.getAbsolutePath() + "#" + file.lastModified())
.collect(Collectors.joining(","));
return new SymbolCacheKey(project.getElementName() + "-java-", DigestUtils.md5Hex(GENERATION + "-" + classpathIdentifier).toUpperCase());
return new IndexCacheKey(project.getElementName() + "-java-", DigestUtils.md5Hex(GENERATION + "-" + classpathIdentifier).toUpperCase());
}
public void setScanTestJavaSources(boolean scanTestJavaSources) {

View File

@@ -31,6 +31,8 @@ import org.eclipse.lemminx.dom.DOMNode;
import org.eclipse.lemminx.dom.DOMParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheKey;
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
import org.springframework.ide.vscode.commons.java.IClasspath;
import org.springframework.ide.vscode.commons.java.IClasspathUtil;
@@ -49,13 +51,13 @@ public class SpringIndexerXML implements SpringIndexer {
private final SymbolHandler symbolHandler;
private final Map<String, SpringIndexerXMLNamespaceHandler> namespaceHandler;
private final SymbolCache cache;
private final IndexCache cache;
private final JavaProjectFinder projectFinder;
private String[] scanFolders = new String[0];
public SpringIndexerXML(SymbolHandler handler, Map<String, SpringIndexerXMLNamespaceHandler> namespaceHandler,
SymbolCache cache, JavaProjectFinder projectFinder) {
IndexCache cache, JavaProjectFinder projectFinder) {
this.symbolHandler = handler;
this.namespaceHandler = namespaceHandler;
this.cache = cache;
@@ -104,7 +106,7 @@ public class SpringIndexerXML implements SpringIndexer {
log.info("scan xml files for symbols for project: " + project.getElementName() + " - no. of files: " + files.length);
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
CachedSymbol[] symbols = this.cache.retrieveSymbols(cacheKey, files);
if (symbols == null) {
@@ -135,7 +137,7 @@ public class SpringIndexerXML implements SpringIndexer {
@Override
public void removeProject(IJavaProject project) throws Exception {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
this.cache.remove(cacheKey);
}
@@ -149,7 +151,7 @@ public class SpringIndexerXML implements SpringIndexer {
scanFile(project, content, docURI, updatedDoc.getLastModified(), generatedSymbols);
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
String file = new File(new URI(docURI)).getAbsolutePath();
this.cache.update(cacheKey, file, updatedDoc.getLastModified(), generatedSymbols, null);
@@ -172,7 +174,7 @@ public class SpringIndexerXML implements SpringIndexer {
List<CachedSymbol> generatedSymbols = new ArrayList<CachedSymbol>();
scanFile(project, content, docURI, updatedDoc.getLastModified(), generatedSymbols);
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
String file = new File(new URI(docURI)).getAbsolutePath();
this.cache.update(cacheKey, file, updatedDoc.getLastModified(), generatedSymbols, null);
@@ -184,7 +186,7 @@ public class SpringIndexerXML implements SpringIndexer {
@Override
public void removeFiles(IJavaProject project, String[] docURIs) throws Exception {
SymbolCacheKey cacheKey = getCacheKey(project);
IndexCacheKey cacheKey = getCacheKey(project);
for (String docURI : docURIs) {
String file = new File(new URI(docURI)).getAbsolutePath();
@@ -267,7 +269,7 @@ public class SpringIndexerXML implements SpringIndexer {
return xmlFiles;
}
private SymbolCacheKey getCacheKey(IJavaProject project) {
private IndexCacheKey getCacheKey(IJavaProject project) {
IClasspath classpath = project.getClasspath();
Stream<File> classpathEntries = IClasspathUtil.getAllBinaryRoots(classpath).stream();
@@ -276,7 +278,7 @@ public class SpringIndexerXML implements SpringIndexer {
.map(file -> file.getAbsolutePath() + "#" + file.lastModified())
.collect(Collectors.joining(","));
return new SymbolCacheKey(project.getElementName() + "-xml-", DigestUtils.md5Hex(classpathIdentifier).toUpperCase());
return new IndexCacheKey(project.getElementName() + "-xml-", DigestUtils.md5Hex(classpathIdentifier).toUpperCase());
}
private void clearIndex() {

View File

@@ -1,41 +0,0 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 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
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.collect.Multimap;
/**
* @author Martin Lippert
*/
public interface SymbolCache {
void store(SymbolCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies);
Pair<CachedSymbol[], Multimap<String, String>> retrieve(SymbolCacheKey cacheKey, String[] files);
void update(SymbolCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies);
void update(SymbolCacheKey cacheKey, String[] files, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies);
void remove(SymbolCacheKey cacheKey);
void removeFile(SymbolCacheKey symbolCacheKey, String file);
default CachedSymbol[] retrieveSymbols(SymbolCacheKey cacheKey, String[] files) {
Pair<CachedSymbol[], Multimap<String, String>> r = retrieve(cacheKey, files);
return r!=null ? r.getLeft() : null;
}
long getModificationTimestamp(SymbolCacheKey cacheKey, String docURI);
}

View File

@@ -15,10 +15,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
@@ -29,8 +29,8 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
@Import(AdHocPropertyHarnessTestConf.class)
public class HoverTestConf {
@Bean SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {

View File

@@ -17,12 +17,12 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
@@ -38,8 +38,8 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
@Import(AdHocPropertyHarnessTestConf.class)
public class PropertyEditorTestConf {
@Bean SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {

View File

@@ -15,11 +15,11 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.java.utils.test.MockProjectObserver;
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
@@ -35,8 +35,8 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
@Import(AdHocPropertyHarnessTestConf.class)
public class SourceLinksTestConf {
@Bean public SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean public IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {

View File

@@ -15,10 +15,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
@@ -30,8 +30,8 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
@Import(AdHocPropertyHarnessTestConf.class)
public class SymbolProviderTestConf {
@Bean public SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean public IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {

View File

@@ -15,12 +15,12 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.java.utils.test.MockProjectObserver;
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
@@ -34,8 +34,8 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
@Import(AdHocPropertyHarnessTestConf.class)
public class XmlBeansTestConf {
@Bean public SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean public IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pivotal, Inc.
* Copyright (c) 2019, 2023 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
@@ -8,22 +8,22 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils.test;
package org.springframework.ide.vscode.boot.index.cache.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import org.junit.jupiter.api.Test;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheKey;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheKey;
/**
* @author Martin Lippert
*/
public class SymbolCacheKeyTest {
public class IndexCacheKeyTest {
@Test
void testCacheKey() {
SymbolCacheKey key = new SymbolCacheKey("primary", "version");
IndexCacheKey key = new IndexCacheKey("primary", "version");
assertEquals("primary", key.getPrimaryIdentifier());
assertEquals("version", key.getVersion());
@@ -32,33 +32,33 @@ public class SymbolCacheKeyTest {
@Test
void testCacheKeyParsingFromFileName() {
SymbolCacheKey key = SymbolCacheKey.parse("primary-version.json");
IndexCacheKey key = IndexCacheKey.parse("primary-version.json");
assertEquals("primary", key.getPrimaryIdentifier());
assertEquals("version", key.getVersion());
key = SymbolCacheKey.parse("primary-name-with-separator-123ABC.json");
key = IndexCacheKey.parse("primary-name-with-separator-123ABC.json");
assertEquals("primary-name-with-separator", key.getPrimaryIdentifier());
assertEquals("123ABC", key.getVersion());
}
@Test
void testCacheKeyParsingWithoutFileExtension() {
SymbolCacheKey key = SymbolCacheKey.parse("primary-version");
IndexCacheKey key = IndexCacheKey.parse("primary-version");
assertEquals("primary", key.getPrimaryIdentifier());
assertEquals("version", key.getVersion());
key = SymbolCacheKey.parse("primary-name-with-separator-123ABC");
key = IndexCacheKey.parse("primary-name-with-separator-123ABC");
assertEquals("primary-name-with-separator", key.getPrimaryIdentifier());
assertEquals("123ABC", key.getVersion());
}
@Test
void testCacheKeyEquals() {
SymbolCacheKey key1 = new SymbolCacheKey("primary", "1");
SymbolCacheKey key2 = new SymbolCacheKey("primary", "1");
IndexCacheKey key1 = new IndexCacheKey("primary", "1");
IndexCacheKey key2 = new IndexCacheKey("primary", "1");
SymbolCacheKey key3 = new SymbolCacheKey("primary", "2");
SymbolCacheKey key4 = new SymbolCacheKey("secondary", "1");
IndexCacheKey key3 = new IndexCacheKey("primary", "2");
IndexCacheKey key4 = new IndexCacheKey("secondary", "1");
assertEquals(key1, key1);
assertEquals(key2, key2);

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 Pivotal, Inc.
* Copyright (c) 2019, 2023 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
@@ -8,7 +8,7 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils.test;
package org.springframework.ide.vscode.boot.index.cache.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -36,12 +36,12 @@ import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheKey;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheOnDisc;
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.requestmapping.WebfluxElementsInformation;
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheKey;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheOnDisc;
import org.springframework.ide.vscode.commons.util.UriUtil;
import com.google.common.collect.ImmutableList;
@@ -49,15 +49,15 @@ import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
public class SymbolCacheOnDiscTest {
public class IndexCacheOnDiscTest {
private Path tempDir;
private SymbolCacheOnDisc cache;
private IndexCacheOnDisc cache;
@BeforeEach
public void setup() throws Exception {
tempDir = Files.createTempDirectory("cachetest");
cache = new SymbolCacheOnDisc(tempDir.toFile());
cache = new IndexCacheOnDisc(tempDir.toFile());
}
@AfterEach
@@ -67,7 +67,7 @@ public class SymbolCacheOnDiscTest {
@Test
void testEmptyCache() throws Exception {
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("something", "0"), new String[0]);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("something", "0"), new String[0]);
assertNull(result);
}
@@ -89,13 +89,13 @@ public class SymbolCacheOnDiscTest {
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol, null));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols, ImmutableMultimap.of(
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols, ImmutableMultimap.of(
file1.toString(), "file1dep1",
file2.toString(), "file2dep1",
file2.toString(), "file2dep2"
));
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("somekey", "1"), files);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("somekey", "1"), files);
CachedSymbol[] cachedSymbols = result.getLeft();
assertNotNull(cachedSymbols);
@@ -111,8 +111,8 @@ public class SymbolCacheOnDiscTest {
assertEquals(dependencies.get(file1.toString()), ImmutableSet.of("file1dep1"));
assertEquals(dependencies.get(file2.toString()), ImmutableSet.of("file2dep1", "file2dep2"));
assertEquals(timeFile1.toMillis(), cache.getModificationTimestamp(new SymbolCacheKey("somekey", "1"), file1.toString()));
assertEquals(0, cache.getModificationTimestamp(new SymbolCacheKey("somekey", "1"), "random-non-existing-file"));
assertEquals(timeFile1.toMillis(), cache.getModificationTimestamp(new IndexCacheKey("somekey", "1"), file1.toString()));
assertEquals(0, cache.getModificationTimestamp(new IndexCacheKey("somekey", "1"), "random-non-existing-file"));
assertNull(cachedSymbols[0].getBean());
}
@@ -135,9 +135,9 @@ public class SymbolCacheOnDiscTest {
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol, null));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols, null);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols, null);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("otherkey", "1"), files);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("otherkey", "1"), files);
assertNull(result);
}
@@ -159,14 +159,14 @@ public class SymbolCacheOnDiscTest {
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol, null));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols, ImmutableMultimap.of(
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols, ImmutableMultimap.of(
file1.toString(), "file1dep",
file2.toString(), "file2dep"
));
assertTrue(file1.toFile().setLastModified(timeFile1.toMillis() + 1000));
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("somekey", "1"), files);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("somekey", "1"), files);
assertNull(result);
}
@@ -181,10 +181,10 @@ public class SymbolCacheOnDiscTest {
Files.createFile(file3);
String[] files = {file1.toString(), file2.toString()};
cache.store(new SymbolCacheKey("somekey", "1"), files, new ArrayList<>(), null);
cache.store(new IndexCacheKey("somekey", "1"), files, new ArrayList<>(), null);
String[] moreFiles = {file1.toString(), file2.toString(), file3.toString()};
assertNull(cache.retrieve(new SymbolCacheKey("somekey", "1"), moreFiles));
assertNull(cache.retrieve(new IndexCacheKey("somekey", "1"), moreFiles));
}
@Test
@@ -198,19 +198,19 @@ public class SymbolCacheOnDiscTest {
Files.createFile(file3);
String[] files = {file1.toString(), file2.toString(), file3.toString()};
cache.store(new SymbolCacheKey("somekey", "1"), files, new ArrayList<>(), null);
cache.store(new IndexCacheKey("somekey", "1"), files, new ArrayList<>(), null);
String[] fewerFiles = {file1.toString(), file2.toString()};
assertNull(cache.retrieve(new SymbolCacheKey("somekey", "1"), fewerFiles));
assertNull(cache.retrieve(new IndexCacheKey("somekey", "1"), fewerFiles));
}
@Test
void testDeleteOldCacheFileIfNewOneIsStored() throws Exception {
SymbolCacheKey key1 = new SymbolCacheKey("somekey", "1");
IndexCacheKey key1 = new IndexCacheKey("somekey", "1");
cache.store(key1, new String[0], new ArrayList<>(), null);
assertTrue(Files.exists(tempDir.resolve(Paths.get(key1.toString() + ".json"))));
SymbolCacheKey key2 = new SymbolCacheKey("somekey", "2");
IndexCacheKey key2 = new IndexCacheKey("somekey", "2");
cache.store(key2, new String[0], new ArrayList<>(), null);
assertTrue(Files.exists(tempDir.resolve(Paths.get(key2.toString() + ".json"))));
assertFalse(Files.exists(tempDir.resolve(Paths.get(key1.toString() + ".json"))));
@@ -233,9 +233,9 @@ public class SymbolCacheOnDiscTest {
generatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol, null));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols, null);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols, null);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new SymbolCacheKey("somekey", "1"), files);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new IndexCacheKey("somekey", "1"), files);
assertNotNull(cachedSymbols);
assertEquals(1, cachedSymbols.length);
@@ -270,7 +270,7 @@ public class SymbolCacheOnDiscTest {
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1, null));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, null);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols1, null);
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
@@ -283,13 +283,13 @@ public class SymbolCacheOnDiscTest {
generatedSymbols2.add(new CachedSymbol(doc1URI, timeFile1.toMillis() + 2000, enhancedSymbol2, null));
assertTrue(file1.toFile().setLastModified(timeFile1.toMillis() + 2000));
cache.update(new SymbolCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols2, null);
cache.update(new IndexCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols2, null);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new SymbolCacheKey("somekey", "1"), files);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new IndexCacheKey("somekey", "1"), files);
assertNotNull(cachedSymbols);
assertEquals(2, cachedSymbols.length);
assertEquals(timeFile1.toMillis() + 2000, cache.getModificationTimestamp(new SymbolCacheKey("somekey", "1"), file1.toString()));
assertEquals(timeFile1.toMillis() + 2000, cache.getModificationTimestamp(new IndexCacheKey("somekey", "1"), file1.toString()));
}
@Test
@@ -328,7 +328,7 @@ public class SymbolCacheOnDiscTest {
generatedSymbols.add(new CachedSymbol(doc3URI, timeFile3.toMillis(), enhancedSymbol3, null));
// store original version of the symbols to the cache
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols, null);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols, null);
// create updated and new symbols
@@ -353,10 +353,10 @@ public class SymbolCacheOnDiscTest {
long[] updatedModificationTimestamps = new long[]{timeFile1.toMillis() + 2000, timeFile2.toMillis() + 3000};
// update multiple files in the cache
cache.update(new SymbolCacheKey("somekey", "1"), updatedFiles, updatedModificationTimestamps, updatedSymbols, null);
cache.update(new IndexCacheKey("somekey", "1"), updatedFiles, updatedModificationTimestamps, updatedSymbols, null);
// double check whether all changes got stored and retrieved correctly
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new SymbolCacheKey("somekey", "1"), files);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new IndexCacheKey("somekey", "1"), files);
assertNotNull(cachedSymbols);
assertEquals(4, cachedSymbols.length);
@@ -365,9 +365,9 @@ public class SymbolCacheOnDiscTest {
assertSymbol(updatedEnhancedSymbol2, cachedSymbols);
assertSymbol(enhancedSymbol3, cachedSymbols);
assertEquals(timeFile1.toMillis() + 2000, cache.getModificationTimestamp(new SymbolCacheKey("somekey", "1"), file1.toString()));
assertEquals(timeFile2.toMillis() + 3000, cache.getModificationTimestamp(new SymbolCacheKey("somekey", "1"), file2.toString()));
assertEquals(timeFile3.toMillis(), cache.getModificationTimestamp(new SymbolCacheKey("somekey", "1"), file3.toString()));
assertEquals(timeFile1.toMillis() + 2000, cache.getModificationTimestamp(new IndexCacheKey("somekey", "1"), file1.toString()));
assertEquals(timeFile2.toMillis() + 3000, cache.getModificationTimestamp(new IndexCacheKey("somekey", "1"), file2.toString()));
assertEquals(timeFile3.toMillis(), cache.getModificationTimestamp(new IndexCacheKey("somekey", "1"), file3.toString()));
}
private void assertSymbol(EnhancedSymbolInformation enhancedSymbol, CachedSymbol[] cachedSymbols) {
@@ -395,13 +395,13 @@ public class SymbolCacheOnDiscTest {
List<CachedSymbol> generatedSymbols = ImmutableList.of();
Multimap<String, String> dependencies = ImmutableMultimap.of(file1.toString(), "dep1");
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols, dependencies);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols, dependencies);
assertTrue(file1.toFile().setLastModified(timeFile1.toMillis() + 2000));
Set<String> dependencies2 = ImmutableSet.of("dep1", "dep2");
cache.update(new SymbolCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols, dependencies2);
cache.update(new IndexCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols, dependencies2);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("somekey", "1"), files);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("somekey", "1"), files);
assertNotNull(result);
assertEquals(ImmutableSet.of("dep1", "dep2"), result.getRight().get(file1.toString()));
}
@@ -422,14 +422,14 @@ public class SymbolCacheOnDiscTest {
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1, null));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, null);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols1, null);
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
assertTrue(file1.toFile().setLastModified(timeFile1.toMillis() + 2000));
cache.update(new SymbolCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols2, null);
cache.update(new IndexCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols2, null);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new SymbolCacheKey("somekey", "1"), files);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new IndexCacheKey("somekey", "1"), files);
assertNotNull(cachedSymbols);
assertEquals(0, cachedSymbols.length);
}
@@ -450,15 +450,15 @@ public class SymbolCacheOnDiscTest {
file1.toString(), "dep2"
);
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, dependencies1);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols1, dependencies1);
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
assertTrue(file1.toFile().setLastModified(timeFile1.toMillis() + 2000));
Set<String> dependencies2 = ImmutableSet.of("dep2");
cache.update(new SymbolCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols2, dependencies2);
cache.update(new IndexCacheKey("somekey", "1"), file1.toAbsolutePath().toString(), timeFile1.toMillis() + 2000, generatedSymbols2, dependencies2);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("somekey", "1"), files);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("somekey", "1"), files);
assertNotNull(result);
assertEquals(ImmutableSet.of("dep2"), result.getRight().get(file1.toString()));
}
@@ -483,7 +483,7 @@ public class SymbolCacheOnDiscTest {
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1, null));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, null);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols1, null);
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Interface, Either.forLeft(new Location(doc2URI, new Range(new Position(5, 5), new Position(5, 10)))));
@@ -491,9 +491,9 @@ public class SymbolCacheOnDiscTest {
generatedSymbols2.add(new CachedSymbol(doc2URI, timeFile2.toMillis(), enhancedSymbol2, null));
cache.update(new SymbolCacheKey("somekey", "1"), file2.toString(), timeFile2.toMillis(), generatedSymbols2, null);
cache.update(new IndexCacheKey("somekey", "1"), file2.toString(), timeFile2.toMillis(), generatedSymbols2, null);
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new SymbolCacheKey("somekey", "1"), new String[]{file1.toString(), file2.toString()});
CachedSymbol[] cachedSymbols = cache.retrieveSymbols(new IndexCacheKey("somekey", "1"), new String[]{file1.toString(), file2.toString()});
assertNotNull(cachedSymbols);
assertEquals(2, cachedSymbols.length);
}
@@ -513,12 +513,12 @@ public class SymbolCacheOnDiscTest {
Multimap<String, String> dependencies1 = ImmutableMultimap.of(
file1.toString(), "dep1"
);
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, dependencies1);
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols1, dependencies1);
Set<String> dependencies2 = ImmutableSet.of("dep2");
cache.update(new SymbolCacheKey("somekey", "1"), file2.toString(), timeFile2.toMillis(), generatedSymbols1, dependencies2);
cache.update(new IndexCacheKey("somekey", "1"), file2.toString(), timeFile2.toMillis(), generatedSymbols1, dependencies2);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("somekey", "1"), new String[]{file1.toString(), file2.toString()});
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("somekey", "1"), new String[]{file1.toString(), file2.toString()});
assertNotNull(result);
assertEquals(ImmutableSet.of("dep2"), result.getRight().get(file2.toString()));
assertEquals(ImmutableSet.of("dep1"), result.getRight().get(file1.toString()));
@@ -526,7 +526,7 @@ public class SymbolCacheOnDiscTest {
@Test
void testProjectDeleted() throws Exception {
SymbolCacheKey key1 = new SymbolCacheKey("somekey", "1");
IndexCacheKey key1 = new IndexCacheKey("somekey", "1");
cache.store(key1, new String[0], new ArrayList<>(), null);
assertTrue(Files.exists(tempDir.resolve(Paths.get(key1.toString() + ".json"))));
@@ -564,11 +564,11 @@ public class SymbolCacheOnDiscTest {
file1.toString(), "dep1",
file2.toString(), "dep2"
);
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols, dependencies);
cache.removeFile(new SymbolCacheKey("somekey", "1"), file1.toAbsolutePath().toString());
cache.store(new IndexCacheKey("somekey", "1"), files, generatedSymbols, dependencies);
cache.removeFile(new IndexCacheKey("somekey", "1"), file1.toAbsolutePath().toString());
files = new String[]{file2.toAbsolutePath().toString()};
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new SymbolCacheKey("somekey", "1"), files);
Pair<CachedSymbol[], Multimap<String, String>> result = cache.retrieve(new IndexCacheKey("somekey", "1"), files);
CachedSymbol[] cachedSymbols = result.getLeft();
assertNotNull(result);
assertEquals(1, cachedSymbols.length);

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Pivotal, Inc.
* Copyright (c) 2020, 2023 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
@@ -8,7 +8,7 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.utils.test;
package org.springframework.ide.vscode.boot.index.cache.test;
import java.io.File;
import java.io.IOException;
@@ -23,25 +23,25 @@ import java.util.TreeMap;
import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheKey;
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheKey;
import com.google.common.collect.Multimap;
/**
* @author Martin Lippert
*/
public class SymbolCacheTimestampsOnly implements SymbolCache {
public class IndexCacheTimestampsOnly implements IndexCache {
private Map<SymbolCacheKey, Map<String, Long>> timestampCache;
private Map<IndexCacheKey, Map<String, Long>> timestampCache;
public SymbolCacheTimestampsOnly() {
public IndexCacheTimestampsOnly() {
this.timestampCache = new HashMap<>();
}
@Override
public void store(SymbolCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String,String> dependencies) {
public void store(IndexCacheKey cacheKey, String[] files, List<CachedSymbol> generatedSymbols, Multimap<String,String> dependencies) {
SortedMap<String, Long> timestampedFiles = new TreeMap<>();
timestampedFiles = Arrays.stream(files)
@@ -58,18 +58,18 @@ public class SymbolCacheTimestampsOnly implements SymbolCache {
}
@Override
public Pair<CachedSymbol[], Multimap<String, String>> retrieve(SymbolCacheKey cacheKey, String[] files) {
public Pair<CachedSymbol[], Multimap<String, String>> retrieve(IndexCacheKey cacheKey, String[] files) {
return null;
}
@Override
public void update(SymbolCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies) {
public void update(IndexCacheKey cacheKey, String file, long lastModified, List<CachedSymbol> generatedSymbols, Set<String> dependencies) {
Map<String, Long> timestampMap = timestampCache.get(cacheKey);
timestampMap.put(file, lastModified);
}
@Override
public void update(SymbolCacheKey cacheKey, String[] files, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
public void update(IndexCacheKey cacheKey, String[] files, long[] lastModified, List<CachedSymbol> generatedSymbols, Multimap<String, String> dependencies) {
Map<String, Long> timestampMap = timestampCache.get(cacheKey);
for (int i = 0; i < files.length; i++) {
@@ -78,15 +78,15 @@ public class SymbolCacheTimestampsOnly implements SymbolCache {
}
@Override
public void remove(SymbolCacheKey cacheKey) {
public void remove(IndexCacheKey cacheKey) {
}
@Override
public void removeFile(SymbolCacheKey symbolCacheKey, String file) {
public void removeFile(IndexCacheKey symbolCacheKey, String file) {
}
@Override
public long getModificationTimestamp(SymbolCacheKey cacheKey, String file) {
public long getModificationTimestamp(IndexCacheKey cacheKey, String file) {
Map<String, Long> timestampMap = timestampCache.get(cacheKey);
if (timestampMap != null) {
Long timestamp = timestampMap.get(file);

View File

@@ -8,7 +8,7 @@
* Contributors:
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.metamodel.test;
package org.springframework.ide.vscode.boot.index.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

View File

@@ -8,7 +8,7 @@
* Contributors:
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.metamodel.test;
package org.springframework.ide.vscode.boot.index.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -25,7 +25,7 @@ import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.Range;
import org.junit.jupiter.api.Test;
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheOnDisc;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheOnDisc;
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
import org.springframework.ide.vscode.commons.protocol.spring.DefaultValues;
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
@@ -224,7 +224,7 @@ public class SpringMetamodelIndexTest {
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, new InjectionPoint[] {point1, point2}, new String[] {"supertype1", "supertype2"}, emptyAnnotations);
String serialized = bean1.toString();
Gson gson = SymbolCacheOnDisc.createGson();
Gson gson = IndexCacheOnDisc.createGson();
Bean deserializedBean = gson.fromJson(serialized, Bean.class);
assertEquals("beanName1", deserializedBean.getName());
@@ -252,7 +252,7 @@ public class SpringMetamodelIndexTest {
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations);
String serialized = bean1.toString();
Gson gson = SymbolCacheOnDisc.createGson();
Gson gson = IndexCacheOnDisc.createGson();
Bean deserializedBean = gson.fromJson(serialized, Bean.class);
assertEquals("beanName1", deserializedBean.getName());

View File

@@ -8,7 +8,7 @@
* Contributors:
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.metamodel.test;
package org.springframework.ide.vscode.boot.index.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

View File

@@ -8,7 +8,7 @@
* Contributors:
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.metamodel.test;
package org.springframework.ide.vscode.boot.index.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

View File

@@ -32,12 +32,12 @@ import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.bootiful.AdHocPropertyHarnessTestConf;
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
@@ -73,8 +73,8 @@ public class CompilationUnitCacheTest {
@Configuration static class TestConf {
@Bean SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {

View File

@@ -33,7 +33,8 @@ import org.springframework.context.annotation.Import;
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.test.IndexCacheTimestampsOnly;
import org.springframework.ide.vscode.boot.java.utils.SymbolIndexConfig;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
@@ -53,8 +54,8 @@ public class SpringIndexerMultipleFilesTest {
// in order to check the java symbol indexer feature which avoid scanning the
// same file again even if the timestamp hasn't changed
public static class TimestampingAwareCacheConfig extends SymbolProviderTestConf {
@Bean public SymbolCache symbolCache() {
return new SymbolCacheTimestampsOnly();
@Bean public IndexCache symbolCache() {
return new IndexCacheTimestampsOnly();
}
}

View File

@@ -35,11 +35,11 @@ import org.springframework.ide.vscode.boot.bootiful.AdHocPropertyHarnessTestConf
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
import org.springframework.ide.vscode.commons.java.IJavaProject;
@@ -117,8 +117,8 @@ public class ValueCompletionTest {
);
}
@Bean SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean SourceLinks sourceLinks(SimpleTextDocumentService documents, CompilationUnitCache cuCache) {

View File

@@ -40,14 +40,14 @@ import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
import org.springframework.ide.vscode.boot.bootiful.AdHocPropertyHarnessTestConf;
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
import org.springframework.ide.vscode.boot.index.cache.IndexCache;
import org.springframework.ide.vscode.boot.index.cache.IndexCacheVoid;
import org.springframework.ide.vscode.boot.java.handlers.BootJavaReconcileEngine;
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
import org.springframework.ide.vscode.boot.java.reconcilers.JavaReconciler;
import org.springframework.ide.vscode.boot.java.reconcilers.JdtReconciler;
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
@@ -129,8 +129,8 @@ public class ValueSpelExpressionValidationTest {
);
}
@Bean SymbolCache symbolCache() {
return new SymbolCacheVoid();
@Bean IndexCache symbolCache() {
return new IndexCacheVoid();
}
@Bean SourceLinks sourceLinks(SimpleTextDocumentService documents, CompilationUnitCache cuCache) {