Search in sources :

Example 1 with MoveRefactoringSession

use of org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession in project che by eclipse.

the class RefactoringManager method setMoveSettings.

/**
     * Sets move refactoring settings.
     * update references, update qualified names, files pattern
     *
     * @param settings
     *         the move refactoring settings
     * @throws RefactoringException
     *         when move refactoring session not found.
     */
public void setMoveSettings(MoveSettings settings) throws RefactoringException {
    RefactoringSession session = getRefactoringSession(settings.getSessionId());
    if (!(session instanceof MoveRefactoringSession)) {
        throw new RefactoringException("Can't set move on none move refactoring session.");
    }
    MoveRefactoringSession refactoring = ((MoveRefactoringSession) session);
    refactoring.setUpdateReferences(settings.isUpdateReferences());
    if (settings.isUpdateQualifiedNames()) {
        refactoring.setFilePatterns(settings.getFilePatterns());
    }
    refactoring.setUpdateQualifiedNames(settings.isUpdateQualifiedNames());
}
Also used : MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession)

Example 2 with MoveRefactoringSession

use of org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession in project che by eclipse.

the class RefactoringManager method createMoveRefactoringSession.

/**
     * Create move refactoring session.
     *
     * @param javaElements
     *         the java elements
     * @return the ID of the refactoring session
     */
public String createMoveRefactoringSession(IJavaElement[] javaElements) throws JavaModelException, RefactoringException {
    IReorgPolicy.IMovePolicy policy = ReorgPolicyFactory.createMovePolicy(new IResource[0], javaElements);
    if (policy.canEnable()) {
        JavaMoveProcessor processor = new JavaMoveProcessor(policy);
        //TODO this may overwrite existing sources.
        processor.setReorgQueries(new NullReorgQueries());
        processor.setCreateTargetQueries(() -> null);
        Refactoring refactoring = new MoveRefactoring(processor);
        MoveRefactoringSession session = new MoveRefactoringSession(refactoring, processor);
        final String id = String.format("move-%s", sessionId.getAndIncrement());
        sessions.put(id, session);
        return id;
    } else {
        throw new RefactoringException("Can't create move refactoring session.");
    }
}
Also used : IReorgPolicy(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy) NullReorgQueries(org.eclipse.jdt.internal.corext.refactoring.reorg.NullReorgQueries) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) JavaMoveProcessor(org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor)

Aggregations

MoveRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession)2 RenameRefactoringSession (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)1 RefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession)1 RenameLinkedModeRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession)1 ReorgRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession)1 IReorgPolicy (org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy)1 JavaMoveProcessor (org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor)1 NullReorgQueries (org.eclipse.jdt.internal.corext.refactoring.reorg.NullReorgQueries)1 Refactoring (org.eclipse.ltk.core.refactoring.Refactoring)1 MoveRefactoring (org.eclipse.ltk.core.refactoring.participants.MoveRefactoring)1 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)1