本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers类的典型用法代码示例。如果您正苦于以下问题:Java RefactoringFileBuffers类的具体用法?Java RefactoringFileBuffers怎么用?Java RefactoringFileBuffers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RefactoringFileBuffers类属于org.eclipse.jdt.internal.corext.refactoring.util包,在下文中一共展示了RefactoringFileBuffers类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTextEditFromRewrite
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
private static TextChange addTextEditFromRewrite(
TextChangeManager manager, ICompilationUnit cu, ASTRewrite rewrite) throws CoreException {
try {
ITextFileBuffer buffer = RefactoringFileBuffers.acquire(cu);
TextEdit resultingEdits =
rewrite.rewriteAST(buffer.getDocument(), cu.getJavaProject().getOptions(true));
TextChange textChange = manager.get(cu);
if (textChange instanceof TextFileChange) {
TextFileChange tfc = (TextFileChange) textChange;
tfc.setSaveMode(TextFileChange.KEEP_SAVE_STATE);
}
String message = RefactoringCoreMessages.DeleteChangeCreator_1;
TextChangeCompatibility.addTextEdit(textChange, message, resultingEdits);
return textChange;
} finally {
RefactoringFileBuffers.release(cu);
}
}
示例2: addTextEditFromRewrite
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
private static TextChange addTextEditFromRewrite(TextChangeManager manager, ICompilationUnit cu, ASTRewrite rewrite) throws CoreException {
try {
ITextFileBuffer buffer= RefactoringFileBuffers.acquire(cu);
TextEdit resultingEdits= rewrite.rewriteAST(buffer.getDocument(), cu.getJavaProject().getOptions(true));
TextChange textChange= manager.get(cu);
if (textChange instanceof TextFileChange) {
TextFileChange tfc= (TextFileChange) textChange;
tfc.setSaveMode(TextFileChange.KEEP_SAVE_STATE);
}
String message= RefactoringCoreMessages.DeleteChangeCreator_1;
TextChangeCompatibility.addTextEdit(textChange, message, resultingEdits);
return textChange;
} finally {
RefactoringFileBuffers.release(cu);
}
}
示例3: CallInliner
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
public CallInliner(ICompilationUnit unit, CompilationUnit targetAstRoot, SourceProvider provider)
throws CoreException {
super();
fCUnit = unit;
fBuffer = RefactoringFileBuffers.acquire(fCUnit);
fSourceProvider = provider;
fImportRewrite = StubUtility.createImportRewrite(targetAstRoot, true);
fLocals = new ArrayList<VariableDeclarationStatement>(3);
fRewrite = ASTRewrite.create(targetAstRoot.getAST());
fRewrite.setTargetSourceRangeComputer(new NoCommentSourceRangeComputer());
fTypeEnvironment = new TypeEnvironment();
}
示例4: dispose
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
public void dispose() {
try {
RefactoringFileBuffers.release(fCUnit);
} catch (CoreException exception) {
JavaPlugin.log(exception);
}
}
示例5: CallInliner
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
public CallInliner(ICompilationUnit unit, CompilationUnit targetAstRoot, SourceProvider provider) throws CoreException {
super();
fCUnit= unit;
fBuffer= RefactoringFileBuffers.acquire(fCUnit);
fSourceProvider= provider;
fImportRewrite= StubUtility.createImportRewrite(targetAstRoot, true);
fLocals= new ArrayList<VariableDeclarationStatement>(3);
fRewrite= ASTRewrite.create(targetAstRoot.getAST());
fRewrite.setTargetSourceRangeComputer(new NoCommentSourceRangeComputer());
fTypeEnvironment= new TypeEnvironment();
}
示例6: dispose
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
public void dispose() {
try {
RefactoringFileBuffers.release(fCUnit);
} catch (CoreException exception) {
JavaPlugin.log(exception);
}
}
示例7: createChange
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
ASTParser p= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
p.setSource(getDestinationCu());
CompilationUnit cuNode= (CompilationUnit) p.createAST(pm);
ASTRewrite rewrite= ASTRewrite.create(cuNode.getAST());
TypedSource source= null;
for (int i= fSources.length - 1; i >= 0; i--) {
source= fSources[i];
final ASTNode destination= getDestinationNodeForSourceElement(fDestination, source.getType(), cuNode);
if (destination != null) {
if (destination instanceof CompilationUnit)
insertToCu(rewrite, createNewNodeToInsertToCu(source, rewrite), (CompilationUnit) destination);
else if (destination instanceof AbstractTypeDeclaration)
insertToType(rewrite, createNewNodeToInsertToType(source, rewrite), (AbstractTypeDeclaration) destination);
}
}
final CompilationUnitChange result= new CompilationUnitChange(ReorgMessages.PasteAction_change_name, getDestinationCu());
try {
ITextFileBuffer buffer= RefactoringFileBuffers.acquire(getDestinationCu());
TextEdit rootEdit= rewrite.rewriteAST(buffer.getDocument(), fDestination.getJavaProject().getOptions(true));
if (getDestinationCu().isWorkingCopy())
result.setSaveMode(TextFileChange.LEAVE_DIRTY);
TextChangeCompatibility.addTextEdit(result, ReorgMessages.PasteAction_edit_name, rootEdit);
} finally {
RefactoringFileBuffers.release(getDestinationCu());
}
return result;
}
示例8: replaceParameterWithExpression
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
private void replaceParameterWithExpression(
ASTRewrite rewriter, CallContext context, ImportRewrite importRewrite) throws CoreException {
Expression[] arguments = context.arguments;
try {
ITextFileBuffer buffer = RefactoringFileBuffers.acquire(context.compilationUnit);
for (int i = 0; i < arguments.length; i++) {
Expression expression = arguments[i];
String expressionString = null;
if (expression instanceof SimpleName) {
expressionString = ((SimpleName) expression).getIdentifier();
} else {
try {
expressionString =
buffer.getDocument().get(expression.getStartPosition(), expression.getLength());
} catch (BadLocationException exception) {
JavaPlugin.log(exception);
continue;
}
}
ParameterData parameter = getParameterData(i);
List<SimpleName> references = parameter.references();
for (Iterator<SimpleName> iter = references.iterator(); iter.hasNext(); ) {
ASTNode element = iter.next();
Expression newExpression =
(Expression)
rewriter.createStringPlaceholder(expressionString, expression.getNodeType());
AST ast = rewriter.getAST();
ITypeBinding explicitCast = ASTNodes.getExplicitCast(expression, (Expression) element);
if (explicitCast != null) {
CastExpression cast = ast.newCastExpression();
if (NecessaryParenthesesChecker.needsParentheses(
expression, cast, CastExpression.EXPRESSION_PROPERTY)) {
newExpression = createParenthesizedExpression(newExpression, ast);
}
cast.setExpression(newExpression);
ImportRewriteContext importRewriteContext =
new ContextSensitiveImportRewriteContext(expression, importRewrite);
cast.setType(importRewrite.addImport(explicitCast, ast, importRewriteContext));
expression = newExpression = cast;
}
if (NecessaryParenthesesChecker.needsParentheses(
expression, element.getParent(), element.getLocationInParent())) {
newExpression = createParenthesizedExpression(newExpression, ast);
}
rewriter.replace(element, newExpression, null);
}
}
} finally {
RefactoringFileBuffers.release(context.compilationUnit);
}
}
示例9: replaceParameterWithExpression
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringFileBuffers; //导入依赖的package包/类
private void replaceParameterWithExpression(ASTRewrite rewriter, CallContext context, ImportRewrite importRewrite) throws CoreException {
Expression[] arguments= context.arguments;
try {
ITextFileBuffer buffer= RefactoringFileBuffers.acquire(context.compilationUnit);
for (int i= 0; i < arguments.length; i++) {
Expression expression= arguments[i];
String expressionString= null;
if (expression instanceof SimpleName) {
expressionString= ((SimpleName)expression).getIdentifier();
} else {
try {
expressionString= buffer.getDocument().get(expression.getStartPosition(), expression.getLength());
} catch (BadLocationException exception) {
JavaPlugin.log(exception);
continue;
}
}
ParameterData parameter= getParameterData(i);
List<SimpleName> references= parameter.references();
for (Iterator<SimpleName> iter= references.iterator(); iter.hasNext();) {
ASTNode element= iter.next();
Expression newExpression= (Expression)rewriter.createStringPlaceholder(expressionString, expression.getNodeType());
AST ast= rewriter.getAST();
ITypeBinding explicitCast= ASTNodes.getExplicitCast(expression, (Expression)element);
if (explicitCast != null) {
CastExpression cast= ast.newCastExpression();
if (NecessaryParenthesesChecker.needsParentheses(expression, cast, CastExpression.EXPRESSION_PROPERTY)) {
newExpression= createParenthesizedExpression(newExpression, ast);
}
cast.setExpression(newExpression);
ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(expression, importRewrite);
cast.setType(importRewrite.addImport(explicitCast, ast, importRewriteContext));
expression= newExpression= cast;
}
if (NecessaryParenthesesChecker.needsParentheses(expression, element.getParent(), element.getLocationInParent())) {
newExpression= createParenthesizedExpression(newExpression, ast);
}
rewriter.replace(element, newExpression, null);
}
}
} finally {
RefactoringFileBuffers.release(context.compilationUnit);
}
}