summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-01-06 12:20:16 -0800
committerGeorge Fraser <george@fivetran.com>2019-01-06 12:20:16 -0800
commit3b196bb2dafbfa78034e9c1195d2f0ec4cd70abe (patch)
tree7283139d6a2f02e41a2f735b969f0d9a9c5e04eb
parent97cf157712cb221c7fa27529dcc563916f7ab293 (diff)
downloadjava-language-server-3b196bb2dafbfa78034e9c1195d2f0ec4cd70abe.zip
Fix needs(_)
-rw-r--r--src/main/java/org/javacs/Cache.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/org/javacs/Cache.java b/src/main/java/org/javacs/Cache.java
index 6344044..139d1e1 100644
--- a/src/main/java/org/javacs/Cache.java
+++ b/src/main/java/org/javacs/Cache.java
@@ -43,8 +43,9 @@ class Cache<K, V> {
private final Map<Key, Value> map = new HashMap<>();
- boolean needs(Path file, K key) {
+ boolean needs(Path file, K k) {
// If key is not in map, it needs to be loaded
+ var key = new Key(file, k);
if (!map.containsKey(key)) return true;
// If key was loaded before file was last modified, it needs to be reloaded
@@ -58,17 +59,19 @@ class Cache<K, V> {
return value.created.isBefore(modified);
}
- void load(Path file, K key, V value) {
+ void load(Path file, K k, V v) {
// TODO limit total size of cache
- map.put(new Key(file, key), new Value(value));
+ var key = new Key(file, k);
+ var value = new Value(v);
+ map.put(key, value);
}
- V get(Path file, K key) {
- var k = new Key(file, key);
- if (!map.containsKey(k)) {
+ V get(Path file, K k) {
+ var key = new Key(file, k);
+ if (!map.containsKey(key)) {
throw new IllegalArgumentException(k + " is not in map " + map);
}
- return map.get(k).value;
+ return map.get(key).value;
}
void clear() {