Java Code Examples for org.eclipse.jdt.core.Signature#getSignatureQualifier()

The following examples show how to use org.eclipse.jdt.core.Signature#getSignatureQualifier() . 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
private void createAnonymousTypeLabel(CompletionProposal proposal, CompletionItem item) {
	char[] declaringTypeSignature= proposal.getDeclarationSignature();
	declaringTypeSignature= Signature.getTypeErasure(declaringTypeSignature);
	String name = new String(Signature.getSignatureSimpleName(declaringTypeSignature));
	item.setInsertText(name);
	StringBuilder buf= new StringBuilder();
	buf.append(name);
	buf.append('(');
	appendUnboundedParameterList(buf, proposal);
	buf.append(')');
	buf.append("  "); //$NON-NLS-1$
	buf.append("Anonymous Inner Type"); //TODO: consider externalization
	item.setLabel(buf.toString());

	if (proposal.getRequiredProposals() != null) {
		char[] signatureQualifier= Signature.getSignatureQualifier(declaringTypeSignature);
		if (signatureQualifier.length > 0) {
			item.setDetail(String.valueOf(signatureQualifier) + "." + name);
		}
	}
	setDeclarationSignature(item, String.valueOf(declaringTypeSignature));
}
 
Example 2
Source File: SetterAttributeProposalComputer.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Determines whether a setter's parameter signature can be parsed from an
 * attribute based on the GWT AttributeParsers implementation.
 */
private boolean isParsableSetter(IMethod method) {
  StringBuffer signature = new StringBuffer();

  for (String paramType : method.getParameterTypes()) {
    if (signature.length() > 0) {
      signature.append(',');
    }

    String qualifier = Signature.getSignatureQualifier(paramType);
    if (qualifier.length() > 0) {
      signature.append(qualifier);
      signature.append('.');
    }

    signature.append(Signature.getSignatureSimpleName(paramType));
  }

  return PARSABLE_ARGS.contains(signature.toString());
}
 
Example 3
Source File: CompletionProposalLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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(')');
	buffer.append("  "); //$NON-NLS-1$
	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);
}
 
Example 4
Source File: JavaModelSearch.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Extract the fully-qualified type name out of a type signature, with dots as
 * package separators.
 */
public static String getQualifiedTypeName(String typeSignature) {
  // Make sure we're using dots for package separator, not /'s
  typeSignature = typeSignature.replace('/', '.');

  String pckg = Signature.getSignatureQualifier(typeSignature);
  String typeName = Signature.getSignatureSimpleName(typeSignature);

  if (pckg == null || pckg.length() == 0) {
    return typeName;
  }

  return pckg + "." + typeName;
}
 
Example 5
Source File: SignatureUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the qualified signature corresponding to
 * <code>signature</code>.
 *
 * @param signature the signature to qualify
 * @param context the type inside which an unqualified type will be
 *        resolved to find the qualifier, or <code>null</code> if no
 *        context is available
 * @return the qualified signature
 */
public static String qualifySignature(final String signature, final IType context) {
	if (context == null)
		return signature;

	String qualifier= Signature.getSignatureQualifier(signature);
	if (qualifier.length() > 0)
		return signature;

	String elementType= Signature.getElementType(signature);
	String erasure= Signature.getTypeErasure(elementType);
	String simpleName= Signature.getSignatureSimpleName(erasure);
	String genericSimpleName= Signature.getSignatureSimpleName(elementType);

	int dim= Signature.getArrayCount(signature);

	try {
		String[][] strings= context.resolveType(simpleName);
		if (strings != null && strings.length > 0)
			qualifier= strings[0][0];
	} catch (JavaModelException e) {
		// ignore - not found
	}

	if (qualifier.length() == 0)
		return signature;

	String qualifiedType= Signature.toQualifiedName(new String[] {qualifier, genericSimpleName});
	String qualifiedSignature= Signature.createTypeSignature(qualifiedType, true);
	String newSignature= Signature.createArraySignature(qualifiedSignature, dim);

	return newSignature;
}
 
Example 6
Source File: CompletionRequestorWrapper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private char[][] getParameterPackages(char[] methodSignature) {
	char[][] parameterQualifiedTypes = Signature.getParameterTypes(methodSignature);
	int length = parameterQualifiedTypes == null ? 0 : parameterQualifiedTypes.length;
	char[][] parameterPackages = new char[length][];
	for(int i = 0; i < length; i++) {
		parameterPackages[i] = Signature.getSignatureQualifier(parameterQualifiedTypes[i]);
	}

	return parameterPackages;
}