use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class ConvertAnonymousToNestedRefactoring method checkInitialConditions.
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
RefactoringStatus result = Checks.validateModifiesFiles(ResourceUtil.getFiles(new ICompilationUnit[] { fCu }), getValidationContext());
if (result.hasFatalError())
return result;
initAST(pm);
if (fAnonymousInnerClassNode == null)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_place_caret);
if (!fSelfInitializing)
initializeDefaults();
if (getSuperConstructorBinding() == null)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_compile_errors);
if (getSuperTypeBinding().isLocal())
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_extends_local_class);
return new RefactoringStatus();
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class ExtractConstantRefactoring method checkExpression.
private RefactoringStatus checkExpression() throws JavaModelException {
RefactoringStatus result = new RefactoringStatus();
result.merge(checkExpressionBinding());
if (result.hasFatalError())
return result;
checkAllStaticFinal();
IExpressionFragment selectedExpression = getSelectedExpression();
Expression associatedExpression = selectedExpression.getAssociatedExpression();
if (associatedExpression instanceof NullLiteral)
result.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_null_literals));
else if (!ConstantChecks.isLoadTimeConstant(selectedExpression))
result.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_not_load_time_constant));
else if (associatedExpression instanceof SimpleName) {
if (associatedExpression.getParent() instanceof QualifiedName && associatedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || associatedExpression.getParent() instanceof FieldAccess && associatedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_select_expression);
}
return result;
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class ExtractConstantRefactoring method checkSelection.
private RefactoringStatus checkSelection(IProgressMonitor pm) throws JavaModelException {
try {
//$NON-NLS-1$
pm.beginTask("", 2);
IExpressionFragment selectedExpression = getSelectedExpression();
if (selectedExpression == null) {
String message = RefactoringCoreMessages.ExtractConstantRefactoring_select_expression;
return CodeRefactoringUtil.checkMethodSyntaxErrors(fSelectionStart, fSelectionLength, fCuRewrite.getRoot(), message);
}
pm.worked(1);
RefactoringStatus result = new RefactoringStatus();
result.merge(checkExpression());
if (result.hasFatalError())
return result;
pm.worked(1);
return result;
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class ExtractConstantRefactoring method checkFinalConditions.
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
pm.beginTask(RefactoringCoreMessages.ExtractConstantRefactoring_checking_preconditions, 2);
try {
RefactoringStatus result = new RefactoringStatus();
createConstantDeclaration();
replaceExpressionsWithConstant();
fChange = fCuRewrite.createChange(RefactoringCoreMessages.ExtractConstantRefactoring_change_name, true, new SubProgressMonitor(pm, 1));
if (fCheckResultForCompileProblems) {
checkSource(new SubProgressMonitor(pm, 1), result);
}
return result;
} finally {
fConstantTypeCache = null;
fCuRewrite.clearASTAndImportRewrites();
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringStatus in project che by eclipse.
the class TypeContextChecker method checkParameterTypeSyntax.
public static RefactoringStatus checkParameterTypeSyntax(String type, IJavaProject project) {
String newTypeName = ParameterInfo.stripEllipsis(type.trim()).trim();
String typeLabel = BasicElementLabels.getJavaElementName(type);
if ("".equals(newTypeName.trim())) {
//$NON-NLS-1$
String msg = Messages.format(RefactoringCoreMessages.TypeContextChecker_parameter_type, typeLabel);
return RefactoringStatus.createFatalErrorStatus(msg);
}
if (ParameterInfo.isVarargs(type) && !JavaModelUtil.is50OrHigher(project)) {
String msg = Messages.format(RefactoringCoreMessages.TypeContextChecker_no_vararg_below_50, typeLabel);
return RefactoringStatus.createFatalErrorStatus(msg);
}
List<String> problemsCollector = new ArrayList<String>(0);
Type parsedType = parseType(newTypeName, project, problemsCollector);
boolean valid = parsedType != null;
if (valid && parsedType instanceof PrimitiveType)
valid = !PrimitiveType.VOID.equals(((PrimitiveType) parsedType).getPrimitiveTypeCode());
if (!valid) {
String msg = Messages.format(RefactoringCoreMessages.TypeContextChecker_invalid_type_name, BasicElementLabels.getJavaElementName(newTypeName));
return RefactoringStatus.createFatalErrorStatus(msg);
}
if (problemsCollector.size() == 0)
return null;
RefactoringStatus result = new RefactoringStatus();
for (Iterator<String> iter = problemsCollector.iterator(); iter.hasNext(); ) {
String msg = Messages.format(RefactoringCoreMessages.TypeContextChecker_invalid_type_syntax, new String[] { BasicElementLabels.getJavaElementName(newTypeName), BasicElementLabels.getJavaElementName(iter.next()) });
result.addError(msg);
}
return result;
}
Aggregations