Java Code Examples for org.eclipse.xtext.common.types.JvmVisibility#DEFAULT

The following examples show how to use org.eclipse.xtext.common.types.JvmVisibility#DEFAULT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JvmMemberDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: DefaultVisibilityProvider.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public JvmVisibility getDefaultJvmVisibility(EObject element) {
	EObject realObject = element;
	if (realObject instanceof JvmIdentifiableElement) {
		final EObject obj = this.associations.getPrimarySourceElement(realObject);
		if (obj != null) {
			realObject = obj;
		}
	}
	if (realObject instanceof XtendMemberImplCustom) {
		try {
			return (JvmVisibility) this.visiblityMethod.invoke(realObject);
		} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
			throw new RuntimeException(exception);
		}
	}
	return JvmVisibility.DEFAULT;
}
 
Example 3
Source File: ContextualVisibilityHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean isVisible(JvmMember member) {
	// TODO private visibility?
	JvmVisibility visibility = member.getVisibility();
	if (visibility == JvmVisibility.PUBLIC) {
		return true;
	}
	JvmDeclaredType type = member instanceof JvmDeclaredType ? (JvmDeclaredType) member : member.getDeclaringType();
	if (type == rawContextType || EcoreUtil.isAncestor(rawContextType, type)) {
		return true;
	}
	if (type != null && visibility == JvmVisibility.PROTECTED) {
		if (superTypeNames == null) {
			this.superTypeNames = computeSuperTypeNames();
		}
		if (superTypeNames.contains(type.getIdentifier())) {
			return true;
		}
		if (type == member) {
			JvmDeclaredType declaringType = member.getDeclaringType();
			if (declaringType != null && superTypeNames.contains(declaringType.getIdentifier())) {
				return true;
			}
		}
	}
	if (type != null 
			&& (rawContextType == null || rawContextType instanceof JvmDeclaredType) 
			&& (visibility == JvmVisibility.DEFAULT || visibility == JvmVisibility.PROTECTED)) {
		if (Strings.isEmpty(packageName) && Strings.isEmpty(type.getPackageName())
				|| (packageName != null && packageName.equals(type.getPackageName()))) {
			return true;
		}
	}
	return parent.isVisible(member);
}
 
Example 4
Source File: XtendMemberImplCustom.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JvmVisibility getDeclaredVisibility() {
	for(String modifier: getModifiers()) {
		if(equal(modifier, "public")) 
			return JvmVisibility.PUBLIC;
		if(equal(modifier, "package")) 
			return JvmVisibility.DEFAULT;
		if(equal(modifier, "protected")) 
			return JvmVisibility.PROTECTED;
		if(equal(modifier, "private")) 
			return JvmVisibility.PRIVATE;
	}
	return null;
}
 
Example 5
Source File: DefaultVisibilityProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("checkstyle:npathcomplexity")
public JvmVisibility getDefaultJvmVisibility(EObject container, EClass element) {
	EObject realObject = container;
	if (realObject instanceof JvmIdentifiableElement) {
		final EObject obj = this.associations.getPrimarySourceElement(realObject);
		if (obj != null) {
			realObject = obj;
		}
	}
	if (realObject != null) {
		if (XtendPackage.eINSTANCE.getXtendFunction().isSuperTypeOf(element)) {
			return IDefaultVisibilityProvider.getActionDefaultVisibilityIn(realObject);
		}
		if (XtendPackage.eINSTANCE.getXtendField().isSuperTypeOf(element)) {
			return IDefaultVisibilityProvider.getFieldDefaultVisibilityIn(realObject);
		}
		if (XtendPackage.eINSTANCE.getXtendClass().isSuperTypeOf(element)) {
			return IDefaultVisibilityProvider.getClassDefaultVisibilityIn(realObject);
		}
		if (XtendPackage.eINSTANCE.getXtendInterface().isSuperTypeOf(element)) {
			return IDefaultVisibilityProvider.getInterfaceDefaultVisibilityIn(realObject);
		}
		if (XtendPackage.eINSTANCE.getXtendEnum().isSuperTypeOf(element)) {
			return IDefaultVisibilityProvider.getEnumerationDefaultVisibilityIn(realObject);
		}
		if (XtendPackage.eINSTANCE.getXtendAnnotationType().isSuperTypeOf(element)) {
			return IDefaultVisibilityProvider.getAnnotationTypeDefaultVisibilityIn(realObject);
		}
		if (XtendPackage.eINSTANCE.getXtendMember().isSuperTypeOf(element)) {
			return JvmVisibility.PUBLIC;
		}
	}
	return JvmVisibility.DEFAULT;
}
 
