org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext Java Examples
The following examples show how to use
org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext.
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: AbstractProcessorBasedRenameParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected List<? extends IRenameElementContext> createRenameElementContexts(Object element) { if (element instanceof IRenameElementContext) { IRenameElementContext triggeringContext = (IRenameElementContext) element; IProject project = projectUtil.getProject(triggeringContext.getTargetElementURI()); if (project != null) { ResourceSet resourceSet = resourceSetProvider.get(project); EObject originalTarget = resourceSet.getEObject(triggeringContext.getTargetElementURI(), true); List<EObject> renamedElements = getRenamedElementsOrProxies(originalTarget); if (renamedElements == null || renamedElements.isEmpty()) return null; List<IRenameElementContext> contexts = newArrayListWithCapacity(renamedElements.size()); for (EObject renamedElement : renamedElements) contexts.add(new IRenameElementContext.Impl(EcoreUtil.getURI(renamedElement), renamedElement .eClass(), triggeringContext.getTriggeringEditor(), triggeringContext .getTriggeringEditorSelection(), triggeringContext.getContextResourceURI())); return contexts; } } return null; }
Example #2
Source File: CombinedJvmJdtRenameProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public boolean initialize(final IRenameElementContext renameElementContext) { Assert.isLegal(renameElementContext instanceof CombinedJvmJdtRenameContext); if (!super.initialize(renameElementContext)) return false; jvmElements2jdtProcessors = newHashMap(); for (Map.Entry<URI, IJavaElement> jvm2javaElement : ((CombinedJvmJdtRenameContext) renameElementContext) .getJvm2JavaElements().entrySet()) { JavaRenameProcessor jdtRenameProcessor = jdtRefactoringFactory.createRenameProcessor(jvm2javaElement .getValue()); if (jdtRenameProcessor != null) { jvmElements2jdtProcessors.put(jvm2javaElement.getKey(), jdtRenameProcessor); } else { return false; } } return true; }
Example #3
Source File: XtendRenameContextFactory.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public IRenameElementContext createLocalRenameElementContext(EObject targetElement, XtextEditor editor, ITextSelection selection, XtextResource resource) { EObject declarationTarget = getDeclarationTarget(targetElement); if (declarationTarget instanceof XtendFunction && ((XtendFunction) declarationTarget).isDispatch()) { IProject project = projectUtil.getProject(declarationTarget.eResource().getURI()); ResourceSet resourceSet = resourceSetProvider.get(project); XtendFunction relaodedDispatchFunction = (XtendFunction) resourceSet.getEObject( EcoreUtil2.getPlatformResourceOrNormalizedURI(declarationTarget), true); Iterable<JvmOperation> allDispatchOperations = dispatchRenameSupport .getAllDispatchOperations(relaodedDispatchFunction); Map<URI, IJavaElement> jvm2javaElement = newLinkedHashMap(); for (JvmOperation jvmOperation : allDispatchOperations) { IJavaElement javaElement = getJavaElementFinder().findExactElementFor(jvmOperation); if (javaElement != null) { URI jvmOperationURI = EcoreUtil.getURI(jvmOperation); jvm2javaElement.put(jvmOperationURI, javaElement); } } if (!jvm2javaElement.isEmpty()) { return new DispatchMethodRenameContext(relaodedDispatchFunction, jvm2javaElement, editor, selection, resource); } } return super.createLocalRenameElementContext(targetElement, editor, selection, resource); }
Example #4
Source File: JvmRenameRefactoringProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public ProcessorBasedRefactoring getRenameRefactoring(IRenameElementContext renameElementContext) { if (renameElementContext instanceof JdtRefactoringContext) { IJavaElement javaElement = ((JdtRefactoringContext) renameElementContext).getJavaElement(); if (isJavaSource(javaElement)) { try { RenameJavaElementDescriptor renameDescriptor = createRenameDescriptor(javaElement, javaElement.getElementName()); return (ProcessorBasedRefactoring) renameDescriptor.createRefactoring(new RefactoringStatus()); } catch (Exception exc) { throw new WrappedException(exc); } } } return super.getRenameRefactoring(renameElementContext); }
Example #5
Source File: XtextRenameStrategyProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected IRenameStrategy createRenameStrategy(final EObject targetElement, final IRenameElementContext context) { return new XtextSwitch<IRenameStrategy>() { @Override public IRenameStrategy caseAbstractMetamodelDeclaration(AbstractMetamodelDeclaration metamodelDeclaration) { return metamodelDeclarationProvider.get(); } @Override public IRenameStrategy caseAbstractRule(AbstractRule rule) { return ruleProvider.get(); } @Override public IRenameStrategy caseGrammar(Grammar grammar) { return XtextRenameStrategyProvider.super.createRenameStrategy(targetElement, context); } }.doSwitch(targetElement); }
Example #6
Source File: XtextRenameContextFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public IRenameElementContext createRenameElementContext(EObject targetElement, XtextEditor editor, ITextSelection selection, XtextResource resource) { if(targetElement instanceof AbstractRule) { AbstractRule targetRule = (AbstractRule) targetElement; List<IEObjectDescription> overriddenRules = ruleOverrideUtil.getOverriddenRules(targetRule); if(!overriddenRules.isEmpty()) { IEObjectDescription topMostSuperRule = overriddenRules.get(overriddenRules.size()-1); StringBuilder builder = new StringBuilder(); builder .append("Rule '") .append(targetRule.getName()) .append("' overrides a rule from a super grammar.\n") .append("Rename super rule instead?"); boolean isRenameSuperRule = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Overriding Rule", builder.toString()); if(isRenameSuperRule) { EObject newTarget = EcoreUtil.resolve(topMostSuperRule.getEObjectOrProxy(), targetElement.eResource().getResourceSet()); return super.createRenameElementContext(newTarget, editor, selection, resource); } } } return super.createRenameElementContext(targetElement, editor, selection, resource); }
Example #7
Source File: RefactoringTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected IRenameSupport createRenameSupportForJvmReference() { if(!languageServices.hasRefactoring()) return null; IRenameElementContext renameElementContext = editor.getDocument().tryReadOnly( new IUnitOfWork<IRenameElementContext, XtextResource>() { @Override public IRenameElementContext exec(XtextResource state) throws Exception { Model model = (Model) state.getContents().get(0); JvmType defaultReference = model.getReferenceHolder().get(0).getDefaultReference(); return languageServices.renameContextFactory.createRenameElementContext(defaultReference, editor, null, state); } }); if (renameElementContext == null) return null; IRenameSupport renameSupport = languageServices.renameSupportFactory.create(renameElementContext, "NewJavaClass"); return renameSupport; }
Example #8
Source File: RefactoringTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected IRenameSupport createRenameSupportForElement() { if(!languageServices.hasRefactoring()) return null; IRenameElementContext renameElementContext = editor.getDocument().tryReadOnly( new IUnitOfWork<IRenameElementContext, XtextResource>() { @Override public IRenameElementContext exec(XtextResource state) throws Exception { Model model = (Model) state.getContents().get(0); ReferenceHolder referenceHolder = model.getReferenceHolder().get(0); return languageServices.renameContextFactory.createRenameElementContext(referenceHolder, editor, null, state); } }); if (renameElementContext == null) return null; IRenameSupport renameSupport = languageServices.renameSupportFactory.create(renameElementContext, "newTestName"); return renameSupport; }
Example #9
Source File: JvmModelJdtRenameParticipantContext.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected List<? extends IRenameElementContext> createJdtParticipantXtextSourceContexts( JdtRenameParticipant participant, EObject indexedJvmElement) { if(operatorMappingUtil.isMappedOperator(indexedJvmElement)) return Collections.emptyList(); EObject jvmElement; if(indexedJvmElement instanceof JvmConstructor) jvmElement = ((JvmConstructor) indexedJvmElement).getDeclaringType(); else jvmElement = indexedJvmElement; EObject renameTargetElement = associations.getPrimarySourceElement(jvmElement); if (renameTargetElement != null) { return singletonList(new JvmModelJdtRenameParticipantContext(participant, EcoreUtil2.getPlatformResourceOrNormalizedURI(renameTargetElement), renameTargetElement.eClass())); } return super.createJdtParticipantXtextSourceContexts(participant, jvmElement); }
Example #10
Source File: RenameElementProcessor2.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public boolean initialize(IRenameElementContext renameElementContext) { this.renameElementContext = renameElementContext; status = statusProvider.get(); project = projectUtil.getProject(renameElementContext.getTargetElementURI().trimFragment()); if (project == null) { URI targetElementURI = renameElementContext.getTargetElementURI(); status.add(RefactoringIssueAcceptor.Severity.ERROR, // "Cannot determine project from targetURI " + (targetElementURI != null ? targetElementURI.toString() : null), // renameElementContext.getTargetElementURI()); return false; } resourceSet = resourceSetProvider.get(project); EObject target = resourceSet.getEObject(renameElementContext.getTargetElementURI(), true); if (target == null) { status.add(RefactoringIssueAcceptor.Severity.ERROR, "Rename target does not exist", renameElementContext.getTargetElementURI()); } else { originalName = simpleNameProvider.getSimpleName(target); } return true; }
Example #11
Source File: JdtRenameParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected List<? extends IRenameElementContext> createRenameElementContexts(Object element) { if (element instanceof IJavaElement) { IJavaElement javaElement = (IJavaElement) element; EClass expectedJvmType = getExpectedJvmType(javaElement); if (expectedJvmType != null) { IJavaProject javaProject = javaElement.getJavaProject(); IProject project = javaProject.getProject(); ResourceSet resourceSet = resourceSetProvider.get(project); EObject directJvmElement = jvmElementFinder.getCorrespondingJvmElement(javaElement, resourceSet); if (directJvmElement != null && expectedJvmType.isSuperTypeOf(directJvmElement.eClass())) { ResourceSet resourceSet2 = resourceSetProvider.get(project); EObject indexedJvmElement = jvmElementFinder.findJvmElementDeclarationInIndex(directJvmElement, project, resourceSet2); if (indexedJvmElement != null) // jvmElement is indexed, thus contained in an XtextResurce and likely inferred from some Xtext-based elements return getContextFactory(indexedJvmElement).createJdtParticipantXtextSourceContexts( this, indexedJvmElement); else if (directJvmElement instanceof JvmMember) // jvmElement could only be cross referenced by Xtext-based elements return createJdtRenameParticipantContext((JvmMember) directJvmElement, javaElement); } } } return null; }
Example #12
Source File: SARLRenameStrategyProvider.java From sarl with Apache License 2.0 | 5 votes |
@Override protected IRenameStrategy createRenameStrategy(EObject targetEObject, IRenameElementContext renameElementContext) { if (targetEObject instanceof SarlScript) { return this.guiceEcorePackageStrategyProvider.get(); } return super.createRenameStrategy(targetEObject, renameElementContext); }
Example #13
Source File: XtendRenameStrategyProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public IRenameStrategy get(EObject targetEObject, IRenameElementContext renameElementContext) throws NoSuchStrategyException { if(targetEObject instanceof XtendConstructor) // Xtend constructors can be ignored in rename refactorings return null; return super.get(targetEObject, renameElementContext); }
Example #14
Source File: SARLFileRenameParticipant.java From sarl with Apache License 2.0 | 5 votes |
@Override protected List<? extends IRenameElementContext> createRenameElementContexts(Object element) { if (!getArguments().getUpdateReferences()) { return super.createRenameElementContexts(element); } assert element instanceof IFile; final IFile file = (IFile) element; final IPath filePath = file.getFullPath(); if (Objects.equals(filePath.getFileExtension(), this.fileExtension)) { final String typeName = filePath.removeFileExtension().lastSegment(); final IPath newPath = filePath.removeLastSegments(1).append( getNewName()).addFileExtension(this.fileExtension); final ResourceSet resourceSet = this.resourceSetProvider.get(file.getProject()); final URI resourceURI = URI.createPlatformResourceURI(filePath.toString(), true); final Resource resource = resourceSet.getResource(resourceURI, true); if (resource != null && !resource.getContents().isEmpty()) { for (final XtendTypeDeclaration type : EcoreUtil2.eAllOfType(resource.getContents().get(0), XtendTypeDeclaration.class)) { if (Objects.equals(typeName, type.getName())) { final IRenameElementContext renameElementContext = this.renameContextFactory.createRenameElementContext( type, null, null, (XtextResource) resource); if (renameElementContext instanceof IChangeRedirector.Aware) { ((IChangeRedirector.Aware) renameElementContext).setChangeRedirector( source -> Objects.equals(source, filePath) ? newPath : filePath); } return singletonList(renameElementContext); } } } } return super.createRenameElementContexts(element); }
Example #15
Source File: XtendQuickfixProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Fix(IssueCodes.WRONG_FILE) public void fixWrongFileRenameClass(final Issue issue, final IssueResolutionAcceptor acceptor) { URI uri = issue.getUriToProblem(); String className = uri.trimFileExtension().lastSegment(); String label = String.format("Rename class to '%s'", className); acceptor.accept(issue, label, label, null, (element, context) -> { context.getXtextDocument().modify(resource -> { IRenameElementContext renameContext = renameContextFactory.createRenameElementContext(element, null, new TextSelection(context.getXtextDocument(), issue.getOffset(), issue.getLength()), resource); final ProcessorBasedRefactoring refactoring = renameRefactoringProvider.getRenameRefactoring(renameContext); ((RenameElementProcessor) refactoring.getProcessor()).setNewName(className); PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, monitor -> { try { if (!refactoring.checkFinalConditions(monitor).isOK()) return; Change change = refactoring.createChange(monitor); change.initializeValidationData(monitor); PerformChangeOperation performChangeOperation = new PerformChangeOperation(change); performChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), refactoring.getName()); performChangeOperation.setSchedulingRule(ResourcesPlugin.getWorkspace().getRoot()); performChangeOperation.run(monitor); } catch (CoreException e) { logger.error(e); } }); return null; }); }); }
Example #16
Source File: DispatchMethodRenameStrategy.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public boolean initialize(EObject xtendMethod, IRenameElementContext context) { Assert.isLegal(xtendMethod instanceof XtendFunction); Assert.isLegal(((XtendFunction) xtendMethod).isDispatch()); Assert.isLegal(context instanceof DispatchMethodRenameContext); ResourceSet resourceSet = xtendMethod.eResource().getResourceSet(); Map<URI, IJavaElement> jvm2JavaElements = ((DispatchMethodRenameContext)context).getJvm2JavaElements(); for(URI dispatchOperationURI: jvm2JavaElements.keySet()) { JvmOperation dispatchOperation = (JvmOperation) resourceSet.getEObject(dispatchOperationURI, true); XtendFunction xtendDispatchMethod = associations.getXtendFunction(dispatchOperation); if(xtendDispatchMethod != null) { if(equal(xtendDispatchMethod.getName(),dispatchOperation.getSimpleName())) { // synthetic dispatcher dispatchers.add(dispatchOperation); } else { // xtend dispatch method XtendDispatchMethodChildStrategy xtendChildStrategy = childStrategyProvider.get(); xtendChildStrategy.initialize(xtendDispatchMethod, context); children.add(xtendChildStrategy); } } else { // a dispatch method form a Java class JavaDispatchMethodChildStrategy jvmChildStrategy = javaStrategyProvider.get(); jvmChildStrategy.initialize(dispatchOperation, context); children.add(jvmChildStrategy); } } return !children.isEmpty(); }
Example #17
Source File: N4JSRenameElementHandler.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected boolean isRefactoringEnabled(IRenameElementContext renameElementContext, XtextResource resource) { // Do not allow renaming built-in types such as int, string etc. if (renameElementContext.getTargetElementURI().scheme().equals("n4scheme")) { return false; } return super.isRefactoringEnabled(renameElementContext, resource); }
Example #18
Source File: DotHtmlLabelRenameStrategy.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public boolean initialize(EObject targetElement, IRenameElementContext context) { if (super.initialize(targetElement, context)) { this.targetElement = targetElement; return true; } return false; }
Example #19
Source File: AbstractXtendRenameRefactoringTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected ProcessorBasedRefactoring createXtendRenameRefactoring(final XtextEditor editor, final int offset, String newName) { IRenameElementContext renameElementContext = createRenameElementContext(editor, offset); ProcessorBasedRefactoring renameRefactoring = renameRefactoringProvider .getRenameRefactoring(renameElementContext); RefactoringProcessor processor = renameRefactoring.getProcessor(); if (processor instanceof AbstractRenameProcessor) ((AbstractRenameProcessor) processor).setNewName(newName); else if (processor instanceof JavaRenameProcessor) ((JavaRenameProcessor) processor).setNewElementName(newName); return renameRefactoring; }
Example #20
Source File: DotRenameStrategy.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public boolean initialize(EObject targetElement, IRenameElementContext context) { if (super.initialize(targetElement, context)) { this.targetElement = targetElement; return true; } return false; }
Example #21
Source File: AbstractXtendRenameRefactoringTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected IRenameElementContext createRenameElementContext(final XtextEditor editor, final int offset) { IRenameElementContext renameElementContext = editor.getDocument().readOnly( new IUnitOfWork<IRenameElementContext, XtextResource>() { @Override public IRenameElementContext exec(XtextResource state) throws Exception { EObject element = eObjectAtOffsetHelper.resolveElementAt(state, offset); return renameContextFactory.createRenameElementContext(element, editor, new TextSelection( offset, 1), state); } }); return renameElementContext; }
Example #22
Source File: EcorePackageRenameStrategy.java From sarl with Apache License 2.0 | 5 votes |
@Override public boolean initialize(EObject targetEObject, IRenameElementContext renameElementContext) { if (targetEObject instanceof SarlScript) { final SarlScript script = (SarlScript) targetEObject; this.currentPackageName = Strings.emptyIfNull(script.getPackage()); this.uriProvider = it -> renameElementContext.getTargetElementURI(); return true; } return false; }
Example #23
Source File: XtendFileRenameParticipant.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected List<? extends IRenameElementContext> createRenameElementContexts(Object element) { if(super.getNewName().endsWith(".xtend")) { IFile file = (IFile) element; final IPath filePath = file.getFullPath(); final IPath newPath = file.getFullPath().removeLastSegments(1).append(getNewName() + ".xtend"); String className = trimFileExtension(file.getName()); if(className != null) { ResourceSet resourceSet = resourceSetProvider.get(file.getProject()); URI resourceURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); Resource resource = resourceSet.getResource(resourceURI, true); if (resource != null && !resource.getContents().isEmpty()) { for (XtendTypeDeclaration type : EcoreUtil2.eAllOfType(resource.getContents().get(0), XtendTypeDeclaration.class)) { if (equal(className, type.getName())) { IRenameElementContext renameElementContext = renameContextFactory.createRenameElementContext(type, null, null, (XtextResource) resource); if(renameElementContext instanceof IChangeRedirector.Aware) ((IChangeRedirector.Aware) renameElementContext).setChangeRedirector(new IChangeRedirector() { @Override public IPath getRedirectedPath(IPath source) { return source.equals(filePath) ? newPath : source; } }); return singletonList(renameElementContext); } } } } } return super.createRenameElementContexts(element); }
Example #24
Source File: JdtRefactoringContextFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IRenameElementContext createExternalRenameElementContext(EObject targetElement, XtextEditor editor, ITextSelection selection, XtextResource resource) { if (isJvmMember(targetElement) && isTypeResource(targetElement)) { IJavaElement javaElement; if(targetElement instanceof JvmConstructor) javaElement = getJavaElementFinder().findExactElementFor(((JvmConstructor) targetElement).getDeclaringType()); else javaElement = getJavaElementFinder().findExactElementFor((JvmMember) targetElement); if (javaElement != null) return new JdtRefactoringContext(targetElement, javaElement, editor, selection, resource, true); } return super.createExternalRenameElementContext(targetElement, editor, selection, resource); }
Example #25
Source File: JdtRenameParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected RenameProcessor getRenameProcessor(IRenameElementContext participantContext) { RenameProcessor renameProcessor = super.getRenameProcessor(participantContext); // We need to do all changes for one language inside the same processor in order to be able to // restructure them to avoid collisions. That's why we add all processors to the same composite // which is only returned in the first context. CompositeRefactoringProcessor current = compositeRefactoringProcessorAccess.getCurrent(getProcessor()); current.addProcessor(renameProcessor); if (current.getNumProcessors() == 1) return current; else return null; }
Example #26
Source File: JvmMemberRenameStrategy.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IRenameStrategy get(EObject targetEObject, IRenameElementContext renameElementContext) throws NoSuchStrategyException { if(targetEObject instanceof JvmMember) { JvmMemberRenameStrategy jvmMemberRenameStrategy = guiceStartegyProvider.get(); jvmMemberRenameStrategy.initialize((JvmMember) targetEObject, renameElementContext); return jvmMemberRenameStrategy; } return delegate == null ? null : delegate.get(targetEObject, renameElementContext); }
Example #27
Source File: CombinedJvmJdtRenameRefactoringProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public RenameProcessor getRenameProcessor(IRenameElementContext renameElementContext) { RenameElementProcessor processor = null; if (renameElementContext instanceof JvmModelJdtRenameParticipantContext) processor = jdtRenameParticipantProcessorProvider.get(); else if (renameElementContext instanceof CombinedJvmJdtRenameContext) processor = combinedRenameProcessorProvider.get(); if (processor != null) { if (processor.initialize(renameElementContext)) return processor; else return null; } return super.getRenameProcessor(renameElementContext); }
Example #28
Source File: CombinedJvmJdtRenameRefactoringProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public ProcessorBasedRefactoring getRenameRefactoring(IRenameElementContext renameElementContext) { if (renameElementContext instanceof CombinedJvmJdtRenameContext) { RenameProcessor renameProcessor = getRenameProcessor(renameElementContext); if (renameProcessor != null) { return createChangeCombiningRefactoring(renameProcessor); } return null; } return super.getRenameRefactoring(renameElementContext); }
Example #29
Source File: CombinedJvmJdtRenameContextFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IRenameElementContext createLocalRenameElementContext(EObject targetElement, XtextEditor editor, ITextSelection selection, XtextResource resource) { EObject declarationTarget = getDeclarationTarget(targetElement); Set<EObject> jvmElements = filterJvmElements(associations.getJvmElements(declarationTarget)); if (!jvmElements.isEmpty()) { Map<URI, IJavaElement> jvm2javaElement = newLinkedHashMap(); for (JvmIdentifiableElement jvmElement : filter(jvmElements, JvmIdentifiableElement.class)) { JvmIdentifiableElement jvmElementToBeRenamed = (jvmElement instanceof JvmConstructor) ? ((JvmConstructor) jvmElement).getDeclaringType() : jvmElement; IJavaElement javaElement = getJavaElementFinder().findExactElementFor(jvmElementToBeRenamed); if (javaElement != null) if (javaElement instanceof IMethod) addDeclaringMethod(jvmElementToBeRenamed, javaElement, jvm2javaElement); else jvm2javaElement.put(EcoreUtil.getURI(jvmElementToBeRenamed), javaElement); } if (!jvm2javaElement.isEmpty()) { return new CombinedJvmJdtRenameContext(declarationTarget, jvm2javaElement, editor, selection, resource); } } if (targetElement instanceof JvmFormalParameter || targetElement instanceof JvmTypeParameter) { EObject sourceParameter = associations.getPrimarySourceElement(targetElement); if (sourceParameter != null) return super.createLocalRenameElementContext(sourceParameter, editor, selection, resource); } return super.createLocalRenameElementContext(targetElement, editor, selection, resource); }
Example #30
Source File: AbstractProcessorBasedRenameParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected RenameProcessor getRenameProcessor(IRenameElementContext participantContext) { IRenameRefactoringProvider renameRefactoringProvider = getRenameRefactoringProvider(participantContext); if (renameRefactoringProvider != null) return renameRefactoringProvider.getRenameProcessor(participantContext); else return null; }