switch to nio API only for checking modification dates of files
This commit is contained in:
@@ -13,7 +13,9 @@ package org.springframework.ide.vscode.boot.java.utils;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -72,7 +74,13 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
|
||||
timestampedFiles = Arrays.stream(files)
|
||||
.filter(file -> new File(file).exists())
|
||||
.collect(Collectors.toMap(file -> file, file -> new File(file).lastModified(), (v1,v2) -> { throw new RuntimeException(String.format("Duplicate key for values %s and %s", v1, v2));}, TreeMap::new));
|
||||
.collect(Collectors.toMap(file -> file, file -> {
|
||||
try {
|
||||
return Files.getLastModifiedTime(new File(file).toPath()).toMillis();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, (v1,v2) -> { throw new RuntimeException(String.format("Duplicate key for values %s and %s", v1, v2));}, TreeMap::new));
|
||||
|
||||
save(cacheKey, generatedSymbols, timestampedFiles);
|
||||
}
|
||||
@@ -88,7 +96,13 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
|
||||
SortedMap<String, Long> timestampedFiles = Arrays.stream(files)
|
||||
.filter(file -> new File(file).exists())
|
||||
.collect(Collectors.toMap(file -> file, file -> new File(file).lastModified(), (v1,v2) -> { throw new RuntimeException(String.format("Duplicate key for values %s and %s", v1, v2));}, TreeMap::new));
|
||||
.collect(Collectors.toMap(file -> file, file -> {
|
||||
try {
|
||||
return Files.getLastModifiedTime(new File(file).toPath()).toMillis();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, (v1,v2) -> { throw new RuntimeException(String.format("Duplicate key for values %s and %s", v1, v2));}, TreeMap::new));
|
||||
|
||||
if (isFileMatch(timestampedFiles, store.getTimestampedFiles())) {
|
||||
this.stores.put(cacheKey, store);
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
@@ -229,7 +228,7 @@ public class SymbolCacheOnDiscTest {
|
||||
assertEquals(new Range(new Position(6, 6), new Position(7, 7)), ranges[1]);
|
||||
}
|
||||
|
||||
@Ignore @Test
|
||||
@Test
|
||||
public void testSymbolAddedToExistingFile() throws Exception {
|
||||
Path file1 = Paths.get(tempDir.toAbsolutePath().toString(), "tempFile1");
|
||||
|
||||
@@ -265,7 +264,7 @@ public class SymbolCacheOnDiscTest {
|
||||
assertEquals(2, cachedSymbols.length);
|
||||
}
|
||||
|
||||
@Ignore @Test
|
||||
@Test
|
||||
public void testSymbolRemovedFromExistingFile() throws Exception {
|
||||
Path file1 = Paths.get(tempDir.toAbsolutePath().toString(), "tempFile1");
|
||||
|
||||
@@ -293,7 +292,7 @@ public class SymbolCacheOnDiscTest {
|
||||
assertEquals(0, cachedSymbols.length);
|
||||
}
|
||||
|
||||
@Ignore @Test
|
||||
@Test
|
||||
public void testSymbolAddedToNewFile() throws Exception {
|
||||
Path file1 = Paths.get(tempDir.toAbsolutePath().toString(), "tempFile1");
|
||||
Path file2 = Paths.get(tempDir.toAbsolutePath().toString(), "tempFile2");
|
||||
|
||||
Reference in New Issue
Block a user