use of org.eclipse.ltk.core.refactoring.RefactoringStatusContext in project che by eclipse.
the class RenameNonVirtualMethodProcessor method doCheckFinalConditions.
//----------- preconditions --------------
@Override
protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext checkContext) throws CoreException {
try {
//$NON-NLS-1$
pm.beginTask("", 3);
RefactoringStatus result = new RefactoringStatus();
result.merge(super.doCheckFinalConditions(new SubProgressMonitor(pm, 1), checkContext));
if (result.hasFatalError())
return result;
final IMethod method = getMethod();
final IType declaring = method.getDeclaringType();
final String name = getNewElementName();
IMethod[] hierarchyMethods = hierarchyDeclaresMethodName(new SubProgressMonitor(pm, 1), declaring.newTypeHierarchy(new SubProgressMonitor(pm, 1)), method, name);
for (int i = 0; i < hierarchyMethods.length; i++) {
IMethod hierarchyMethod = hierarchyMethods[i];
RefactoringStatusContext context = JavaStatusContext.create(hierarchyMethod);
if (Checks.compareParamTypes(method.getParameterTypes(), hierarchyMethod.getParameterTypes())) {
String message = Messages.format(RefactoringCoreMessages.RenamePrivateMethodRefactoring_hierarchy_defines, new String[] { BasicElementLabels.getJavaElementName(declaring.getFullyQualifiedName('.')), BasicElementLabels.getJavaElementName(name) });
result.addError(message, context);
} else {
String message = Messages.format(RefactoringCoreMessages.RenamePrivateMethodRefactoring_hierarchy_defines2, new String[] { BasicElementLabels.getJavaElementName(declaring.getFullyQualifiedName('.')), BasicElementLabels.getJavaElementName(name) });
result.addWarning(message, context);
}
}
return result;
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatusContext in project che by eclipse.
the class RenameAnalyzeUtil method addReferenceShadowedError.
private static void addReferenceShadowedError(ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
//TODO: should not have to filter declarations:
if (newMatch instanceof MethodDeclarationMatch || newMatch instanceof FieldDeclarationMatch)
return;
ISourceRange range = getOldSourceRange(newMatch);
RefactoringStatusContext context = JavaStatusContext.create(cu, range);
String message = Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_reference_shadowed, new String[] { BasicElementLabels.getFileName(cu), BasicElementLabels.getJavaElementName(newElementName) });
result.addError(message, context);
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatusContext in project che by eclipse.
the class RenameAnalyzeUtil method addShadowsError.
private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) {
//TODO: should not have to filter declarations:
if (oldMatch instanceof MethodDeclarationMatch || oldMatch instanceof FieldDeclarationMatch)
return;
ISourceRange range = new SourceRange(oldMatch.getOffset(), oldMatch.getLength());
RefactoringStatusContext context = JavaStatusContext.create(cu, range);
String message = Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_shadows, BasicElementLabels.getFileName(cu));
result.addError(message, context);
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatusContext in project che by eclipse.
the class ChangeSignatureProcessor method checkInitialConditions.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.Refactoring#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor monitor) throws CoreException {
try {
//$NON-NLS-1$
monitor.beginTask("", 5);
RefactoringStatus result = Checks.checkIfCuBroken(fMethod);
if (result.hasFatalError())
return result;
if (fMethod == null || !fMethod.exists()) {
String message = Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_method_deleted, BasicElementLabels.getFileName(getCu()));
return RefactoringStatus.createFatalErrorStatus(message);
}
if (fMethod.getDeclaringType().isInterface()) {
fTopMethod = MethodChecks.overridesAnotherMethod(fMethod, fMethod.getDeclaringType().newSupertypeHierarchy(new SubProgressMonitor(monitor, 1)));
monitor.worked(1);
} else if (MethodChecks.isVirtual(fMethod)) {
ITypeHierarchy hierarchy = getCachedTypeHierarchy(new SubProgressMonitor(monitor, 1));
fTopMethod = MethodChecks.isDeclaredInInterface(fMethod, hierarchy, new SubProgressMonitor(monitor, 1));
if (fTopMethod == null)
fTopMethod = MethodChecks.overridesAnotherMethod(fMethod, hierarchy);
}
if (fTopMethod == null)
fTopMethod = fMethod;
if (!fTopMethod.equals(fMethod)) {
if (fTopMethod.getDeclaringType().isInterface()) {
RefactoringStatusContext context = JavaStatusContext.create(fTopMethod);
String message = Messages.format(RefactoringCoreMessages.MethodChecks_implements, new String[] { JavaElementUtil.createMethodSignature(fTopMethod), BasicElementLabels.getJavaElementName(fTopMethod.getDeclaringType().getFullyQualifiedName('.')) });
return RefactoringStatus.createStatus(RefactoringStatus.FATAL, message, context, Corext.getPluginId(), RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE, fTopMethod);
} else {
RefactoringStatusContext context = JavaStatusContext.create(fTopMethod);
String message = Messages.format(RefactoringCoreMessages.MethodChecks_overrides, new String[] { JavaElementUtil.createMethodSignature(fTopMethod), BasicElementLabels.getJavaElementName(fTopMethod.getDeclaringType().getFullyQualifiedName('.')) });
return RefactoringStatus.createStatus(RefactoringStatus.FATAL, message, context, Corext.getPluginId(), RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD, fTopMethod);
}
}
if (monitor.isCanceled())
throw new OperationCanceledException();
if (fBaseCuRewrite == null || !fBaseCuRewrite.getCu().equals(getCu())) {
fBaseCuRewrite = new CompilationUnitRewrite(getCu());
fBaseCuRewrite.getASTRewrite().setTargetSourceRangeComputer(new TightSourceRangeComputer());
}
RefactoringStatus[] status = TypeContextChecker.checkMethodTypesSyntax(fMethod, getParameterInfos(), fReturnTypeInfo);
for (int i = 0; i < status.length; i++) {
result.merge(status[i]);
}
monitor.worked(1);
result.merge(createExceptionInfoList());
monitor.worked(1);
return result;
} finally {
monitor.done();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatusContext in project che by eclipse.
the class InlineTempRefactoring method checkAssignments.
private RefactoringStatus checkAssignments(VariableDeclaration decl) {
TempAssignmentFinder assignmentFinder = new TempAssignmentFinder(decl);
getASTRoot().accept(assignmentFinder);
if (!assignmentFinder.hasAssignments())
return new RefactoringStatus();
ASTNode firstAssignment = assignmentFinder.getFirstAssignment();
int start = firstAssignment.getStartPosition();
int length = firstAssignment.getLength();
ISourceRange range = new SourceRange(start, length);
RefactoringStatusContext context = JavaStatusContext.create(fCu, range);
String message = Messages.format(RefactoringCoreMessages.InlineTempRefactoring_assigned_more_once, BasicElementLabels.getJavaElementName(decl.getName().getIdentifier()));
return RefactoringStatus.createFatalErrorStatus(message, context);
}
Aggregations