org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator Java Examples

The following examples show how to use org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultLinkedPositionGroupCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Provider<LinkedPositionGroup> getLinkedPositionGroup(
		IRenameElementContext renameElementContext,
		IProgressMonitor monitor) {
	final SubMonitor progress = SubMonitor.convert(monitor, 100);
	final 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());
	
	RefactoringResourceSetProvider resourceSetProvider = new CachingResourceSetProvider(DefaultLinkedPositionGroupCalculator.this.resourceSetProvider);
	
	ResourceSet resourceSet = resourceSetProvider.get(project);
	EObject targetElement = resourceSet.getEObject(renameElementContext.getTargetElementURI(), true);
	if (targetElement == null)
		throw new IllegalStateException("Target element could not be loaded");
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	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));
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	LocalResourceRefactoringUpdateAcceptor updateAcceptor = updateAcceptorProvider.get();
	updateAcceptor.setLocalResourceURI(renameElementContext.getContextResourceURI());
	renameStrategy.createDeclarationUpdates(newName, resourceSet, updateAcceptor);
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	Map<URI, URI> original2newEObjectURI = renamedElementTracker.renameAndTrack(
			concat(Collections.singleton(renameElementContext.getTargetElementURI()), dependentElementURIs),
			newName, resourceSet, renameStrategy, progress.newChild(10));
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	ElementRenameArguments elementRenameArguments = new ElementRenameArguments(
			renameElementContext.getTargetElementURI(), newName, renameStrategy, original2newEObjectURI, resourceSetProvider);
	final List<IReferenceDescription> referenceDescriptions = newArrayList();
	IReferenceFinder.Acceptor referenceAcceptor = new IReferenceFinder.Acceptor() {
		@Override
		public void accept(IReferenceDescription referenceDescription) {
			referenceDescriptions.add(referenceDescription);
		}
		@Override
		public void accept(EObject source, URI sourceURI, EReference eReference, int index, EObject targetOrProxy,
				URI targetURI) {
			referenceDescriptions.add(new DefaultReferenceDescription(EcoreUtil2.getFragmentPathURI(source), targetURI, eReference, index, null));
		}
	};
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	referenceFinder.findReferences(
			targetURIConverter.fromIterable(elementRenameArguments.getRenamedElementURIs()),
			resourceSet.getResource(renameElementContext.getContextResourceURI(), true),
			referenceAcceptor, progress.newChild(10));
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	referenceUpdater.createReferenceUpdates(elementRenameArguments, referenceDescriptions, updateAcceptor,
			progress.newChild(60));
	final List<ReplaceEdit> textEdits = updateAcceptor.getTextEdits();
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	final IRenameStrategy renameStrategy2 = renameStrategy;
	return new Provider<LinkedPositionGroup>() {

		@Override
		public LinkedPositionGroup get() {
			LinkedPositionGroup linkedGroup = createLinkedGroupFromReplaceEdits(textEdits, editor,
					renameStrategy2.getOriginalName(), progress.newChild(10));
			return linkedGroup;
		}
	};
}
 
Example #2
Source File: AbstractRefactoringTestLanguage2UiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #3
Source File: AbstractRefactoringTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #4
Source File: AbstractContentAssistTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #5
Source File: AbstractRefactoringTestLanguage1UiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #6
Source File: AbstractDomainmodelUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #7
Source File: AbstractStatemachineUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #8
Source File: AbstractRuleEngineUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #9
Source File: AbstractArithmeticsUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #10
Source File: AbstractBuilderTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #11
Source File: AbstractEcore2XtextTestUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #12
Source File: AbstractPureXbaseUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #13
Source File: AbstractBug462047LangUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #14
Source File: AbstractXImportSectionTestLangUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #15
Source File: AbstractContentAssistFragmentTestLangUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #16
Source File: AbstractXtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #17
Source File: XtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return XtendDependentElementsCalculator.class;
}
 
Example #18
Source File: AbstractHelloWorldUiModule.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #19
Source File: AbstractGamlUiModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #20
Source File: AbstractSARLUiModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return JvmModelDependentElementsCalculator.class;
}
 
Example #21
Source File: AbstractXtextGrammarTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #22
Source File: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return N4JSDependentElementsCalculator.class;
}
 
Example #23
Source File: AbstractRegularExpressionUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #24
Source File: AbstractJSONUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #25
Source File: AbstractBromiumUiModule.java    From bromium with MIT License 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #26
Source File: AbstractMyDslUiModule.java    From M2Doc with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #27
Source File: AbstractFileAwareTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #28
Source File: AbstractExBeeLangTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #29
Source File: AbstractSimpleBeeLangTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}
 
Example #30
Source File: AbstractBeeLangTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IDependentElementsCalculator> bindIDependentElementsCalculator() {
	return DefaultDependentElementsCalculator.class;
}