Java Code Examples for org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal#setDisplayString()
The following examples show how to use
org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal#setDisplayString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XtextProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected ICompletionProposal createFeatureProposal(EStructuralFeature feature, int priorityFactor, Function<IEObjectDescription, ICompletionProposal> factory, ContentAssistContext context) { IEObjectDescription description = EObjectDescription.create(QualifiedName.create(feature.getName()), feature); ConfigurableCompletionProposal proposal = (ConfigurableCompletionProposal) factory.apply(description); if (proposal != null) { proposal.setPriority(proposal.getPriority() * priorityFactor); if(SemanticHighlightingCalculator.SPECIAL_ATTRIBUTES.contains(feature.getName())) { StyledString displayString = stylerFactory.createFromXtextStyle(feature.getName(), semanticHighlightingConfiguration.specialAttribute()) .append(" - Assignment of special attribute ") .append(stylerFactory.createFromXtextStyle(feature.getName(), semanticHighlightingConfiguration.specialAttribute())); proposal.setDisplayString(displayString); } else { proposal.setDisplayString(new StyledString(feature.getName() + " - Assignment of feature " + feature.getName())); } if(feature.isMany()) { proposal.setReplacementString(feature.getName() + "+="); proposal.setCursorPosition(proposal.getCursorPosition() + 2); } else if(feature.getEType() == EcorePackage.Literals.EBOOLEAN) { proposal.setReplacementString(feature.getName() + "?="); proposal.setCursorPosition(proposal.getCursorPosition() + 2); } else { proposal.setReplacementString(feature.getName() + "="); proposal.setCursorPosition(proposal.getCursorPosition() + 1); } } return proposal; }
Example 2
Source File: XtextProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void createClassifierProposals(AbstractMetamodelDeclaration declaration, EObject model, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { String alias = declaration.getAlias(); QualifiedName prefix = (!Strings.isEmpty(alias)) ? QualifiedName.create(getValueConverter().toString(alias, grammarAccess.getValidIDRule().getName())) : null; boolean createDatatypeProposals = !(model instanceof AbstractElement) && modelOrContainerIs(model, AbstractRule.class); boolean createEnumProposals = !(model instanceof AbstractElement) && modelOrContainerIs(model, EnumRule.class); boolean createClassProposals = modelOrContainerIs(model, ParserRule.class, CrossReference.class, Action.class); Function<IEObjectDescription, ICompletionProposal> factory = new DefaultProposalCreator(context, null, classifierQualifiedNameConverter); for (EClassifier classifier : declaration.getEPackage().getEClassifiers()) { if (classifier instanceof EDataType && createDatatypeProposals || classifier instanceof EEnum && createEnumProposals || classifier instanceof EClass && createClassProposals) { String classifierName = getValueConverter().toString(classifier.getName(), grammarAccess.getValidIDRule().getName()); QualifiedName proposalQualifiedName = (prefix != null) ? prefix.append(classifierName) : QualifiedName .create(classifierName); IEObjectDescription description = EObjectDescription.create(proposalQualifiedName, classifier); ConfigurableCompletionProposal proposal = (ConfigurableCompletionProposal) factory.apply(description); if (proposal != null) { if (prefix != null) proposal.setDisplayString(classifier.getName() + " - " + alias); proposal.setPriority(proposal.getPriority() * 2); } acceptor.accept(proposal); } } }
Example 3
Source File: GamlProposalProvider.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public ICompletionProposal apply(final IEObjectDescription candidate) { final ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) super.apply(candidate); boolean isOperator = false; String doc = candidate.getUserData("doc"); final String title = candidate.getUserData("title"); if (doc == null) { doc = "Not documented yet"; } if (cp != null) { cp.setAdditionalProposalInfo("<b>" + title + "</b><p/><p>" + doc + "</p>"); final String type = candidate.getUserData("type"); if (type != null) { if (type.equals("operator")) { isOperator = true; cp.setDisplayString(cp.getDisplayString().concat(" (Built-in operator) ")); cp.setImage(actionImage); } else if (type.equals("variable")) { cp.setDisplayString(cp.getDisplayString().concat(" (Built-in variable) ")); cp.setImage(varImage); } else if (type.equals("field")) { cp.setDisplayString(cp.getDisplayString().concat(" (Built-in field) ")); cp.setImage(varImage); } else if (type.equals("action")) { cp.setDisplayString(cp.getDisplayString().concat(" (Built-in action) ")); cp.setImage(actionImage); } else if (type.equals("unit")) { isOperator = true; cp.setDisplayString(cp.getDisplayString().concat(" (Built-in unit) ")); cp.setImage(null); } else if (type.equals("type")) { isOperator = true; cp.setDisplayString(cp.getDisplayString().concat(" (Built-in type) ")); cp.setImage(typeImage); } cp.setPriority(1000); } } if (context.getPrefix().equals(".")) { if (isOperator) { return null; } if (cp != null && cp.getPriority() > 500) { cp.setPriority(200); } } return cp; }