本文整理汇总了Java中org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal.setSelectionLength方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableCompletionProposal.setSelectionLength方法的具体用法?Java ConfigurableCompletionProposal.setSelectionLength怎么用?Java ConfigurableCompletionProposal.setSelectionLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal
的用法示例。
在下文中一共展示了ConfigurableCompletionProposal.setSelectionLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStringProposal
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入方法依赖的package包/类
private void createStringProposal(ContentAssistContext context, ICompletionProposalAcceptor acceptor,
String feature, RuleCall ruleCall) {
String proposalText = feature != null ? feature : Strings.toFirstUpper(ruleCall.getRule().getName().toLowerCase());
proposalText = getValueConverter().toString(proposalText, ruleCall.getRule().getName());
String displayText = proposalText;
if (feature != null)
displayText = displayText + " - " + ruleCall.getRule().getName();
ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context);
if (proposal instanceof ConfigurableCompletionProposal) {
ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
configurable.setSelectionStart(configurable.getReplacementOffset() + 1);
configurable.setSelectionLength(proposalText.length() - 2);
configurable.setAutoInsertable(false);
configurable.setSimpleLinkedMode(context.getViewer(), proposalText.charAt(0), '\t');
}
acceptor.accept(proposal);
}
示例2: createIntProposal
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入方法依赖的package包/类
private void createIntProposal(ContentAssistContext context, ICompletionProposalAcceptor acceptor,
RuleCall ruleCall, String feature, int i) {
String proposalText = getValueConverter().toString(i, ruleCall.getRule().getName());
String displayText = proposalText + " - " + ruleCall.getRule().getName();
if (feature != null)
displayText = proposalText + " - " + feature;
ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context);
if (proposal instanceof ConfigurableCompletionProposal) {
ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
configurable.setSelectionStart(configurable.getReplacementOffset());
configurable.setSelectionLength(proposalText.length());
configurable.setAutoInsertable(false);
configurable.setSimpleLinkedMode(context.getViewer(), '\t', ' ');
}
acceptor.accept(proposal);
}
示例3: complete_HEX
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入方法依赖的package包/类
@Override
public void complete_HEX(EObject model, RuleCall ruleCall, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
ICompletionProposalAcceptor priorityOptimizer = getCustomAcceptor(model, "integer", acceptor);
String proposalText = "0x1";
ICompletionProposal proposal = createCompletionProposal(proposalText,
proposalText + " - " + ruleCall.getRule().getName(), null, context);
if (proposal instanceof ConfigurableCompletionProposal) {
ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
configurable.setSelectionStart(configurable.getReplacementOffset() + 2);
configurable.setSelectionLength(proposalText.length() - 2);
configurable.setAutoInsertable(false);
configurable.setSimpleLinkedMode(context.getViewer(), '\t', ' ');
}
priorityOptimizer.accept(proposal);
}
示例4: complete_ID
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入方法依赖的package包/类
public void complete_ID(EObject model, RuleCall ruleCall, final ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
if (doCreateIdProposals()) {
PrefixMatcher newMatcher = new PrefixMatcher() {
@Override
public boolean isCandidateMatchingPrefix(String name, String prefix) {
String strippedName = name;
if (name.startsWith("^") && !prefix.startsWith("^")) {
strippedName = name.substring(1);
}
return context.getMatcher().isCandidateMatchingPrefix(strippedName, prefix);
}
};
ContentAssistContext myContext = context.copy().setMatcher(newMatcher).toContext();
String feature = getAssignedFeature(ruleCall);
String proposalText = feature != null ? feature : Strings.toFirstUpper(ruleCall.getRule().getName().toLowerCase());
String displayText = proposalText;
if (feature != null)
displayText = proposalText + " - " + ruleCall.getRule().getName();
proposalText = getValueConverter().toString(proposalText, ruleCall.getRule().getName());
ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, myContext);
if (proposal instanceof ConfigurableCompletionProposal) {
ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
configurable.setSelectionStart(configurable.getReplacementOffset());
configurable.setSelectionLength(proposalText.length());
configurable.setAutoInsertable(false);
configurable.setSimpleLinkedMode(myContext.getViewer(), '\t', ' ');
}
acceptor.accept(proposal);
}
}
示例5: complete_NAME
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入方法依赖的package包/类
public void complete_NAME(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
String ctx = context.getLastCompleteNode().getText();
String name = null;
if (ctx.equals( "alias") || ctx.equals( "as")) {
if (model instanceof ModelName) {
name = ((ModelName)model).getBaseUri();
}
else if (model instanceof Import) {
name = ((Import)model).getImportURI();
}
if (name != null) {
int ls = name.lastIndexOf("/");
if (ls > 0) {
name = name.substring(ls + 1);
}
}
}
else {
name = "NewName ";
}
Image image = getImage(model);
ICompletionProposal proposal = createCompletionProposal(name, name + " - NAME", image, context);
if (proposal instanceof ConfigurableCompletionProposal) {
ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
configurable.setSelectionStart(configurable.getReplacementOffset());
configurable.setSelectionLength(name.length());
configurable.setAutoInsertable(false);
configurable.setSimpleLinkedMode(context.getViewer(), name.charAt(0), '\t');
}
acceptor.accept(proposal);
}