Search in sources :

Example 1 with IRenameSupport

use of org.eclipse.xtext.ui.refactoring.ui.IRenameSupport in project xtext-eclipse by eclipse.

the class RefactoringTest method testRenameElement_1.

@Test
public void testRenameElement_1() throws Exception {
    setLanguageConfig(true, false);
    IRenameSupport renameSupport = createRenameSupportForElement();
    assertNotNull(renameSupport);
    renameSupport.startDirectRefactoring();
    waitForBuild();
    assertXtextElementRefactored();
    assertJavaUnchanged();
}
Also used : IRenameSupport(org.eclipse.xtext.ui.refactoring.ui.IRenameSupport) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Example 2 with IRenameSupport

use of org.eclipse.xtext.ui.refactoring.ui.IRenameSupport in project xtext-eclipse by eclipse.

the class RefactoringTest method createRenameSupportForJvmReference.

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;
}
Also used : IRenameSupport(org.eclipse.xtext.ui.refactoring.ui.IRenameSupport) Model(org.eclipse.xtext.common.types.xtext.ui.refactoringTestLanguage.Model) IRenameElementContext(org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext) XtextResource(org.eclipse.xtext.resource.XtextResource) JvmType(org.eclipse.xtext.common.types.JvmType) JavaModelException(org.eclipse.jdt.core.JavaModelException)

Example 3 with IRenameSupport

use of org.eclipse.xtext.ui.refactoring.ui.IRenameSupport in project xtext-eclipse by eclipse.

the class RefactoringTest method testRenameElement_2.

@Test
public void testRenameElement_2() throws Exception {
    setLanguageConfig(true, true);
    IRenameSupport renameSupport = createRenameSupportForElement();
    assertNotNull(renameSupport);
    renameSupport.startDirectRefactoring();
    waitForBuild();
    assertXtextElementRefactored();
    assertJavaUnchanged();
}
Also used : IRenameSupport(org.eclipse.xtext.ui.refactoring.ui.IRenameSupport) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Example 4 with IRenameSupport

use of org.eclipse.xtext.ui.refactoring.ui.IRenameSupport in project xtext-eclipse by eclipse.

the class RefactoringTest method testRenameJvmReference_1.

@Test
public void testRenameJvmReference_1() throws Exception {
    setLanguageConfig(true, false);
    IRenameSupport renameSupport = createRenameSupportForJvmReference();
    assertNull(renameSupport);
}
Also used : IRenameSupport(org.eclipse.xtext.ui.refactoring.ui.IRenameSupport) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Example 5 with IRenameSupport

use of org.eclipse.xtext.ui.refactoring.ui.IRenameSupport in project xtext-eclipse by eclipse.

the class RefactoringTest method createRenameSupportForElement.

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;
}
Also used : IRenameSupport(org.eclipse.xtext.ui.refactoring.ui.IRenameSupport) ReferenceHolder(org.eclipse.xtext.common.types.xtext.ui.refactoringTestLanguage.ReferenceHolder) Model(org.eclipse.xtext.common.types.xtext.ui.refactoringTestLanguage.Model) IRenameElementContext(org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext) XtextResource(org.eclipse.xtext.resource.XtextResource) JavaModelException(org.eclipse.jdt.core.JavaModelException)

Aggregations

IRenameSupport (org.eclipse.xtext.ui.refactoring.ui.IRenameSupport)8 AbstractEditorTest (org.eclipse.xtext.ui.testing.AbstractEditorTest)6 Test (org.junit.Test)6 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 Model (org.eclipse.xtext.common.types.xtext.ui.refactoringTestLanguage.Model)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 IRenameElementContext (org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext)2 JvmType (org.eclipse.xtext.common.types.JvmType)1 ReferenceHolder (org.eclipse.xtext.common.types.xtext.ui.refactoringTestLanguage.ReferenceHolder)1