Use CachedValuesManager.getCachedValue()
This commit is contained in:
@@ -74,12 +74,12 @@ public final class AnalyzerFacadeWithCache {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static AnalyzeExhaust analyzeFileWithCache(@NotNull final JetFile file,
|
public static AnalyzeExhaust analyzeFileWithCache(@NotNull final JetFile file,
|
||||||
@NotNull final Function<JetFile, Collection<JetFile>> declarationProvider) {
|
@NotNull final Function<JetFile, Collection<JetFile>> declarationProvider) {
|
||||||
// Need lock for getValue(), because parallel threads can start evaluation of compute() simultaneously
|
// Need lock, because parallel threads can start evaluation of compute() simultaneously
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
CachedValue<AnalyzeExhaust> result = file.getUserData(ANALYZE_EXHAUST_FULL);
|
return CachedValuesManager.getManager(file.getProject()).getCachedValue(
|
||||||
if (result == null) {
|
file,
|
||||||
result =
|
ANALYZE_EXHAUST_FULL,
|
||||||
CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<AnalyzeExhaust>() {
|
new CachedValueProvider<AnalyzeExhaust>() {
|
||||||
@Override
|
@Override
|
||||||
public Result<AnalyzeExhaust> compute() {
|
public Result<AnalyzeExhaust> compute() {
|
||||||
try {
|
try {
|
||||||
@@ -105,12 +105,9 @@ public final class AnalyzerFacadeWithCache {
|
|||||||
return emptyExhaustWithDiagnosticOnFile(file, e);
|
return emptyExhaustWithDiagnosticOnFile(file, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false);
|
},
|
||||||
|
false
|
||||||
file.putUserData(ANALYZE_EXHAUST_FULL, result);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return result.getValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user