org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationsPackage Java Examples

The following examples show how to use org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationsPackage. 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: DiscouragedAnnotationTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlValidation")
public void perceptGuardEvaluator() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import io.sarl.lang.annotation.PerceptGuardEvaluator",
			"agent A1 {",
			"	@PerceptGuardEvaluator",
			"	def fct {",
			"	}",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertWarning(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			IssueCodes.USED_RESERVED_SARL_ANNOTATION,
			"Discouraged use of reserved annotation");
}
 
Example #2
Source File: DiscouragedAnnotationTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlValidation")
public void defaultValueUse() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import io.sarl.lang.annotation.DefaultValueUse",
			"agent A1 {",
			"	@DefaultValueUse(\"\")",
			"	def fct {",
			"	}",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertWarning(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			IssueCodes.USED_RESERVED_SARL_ANNOTATION,
			"Discouraged use of reserved annotation");
}
 
Example #3
Source File: XAnnotationImpl.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eUnset(int featureID)
{
	switch (featureID)
	{
		case XAnnotationsPackage.XANNOTATION__ELEMENT_VALUE_PAIRS:
			getElementValuePairs().clear();
			return;
		case XAnnotationsPackage.XANNOTATION__ANNOTATION_TYPE:
			setAnnotationType((JvmType)null);
			return;
		case XAnnotationsPackage.XANNOTATION__VALUE:
			setValue((XExpression)null);
			return;
	}
	super.eUnset(featureID);
}
 
Example #4
Source File: DiscouragedAnnotationTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlValidation")
public void earlyExit_onFunction() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import io.sarl.lang.annotation.EarlyExit",
			"agent A1 {",
			"   @EarlyExit",
			"	def fct {",
			"	}",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertWarning(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			IssueCodes.USED_RESERVED_SARL_ANNOTATION,
			"Discouraged use of reserved annotation");
}
 
Example #5
Source File: XtendStandaloneSetup.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Injector createInjectorAndDoEMFRegistration() {
	// don't call super, since that would create useless injectors for all the super languages.
	// register default ePackages
	if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().
		put("ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
	if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().
		put("xmi", new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl());
	if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) Resource.Factory.Registry.INSTANCE.
		getExtensionToFactoryMap().put("xtextbin", new org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl());
	if (!EPackage.Registry.INSTANCE.containsKey(org.eclipse.xtext.XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(
		org.eclipse.xtext.XtextPackage.eNS_URI, org.eclipse.xtext.XtextPackage.eINSTANCE);
	// // register used EPackages
	EPackage.Registry.INSTANCE.put(XtendPackage.eINSTANCE.getNsURI(), XtendPackage.eINSTANCE);
	EPackage.Registry.INSTANCE.put(XbasePackage.eINSTANCE.getNsURI(), XbasePackage.eINSTANCE);
	EPackage.Registry.INSTANCE.put(XAnnotationsPackage.eINSTANCE.getNsURI(), XAnnotationsPackage.eINSTANCE);
	EPackage.Registry.INSTANCE.put(TypesPackage.eINSTANCE.getNsURI(), TypesPackage.eINSTANCE);
	EPackage.Registry.INSTANCE.put(XtypePackage.eINSTANCE.getNsURI(), XtypePackage.eINSTANCE);
	Injector injector = createInjector();
	register(injector);
	return injector;
}
 
Example #6
Source File: XAnnotationElementValuePairImpl.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setValue(XExpression newValue)
{
	if (newValue != value)
	{
		NotificationChain msgs = null;
		if (value != null)
			msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XAnnotationsPackage.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE, null, msgs);
		if (newValue != null)
			msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XAnnotationsPackage.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE, null, msgs);
		msgs = basicSetValue(newValue, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, XAnnotationsPackage.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE, newValue, newValue));
}
 
Example #7
Source File: CreateJavaTypeQuickfixes.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void addQuickfixes(Issue issue, IssueResolutionAcceptor issueResolutionAcceptor,
		IXtextDocument xtextDocument, XtextResource resource, 
		EObject referenceOwner, EReference unresolvedReference)
		throws Exception {
	String typeString = (issue.getData() != null && issue.getData().length > 0) 
			? issue.getData()[0] 
			: xtextDocument.get(issue.getOffset(), issue.getLength());
	Pair<String, String> packageAndType = typeNameGuesser.guessPackageAndTypeName(referenceOwner, typeString);
	String packageName = packageAndType.getFirst();
	if(isEmpty(packageAndType.getSecond()))
		return;
	String typeName = packageAndType.getSecond();
	if (unresolvedReference == XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR) {
		if(((XConstructorCall)referenceOwner).getConstructor().eIsProxy())
			newJavaClassQuickfix(typeName, packageName, resource, issue, issueResolutionAcceptor);
	} else if(unresolvedReference == XbasePackage.Literals.XTYPE_LITERAL__TYPE
			|| unresolvedReference == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE) {
		newJavaClassQuickfix(typeName, packageName, resource, issue, issueResolutionAcceptor);
		newJavaInterfaceQuickfix(typeName, packageName, resource, issue, issueResolutionAcceptor);
	} else if(unresolvedReference == XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE) {
		newJavaAnnotationQuickfix(typeName, packageName, resource, issue, issueResolutionAcceptor);
	}
}
 
