use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.
the class XtendJvmLabelProvider method text.
@Override
protected Object text(final JvmField element) {
String _simpleName = element.getSimpleName();
StyledString _styledString = new StyledString(_simpleName);
String _simpleName_1 = element.getType().getSimpleName();
String _plus = (" : " + _simpleName_1);
StyledString _styledString_1 = new StyledString(_plus, StyledString.DECORATIONS_STYLER);
return _styledString.append(_styledString_1);
}
use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.
the class XtendLabelProvider method text.
protected StyledString text(final XtendFunction element) {
final String simpleName = element.getName();
if ((simpleName != null)) {
final QualifiedName qnName = QualifiedName.create(simpleName);
final QualifiedName operator = this.operatorMapping.getOperator(qnName);
if ((operator != null)) {
final StyledString result = this.signature(operator.getFirstSegment(), this._iXtendJvmAssociations.getDirectlyInferredOperation(element));
result.append(((" (" + simpleName) + ")"), StyledString.COUNTER_STYLER);
return result;
}
}
return this.signature(element.getName(), this._iXtendJvmAssociations.getDirectlyInferredOperation(element));
}
use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.
the class XtendProposalProvider method completeMember_Name.
@Override
public void completeMember_Name(final EObject model, Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
if (announceProcessing(Lists.newArrayList("completeMember_Name", model, assignment.getFeature()))) {
EObject previousModel = context.getPreviousModel();
if (previousModel instanceof XExpression) {
if (!(previousModel instanceof XBlockExpression)) {
return;
}
}
if (model instanceof XtendField) {
// TODO go up type hierarchy and collect all local fields
final List<XtendField> siblings = EcoreUtil2.getSiblingsOfType(model, XtendField.class);
Set<String> alreadyTaken = Sets.newHashSet();
for (XtendField sibling : siblings) {
alreadyTaken.add(sibling.getName());
}
alreadyTaken.addAll(getAllKeywords());
completions.getVariableProposals(model, XtendPackage.Literals.XTEND_FIELD__TYPE, VariableType.INSTANCE_FIELD, alreadyTaken, new JdtVariableCompletions.CompletionDataAcceptor() {
@Override
public void accept(String replaceText, StyledString label, Image img) {
acceptor.accept(createCompletionProposal(replaceText, label, img, context));
}
});
} else if (model instanceof XtendFunction) {
for (QualifiedName operator : operatorMapping.getOperators()) {
StyledString displayString = new StyledString(operator.getFirstSegment());
displayString.append(" " + operatorMapping.getMethodName(operator), StyledString.DECORATIONS_STYLER);
acceptor.accept(createCompletionProposal(operator.getFirstSegment(), displayString, getImage(model), context));
}
super.completeMember_Name(model, assignment, context, acceptor);
} else {
super.completeMember_Name(model, assignment, context, acceptor);
}
}
}
use of org.eclipse.jface.viewers.StyledString in project xtext-xtend by eclipse.
the class XtendOutlineJvmTreeProvider method buildXtendNode.
@Override
public IXtendOutlineContext buildXtendNode(EObject modelElement, IXtendOutlineContext context) {
IXtendOutlineContext resultedContext = super.buildXtendNode(modelElement, context);
if (!context.isShowInherited()) {
EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
if (parentNode instanceof DocumentRootNode) {
if (modelElement instanceof JvmDeclaredType) {
JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) modelElement;
String packageName = jvmDeclaredType.getPackageName();
if (packageName != null) {
EObject rootElement = modelElement.eResource().getContents().get(0);
if (rootElement instanceof XtendFile) {
XtendFile xtendFile = (XtendFile) rootElement;
String primaryPackage = xtendFile.getPackage();
if (!packageName.equals(primaryPackage)) {
EObjectNode typeNode = (EObjectNode) ((EclipseXtendOutlineContext) resultedContext).getParentNode();
if (typeNode.getText() instanceof StyledString) {
typeNode.setText(((StyledString) typeNode.getText()).append(new StyledString(" - " + packageName, StyledString.QUALIFIER_STYLER)));
}
}
}
}
}
}
}
return resultedContext;
}
use of org.eclipse.jface.viewers.StyledString in project eclipse.platform.text by eclipse.
the class FileLabelProvider method getColoredLabelWithCounts.
private StyledString getColoredLabelWithCounts(Object element, StyledString coloredName) {
AbstractTextSearchResult result = fPage.getInput();
if (result == null)
return coloredName;
int matchCount = result.getMatchCount(element);
if (matchCount <= 1)
return coloredName;
String countInfo = Messages.format(SearchMessages.FileLabelProvider_count_format, Integer.valueOf(matchCount));
coloredName.append(' ').append(countInfo, StyledString.COUNTER_STYLER);
return coloredName;
}
Aggregations