Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f976847ce0ee639c474d3840b28be90c642e8a18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*******************************************************************************
 * Copyright (c) 2009, 2013 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.core;

import java.util.Comparator;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.RefreshUtil;

/**
 * Compares refresh scope attributes as the format has changed from a working
 * set memento to an XML memento of resource paths. Avoids migrating attribute
 * to new format until something else in the configuration changes.
 *
 * @since 3.6
 */
public class RefreshScopeComparator implements Comparator<String> {

	@Override
	public int compare(String o1, String o2) {
		String m1 = o1;
		String m2 = o2;
		try {
			IResource[] r1 = RefreshUtil.toResources(m1);
			IResource[] r2 = RefreshUtil.toResources(m2);
			if (r1.length == r2.length) {
				for (int i = 0; i < r2.length; i++) {
					if (!r1[i].equals(r2[i])) {
						return -1;
					}
				}
				return 0;
			}
		} catch (CoreException e) {
			return -1;
		}
		return -1;
	}

}

Back to the top