Example #8
Source File: DiscouragedAnnotationTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlValidation")
public void syntheticMember() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import io.sarl.lang.annotation.SyntheticMember",
			"agent A1 {",
			"   @SyntheticMember",
			"	def fct {",
			"	}",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertWarning(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			IssueCodes.USED_RESERVED_SARL_ANNOTATION,
			"Discouraged use of reserved annotation");
}
 
Example #9
Source File: XAnnotationImpl.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
	switch (featureID)
	{
		case XAnnotationsPackage.XANNOTATION__ELEMENT_VALUE_PAIRS:
			return getElementValuePairs();
		case XAnnotationsPackage.XANNOTATION__ANNOTATION_TYPE:
			if (resolve) return getAnnotationType();
			return basicGetAnnotationType();
		case XAnnotationsPackage.XANNOTATION__VALUE:
			return getValue();
	}
	return super.eGet(featureID, resolve, coreType);
}
 
Example #10
Source File: ManualInlineAnnotationTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlValidation")
public void testDefaultValue() throws Exception {
	try {
		SarlScript mas = file(getParseHelper(), multilineString(
				"import org.eclipse.xtext.xbase.lib.Inline",
				"agent A1 {",
				"   @Inline(\"\")",
				"	def fct() {",
				"	}",
				"}"
				));
		validate(getValidationHelper(), getInjector(), mas).assertWarning(
				XAnnotationsPackage.eINSTANCE.getXAnnotation(),
				IssueCodes.MANUAL_INLINE_DEFINITION,
				"Discouraged manual definition of an inline expression");
	} catch (Throwable e) {
		e.printStackTrace();
		Throwables.propagate(e);
	}
}
 
Example #11
Source File: DiscouragedAnnotationTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlValidation")
public void defaultValueSource() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import io.sarl.lang.annotation.DefaultValueSource",
			"agent A1 {",
			"	@DefaultValueSource",
			"	def fct {",
			"	}",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertWarning(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			IssueCodes.USED_RESERVED_SARL_ANNOTATION,
			"Discouraged use of reserved annotation");
}
 
Example #12
Source File: DiscouragedAnnotationTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlValidation")
public void sarlSourceCode() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import io.sarl.lang.annotation.SarlSourceCode",
			"agent A1 {",
			"	@SarlSourceCode",
			"	def fct {",
			"	}",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertWarning(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			IssueCodes.USED_RESERVED_SARL_ANNOTATION,
			"Discouraged use of reserved annotation");
}
 
Example #13
Source File: SarlPackageImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link SarlPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static SarlPackage init()
{
	if (isInited) return (SarlPackage)EPackage.Registry.INSTANCE.getEPackage(SarlPackage.eNS_URI);

	// Obtain or create and register package
	Object registeredSarlPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
	SarlPackageImpl theSarlPackage = registeredSarlPackage instanceof SarlPackageImpl ? (SarlPackageImpl)registeredSarlPackage : new SarlPackageImpl();

	isInited = true;

	// Initialize simple dependencies
	XtendPackage.eINSTANCE.eClass();
	TypesPackage.eINSTANCE.eClass();
	XbasePackage.eINSTANCE.eClass();
	XtypePackage.eINSTANCE.eClass();
	XAnnotationsPackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theSarlPackage.createPackageContents();

	// Initialize created meta-data
	theSarlPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theSarlPackage.freeze();

	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(SarlPackage.eNS_URI, theSarlPackage);
	return theSarlPackage;
}
 
Example #14
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inEvent_02() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.Accessors",
			"import org.eclipse.xtend.lib.annotations.AccessorType",
			"@Accessors(PROTECTED_SETTER) event E1 {",
			"	var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}
 
Example #15
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inEventField_02() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.Accessors",
			"import org.eclipse.xtend.lib.annotations.AccessorType",
			"event E1 {",
			"	@Accessors(PROTECTED_SETTER) var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}
 
