Java Code Examples for org.eclipse.jdt.internal.corext.template.java.SignatureUtil#fix83600()

The following examples show how to use org.eclipse.jdt.internal.corext.template.java.SignatureUtil#fix83600() . 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: CompletionProposalDescriptionProvider.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Appends the parameter list to <code>buffer</code>.
 *
 * @param buffer the buffer to append to
 * @param methodProposal the method proposal
 * @return the modified <code>buffer</code>
 */
private StringBuilder appendUnboundedParameterList(StringBuilder buffer, CompletionProposal methodProposal) {
	// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
	// gets fixed.
	char[] signature= SignatureUtil.fix83600(methodProposal.getSignature());
	char[][] parameterNames;
	try {
		parameterNames = methodProposal.findParameterNames(null);
	} catch (Exception e) {
		JavaLanguageServerPlugin.logException(e.getMessage(), e);
		parameterNames = CompletionEngine.createDefaultParameterNames(Signature.getParameterCount(signature));
		methodProposal.setParameterNames(parameterNames);
	}
	char[][] parameterTypes= Signature.getParameterTypes(signature);

	for (int i= 0; i < parameterTypes.length; i++) {
		parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i]));
	}

	if (Flags.isVarargs(methodProposal.getFlags())) {
		int index= parameterTypes.length - 1;
		parameterTypes[index]= convertToVararg(parameterTypes[index]);
	}
	return appendParameterSignature(buffer, parameterTypes, parameterNames);
}
 
Example 2
Source File: CompletionProposalLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Appends the parameter list to <code>buffer</code>.
 *
 * @param buffer the buffer to append to
 * @param methodProposal the method proposal
 * @return the modified <code>buffer</code>
 */
private StyledString appendUnboundedParameterList(StyledString buffer, CompletionProposal methodProposal) {
	// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
	// gets fixed.
	char[] signature= SignatureUtil.fix83600(methodProposal.getSignature());
	char[][] parameterNames= methodProposal.findParameterNames(null);
	char[][] parameterTypes= Signature.getParameterTypes(signature);

	for (int i= 0; i < parameterTypes.length; i++)
		parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i]));

	if (Flags.isVarargs(methodProposal.getFlags())) {
		int index= parameterTypes.length - 1;
		parameterTypes[index]= convertToVararg(parameterTypes[index]);
	}
	return appendParameterSignature(buffer, parameterTypes, parameterNames);
}
 
Example 3
Source File: CompletionProposalDescriptionProvider.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Appends the type parameter list to <code>buffer</code>.
 *
 * @param buffer the buffer to append to
 * @param typeProposal the type proposal
 * @return the modified <code>buffer</code>
 */
private StringBuilder appendTypeParameterList(StringBuilder buffer, CompletionProposal typeProposal) {
	// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
	// gets fixed.
	char[] signature= SignatureUtil.fix83600(typeProposal.getSignature());
	char[][] typeParameters= Signature.getTypeArguments(signature);
	for (int i= 0; i < typeParameters.length; i++) {
		char[] param= typeParameters[i];
		typeParameters[i]= Signature.toCharArray(param);
	}
	return appendParameterSignature(buffer, typeParameters, null);
}
 
Example 4
Source File: CompletionProposalReplacementProvider.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Originally copied from
 * org.eclipse.jdt.internal.ui.text.java.ParameterGuessingProposal.getParameterTypes()
 */
private String[] getParameterTypes(CompletionProposal proposal) {
	char[] signature = SignatureUtil.fix83600(proposal.getSignature());
	char[][] types = Signature.getParameterTypes(signature);

	String[] ret = new String[types.length];
	for (int i = 0; i < types.length; i++) {
		ret[i] = new String(Signature.toCharArray(types[i]));
	}
	return ret;
}
 
Example 5
Source File: CompletionProposalReplacementProvider.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private IJavaElement[][] getAssignableElements(CompletionProposal proposal) {
	char[] signature = SignatureUtil.fix83600(proposal.getSignature());
	char[][] types = Signature.getParameterTypes(signature);

	IJavaElement[][] assignableElements = new IJavaElement[types.length][];
	for (int i = 0; i < types.length; i++) {
		assignableElements[i] = context.getVisibleElements(new String(types[i]));
	}
	return assignableElements;
}
 
Example 6
Source File: SignatureHelpRequestor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public SignatureInformation toSignatureInformation(CompletionProposal methodProposal) {
	SignatureInformation $ = new SignatureInformation();
	StringBuilder desription = descriptionProvider.createMethodProposalDescription(methodProposal);
	$.setLabel(desription.toString());
	$.setDocumentation(this.computeJavaDoc(methodProposal));

	char[] signature = SignatureUtil.fix83600(methodProposal.getSignature());
	char[][] parameterNames = methodProposal.findParameterNames(null);
	char[][] parameterTypes = Signature.getParameterTypes(signature);

	for (int i = 0; i < parameterTypes.length; i++) {
		parameterTypes[i] = Signature.getSimpleName(Signature.toCharArray(SignatureUtil.getLowerBound(parameterTypes[i])));
	}

	if (Flags.isVarargs(methodProposal.getFlags())) {
		int index = parameterTypes.length - 1;
		parameterTypes[index] = convertToVararg(parameterTypes[index]);
	}

	List<ParameterInformation> parameterInfos = new LinkedList<>();
	for (int i = 0; i < parameterTypes.length; i++) {
		StringBuilder builder = new StringBuilder();
		builder.append(parameterTypes[i]);
		builder.append(' ');
		builder.append(parameterNames[i]);

		parameterInfos.add(new ParameterInformation(builder.toString()));
	}

	$.setParameters(parameterInfos);

	return $;
}
 
Example 7
Source File: CompletionProposalLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Appends the type parameter list to <code>buffer</code>.
 *
 * @param buffer the buffer to append to
 * @param typeProposal the type proposal
 * @return the modified <code>buffer</code>
 * @since 3.2
 */
private StyledString appendTypeParameterList(StyledString buffer, CompletionProposal typeProposal) {
	// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
	// gets fixed.
	char[] signature= SignatureUtil.fix83600(typeProposal.getSignature());
	char[][] typeParameters= Signature.getTypeArguments(signature);
	for (int i= 0; i < typeParameters.length; i++) {
		char[] param= typeParameters[i];
		typeParameters[i]= Signature.toCharArray(param);
	}
	return appendParameterSignature(buffer, typeParameters, null);
}
 
Example 8
Source File: ParameterGuessingProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IJavaElement[][] getAssignableElements() {
	char[] signature= SignatureUtil.fix83600(getProposal().getSignature());
	char[][] types= Signature.getParameterTypes(signature);

	IJavaElement[][] assignableElements= new IJavaElement[types.length][];
	for (int i= 0; i < types.length; i++) {
		assignableElements[i]= fCoreContext.getVisibleElements(new String(types[i]));
	}
	return assignableElements;
}
 
Example 9
Source File: ParameterGuessingProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String[] getParameterTypes() {
	char[] signature= SignatureUtil.fix83600(fProposal.getSignature());
	char[][] types= Signature.getParameterTypes(signature);

	String[] ret= new String[types.length];
	for (int i= 0; i < types.length; i++) {
		ret[i]= new String(Signature.toCharArray(types[i]));
	}
	return ret;
}