Bug 305161 Dynamic Path Variable ui.ide API review
Dynamic Path Variable ui.ide API review
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ImportTypeDialog.java
String mostAppropriateToParent = null;
		int mostAppropriateCount = Integer.MAX_VALUE;
		int mostAppropriateCountToParent = Integer.MAX_VALUE;
		IPathVariableManager pathVariableManager = target.getPathVariableManager();
		String [] variables = pathVariableManager.getPathVariableNames();
		
		for (int i = 0; i < variables.length; i++) {
			if (isPreferred(variables[i])) {
				URI rawValue = pathVariableManager.getURIValue(variables[i]);
				URI value = pathVariableManager.resolveURI(rawValue);
				if (value != null) {
					IPath path = URIUtil.toPath(value);
					if (path != null) {
						int difference = path.matchingFirstSegments(commonRoot);
						if (difference > 0) {
							if (difference < mostAppropriateCount) {
								mostAppropriateCount = difference;
								mostAppropriate = variables[i];
							}
						}
						else {
							
							difference = commonRoot.matchingFirstSegments(path);
							if (difference > 0) {
								if (difference < mostAppropriateCountToParent) {
									mostAppropriateCountToParent = difference;
									mostAppropriateToParent = variables[i];
								}
							}
						}