Example #16
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inSkillField_01() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.Accessors",
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"	@Accessors var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertNoErrors(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
}
 
Example #17
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inCapacity_01() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.Data",
			"@Data capacity C1 {",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}
 
Example #18
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inSkill_02() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.Accessors",
			"import org.eclipse.xtend.lib.annotations.AccessorType",
			"capacity C1 { }",
			"@Accessors(PROTECTED_SETTER) skill S1 implements C1 {",
			"	var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertNoErrors(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
}
 
Example #19
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inBehavior_01() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.Delegate",
			"@Delegate behavior B1 {",
			"	var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}
 
Example #20
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inClass_01() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor",
			"@FinalFieldsConstructor class C1 {",
			"	var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}
 
Example #21
Source File: SARLUIValidator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected List<EPackage> getEPackages() {
	final List<EPackage> packages = super.getEPackages();
	packages.add(io.sarl.lang.sarl.SarlPackage.eINSTANCE);
	packages.add(XtendPackage.eINSTANCE);
	packages.add(XbasePackage.eINSTANCE);
	packages.add(TypesPackage.eINSTANCE);
	packages.add(XtypePackage.eINSTANCE);
	packages.add(XAnnotationsPackage.eINSTANCE);
	return packages;
}
 
Example #22
Source File: CheckPackageImpl.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 * 
 * <p>This method is used to initialize {@link CheckPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static CheckPackage init()
{
	if (isInited) return (CheckPackage)EPackage.Registry.INSTANCE.getEPackage(CheckPackage.eNS_URI);

	// Obtain or create and register package
	CheckPackageImpl theCheckPackage = (CheckPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof CheckPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new CheckPackageImpl());

	isInited = true;

	// Initialize simple dependencies
	XAnnotationsPackage.eINSTANCE.eClass();
	XbasePackage.eINSTANCE.eClass();
	XtypePackage.eINSTANCE.eClass();
	XtextPackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theCheckPackage.createPackageContents();

	// Initialize created meta-data
	theCheckPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theCheckPackage.freeze();

 
	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(CheckPackage.eNS_URI, theCheckPackage);
	return theCheckPackage;
}
 
Example #23
Source File: ProblemSupportImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public EStructuralFeature getSignificantFeature(final EObject obj) {
  EStructuralFeature _switchResult = null;
  boolean _matched = false;
  if (obj instanceof XtendTypeDeclaration) {
    _matched=true;
    _switchResult = XtendPackage.eINSTANCE.getXtendTypeDeclaration_Name();
  }
  if (!_matched) {
    if (obj instanceof XtendField) {
      _matched=true;
      _switchResult = XtendPackage.eINSTANCE.getXtendField_Name();
    }
  }
  if (!_matched) {
    if (obj instanceof XtendFunction) {
      _matched=true;
      _switchResult = XtendPackage.eINSTANCE.getXtendFunction_Name();
    }
  }
  if (!_matched) {
    if (obj instanceof JvmFormalParameter) {
      _matched=true;
      _switchResult = TypesPackage.eINSTANCE.getJvmFormalParameter_Name();
    }
  }
  if (!_matched) {
    if (obj instanceof XAnnotation) {
      _matched=true;
      _switchResult = XAnnotationsPackage.eINSTANCE.getXAnnotation_AnnotationType();
    }
  }
  return _switchResult;
}
 
Example #24
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inBehavior_01() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.EqualsHashCode",
			"@EqualsHashCode behavior B1 {",
			"	var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}
 
Example #25
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inAgent_01() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.EqualsHashCode",
			"@EqualsHashCode agent A1 {",
			"	var field : double = 0",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}
 
Example #26
Source File: XAnnotationExtensions.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Checks whether this annotation is pointing to a processed annotation, without resolving the proxy
 */
public boolean isProcessed(final XAnnotation it) {
  Object _eGet = it.eGet(XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE, false);
  final Object proxy = _eGet;
  boolean _matched = false;
  if (proxy instanceof EObject) {
    boolean _eIsProxy = ((EObject)proxy).eIsProxy();
    if (_eIsProxy) {
      _matched=true;
      final URI uri = ((InternalEObject) proxy).eProxyURI();
      boolean _isCrossLinkFragment = this.encoder.isCrossLinkFragment(it.eResource(), uri.fragment());
      if (_isCrossLinkFragment) {
        final Triple<EObject, EReference, INode> triple = this.encoder.decode(it.eResource(), uri.fragment());
        final List<EObject> candidates = this.linkingService.getLinkedObjects(triple.getFirst(), triple.getSecond(), triple.getThird());
        boolean _isEmpty = candidates.isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
          final EObject head = IterableExtensions.<EObject>head(candidates);
          if ((head instanceof JvmAnnotationType)) {
            return this.isActiveAnnotation(((JvmAnnotationType)head));
          }
        }
      }
    }
  }
  if (!_matched) {
    if (proxy instanceof JvmAnnotationType) {
      _matched=true;
      return this.isActiveAnnotation(((JvmAnnotationType)proxy));
    }
  }
  return false;
}
 
