Skip to content

Commit

Permalink
Fixed the check for unprocessed methods by examining if methodBinding…
Browse files Browse the repository at this point in the history
….getMethodDeclaration().getKey() is contained in the processed methods in addition to methodBinding.getKey()

Based on the documentation of IMethodBinding.getMethodDeclaration()
For parameterized methods (isParameterizedMethod()) and raw methods (isRawMethod()), this method returns the binding for the corresponding generic method.

Updated plug-in version to 5.0.59
  • Loading branch information
tsantalis committed Jun 11, 2016
1 parent 731fc3d commit 09d3f52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JDeodorant Plug-in
Bundle-SymbolicName: gr.uom.java.jdeodorant; singleton:=true
Bundle-Version: 5.0.58
Bundle-Version: 5.0.59
Bundle-Activator: gr.uom.java.jdeodorant.refactoring.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
Expand Down
34 changes: 19 additions & 15 deletions src/gr/uom/java/ast/decomposition/cfg/MethodCallAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,11 @@ private void processArgumentOfInternalMethodInvocation(AbstractMethodDeclaration
ListIterator<MethodObject> methodIterator = subClassObject.getMethodIterator();
while(methodIterator.hasNext()) {
MethodObject subMethod = methodIterator.next();
if(equalSignature(subMethod.getMethodDeclaration().resolveBinding(), superMethodDeclarationBinding)) {
MethodDeclaration subMethodDeclaration = subMethod.getMethodDeclaration();
if(equalSignature(subMethodDeclaration.resolveBinding(), superMethodDeclarationBinding)) {
ParameterObject parameterObject = subMethod.getParameter(initialArgumentPosition);
VariableDeclaration parameterDeclaration2 = parameterObject.getSingleVariableDeclaration();
if(!processedMethods.contains(subMethod.getMethodDeclaration().resolveBinding().getKey()))
if(isUnprocessedMethod(processedMethods, subMethodDeclaration.resolveBinding()))
processArgumentOfInternalMethodInvocation(subMethod, argumentDeclaration, initialArgumentPosition, parameterDeclaration2, processedMethods);
break;
}
Expand Down Expand Up @@ -401,7 +402,7 @@ private void processArgumentOfInternalMethodInvocation(AbstractMethodDeclaration
//fix for method calls with varargs
if(parameterObject != null) {
VariableDeclaration parameterDeclaration2 = parameterObject.getSingleVariableDeclaration();
if(!processedMethods.contains(methodInvocation2.resolveMethodBinding().getKey()))
if(isUnprocessedMethod(processedMethods, methodInvocation2.resolveMethodBinding()))
processArgumentOfInternalMethodInvocation(methodObject2, argumentDeclaration, argumentPosition, parameterDeclaration2, processedMethods);
}
}
Expand All @@ -422,7 +423,7 @@ private void processArgumentOfInternalMethodInvocation(AbstractMethodDeclaration
int argumentPosition = getArgumentPosition(superMethodInvocation.arguments(), parameter);
ParameterObject parameterObject = methodObject2.getParameter(argumentPosition);
VariableDeclaration parameterDeclaration2 = parameterObject.getSingleVariableDeclaration();
if(!processedMethods.contains(superMethodInvocation.resolveMethodBinding().getKey()))
if(isUnprocessedMethod(processedMethods, superMethodInvocation.resolveMethodBinding()))
processArgumentOfInternalMethodInvocation(methodObject2, argumentDeclaration, argumentPosition, parameterDeclaration2, processedMethods);
}
}
Expand Down Expand Up @@ -503,7 +504,7 @@ private void processInternalMethodInvocation(ClassObject classObject, AbstractMe
if(methodObject.isAbstract() || classObject.isInterface()) {
AbstractTypeDeclaration typeDeclaration = classObject.getAbstractTypeDeclaration();
IMethodBinding superMethodDeclarationBinding = methodObject.getMethodDeclaration().resolveBinding();
if(!processedMethods.contains(superMethodDeclarationBinding.getKey())) {
if(isUnprocessedMethod(processedMethods, superMethodDeclarationBinding)) {
IType superType = (IType)typeDeclaration.resolveBinding().getJavaElement();
processedMethods.add(superMethodDeclarationBinding.getKey());
Set<IType> subTypes = CompilationUnitCache.getInstance().getSubTypes(superType);
Expand Down Expand Up @@ -589,7 +590,7 @@ private void processInternalMethodInvocation(ClassObject classObject, AbstractMe
if(classObject2 != null) {
MethodObject methodObject2 = classObject2.getMethod(methodInvocationObject);
if(methodObject2 != null) {
if(!processedMethods.contains(methodInvocation2.resolveMethodBinding().getKey()))
if(isUnprocessedMethod(processedMethods, methodInvocation2.resolveMethodBinding()))
processInternalMethodInvocation(classObject2, methodObject2, field, processedMethods);
}
}
Expand All @@ -613,7 +614,7 @@ private void processInternalMethodInvocation(ClassObject classObject, AbstractMe
if(methodObject2 != null) {
if(!methodObject2.equals(methodObject)) {
MethodInvocation methodInvocation2 = methodInvocationObject.getMethodInvocation();
if(!processedMethods.contains(methodInvocation2.resolveMethodBinding().getKey()))
if(isUnprocessedMethod(processedMethods, methodInvocation2.resolveMethodBinding()))
processInternalMethodInvocation(classObject, methodObject2, variableDeclaration, processedMethods);
}
}
Expand All @@ -627,7 +628,7 @@ private void processInternalMethodInvocation(ClassObject classObject, AbstractMe
//the commented code that follows is causing significant performance deterioration. It's time to reconsider the PDG generation strategy
/*
MethodInvocation methodInvocation2 = methodInvocationObject.getMethodInvocation();
if(!processedMethods.contains(methodInvocation2.resolveMethodBinding().getKey()))
if(isUnprocessedMethod(processedMethods, methodInvocation2.resolveMethodBinding()))
processInternalMethodInvocation(classObject2, methodObject2, variableDeclaration, processedMethods);
*/
}
Expand All @@ -640,7 +641,7 @@ private void processInternalMethodInvocation(ClassObject classObject, AbstractMe
MethodObject methodObject2 = classObject2.getMethod(superMethodInvocationObject);
if(methodObject2 != null) {
SuperMethodInvocation superMethodInvocation = superMethodInvocationObject.getSuperMethodInvocation();
if(!processedMethods.contains(superMethodInvocation.resolveMethodBinding().getKey()))
if(isUnprocessedMethod(processedMethods, superMethodInvocation.resolveMethodBinding()))
processInternalMethodInvocation(classObject2, methodObject2, variableDeclaration, processedMethods);
}
}
Expand All @@ -651,7 +652,7 @@ private void processInternalMethodInvocation(ClassObject classObject, AbstractMe
ConstructorObject constructorObject2 = classObject2.getConstructor(constructorInvocationObject);
if(constructorObject2 != null) {
ConstructorInvocation constructorInvocation = constructorInvocationObject.getConstructorInvocation();
if(!processedMethods.contains(constructorInvocation.resolveConstructorBinding().getKey()))
if(isUnprocessedMethod(processedMethods, constructorInvocation.resolveConstructorBinding()))
processInternalMethodInvocation(classObject2, constructorObject2, variableDeclaration, processedMethods);
}
}
Expand All @@ -662,7 +663,7 @@ private void processInternalMethodInvocation(ClassObject classObject, AbstractMe
if(classObject2 != null) {
MethodObject methodObject2 = classObject2.getMethod(staticMethodInvocationObject);
if(methodObject2 != null) {
if(!processedMethods.contains(staticMethodInvocation.resolveMethodBinding().getKey()))
if(isUnprocessedMethod(processedMethods, staticMethodInvocation.resolveMethodBinding()))
processInternalMethodInvocation(classObject2, methodObject2, null, processedMethods);
}
}
Expand Down Expand Up @@ -754,7 +755,7 @@ private void processExternalMethodInvocation(MethodDeclaration methodDeclaration
IMethodBinding methodBinding2 = methodInvocation.resolveMethodBinding();
MethodDeclaration invokedMethodDeclaration = getInvokedMethodDeclaration(methodBinding2);
if(invokedMethodDeclaration != null && !invokedMethodDeclaration.equals(methodDeclaration)) {
if(!processedMethods.contains(methodBinding2.getKey())) {
if(isUnprocessedMethod(processedMethods, methodBinding2)) {
if((invokedMethodDeclaration.getModifiers() & Modifier.NATIVE) != 0) {
//method is native
}
Expand All @@ -775,7 +776,7 @@ private void processExternalMethodInvocation(MethodDeclaration methodDeclaration
IMethodBinding methodBinding2 = methodInvocation.resolveMethodBinding();
MethodDeclaration invokedMethodDeclaration = getInvokedMethodDeclaration(methodBinding2);
if(invokedMethodDeclaration != null && !invokedMethodDeclaration.equals(methodDeclaration)) {
if(!processedMethods.contains(methodBinding2.getKey())) {
if(isUnprocessedMethod(processedMethods, methodBinding2)) {
if((invokedMethodDeclaration.getModifiers() & Modifier.NATIVE) != 0) {
//method is native
}
Expand All @@ -793,7 +794,7 @@ private void processExternalMethodInvocation(MethodDeclaration methodDeclaration
IMethodBinding methodBinding2 = superMethodInvocation.resolveMethodBinding();
MethodDeclaration invokedSuperMethodDeclaration = getInvokedMethodDeclaration(methodBinding2);
if(invokedSuperMethodDeclaration != null) {
if(!processedMethods.contains(methodBinding2.getKey())) {
if(isUnprocessedMethod(processedMethods, methodBinding2)) {
if((invokedSuperMethodDeclaration.getModifiers() & Modifier.NATIVE) != 0) {
//method is native
}
Expand All @@ -810,7 +811,7 @@ private void processExternalMethodInvocation(MethodDeclaration methodDeclaration
IMethodBinding methodBinding2 = methodInvocation.resolveMethodBinding();
MethodDeclaration invokedMethodDeclaration = getInvokedMethodDeclaration(methodBinding2);
if(invokedMethodDeclaration != null && !invokedMethodDeclaration.equals(methodDeclaration)) {
if(!processedMethods.contains(methodBinding2.getKey())) {
if(isUnprocessedMethod(processedMethods, methodBinding2)) {
if((invokedMethodDeclaration.getModifiers() & Modifier.NATIVE) != 0) {
//method is native
}
Expand Down Expand Up @@ -1168,4 +1169,7 @@ private Set<MethodDeclaration> getMatchingMethodDeclarationsForSubType(IMethodBi
return matchingMethodDeclarations;
}

private boolean isUnprocessedMethod(Set<String> processedMethods, IMethodBinding methodBinding) {
return !processedMethods.contains(methodBinding.getKey()) && !processedMethods.contains(methodBinding.getMethodDeclaration().getKey());
}
}

0 comments on commit 09d3f52

Please sign in to comment.