private static TextChange getTextChange(SearchMatch searchResult, TextChangeManager manager) { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); if (cu == null) return null; return manager.get(cu); }
private static TextChange getTextChange(SearchMatch searchResult, TextChangeManager manager) { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); if (cu == null) return null; return manager.get(cu); }
private static TextChange getTextChange(SearchMatch searchResult, TextChangeManager manager) { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); if (cu == null) return null; return manager.get(cu); }
private void addImportRewriteUpdates(TextChangeManager changeManager) throws CoreException { for (Iterator<ICompilationUnit> iter= fImportRewrites.keySet().iterator(); iter.hasNext();) { ICompilationUnit cu= iter.next(); ImportRewrite importRewrite= fImportRewrites.get(cu); if (importRewrite != null && importRewrite.hasRecordedChanges()) { TextChangeCompatibility.addTextEdit(changeManager.get(cu), RefactoringCoreMessages.MoveCuUpdateCreator_update_imports, importRewrite.rewriteImports(null)); } } }
private void addImportRewriteUpdates(TextChangeManager changeManager) throws CoreException { for (Iterator iter= fImportRewrites.keySet().iterator(); iter.hasNext();) { ICompilationUnit cu= (ICompilationUnit) iter.next(); ImportRewrite importRewrite= (ImportRewrite) fImportRewrites.get(cu); if (importRewrite != null && importRewrite.hasRecordedChanges()) { TextChangeCompatibility.addTextEdit(changeManager.get(cu), RefactoringCoreMessages.MoveCuUpdateCreator_update_imports, importRewrite.rewriteImports(null)); } } }
private void createEdits(ICompilationUnit unit, ASTRewrite rewriter, List<TextEditGroup> groups, ImportRewrite importRewrite) throws CoreException { TextChange change= fChangeManager.get(unit); MultiTextEdit root= new MultiTextEdit(); change.setEdit(root); root.addChild(importRewrite.rewriteImports(null)); root.addChild(rewriter.rewriteAST()); for (Iterator<TextEditGroup> iter= groups.iterator(); iter.hasNext();) { change.addTextEditGroup(iter.next()); } }
private void createEdits(ICompilationUnit unit, ASTRewrite rewriter, List<TextEditGroup> groups, ImportRewrite importRewrite) throws CoreException { TextChange change= fChangeManager.get(unit); MultiTextEdit root= new MultiTextEdit(); change.setEdit(root); root.addChild(importRewrite.rewriteImports(null)); root.addChild(rewriter.rewriteAST()); for (Iterator<TextEditGroup> iter= groups.iterator(); iter.hasNext();) { change.addTextEditGroup(iter.next()); } }
private static String getCopiedFileSource(IProgressMonitor monitor, ICompilationUnit unit, String newTypeName) throws CoreException { ICompilationUnit copy= unit.getPrimary().getWorkingCopy(null); try { TextChangeManager manager= createChangeManager(monitor, copy, newTypeName); String result= manager.get(copy).getPreviewContent(new NullProgressMonitor()); return result; } finally { copy.discardWorkingCopy(); } }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
private static String getCopiedFileSource(IProgressMonitor monitor, ICompilationUnit unit, String newTypeName) throws CoreException { ICompilationUnit copy= unit.getPrimary().getWorkingCopy(null); try { TextChangeManager manager= createChangeManager(monitor, copy, newTypeName); String result= manager.get(copy).getPreviewContent(new NullProgressMonitor()); return result; } finally { copy.discardWorkingCopy(); } }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
private static String getCopiedFileSource(IProgressMonitor monitor, ICompilationUnit unit, String newTypeName) throws CoreException { ICompilationUnit copy= unit.getPrimary().getWorkingCopy(null); try { TextChangeManager manager= createChangeManager(monitor, copy, newTypeName); String result= manager.get(copy).getPreviewContent(new NullProgressMonitor()); return result; } finally { copy.discardWorkingCopy(); } }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
private void addTypeDeclarationUpdate(TextChangeManager manager) throws CoreException { String name= RefactoringCoreMessages.RenameTypeRefactoring_update; int typeNameLength= fType.getElementName().length(); ICompilationUnit cu= fType.getCompilationUnit(); TextChangeCompatibility.addTextEdit(manager.get(cu), name, new ReplaceEdit(fType.getNameRange().getOffset(), typeNameLength, getNewElementName())); }
private void addTypeDeclarationUpdate(TextChangeManager manager) throws CoreException { String name= RefactoringCoreMessages.RenameTypeRefactoring_update; int typeNameLength= fType.getElementName().length(); ICompilationUnit cu= fType.getCompilationUnit(); TextChangeCompatibility.addTextEdit(manager.get(cu), name, new ReplaceEdit(fType.getNameRange().getOffset(), typeNameLength, getNewElementName())); }
private void addTypeDeclarationUpdate(TextChangeManager manager) throws CoreException { String name= RefactoringCoreMessages.RenameTypeRefactoring_update; int typeNameLength= fType.getElementName().length(); ICompilationUnit cu= fType.getCompilationUnit(); TextChangeCompatibility.addTextEdit(manager.get(cu), name, new ReplaceEdit(fType.getNameRange().getOffset(), typeNameLength, getNewElementName())); }
private void addDeclarationUpdate() throws CoreException { ISourceRange nameRange= fField.getNameRange(); TextEdit textEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName()); ICompilationUnit cu= fField.getCompilationUnit(); String groupName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration; addTextEdit(fChangeManager.get(cu), groupName, textEdit); }
private void addDeclarationUpdate() throws CoreException { ISourceRange nameRange= fField.getNameRange(); TextEdit textEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName()); ICompilationUnit cu= fField.getCompilationUnit(); String groupName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration; addTextEdit(fChangeManager.get(cu), groupName, textEdit); }
private void addDeclarationUpdate() throws CoreException { ISourceRange nameRange= fField.getNameRange(); TextEdit textEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName()); ICompilationUnit cu= fField.getCompilationUnit(); String groupName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration; addTextEdit(fChangeManager.get(cu), groupName, textEdit); }
private RefactoringStatus checkCompilationofDeclaringCu() throws CoreException { ICompilationUnit cu= getCu(); TextChange change= fChangeManager.get(cu); String newCuSource= change.getPreviewContent(new NullProgressMonitor()); CompilationUnit newCUNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(newCuSource, cu, true, false, null); IProblem[] problems= RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fBaseCuRewrite.getRoot()); RefactoringStatus result= new RefactoringStatus(); for (int i= 0; i < problems.length; i++) { IProblem problem= problems[i]; if (shouldReport(problem, newCUNode)) result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem)))); } return result; }