Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 Contributors: Lazar Kirchev, SAP AG - initial API and implementation /
package org.eclipse.equinox.console.completion;
This class provides completion for arbitrary strings
public class StringsCompleter implements Completer {
	private Set<Stringstrings;
	private boolean isCaseSensitive;
	public StringsCompleter(Set<Stringstringsboolean isCaseSensitive) {
		this. = strings;
		this. = isCaseSensitive;
	public Map<StringIntegergetCandidates(String bufferint cursor) {
		String currentToken = CommandLineParser.getCurrentToken(buffercursor);
		if (currentToken == null) {
			return new HashMap<StringInteger>();
			currentToken = currentToken.toLowerCase();
		int startIndex = cursor - currentToken.length();
		// if currentToken is empty string, then there is nothing to complete
		// the only exception is if the previous character is $, which signifies
		// that a variable name is expected; in this case all strings will be 
		// returned as candidates
		if(currentToken.equals("") && buffer.charAt(startIndex - 1) != '$') {
			return new HashMap<StringInteger>();
		Map<StringIntegerresult = new HashMap<StringInteger>();
		for(String candidate : ) {
				if (candidate.startsWith(currentToken)) {
else {
				if (candidate.toLowerCase().startsWith(currentToken)) {
		return result;
New to GrepCode? Check out our FAQ X