本文整理汇总了Java中org.eclipse.xtext.ui.refactoring.IRenameStrategy类的典型用法代码示例。如果您正苦于以下问题:Java IRenameStrategy类的具体用法?Java IRenameStrategy怎么用?Java IRenameStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRenameStrategy类属于org.eclipse.xtext.ui.refactoring包,在下文中一共展示了IRenameStrategy类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOriginalName
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
protected String getOriginalName(final XtextEditor xtextEditor) {
return xtextEditor.getDocument().readOnly(new IUnitOfWork<String, XtextResource>() {
public String exec(XtextResource state) throws Exception {
try {
EObject targetElement = state.getResourceSet().getEObject(renameElementContext.getTargetElementURI(),
false);
IRenameStrategy.Provider strategyProvider = globalServiceProvider.findService(targetElement,
IRenameStrategy.Provider.class);
if (strategyProvider != null) {
IRenameStrategy strategy = strategyProvider.get(targetElement, renameElementContext);
if (strategy != null)
return strategy.getOriginalName();
}
} catch(NoSuchStrategyException e) {
// null
}
return null;
}
});
}
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:RenameRefactoringController.java
示例2: isRefactoringEnabled
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
protected boolean isRefactoringEnabled(IRenameElementContext renameElementContext, XtextResource resource) {
ResourceSet resourceSet = resource.getResourceSet();
if (renameElementContext != null && resourceSet != null) {
EObject targetElement = resourceSet.getEObject(renameElementContext.getTargetElementURI(), true);
if (targetElement != null && !targetElement.eIsProxy()) {
if(targetElement.eResource() == resource && renameElementContext.getTriggeringEditorSelection() instanceof ITextSelection) {
ITextSelection textSelection = (ITextSelection) renameElementContext.getTriggeringEditorSelection();
ITextRegion selectedRegion = new TextRegion(textSelection.getOffset(), textSelection.getLength());
INode crossReferenceNode = eObjectAtOffsetHelper.getCrossReferenceNode(resource, selectedRegion);
if(crossReferenceNode == null) {
// selection is on the declaration. make sure it's the name
ITextRegion significantRegion = locationInFileProvider.getSignificantTextRegion(targetElement);
if(!significantRegion.contains(selectedRegion))
return false;
}
}
IRenameStrategy.Provider renameStrategyProvider = globalServiceProvider.findService(targetElement,
IRenameStrategy.Provider.class);
try {
return renameStrategyProvider.get(targetElement, renameElementContext) != null;
} catch (NoSuchStrategyException e) {
MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Cannot rename element",
e.getMessage());
}
}
}
return false;
}
开发者ID:cplutte,项目名称:bts,代码行数:29,代码来源:DefaultRenameElementHandler.java
示例3: get
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
public IRenameStrategy get(EObject targetEObject, IRenameElementContext renameElementContext) throws NoSuchStrategyException {
IRenameStrategy renameStrategy = createRenameStrategy(targetEObject, renameElementContext);
if (renameStrategy instanceof DefaultRenameStrategyProvider.IInitializable
&& ((DefaultRenameStrategyProvider.IInitializable) renameStrategy).initialize(targetEObject,
renameElementContext)) {
return renameStrategy;
}
return null;
}
开发者ID:cplutte,项目名称:bts,代码行数:10,代码来源:DefaultRenameStrategyProvider.java
示例4: renameAndTrack
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
public Map<URI, URI> renameAndTrack(Iterable<URI> renamedElementURIs, String newName, ResourceSet resourceSet, IRenameStrategy renameStrategy, IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor).setWorkRemaining(3);
Map<EObject, URI> renamedElement2oldURI = resolveRenamedElements(renamedElementURIs, resourceSet);
progress.worked(1);
renameStrategy.applyDeclarationChange(newName, resourceSet);
progress.worked(1);
Map<URI, URI> old2newURI = relocateRenamedElements(renamedElement2oldURI);
progress.worked(1);
renameStrategy.revertDeclarationChange(resourceSet);
return old2newURI;
}
开发者ID:cplutte,项目名称:bts,代码行数:12,代码来源:RenamedElementTracker.java
示例5: bindIRenameStrategy
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
public Class<? extends IRenameStrategy> bindIRenameStrategy() {
return DefaultRenameStrategy.class;
}
开发者ID:rehne93,项目名称:pokemon-tcgo-deck-generator,代码行数:4,代码来源:AbstractPkmntcgoUiModule.java
示例6:
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
public Class<? extends IRenameStrategy.Provider> bindIRenameStrategy$Provider() {
return JvmMemberRenameStrategy.Provider.class;
}
开发者ID:gw4e,项目名称:gw4e.project,代码行数:4,代码来源:AbstractDSLPoliciesUiModule.java
示例7: bindIRenameStrategy
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
public Class<? extends IRenameStrategy> bindIRenameStrategy() {
return DefaultJvmModelRenameStrategy.class;
}
开发者ID:gw4e,项目名称:gw4e.project,代码行数:4,代码来源:AbstractDSLPoliciesUiModule.java
示例8: bindIRenameStrategy
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
/**
* @since 2.1
*/
public Class<? extends IRenameStrategy> bindIRenameStrategy() {
return EmfResourceRenameStrategy.class;
}
开发者ID:cplutte,项目名称:bts,代码行数:7,代码来源:EmfUiModule.java
示例9:
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
/**
* @since 2.0
*/
public Class<? extends IRenameStrategy.Provider> bindIRenameStrategy$Provider() {
return DefaultRenameStrategyProvider.class;
}
开发者ID:cplutte,项目名称:bts,代码行数:7,代码来源:EmfUiModule.java
示例10: getLinkedPositionGroup
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
public LinkedPositionGroup getLinkedPositionGroup(IRenameElementContext renameElementContext,
IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, 100);
XtextEditor editor = (XtextEditor) renameElementContext.getTriggeringEditor();
IProject project = projectUtil.getProject(renameElementContext.getContextResourceURI());
if (project == null)
throw new IllegalStateException("Could not determine project for context resource "
+ renameElementContext.getContextResourceURI());
ResourceSet resourceSet = resourceSetProvider.get(project);
EObject targetElement = resourceSet.getEObject(renameElementContext.getTargetElementURI(), true);
if (targetElement == null)
throw new IllegalStateException("Target element could not be loaded");
IRenameStrategy.Provider strategyProvider = globalServiceProvider.findService(targetElement,
IRenameStrategy.Provider.class);
IRenameStrategy renameStrategy = null;
try {
renameStrategy = strategyProvider.get(targetElement, renameElementContext);
} catch(NoSuchStrategyException exc) {
// handle in next line
}
if(renameStrategy == null)
throw new IllegalArgumentException("Cannot find a rename strategy for "
+ notNull(renameElementContext.getTargetElementURI()));
String newName = renameStrategy.getOriginalName();
IResourceServiceProvider resourceServiceProvider = resourceServiceProviderRegistry.getResourceServiceProvider(renameElementContext.getTargetElementURI());
IDependentElementsCalculator dependentElementsCalculator = resourceServiceProvider.get(IDependentElementsCalculator.class);
Iterable<URI> dependentElementURIs = dependentElementsCalculator.getDependentElementURIs(targetElement,
progress.newChild(10));
LocalResourceRefactoringUpdateAcceptor updateAcceptor = updateAcceptorProvider.get();
updateAcceptor.setLocalResourceURI(renameElementContext.getContextResourceURI());
renameStrategy.createDeclarationUpdates(newName, resourceSet, updateAcceptor);
Map<URI, URI> original2newEObjectURI = renamedElementTracker.renameAndTrack(
concat(Collections.singleton(renameElementContext.getTargetElementURI()), dependentElementURIs),
newName, resourceSet, renameStrategy, progress.newChild(10));
ElementRenameArguments elementRenameArguments = new ElementRenameArguments(
renameElementContext.getTargetElementURI(), newName, renameStrategy, original2newEObjectURI);
final List<IReferenceDescription> referenceDescriptions = newArrayList();
IAcceptor<IReferenceDescription> referenceAcceptor = new IAcceptor<IReferenceDescription>() {
public void accept(IReferenceDescription referenceDescription) {
referenceDescriptions.add(referenceDescription);
}
};
referenceFinder.findReferences(elementRenameArguments.getRenamedElementURIs(),
singleton(renameElementContext.getContextResourceURI()), new SimpleLocalResourceAccess(resourceSet),
referenceAcceptor, progress.newChild(60));
referenceUpdater.createReferenceUpdates(elementRenameArguments, referenceDescriptions, updateAcceptor,
progress.newChild(10));
List<ReplaceEdit> textEdits = updateAcceptor.getTextEdits();
LinkedPositionGroup linkedGroup = createLinkedGroupFromReplaceEdits(textEdits, editor,
renameStrategy.getOriginalName(), progress.newChild(10));
return linkedGroup;
}
开发者ID:cplutte,项目名称:bts,代码行数:53,代码来源:DefaultLinkedPositionGroupCalculator.java
示例11: createRenameElementStrategy
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
protected IRenameStrategy createRenameElementStrategy(EObject targetElement,
IRenameElementContext renameElementContext) throws NoSuchStrategyException {
IRenameStrategy result = strategyProvider.get(targetElement, renameElementContext);
return result;
}
开发者ID:cplutte,项目名称:bts,代码行数:6,代码来源:RenameElementProcessor.java
示例12: getRenameElementStrategy
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
public IRenameStrategy getRenameElementStrategy() {
return renameStrategy;
}
开发者ID:cplutte,项目名称:bts,代码行数:4,代码来源:RenameElementProcessor.java
示例13: createRenameStrategy
import org.eclipse.xtext.ui.refactoring.IRenameStrategy; //导入依赖的package包/类
protected IRenameStrategy createRenameStrategy(EObject targetEObject, IRenameElementContext renameElementContext) {
return guiceStrategyProvider == null ? null : guiceStrategyProvider.get();
}
开发者ID:cplutte,项目名称:bts,代码行数:4,代码来源:DefaultRenameStrategyProvider.java
注:本文中的org.eclipse.xtext.ui.refactoring.IRenameStrategy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论