blob: 2a9af66319bd50cba6905db81dbe25edececc4cf [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2007 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
*
*******************************************************************************/
package org.eclipse.dltk.ruby.internal.ui.text.completion;
import org.eclipse.dltk.core.CompletionProposal;
import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.ruby.core.RubyNature;
import org.eclipse.dltk.ui.text.completion.IScriptCompletionProposal;
import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposal;
import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalCollector;
import org.eclipse.swt.graphics.Image;
public class RubyCompletionProposalCollector extends
ScriptCompletionProposalCollector {
protected final static char[] VAR_TRIGGER = new char[] { '\t', ' ', '=',
';', '.' };
protected char[] getVarTrigger() {
return VAR_TRIGGER;
}
public RubyCompletionProposalCollector(ISourceModule module) {
super(module);
}
// Specific proposals creation. May be use factory?
protected ScriptCompletionProposal createScriptCompletionProposal(
String completion, int replaceStart, int length, Image image,
String displayString, int i) {
return new RubyCompletionProposal(completion, replaceStart, length,
image, displayString, i);
}
protected ScriptCompletionProposal createScriptCompletionProposal(
String completion, int replaceStart, int length, Image image,
String displayString, int i, boolean isInDoc) {
return new RubyCompletionProposal(completion, replaceStart, length,
image, displayString, i, isInDoc);
}
protected ScriptCompletionProposal createOverrideCompletionProposal(
IScriptProject scriptProject, ISourceModule compilationUnit,
String name, String[] paramTypes, int start, int length,
String displayName, String completionProposal) {
return new RubyOverrideCompletionProposal(scriptProject,
compilationUnit, name, paramTypes, start, length, displayName,
completionProposal);
}
protected IScriptCompletionProposal createKeywordProposal(
CompletionProposal proposal) {
String completion = String.valueOf(proposal.getCompletion());
int start = proposal.getReplaceStart();
int length = getLength(proposal);
String label = getLabelProvider().createSimpleLabel(proposal);
Image img = getImage(getLabelProvider().createImageDescriptor(proposal));
int relevance = computeRelevance(proposal);
return createScriptCompletionProposal(completion, start, length, img,
label, relevance);
}
@Override
protected String getNatureId() {
return RubyNature.NATURE_ID;
}
}