Reduce "static synchronized" where possible

Change-Id: I65b947dee5a153bafd7bc39fdf8e19dd8dc24fcf
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
diff --git a/core/plugins/org.eclipse.dltk.core.index.lucene/src/org/eclipse/dltk/internal/core/index/lucene/IndexContainer.java b/core/plugins/org.eclipse.dltk.core.index.lucene/src/org/eclipse/dltk/internal/core/index/lucene/IndexContainer.java
index a94e369..5d920e8 100644
--- a/core/plugins/org.eclipse.dltk.core.index.lucene/src/org/eclipse/dltk/internal/core/index/lucene/IndexContainer.java
+++ b/core/plugins/org.eclipse.dltk.core.index.lucene/src/org/eclipse/dltk/internal/core/index/lucene/IndexContainer.java
@@ -292,7 +292,7 @@
 		return false;
 	}
 
-	synchronized void commit(IProgressMonitor monitor) {
+	void commit(IProgressMonitor monitor) {
 		int ticks = 1;
 		for (Map<?, ?> dataWriters : fIndexWriters.values()) {
 			ticks += dataWriters.size() * 2;
diff --git a/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/ASTCacheManager.java b/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/ASTCacheManager.java
index 3e60ec5..8567c79 100644
--- a/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/ASTCacheManager.java
+++ b/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/ASTCacheManager.java
@@ -15,28 +15,30 @@
 
 	private static Map<String, IASTCache[]> providers = null;
 
-	public synchronized static IASTCache[] getProviders(String lang) {
+	public static IASTCache[] getProviders(String lang) {
 		if (providers == null) {
-			providers = new HashMap<>();
+			synchronized (ASTCacheManager.class) {
+				providers = new HashMap<>();
 
-			ElementInfo[] infos = manager.getElementInfos();
-			Map<String, List<IASTCache>> langToElementList = new HashMap<>();
-			// Fill element names and sort elements by language
-			for (int i = 0; i < infos.length; i++) {
-				String langauge = infos[i].getConfig().getAttribute("language");
-				List<IASTCache> elements = langToElementList.get(langauge);
-				if (elements == null) {
-					elements = new ArrayList<>();
-					langToElementList.put(langauge, elements);
+				ElementInfo[] infos = manager.getElementInfos();
+				Map<String, List<IASTCache>> langToElementList = new HashMap<>();
+				// Fill element names and sort elements by language
+				for (int i = 0; i < infos.length; i++) {
+					String langauge = infos[i].getConfig().getAttribute("language");
+					List<IASTCache> elements = langToElementList.get(langauge);
+					if (elements == null) {
+						elements = new ArrayList<>();
+						langToElementList.put(langauge, elements);
+					}
+					elements.add((IASTCache) manager.getInitObject(infos[i]));
 				}
-				elements.add((IASTCache) manager.getInitObject(infos[i]));
+				for (Map.Entry<String, List<IASTCache>> entry : langToElementList.entrySet()) {
+					List<IASTCache> list = entry.getValue();
+					IASTCache[] result = list.toArray(new IASTCache[list.size()]);
+					providers.put(entry.getKey(), result);
+				}
 			}
-			for (Map.Entry<String, List<IASTCache>> entry : langToElementList
-					.entrySet()) {
-				List<IASTCache> list = entry.getValue();
-				IASTCache[] result = list.toArray(new IASTCache[list.size()]);
-				providers.put(entry.getKey(), result);
-			}
+
 		}
 		return providers.get(lang);
 	}
diff --git a/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/SourceParserManager.java b/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/SourceParserManager.java
index ebbcfc8..24d074f 100644
--- a/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/SourceParserManager.java
+++ b/core/plugins/org.eclipse.dltk.core/ast/org/eclipse/dltk/ast/parser/SourceParserManager.java
@@ -3,7 +3,7 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
  * Contributors:
@@ -30,8 +30,7 @@
  */
 public class SourceParserManager extends DLTKContributionExtensionManager {
 
-	static final String SOURCE_PARSER_EXT_POINT = DLTKCore.PLUGIN_ID
-			+ ".sourceParsers"; //$NON-NLS-1$
+	static final String SOURCE_PARSER_EXT_POINT = DLTKCore.PLUGIN_ID + ".sourceParsers"; //$NON-NLS-1$
 
 	static final String PARSER_CONTRIBUTION_TAG = "parserContribution"; //$NON-NLS-1$
 
@@ -43,16 +42,19 @@
 
 	private static SourceParserManager instance;
 
-	public static synchronized SourceParserManager getInstance() {
+	public static SourceParserManager getInstance() {
 		if (instance == null) {
-			instance = new SourceParserManager();
+			synchronized (SourceParserManager.class) {
+				if (instance == null) {
+					instance = new SourceParserManager();
+				}
+			}
 		}
 		return instance;
 	}
 
 	public ISourceParser getSourceParserById(String id) {
-		return ((SourceParserContribution) getContributionById(id))
-				.createSourceParser(null);
+		return ((SourceParserContribution) getContributionById(id)).createSourceParser(null);
 	}
 
 	@Override
@@ -76,22 +78,19 @@
 	}
 
 	@Override
-	protected Object configureContribution(Object object,
-			IConfigurationElement config) {
+	protected Object configureContribution(Object object, IConfigurationElement config) {
 		/*
-		 * using the following delegate class allows for integration with the
-		 * generic managed contribution preference page.
+		 * using the following delegate class allows for integration with the generic
+		 * managed contribution preference page.
 		 *
-		 * not all source parsers are thread safe, so the factory allows us to
-		 * create a new instance each time one is requested
+		 * not all source parsers are thread safe, so the factory allows us to create a
+		 * new instance each time one is requested
 		 */
-		return new SourceParserContribution((ISourceParserFactory) object,
-				config);
+		return new SourceParserContribution((ISourceParserFactory) object, config);
 	}
 
 	public ISourceParser getSourceParser(IProject project, String natureId) {
-		SourceParserContribution contribution = (SourceParserContribution) getSelectedContribution(
-				project, natureId);
+		SourceParserContribution contribution = (SourceParserContribution) getSelectedContribution(project, natureId);
 		if (contribution != null) {
 			return contribution.createSourceParser(project);
 		}
@@ -105,35 +104,29 @@
 		@Nullable
 		final ISourceParserConfigurator[] configurators;
 
-		SourceParserContribution(ISourceParserFactory factory,
-				IConfigurationElement config) {
+		SourceParserContribution(ISourceParserFactory factory, IConfigurationElement config) {
 			this.factory = factory;
 			this.config = config;
 
 			/*
-			 * this is a cheat - this class contains all the attributes of the
-			 * configured extension, so leverage the code
-			 * DLTKContributedExtension already provides
+			 * this is a cheat - this class contains all the attributes of the configured
+			 * extension, so leverage the code DLTKContributedExtension already provides
 			 */
 			setInitializationData(config, null, null);
-			this.configurators = getId() != null ? createConfigurators(getId())
-					: null;
+			this.configurators = getId() != null ? createConfigurators(getId()) : null;
 		}
 
 		ISourceParser createSourceParser(@Nullable IProject project) {
 			final ISourceParser parser = factory.createSourceParser();
 			/*
-			 * another cheat - not all source parsers are thread safe, so we
-			 * need to create a new instance each time one is requested (hence
-			 * the factory).
+			 * another cheat - not all source parsers are thread safe, so we need to create
+			 * a new instance each time one is requested (hence the factory).
 			 *
-			 * the parser instance should be initialized with all it's attribute
-			 * data
+			 * the parser instance should be initialized with all it's attribute data
 			 */
 			if (parser instanceof IExecutableExtension) {
 				try {
-					((IExecutableExtension) parser)
-							.setInitializationData(config, null, null);
+					((IExecutableExtension) parser).setInitializationData(config, null, null);
 				} catch (CoreException e) {
 					DLTKCore.error(e);
 				}
@@ -147,33 +140,25 @@
 			return parser;
 		}
 
-		private static ISourceParserConfigurator[] createConfigurators(
-				String parserId) {
+		private static ISourceParserConfigurator[] createConfigurators(String parserId) {
 			List<ISourceParserConfigurator> result = null;
 			for (IConfigurationElement element : Platform.getExtensionRegistry()
 					.getConfigurationElementsFor(SOURCE_PARSER_EXT_POINT)) {
-				if (PARSER_CONFIGURATOR_TAG.equals(element.getName())
-						&& parserId.equals(element.getAttribute("id"))) { //$NON-NLS-1$
+				if (PARSER_CONFIGURATOR_TAG.equals(element.getName()) && parserId.equals(element.getAttribute("id"))) { //$NON-NLS-1$
 					try {
-						final Object configurator = element
-								.createExecutableExtension(
-										PARSER_CONFIGURATOR_CLASS);
+						final Object configurator = element.createExecutableExtension(PARSER_CONFIGURATOR_CLASS);
 						if (configurator instanceof ISourceParserConfigurator) {
 							if (result == null) {
 								result = new ArrayList<>();
 							}
-							result.add(
-									(ISourceParserConfigurator) configurator);
+							result.add((ISourceParserConfigurator) configurator);
 						}
 					} catch (CoreException e) {
 						DLTKCore.error(e);
 					}
 				}
 			}
-			return result != null
-					? result.toArray(
-							new ISourceParserConfigurator[result.size()])
-					: null;
+			return result != null ? result.toArray(new ISourceParserConfigurator[result.size()]) : null;
 		}
 	}
 }
diff --git a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/DefaultProblemIdentifier.java b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/DefaultProblemIdentifier.java
index 1898489..4d351eb 100644
--- a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/DefaultProblemIdentifier.java
+++ b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/DefaultProblemIdentifier.java
@@ -4,7 +4,7 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
  * Contributors:
@@ -34,12 +34,10 @@
 		return DLTKCore.PLUGIN_ID;
 	}
 
-	private static class Manager
-			extends NatureExtensionManager<IProblemIdentifierFactory> {
+	private static class Manager extends NatureExtensionManager<IProblemIdentifierFactory> {
 
 		public Manager() {
-			super(InternalDLTKLanguageManager.PROBLEM_FACTORY_EXTPOINT,
-					IProblemIdentifierFactory.class);
+			super(InternalDLTKLanguageManager.PROBLEM_FACTORY_EXTPOINT, IProblemIdentifierFactory.class);
 		}
 
 		@Override
@@ -54,9 +52,13 @@
 
 	}
 
-	private static synchronized Manager getManager() {
+	private static Manager getManager() {
 		if (manager == null) {
-			manager = new Manager();
+			synchronized (DefaultProblemIdentifier.class) {
+				if (manager == null) {
+					manager = new Manager();
+				}
+			}
 		}
 		return manager;
 	}
@@ -72,14 +74,12 @@
 		if (id != null && id.length() != 0) {
 			final int pos = id.indexOf(SEPARATOR);
 			if (pos >= 0) {
-				IProblemIdentifierFactory[] factories = getManager()
-						.getInstances(id.substring(0, pos));
+				IProblemIdentifierFactory[] factories = getManager().getInstances(id.substring(0, pos));
 				if (factories != null) {
 					final String localName = id.substring(pos + 1);
 					for (IProblemIdentifierFactory factory : factories) {
 						try {
-							final IProblemIdentifier value = factory
-									.valueOf(localName);
+							final IProblemIdentifier value = factory.valueOf(localName);
 							if (value != null) {
 								return value;
 							}
@@ -90,10 +90,8 @@
 				}
 			}
 			synchronized (reportedProblemIds) {
-				if (reportedProblemIds.size() < 100
-						&& reportedProblemIds.add(id)) {
-					DLTKCore.warn(
-							"Error decoding problem idenfier \"" + id + "\"");
+				if (reportedProblemIds.size() < 100 && reportedProblemIds.add(id)) {
+					DLTKCore.warn("Error decoding problem idenfier \"" + id + "\"");
 				}
 			}
 			try {
@@ -108,8 +106,7 @@
 	}
 
 	public static IProblemIdentifier[] values(String namespace) {
-		final IProblemIdentifierFactory[] factories = getManager()
-				.getInstances(namespace);
+		final IProblemIdentifierFactory[] factories = getManager().getInstances(namespace);
 		final List<IProblemIdentifier> result = new ArrayList<>();
 		if (factories != null) {
 			for (IProblemIdentifierFactory factory : factories) {
@@ -133,8 +130,7 @@
 		if (identifier == null) {
 			return Util.EMPTY_STRING;
 		} else if (identifier instanceof Enum<?>) {
-			return identifier.getClass().getName() + SEPARATOR
-					+ identifier.name();
+			return identifier.getClass().getName() + SEPARATOR + identifier.name();
 		} else {
 			return identifier.name();
 		}
diff --git a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCategoryManager.java b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCategoryManager.java
index 10929df..8f8e4e2 100644
--- a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCategoryManager.java
+++ b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCategoryManager.java
@@ -4,7 +4,7 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
  * Contributors:
@@ -38,9 +38,13 @@
 
 	private static ProblemCategoryManager instance = null;
 
-	public static synchronized ProblemCategoryManager getInstance() {
+	public static ProblemCategoryManager getInstance() {
 		if (instance == null) {
-			instance = new ProblemCategoryManager();
+			synchronized (ProblemCategoryManager.class) {
+				if (instance == null) {
+					instance = new ProblemCategoryManager();
+				}
+			}
 		}
 		return instance;
 	}
@@ -63,8 +67,7 @@
 		public boolean equals(Object obj) {
 			if (obj instanceof Key) {
 				final Key other = (Key) obj;
-				return natureId.equals(other.natureId)
-						&& scopeId.equals(other.scopeId);
+				return natureId.equals(other.natureId) && scopeId.equals(other.scopeId);
 			}
 			return false;
 		}
@@ -78,8 +81,7 @@
 	}
 
 	@SuppressWarnings("serial")
-	static class ProblemCategory extends HashSet<IProblemIdentifier>
-			implements IProblemCategory {
+	static class ProblemCategory extends HashSet<IProblemIdentifier> implements IProblemCategory {
 
 		private final String name;
 		private final Collection<IProblemIdentifier> contents;
@@ -102,22 +104,20 @@
 	}
 
 	/**
-	 * returns an array (empty is nothing can be found) of all the category ids
-	 * that can be found for this problem.
+	 * returns an array (empty is nothing can be found) of all the category ids that
+	 * can be found for this problem.
 	 *
 	 * @param natureId
 	 * @param scopeId
 	 * @param problem
 	 * @return
 	 */
-	public String[] getID(String natureId, String scopeId,
-			IProblemIdentifier problem) {
+	public String[] getID(String natureId, String scopeId, IProblemIdentifier problem) {
 		Assert.isNotNull(natureId);
 		ScopeDescriptor scope = getScope(natureId, scopeId);
 		if (scope == null)
 			return new String[0];
-		Iterator<Entry<String, ProblemCategory>> iterator = scope.entrySet()
-				.iterator();
+		Iterator<Entry<String, ProblemCategory>> iterator = scope.entrySet().iterator();
 		List<String> ids = new ArrayList<>();
 		while (iterator.hasNext()) {
 			Entry<String, ProblemCategory> entry = iterator.next();
@@ -128,8 +128,7 @@
 		return ids.toArray(new String[ids.size()]);
 	}
 
-	public IProblemCategory getCategory(String natureId, String scopeId,
-			String id) {
+	public IProblemCategory getCategory(String natureId, String scopeId, String id) {
 		Assert.isNotNull(natureId);
 		ScopeDescriptor scope = getScope(natureId, scopeId);
 		if (scope == null)
@@ -153,15 +152,12 @@
 		}
 		if (scope == null) {
 			scope = new ScopeDescriptor();
-			final IConfigurationElement[] elements = Platform
-					.getExtensionRegistry().getConfigurationElementsFor(
-							InternalDLTKLanguageManager.PROBLEM_FACTORY_EXTPOINT);
+			final IConfigurationElement[] elements = Platform.getExtensionRegistry()
+					.getConfigurationElementsFor(InternalDLTKLanguageManager.PROBLEM_FACTORY_EXTPOINT);
 			for (IConfigurationElement element : elements) {
 				if (CATEGORY_ELEMENT.equals(element.getName())
-						&& scopeKey.natureId
-								.equals(element.getAttribute(NATURE_ATTR))
-						&& scopeKey.scopeId
-								.equals(element.getAttribute(SCOPE_ATTR))) {
+						&& scopeKey.natureId.equals(element.getAttribute(NATURE_ATTR))
+						&& scopeKey.scopeId.equals(element.getAttribute(SCOPE_ATTR))) {
 					final String categoryId = element.getAttribute(ID_ATTR);
 					if (categoryId != null) {
 						ProblemCategory category = scope.get(categoryId);
@@ -169,12 +165,9 @@
 							category = new ProblemCategory(categoryId);
 							scope.put(categoryId, category);
 						}
-						for (IConfigurationElement problem : element
-								.getChildren(PROBLEM_ELEMENT)) {
-							final IProblemIdentifier identifier = DefaultProblemIdentifier
-									.decode(problem.getValue());
-							if (identifier != null
-									&& !(identifier instanceof ProblemIdentifierInt)
+						for (IConfigurationElement problem : element.getChildren(PROBLEM_ELEMENT)) {
+							final IProblemIdentifier identifier = DefaultProblemIdentifier.decode(problem.getValue());
+							if (identifier != null && !(identifier instanceof ProblemIdentifierInt)
 									&& !(identifier instanceof ProblemIdentifierString)) {
 								category.add(identifier);
 							}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BufferManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BufferManager.java
index 03ae71d..39d4d30 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BufferManager.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BufferManager.java
@@ -3,10 +3,10 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
- 
+
  *******************************************************************************/
 package org.eclipse.dltk.internal.core;
 
@@ -39,8 +39,7 @@
 	 */
 	protected void addBuffer(IBuffer buffer) {
 		if (VERBOSE) {
-			String owner = ((Openable) buffer.getOwner())
-					.toStringWithAncestors();
+			String owner = ((Openable) buffer.getOwner()).toStringWithAncestors();
 			System.out.println("Adding buffer for " + owner); //$NON-NLS-1$
 		}
 		synchronized (this.openBuffers) {
@@ -49,29 +48,26 @@
 		// close buffers that were removed from the cache if space was needed
 		this.openBuffers.closeBuffers();
 		if (VERBOSE) {
-			System.out
-					.println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$
+			System.out.println("-> Buffer cache filling ratio = " //$NON-NLS-1$
+					+ NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$
 		}
 	}
 
 	public static IBuffer createBuffer(IOpenable owner) {
 		IModelElement element = owner;
 		IResource resource = element.getResource();
-		return new Buffer(resource instanceof IFile ? (IFile) resource : null,
-				owner, element.isReadOnly());
+		return new Buffer(resource instanceof IFile ? (IFile) resource : null, owner, element.isReadOnly());
 	}
 
 	public static IBuffer createNullBuffer(IOpenable owner) {
 		IModelElement element = owner;
 		IResource resource = element.getResource();
-		return new NullBuffer(resource instanceof IFile ? (IFile) resource
-				: null, owner, element.isReadOnly());
+		return new NullBuffer(resource instanceof IFile ? (IFile) resource : null, owner, element.isReadOnly());
 	}
 
 	/**
-	 * Returns the open buffer associated with the given owner, or
-	 * <code>null</code> if the owner does not have an open buffer associated
-	 * with it.
+	 * Returns the open buffer associated with the given owner, or <code>null</code>
+	 * if the owner does not have an open buffer associated with it.
 	 */
 	public IBuffer getBuffer(IOpenable owner) {
 		synchronized (this.openBuffers) {
@@ -82,9 +78,13 @@
 	/**
 	 * Returns the default buffer manager.
 	 */
-	public synchronized static BufferManager getDefaultBufferManager() {
+	public static BufferManager getDefaultBufferManager() {
 		if (DEFAULT_BUFFER_MANAGER == null) {
-			DEFAULT_BUFFER_MANAGER = new BufferManager();
+			synchronized (BufferManager.class) {
+				if (DEFAULT_BUFFER_MANAGER == null) {
+					DEFAULT_BUFFER_MANAGER = new BufferManager();
+				}
+			}
 		}
 		return DEFAULT_BUFFER_MANAGER;
 	}
@@ -93,7 +93,7 @@
 	 * Returns an enumeration of all open buffers.
 	 * <p>
 	 * The <code>Enumeration</code> answered is thread safe.
-	 * 
+	 *
 	 * @see OverflowingLRUCache
 	 * @return Enumeration of IBuffer
 	 */
@@ -113,8 +113,7 @@
 	 */
 	protected void removeBuffer(IBuffer buffer) {
 		if (VERBOSE) {
-			String owner = ((Openable) buffer.getOwner())
-					.toStringWithAncestors();
+			String owner = ((Openable) buffer.getOwner()).toStringWithAncestors();
 			System.out.println("Removing buffer for " + owner); //$NON-NLS-1$
 		}
 		synchronized (this.openBuffers) {
@@ -123,8 +122,8 @@
 		// close buffers that were removed from the cache (should be only one)
 		this.openBuffers.closeBuffers();
 		if (VERBOSE) {
-			System.out
-					.println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$
+			System.out.println("-> Buffer cache filling ratio = " //$NON-NLS-1$
+					+ NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$
 		}
 	}
 }
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ExternalFoldersManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ExternalFoldersManager.java
index 77165bb..b7116ca 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ExternalFoldersManager.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ExternalFoldersManager.java
@@ -98,9 +98,13 @@
 		}
 	}
 
-	public static synchronized ExternalFoldersManager getExternalFoldersManager() {
+	public static ExternalFoldersManager getExternalFoldersManager() {
 		if (MANAGER == null) {
-			MANAGER = new ExternalFoldersManager();
+			synchronized (ExternalFoldersManager.class) {
+				if (MANAGER == null) {
+					MANAGER = new ExternalFoldersManager();
+				}
+			}
 		}
 		return MANAGER;
 	}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelProviderManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelProviderManager.java
index 4ccf516..6ab61ee 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelProviderManager.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelProviderManager.java
@@ -4,7 +4,7 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
  * Contributors:
@@ -40,80 +40,79 @@
 
 	public synchronized static IModelProvider[] getProviders(String lang) {
 		if (providers == null) {
-			providers = new HashMap<>();
+			synchronized (ModelProviderManager.class) {
+				if (providers == null) {
 
-			final SimpleClassDLTKExtensionManager manager = new SimpleClassDLTKExtensionManager(
-					EXT_POINT) {
-				@Override
-				protected boolean isValidElement(
-						IConfigurationElement confElement) {
-					return "model".equals(confElement.getName());
-				}
-			};
-			ElementInfo[] infos = manager.getElementInfos();
-			Map<String, List<ElementInfo>> langToElementList = new HashMap<>();
-			// Fill element names and sort elements by language
-			for (int i = 0; i < infos.length; i++) {
-				String langauge = infos[i].getConfig().getAttribute(LANGUAGE);
-				if (langToElementList.containsKey(langauge)) {
-					List<ElementInfo> elements = langToElementList
-							.get(langauge);
-					elements.add(infos[i]);
-				} else {
-					List<ElementInfo> elements = new ArrayList<>();
-					elements.add(infos[i]);
-					langToElementList.put(langauge, elements);
-				}
-			}
-			for (Map.Entry<String, List<ElementInfo>> entry : langToElementList
-					.entrySet()) {
-				String language = entry.getKey();
-				List<ElementInfo> elements = entry.getValue();
+					providers = new HashMap<>();
 
-				Map<String, ElementInfo> names = new HashMap<>(); // Contains
-																						// map
-																						// for
-																						// all
-																						// ids
-				for (int i = 0; i < elements.size(); i++) {
-					ElementInfo info = elements.get(i);
-					String name = info.getConfig().getAttribute(ID);
-					names.put(name, info);
-				}
-				List<IModelProvider> result = new ArrayList<>(); // Final
-																				// IModelProvider
-																				// elements
-				Set<String> added = new HashSet<>(); // Contain names for
-															// added elements
-				// Process elements and keep dependencies
-				List<ElementInfo> toProcess = new ArrayList<>();
-				toProcess.addAll(elements);
-				while (!toProcess.isEmpty()) {
-					ElementInfo info = toProcess.remove(0);
-					String requires = info.getConfig().getAttribute(REQUIRES);
-					if (requires == null) {
-						result.add(
-								(IModelProvider) manager.getInitObject(info));
-					} else {
-						String req = requires.trim();
-						if (added.contains(req)) { // Dependency
-							// present
-							result.add((IModelProvider) info.object);
+					final SimpleClassDLTKExtensionManager manager = new SimpleClassDLTKExtensionManager(EXT_POINT) {
+						@Override
+						protected boolean isValidElement(IConfigurationElement confElement) {
+							return "model".equals(confElement.getName());
+						}
+					};
+					ElementInfo[] infos = manager.getElementInfos();
+					Map<String, List<ElementInfo>> langToElementList = new HashMap<>();
+					// Fill element names and sort elements by language
+					for (int i = 0; i < infos.length; i++) {
+						String langauge = infos[i].getConfig().getAttribute(LANGUAGE);
+						if (langToElementList.containsKey(langauge)) {
+							List<ElementInfo> elements = langToElementList.get(langauge);
+							elements.add(infos[i]);
 						} else {
-							if (names.containsKey(req)) { // Dependency exist
-								// Add element to end of process
-								toProcess.add(info);
-								added.add(info.getConfig().getAttribute(ID));
-							} else {
-								// Dependency doesn't exists so add to results
-								result.add((IModelProvider) info.object);
-								added.add(info.getConfig().getAttribute(ID));
-							}
+							List<ElementInfo> elements = new ArrayList<>();
+							elements.add(infos[i]);
+							langToElementList.put(langauge, elements);
 						}
 					}
+					for (Map.Entry<String, List<ElementInfo>> entry : langToElementList.entrySet()) {
+						String language = entry.getKey();
+						List<ElementInfo> elements = entry.getValue();
+
+						Map<String, ElementInfo> names = new HashMap<>(); // Contains
+																			// map
+																			// for
+																			// all
+																			// ids
+						for (int i = 0; i < elements.size(); i++) {
+							ElementInfo info = elements.get(i);
+							String name = info.getConfig().getAttribute(ID);
+							names.put(name, info);
+						}
+						List<IModelProvider> result = new ArrayList<>(); // Final
+																			// IModelProvider
+																			// elements
+						Set<String> added = new HashSet<>(); // Contain names for
+																// added elements
+						// Process elements and keep dependencies
+						List<ElementInfo> toProcess = new ArrayList<>();
+						toProcess.addAll(elements);
+						while (!toProcess.isEmpty()) {
+							ElementInfo info = toProcess.remove(0);
+							String requires = info.getConfig().getAttribute(REQUIRES);
+							if (requires == null) {
+								result.add((IModelProvider) manager.getInitObject(info));
+							} else {
+								String req = requires.trim();
+								if (added.contains(req)) { // Dependency
+									// present
+									result.add((IModelProvider) info.object);
+								} else {
+									if (names.containsKey(req)) { // Dependency exist
+										// Add element to end of process
+										toProcess.add(info);
+										added.add(info.getConfig().getAttribute(ID));
+									} else {
+										// Dependency doesn't exists so add to results
+										result.add((IModelProvider) info.object);
+										added.add(info.getConfig().getAttribute(ID));
+									}
+								}
+							}
+						}
+						providers.put(language, result.toArray(new IModelProvider[result.size()]));
+					}
 				}
-				providers.put(language,
-						result.toArray(new IModelProvider[result.size()]));
 			}
 		}
 		return providers.get(lang);
@@ -127,8 +126,7 @@
 		}
 	};
 
-	public static IProjectFragmentFactory[] getProjectFragmentFactories(
-			String natureId) {
+	public static IProjectFragmentFactory[] getProjectFragmentFactories(String natureId) {
 		return projectFragmentFactories.getInstances(natureId);
 	}
 
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java
index 3579f35..2559945 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java
@@ -4,7 +4,7 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
  * Contributors:
@@ -35,11 +35,9 @@
 import org.eclipse.dltk.utils.NatureExtensionManager;
 import org.eclipse.osgi.util.NLS;
 
-public class BuildParticipantManager
-		extends NatureExtensionManager<FactoryValue> {
+public class BuildParticipantManager extends NatureExtensionManager<FactoryValue> {
 
-	private static final String EXT_POINT = DLTKCore.PLUGIN_ID
-			+ ".buildParticipant"; //$NON-NLS-1$
+	private static final String EXT_POINT = DLTKCore.PLUGIN_ID + ".buildParticipant"; //$NON-NLS-1$
 
 	public static class FactoryValue<T> {
 		final T factory;
@@ -49,8 +47,7 @@
 		}
 	}
 
-	public static class BuildParticipantFactoryValue
-			extends FactoryValue<IBuildParticipantFactory> {
+	public static class BuildParticipantFactoryValue extends FactoryValue<IBuildParticipantFactory> {
 		final String id;
 		final String name;
 		public final Set<String> requirements = new HashSet<>();
@@ -58,8 +55,7 @@
 		/**
 		 * @param factory
 		 */
-		public BuildParticipantFactoryValue(IBuildParticipantFactory factory,
-				String id, String name) {
+		public BuildParticipantFactoryValue(IBuildParticipantFactory factory, String id, String name) {
 			super(factory);
 			this.id = id != null ? id : factory.getClass().getName();
 			this.name = name;
@@ -67,8 +63,7 @@
 
 	}
 
-	public static class FilterFactoryValue
-			extends FactoryValue<IBuildParticipantFilterFactory> {
+	public static class FilterFactoryValue extends FactoryValue<IBuildParticipantFilterFactory> {
 
 		public FilterFactoryValue(IBuildParticipantFilterFactory factory) {
 			super(factory);
@@ -90,25 +85,18 @@
 	private static final String ATTR_NAME = "name"; //$NON-NLS-1$
 
 	@Override
-	protected Object createInstanceByDescriptor(Object input)
-			throws CoreException {
+	protected Object createInstanceByDescriptor(Object input) throws CoreException {
 		final IConfigurationElement element = (IConfigurationElement) input;
 		if (PARTICIPANT.equals(element.getName())) {
 			final Object factory = element.createExecutableExtension(classAttr);
 			if (!(factory instanceof IBuildParticipantFactory)) {
-				DLTKCore.warn(NLS.bind(
-						"{0} contributed by {1} must implement {2}",
-						new Object[] { element.getName(),
-								element.getContributor(),
-								IBuildParticipantFactory.class.getName() }));
+				DLTKCore.warn(NLS.bind("{0} contributed by {1} must implement {2}", new Object[] { element.getName(),
+						element.getContributor(), IBuildParticipantFactory.class.getName() }));
 				return null;
 			}
 			final BuildParticipantFactoryValue factoryValue = new BuildParticipantFactoryValue(
-					(IBuildParticipantFactory) factory,
-					element.getAttribute(ATTR_ID),
-					element.getAttribute(ATTR_NAME));
-			final IConfigurationElement[] requires = element
-					.getChildren(REQUIRES);
+					(IBuildParticipantFactory) factory, element.getAttribute(ATTR_ID), element.getAttribute(ATTR_NAME));
+			final IConfigurationElement[] requires = element.getChildren(REQUIRES);
 			for (int i = 0; i < requires.length; ++i) {
 				final String id = requires[i].getAttribute(REQUIRES_ID);
 				if (id != null) {
@@ -119,30 +107,27 @@
 		} else if (FILTER.equals(element.getName())) {
 			final Object factory = element.createExecutableExtension(classAttr);
 			if (!(factory instanceof IBuildParticipantFilterFactory)) {
-				DLTKCore.warn(
-						NLS.bind("{0} contributed by {1} must implement {2}",
-								new Object[] { element.getName(),
-										element.getContributor(),
-										IBuildParticipantFilterFactory.class
-												.getName() }));
+				DLTKCore.warn(NLS.bind("{0} contributed by {1} must implement {2}", new Object[] { element.getName(),
+						element.getContributor(), IBuildParticipantFilterFactory.class.getName() }));
 				return null;
 			}
-			return new FilterFactoryValue(
-					(IBuildParticipantFilterFactory) factory);
+			return new FilterFactoryValue((IBuildParticipantFilterFactory) factory);
 		} else {
-			DLTKCore.warn(NLS.bind(
-					"Wrong element {0} in {1} extension point contributed by {2}",
-					new Object[] { element.getName(), extensionPoint,
-							element.getContributor() }));
+			DLTKCore.warn(NLS.bind("Wrong element {0} in {1} extension point contributed by {2}",
+					new Object[] { element.getName(), extensionPoint, element.getContributor() }));
 			return null;
 		}
 	}
 
 	private static BuildParticipantManager instance = null;
 
-	private static synchronized BuildParticipantManager getInstance() {
+	private static BuildParticipantManager getInstance() {
 		if (instance == null) {
-			instance = new BuildParticipantManager();
+			synchronized (BuildParticipantManager.class) {
+				if (instance == null) {
+					instance = new BuildParticipantManager();
+				}
+			}
 		}
 		return instance;
 	}
@@ -165,25 +150,22 @@
 	}
 
 	/**
-	 * Returns {@link IBuildParticipant} instances of the specified nature. If
-	 * there are no build participants then the empty array is returned.
+	 * Returns {@link IBuildParticipant} instances of the specified nature. If there
+	 * are no build participants then the empty array is returned.
 	 *
 	 * @param project
 	 * @param natureId
 	 * @return
 	 */
-	public static BuildParticipantResult getBuildParticipants(
-			IScriptProject project, String natureId) {
-		final FactoryValue<?>[] factories = getInstance()
-				.getInstances(natureId);
+	public static BuildParticipantResult getBuildParticipants(IScriptProject project, String natureId) {
+		final FactoryValue<?>[] factories = getInstance().getInstances(natureId);
 		if (factories == null || factories.length == 0) {
 			return new BuildParticipantResult(NO_PARTICIPANTS, null);
 		}
 		return createParticipants(project, factories);
 	}
 
-	public static BuildParticipantResult createParticipants(
-			IScriptProject project, FactoryValue<?>[] factories) {
+	public static BuildParticipantResult createParticipants(IScriptProject project, FactoryValue<?>[] factories) {
 		final IBuildParticipant[] result = new IBuildParticipant[factories.length];
 		final Set<String> processed = new HashSet<>();
 		final Map<String, IBuildParticipant> created = new HashMap<>();
@@ -195,25 +177,20 @@
 					continue;
 				}
 				final BuildParticipantFactoryValue factory = (BuildParticipantFactoryValue) factories[i];
-				if (!processed.contains(factory.id)
-						&& created.keySet().containsAll(factory.requirements)) {
+				if (!processed.contains(factory.id) && created.keySet().containsAll(factory.requirements)) {
 					processed.add(factory.id);
 					try {
-						final IBuildParticipant participant = factory.factory
-								.createBuildParticipant(project);
+						final IBuildParticipant participant = factory.factory.createBuildParticipant(project);
 						if (participant != null) {
 							result[created.size()] = participant;
 							created.put(factory.id, participant);
 							if (!factory.requirements.isEmpty()) {
 								for (String req : factory.requirements) {
-									final IBuildParticipant reqParticipant = created
-											.get(req);
-									List<IBuildParticipant> depList = dependencies
-											.get(reqParticipant);
+									final IBuildParticipant reqParticipant = created.get(req);
+									List<IBuildParticipant> depList = dependencies.get(reqParticipant);
 									if (depList == null) {
 										depList = new ArrayList<>();
-										dependencies.put(reqParticipant,
-												depList);
+										dependencies.put(reqParticipant, depList);
 									}
 									depList.add(participant);
 								}
@@ -233,8 +210,7 @@
 			if (created.size() == 0) {
 				return new BuildParticipantResult(NO_PARTICIPANTS, null);
 			}
-			final IBuildParticipant[] newResult = new IBuildParticipant[created
-					.size()];
+			final IBuildParticipant[] newResult = new IBuildParticipant[created.size()];
 			System.arraycopy(result, 0, newResult, 0, created.size());
 			return new BuildParticipantResult(newResult, dependencies);
 		} else {
@@ -242,18 +218,15 @@
 		}
 	}
 
-	public static IBuildParticipantFilter[] getFilters(IScriptProject project,
-			String natureId, Object context) {
-		final FactoryValue<?>[] factories = getInstance()
-				.getInstances(natureId);
+	public static IBuildParticipantFilter[] getFilters(IScriptProject project, String natureId, Object context) {
+		final FactoryValue<?>[] factories = getInstance().getInstances(natureId);
 		if (factories == null || factories.length == 0) {
 			return NO_PREDICATES;
 		}
 		return createFilters(project, factories, context);
 	}
 
-	public static IBuildParticipantFilter[] createFilters(
-			IScriptProject project, FactoryValue<?>[] factories,
+	public static IBuildParticipantFilter[] createFilters(IScriptProject project, FactoryValue<?>[] factories,
 			Object context) {
 		final IBuildParticipantFilter[] result = new IBuildParticipantFilter[factories.length];
 		int created = 0;
@@ -263,15 +236,13 @@
 			}
 			final FilterFactoryValue factory = (FilterFactoryValue) factories[i];
 			try {
-				final IBuildParticipantFilter filter = factory.factory
-						.createPredicate(project, context);
+				final IBuildParticipantFilter filter = factory.factory.createPredicate(project, context);
 				if (filter != null) {
 					result[created++] = filter;
 				}
 			} catch (CoreException e) {
 				final String tpl = Messages.BuildParticipantManager_buildParticipantCreateError;
-				DLTKCore.warn(
-						NLS.bind(tpl, factory.factory.getClass().getName()), e);
+				DLTKCore.warn(NLS.bind(tpl, factory.factory.getClass().getName()), e);
 			}
 		}
 		if (created != result.length) {
@@ -286,8 +257,7 @@
 		}
 	}
 
-	public static IBuildParticipant[] copyFirst(IBuildParticipant[] array,
-			int length) {
+	public static IBuildParticipant[] copyFirst(IBuildParticipant[] array, int length) {
 		if (length == array.length) {
 			return array;
 		}
@@ -301,9 +271,8 @@
 	}
 
 	/**
-	 * First removes dangling {@link IBuildParticipant}s from
-	 * {@link #dependencies} then notifies participants about their
-	 * dependencies.
+	 * First removes dangling {@link IBuildParticipant}s from {@link #dependencies}
+	 * then notifies participants about their dependencies.
 	 *
 	 * @param dependencies
 	 * @param participants
@@ -315,10 +284,9 @@
 		}
 		final List<IBuildParticipant> list = Arrays.asList(participants);
 		dependencies.keySet().retainAll(list);
-		for (Iterator<Map.Entry<IBuildParticipant, List<IBuildParticipant>>> i = dependencies
-				.entrySet().iterator(); i.hasNext();) {
-			final Entry<IBuildParticipant, List<IBuildParticipant>> entry = i
-					.next();
+		for (Iterator<Map.Entry<IBuildParticipant, List<IBuildParticipant>>> i = dependencies.entrySet().iterator(); i
+				.hasNext();) {
+			final Entry<IBuildParticipant, List<IBuildParticipant>> entry = i.next();
 			entry.getValue().retainAll(list);
 			if (entry.getValue().isEmpty()) {
 				i.remove();
@@ -327,13 +295,11 @@
 		if (dependencies.isEmpty()) {
 			return;
 		}
-		for (Map.Entry<IBuildParticipant, List<IBuildParticipant>> entry : dependencies
-				.entrySet()) {
+		for (Map.Entry<IBuildParticipant, List<IBuildParticipant>> entry : dependencies.entrySet()) {
 			if (entry.getKey() instanceof IBuildParticipantExtension4) {
 				final List<IBuildParticipant> dependents = entry.getValue();
 				((IBuildParticipantExtension4) entry.getKey())
-						.notifyDependents(dependents.toArray(
-								new IBuildParticipant[dependents.size()]));
+						.notifyDependents(dependents.toArray(new IBuildParticipant[dependents.size()]));
 			}
 		}
 	}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ScriptBuilderManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ScriptBuilderManager.java
index dcd1c37..0b723d4 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ScriptBuilderManager.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ScriptBuilderManager.java
@@ -3,7 +3,7 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
  *******************************************************************************/
@@ -24,28 +24,29 @@
 import org.eclipse.dltk.core.builder.IScriptBuilder;
 import org.eclipse.dltk.utils.NatureExtensionManager;
 
-public class ScriptBuilderManager
-		extends NatureExtensionManager<IScriptBuilder> {
+public class ScriptBuilderManager extends NatureExtensionManager<IScriptBuilder> {
 
 	private ScriptBuilderManager() {
 		super(LANGUAGE_EXTPOINT, IScriptBuilder.class, "#"); //$NON-NLS-1$
 	}
 
-	private final static String LANGUAGE_EXTPOINT = DLTKCore.PLUGIN_ID
-			+ ".builder"; //$NON-NLS-1$
+	private final static String LANGUAGE_EXTPOINT = DLTKCore.PLUGIN_ID + ".builder"; //$NON-NLS-1$
 
 	private static ScriptBuilderManager manager = null;
 
-	private synchronized static ScriptBuilderManager getManager() {
+	private static ScriptBuilderManager getManager() {
 		if (manager == null) {
-			manager = new ScriptBuilderManager();
+			synchronized (ScriptBuilderManager.class) {
+				if (manager == null) {
+					manager = new ScriptBuilderManager();
+				}
+			}
 		}
 		return manager;
 	}
 
 	@Override
-	protected void registerConfigurationElements(
-			IConfigurationElement[] elements, String categoryAttr) {
+	protected void registerConfigurationElements(IConfigurationElement[] elements, String categoryAttr) {
 		super.registerConfigurationElements(elements, categoryAttr);
 		for (IConfigurationElement element : elements) {
 			if ("disable".equals(element.getName())) { //$NON-NLS-1$
@@ -96,8 +97,7 @@
 	}
 
 	@Override
-	protected IScriptBuilder[] filter(IScriptBuilder[] objects,
-			String natureId) {
+	protected IScriptBuilder[] filter(IScriptBuilder[] objects, String natureId) {
 		if (objects != null) {
 			final List<String> disable = disabled.get(natureId);
 			if (disable != null) {
@@ -120,17 +120,14 @@
 	protected final Map<Object, Integer> priorities = new IdentityHashMap<>();
 
 	@Override
-	protected Object createInstanceByDescriptor(Object descriptor)
-			throws CoreException {
+	protected Object createInstanceByDescriptor(Object descriptor) throws CoreException {
 		final Object instance = super.createInstanceByDescriptor(descriptor);
-		priorities.put(instance,
-				priorityOf((IConfigurationElement) descriptor));
+		priorities.put(instance, priorityOf((IConfigurationElement) descriptor));
 		return instance;
 	}
 
 	@Override
-	protected IScriptBuilder[] merge(IScriptBuilder[] all,
-			IScriptBuilder[] nature) {
+	protected IScriptBuilder[] merge(IScriptBuilder[] all, IScriptBuilder[] nature) {
 		final IScriptBuilder[] result = super.merge(all, nature);
 		Arrays.sort(result, new Comparator<IScriptBuilder>() {
 			int priority(IScriptBuilder builder) {
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchyBuilders.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchyBuilders.java
index 5d5590a..73f38b4 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchyBuilders.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchyBuilders.java
@@ -4,7 +4,7 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
+ *
  * SPDX-License-Identifier: EPL-2.0
  *
  * Contributors:
@@ -21,34 +21,32 @@
 import org.eclipse.dltk.core.ITypeHierarchyBuilder;
 import org.eclipse.dltk.utils.NatureExtensionManager;
 
-public class TypeHierarchyBuilders extends
-		NatureExtensionManager<ITypeHierarchyBuilder> {
+public class TypeHierarchyBuilders extends NatureExtensionManager<ITypeHierarchyBuilder> {
 
 	private static TypeHierarchyBuilders INSTANCE = null;
 
-	private static synchronized TypeHierarchyBuilders get() {
+	private static TypeHierarchyBuilders get() {
 		if (INSTANCE == null) {
-			INSTANCE = new TypeHierarchyBuilders();
+			synchronized (TypeHierarchyBuilders.class) {
+				if (INSTANCE == null) {
+					INSTANCE = new TypeHierarchyBuilders();
+				}
+			}
 		}
 		return INSTANCE;
 	}
 
 	public TypeHierarchyBuilders() {
-		super(DLTKCore.PLUGIN_ID + ".typeHierarchy",
-				ITypeHierarchyBuilder.class);
+		super(DLTKCore.PLUGIN_ID + ".typeHierarchy", ITypeHierarchyBuilder.class);
 	}
 
-	public static ITypeHierarchy getTypeHierarchy(IType type,
-			ITypeHierarchy.Mode mode, IProgressMonitor monitor) {
-		final IDLTKLanguageToolkit toolkit = DLTKLanguageManager
-				.getLanguageToolkit(type);
+	public static ITypeHierarchy getTypeHierarchy(IType type, ITypeHierarchy.Mode mode, IProgressMonitor monitor) {
+		final IDLTKLanguageToolkit toolkit = DLTKLanguageManager.getLanguageToolkit(type);
 		if (toolkit != null) {
-			final ITypeHierarchyBuilder[] builders = get().getInstances(
-					toolkit.getNatureId());
+			final ITypeHierarchyBuilder[] builders = get().getInstances(toolkit.getNatureId());
 			if (builders != null) {
 				for (ITypeHierarchyBuilder builder : builders) {
-					final ITypeHierarchy hierarchy = builder.build(type, mode,
-							monitor);
+					final ITypeHierarchy hierarchy = builder.build(type, mode, monitor);
 					if (hierarchy != null) {
 						return hierarchy;
 					}
diff --git a/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/ExecutionContexts.java b/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/ExecutionContexts.java
index 2841f71..ab72645 100644
--- a/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/ExecutionContexts.java
+++ b/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/ExecutionContexts.java
@@ -4,8 +4,8 @@
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0 which is available at
  * http://www.eclipse.org/legal/epl-2.0.
- * 
- * SPDX-License-Identifier: EPL-2.0  
+ *
+ * SPDX-License-Identifier: EPL-2.0
  *
  * Contributors:
  *     xored software, Inc. - initial API and Implementation (Alex Panchenko)
@@ -32,7 +32,7 @@
 
 	};
 
-	public static synchronized IExecutionContextManager getManager() {
+	public static IExecutionContextManager getManager() {
 		if (fManager != null) {
 			return fManager;
 		} else {
@@ -40,8 +40,10 @@
 		}
 	}
 
-	public static synchronized void setManager(IExecutionContextManager manager) {
-		fManager = manager;
+	public static void setManager(IExecutionContextManager manager) {
+		synchronized (fDefaultManager) {
+			fManager = manager;
+		}
 	}
 
 }