org.eclipse.jdt.core.Signature Java Examples
The following examples show how to use
org.eclipse.jdt.core.Signature.
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: CompletionProposalLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * 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 #2
Source File: KeyToSignature.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void consumeMethod(char[] selector, char[] methodSignature) { this.arguments = new ArrayList(); this.typeArguments = new ArrayList(); CharOperation.replace(methodSignature, '/', '.'); switch(this.kind) { case SIGNATURE: this.signature = new StringBuffer(); this.signature.append(methodSignature); break; case THROWN_EXCEPTIONS: if (CharOperation.indexOf('^', methodSignature) > 0) { char[][] types = Signature.getThrownExceptionTypes(methodSignature); int length = types.length; for (int i=0; i<length; i++) { this.thrownExceptions.add(new String(types[i])); } } break; } }
Example #3
Source File: RemoteServiceProblemFactory.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Returns a new {@link RemoteServiceProblem} for a * {@link RemoteServiceProblemType#INVALID_ASYNC_RETURN_TYPE}. */ static RemoteServiceProblem newInvalidAsyncReturnType( MethodDeclaration methodDeclaration) { StringBuilder sb = new StringBuilder(); for (int i = 0, n = Util.VALID_ASYNC_RPC_RETURN_TYPES.size(); i < n; ++i) { if (i > 0) { if (i == n - 1) { sb.append(" or "); } else { sb.append(", "); } } String validReturnType = Util.VALID_ASYNC_RPC_RETURN_TYPES.get(i); sb.append(Signature.getSimpleName(validReturnType)); } return RemoteServiceProblem.create(methodDeclaration.getReturnType2(), RemoteServiceProblemType.INVALID_ASYNC_RETURN_TYPE, new String[] {sb.toString()}, NO_STRINGS); }
Example #4
Source File: DialogFactoryHelperImpl.java From jenerate with Eclipse Public License 1.0 | 6 votes |
private String getMethodLabel(final IMethod method) { StringBuffer result = new StringBuffer("`"); String[] params = method.getParameterTypes(); result.append(method.getElementName()); result.append("("); for (int i = 0; i < params.length; i++) { if (i != 0) { result.append(", "); } result.append(Signature.toString(params[i])); } result.append(")`"); return result.toString(); }
Example #5
Source File: CreateMethodOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the type signatures of the parameter types of the * current <code>MethodDeclaration</code> */ protected String[] convertASTMethodTypesToSignatures() { if (this.parameterTypes == null) { if (this.createdNode != null) { MethodDeclaration methodDeclaration = (MethodDeclaration) this.createdNode; List parameters = methodDeclaration.parameters(); int size = parameters.size(); this.parameterTypes = new String[size]; Iterator iterator = parameters.iterator(); // convert the AST types to signatures for (int i = 0; i < size; i++) { SingleVariableDeclaration parameter = (SingleVariableDeclaration) iterator.next(); String typeSig = Util.getSignature(parameter.getType()); int extraDimensions = parameter.getExtraDimensions(); if (methodDeclaration.isVarargs() && i == size-1) extraDimensions++; this.parameterTypes[i] = Signature.createArraySignature(typeSig, extraDimensions); } } } return this.parameterTypes; }
Example #6
Source File: LaunchPipelineShortcut.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private static LaunchableResource toLaunchableResource(IResource resource) { if (resource == null) { return null; } IJavaElement javaElement = resource.getAdapter(IJavaElement.class); if (javaElement != null && javaElement.exists() && javaElement instanceof ICompilationUnit) { ICompilationUnit compilationUnit = (ICompilationUnit) javaElement; IType javaType = compilationUnit.findPrimaryType(); if (javaType == null) { return null; } IMethod mainMethod = javaType.getMethod( "main", new String[] {Signature.createTypeSignature("String[]", false)}); return new LaunchableResource(resource, mainMethod, javaType); } return new LaunchableResource(resource); }
Example #7
Source File: RenameTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean sameParams(IMethod method, IMethod method2) { if (method.getNumberOfParameters() != method2.getNumberOfParameters()) return false; String[] params= method.getParameterTypes(); String[] params2= method2.getParameterTypes(); for (int i= 0; i < params.length; i++) { String t1= Signature.getSimpleName(Signature.toString(params[i])); String t2= Signature.getSimpleName(Signature.toString(params2[i])); if (!t1.equals(t2)) { return false; } } return true; }
Example #8
Source File: ChangeSignatureProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public String getOldMethodSignature() throws JavaModelException{ StringBuffer buff= new StringBuffer(); int flags= getMethod().getFlags(); buff.append(getVisibilityString(flags)); if (Flags.isStatic(flags)) { buff.append("static "); //$NON-NLS-1$ } else if (Flags.isDefaultMethod(flags)) { buff.append("default "); //$NON-NLS-1$ } if (! getMethod().isConstructor()) buff.append(fReturnTypeInfo.getOldTypeName()) .append(' '); buff.append(JavaElementLabels.getElementLabel(fMethod.getParent(), JavaElementLabels.ALL_FULLY_QUALIFIED)); buff.append('.'); buff.append(fMethod.getElementName()) .append(Signature.C_PARAM_START) .append(getOldMethodParameters()) .append(Signature.C_PARAM_END); buff.append(getOldMethodThrows()); return BasicElementLabels.getJavaCodeString(buff.toString()); }
Example #9
Source File: JavaTypeCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IJavaCompletionProposal createTypeProposal(int relevance, String fullyQualifiedType, JavaContentAssistInvocationContext context) throws JavaModelException { IType type= context.getCompilationUnit().getJavaProject().findType(fullyQualifiedType); if (type == null) return null; CompletionProposal proposal= CompletionProposal.create(CompletionProposal.TYPE_REF, context.getInvocationOffset()); proposal.setCompletion(fullyQualifiedType.toCharArray()); proposal.setDeclarationSignature(type.getPackageFragment().getElementName().toCharArray()); proposal.setFlags(type.getFlags()); proposal.setRelevance(relevance); proposal.setReplaceRange(context.getInvocationOffset(), context.getInvocationOffset()); proposal.setSignature(Signature.createTypeSignature(fullyQualifiedType, true).toCharArray()); if (shouldProposeGenerics(context.getProject())) return new LazyGenericTypeProposal(proposal, context); else return new LazyJavaTypeCompletionProposal(proposal, context); }
Example #10
Source File: AnonymousTypeCompletionProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private String createDummyType(String name) throws JavaModelException { StringBuffer buffer = new StringBuffer(); buffer.append("abstract class "); //$NON-NLS-1$ buffer.append(name); if (fSuperType.isInterface()) { buffer.append(" implements "); //$NON-NLS-1$ } else { buffer.append(" extends "); //$NON-NLS-1$ } if (fDeclarationSignature != null) { buffer.append(Signature.toString(fDeclarationSignature)); } else { buffer.append(fSuperType.getFullyQualifiedParameterizedName()); } buffer.append(" {"); //$NON-NLS-1$ buffer.append("\n"); //$NON-NLS-1$ buffer.append("}"); //$NON-NLS-1$ return buffer.toString(); }
Example #11
Source File: NLSHintHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static IStorage getResourceBundle(IJavaProject javaProject, AccessorClassReference accessorClassReference) throws JavaModelException { String resourceBundle= accessorClassReference.getResourceBundleName(); if (resourceBundle == null) return null; String resourceName= Signature.getSimpleName(resourceBundle) + NLSRefactoring.PROPERTY_FILE_EXT; String packName= Signature.getQualifier(resourceBundle); ITypeBinding accessorClass= accessorClassReference.getBinding(); if (accessorClass.isFromSource()) return getResourceBundle(javaProject, packName, resourceName); else if (accessorClass.getJavaElement() != null) return getResourceBundle((IPackageFragmentRoot)accessorClass.getJavaElement().getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT), packName, resourceName); return null; }
Example #12
Source File: CompletionProposalReplacementProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * @param completionBuffer * @param proposal */ private void appendMethodOverrideReplacement(StringBuilder completionBuffer, CompletionProposal proposal) { IDocument document; try { document = JsonRpcHelpers.toDocument(this.compilationUnit.getBuffer()); String signature = String.valueOf(proposal.getSignature()); String[] types = Stream.of(Signature.getParameterTypes(signature)).map(t -> Signature.toString(t)) .toArray(String[]::new); String methodName = String.valueOf(proposal.getName()); int offset = proposal.getReplaceStart(); String completion = new String(proposal.getCompletion()); OverrideCompletionProposal overrider = new OverrideCompletionProposal(compilationUnit, methodName, types, completion); String replacement = overrider.updateReplacementString(document, offset, importRewrite, client.isCompletionSnippetsSupported()); completionBuffer.append(replacement); } catch (BadLocationException | CoreException e) { JavaLanguageServerPlugin.logException("Failed to compute override replacement", e); } }
Example #13
Source File: TypeConverter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private TypeReference[] decodeTypeArguments(String typeSignature, int length, int start, int end) { ArrayList argumentList = new ArrayList(1); int count = 0; argumentsLoop: while (this.namePos < length) { TypeReference argument = decodeType(typeSignature, length, start, end); count++; argumentList.add(argument); if (this.namePos >= length) break argumentsLoop; if (typeSignature.charAt(this.namePos) == Signature.C_GENERIC_END) { break argumentsLoop; } } TypeReference[] typeArguments = new TypeReference[count]; argumentList.toArray(typeArguments); return typeArguments; }
Example #14
Source File: ChangeSignatureProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public String getNewMethodSignature() throws JavaModelException{ StringBuffer buff= new StringBuffer(); buff.append(getVisibilityString(fVisibility)); int flags= getMethod().getFlags(); if (Flags.isStatic(flags)) { buff.append("static "); //$NON-NLS-1$ } else if (Flags.isDefaultMethod(flags)) { buff.append("default "); //$NON-NLS-1$ } if (! getMethod().isConstructor()) buff.append(getReturnTypeString()) .append(' '); buff.append(getMethodName()) .append(Signature.C_PARAM_START) .append(getMethodParameters()) .append(Signature.C_PARAM_END); buff.append(getMethodThrows()); return BasicElementLabels.getJavaCodeString(buff.toString()); }
Example #15
Source File: JavaStatementPostfixContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public String[] suggestFieldName(String type, String[] excludes, boolean staticField, boolean finalField) throws IllegalArgumentException { int dim = 0; while (type.endsWith("[]")) { dim++; type = type.substring(0, type.length() - 2); } IJavaProject project = getJavaProject(); int namingConventions = 0; if (staticField && finalField) { namingConventions = NamingConventions.VK_STATIC_FINAL_FIELD; } else if (staticField && !finalField) { namingConventions = NamingConventions.VK_STATIC_FIELD; } else { namingConventions = NamingConventions.VK_INSTANCE_FIELD; } if (project != null) return StubUtility.getVariableNameSuggestions(namingConventions, project, type, dim, Arrays.asList(excludes), true); return new String[] {Signature.getSimpleName(type).toLowerCase()}; }
Example #16
Source File: CompletionProposalDescriptionProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * 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 #17
Source File: JsniCompletionProposalCollector.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@Override protected IJavaCompletionProposal createJavaCompletionProposal( CompletionProposal proposal) { IJavaCompletionProposal defaultProposal = super.createJavaCompletionProposal(proposal); // For members of inner classes, there's a bug in the JDT which results in // the declaration signature of the proposal missing the outer classes, so // we have to manually set the signature instead. if (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.FIELD_REF) { char[] typeSignature = Signature.createTypeSignature(qualifiedTypeName, true).toCharArray(); proposal.setDeclarationSignature(typeSignature); } return JsniCompletionProposal.create(defaultProposal, proposal, getCompilationUnit().getJavaProject(), refOffset, refLength); }
Example #18
Source File: JavaModelUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Resolves a type name in the context of the declaring type. * * @param refTypeSig the type name in signature notation (for example 'QVector') this can also be an array type, but dimensions will be ignored. * @param declaringType the context for resolving (type where the reference was made in) * @return returns the fully qualified type name or build-in-type name. if a unresolved type couldn't be resolved null is returned * @throws JavaModelException thrown when the type can not be accessed */ public static String getResolvedTypeName(String refTypeSig, IType declaringType) throws JavaModelException { int arrayCount= Signature.getArrayCount(refTypeSig); char type= refTypeSig.charAt(arrayCount); if (type == Signature.C_UNRESOLVED) { String name= ""; //$NON-NLS-1$ int bracket= refTypeSig.indexOf(Signature.C_GENERIC_START, arrayCount + 1); if (bracket > 0) name= refTypeSig.substring(arrayCount + 1, bracket); else { int semi= refTypeSig.indexOf(Signature.C_SEMICOLON, arrayCount + 1); if (semi == -1) { throw new IllegalArgumentException(); } name= refTypeSig.substring(arrayCount + 1, semi); } String[][] resolvedNames= declaringType.resolveType(name); if (resolvedNames != null && resolvedNames.length > 0) { return JavaModelUtil.concatenateName(resolvedNames[0][0], resolvedNames[0][1]); } return null; } else { return Signature.toString(refTypeSig.substring(arrayCount)); } }
Example #19
Source File: JdtBasedTypeFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private IMethod findJavaMethod(IType type) { // Locate the method from its signature. // String[] parameterTypes = Signature.getParameterTypes(new BindingKey("Lx;.x(" + signature + ")").toSignature()); IMethod javaMethod = type.getMethod(name, parameterTypes); // If the method doesn't exist and this is a nested type... // if (!javaMethod.exists() && type.getDeclaringType() != null) { // This special case handles what appears to be a JDT bug // that sometimes it knows when there are implicit constructor arguments for nested types and sometimes it doesn't. // Infer one more initial parameter type and locate the method based on that. // String[] augmented = new String[parameterTypes.length + 1]; System.arraycopy(parameterTypes, 0, augmented, 1, parameterTypes.length); String first = Signature.createTypeSignature(type.getDeclaringType().getFullyQualifiedName(), true); augmented[0] = first; javaMethod = type.getMethod(name, augmented); } return javaMethod; }
Example #20
Source File: SourceMapper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public LocalVariableElementKey(IJavaElement method, String name) { StringBuffer buffer = new StringBuffer(); buffer .append(method.getParent().getHandleIdentifier()) .append('#') .append(method.getElementName()) .append('('); if (method.getElementType() == IJavaElement.METHOD) { String[] parameterTypes = ((IMethod) method).getParameterTypes(); for (int i = 0, max = parameterTypes.length; i < max; i++) { if (i > 0) { buffer.append(','); } buffer.append(Signature.getSignatureSimpleName(parameterTypes[i])); } } buffer.append(')'); this.parent = String.valueOf(buffer); this.name = name; }
Example #21
Source File: TypeParameterPattern.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * @param findDeclarations * @param findReferences * @param typeParameter * @param matchRule */ public TypeParameterPattern(boolean findDeclarations, boolean findReferences, ITypeParameter typeParameter, int matchRule) { super(TYPE_PARAM_PATTERN, matchRule); this.findDeclarations = findDeclarations; // set to find declarations & all occurences this.findReferences = findReferences; // set to find references & all occurences this.typeParameter = typeParameter; this.name = typeParameter.getElementName().toCharArray(); // store type parameter name IMember member = typeParameter.getDeclaringMember(); this.declaringMemberName = member.getElementName().toCharArray(); // store type parameter declaring member name // For method type parameter, store also declaring class name and parameters type names if (member instanceof IMethod) { IMethod method = (IMethod) member; this.methodDeclaringClassName = method.getParent().getElementName().toCharArray(); String[] parameters = method.getParameterTypes(); int length = parameters.length; this.methodArgumentTypes = new char[length][]; for (int i=0; i<length; i++) { this.methodArgumentTypes[i] = Signature.toCharArray(parameters[i].toCharArray()); } } }
Example #22
Source File: Disassembler.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private char[][] getParameterNames(char[] methodDescriptor, ICodeAttribute codeAttribute, IMethodParametersAttribute parametersAttribute, int accessFlags) { int paramCount = Signature.getParameterCount(methodDescriptor); char[][] parameterNames = new char[paramCount][]; // check if the code attribute has debug info for this method if (parametersAttribute != null) { int parameterCount = parametersAttribute.getMethodParameterLength(); for (int i = 0; i < paramCount; i++) { if (i < parameterCount && parametersAttribute.getParameterName(i) != null) { parameterNames[i] = parametersAttribute.getParameterName(i); } else { parameterNames[i] = Messages.disassembler_anonymousparametername.toCharArray(); } } } else if (codeAttribute != null) { ILocalVariableAttribute localVariableAttribute = codeAttribute.getLocalVariableAttribute(); if (localVariableAttribute != null) { ILocalVariableTableEntry[] entries = localVariableAttribute.getLocalVariableTable(); final int startingIndex = (accessFlags & IModifierConstants.ACC_STATIC) != 0 ? 0 : 1; for (int i = 0; i < paramCount; i++) { ILocalVariableTableEntry searchedEntry = getEntryFor(getLocalIndex(startingIndex, i, methodDescriptor), entries); if (searchedEntry != null) { parameterNames[i] = searchedEntry.getName(); } else { parameterNames[i] = CharOperation.concat(Messages.disassembler_parametername.toCharArray(), Integer.toString(i).toCharArray()); } } } else { for (int i = 0; i < paramCount; i++) { parameterNames[i] = CharOperation.concat(Messages.disassembler_parametername.toCharArray(), Integer.toString(i).toCharArray()); } } } else { for (int i = 0; i < paramCount; i++) { parameterNames[i] = CharOperation.concat(Messages.disassembler_parametername.toCharArray(), Integer.toString(i).toCharArray()); } } return parameterNames; }
Example #23
Source File: JavaContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String[] suggestVariableName(String type, String[] excludes) throws IllegalArgumentException { int dim=0; while (type.endsWith("[]")) {//$NON-NLS-1$ dim++; type= type.substring(0, type.length() - 2); } IJavaProject project= getJavaProject(); if (project != null) return StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, project, type, dim, Arrays.asList(excludes), true); // fallback if we lack proper context: roll-our own lowercasing return new String[] {Signature.getSimpleName(type).toLowerCase()}; }
Example #24
Source File: SimilarElementsRequestor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static final int getKind(int flags, char[] typeNameSig) { if (Signature.getTypeSignatureKind(typeNameSig) == Signature.TYPE_VARIABLE_SIGNATURE) { return VARIABLES; } if (Flags.isAnnotation(flags)) { return ANNOTATIONS; } if (Flags.isInterface(flags)) { return INTERFACES; } if (Flags.isEnum(flags)) { return ENUMS; } return CLASSES; }
Example #25
Source File: CompletionProposalDescriptionProvider.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * Creates and returns the method signature suitable for display. * * @param proposal * the proposal to create the description for * @return the string of method signature suitable for display */ public StringBuilder createMethodProposalDescription(CompletionProposal proposal) { int kind = proposal.getKind(); StringBuilder description = new StringBuilder(); switch (kind) { case CompletionProposal.METHOD_REF: case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: case CompletionProposal.CONSTRUCTOR_INVOCATION: // method name description.append(proposal.getName()); // parameters description.append('('); appendUnboundedParameterList(description, proposal); description.append(')'); // return type if (!proposal.isConstructor()) { // TODO remove SignatureUtil.fix83600 call when bugs are fixed char[] returnType = createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(proposal.getSignature())))); description.append(RETURN_TYPE_SEPARATOR); description.append(returnType); } } return description; // dummy }
Example #26
Source File: JavaElementLabelComposer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * Appends labels for type parameters from a signature. * * @param typeParamSigs the type parameter signature * @param flags flags with render options */ private void appendTypeParameterSignaturesLabel(String[] typeParamSigs, long flags) { if (typeParamSigs.length > 0) { fBuilder.append(getLT()); for (int i = 0; i < typeParamSigs.length; i++) { if (i > 0) { fBuilder.append(JavaElementLabels.COMMA_STRING); } fBuilder.append(Signature.getTypeVariable(typeParamSigs[i])); } fBuilder.append(getGT()); } }
Example #27
Source File: SetterAttributeProposalComputer.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private String getDescription(IType type, IMethod method) { try { return MessageFormat.format(DESCRIPTION_FORMAT, type.getElementName(), Signature.toString(method.getSignature(), method.getElementName(), method.getParameterNames(), false, false)); } catch (JavaModelException e) { // if the above throws, we fall-back on a safer/simpler version return MessageFormat.format(DESCRIPTION_FORMAT, type.getElementName(), method.getElementName()); } }
Example #28
Source File: KeyToSignature.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void consumeParameterizedGenericMethod() { this.typeArguments = this.arguments; int typeParametersSize = this.arguments.size(); if (typeParametersSize > 0) { int sigLength = this.signature.length(); char[] methodSignature = new char[sigLength]; this.signature.getChars(0, sigLength, methodSignature, 0); char[][] typeParameterSigs = Signature.getTypeParameters(methodSignature); if (typeParameterSigs.length != typeParametersSize) return; this.signature = new StringBuffer(); // type parameters for (int i = 0; i < typeParametersSize; i++) typeParameterSigs[i] = CharOperation.concat(Signature.C_TYPE_VARIABLE,Signature.getTypeVariable(typeParameterSigs[i]), Signature.C_SEMICOLON); int paramStart = CharOperation.indexOf(Signature.C_PARAM_START, methodSignature); char[] typeParametersString = CharOperation.subarray(methodSignature, 0, paramStart); this.signature.append(typeParametersString); // substitute parameters this.signature.append(Signature.C_PARAM_START); char[][] parameters = Signature.getParameterTypes(methodSignature); for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) substitute(parameters[i], typeParameterSigs, typeParametersSize); this.signature.append(Signature.C_PARAM_END); // substitute return type char[] returnType = Signature.getReturnType(methodSignature); substitute(returnType, typeParameterSigs, typeParametersSize); // substitute exceptions char[][] exceptions = Signature.getThrownExceptionTypes(methodSignature); for (int i = 0, exceptionsLength = exceptions.length; i < exceptionsLength; i++) { this.signature.append(Signature.C_EXCEPTION_START); substitute(exceptions[i], typeParameterSigs, typeParametersSize); } } }
Example #29
Source File: DefaultBytecodeVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see IBytecodeVisitor#_putstatic(int, int, IConstantPoolEntry) */ public void _putstatic(int pc, int index, IConstantPoolEntry constantFieldref) { dumpPcNumber(pc); this.buffer.append(Messages.bind(Messages.classformat_putstatic, new String[] { OpcodeStringValues.BYTECODE_NAMES[IOpcodeMnemonics.PUTSTATIC], Integer.toString(index), returnDeclaringClassName(constantFieldref), new String(constantFieldref.getFieldName()), returnClassName(Signature.toCharArray(constantFieldref.getFieldDescriptor())) })); writeNewLine(); }
Example #30
Source File: DefaultBytecodeVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see IBytecodeVisitor#_getfield(int, int, IConstantPoolEntry) */ public void _getfield(int pc, int index, IConstantPoolEntry constantFieldref) { dumpPcNumber(pc); this.buffer.append(Messages.bind(Messages.classformat_getfield, new String[] { OpcodeStringValues.BYTECODE_NAMES[IOpcodeMnemonics.GETFIELD], Integer.toString(index), returnDeclaringClassName(constantFieldref), new String(constantFieldref.getFieldName()), returnClassName(Signature.toCharArray(constantFieldref.getFieldDescriptor())) })); writeNewLine(); }