List of usage examples for org.eclipse.jdt.core.util IMethodInfo getAccessFlags
int getAccessFlags();
From source file:org.eclipse.pde.tools.internal.versioning.JavaClassVersionCompare.java
License:Open Source License
/** * compares two IMethodInfo instances to find any change from <code>method2</code> to <code>method1</code> * /* w w w .ja v a 2 s .c o m*/ * @param className name of class to which <code>method1</code>(and <code>method2</code>) belongs * @param method1 IMethodInfo instance * @param method2 IMethodInfo instance */ private void compareMethodInfos(String className, IMethodInfo method1, IMethodInfo method2) { // compare AccessFlags (AccessFlags defines the modifiers of a method (e.g. public static final compareTo()) int accessFlag1 = method1.getAccessFlags(); int accessFlag2 = method2.getAccessFlags(); // we just care about field who was public or protected if (!(Flags.isPublic(accessFlag2) || Flags.isProtected(accessFlag2))) return; if (isModifierNarrowed(accessFlag1, accessFlag2)) { // get what modifiers have been changed int change = accessFlag1 ^ accessFlag2; // if the visibility of a method has been narrowed, it is a change should be caught Object[] msg = { METHOD_TITLE, getSignatureString(method1), createChangedModifierString(accessFlag2, change), createChangedModifierString(accessFlag1, change), className }; finalResult.merge(resultStatusHandler(IStatus.INFO, IVersionCompare.CLASS_DETAIL_STATUS | IVersionCompare.MAJOR_CHANGE, NLS.bind(Messages.JavaClassVersionCompare_ModifierChangedMsg, msg), null)); } // compare isDeprecated(if a method has been deprecated) if (method1.isDeprecated() && !method2.isDeprecated()) { Object[] msg = { METHOD_TITLE, getSignatureString(method1), className }; finalResult.merge(resultStatusHandler(IStatus.INFO, IVersionCompare.CLASS_DETAIL_STATUS | IVersionCompare.MICRO_CHANGE, NLS.bind(Messages.JavaClassVersionCompare_deprecatedChangedMsg, msg), null)); } // compare exceptions IExceptionAttribute exceptionAtrributes1 = method1.getExceptionAttribute(); IExceptionAttribute exceptionAtrributes2 = method2.getExceptionAttribute(); checkExceptions(className, getSignatureString(method1), exceptionAtrributes1, exceptionAtrributes2); }
From source file:org.eclipse.pde.tools.internal.versioning.JavaClassVersionCompare.java
License:Open Source License
/** * converts the given object signature to a readable string * @param object IFieldInfo instance of IMethodInfo instance * @return String type signature/*from w w w. j a v a2s . c o m*/ */ private String getSignatureString(Object object) { StringBuffer buffer = new StringBuffer(); if (object instanceof IMethodInfo) { IMethodInfo method = (IMethodInfo) object; buffer.append(Flags.toString(method.getAccessFlags())); buffer.append(SPACE); buffer.append(Signature.toString(charsToString(method.getDescriptor()), charsToString(method.getName()), null, false, true)); } else { IFieldInfo field = (IFieldInfo) object; buffer.append(Flags.toString(field.getAccessFlags())); buffer.append(SPACE); buffer.append(Signature.toString(charsToString(field.getDescriptor()))); buffer.append(SPACE); buffer.append(charsToString(field.getName())); } return buffer.toString(); }