本文整理汇总了Java中org.eclipse.ltk.core.refactoring.RefactoringStatus.hasError方法的典型用法代码示例。如果您正苦于以下问题:Java RefactoringStatus.hasError方法的具体用法?Java RefactoringStatus.hasError怎么用?Java RefactoringStatus.hasError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ltk.core.refactoring.RefactoringStatus
的用法示例。
在下文中一共展示了RefactoringStatus.hasError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRefactoring
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
* Creates a refactoring (or returns a previously created refactoring).
*/
public Refactoring createRefactoring() throws RefactoringException {
if (refactoring != null) {
return refactoring;
}
RefactoringStatus status = new RefactoringStatus();
D descriptor = createDescriptor();
try {
refactoring = descriptor.createRefactoring(status);
} catch (CoreException e) {
throw new RefactoringException(e);
}
if (refactoring == null) {
throw new RefactoringException(
String.format(
"The refactoring descriptor (%s) was unable to create a refactoring.",
descriptor.getClass().getSimpleName()));
}
if (status.hasError()) {
throw new RefactoringException(
status.getMessageMatchingSeverity(RefactoringStatus.ERROR));
}
return refactoring;
}
示例2: analyzeLocalRenames
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的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;
}
示例3: updateTargetVisibility
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus updateTargetVisibility(IProgressMonitor monitor)
throws JavaModelException, CoreException {
RefactoringStatus result = new RefactoringStatus();
// Adjust the visibility of the method and of the referenced type. Note that
// the target method may not be in the target type; and in this case, the type
// of the target method does not need a visibility adjustment.
// This method is called after all other changes have been
// created. Changes induced by this method will be attached to those changes.
result.merge(
adjustVisibility(
(IType) fIntermediaryFirstParameterType.getJavaElement(), fIntermediaryType, monitor));
if (result.hasError()) return result; // binary
ModifierKeyword neededVisibility = getNeededVisibility(fTargetMethod, fIntermediaryType);
if (neededVisibility != null) {
result.merge(adjustVisibility(fTargetMethod, neededVisibility, monitor));
if (result.hasError()) return result; // binary
// Need to adjust the overridden methods of the target method.
ITypeHierarchy hierarchy = fTargetMethod.getDeclaringType().newTypeHierarchy(null);
MethodOverrideTester tester =
new MethodOverrideTester(fTargetMethod.getDeclaringType(), hierarchy);
IType[] subtypes = hierarchy.getAllSubtypes(fTargetMethod.getDeclaringType());
for (int i = 0; i < subtypes.length; i++) {
IMethod method = tester.findOverridingMethodInType(subtypes[i], fTargetMethod);
if (method != null && method.exists()) {
result.merge(adjustVisibility(method, neededVisibility, monitor));
if (monitor.isCanceled()) throw new OperationCanceledException();
if (result.hasError()) return result; // binary
}
}
}
return result;
}