Java Code Examples for org.eclipse.xtext.ui.refactoring.impl.StatusWrapper#add()
The following examples show how to use
org.eclipse.xtext.ui.refactoring.impl.StatusWrapper#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdtRenameRefactoringParticipantProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Subclasses can decide to override this to allow specific multi-refactorings. * * @since 2.4 */ protected RefactoringStatus preCheckInitialConditions(IProgressMonitor pm) throws CoreException { if (associations.getJvmElements(getTargetElement()).size() > 1) { StatusWrapper statusWrapper = getStatusProvider().get(); statusWrapper.add(ERROR, "Rename from here will not be complete. Try to rename {0} instead.", getTargetElement()); statusWrapper.merge(super.checkInitialConditions(pm)); return statusWrapper.getRefactoringStatus(); } return new RefactoringStatus(); }
Example 2
Source File: ExtractVariableRefactoring.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void handleException(Exception exc, StatusWrapper status) { status.add(FATAL, "Error during refactoring: {0}", exc, LOG); }
Example 3
Source File: ExtractMethodRefactoring.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException { StatusWrapper status = statusProvider.get(); IResolvedTypes resolvedTypes = typeResolver.resolveTypes(firstExpression, new CancelIndicator() { @Override public boolean isCanceled() { return pm.isCanceled(); } }); try { Set<String> calledExternalFeatureNames = newHashSet(); returnType = calculateReturnType(resolvedTypes); if (returnType != null && !equal("void", returnType.getIdentifier())) returnExpression = lastExpression; boolean isReturnAllowed = isEndOfOriginalMethod(); for (EObject element : EcoreUtil2.eAllContents(originalMethod.getExpression())) { if (pm.isCanceled()) { throw new OperationCanceledException(); } boolean isLocalExpression = EcoreUtil.isAncestor(expressions, element); if (element instanceof XFeatureCall) { XFeatureCall featureCall = (XFeatureCall) element; JvmIdentifiableElement feature = featureCall.getFeature(); LightweightTypeReference featureType = resolvedTypes.getActualType(featureCall); boolean isLocalFeature = EcoreUtil.isAncestor(expressions, feature); if (!isLocalFeature && isLocalExpression) { // call-out if (feature instanceof JvmFormalParameter || feature instanceof XVariableDeclaration) { if (!calledExternalFeatureNames.contains(feature.getSimpleName())) { calledExternalFeatureNames.add(feature.getSimpleName()); ParameterInfo parameterInfo = new ParameterInfo(featureType.getIdentifier(), feature.getSimpleName(), parameterInfos.size()); parameterInfos.add(parameterInfo); parameter2type.put(parameterInfo, featureType); } externalFeatureCalls.put(feature.getSimpleName(), featureCall); } } else if (isLocalFeature && !isLocalExpression) { // call-in if (returnExpression != null) { status.add(RefactoringStatus.FATAL, "Ambiguous return value: Multiple local variables are accessed in subsequent code."); break; } returnExpression = featureCall; returnType = featureType; } } else if(isLocalExpression) { if(element instanceof XReturnExpression && !isReturnAllowed) { status.add(RefactoringStatus.FATAL, "Extracting method would break control flow due to return statements."); break; } else if (element instanceof JvmTypeReference) { JvmType type = ((JvmTypeReference) element).getType(); if (type instanceof JvmTypeParameter) { JvmOperation operation = associations.getDirectlyInferredOperation(originalMethod); if (operation != null) { List<JvmTypeParameter> typeParameters = operation.getTypeParameters(); if (typeParameters.contains(type)) neededTypeParameters.add((JvmTypeParameter) type); } } } else if (element instanceof JvmFormalParameter) localFeatureNames.add(((JvmFormalParameter) element).getName()); else if (element instanceof XVariableDeclaration) localFeatureNames.add(((XVariableDeclaration) element).getIdentifier()); } } } catch (OperationCanceledException e) { throw e; } catch (Exception exc) { handleException(exc, status); } return status.getRefactoringStatus(); }
Example 4
Source File: ExtractMethodRefactoring.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void handleException(Exception exc, StatusWrapper status) { status.add(FATAL, "Error during refactoring: {0}", exc, LOG); }