public String getSignature() { try { return m_method.getSignature(); } catch(JavaModelException jme) { ; } return ""; }
/** * Extracts the resolved binary parameters from the given method * * @param method * method to resolve * @return binary parameter specification */ public static String getParameters(final IMethod method) throws JavaModelException { if (method.isBinary()) { return getParameters(method.getSignature()); } final StringBuilder buffer = new StringBuilder(); final String[] parameterTypes = method.getParameterTypes(); for (final String t : parameterTypes) { resolveArrayParameterType(method, t, buffer); } return buffer.toString(); }
/** * Generate the binary signature for the provided method. This is the * type-erased signature written out to the .class file. * * @param method the method * @return the method signature as would be encoded in a .class file * @throws JavaModelException */ private static String generateBinarySignature(IMethod method) throws JavaModelException { ITypeParameter[] typeTPs = method.getDeclaringType().getTypeParameters(); ITypeParameter[] methodTPs = method.getTypeParameters(); if (typeTPs.length == 0 && methodTPs.length == 0) { return method.getSignature(); } Map<String, String> lookup = new HashMap<>(); Stream.concat(Stream.of(typeTPs), Stream.of(methodTPs)).forEach(tp -> { try { String sigs[] = tp.getBoundsSignatures(); lookup.put(tp.getElementName(), sigs.length == 1 ? sigs[0] : "Ljava.lang.Object;"); //$NON-NLS-1$ } catch (JavaModelException e) { /* ignore */ } }); String[] parameterTypes = Stream.of(method.getParameterTypes()).map(p -> expandParameterType(p, lookup)).toArray(String[]::new); return Signature.createMethodSignature(parameterTypes, expandParameterType(method.getReturnType(), lookup)); }
private void checkMethodReturnTypes(final IProgressMonitor monitor, final RefactoringStatus status, final Set<IMember> notDeletedMembersInSubtypes) throws JavaModelException { final Map<IMember, Set<IMember>> mapping= getMatchingMembers(getDestinationTypeHierarchy(monitor), getDestinationType(), true); final IMember[] members= getCreatedDestinationMembers(); for (int i= 0; i < members.length; i++) { if (members[i].getElementType() != IJavaElement.METHOD) continue; final IMethod method= (IMethod) members[i]; if (mapping.containsKey(method)) { final Set<IMember> set= mapping.get(method); if (set != null) { final String returnType= Signature.toString(Signature.getReturnType(method.getSignature()).toString()); for (final Iterator<IMember> iter= set.iterator(); iter.hasNext();) { final IMethod matchingMethod= (IMethod) iter.next(); if (method.equals(matchingMethod)) continue; if (!notDeletedMembersInSubtypes.contains(matchingMethod)) continue; if (returnType.equals(Signature.toString(Signature.getReturnType(matchingMethod.getSignature()).toString()))) continue; final String[] keys= { JavaElementLabels.getTextLabel(matchingMethod, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(matchingMethod.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}; final String message= Messages.format(RefactoringCoreMessages.PullUpRefactoring_different_method_return_type, keys); final RefactoringStatusContext context= JavaStatusContext.create(matchingMethod.getCompilationUnit(), matchingMethod.getNameRange()); status.addError(message, context); } } } } }
public static String createMethodSignature(IMethod method){ try { return Signature.toString(method.getSignature(), method.getElementName(), method.getParameterNames(), false, ! method.isConstructor()); } catch(JavaModelException e) { return method.getElementName(); //fallback } }
/** * Constructs a step handler to step into the given method in the given thread * starting from the given stack frame. */ public StepIntoSelectionHandler(IJavaThread thread, IJavaStackFrame frame, IMethod method) { fMethod = method; fThread = thread; try { fOriginalName = frame.getName(); fOriginalSignature = frame.getSignature(); fOriginalTypeName = frame.getDeclaringTypeName(); if (method.isBinary()) { fResolvedSignature = method.getSignature(); } else { fResolvedSignature = ToggleBreakpointAdapter.resolveMethodSignature(method.getDeclaringType(), method.getSignature()); } } catch (CoreException e) { JDIDebugUIPlugin.log(e); } }
private void checkMethodReturnTypes(final IProgressMonitor monitor, final RefactoringStatus status, final Set<IMember> notDeletedMembersInSubtypes) throws JavaModelException { final Map<IMember, Set<IMember>> mapping= getMatchingMembers(getDestinationTypeHierarchy(monitor), getDestinationType(), true); final IMember[] members= getCreatedDestinationMembers(); for (int i= 0; i < members.length; i++) { if (members[i].getElementType() != IJavaElement.METHOD) continue; final IMethod method= (IMethod) members[i]; if (mapping.containsKey(method)) { final Set<IMember> set= mapping.get(method); if (set != null) { final String returnType= Signature.toString(Signature.getReturnType(method.getSignature()).toString()); for (final Iterator<IMember> iter= set.iterator(); iter.hasNext();) { final IMethod matchingMethod= (IMethod) iter.next(); if (method.equals(matchingMethod)) continue; if (!notDeletedMembersInSubtypes.contains(matchingMethod)) continue; if (returnType.equals(Signature.toString(Signature.getReturnType(matchingMethod.getSignature()).toString()))) continue; final String[] keys= { JavaElementLabels.getTextLabel(matchingMethod, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(matchingMethod.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}; final String message= Messages.format(RefactoringCoreMessages.PullUpRefactoring_different_method_return_type, keys); final RefactoringStatusContext context= JavaStatusContext.create(matchingMethod.getCompilationUnit(), matchingMethod.getNameRange()); status.addError(message, context); } } } } }
private void checkMethodReturnTypes(final IProgressMonitor monitor, final RefactoringStatus status, final Set notDeletedMembersInSubtypes) throws JavaModelException { final Map mapping= getMatchingMembers(getDestinationTypeHierarchy(monitor), getDestinationType(), true); final IMember[] members= getCreatedDestinationMembers(); for (int i= 0; i < members.length; i++) { if (members[i].getElementType() != IJavaElement.METHOD) continue; final IMethod method= (IMethod) members[i]; if (mapping.containsKey(method)) { final Set set= (Set) mapping.get(method); if (set != null) { final String returnType= Signature.toString(Signature.getReturnType(method.getSignature()).toString()); for (final Iterator iter= set.iterator(); iter.hasNext();) { final IMethod matchingMethod= (IMethod) iter.next(); if (method.equals(matchingMethod)) continue; if (!notDeletedMembersInSubtypes.contains(matchingMethod)) continue; if (returnType.equals(Signature.toString(Signature.getReturnType(matchingMethod.getSignature()).toString()))) continue; final String[] keys= { JavaElementLabels.getTextLabel(matchingMethod, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(matchingMethod.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}; final String message= Messages.format(RefactoringCoreMessages.PullUpRefactoring_different_method_return_type, keys); final RefactoringStatusContext context= JavaStatusContext.create(matchingMethod.getCompilationUnit(), matchingMethod.getNameRange()); status.addError(message, context); } } } } }
String signature= method.getSignature();
public static String createMethodSignature(IMethod method){ try { return BasicElementLabels.getJavaElementName(Signature.toString(method.getSignature(), method.getElementName(), method.getParameterNames(), false, ! method.isConstructor())); } catch(JavaModelException e) { return BasicElementLabels.getJavaElementName(method.getElementName()); //fallback } }
public static String createMethodSignature(IMethod method){ try { return BasicElementLabels.getJavaElementName(Signature.toString(method.getSignature(), method.getElementName(), method.getParameterNames(), false, ! method.isConstructor())); } catch(JavaModelException e) { return BasicElementLabels.getJavaElementName(method.getElementName()); //fallback } }
public static String createMethodSignature(IMethod method){ try { return BasicElementLabels.getJavaElementName(Signature.toString(method.getSignature(), method.getElementName(), method.getParameterNames(), false, ! method.isConstructor())); } catch(JavaModelException e) { return BasicElementLabels.getJavaElementName(method.getElementName()); //fallback } }
/** * Creates a new change signature refactoring. * @param method the method, or <code>null</code> if invoked by scripting framework * @throws JavaModelException if something's wrong with the given method */ public ChangeSignatureProcessor(IMethod method) throws JavaModelException { fMethod= method; fOldVarargIndex= -1; fDelegateUpdating= false; fDelegateDeprecation= true; if (fMethod != null) { fParameterInfos= createParameterInfoList(method); // fExceptionInfos is created in checkInitialConditions fReturnTypeInfo= new ReturnTypeInfo(Signature.toString(Signature.getReturnType(fMethod.getSignature()))); fMethodName= fMethod.getElementName(); fVisibility= JdtFlags.getVisibilityCode(fMethod); } }
/** * Creates a new change signature refactoring. * @param method the method, or <code>null</code> if invoked by scripting framework * @throws JavaModelException */ public ChangeSignatureRefactoring(IMethod method) throws JavaModelException { fMethod= method; fOldVarargIndex= -1; fDelegateUpdating= false; fDelegateDeprecation= true; if (fMethod != null) { fParameterInfos= createParameterInfoList(method); // fExceptionInfos is created in checkInitialConditions fReturnTypeInfo= new ReturnTypeInfo(Signature.toString(Signature.getReturnType(fMethod.getSignature()))); fMethodName= fMethod.getElementName(); fVisibility= JdtFlags.getVisibilityCode(fMethod); } }
/** * Creates a new change signature refactoring. * @param method the method, or <code>null</code> if invoked by scripting framework * @throws JavaModelException if something's wrong with the given method */ public ChangeSignatureProcessor(IMethod method) throws JavaModelException { fMethod= method; fOldVarargIndex= -1; fDelegateUpdating= false; fDelegateDeprecation= true; if (fMethod != null) { fParameterInfos= createParameterInfoList(method); // fExceptionInfos is created in checkInitialConditions fReturnTypeInfo= new ReturnTypeInfo(Signature.toString(Signature.getReturnType(fMethod.getSignature()))); fMethodName= fMethod.getElementName(); fVisibility= JdtFlags.getVisibilityCode(fMethod); } }
if (paramTypes.length == otherParams.length - syntheticParameterCorrection) { fFallbackMatch= method; String signature= method.getSignature();
if (paramTypes.length == otherParams.length - syntheticParameterCorrection) { fFallbackMatch= method; String signature= method.getSignature();
public void run() { String methodName = null; try { methodName = Signature.toString(getMethod().getSignature(), getMethod().getElementName(), getMethod().getParameterNames(), false, false); } catch (JavaModelException e) { methodName = getMethod().getElementName(); } new MessageDialog(JDIDebugUIPlugin.getActiveWorkbenchShell(), ActionMessages.StepIntoSelectionHandler_1, null, MessageFormat.format(ActionMessages.StepIntoSelectionHandler_Execution_did_not_enter____0____before_the_current_method_returned__1, new String[]{methodName}), MessageDialog.INFORMATION, new String[] {ActionMessages.StepIntoSelectionHandler_2}, 0).open(); } };
public Change perform(IProgressMonitor pm) throws CoreException { Map map = new HashMap(); BreakpointUtils.addJavaBreakpointAttributes(map, fDestMethod); IResource resource = BreakpointUtils.getBreakpointResource(fDestMethod); int range[] = getNewLineNumberAndRange(fDestMethod); IJavaMethodBreakpoint breakpoint = JDIDebugModel.createMethodBreakpoint( resource, fDestMethod.getDeclaringType().getFullyQualifiedName(), fDestMethod.getElementName(), fDestMethod.getSignature(), isEntry(), isExit(), isNativeOnly(), range[0], range[1], range[2], getHitCount(), true, map); apply(breakpoint); getOriginalBreakpoint().delete(); return new DeleteBreakpointChange(breakpoint); }
String methodSignature = methods[i].getSignature(); addPackages(Signature.getThrownExceptionTypes(methodSignature), pkgs, type, binary, subMonitor.split(1));