本文整理汇总了Java中org.eclipse.ltk.core.refactoring.TextChange.getPreviewContent方法的典型用法代码示例。如果您正苦于以下问题:Java TextChange.getPreviewContent方法的具体用法?Java TextChange.getPreviewContent怎么用?Java TextChange.getPreviewContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ltk.core.refactoring.TextChange
的用法示例。
在下文中一共展示了TextChange.getPreviewContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCompilationofDeclaringCu
import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
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;
}
示例2: checkCompilationofDeclaringCu
import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
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;
}
示例3: analyzeLocalRenames
import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
/**
* This method analyzes a set of local variable renames inside one cu. It checks whether
* any new compile errors have been introduced by the rename(s) and whether the correct
* node(s) has/have been renamed.
*
* @param analyzePackages the LocalAnalyzePackages containing the information about the local renames
* @param cuChange the TextChange containing all local variable changes to be applied.
* @param oldCUNode the fully (incl. bindings) resolved AST node of the original compilation unit
* @param recovery whether statements and bindings recovery should be performed when parsing the changed CU
* @return a RefactoringStatus containing errors if compile errors or wrongly renamed nodes are found
* @throws CoreException thrown if there was an error greating the preview content of the change
*/
public static RefactoringStatus analyzeLocalRenames(LocalAnalyzePackage[] analyzePackages, TextChange cuChange, CompilationUnit oldCUNode, boolean recovery) throws CoreException {
RefactoringStatus result= new RefactoringStatus();
ICompilationUnit compilationUnit= (ICompilationUnit) oldCUNode.getJavaElement();
String newCuSource= cuChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(newCuSource, compilationUnit, true, recovery, null);
result.merge(analyzeCompileErrors(newCuSource, newCUNode, oldCUNode));
if (result.hasError())
return result;
for (int i= 0; i < analyzePackages.length; i++) {
ASTNode enclosing= getEnclosingBlockOrMethodOrLambda(analyzePackages[i].fDeclarationEdit, cuChange, newCUNode);
// get new declaration
IRegion newRegion= RefactoringAnalyzeUtil.getNewTextRange(analyzePackages[i].fDeclarationEdit, cuChange);
ASTNode newDeclaration= NodeFinder.perform(newCUNode, newRegion.getOffset(), newRegion.getLength());
Assert.isTrue(newDeclaration instanceof Name);
VariableDeclaration declaration= getVariableDeclaration((Name) newDeclaration);
Assert.isNotNull(declaration);
SimpleName[] problemNodes= ProblemNodeFinder.getProblemNodes(enclosing, declaration, analyzePackages[i].fOccurenceEdits, cuChange);
result.merge(RefactoringAnalyzeUtil.reportProblemNodes(newCuSource, problemNodes));
}
return result;
}
示例4: analyzeLocalRenames
import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
/**
* This method analyzes a set of local variable renames inside one cu. It checks whether
* any new compile errors have been introduced by the rename(s) and whether the correct
* node(s) has/have been renamed.
*
* @param analyzePackages the LocalAnalyzePackages containing the information about the local renames
* @param cuChange the TextChange containing all local variable changes to be applied.
* @param oldCUNode the fully (incl. bindings) resolved AST node of the original compilation unit
* @param recovery whether statements and bindings recovery should be performed when parsing the changed CU
* @return a RefactoringStatus containing errors if compile errors or wrongly renamed nodes are found
* @throws CoreException thrown if there was an error greating the preview content of the change
*/
public static RefactoringStatus analyzeLocalRenames(LocalAnalyzePackage[] analyzePackages, TextChange cuChange, CompilationUnit oldCUNode, boolean recovery) throws CoreException {
RefactoringStatus result= new RefactoringStatus();
ICompilationUnit compilationUnit= (ICompilationUnit) oldCUNode.getJavaElement();
String newCuSource= cuChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(newCuSource, compilationUnit, true, recovery, null);
result.merge(analyzeCompileErrors(newCuSource, newCUNode, oldCUNode));
if (result.hasError())
return result;
for (int i= 0; i < analyzePackages.length; i++) {
ASTNode enclosing= getEnclosingBlockOrMethod(analyzePackages[i].fDeclarationEdit, cuChange, newCUNode);
// get new declaration
IRegion newRegion= RefactoringAnalyzeUtil.getNewTextRange(analyzePackages[i].fDeclarationEdit, cuChange);
ASTNode newDeclaration= NodeFinder.perform(newCUNode, newRegion.getOffset(), newRegion.getLength());
Assert.isTrue(newDeclaration instanceof Name);
VariableDeclaration declaration= getVariableDeclaration((Name) newDeclaration);
Assert.isNotNull(declaration);
SimpleName[] problemNodes= ProblemNodeFinder.getProblemNodes(enclosing, declaration, analyzePackages[i].fOccurenceEdits, cuChange);
result.merge(RefactoringAnalyzeUtil.reportProblemNodes(newCuSource, problemNodes));
}
return result;
}
示例5: analyzeLocalRenames
import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
/**
* This method analyzes a set of local variable renames inside one cu. It checks whether any new
* compile errors have been introduced by the rename(s) and whether the correct node(s) has/have
* been renamed.
*
* @param analyzePackages the LocalAnalyzePackages containing the information about the local
* renames
* @param cuChange the TextChange containing all local variable changes to be applied.
* @param oldCUNode the fully (incl. bindings) resolved AST node of the original compilation unit
* @param recovery whether statements and bindings recovery should be performed when parsing the
* changed CU
* @return a RefactoringStatus containing errors if compile errors or wrongly renamed nodes are
* found
* @throws CoreException thrown if there was an error greating the preview content of the change
*/
public static RefactoringStatus analyzeLocalRenames(
LocalAnalyzePackage[] analyzePackages,
TextChange cuChange,
CompilationUnit oldCUNode,
boolean recovery)
throws CoreException {
RefactoringStatus result = new RefactoringStatus();
ICompilationUnit compilationUnit = (ICompilationUnit) oldCUNode.getJavaElement();
String newCuSource = cuChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode =
new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL)
.parse(newCuSource, compilationUnit, true, recovery, null);
result.merge(analyzeCompileErrors(newCuSource, newCUNode, oldCUNode));
if (result.hasError()) return result;
for (int i = 0; i < analyzePackages.length; i++) {
ASTNode enclosing =
getEnclosingBlockOrMethodOrLambda(
analyzePackages[i].fDeclarationEdit, cuChange, newCUNode);
// get new declaration
IRegion newRegion =
RefactoringAnalyzeUtil.getNewTextRange(analyzePackages[i].fDeclarationEdit, cuChange);
ASTNode newDeclaration =
NodeFinder.perform(newCUNode, newRegion.getOffset(), newRegion.getLength());
Assert.isTrue(newDeclaration instanceof Name);
VariableDeclaration declaration = getVariableDeclaration((Name) newDeclaration);
Assert.isNotNull(declaration);
SimpleName[] problemNodes =
ProblemNodeFinder.getProblemNodes(
enclosing, declaration, analyzePackages[i].fOccurenceEdits, cuChange);
result.merge(RefactoringAnalyzeUtil.reportProblemNodes(newCuSource, problemNodes));
}
return result;
}