Example #27
Source File: ProcessedRichStringPackageImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link ProcessedRichStringPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static ProcessedRichStringPackage init()
{
	if (isInited) return (ProcessedRichStringPackage)EPackage.Registry.INSTANCE.getEPackage(ProcessedRichStringPackage.eNS_URI);

	// Obtain or create and register package
	Object registeredProcessedRichStringPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
	ProcessedRichStringPackageImpl theProcessedRichStringPackage = registeredProcessedRichStringPackage instanceof ProcessedRichStringPackageImpl ? (ProcessedRichStringPackageImpl)registeredProcessedRichStringPackage : new ProcessedRichStringPackageImpl();

	isInited = true;

	// Initialize simple dependencies
	TypesPackage.eINSTANCE.eClass();
	XAnnotationsPackage.eINSTANCE.eClass();
	XbasePackage.eINSTANCE.eClass();
	XtendPackage.eINSTANCE.eClass();
	XtypePackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theProcessedRichStringPackage.createPackageContents();

	// Initialize created meta-data
	theProcessedRichStringPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theProcessedRichStringPackage.freeze();

	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(ProcessedRichStringPackage.eNS_URI, theProcessedRichStringPackage);
	return theProcessedRichStringPackage;
}
 
Example #28
Source File: XtendPackageImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link XtendPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static XtendPackage init()
{
	if (isInited) return (XtendPackage)EPackage.Registry.INSTANCE.getEPackage(XtendPackage.eNS_URI);

	// Obtain or create and register package
	Object registeredXtendPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
	XtendPackageImpl theXtendPackage = registeredXtendPackage instanceof XtendPackageImpl ? (XtendPackageImpl)registeredXtendPackage : new XtendPackageImpl();

	isInited = true;

	// Initialize simple dependencies
	TypesPackage.eINSTANCE.eClass();
	XAnnotationsPackage.eINSTANCE.eClass();
	XbasePackage.eINSTANCE.eClass();
	XtypePackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theXtendPackage.createPackageContents();

	// Initialize created meta-data
	theXtendPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theXtendPackage.freeze();

	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(XtendPackage.eNS_URI, theXtendPackage);
	return theXtendPackage;
}
 
Example #29
Source File: XtendValidator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Check
public void checkMultipleAnnotations(final XtendAnnotationTarget annotationTarget) {
	if (annotationTarget.getAnnotations().size() <= 1 || !isRelevantAnnotationTarget(annotationTarget)) {
		return;
	}
	
	ImmutableListMultimap<String, XAnnotation> groupByIdentifier = Multimaps.index(annotationTarget.getAnnotations(),
			new Function<XAnnotation, String>() {
				@Override
				public String apply(XAnnotation input) {
					return input.getAnnotationType().getIdentifier();
				}
			});

	for (String qName : groupByIdentifier.keySet()) {
		ImmutableList<XAnnotation> sameType = groupByIdentifier.get(qName);
		if (sameType.size() > 1) {
			JvmType type = sameType.get(0).getAnnotationType();
			if (type instanceof JvmAnnotationType && !type.eIsProxy()
					&& !annotationLookup.isRepeatable((JvmAnnotationType) type)) {
				for (XAnnotation xAnnotation : sameType) {
					error("Multiple annotations of non-repeatable type @"
							+ xAnnotation.getAnnotationType().getSimpleName()
							+ ". Only annotation types marked @Repeatable can be used multiple times at one target.",
							xAnnotation, XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE, INSIGNIFICANT_INDEX, ANNOTATION_MULTIPLE);
				}
			}
		}
	}
}
 
Example #30
Source File: ActiveAnnotationTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
@Tag("sarlValidation")
public void inCapacity_01() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"import org.eclipse.xtend.lib.annotations.EqualsHashCode",
			"@EqualsHashCode capacity C1 {",
			"}"
			));
	validate(getValidationHelper(), getInjector(), mas).assertError(
			XAnnotationsPackage.eINSTANCE.getXAnnotation(),
			org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE,
			"Forbidden annotation");
}