Java Code Examples for org.eclipse.jdt.core.Signature#getThrownExceptionTypes()
The following examples show how to use
org.eclipse.jdt.core.Signature#getThrownExceptionTypes() .
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: 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 2
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 3
Source File: BinaryMethod.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public String[] getExceptionTypes() throws JavaModelException { if (this.exceptionTypes == null) { IBinaryMethod info = (IBinaryMethod) getElementInfo(); char[] genericSignature = info.getGenericSignature(); if (genericSignature != null) { char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.'); this.exceptionTypes = Signature.getThrownExceptionTypes(new String(dotBasedSignature)); } if (this.exceptionTypes == null || this.exceptionTypes.length == 0) { char[][] eTypeNames = info.getExceptionTypeNames(); if (eTypeNames == null || eTypeNames.length == 0) { this.exceptionTypes = CharOperation.NO_STRINGS; } else { eTypeNames = ClassFile.translatedNames(eTypeNames); this.exceptionTypes = new String[eTypeNames.length]; for (int j = 0, length = eTypeNames.length; j < length; j++) { // 1G01HRY: ITPJCORE:WINNT - method.getExceptionType not in correct format int nameLength = eTypeNames[j].length; char[] convertedName = new char[nameLength + 2]; System.arraycopy(eTypeNames[j], 0, convertedName, 1, nameLength); convertedName[0] = 'L'; convertedName[nameLength + 1] = ';'; this.exceptionTypes[j] = new String(convertedName); } } } } return this.exceptionTypes; }