本文整理汇总了Java中org.eclipse.ltk.core.refactoring.RefactoringStatus.createFatalErrorStatus方法的典型用法代码示例。如果您正苦于以下问题:Java RefactoringStatus.createFatalErrorStatus方法的具体用法?Java RefactoringStatus.createFatalErrorStatus怎么用?Java RefactoringStatus.createFatalErrorStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ltk.core.refactoring.RefactoringStatus
的用法示例。
在下文中一共展示了RefactoringStatus.createFatalErrorStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkName
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
* Returns a fatal error in case the name is empty. In all other cases, an
* error based on the given status is returned.
*
* @param name
* a name
* @param status
* a status
* @return RefactoringStatus based on the given status or the name, if
* empty.
*/
public static RefactoringStatus checkName(String name, IStatus status) {
RefactoringStatus result = new RefactoringStatus();
if ("".equals(name)) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.Checks_Choose_name);
}
if (status.isOK()) {
return result;
}
switch (status.getSeverity()) {
case IStatus.ERROR:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
case IStatus.WARNING:
return RefactoringStatus.createWarningStatus(status.getMessage());
case IStatus.INFO:
return RefactoringStatus.createInfoStatus(status.getMessage());
default: //no nothing
return new RefactoringStatus();
}
}
示例2: checkTempTypeForLocalTypeUsage
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkTempTypeForLocalTypeUsage() {
VariableDeclarationStatement vds = getTempDeclarationStatement();
if (vds == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_cannot_promote);
Type type = vds.getType();
ITypeBinding binding = type.resolveBinding();
if (binding == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_cannot_promote);
IMethodBinding declaringMethodBinding = getMethodDeclaration().resolveBinding();
ITypeBinding[] methodTypeParameters =
declaringMethodBinding == null
? new ITypeBinding[0]
: declaringMethodBinding.getTypeParameters();
LocalTypeAndVariableUsageAnalyzer analyzer =
new LocalTypeAndVariableUsageAnalyzer(methodTypeParameters);
type.accept(analyzer);
boolean usesLocalTypes = !analyzer.getUsageOfEnclosingNodes().isEmpty();
fTempTypeUsesClassTypeVariables = analyzer.getClassTypeVariablesUsed();
if (usesLocalTypes)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_uses_type_declared_locally);
return null;
}
示例3: checkMethodSyntaxErrors
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public static RefactoringStatus checkMethodSyntaxErrors(
int selectionStart,
int selectionLength,
CompilationUnit cuNode,
String invalidSelectionMessage) {
SelectionAnalyzer analyzer =
new SelectionAnalyzer(
Selection.createFromStartLength(selectionStart, selectionLength), true);
cuNode.accept(analyzer);
ASTNode coveringNode = analyzer.getLastCoveringNode();
if (!(coveringNode instanceof Block)
|| !(coveringNode.getParent() instanceof MethodDeclaration))
return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage);
if (ASTNodes.getMessages(coveringNode, ASTNodes.NODE_ONLY).length == 0)
return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage);
MethodDeclaration methodDecl = (MethodDeclaration) coveringNode.getParent();
String message =
Messages.format(
RefactoringCoreMessages.CodeRefactoringUtil_error_message,
BasicElementLabels.getJavaElementName(methodDecl.getName().getIdentifier()));
return RefactoringStatus.createFatalErrorStatus(message);
}
示例4: verifyDestination
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@Override
protected RefactoringStatus verifyDestination(IResource resource) throws JavaModelException {
Assert.isNotNull(resource);
if (!resource.exists() || resource.isPhantom())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_phantom);
if (!resource.isAccessible())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_inaccessible);
if (resource.getType() == IResource.ROOT)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource);
if (isChildOfOrEqualToAnyFolder(resource))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource);
if (containsLinkedResources() && !ReorgUtils.canBeDestinationForLinkedResources(resource))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReorgPolicyFactory_linked);
return new RefactoringStatus();
}
示例5: checkInitialConditions
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
if (!fMethod.exists()) {
String message =
Messages.format(
RefactoringCoreMessages.RenameMethodRefactoring_deleted,
BasicElementLabels.getFileName(fMethod.getCompilationUnit()));
return RefactoringStatus.createFatalErrorStatus(message);
}
RefactoringStatus result = Checks.checkAvailability(fMethod);
if (result.hasFatalError()) return result;
result.merge(Checks.checkIfCuBroken(fMethod));
if (JdtFlags.isNative(fMethod))
result.addError(RefactoringCoreMessages.RenameMethodRefactoring_no_native);
return result;
}
示例6: workspaceChanged
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public void workspaceChanged() {
long currentTime = System.currentTimeMillis();
if (currentTime - fTimeStamp < LIFE_TIME) return;
fValidationState =
RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.DynamicValidationStateChange_workspace_changed);
// remove listener from workspace tracker
WorkspaceTracker.INSTANCE.removeListener(this);
fListenerRegistered = false;
// clear up the children to not hang onto too much memory
Change[] children = clear();
for (int i = 0; i < children.length; i++) {
final Change change = children[i];
SafeRunner.run(
new ISafeRunnable() {
public void run() throws Exception {
change.dispose();
}
public void handleException(Throwable exception) {
JavaPlugin.log(exception);
}
});
}
}
示例7: checkConditions
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@Override
public RefactoringStatus checkConditions(IProgressMonitor pm,
CheckConditionsContext context) throws OperationCanceledException {
String newName = getArguments().getNewName();
String newExt = newName.substring(newName.lastIndexOf(".")+1);
if("job".equals(modifiedResource.getFileExtension())) {
if(!("job".equals(newExt))) {
return RefactoringStatus.createFatalErrorStatus("Changing extension of job file is not allowed");
}
}
else if("job".equals(newExt)) {
return RefactoringStatus.createFatalErrorStatus("Changing extension to .job not allowed." +
"Please create a new job file.");
}
else if(CustomMessages.ProjectSupport_JOBS.equals(modifiedResource.getFullPath().segment(1))
&& !newExt.matches("job|xml")) {
return RefactoringStatus.createFatalErrorStatus("Only .job and .xml files can be stored in this folder" );
}
else if(modifiedResource.getFileExtension().matches("xml|properties")
|| (newExt.matches("xml|properties"))){
if(ResourceChangeUtil.isGeneratedFile(modifiedResource.getName()
,modifiedResource.getProject())) {
return RefactoringStatus.createFatalErrorStatus(
".xml or .properties file cannot be renamed. " +
"Rename the .job file to rename the xml and properties file");
}
else if(ResourceChangeUtil.isGeneratedFile(newName,modifiedResource.getProject())) {
return RefactoringStatus.createFatalErrorStatus("Generated file with same name exists.Please choose a different name");
}
else if(("properties".equals(modifiedResource.getFileExtension())
|| "properties".equals(newExt))
&& !modifiedResource.getFullPath().segment(1).equals(CustomMessages.ProjectSupport_PARAM)) {
return RefactoringStatus.createFatalErrorStatus("properties file can only be saved in param folder.");
}
}
return new RefactoringStatus();
}
示例8: checkVarargOrder
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
* Checks if varargs are ordered correctly.
*
* @return validation status
*/
public RefactoringStatus checkVarargOrder() {
for (Iterator<ParameterInfo> iter = fParameterInfos.iterator(); iter.hasNext();) {
ParameterInfo info = iter.next();
if (info.isOldVarargs() && iter.hasNext()) {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.ExtractMethodRefactoring_error_vararg_ordering, BasicElementLabels.getJavaElementName(info.getOldName())));
}
}
return new RefactoringStatus();
}
示例9: checkPackageInCurrentRoot
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkPackageInCurrentRoot(String newName) throws CoreException {
if (fRenameSubpackages) {
String currentName = getCurrentElementName();
if (isAncestorPackage(currentName, newName)) {
// renaming to subpackage (a -> a.b) is always OK, since all subpackages are also renamed
return null;
}
if (!isAncestorPackage(newName, currentName)) {
// renaming to an unrelated package
if (!isPackageNameOkInRoot(newName, getPackageFragmentRoot())) {
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
}
}
// renaming to superpackage (a.b -> a) or another package is OK iff
// 'a.b' does not contain any subpackage that would collide with another subpackage of 'a'
// (e.g. a.b.c collides if a.c already exists, but a.b.b does not collide with a.b)
IPackageFragment[] packsToRename = JavaElementUtil.getPackageAndSubpackages(fPackage);
for (int i = 0; i < packsToRename.length; i++) {
IPackageFragment pack = packsToRename[i];
String newPack = newName + pack.getElementName().substring(currentName.length());
if (!isAncestorPackage(currentName, newPack)
&& !isPackageNameOkInRoot(newPack, getPackageFragmentRoot())) {
String msg =
Messages.format(
RefactoringCoreMessages.RenamePackageProcessor_subpackage_collides,
BasicElementLabels.getJavaElementName(newPack));
return RefactoringStatus.createFatalErrorStatus(msg);
}
}
return null;
} else if (!isPackageNameOkInRoot(newName, getPackageFragmentRoot())) {
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
} else {
return null;
}
}
示例10: validateNewName
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
protected RefactoringStatus validateNewName(String newName) {
TypeScriptRenameProcessor ref= getNameUpdating();
ref.setNewName(newName);
try{
return null;//ref.checkNewElementName(newName);
} catch (Exception e){
JSDTTypeScriptUIPlugin.log(e);
return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.RenameRefactoringWizard_internal_error);
}
}
示例11: checkInitialConditions
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@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 (fTempDeclarationNode == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_select_declaration);
if (!Checks.isDeclaredIn(fTempDeclarationNode, MethodDeclaration.class))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_only_declared_in_methods);
if (isMethodParameter())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_method_parameters);
if (isTempAnExceptionInCatchBlock())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_exceptions);
ASTNode declaringType = ASTResolving.findParentType(fTempDeclarationNode);
if (declaringType instanceof TypeDeclaration && ((TypeDeclaration) declaringType).isInterface())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_interface_methods);
result.merge(checkTempTypeForLocalTypeUsage());
if (result.hasFatalError()) return result;
checkTempInitializerForLocalTypeUsage();
if (!fSelfInitializing) initializeDefaults();
return result;
}
示例12: checkInitialConditions
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
// TargetProvider must get an untampered AST with original invocation node
// SourceProvider must get a tweaked AST with method body / parameter names replaced
RefactoringStatus result = new RefactoringStatus();
if (fMethod == null) {
if (!(fSelectionTypeRoot instanceof ICompilationUnit))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReplaceInvocationsRefactoring_cannot_replace_in_binary);
ICompilationUnit cu = (ICompilationUnit) fSelectionTypeRoot;
CompilationUnit root = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(cu, true);
fSelectionNode = getTargetNode(cu, root, fSelectionStart, fSelectionLength);
if (fSelectionNode == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ReplaceInvocationsRefactoring_select_method_to_apply);
if (fSelectionNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
MethodDeclaration methodDeclaration = (MethodDeclaration) fSelectionNode;
fTargetProvider = TargetProvider.create(methodDeclaration);
fMethodBinding = methodDeclaration.resolveBinding();
} else {
MethodInvocation methodInvocation = (MethodInvocation) fSelectionNode;
fTargetProvider = TargetProvider.create(cu, methodInvocation);
fMethodBinding = methodInvocation.resolveMethodBinding();
}
if (fMethodBinding == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.InlineMethodRefactoring_error_noMethodDeclaration);
fMethod = (IMethod) fMethodBinding.getJavaElement();
} else {
ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setProject(fMethod.getJavaProject());
IBinding[] bindings = parser.createBindings(new IJavaElement[] {fMethod}, null);
fMethodBinding = (IMethodBinding) bindings[0];
if (fMethodBinding == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.InlineMethodRefactoring_error_noMethodDeclaration);
fTargetProvider = TargetProvider.create(fMethodBinding);
}
result.merge(fTargetProvider.checkActivation());
return result;
}
示例13: checkExpression
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
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;
}
示例14: createExceptionInfoList
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus createExceptionInfoList() {
if (fExceptionInfos == null || fExceptionInfos.isEmpty()) {
fExceptionInfos = new ArrayList<ExceptionInfo>(0);
try {
ASTNode nameNode = NodeFinder.perform(fBaseCuRewrite.getRoot(), fMethod.getNameRange());
if (nameNode == null
|| !(nameNode instanceof Name)
|| !(nameNode.getParent() instanceof MethodDeclaration)) return null;
MethodDeclaration methodDeclaration = (MethodDeclaration) nameNode.getParent();
List<Type> exceptions = methodDeclaration.thrownExceptionTypes();
List<ExceptionInfo> result = new ArrayList<ExceptionInfo>(exceptions.size());
for (int i = 0; i < exceptions.size(); i++) {
Type type = exceptions.get(i);
ITypeBinding typeBinding = type.resolveBinding();
if (typeBinding == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ChangeSignatureRefactoring_no_exception_binding);
IJavaElement element = typeBinding.getJavaElement();
result.add(ExceptionInfo.createInfoForOldException(element, typeBinding));
}
fExceptionInfos = result;
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
return null;
}
示例15: createFrom
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private static RefactoringStatus createFrom(IStatus status) {
if (status.isOK()) return new RefactoringStatus();
if (!status.isMultiStatus()) {
switch (status.getSeverity()) {
case IStatus.OK:
return new RefactoringStatus();
case IStatus.INFO:
return RefactoringStatus.createInfoStatus(status.getMessage());
case IStatus.WARNING:
return RefactoringStatus.createWarningStatus(status.getMessage());
case IStatus.ERROR:
return RefactoringStatus.createErrorStatus(status.getMessage());
case IStatus.CANCEL:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
default:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
}
} else {
IStatus[] children = status.getChildren();
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < children.length; i++) {
result.merge(createFrom(children[i]));
}
return result;
}
}