Example 6
Source File: AnonymousClassImplCustom.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public JvmVisibility getDeclaredVisibility() {
	return JvmVisibility.DEFAULT;
}
 
Example 7
Source File: AnonymousClassImplCustom.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public JvmVisibility getVisibility() {
	return JvmVisibility.DEFAULT;
}
 
Example 8
Source File: SARLLabelProvider.java    From sarl with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("checkstyle:npathcomplexity")
@Override
public ImageDescriptor getImageDescriptorForQualifiedName(String qualifiedName, Notifier context,
		IJvmTypeProvider typeProvider) {
	JvmType type = null;
	if (typeProvider != null) {
		type = typeProvider.findTypeByName(qualifiedName);
	}
	if (type == null && context != null) {
		type = this.services.getTypeReferences().findDeclaredType(qualifiedName, context);
	}
	int adornments = this.adornments.get(type);
	JvmVisibility visibility = JvmVisibility.DEFAULT;
	if (type != null) {
		if (type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
			final JvmGenericType gtype = (JvmGenericType) type;
			visibility = gtype.getVisibility();
			final int ecoreCode = this.inheritanceHelper.getSarlElementEcoreType(gtype);
			switch (ecoreCode) {
			case SarlPackage.SARL_AGENT:
				return this.images.forAgent(visibility, this.adornments.get(gtype));
			case SarlPackage.SARL_BEHAVIOR:
				return this.images.forBehavior(visibility, this.adornments.get(gtype));
			case SarlPackage.SARL_CAPACITY:
				// Remove the "abstract" ornment because capacities are always abstract.
				adornments = (adornments & JavaElementImageDescriptor.ABSTRACT) ^ adornments;
				return this.images.forCapacity(visibility, adornments);
			case SarlPackage.SARL_EVENT:
				return this.images.forEvent(visibility, this.adornments.get(gtype));
			case SarlPackage.SARL_SKILL:
				return this.images.forSkill(visibility, this.adornments.get(gtype));
			default:
				if (gtype.isInterface()) {
					return this.images.forInterface(visibility, this.adornments.get(gtype));
				}
			}
		} else if (type.eClass() == TypesPackage.Literals.JVM_ENUMERATION_TYPE) {
			final JvmEnumerationType etype = (JvmEnumerationType) type;
			visibility = etype.getVisibility();
			return this.images.forEnum(visibility, adornments);
		} else if (type.eClass() == TypesPackage.Literals.JVM_ANNOTATION_TYPE) {
			final JvmAnnotationType atype = (JvmAnnotationType) type;
			visibility = atype.getVisibility();
			return this.images.forAnnotation(visibility, adornments);
		} else {
			visibility = JvmVisibility.DEFAULT;
		}
	}
	// Default icon is the class icon.
	return this.images.forClass(visibility, adornments);
}
 
Example 9
Source File: SARLValidator.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("synthetic-access")
protected boolean isPackageByDefault(XtendMember member) {
	final JvmVisibility defaultVisibility = SARLValidator.this.defaultVisibilityProvider.getDefaultJvmVisibility(member);
	return defaultVisibility == JvmVisibility.DEFAULT;
}