diff --git a/src/org/ntlab/pushPullRefactoring/PushPullDescriptor.java b/src/org/ntlab/pushPullRefactoring/PushPullDescriptor.java index fd8b275..509e2a1 100644 --- a/src/org/ntlab/pushPullRefactoring/PushPullDescriptor.java +++ b/src/org/ntlab/pushPullRefactoring/PushPullDescriptor.java @@ -13,6 +13,14 @@ private boolean isPushToPull; + public boolean isPushToPull() { + return isPushToPull; + } + + public void setPushToPull(boolean isPushToPull) { + this.isPushToPull = isPushToPull; + } + protected PushPullDescriptor() { super(PushPullRefactoring.ID); } diff --git a/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java b/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java index 95250ef..f214d31 100644 --- a/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java +++ b/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java @@ -252,6 +252,12 @@ return result; } + private void changePush2Pull(IProgressMonitor pm) { + + } +private void changePull2Push(IProgressMonitor pm) { + + } private Change createPushPullChanges() { // TODO Auto-generated method stub SearchPattern pattern = createSearchPattern(); diff --git a/src/org/ntlab/pushPullRefactoring/PushPullRefactoringHandler.java b/src/org/ntlab/pushPullRefactoring/PushPullRefactoringHandler.java index 8bf19c6..249b400 100644 --- a/src/org/ntlab/pushPullRefactoring/PushPullRefactoringHandler.java +++ b/src/org/ntlab/pushPullRefactoring/PushPullRefactoringHandler.java @@ -21,9 +21,11 @@ import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.ASTVisitor; +import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.FieldDeclaration; import org.eclipse.jdt.core.dom.SimpleType; +import org.eclipse.jdt.core.dom.SingleMemberAnnotation; import org.eclipse.jdt.core.dom.VariableDeclarationFragment; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; @@ -75,7 +77,19 @@ CompilationUnit srcNode = (CompilationUnit) getASTNode(targetField.getCompilationUnit()); srcNode.accept(new ASTVisitor() { public boolean visit(FieldDeclaration node) { + for(var astNode : node.modifiers()) { + if(astNode instanceof SingleMemberAnnotation) { + SingleMemberAnnotation annotation = (SingleMemberAnnotation)astNode; + String annotationName = ((Annotation)annotation).getTypeName().toString(); + if(annotationName.equals("PushReference")) { + + } + System.out.println( annotation.getValue().toString()); + } + } + for (Object v : node.fragments()) { + node.modifiers(); VariableDeclarationFragment var = (VariableDeclarationFragment) v; if (var.getName().getIdentifier().equals(targetField.getElementName())) { dstNode[0] = ((SimpleType) node.getType()); @@ -85,14 +99,7 @@ return true; } }); - - -// if (targetType == null) { -// return null; -// } -// IType sourceResource; -// String sourceResourceName; - + srcUnit = getSourceCompilationUnit(event); dstUnit = getDistinationCompilationUnit(event, dstNode[0].toString()); @@ -122,22 +129,7 @@ } return null; } - // -// private SourceField getTargetField(ExecutionEvent event) { -// SourceField targetType = null; -// -// try { -// targetType = codeResolve(event); -// } catch (JavaModelException e) { -// return null; -// } -// -// if (!(targetType instanceof IType)) { -// return null; -// } -// -// return targetType; -// } + private SourceField getTargetField(ExecutionEvent event) throws JavaModelException { IEditorInput editorInput = HandlerUtil.getActiveEditorInput(event); @@ -192,6 +184,13 @@ result.recordModifications(); return result; } + private SearchPattern createSearchPattern() { + String pattern = "Resource"; // �A�m�e�[�V������ + int searchFor = IJavaSearchConstants.ANNOTATION_TYPE; + int limitTo = IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE; // �A�m�e�[�V�������g���Ă���ӏ������� + int matchRule = SearchPattern.R_CASE_SENSITIVE; + return SearchPattern.createPattern(pattern, searchFor, limitTo, matchRule); + } private CompilationUnit getDistinationCompilationUnit(ExecutionEvent event, String typeName) throws JavaModelException { IEditorInput editorInput = HandlerUtil.getActiveEditorInput(event); @@ -201,6 +200,7 @@ int matchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH; SearchPattern searchPattern = SearchPattern.createPattern(pattern, searchFor, limitTo, matchRule); + searchPattern = createSearchPattern(); SearchParticipant[] participants = { SearchEngine.getDefaultSearchParticipant() }; IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); @@ -225,29 +225,6 @@ e.printStackTrace(); } - -// if (typeRoot instanceof ICodeAssist) { -// if (typeRoot instanceof ICompilationUnit) { -// -// ((ICompilationUnit) typeRoot).reconcile( -// ICompilationUnit.NO_AST, -// false /* don't force problem detection */, -// null /* use primary owner */, -// null /* no progress monitor */); -// } -// ITextSelection selection = (ITextSelection) HandlerUtil.getActiveMenuSelection(event); -//// ITextSelection selection = (ITextSelection) HandlerUtil.getCurrentSelection(event); -// IJavaElement[] elements = ((ICodeAssist)typeRoot).codeSelect(selection.getOffset() + selection.getLength(), 0); -// if (elements[0] instanceof SourceField) { -// IAnnotation annotation = ((SourceField) elements[0]).getAnnotation("PushReference"); -// IMemberValuePair[] values = annotation.getMemberValuePairs(); -// boolean f = annotation.exists(); -// //�����̒l�� -// ((SourceField) elements[0]).getElementName(); -// -// } -// -// } ASTParser parser = ASTParser.newParser(AST.JLS4); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setResolveBindings(true);