use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalCollector method createFieldWithCastedReceiverProposal.
/**
* Creates the Java completion proposal for the JDT Core
* {@link org.eclipse.jdt.core.CompletionProposal#FIELD_REF_WITH_CASTED_RECEIVER} proposal.
*
* @param proposal the JDT Core proposal
* @return the Java completion proposal
* @since 3.4
*/
private IJavaCompletionProposal createFieldWithCastedReceiverProposal(CompletionProposal proposal) {
String completion = String.valueOf(proposal.getCompletion());
//$NON-NLS-1$
completion = CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, completion, 0, "\n", fJavaProject);
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 JavaFieldWithCastedReceiverCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext(), proposal);
if (fJavaProject != null)
javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal));
javaProposal.setTriggerCharacters(VAR_TRIGGER);
return javaProposal;
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalCollector method createLocalVariableProposal.
private IJavaCompletionProposal createLocalVariableProposal(CompletionProposal proposal) {
String completion = String.valueOf(proposal.getCompletion());
int start = proposal.getReplaceStart();
int length = getLength(proposal);
Image image = getImage(fLabelProvider.createLocalImageDescriptor(proposal));
StyledString label = fLabelProvider.createSimpleLabelWithType(proposal);
int relevance = computeRelevance(proposal);
final JavaCompletionProposal javaProposal = new JavaCompletionProposal(completion, start, length, image, label, relevance);
javaProposal.setTriggerCharacters(VAR_TRIGGER);
return javaProposal;
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalCollector method createAnonymousTypeProposal.
private IJavaCompletionProposal createAnonymousTypeProposal(CompletionProposal proposal, JavaContentAssistInvocationContext invocationContext) {
if (fCompilationUnit == null || fJavaProject == null)
return null;
char[] declarationKey = proposal.getDeclarationKey();
if (declarationKey == null)
return null;
try {
IJavaElement element = fJavaProject.findElement(new String(declarationKey), null);
if (!(element instanceof IType))
return null;
IType type = (IType) element;
String completion = String.valueOf(proposal.getCompletion());
int start = proposal.getReplaceStart();
int length = getLength(proposal);
int relevance = computeRelevance(proposal);
StyledString label = fLabelProvider.createAnonymousTypeLabel(proposal);
JavaCompletionProposal javaProposal = new AnonymousTypeCompletionProposal(fJavaProject, fCompilationUnit, invocationContext, start, length, completion, label, String.valueOf(proposal.getDeclarationSignature()), type, relevance);
javaProposal.setProposalInfo(new AnonymousTypeProposalInfo(fJavaProject, proposal));
return javaProposal;
} catch (JavaModelException e) {
return null;
}
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createOverrideMethodProposalLabel.
StyledString createOverrideMethodProposalLabel(CompletionProposal methodProposal) {
StyledString nameBuffer = new StyledString();
// method name
nameBuffer.append(methodProposal.getName());
// parameters
nameBuffer.append('(');
appendUnboundedParameterList(nameBuffer, methodProposal);
nameBuffer.append(')');
nameBuffer.append(RETURN_TYPE_SEPARATOR);
// return type
// TODO remove SignatureUtil.fix83600 call when bugs are fixed
char[] returnType = createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(methodProposal.getSignature()))));
nameBuffer.append(returnType);
// declaring type
nameBuffer.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
String declaringType = extractDeclaringTypeFQN(methodProposal);
declaringType = Signature.getSimpleName(declaringType);
nameBuffer.append(Messages.format(JavaTextMessages.ResultCollector_overridingmethod, BasicElementLabels.getJavaElementName(declaringType)), StyledString.QUALIFIER_STYLER);
return nameBuffer;
}
use of org.eclipse.jface.viewers.StyledString in project che by eclipse.
the class CompletionProposalLabelProvider method createJavadocTypeProposalLabel.
StyledString createJavadocTypeProposalLabel(char[] fullName) {
// only display innermost type name as type name, using any
// enclosing types as qualification
int qIndex = findSimpleNameStart(fullName);
//$NON-NLS-1$
StyledString buf = new StyledString("{@link ");
buf.append(new String(fullName, qIndex, fullName.length - qIndex));
buf.append('}');
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);
}
Aggregations