当前位置: 首页>>代码示例>>Java>>正文


Java TextChange.getEdit方法代码示例

本文整理汇总了Java中org.eclipse.ltk.core.refactoring.TextChange.getEdit方法的典型用法代码示例。如果您正苦于以下问题:Java TextChange.getEdit方法的具体用法?Java TextChange.getEdit怎么用?Java TextChange.getEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ltk.core.refactoring.TextChange的用法示例。


在下文中一共展示了TextChange.getEdit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateChange

import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的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());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:GWTRefactoringSupportTest.java

示例2: createChange

import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
	CompositeChange changes = new CompositeChange("Rename method change");

	for (ICompilationUnit unit : map.keySet()) {
		TextEdit newEdit = map.get(unit).getAstRewrite().rewriteAST();
		TextChange existingChange = getTextChange(unit);

		if (existingChange == null) {
			CompilationUnitChange change = new CompilationUnitChange("change", unit);
			change.setEdit(newEdit);
			changes.add(change);
		} else {
			TextEdit existingEdit = existingChange.getEdit();
			if (existingEdit.covers(newEdit)) {
				mergeEdits(existingEdit, newEdit);
			} else {
				existingEdit.addChild(newEdit);
			}
		}
	}

	return changes;
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder_plugin,代码行数:25,代码来源:EsfingeRenameParticipant.java

示例3: getCommandFromProposal

import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
private Command getCommandFromProposal(CUCorrectionProposal proposal) throws CoreException {
	String name = proposal.getName();
	TextChange textChange = proposal.getTextChange();
	TextEdit edit = textChange.getEdit();
	ICompilationUnit unit = proposal.getCompilationUnit();

	return textEditToCommand(unit, name, edit);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:9,代码来源:CodeActionHandler.java

示例4: getAdditionalProposalInfo

import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
@Override
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
	final StringBuffer buf= new StringBuffer();

	try {
		for (int i= 0; i < fChanges.length; i++) {
			if (fChanges[i] instanceof TextChange) {
				TextChange change= (TextChange) fChanges[i];
				String filename= getFileName(change);
				if (filename != null) {
					buf.append("<b>"); //$NON-NLS-1$
					buf.append(filename);
					buf.append("</b>"); //$NON-NLS-1$
					buf.append("<br>"); //$NON-NLS-1$
				}
				change.setKeepPreviewEdits(true);
				IDocument currentContent= change.getCurrentDocument(monitor);

				TextEdit rootEdit= change.getEdit();

				EditAnnotator ea= new EditAnnotator(buf, currentContent) {
					@Override
					protected boolean rangeRemoved(TextEdit edit) {
						return annotateEdit(edit, "<del>", "</del>"); //$NON-NLS-1$ //$NON-NLS-2$
					}
				};
				rootEdit.accept(ea);
				ea.unchangedUntil(currentContent.getLength()); // Final pre-existing region
				buf.append("<br><br>"); //$NON-NLS-1$
			}
		}

	} catch (CoreException e) {
		JavaPlugin.log(e);
	}
	return buf.toString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:38,代码来源:PropertiesQuickAssistProcessor.java

示例5: addWorkspaceEdit

import org.eclipse.ltk.core.refactoring.TextChange; //导入方法依赖的package包/类
private void addWorkspaceEdit(ICompilationUnit cu, CUCorrectionProposal proposal, WorkspaceEdit rootEdit) throws CoreException {
	TextChange textChange = proposal.getTextChange();
	TextEdit edit = textChange.getEdit();
	TextEditConverter converter = new TextEditConverter(cu, edit);
	rootEdit.getChanges().put(JDTUtils.toURI(cu), converter.convert());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:7,代码来源:OrganizeImportsCommand.java


注:本文中的org.eclipse.ltk.core.refactoring.TextChange.getEdit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。