Search in sources :

Example 1 with AbstractClassBuilder

use of org.eclipse.xtend.ide.codebuilder.AbstractClassBuilder in project xtext-xtend by eclipse.

the class ClassBuilderTest method testXtendClass.

@Test
public void testXtendClass() {
    AbstractClassBuilder _createClassBuilder = this._codeBuilderFactory.createClassBuilder(this.getXtendClass());
    final Procedure1<AbstractClassBuilder> _function = (AbstractClassBuilder it) -> {
        it.setContext(this.getXtendClass());
        it.setClassName("Bar");
        it.setVisibility(JvmVisibility.PUBLIC);
    };
    AbstractClassBuilder _doubleArrow = ObjectExtensions.<AbstractClassBuilder>operator_doubleArrow(_createClassBuilder, _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("}");
    this.assertBuilds(_doubleArrow, _builder.toString());
}
Also used : AbstractClassBuilder(org.eclipse.xtend.ide.codebuilder.AbstractClassBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractBuilderTest(org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)

Example 2 with AbstractClassBuilder

use of org.eclipse.xtend.ide.codebuilder.AbstractClassBuilder in project xtext-xtend by eclipse.

the class ClassBuilderTest method testJavaClass.

@Test
public void testJavaClass() {
    AbstractClassBuilder _createClassBuilder = this._codeBuilderFactory.createClassBuilder(this.getJavaClass());
    final Procedure1<AbstractClassBuilder> _function = (AbstractClassBuilder it) -> {
        it.setContext(this.getJavaClass());
        it.setClassName("Bar");
        it.setVisibility(JvmVisibility.PUBLIC);
    };
    AbstractClassBuilder _doubleArrow = ObjectExtensions.<AbstractClassBuilder>operator_doubleArrow(_createClassBuilder, _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public class Bar {");
    _builder.newLine();
    _builder.append("}");
    this.assertBuilds(_doubleArrow, _builder.toString());
}
Also used : AbstractClassBuilder(org.eclipse.xtend.ide.codebuilder.AbstractClassBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractBuilderTest(org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)

Example 3 with AbstractClassBuilder

use of org.eclipse.xtend.ide.codebuilder.AbstractClassBuilder in project xtext-xtend by eclipse.

the class CreateXtendTypeQuickfixes method newLocalXtendClassQuickfix.

protected void newLocalXtendClassQuickfix(String typeName, XtextResource resource, Issue issue, IssueResolutionAcceptor issueResolutionAcceptor) {
    EObject eObject = resource.getEObject(issue.getUriToProblem().fragment());
    XtendTypeDeclaration xtendType = getAnnotationTarget(eObject);
    if (xtendType != null) {
        JvmDeclaredType inferredType = associations.getInferredType(xtendType);
        if (inferredType != null) {
            AbstractClassBuilder classBuilder = codeBuilderFactory.createClassBuilder(inferredType);
            classBuilder.setClassName(typeName);
            classBuilder.setVisibility(JvmVisibility.PUBLIC);
            classBuilder.setContext(xtendType);
            classBuilder.setImage("xtend_file.png");
            codeBuilderQuickfix.addQuickfix(classBuilder, "Create local Xtend class '" + typeName + "'", issue, issueResolutionAcceptor);
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) AbstractClassBuilder(org.eclipse.xtend.ide.codebuilder.AbstractClassBuilder) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType)

Aggregations

AbstractClassBuilder (org.eclipse.xtend.ide.codebuilder.AbstractClassBuilder)3 AbstractBuilderTest (org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 Test (org.junit.Test)2 EObject (org.eclipse.emf.ecore.EObject)1 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)1 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)1