本文整理汇总了Java中org.eclipse.ltk.core.refactoring.TextFileChange类的典型用法代码示例。如果您正苦于以下问题:Java TextFileChange类的具体用法?Java TextFileChange怎么用?Java TextFileChange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextFileChange类属于org.eclipse.ltk.core.refactoring包,在下文中一共展示了TextFileChange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTextEditFromRewrite
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
private static TextChange addTextEditFromRewrite(
TextChangeManager manager, ICompilationUnit cu, ASTRewrite rewrite) throws CoreException {
try {
ITextFileBuffer buffer = RefactoringFileBuffers.acquire(cu);
TextEdit resultingEdits =
rewrite.rewriteAST(buffer.getDocument(), cu.getJavaProject().getOptions(true));
TextChange textChange = manager.get(cu);
if (textChange instanceof TextFileChange) {
TextFileChange tfc = (TextFileChange) textChange;
tfc.setSaveMode(TextFileChange.KEEP_SAVE_STATE);
}
String message = RefactoringCoreMessages.DeleteChangeCreator_1;
TextChangeCompatibility.addTextEdit(textChange, message, resultingEdits);
return textChange;
} finally {
RefactoringFileBuffers.release(cu);
}
}
示例2: getSingleChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的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;
}
示例3: getChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的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: addToTextChangeMap
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
private void addToTextChangeMap(Change change) {
if (change instanceof TextChange) {
Object element = ((TextChange) change).getModifiedElement();
if (element != null) {
fTextChangeMap.put(element, change);
}
// check if we have a subclass of TextFileChange. If so also put the change
// under the file resource into the hash table if possible.
if (change instanceof TextFileChange && !change.getClass().equals(TextFileChange.class)) {
IFile file = ((TextFileChange) change).getFile();
fTextChangeMap.put(file, change);
}
} else if (change instanceof CompositeChange) {
Change[] children = ((CompositeChange) change).getChildren();
for (int i = 0; i < children.length; i++) {
addToTextChangeMap(children[i]);
}
}
}
示例5: testCreateChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
public void testCreateChange() {
JsniTypeReferenceChangeFactory factory = new JsniTypeReferenceChangeFactory(
null);
// This file doesn't need to actually exist in the workspace
IFile file = Util.getWorkspaceRoot().getFile(
new Path("/Project/src/com/google/gwt/GWT.java"));
// Create a change and verify its properties
TextFileChange change = factory.createChange(file);
assertEquals(file, change.getFile());
assertTrue(change instanceof IJsniTypeReferenceChange);
IJsniTypeReferenceChange jsniRefChange = (IJsniTypeReferenceChange) change;
ICompilationUnit cu = (ICompilationUnit) JavaCore.create(file);
assertEquals(jsniRefChange.getCompilationUnit(), cu);
}
示例6: testPerform
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
public void testPerform() throws CoreException {
// Create a dummy change for updating references in RefactorTest.java
// to the class R to its new name 'RRR'
ICompilationUnit cu = refactorTestClass.getCompilationUnit();
GWTRefactoringSupport support = new DummyRefactoringSupport();
JsniReferenceChangeFactory factory = new JsniReferenceChangeFactory(support);
IJsniReferenceChange jsniChange = factory.createChange(cu);
// Add one dummy edit to the change
TextEdit oldRootEdit = new MultiTextEdit();
oldRootEdit.addChild(new ReplaceEdit(252, 0, ""));
((TextFileChange)jsniChange).setEdit(oldRootEdit);
// Perform the change (this should replace the original edits with new ones
// with the correct offsets).
((TextFileChange)jsniChange).perform(new NullProgressMonitor());
// Verify that the change still has one edit
TextEdit newRootEdit = ((TextFileChange)jsniChange).getEdit();
assertEquals(1, newRootEdit.getChildrenSize());
}
示例7: testCreateChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
public void testCreateChange() {
JsniReferenceChangeFactory factory = new JsniReferenceChangeFactory(null);
// This file doesn't need to actually exist in the workspace
IFile file = Util.getWorkspaceRoot().getFile(
new Path("/Project/src/com/google/gwt/GWT.java"));
// Create a change and verify its properties
TextFileChange change = factory.createChange(file);
assertEquals(file, change.getFile());
assertTrue(change instanceof IJsniReferenceChange);
IJsniReferenceChange jsniRefChange = (IJsniReferenceChange) change;
ICompilationUnit cu = (ICompilationUnit) JavaCore.create(file);
assertEquals(jsniRefChange.getCompilationUnit(), cu);
}
示例8: cloneCompilationUnitChangeWithDifferentCu
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
/**
* Destructively clones a {@link CompilationUnitChange} where the cloned
* change will have a different compilation unit. This does not update text
* regions or anything more than setting the change properties and moving text
* edits from the old to new change.
*
* @param originalChange the original change, this change's internal state
* will likely become invalid (its text edits will be moved to the
* new change)
* @param cu the compilation unit to be used for the new
* {@link CompilationUnitChange}
* @return the cloned {@link CompilationUnitChange}
*/
public static CompilationUnitChange cloneCompilationUnitChangeWithDifferentCu(
TextFileChange originalChange, ICompilationUnit cu) {
CompilationUnitChange newChange = new CompilationUnitChange(
originalChange.getName(), cu);
newChange.setEdit(originalChange.getEdit());
newChange.setEnabledShallow(originalChange.isEnabled());
newChange.setKeepPreviewEdits(originalChange.getKeepPreviewEdits());
newChange.setSaveMode(originalChange.getSaveMode());
newChange.setTextType(originalChange.getTextType());
// Copy the changes over
TextEditUtilities.moveTextEditGroupsIntoChange(
originalChange.getChangeGroups(), newChange);
return newChange;
}
示例9: RegionUpdaterChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
/**
* Creates a region updater change.
*
* @param compilationUnitChange the compilation unit change whose text edits
* will be updated
* @param regionUpdaters a list of updaters for text edits in the compilation
* unit change
* @param referenceUpdater aids in finding the corresponding AST nodes for
* those that have been refactored (e.g. if FooService was renamed to
* BarService, this instance would pass that knowledge)
*/
public RegionUpdaterChange(String name, TextFileChange compilationUnitChange,
List<RegionUpdater> regionUpdaters, ReferenceUpdater referenceUpdater) {
super(name);
assert compilationUnitChange.getModifiedElement() instanceof ICompilationUnit;
this.compilationUnitChange = compilationUnitChange;
this.regionUpdaters = regionUpdaters;
this.referenceUpdater = referenceUpdater;
// Do not show this in previews
markAsSynthetic();
// Wrap the original compilation unit
add(compilationUnitChange);
}
示例10: addTextEditFromRewrite
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
private static TextChange addTextEditFromRewrite(TextChangeManager manager, ICompilationUnit cu, ASTRewrite rewrite) throws CoreException {
try {
ITextFileBuffer buffer= RefactoringFileBuffers.acquire(cu);
TextEdit resultingEdits= rewrite.rewriteAST(buffer.getDocument(), cu.getJavaProject().getOptions(true));
TextChange textChange= manager.get(cu);
if (textChange instanceof TextFileChange) {
TextFileChange tfc= (TextFileChange) textChange;
tfc.setSaveMode(TextFileChange.KEEP_SAVE_STATE);
}
String message= RefactoringCoreMessages.DeleteChangeCreator_1;
TextChangeCompatibility.addTextEdit(textChange, message, resultingEdits);
return textChange;
} finally {
RefactoringFileBuffers.release(cu);
}
}
示例11: removeKeys
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
public static Change removeKeys(IPath propertyFilePath, List<String> keys) throws CoreException {
String name= Messages.format(NLSMessages.NLSPropertyFileModifier_remove_from_property_file, BasicElementLabels.getPathLabel(propertyFilePath, false));
TextChange textChange= new TextFileChange(name, getPropertyFile(propertyFilePath));
textChange.setTextType("properties"); //$NON-NLS-1$
PropertyFileDocumentModel model= new PropertyFileDocumentModel(textChange.getCurrentDocument(new NullProgressMonitor()));
for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) {
String key= iterator.next();
TextEdit edit= model.remove(key);
if (edit != null) {
TextChangeCompatibility.addTextEdit(textChange, Messages.format(NLSMessages.NLSPropertyFileModifier_remove_entry, BasicElementLabels.getJavaElementName(key)), edit);
}
}
return textChange;
}
示例12: getSingleChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的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;
}
示例13: getChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:GetterSetterCorrectionSubProcessor.java
示例14: createChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm)
throws CoreException, OperationCanceledException
{
if (editsPerFiles.isEmpty())
return null;
pm.beginTask("Searching for references.", editsPerFiles.size());
final CompositeChange changes = new CompositeChange("Update mapper element ID");
int workCount = 0;
for (Entry<IFile, List<ReplaceEdit>> editsPerFile : editsPerFiles.entrySet())
{
IFile file = editsPerFile.getKey();
TextChange change = new TextFileChange(file.getName(), file);
TextEdit editRoot = new MultiTextEdit();
change.setEdit(editRoot);
for (ReplaceEdit edit : editsPerFile.getValue())
{
editRoot.addChild(edit);
}
changes.add(change);
pm.worked(++workCount);
}
pm.done();
return changes;
}
示例15: createChange
import org.eclipse.ltk.core.refactoring.TextFileChange; //导入依赖的package包/类
protected Change createChange() throws CoreException {
final Change change = fClasspathFixProposal.createChange(null);
if (fImportRewrites != null) {
final CompositeChange composite = new CompositeChange(getDisplayString());
composite.add(change);
for (final ImportRewrite ir : fImportRewrites) {
final TextFileChange cuChange = new TextFileChange("Add import", //$NON-NLS-1$
(IFile) ir.getCompilationUnit().getResource());
cuChange.setEdit(ir.rewriteImports(null));
composite.add(cuChange);
}
return composite;
}
return change;
}