use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createTypeProposalLabel.
StyledString createTypeProposalLabel(char[] fullName) {
// only display innermost type name as type name, using any
// enclosing types as qualification
int qIndex = findSimpleNameStart(fullName);
StyledString buf = new StyledString();
buf.append(new String(fullName, qIndex, fullName.length - qIndex));
if (qIndex > 0) {
buf.append(JavaElementLabels.CONCAT_STRING, StyledString.QUALIFIER_STYLER);
buf.append(new String(fullName, 0, qIndex - 1), StyledString.QUALIFIER_STYLER);
}
return Strings.markJavaElementLabelLTR(buf);
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createJavadocMethodProposalLabel.
/**
* Creates a display label for the given method proposal. The display label consists of:
* <ul>
* <li>the method name</li>
* <li>the raw simple name of the declaring type</li>
* </ul>
* <p>
* Examples: For the <code>get(int)</code> method of a variable of type
* <code>List<? extends Number></code>, the following display name is returned <code>get(int) - List</code>.<br>
* For the <code>add(E)</code> method of a variable of type <code>List</code>, the
* following display name is returned:
* <code>add(Object) - List</code>.<br>
* </p>
*
* @param methodProposal the method proposal to display
* @return the display label for the given method proposal
* @since 3.2
*/
StyledString createJavadocMethodProposalLabel(CompletionProposal methodProposal) {
StyledString nameBuffer = new StyledString();
// method name
nameBuffer.append(methodProposal.getCompletion());
// declaring type
nameBuffer.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
String declaringType = extractDeclaringTypeFQN(methodProposal);
declaringType = Signature.getSimpleName(declaringType);
nameBuffer.append(declaringType, StyledString.QUALIFIER_STYLER);
return Strings.markJavaElementLabelLTR(nameBuffer);
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createMethodProposalLabel.
/**
* Creates a display label for the given method proposal. The display label
* consists of:
* <ul>
* <li>the method name</li>
* <li>the parameter list (see {@link #createParameterList(org.eclipse.jdt.core.CompletionProposal)})</li>
* <li>the upper bound of the return type (see {@link SignatureUtil#getUpperBound(String)})</li>
* <li>the raw simple name of the declaring type</li>
* </ul>
* <p>
* Examples:
* For the <code>get(int)</code> method of a variable of type <code>List<? extends Number></code>, the following
* display name is returned: <code>get(int index) Number - List</code>.<br>
* For the <code>add(E)</code> method of a variable of type <code>List<? super Number></code>, the following
* display name is returned: <code>add(Number o) void - List</code>.<br>
* </p>
*
* @param methodProposal the method proposal to display
* @return the display label for the given method proposal
*/
StyledString createMethodProposalLabel(CompletionProposal methodProposal) {
StyledString nameBuffer = new StyledString();
// method name
nameBuffer.append(methodProposal.getName());
// parameters
nameBuffer.append('(');
appendUnboundedParameterList(nameBuffer, methodProposal);
nameBuffer.append(')');
// return type
if (!methodProposal.isConstructor()) {
// TODO remove SignatureUtil.fix83600 call when bugs are fixed
char[] returnType = createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(methodProposal.getSignature()))));
nameBuffer.append(RETURN_TYPE_SEPARATOR);
nameBuffer.append(returnType);
}
// declaring type
nameBuffer.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
String declaringType = extractDeclaringTypeFQN(methodProposal);
if (methodProposal.getRequiredProposals() != null) {
String qualifier = Signature.getQualifier(declaringType);
if (qualifier.length() > 0) {
nameBuffer.append(qualifier, StyledString.QUALIFIER_STYLER);
nameBuffer.append('.', StyledString.QUALIFIER_STYLER);
}
}
declaringType = Signature.getSimpleName(declaringType);
nameBuffer.append(declaringType, StyledString.QUALIFIER_STYLER);
return Strings.markJavaElementLabelLTR(nameBuffer);
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalCollector method createMethodDeclarationProposal.
private IJavaCompletionProposal createMethodDeclarationProposal(CompletionProposal proposal) {
if (fCompilationUnit == null || fJavaProject == null)
return null;
String name = String.valueOf(proposal.getName());
String[] paramTypes = Signature.getParameterTypes(String.valueOf(proposal.getSignature()));
for (int index = 0; index < paramTypes.length; index++) paramTypes[index] = Signature.toString(paramTypes[index]);
int start = proposal.getReplaceStart();
int length = getLength(proposal);
StyledString label = fLabelProvider.createOverrideMethodProposalLabel(proposal);
JavaCompletionProposal javaProposal = new OverrideCompletionProposal(fJavaProject, fCompilationUnit, name, paramTypes, start, length, label, String.valueOf(proposal.getCompletion()));
javaProposal.setImage(getImage(fLabelProvider.createMethodImageDescriptor(proposal)));
javaProposal.setProposalInfo(new MethodProposalInfo(fJavaProject, proposal));
javaProposal.setRelevance(computeRelevance(proposal));
fSuggestedMethodNames.add(new String(name));
return javaProposal;
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalCollector method createFieldProposal.
private IJavaCompletionProposal createFieldProposal(CompletionProposal proposal) {
String completion = String.valueOf(proposal.getCompletion());
int start = proposal.getReplaceStart();
int length = getLength(proposal);
StyledString label = fLabelProvider.createStyledLabel(proposal);
Image image = getImage(fLabelProvider.createFieldImageDescriptor(proposal));
int relevance = computeRelevance(proposal);
JavaCompletionProposal javaProposal = new JavaCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext());
if (fJavaProject != null)
javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal));
javaProposal.setTriggerCharacters(VAR_TRIGGER);
return javaProposal;
}
Aggregations