mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
synchronize BasePathMacroManager map access
This commit is contained in:
+33
-23
@@ -139,6 +139,7 @@ public class BasePathMacroManager extends PathMacroManager {
|
||||
}
|
||||
|
||||
private class MyTrackingPathMacroSubstitutor implements TrackingPathMacroSubstitutor {
|
||||
private final String myLock = new String("MyTrackingPathMacroSubstitutor.lock");
|
||||
private final Map<String, Set<String>> myMacroToComponentNames = new FactoryMap<String, Set<String>>() {
|
||||
@Override
|
||||
protected Set<String> create(String key) {
|
||||
@@ -158,8 +159,10 @@ public class BasePathMacroManager extends PathMacroManager {
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myMacroToComponentNames.clear();
|
||||
myComponentNameToMacros.clear();
|
||||
synchronized (myLock) {
|
||||
myMacroToComponentNames.clear();
|
||||
myComponentNameToMacros.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,45 +191,52 @@ public class BasePathMacroManager extends PathMacroManager {
|
||||
|
||||
@Override
|
||||
public void invalidateUnknownMacros(final Set<String> macros) {
|
||||
for (final String macro : macros) {
|
||||
final Set<String> components = myMacroToComponentNames.get(macro);
|
||||
for (final String component : components) {
|
||||
myComponentNameToMacros.remove(component);
|
||||
}
|
||||
synchronized (myLock) {
|
||||
for (final String macro : macros) {
|
||||
final Set<String> components = myMacroToComponentNames.get(macro);
|
||||
for (final String component : components) {
|
||||
myComponentNameToMacros.remove(component);
|
||||
}
|
||||
|
||||
myMacroToComponentNames.remove(macro);
|
||||
myMacroToComponentNames.remove(macro);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getComponents(final Collection<String> macros) {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
for (String macro : myMacroToComponentNames.keySet()) {
|
||||
if (macros.contains(macro)) {
|
||||
result.addAll(myMacroToComponentNames.get(macro));
|
||||
synchronized (myLock) {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
for (String macro : myMacroToComponentNames.keySet()) {
|
||||
if (macros.contains(macro)) {
|
||||
result.addAll(myMacroToComponentNames.get(macro));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getUnknownMacros(final String componentName) {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
result.addAll(componentName == null ? myMacroToComponentNames.keySet() : myComponentNameToMacros.get(componentName));
|
||||
return Collections.unmodifiableCollection(result);
|
||||
synchronized (myLock) {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
result.addAll(componentName == null ? myMacroToComponentNames.keySet() : myComponentNameToMacros.get(componentName));
|
||||
return Collections.unmodifiableCollection(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUnknownMacros(final String componentName, final Collection<String> unknownMacros) {
|
||||
if (unknownMacros.isEmpty()) return;
|
||||
|
||||
for (String unknownMacro : unknownMacros) {
|
||||
final Set<String> stringList = myMacroToComponentNames.get(unknownMacro);
|
||||
stringList.add(componentName);
|
||||
}
|
||||
|
||||
myComponentNameToMacros.get(componentName).addAll(unknownMacros);
|
||||
synchronized (myLock) {
|
||||
for (String unknownMacro : unknownMacros) {
|
||||
myMacroToComponentNames.get(unknownMacro).add(componentName);
|
||||
}
|
||||
|
||||
myComponentNameToMacros.get(componentName).addAll(unknownMacros);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user