use of org.eclipse.jdt.core.refactoring.CompilationUnitChange in project che by eclipse.
the class CompilationUnitRewriteOperationsFix method createChange.
// /**
// * {@inheritDoc}
// */
// @Override
// public LinkedProposalModel getLinkedPositions() {
// if (!fLinkedProposalModel.hasLinkedPositions())
// return null;
//
// return fLinkedProposalModel;
// }
/**
* {@inheritDoc}
*/
public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException {
CompilationUnitRewrite cuRewrite = new CompilationUnitRewrite((ICompilationUnit) fCompilationUnit.getJavaElement(), fCompilationUnit);
fLinkedProposalModel.clear();
for (int i = 0; i < fOperations.length; i++) {
CompilationUnitRewriteOperation operation = fOperations[i];
operation.rewriteAST(cuRewrite, fLinkedProposalModel);
}
CompilationUnitChange result = cuRewrite.createChange(getDisplayString(), true, null);
if (result == null)
throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.ID_PLUGIN, Messages.format(FixMessages.CompilationUnitRewriteOperationsFix_nullChangeError, getDisplayString())));
return result;
}
use of org.eclipse.jdt.core.refactoring.CompilationUnitChange in project che by eclipse.
the class StringFix method createChange.
/**
* {@inheritDoc}
*/
public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException {
if (fEditGroups == null || fEditGroups.length == 0)
return null;
CompilationUnitChange result = new CompilationUnitChange(getDisplayString(), fCompilationUnit);
for (int i = 0; i < fEditGroups.length; i++) {
TextEdit[] edits = fEditGroups[i].getTextEdits();
String groupName = fEditGroups[i].getName();
for (int j = 0; j < edits.length; j++) {
TextChangeCompatibility.addTextEdit(result, groupName, edits[j]);
}
}
return result;
}
use of org.eclipse.jdt.core.refactoring.CompilationUnitChange in project che by eclipse.
the class CompilationUnitRewrite method createChange.
/**
* Creates a compilation unit change based on the events recorded by this compilation unit rewrite.
* @param name the name of the change to create
* @param generateGroups <code>true</code> to generate text edit groups, <code>false</code> otherwise
* @param monitor the progress monitor or <code>null</code>
* @return a {@link CompilationUnitChange}, or <code>null</code> for an empty change
* @throws CoreException when text buffer acquisition or import rewrite text edit creation fails
* @throws IllegalArgumentException when the AST rewrite encounters problems
*/
public CompilationUnitChange createChange(String name, boolean generateGroups, IProgressMonitor monitor) throws CoreException {
CompilationUnitChange cuChange = new CompilationUnitChange(name, fCu);
MultiTextEdit multiEdit = new MultiTextEdit();
cuChange.setEdit(multiEdit);
return attachChange(cuChange, generateGroups, monitor);
}
use of org.eclipse.jdt.core.refactoring.CompilationUnitChange in project che by eclipse.
the class CUCorrectionProposal method createTextChange.
/**
* Creates the text change for this proposal.
* This method is only called once and only when no text change has been passed in
* {@link #CUCorrectionProposal(String, ICompilationUnit, TextChange, int, Image)}.
*
* @return the created text change
* @throws CoreException if the creation of the text change failed
*/
protected TextChange createTextChange() throws CoreException {
ICompilationUnit cu = getCompilationUnit();
String name = getName();
TextChange change;
if (!cu.getResource().exists()) {
String source;
try {
source = cu.getSource();
} catch (JavaModelException e) {
JavaPlugin.log(e);
// empty
source = new String();
}
Document document = new Document(source);
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(cu));
change = new DocumentChange(name, document);
} else {
CompilationUnitChange cuChange = new CompilationUnitChange(name, cu);
cuChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
change = cuChange;
}
TextEdit rootEdit = new MultiTextEdit();
change.setEdit(rootEdit);
// initialize text change
IDocument document = change.getCurrentDocument(new NullProgressMonitor());
addEdits(document, rootEdit);
return change;
}
use of org.eclipse.jdt.core.refactoring.CompilationUnitChange in project che by eclipse.
the class ConvertAnonymousToNestedRefactoring method createChange.
/*
* @see org.eclipse.jdt.internal.corext.refactoring.base.IRefactoring#createChange(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
final CompilationUnitChange result = createCompilationUnitChange(pm);
result.setDescriptor(createRefactoringDescriptor());
return result;
}
Aggregations