本文整理汇总了Java中org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableCompletionProposal类的具体用法?Java ConfigurableCompletionProposal怎么用?Java ConfigurableCompletionProposal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurableCompletionProposal类属于org.eclipse.xtext.ui.editor.contentassist包,在下文中一共展示了ConfigurableCompletionProposal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActualReplacementString
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
/**
* Return the to-be-inserted string if an existing import is present.
*/
@Override
public String getActualReplacementString(ConfigurableCompletionProposal proposal) {
String syntacticReplacementString = proposal.getReplacementString();
if (scope != null) {
final QualifiedName qualifiedName = applyValueConverter(syntacticReplacementString);
if (qualifiedName.getSegmentCount() == 1) {
return syntacticReplacementString;
}
final IEObjectDescription element = scope.getSingleElement(qualifiedName);
if (element != null) {
EObject resolved = EcoreUtil.resolve(element.getEObjectOrProxy(), context);
if (!resolved.eIsProxy()) {
IEObjectDescription description = findApplicableDescription(resolved, qualifiedName, true);
if (description != null) {
String multisegmentProposal = applyValueConverter(description.getName());
return multisegmentProposal;
}
}
}
}
return syntacticReplacementString;
}
示例2: getProposal
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
/**
* Creates initial proposal adjusted for the N4JS imports. Then passes that proposal to the provided delegate
* proposal factory. Obtained ICompletionProposal is configured with a FQNImporter as custom text. applier.
*
* @param candidate
* for which proposal is created
* @param delegateProposalFactory
* delegate proposal factory
* @return code completion proposal
*/
private ICompletionProposal getProposal(IEObjectDescription candidate, EObject model,
IScope scope,
EReference reference,
ContentAssistContext context,
Predicate<IEObjectDescription> filter,
Function<IEObjectDescription, ICompletionProposal> delegateProposalFactory) {
final IEObjectDescription inputToUse = getAliasedDescription(candidate, reference, context);
final ICompletionProposal result = delegateProposalFactory.apply(inputToUse);
if (result instanceof ConfigurableCompletionProposal) {
final FQNImporter importer = fqnImporterFactory.create(
model.eResource(),
scope,
valueConverter,
filter,
context.getViewer());
((ConfigurableCompletionProposal) result).setTextApplier(importer);
}
return result;
}
示例3: adjustPriority
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
@Override
protected void adjustPriority(ICompletionProposal proposal, String prefix, int priority) {
if (proposal == null || !(proposal instanceof ConfigurableCompletionProposal))
return;
ConfigurableCompletionProposal castedProposal = (ConfigurableCompletionProposal) proposal;
if (castedProposal.getPriority() != getDefaultPriority())
return;
int adjustedPriority = priority;
if (!Strings.isEmpty(prefix)) {
if (castedProposal.getReplacementString().equals(prefix))
adjustedPriority = (int) (adjustedPriority * sameTextMultiplier);
else if (castedProposal.getReplacementString().startsWith(prefix))
adjustedPriority = adjustedPriority * proposalWithPrefixMultiplier;
}
castedProposal.setPriority(adjustedPriority);
}
示例4: applyText
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
/**
* Applies a content assist proposal using the expected display string.
*
* @param expectedDisplayString
* the content assist proposal to apply
* @param appendSpace
* whether to append a space
* @return a new {@link AcfContentAssistProcessorTestBuilder} with the text applied.
* @throws Exception
* if there was a problem loading the xtext resource
*/
public AcfContentAssistProcessorTestBuilder applyText(final String expectedDisplayString, final boolean appendSpace) throws Exception {
ICompletionProposal proposal = null;
for (final ICompletionProposal p : computeCompletionProposals(getModel(), getCursorPosition())) {
if (expectedDisplayString.equals(p.getDisplayString())) {
proposal = p;
break;
}
}
assertNotNull(MessageFormat.format("\"{0}\" not a valid completion proposal", expectedDisplayString), proposal);
String text = "";
if (proposal instanceof ConfigurableCompletionProposal) {
text = ((ConfigurableCompletionProposal) proposal).getReplacementString();
} else if (proposal instanceof XtextTemplateProposal) {
// These may occur in the context of custom content assist templates
text = ((XtextTemplateProposal) proposal).getAdditionalProposalInfo();
}
AcfContentAssistProcessorTestBuilder ret = append(text);
if (appendSpace) {
return ret.append(" ");
}
return ret;
}
示例5: 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);
}
示例6: 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);
}
示例7: completeGeneratorModel_GeneratorId
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
@Override
public void completeGeneratorModel_GeneratorId(EObject model,
Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
Iterable<IGeneratorDescriptor> descriptions = GeneratorExtensions
.getGeneratorDescriptors();
for (IGeneratorDescriptor desc : descriptions) {
ICompletionProposal proposal = createCompletionProposal(
desc.getId(),
new StyledString((desc.getName() != null) ? desc.getName()
: "null"), PathToImageResolver.toImage(desc.getImagePath()), context);
if (proposal instanceof ConfigurableCompletionProposal) {
ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
configurable.setAdditionalProposalInfo(desc.getDescription());
}
acceptor.accept(proposal);
}
}
示例8: getProposalFactory
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
protected Function<IEObjectDescription, ICompletionProposal> getProposalFactory(String ruleName,
ContentAssistContext contentAssistContext) {
return new DefaultProposalCreator(contentAssistContext, ruleName, getQualifiedNameConverter()) {
@Override
public ICompletionProposal apply(IEObjectDescription candidate) {
ICompletionProposal proposal = super.apply(candidate);
EObject eObjectOrProxy = candidate.getEObjectOrProxy();
if (eObjectOrProxy.eIsProxy()) {
return proposal;
}
if (eObjectOrProxy instanceof Operation) {
Operation operation = (Operation) eObjectOrProxy;
if (operation.getParameters().size() > 0 && (proposal instanceof ConfigurableCompletionProposal)) {
ConfigurableCompletionProposal configurableProposal = (ConfigurableCompletionProposal) proposal;
configurableProposal.setReplacementString(configurableProposal.getReplacementString() + "()");
configurableProposal.setCursorPosition(configurableProposal.getCursorPosition() + 1);
}
}
return proposal;
}
};
}
示例9: 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);
}
示例10: doCreateProposal
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
@Override
protected ConfigurableCompletionProposal doCreateProposal(String proposal,
StyledString displayString, Image image, int priority,
ContentAssistContext context) {
ConfigurableCompletionProposal theproposal = super
.doCreateProposal(proposal, displayString, image, priority, context);
// System.out.println("doCreateProposal "+proposal+context.getSelectedText());
// if(proposal.equals("Activity Template")){
// theproposal.setAdditionalProposalInfo(
// "Activity activityname {\n"+
// "\t\t//involves Resource;\n"+
// "\t\tstarts '2/01/2013';\n"+
// "\t\tduration 10;\n"+
// "\t\t//ends '15/01/2013';\n"+
// "\t\tdescription '';\n" +
// "\t\tcompleteness 0%;\n"+
// "\t}"
// );
// }
return theproposal;
}
示例11: complete_ActivityElement
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
@Override
public void complete_ActivityElement(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
ConfigurableCompletionProposal activityTemplate = (ConfigurableCompletionProposal) createCompletionProposal("Activity Template",
context);
if (activityTemplate != null) {
activityTemplate.setTextApplier(
new ReplacementTextApplier() {
@Override
public String getActualReplacementString(
ConfigurableCompletionProposal proposal) {
Calendar start = GregorianCalendar.getInstance();
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String startString = formatter.format(start.getTime());
return "Activity activityname {\n"+
"\t\tstarts '"+startString+"';\n"+
"\t\tduration 10;\n"+
"\t\tcompleteness 0%;\n"+
"\t}";
}
}
);
acceptor.accept(activityTemplate);
}
}
示例12: simpleApply
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
/**
* Just insert the string at the replacement offset. Everything else is fine.
*/
private void simpleApply(IDocument document, String string, ConfigurableCompletionProposal proposal)
throws BadLocationException {
proposal.setCursorPosition(string.length());
document.replace(proposal.getReplacementOffset(), proposal.getReplacementLength(),
string);
}
示例13: completeConfiguredParameter_NewValue
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
@Override
// CHECKSTYLE:OFF
public void completeConfiguredParameter_NewValue(final EObject model, final Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
// CHECKSTYLE:ON
// TODO filter depending on type of linked parameter
FormalParameter parameter = ((ConfiguredParameter) model).getParameter();
ICheckCfgPropertySpecification propertySpecification = null;
String[] validValues = null;
if (parameter != null) {
propertySpecification = CheckCfgUtil.getPropertySpecification(parameter.getName());
if (propertySpecification != null) {
validValues = propertySpecification.getExpectedValues();
}
}
if (validValues != null && validValues.length > 0) {
String info = propertySpecification.getInfo();
for (String validValue : validValues) {
ICompletionProposal proposal = createCompletionProposal(String.format("\"%s\"", validValue), new StyledString(validValue), getImage(model), 0, context.getPrefix(), context);
if (proposal instanceof ConfigurableCompletionProposal) {
((ConfigurableCompletionProposal) proposal).setAdditionalProposalInfo(info);
}
acceptor.accept(proposal);
}
return;
}
super.completeConfiguredParameter_NewValue(model, assignment, context, acceptor);
}
示例14: 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);
}
}
示例15: accept
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal; //导入依赖的package包/类
public void accept(ICompletionProposal proposal) {
if (proposal instanceof ConfigurableCompletionProposal) {
Keyword keyword = XtextFactory.eINSTANCE.createKeyword();
keyword.setValue(proposal.getDisplayString());
((ConfigurableCompletionProposal) proposal).setAdditionalProposalInfo(keyword);
((ConfigurableCompletionProposal) proposal).setHover(STextProposalProvider.this.getHover());
}
delegate.accept(proposal);
}