Move Field: Issue with package name
seyyedaliayati opened this issue · 1 comments
seyyedaliayati commented
Describe the bug
Cannot move fields in classes that don't belong to a package! As you know in Java classes in "src" folder don't need to have a package name! The problem is that I couldn't move field in those classes!
Consider this example:
src/SourceClass.java:
public class SourceClass {
private int field_for_move = 33;
public int getFieldForMove(){
return this.field_for_move;
}
public void method_for_move(){
System.out.println("SourceClass.method_for_move()");
}
}
src/TargetClass.java:
public class TargetClass {
}
Error Print
Traceback (most recent call last):
File "/home/ali/Documents/dev/CodART/refactorings/move_field.py", line 256, in __get_usage
source_class, target_class, field = self.get_metadata(program)
File "/home/ali/Documents/dev/CodART/refactorings/move_field.py", line 36, in get_metadata
target_class = program.packages[self.target_package_name].classes[self.target_class_name]
KeyError: 'TargetClass'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ali/Documents/dev/CodART/refactorings/move_field.py", line 450, in <module>
refac = refactoring.move()
File "/home/ali/Documents/dev/CodART/refactorings/move_field.py", line 330, in move
usages, program = self.__get_usage()
File "/home/ali/Documents/dev/CodART/refactorings/move_field.py", line 258, in __get_usage
raise UnResolvedMetaError("Source or destination not found!")
__main__.UnResolvedMetaError: Source or destination not found!
File Path
refactorings/move_field.py
seyyedaliayati commented
Fixed in 47cd973