Skip to content

Commit

Permalink
Fix for issue #72
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Dec 29, 2019
1 parent 5b5535c commit 5c45e7d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 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.74
Bundle-Version: 5.0.75
Bundle-Activator: gr.uom.java.jdeodorant.refactoring.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ private void findPassedParameters() {
if((variable2.getVariableName().equals(variable1.getVariableName()) ||
variable1.getVariableName().equals(renamedVariableName)) &&
(variable2.getVariableType().equals(variable1.getVariableType()) ||
variableBinding1 != null && variableBinding2 != null && ASTNodeMatcher.commonSuperType(variableBinding1.getType(), variableBinding2.getType()) != null)) {
commonSuperType(variableBinding1, variableBinding2))) {
sortedVariables2.add(variable2);
break;
}
Expand Down Expand Up @@ -671,6 +671,45 @@ private void findPassedParameters() {
}
}

private boolean commonSuperType(IVariableBinding variableBinding1, IVariableBinding variableBinding2) {
if(variableBinding1 != null && variableBinding2 != null) {
ITypeBinding typeBinding1 = variableBinding1.getType();
ITypeBinding typeBinding2 = variableBinding2.getType();
ITypeBinding commonSuperTypeBinding = ASTNodeMatcher.commonSuperType(typeBinding1, typeBinding2);
if(commonSuperTypeBinding != null) {
return true;
}
else if(typeBinding1.getQualifiedName().equals("java.lang.Number") && isNumberPrimitiveType(typeBinding2)) {
return true;
}
else if(isNumberPrimitiveType(typeBinding1) && typeBinding2.getQualifiedName().equals("java.lang.Number")) {
return true;
}
else if(typeBinding1.getName().equals("float") && typeBinding2.getName().equals("double")) {
return true;
}
else if(typeBinding1.getName().equals("double") && typeBinding2.getName().equals("float")) {
return true;
}
else if(typeBinding1.getName().equals("int") && typeBinding2.getName().equals("byte")) {
return true;
}
else if(typeBinding1.getName().equals("byte") && typeBinding2.getName().equals("int")) {
return true;
}
}
return false;
}

private static boolean isNumberPrimitiveType(ITypeBinding typeBinding) {
if(typeBinding.isPrimitive()) {
String name = typeBinding.getQualifiedName();
if(name.equals("byte") || name.equals("double") || name.equals("float") || name.equals("int") || name.equals("long") || name.equals("short"))
return true;
}
return false;
}

private VariableBindingKeyPair commonPassedParametersAlreadyContainOneOfTheKeys(VariableBindingKeyPair keyPair) {
for(VariableBindingKeyPair key : commonPassedParameters.keySet()) {
if(key.getKey1().equals(keyPair.getKey1()) || key.getKey2().equals(keyPair.getKey2())) {
Expand Down

0 comments on commit 5c45e7d

Please sign in to comment.