Search in sources :

Example 1 with AbstractAnnotationBuilder

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

the class AnnotationBuilderTest method testJavaAnnotation.

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

Example 2 with AbstractAnnotationBuilder

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

the class CreateXtendTypeQuickfixes method newLocalXtendAnnotationQuickfix.

protected void newLocalXtendAnnotationQuickfix(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) {
            AbstractAnnotationBuilder annotationBuilder = codeBuilderFactory.createAnnotationBuilder(inferredType);
            annotationBuilder.setAnnotationName(typeName);
            annotationBuilder.setVisibility(JvmVisibility.PUBLIC);
            annotationBuilder.setContext(xtendType);
            codeBuilderQuickfix.addQuickfix(annotationBuilder, "Create local Xtend annotation '@" + typeName + "'", issue, issueResolutionAcceptor);
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) AbstractAnnotationBuilder(org.eclipse.xtend.ide.codebuilder.AbstractAnnotationBuilder)

Example 3 with AbstractAnnotationBuilder

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

the class AnnotationBuilderTest method testXtendAnnotation.

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

Aggregations

AbstractAnnotationBuilder (org.eclipse.xtend.ide.codebuilder.AbstractAnnotationBuilder)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