use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createParameterList.
/**
* Creates and returns a parameter list of the given method or type proposal suitable for
* display. The list does not include parentheses. The lower bound of parameter types is
* returned.
* <p>
* Examples:
*
* <pre>
* "void method(int i, String s)" -> "int i, String s"
* "? extends Number method(java.lang.String s, ? super Number n)" -> "String s, Number n"
* </pre>
*
* </p>
*
* @param proposal the proposal to create the parameter list for
* @return the list of comma-separated parameters suitable for display
*/
public String createParameterList(CompletionProposal proposal) {
String paramList;
int kind = proposal.getKind();
switch(kind) {
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
return Strings.markJavaElementLabelLTR(paramList);
case CompletionProposal.TYPE_REF:
case CompletionProposal.JAVADOC_TYPE_REF:
paramList = appendTypeParameterList(new StyledString(), proposal).getString();
return Strings.markJavaElementLabelLTR(paramList);
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
return Strings.markJavaElementLabelLTR(paramList);
default:
Assert.isLegal(false);
// dummy
return null;
}
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createLabelWithTypeAndDeclaration.
StyledString createLabelWithTypeAndDeclaration(CompletionProposal proposal) {
char[] name = proposal.getCompletion();
if (!isThisPrefix(name))
name = proposal.getName();
StyledString buf = new StyledString();
buf.append(name);
char[] typeName = Signature.getSignatureSimpleName(proposal.getSignature());
if (typeName.length > 0) {
buf.append(VAR_TYPE_SEPARATOR);
buf.append(typeName);
}
char[] declaration = proposal.getDeclarationSignature();
if (declaration != null) {
declaration = Signature.getSignatureSimpleName(declaration);
if (declaration.length > 0) {
buf.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
if (proposal.getRequiredProposals() != null) {
String declaringType = extractDeclaringTypeFQN(proposal);
String qualifier = Signature.getQualifier(declaringType);
if (qualifier.length() > 0) {
buf.append(qualifier, StyledString.QUALIFIER_STYLER);
buf.append('.', StyledString.QUALIFIER_STYLER);
}
}
buf.append(declaration, StyledString.QUALIFIER_STYLER);
}
}
return Strings.markJavaElementLabelLTR(buf);
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createAnonymousTypeLabel.
StyledString createAnonymousTypeLabel(CompletionProposal proposal) {
char[] declaringTypeSignature = proposal.getDeclarationSignature();
declaringTypeSignature = Signature.getTypeErasure(declaringTypeSignature);
StyledString buffer = new StyledString();
buffer.append(Signature.getSignatureSimpleName(declaringTypeSignature));
buffer.append('(');
appendUnboundedParameterList(buffer, proposal);
buffer.append(')');
//$NON-NLS-1$
buffer.append(" ");
buffer.append(JavaTextMessages.ResultCollector_anonymous_type);
if (proposal.getRequiredProposals() != null) {
char[] signatureQualifier = Signature.getSignatureQualifier(declaringTypeSignature);
if (signatureQualifier.length > 0) {
buffer.append(JavaElementLabels.CONCAT_STRING, StyledString.QUALIFIER_STYLER);
buffer.append(signatureQualifier, StyledString.QUALIFIER_STYLER);
}
}
return Strings.markJavaElementLabelLTR(buffer);
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class JavaElementLabels method getStyledContainerEntryLabel.
/**
* Returns the styled label of a classpath container.
* The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
*
* @param containerPath the path of the container
* @param project the project the container is resolved in
* @return the label of the classpath container
*
* @since 3.4
*/
public static StyledString getStyledContainerEntryLabel(IPath containerPath, IJavaProject project) {
try {
IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, project);
String description = null;
if (container != null) {
description = container.getDescription();
}
if (description == null) {
ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
if (initializer != null) {
description = initializer.getDescription(containerPath, project);
}
}
if (description != null) {
StyledString str = new StyledString(description);
// }
return Strings.markLTR(str);
}
} catch (JavaModelException e) {
// ignore
}
return new StyledString(BasicElementLabels.getPathLabel(containerPath, false));
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class MethodDeclarationCompletionProposal method getDisplayName.
private static StyledString getDisplayName(String methodName, String returnTypeSig) {
StyledString buf = new StyledString();
buf.append(methodName);
buf.append('(');
buf.append(')');
if (returnTypeSig != null) {
//$NON-NLS-1$
buf.append(" : ");
buf.append(Signature.toString(returnTypeSig));
//$NON-NLS-1$
buf.append(" - ", StyledString.QUALIFIER_STYLER);
buf.append(JavaTextMessages.MethodCompletionProposal_method_label, StyledString.QUALIFIER_STYLER);
} else {
//$NON-NLS-1$
buf.append(" - ", StyledString.QUALIFIER_STYLER);
buf.append(JavaTextMessages.MethodCompletionProposal_constructor_label, StyledString.QUALIFIER_STYLER);
}
return buf;
}
Aggregations