Commit 59187945 authored by Zoltan Ujhelyi's avatar Zoltan Ujhelyi
Browse files

Trivial cleanup of MapModelIndex



This change removes the unused 'index' map from the code, and simplifies
the implementation of the 'addProxyUri' and 'removeProxyUri' methods.
The changes should not cause any visible effect for users of Sphinx, but
should make the codebase more maintainable.

Change-Id: Ie9a4eb9ea867a76739da2d335b9f98701abf644c
Signed-off-by: default avatarBalazs Varnai <balazs_varnai@mentor.com>
Signed-off-by: default avatarZoltan Ujhelyi <zoltan.ujhelyi@incquerylabs.com>
parent 0b880afc
Loading
Loading
Loading
Loading
+2 −22
Original line number Diff line number Diff line
@@ -18,9 +18,7 @@ package org.eclipse.sphinx.emf.internal.ecore.proxymanagement.blacklist;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -47,12 +45,10 @@ import org.eclipse.sphinx.platform.util.PlatformLogUtil;
// FIXME aakar: make access to index thread safe
public class MapModelIndex implements IResourceChangeListener {

	private Map<String, Object> index;
	private Set<URI> proxyURIs;
	private MapResourceDeltaVisitor resourceDeltaVisitor;

	public MapModelIndex() {
		index = new WeakHashMap<String, Object>();
		proxyURIs = new HashSet<URI>();
		resourceDeltaVisitor = new MapResourceDeltaVisitor();
		startListening();
@@ -79,13 +75,11 @@ public class MapModelIndex implements IResourceChangeListener {
	}

	public void clearAll() {
		index.clear();
		proxyURIs.clear();
	}

	public void dispose() {
		stopListening();
		index.clear();
		proxyURIs.clear();
	}

@@ -101,28 +95,14 @@ public class MapModelIndex implements IResourceChangeListener {
	 * @return true if the proxy URIs set did not already contain the specified element.
	 */
	public boolean addProxyURI(URI proxyURI) {
		if (proxyURIs.add(proxyURI)) {
			// System.out.println("Added Proxy: " + proxyURIs.size() + " " + proxyURI); //$NON-NLS-1$ //$NON-NLS-2$
			return true;
		} else {
			// System.out.println("Trying to add existing proxy: " + proxyURIs.size() + " " + proxyURI);
			// //$NON-NLS-1$//$NON-NLS-2$
			return false;
		}
		return proxyURIs.add(proxyURI);
	}

	/**
	 * @return true if the proxy URIs set contained the specified element.
	 */
	public boolean removeProxyURI(URI proxyURI) {
		if (proxyURIs.remove(proxyURI)) {
			// System.out.println("Removed Proxy: " + proxyURIs.size() + " " + proxyURI); //$NON-NLS-1$ //$NON-NLS-2$
			return true;
		} else {
			// System.out.println("Trying to remove proxy: " + proxyURIs.size() + " " + proxyURI); //$NON-NLS-1$
			// //$NON-NLS-2$
			return false;
		}
		return proxyURIs.remove(proxyURI);
	}

	/**