Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e72277de0a0f9a949fb1848f342f9fa4aeda7985 (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
/*******************************************************************************
 * Copyright (c) 2011 SAP AG
 * 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:
 *     Lazar Kirchev, SAP AG - initial API and implementation
 *******************************************************************************/

package org.eclipse.equinox.console.completion;

import java.util.Map;
import java.util.Set;

import org.apache.felix.service.command.CommandSession;
import org.eclipse.equinox.console.completion.common.Completer;

/**
 * This class provides completion for gogo session variables. 
 *
 */
public class VariableNamesCompleter implements Completer {

	private CommandSession session; 
	
	public VariableNamesCompleter(CommandSession session) {
		this.session = session;
	}
	
	public Map<String, Integer> getCandidates(String buffer, int cursor) {
		// CommandSession.get(null) returns the names of all registered varialbes
		@SuppressWarnings("unchecked")
		Set<String> variableNames = (Set<String>) session.get(null);
		StringsCompleter completer = new StringsCompleter(variableNames, false);
		return completer.getCandidates(buffer, cursor);
	}

}

Back to the top