diff --git a/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java b/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java index c7dab65..9e44133 100644 --- a/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java +++ b/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java @@ -326,9 +326,6 @@ var i = (invocationsIterator.next()).getKey().equals(resourceName); if (invocations.size() > 1 && i) { - var entityStatement = ""; - var formStatement = ""; - var resultStatement = ""; for (Statement st : (List) invocationsIterator.next().getValue()) { ASTNode[] n = new ASTNode[1]; st.accept(new ASTVisitor() { @@ -367,7 +364,73 @@ } } + /** + * �����Ƃ��ēn���ꂽMethodDeclaration�̃��\�b�h�{�f�B���ɂ���PUT���\�b�h�̌Ăяo�����擾���郁�\�b�h + * + * @param md + * @return + */ + private LinkedHashMap> getPutMethodInvocations(MethodDeclaration md){ + LinkedHashMap> invocations = new LinkedHashMap<>(); + List statements = new ArrayList<>(); + boolean[] isRegistering = new boolean[1]; + for (var st : md.getBody().statements()) { + Statement statement = (Statement) st; + + statement.accept(new ASTVisitor() { + + @Override + public boolean visit(VariableDeclarationStatement node) { + if (node.getType().toString().equals("Form")) { + startRegister(); + } + if (node.getType().toString().equals("String")) { + if (((VariableDeclarationFragment) node.fragments().get(0)).getName().toString() + .equals("result")) { + + MethodInvocation right = (MethodInvocation) ((VariableDeclarationFragment) node + .fragments().get(0)).getInitializer(); + String resourceName = ((MethodInvocation) ((MethodInvocation) right.getExpression()) + .getExpression()).arguments().get(0).toString(); + stopRegister(resourceName); + } + } + return super.visit(node); + } + + @Override + public boolean visit(Assignment node) { + if (node.getLeftHandSide().toString().equals("form")) { + startRegister(); + } + if (node.getLeftHandSide().toString().equals("result")) { + MethodInvocation right = (MethodInvocation) node.getRightHandSide(); + String resourceName = ((MethodInvocation) ((MethodInvocation) right.getExpression()) + .getExpression()).arguments().get(0).toString(); + stopRegister(resourceName); + } + return super.visit(node); + } + + private void startRegister() { + isRegistering[0] = true; + + statements.clear(); + } + + private void stopRegister(String resourceName) { + statements.add(statement); + invocations.put(resourceName, List.copyOf(statements)); + isRegistering[0] = false; + } + }); + if (isRegistering[0]) { + statements.add(statement); + } + } + return invocations; + } public MethodDeclaration[] searchMethodDeclarations(CompilationUnit cu, String annotationName, String... values) { List result = new ArrayList(); cu.accept(new ASTVisitor() { @@ -496,6 +559,10 @@ // Handling �N���X�� updateAvailable() ���\�b�h�� updateRequest() ���\�b�h�̍Ō�ɁCShipping �N���X�� // updateHandling() ���\�b�h���t�B�[���h value �������Ƃ��ēn���ČĂяo���s��lj�����D + for(var update : messages) { + + } + var dstDec = new TypeDeclaration[1]; descriptor.getDistinationClass().accept(new ASTVisitor() {