Skip to content

Commit

Permalink
devtools: properly refresh macro namespaces cache on workspace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Jun 18, 2016
1 parent 3cbfb2e commit 4f8a160
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions resources/unpacked/devtools/front_end/dirac_lazy/dirac_lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ Object.assign(window.dirac, (function() {
console.log("invalidateNamespacesCache");
}
dirac._namespacesCache = null;
// HACK: macro namespaces depend on _namespacesCache, do explicit invalidation here
// TODO: in future we want to be smarter here
// macro namespaces depend on _namespacesCache, do explicit invalidation here
dirac.invalidateMacroNamespaceSymbolsCache();
}

Expand All @@ -273,11 +272,18 @@ Object.assign(window.dirac, (function() {

function extractAndMergeSourceCodeNamespacesAsync(uiSourceCode) {
return extractSourceCodeNamespacesAsync(uiSourceCode).then(result => {
if (Object.keys(result).length) {
const namespaceNames = Object.keys(result);
if (namespaceNames.length) {
if (dirac._DEBUG_CACHES) {
console.log("updated _namespacesCache by merging ", result);
}
Object.assign(dirac._namespacesCache, result);

// refresh macro namespaces data based on new results
for (let namespaceName of namespaceNames) {
dirac.invalidateMacroNamespaceSymbolsCache(namespaceName);
dirac.extractMacroNamespaceSymbolsAsync(namespaceName);
}
}
return result;
});
Expand All @@ -290,6 +296,7 @@ Object.assign(window.dirac, (function() {
if (descriptor.url != url) {
newCache[namespaceName] = descriptor;
} else {
dirac.invalidateMacroNamespaceSymbolsCache(namespaceName);
if (dirac._DEBUG_CACHES) {
console.log("removeNamespacesMatchingUrl removed ", namespaceName, descriptor);
}
Expand Down

0 comments on commit 4f8a160

Please sign in to comment.