use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class RenameFieldProcessor method checkAccessorDeclarations.
private RefactoringStatus checkAccessorDeclarations(IProgressMonitor pm, IMethod existingAccessor) throws CoreException {
RefactoringStatus result = new RefactoringStatus();
SearchPattern pattern = SearchPattern.createPattern(existingAccessor, IJavaSearchConstants.DECLARATIONS, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
IJavaSearchScope scope = SearchEngine.createHierarchyScope(fField.getDeclaringType());
SearchResultGroup[] groupDeclarations = RefactoringSearchEngine.search(pattern, scope, pm, result);
Assert.isTrue(groupDeclarations.length > 0);
if (groupDeclarations.length != 1) {
String message = Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_overridden, JavaElementUtil.createMethodSignature(existingAccessor));
result.addError(message);
} else {
SearchResultGroup group = groupDeclarations[0];
Assert.isTrue(group.getSearchResults().length > 0);
if (group.getSearchResults().length != 1) {
String message = Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_overridden_or_overrides, JavaElementUtil.createMethodSignature(existingAccessor));
result.addError(message);
}
}
return result;
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class RenameFieldProcessor method analyzeAffectedCompilationUnits.
/*
* (non java-doc)
* Analyzes all compilation units in which type is referenced
*/
private RefactoringStatus analyzeAffectedCompilationUnits() throws CoreException {
RefactoringStatus result = new RefactoringStatus();
fReferences = Checks.excludeCompilationUnits(fReferences, result);
if (result.hasFatalError())
return result;
result.merge(Checks.checkCompileErrorsInAffectedFiles(fReferences));
return result;
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class RenameFieldProcessor method checkNestedHierarchy.
private RefactoringStatus checkNestedHierarchy(IType type) throws CoreException {
IType[] nestedTypes = type.getTypes();
if (nestedTypes == null)
return null;
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < nestedTypes.length; i++) {
IField otherField = nestedTypes[i].getField(getNewElementName());
if (otherField.exists()) {
String msg = Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_hiding, new String[] { BasicElementLabels.getJavaElementName(fField.getElementName()), BasicElementLabels.getJavaElementName(getNewElementName()), BasicElementLabels.getJavaElementName(nestedTypes[i].getFullyQualifiedName('.')) });
result.addWarning(msg, JavaStatusContext.create(otherField));
}
result.merge(checkNestedHierarchy(nestedTypes[i]));
}
return result;
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class RenameFieldProcessor method checkAccessor.
//----------
private RefactoringStatus checkAccessor(IProgressMonitor pm, IMethod existingAccessor, String newAccessorName) throws CoreException {
RefactoringStatus result = new RefactoringStatus();
result.merge(checkAccessorDeclarations(pm, existingAccessor));
result.merge(checkNewAccessor(existingAccessor, newAccessorName));
return result;
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class RenameFieldProcessor method doCheckFinalConditions.
@Override
protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
try {
//$NON-NLS-1$
pm.beginTask("", 18);
pm.setTaskName(RefactoringCoreMessages.RenameFieldRefactoring_checking);
RefactoringStatus result = new RefactoringStatus();
result.merge(Checks.checkIfCuBroken(fField));
if (result.hasFatalError())
return result;
result.merge(checkNewElementName(getNewElementName()));
pm.worked(1);
result.merge(checkEnclosingHierarchy());
pm.worked(1);
result.merge(checkNestedHierarchy(fField.getDeclaringType()));
pm.worked(1);
if (fUpdateReferences) {
pm.setTaskName(RefactoringCoreMessages.RenameFieldRefactoring_searching);
fReferences = getReferences(new SubProgressMonitor(pm, 3), result);
pm.setTaskName(RefactoringCoreMessages.RenameFieldRefactoring_checking);
} else {
fReferences = new SearchResultGroup[0];
pm.worked(3);
}
if (fUpdateReferences)
result.merge(analyzeAffectedCompilationUnits());
else
Checks.checkCompileErrorsInAffectedFile(result, fField.getResource());
if (getGetter() != null && fRenameGetter) {
result.merge(checkAccessor(new SubProgressMonitor(pm, 1), getGetter(), getNewGetterName()));
result.merge(Checks.checkIfConstructorName(getGetter(), getNewGetterName(), fField.getDeclaringType().getElementName()));
} else {
pm.worked(1);
}
if (getSetter() != null && fRenameSetter) {
result.merge(checkAccessor(new SubProgressMonitor(pm, 1), getSetter(), getNewSetterName()));
result.merge(Checks.checkIfConstructorName(getSetter(), getNewSetterName(), fField.getDeclaringType().getElementName()));
} else {
pm.worked(1);
}
result.merge(createChanges(new SubProgressMonitor(pm, 10)));
if (result.hasFatalError())
return result;
return result;
} finally {
pm.done();
}
}
Aggregations