Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.text.templates;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -41,7 +44,10 @@ public class ContextTypeRegistry {
* @param contextType the context type to add
*/
public void addContextType(TemplateContextType contextType) {
fContextTypes.put(contextType.getId(), contextType);
String id= contextType.getId();
synchronized (fContextTypes) {
fContextTypes.put(id, contextType);
}
}

/**
Expand All @@ -51,15 +57,21 @@ public void addContextType(TemplateContextType contextType) {
* @return the context type if <code>name</code> is valid, <code>null</code> otherwise
*/
public TemplateContextType getContextType(String id) {
return fContextTypes.get(id);
synchronized (fContextTypes) {
return fContextTypes.get(id);
}
}

/**
* Returns an iterator over all registered context types.
* Returns a read-only iterator over all registered context types.
*
* @return an iterator over all registered context types
* @return a read-only iterator over all registered context types
*/
public Iterator<TemplateContextType> contextTypes() {
return fContextTypes.values().iterator();
Collection<TemplateContextType> values;
synchronized (fContextTypes) {
values= new ArrayList<>(fContextTypes.values());
}
return Collections.unmodifiableCollection(values).iterator();
}
}
Loading