Search in sources :

Example 6 with JvmVisibility

use of org.eclipse.xtext.common.types.JvmVisibility in project xtext-xtend by eclipse.

the class CodeBuilderQuickfix method getImage.

protected String getImage(final ICodeBuilder builder) {
    String _switchResult = null;
    JvmVisibility _visibility = builder.getVisibility();
    if (_visibility != null) {
        switch(_visibility) {
            case PRIVATE:
                _switchResult = "fix_private_obj.gif";
                break;
            case PUBLIC:
                _switchResult = "fix_public_obj.gif";
                break;
            case PROTECTED:
                _switchResult = "fix_protected_obj.gif";
                break;
            default:
                _switchResult = "fix_default_obj.gif";
                break;
        }
    } else {
        _switchResult = "fix_default_obj.gif";
    }
    return _switchResult;
}
Also used : JvmVisibility(org.eclipse.xtext.common.types.JvmVisibility)

Example 7 with JvmVisibility

use of org.eclipse.xtext.common.types.JvmVisibility in project xtext-xtend by eclipse.

the class XtendJvmModelInferrer method transform.

protected void transform(XtendConstructor source, JvmGenericType container) {
    JvmConstructor constructor = typesFactory.createJvmConstructor();
    container.getMembers().add(constructor);
    associator.associatePrimary(source, constructor);
    JvmVisibility visibility = source.getVisibility();
    constructor.setSimpleName(container.getSimpleName());
    constructor.setVisibility(visibility);
    for (XtendParameter parameter : source.getParameters()) {
        translateParameter(constructor, parameter);
    }
    copyAndFixTypeParameters(source.getTypeParameters(), constructor);
    for (JvmTypeReference exception : source.getExceptions()) {
        constructor.getExceptions().add(jvmTypesBuilder.cloneWithProxies(exception));
    }
    translateAnnotationsTo(source.getAnnotations(), constructor);
    setBody(constructor, source.getExpression());
    jvmTypesBuilder.copyDocumentationTo(source, constructor);
}
Also used : XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) JvmVisibility(org.eclipse.xtext.common.types.JvmVisibility)

Example 8 with JvmVisibility

use of org.eclipse.xtext.common.types.JvmVisibility in project xtext-xtend by eclipse.

the class XtendJvmModelInferrer method transform.

protected void transform(XtendFunction source, JvmGenericType container, boolean allowDispatch) {
    JvmOperation operation = typesFactory.createJvmOperation();
    operation.setAbstract(source.isAbstract());
    operation.setNative(source.isNative());
    operation.setSynchronized(source.isSynchonized());
    operation.setStrictFloatingPoint(source.isStrictFloatingPoint());
    if (!source.isAbstract())
        operation.setFinal(source.isFinal());
    container.getMembers().add(operation);
    associator.associatePrimary(source, operation);
    String sourceName = source.getName();
    JvmVisibility visibility = source.getVisibility();
    if (allowDispatch && source.isDispatch()) {
        if (source.getDeclaredVisibility() == null)
            visibility = JvmVisibility.PROTECTED;
        sourceName = "_" + sourceName;
    }
    operation.setSimpleName(sourceName);
    operation.setVisibility(visibility);
    operation.setStatic(source.isStatic());
    if (!operation.isAbstract() && !operation.isStatic() && container.isInterface())
        operation.setDefault(true);
    for (XtendParameter parameter : source.getParameters()) {
        translateParameter(operation, parameter);
    }
    XExpression expression = source.getExpression();
    CreateExtensionInfo createExtensionInfo = source.getCreateExtensionInfo();
    JvmTypeReference returnType = null;
    if (source.getReturnType() != null) {
        returnType = jvmTypesBuilder.cloneWithProxies(source.getReturnType());
    } else if (createExtensionInfo != null) {
        returnType = jvmTypesBuilder.inferredType(createExtensionInfo.getCreateExpression());
    } else if (expression != null) {
        returnType = jvmTypesBuilder.inferredType(expression);
    } else {
        returnType = jvmTypesBuilder.inferredType();
    }
    operation.setReturnType(returnType);
    copyAndFixTypeParameters(source.getTypeParameters(), operation);
    for (JvmTypeReference exception : source.getExceptions()) {
        operation.getExceptions().add(jvmTypesBuilder.cloneWithProxies(exception));
    }
    translateAnnotationsTo(source.getAnnotations(), operation);
    if (source.isOverride() && generatorConfig.getJavaSourceVersion().isAtLeast(JAVA6) && !containsAnnotation(operation, Override.class) && typeReferences.findDeclaredType(Override.class, source) != null) {
        operation.getAnnotations().add(_annotationTypesBuilder.annotationRef(Override.class));
    }
    if (createExtensionInfo != null) {
        transformCreateExtension(source, createExtensionInfo, container, operation, returnType);
    } else {
        setBody(operation, expression);
    }
    jvmTypesBuilder.copyDocumentationTo(source, operation);
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmVisibility(org.eclipse.xtext.common.types.JvmVisibility) XExpression(org.eclipse.xtext.xbase.XExpression) CreateExtensionInfo(org.eclipse.xtend.core.xtend.CreateExtensionInfo)

Example 9 with JvmVisibility

use of org.eclipse.xtext.common.types.JvmVisibility in project xtext-xtend by eclipse.

the class AbstractExecutableBuilder method getImage.

@Override
public String getImage() {
    String _switchResult = null;
    JvmVisibility _visibility = this.getVisibility();
    if (_visibility != null) {
        switch(_visibility) {
            case PRIVATE:
                _switchResult = "methpri_obj.gif";
                break;
            case PROTECTED:
                _switchResult = "methpro_obj.gif";
                break;
            case PUBLIC:
                _switchResult = "methpub_obj.gif";
                break;
            default:
                _switchResult = "methdef_obj.gif";
                break;
        }
    } else {
        _switchResult = "methdef_obj.gif";
    }
    return _switchResult;
}
Also used : JvmVisibility(org.eclipse.xtext.common.types.JvmVisibility)

Example 10 with JvmVisibility

use of org.eclipse.xtext.common.types.JvmVisibility in project xtext-xtend by eclipse.

the class JvmMemberDeclarationImpl method setVisibility.

public void setVisibility(final Visibility visibility) {
    this.checkMutable();
    T _delegate = this.getDelegate();
    JvmVisibility _switchResult = null;
    if (visibility != null) {
        switch(visibility) {
            case DEFAULT:
                _switchResult = JvmVisibility.DEFAULT;
                break;
            case PUBLIC:
                _switchResult = JvmVisibility.PUBLIC;
                break;
            case PRIVATE:
                _switchResult = JvmVisibility.PRIVATE;
                break;
            case PROTECTED:
                _switchResult = JvmVisibility.PROTECTED;
                break;
            default:
                break;
        }
    }
    _delegate.setVisibility(_switchResult);
}
Also used : JvmVisibility(org.eclipse.xtext.common.types.JvmVisibility)

Aggregations

JvmVisibility (org.eclipse.xtext.common.types.JvmVisibility)11 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)4 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)3 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)2 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)2 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)2 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)2 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 DispatchHelper (org.eclipse.xtend.core.jvmmodel.DispatchHelper)1 CreateExtensionInfo (org.eclipse.xtend.core.xtend.CreateExtensionInfo)1 RichString (org.eclipse.xtend.core.xtend.RichString)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1