本文整理汇总了Java中org.eclipse.ltk.core.refactoring.Change类的典型用法代码示例。如果您正苦于以下问题:Java Change类的具体用法?Java Change怎么用?Java Change使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Change类属于org.eclipse.ltk.core.refactoring包,在下文中一共展示了Change类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
copyToPath=getArguments().getDestination().toString();
IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject project = workSpaceRoot.getProject(copyToPath.split("/")[1]);
IFolder jobFolder = project.getFolder(copyToPath.substring(copyToPath.indexOf('/', 2)));
previousJobFiles=new ArrayList<>();
for (IResource iResource : jobFolder.members()) {
if (!(iResource instanceof IFolder)) {
IFile iFile = (IFile) iResource;
if (iFile.getFileExtension().equalsIgnoreCase(Messages.JOB_EXT)) {
previousJobFiles.add(iFile);
}
}
}
copiedFileList.add(modifiedResource);
return null;
}
示例2: getAdditionalProposalInfo
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
public String getAdditionalProposalInfo(IProgressMonitor monitor) throws CoreException {
StringBuffer buf= new StringBuffer();
buf.append("<p>"); //$NON-NLS-1$
try {
Change change= getChange();
if (change != null) {
String name= change.getName();
if (name.length() == 0) {
return null;
}
buf.append(name);
} else {
return null;
}
} catch (CoreException e) {
buf.append("Unexpected error when accessing this proposal:<p><pre>"); //$NON-NLS-1$
buf.append(e.getLocalizedMessage());
buf.append("</pre>"); //$NON-NLS-1$
}
buf.append("</p>"); //$NON-NLS-1$
return buf.toString();
}
示例3: getChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
public TextFileChange getChange(IFile file) throws CoreException {
final SelfEncapsulateFieldRefactoring refactoring =
new SelfEncapsulateFieldRefactoring(fField);
refactoring.setVisibility(Flags.AccPublic);
refactoring.setConsiderVisibility(
false); // private field references are just searched in local file
refactoring.checkInitialConditions(new NullProgressMonitor());
refactoring.checkFinalConditions(new NullProgressMonitor());
Change createdChange = refactoring.createChange(new NullProgressMonitor());
if (createdChange instanceof CompositeChange) {
Change[] children = ((CompositeChange) createdChange).getChildren();
for (int i = 0; i < children.length; i++) {
Change curr = children[i];
if (curr instanceof TextFileChange && ((TextFileChange) curr).getFile().equals(file)) {
return (TextFileChange) curr;
}
}
}
return null;
}
示例4: createChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
public Change createChange(IProgressMonitor pm) throws JavaModelException {
IPackageFragment[] fragments = getPackages();
pm.beginTask("", fragments.length); // $NON-NLS-1$
CompositeChange result =
new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move_package);
result.markAsSynthetic();
IPackageFragmentRoot root = getDestinationAsPackageFragmentRoot();
for (int i = 0; i < fragments.length; i++) {
if (root == null) {
result.add(createChange(fragments[i], (IContainer) getResourceDestination()));
} else {
result.add(createChange(fragments[i], root));
}
pm.worked(1);
if (pm.isCanceled()) throw new OperationCanceledException();
}
pm.done();
return result;
}
示例5: getSingleChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
public Change getSingleChange(IFile[] alreadyTouchedFiles) {
Collection<TextChange> values = fChanges.values();
if (values.size() == 0) return null;
CompositeChange result =
new CompositeChange(RefactoringCoreMessages.QualifiedNameSearchResult_change_name);
result.markAsSynthetic();
List<IFile> files = Arrays.asList(alreadyTouchedFiles);
for (Iterator<TextChange> iter = values.iterator(); iter.hasNext(); ) {
TextFileChange change = (TextFileChange) iter.next();
if (!files.contains(change.getFile())) {
result.add(change);
}
}
return result;
}
示例6: weaveChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
/**
* Ensures each compilation unit change in the tree rooted at the given change
* will be wrapped with a
* {@link com.google.gwt.eclipse.core.refactoring.regionupdater.RegionUpdaterChange}
* to update text regions at change perform-time.
*/
private void weaveChange(Change change) {
String oldName = typeContainer.getBaseType().getElementName();
String newName = getTypeRefactoringSupport().getNewElement().getElementName();
RenamedElementAstMatcher astMatcher = new RenamedElementAstMatcher(oldName,
newName);
String oldCuName = typeContainer.getBaseType().getCompilationUnit().getElementName();
String newCuName = getTypeRefactoringSupport().getNewType().getCompilationUnit().getElementName();
CompilationUnitRenamedReferenceUpdater cuValidator = new CompilationUnitRenamedReferenceUpdater(
oldName, newName,
oldCuName, newCuName);
// Walk through the created change tree and weave a change that, at
// perform-time, will update the text regions
ChangeUtilities.acceptOnChange(change,
new RegionUpdaterChangeWeavingVisitor(astMatcher, cuValidator));
}
示例7: createChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
public Change createChange(IProgressMonitor monitor) throws CoreException,
OperationCanceledException {
try {
monitor.beginTask(
Messages.ConvertConstantsToEnumRefactoring_CreatingChange,
1);
final Collection changes = this.changes.values();
final CompositeChange change = new CompositeChange(this.getName(),
(Change[]) changes.toArray(new Change[changes.size()])) {
public ChangeDescriptor getDescriptor() {
String project = ConvertConstantsToEnumRefactoring.this
.getJavaProject().getElementName();
String description = Messages.ConvertConstantsToEnum_Name;
Map arguments = new HashMap();
return new RefactoringChangeDescriptor(
new ConvertConstantsToEnumDescriptor(project,
description, new String(), arguments));
}
};
return change;
} finally {
monitor.done();
}
}
开发者ID:ponder-lab,项目名称:Constants-to-Enum-Eclipse-Plugin,代码行数:25,代码来源:ConvertConstantsToEnumRefactoring.java
示例8: createChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
public ChangeCreationResult createChange() throws RefactoringException {
Change change =
createChange(
new CreateChangeOperation(
new CheckConditionsOperation(
refactoring, CheckConditionsOperation.FINAL_CONDITIONS),
RefactoringStatus.FATAL),
true);
// Status has been updated since we have passed true
RefactoringStatus status = conditionCheckingStatus;
// Creating the change has been canceled
if (change == null && status == null) {
internalSetChange(change);
throw new RefactoringException("Creating the change has been canceled");
}
// Set change if we don't have fatal errors.
if (!status.hasFatalError()) {
internalSetChange(change);
}
ChangeCreationResult result = DtoFactory.newDto(ChangeCreationResult.class);
result.setStatus(DtoConverter.toRefactoringStatusDto(status));
result.setCanShowPreviewPage(status.isOK());
return result;
}
示例9: createSimpleMoveChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
private Change createSimpleMoveChange(IProgressMonitor pm) {
CompositeChange result =
new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
result.markAsSynthetic();
IFile[] files = getFiles();
IFolder[] folders = getFolders();
ICompilationUnit[] cus = getCus();
pm.beginTask("", files.length + folders.length + cus.length); // $NON-NLS-1$
for (int i = 0; i < files.length; i++) {
result.add(createChange(files[i]));
pm.worked(1);
}
if (pm.isCanceled()) throw new OperationCanceledException();
for (int i = 0; i < folders.length; i++) {
result.add(createChange(folders[i]));
pm.worked(1);
}
if (pm.isCanceled()) throw new OperationCanceledException();
for (int i = 0; i < cus.length; i++) {
result.add(createChange(cus[i]));
pm.worked(1);
}
pm.done();
return result;
}
示例10: testCreateChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
public void testCreateChange() {
GWTRefactoringSupport support = new DummyGWTRefactoringSupport();
support.setUpdateReferences(true);
IType refactorTestType = refactorTestClass.getCompilationUnit().findPrimaryType();
support.setOldElement(refactorTestType);
RefactoringParticipant participant = new DummyRefactoringParticipant();
IRefactoringChangeFactory changeFactory = new DefaultChangeFactory();
CompositeChange change = support.createChange(participant, changeFactory);
// Return value should contain one child change
Change[] changeChildren = change.getChildren();
assertEquals(1, changeChildren.length);
// Root edit should contain two child edits, one for each JSNI ref
TextChange childChange = (TextChange) changeChildren[0];
TextEdit changeEdit = childChange.getEdit();
assertEquals(2, changeEdit.getChildrenSize());
}
示例11: fireChangePerformed
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
private void fireChangePerformed(final Change change) {
if (fListeners == null) return;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IUndoManagerListener listener = (IUndoManagerListener) listeners[i];
SafeRunner.run(
new ISafeRunnable() {
public void run() throws Exception {
listener.changePerformed(UndoManager2.this, change);
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
}
示例12: perform
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
@Override
public final Change perform(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
try {
pm.beginTask(getName(), 2);
String newName = getNewResourceName();
IResource resource = getResource();
boolean performReorg = deleteIfAlreadyExists(new SubProgressMonitor(pm, 1), newName);
if (!performReorg) return null;
getResource()
.copy(getDestinationPath(newName), getReorgFlags(), new SubProgressMonitor(pm, 1));
markAsExecuted(resource);
return null;
} finally {
pm.done();
}
}
示例13: insertChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
/**
* Inserts a change at the specified index.
*
* @param change the change to insert
* @param insertIndex the index to insert at (if >= the number of children, it
* will be added to the end)
* @param parentChange the new parent of the change
*/
public static void insertChange(Change change, int insertIndex,
CompositeChange parentChange) {
Change[] changes = parentChange.getChildren();
if (insertIndex >= changes.length) {
parentChange.add(change);
} else {
// CompositeChange.clear does not clear the parent field on the removed
// changes, but CompositeChange.remove does
for (Change curChange : changes) {
parentChange.remove(curChange);
}
for (int i = 0; i < changes.length; i++) {
if (i == insertIndex) {
parentChange.add(change);
}
parentChange.add(changes[i]);
}
}
}
示例14: createChange
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
final CompositeChange changes = new CompositeChange(getName());
for (RenameChange renameOperation : renameOperations) {
// Update build.policies file
changes.add(renameOperation);
// Rename the test compilation unit
Change ci = renameOperation.createRenameChangeForTestImplementation(pm);
if (ci != null)
changes.add(ci);
// rename the interface compilation unit
Change cti = renameOperation.createRenameChangeForTestInterface(pm);
if (cti != null)
changes.add(cti);
// Update the Generated annotation
Change renameGeneratedAnnotationChange = new RenameGeneratedAnnotation (originalFile.getProject(),originalFile.getFullPath(),newName);
changes.add(renameGeneratedAnnotationChange);
// Update the Model annotation
Change renameModelAnnotationChange = new RenameModelAnnotation (originalFile.getProject(),originalFile.getFullPath(),newName);
changes.add(renameModelAnnotationChange);
// Update Path Usage such as Path.get("foo/bar/Test.json")
Change renamePathUsageChange = new RenamePathUsage (originalFile.getProject(),originalFile.getFullPath(),newName);
changes.add(renamePathUsageChange);
// Open/Close editors
changes.add(renameOperation.createEditorChangeForGraph(pm));
}
// When renaming a folder, it becomes a Move...
MoveGraphParticipant mgp = new MoveGraphParticipant(moveOperations);
Change moveChange = mgp.createChange(new NullProgressMonitor ());
changes.add(moveChange);
return changes;
}
示例15: getContentChanges
import org.eclipse.ltk.core.refactoring.Change; //导入依赖的package包/类
private Change getContentChanges(IProgressMonitor pm) throws CoreException {
final CompositeChange changes = new CompositeChange(getName());
for (MoveChange moveOperation : moveOperations) {
// Update build.policies file
changes.add(moveOperation);
// Move the test compilation unit
Change ci = moveOperation.createMoveChangeForTestImplementation(pm);
if (ci != null)
changes.add(ci);
// Move the interface compilation unit
Change cti = moveOperation.createMoveChangeForTestInterface(pm);
if (cti != null)
changes.add(cti);
// Update the Generated annotation
Change moveGeneratedAnnotationChange = moveOperation.createMoveGeneratedAnnotation( );
changes.add(moveGeneratedAnnotationChange);
// Update the Model annotation
Change moveModelAnnotationChange = moveOperation.createMoveModelAnnotation( );
changes.add(moveModelAnnotationChange);
// Update Path Usage such as Path.get("foo/bar/Test.json")
Change movePathUsageChange = moveOperation.createMovePathUsage( );
changes.add(movePathUsageChange);
// Open/Close editors
changes.add(moveOperation.createEditorChangeForGraph (pm));
}
return changes;
}