当前位置: 首页>>代码示例>>Java>>正文


Java XAnnotationElementValuePair类代码示例

本文整理汇总了Java中org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair的典型用法代码示例。如果您正苦于以下问题:Java XAnnotationElementValuePair类的具体用法?Java XAnnotationElementValuePair怎么用?Java XAnnotationElementValuePair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XAnnotationElementValuePair类属于org.eclipse.xtext.xbase.annotations.xAnnotations包,在下文中一共展示了XAnnotationElementValuePair类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _toJavaExpression

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
protected void _toJavaExpression(final XAnnotation annotation, final ITreeAppendable b) {
	b.append("@");
	b.append(annotation.getAnnotationType());
	XExpression value = annotation.getValue();
	if (value != null) {
		b.append("(");
		internalToJavaExpression(value, b);
		b.append(")");
	} else {
		EList<XAnnotationElementValuePair> valuePairs = annotation.getElementValuePairs();
		if (valuePairs.isEmpty())
			return;
		b.append("(");
		for (int i = 0; i < valuePairs.size(); i++) {
			XAnnotationElementValuePair pair = valuePairs.get(i);
			b.append(pair.getElement().getSimpleName());
			b.append(" = ");
			internalToJavaExpression(pair.getValue(), b);
			if (i < valuePairs.size()-1) {
				b.append(", ");
			}
		}
		b.append(")");
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:XbaseCompiler.java

示例2: eSet

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
	switch (featureID)
	{
		case XAnnotationsPackage.XANNOTATION__ELEMENT_VALUE_PAIRS:
			getElementValuePairs().clear();
			getElementValuePairs().addAll((Collection<? extends XAnnotationElementValuePair>)newValue);
			return;
		case XAnnotationsPackage.XANNOTATION__ANNOTATION_TYPE:
			setAnnotationType((JvmType)newValue);
			return;
		case XAnnotationsPackage.XANNOTATION__VALUE:
			setValue((XExpression)newValue);
			return;
	}
	super.eSet(featureID, newValue);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:XAnnotationImpl.java

示例3: testStringAnnotationWithNullExpression

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
@Test
public void testStringAnnotationWithNullExpression() {
  try {
    final XAnnotationsFactory f = XAnnotationsFactory.eINSTANCE;
    final XExpression context = this.expression("\'Foo\'");
    final XAnnotation anno = f.createXAnnotation();
    JvmType _findDeclaredType = this.references.findDeclaredType(Inject.class, context);
    anno.setAnnotationType(((JvmAnnotationType) _findDeclaredType));
    final XAnnotationElementValuePair pair = f.createXAnnotationElementValuePair();
    EList<XAnnotationElementValuePair> _elementValuePairs = anno.getElementValuePairs();
    this._jvmTypesBuilder.<XAnnotationElementValuePair>operator_add(_elementValuePairs, pair);
    final JvmGenericType type = this.typesFactory.createJvmGenericType();
    this._jvmTypesBuilder.addAnnotation(type, anno);
    Assert.assertEquals(anno.getAnnotationType(), IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getAnnotation());
    Assert.assertTrue(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getExplicitValues().isEmpty());
    Assert.assertFalse(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues().isEmpty());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:JvmTypesBuilderTest.java

示例4: testIntegerAnnotation

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
@Test
public void testIntegerAnnotation() {
  try {
    final XAnnotationsFactory f = XAnnotationsFactory.eINSTANCE;
    final XExpression e = this.expression("\'Foo\'");
    final XAnnotation anno = f.createXAnnotation();
    JvmType _findDeclaredType = this.references.findDeclaredType(TestAnnotation3.class, e);
    final JvmAnnotationType annotatiomType = ((JvmAnnotationType) _findDeclaredType);
    anno.setAnnotationType(annotatiomType);
    final XAnnotationElementValuePair pair = f.createXAnnotationElementValuePair();
    pair.setElement(IterableExtensions.<JvmOperation>head(annotatiomType.getDeclaredOperations()));
    pair.setValue(this.expression("10"));
    EList<XAnnotationElementValuePair> _elementValuePairs = anno.getElementValuePairs();
    this._jvmTypesBuilder.<XAnnotationElementValuePair>operator_add(_elementValuePairs, pair);
    final JvmGenericType type = this.typesFactory.createJvmGenericType();
    this._jvmTypesBuilder.addAnnotation(type, anno);
    Assert.assertEquals(anno.getAnnotationType(), IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getAnnotation());
    Assert.assertEquals(1, IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues().size());
    JvmAnnotationValue _head = IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues());
    final JvmCustomAnnotationValue value = ((JvmCustomAnnotationValue) _head);
    EObject _head_1 = IterableExtensions.<EObject>head(value.getValues());
    Assert.assertTrue((_head_1 instanceof XNumberLiteral));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:JvmTypesBuilderTest.java

示例5: sequence_XAnnotationElementValuePair

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
/**
 * Contexts:
 *     XAnnotationElementValuePair returns XAnnotationElementValuePair
 *
 * Constraint:
 *     (element=[JvmOperation|ValidID] value=XAnnotationElementValue)
 */
protected void sequence_XAnnotationElementValuePair(ISerializationContext context, XAnnotationElementValuePair semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT));
		if (transientValues.isValueTransient(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getXAnnotationElementValuePairAccess().getElementJvmOperationValidIDParserRuleCall_0_0_0_0_1(), semanticObject.eGet(XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT, false));
	feeder.accept(grammarAccess.getXAnnotationElementValuePairAccess().getValueXAnnotationElementValueParserRuleCall_1_0(), semanticObject.getValue());
	feeder.finish();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:AbstractXbaseWithAnnotationsSemanticSequencer.java

示例6: getJvmAnnotationReference

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
/**
 * Translates a single {@link XAnnotation} to {@link JvmAnnotationReference} that can be added to a {@link JvmAnnotationTarget}.
 * 
 * @param anno the source annotation
 * 
 * @return a {@link JvmAnnotationReference} that can be attached to some {@link JvmAnnotationTarget}
 */
/* @Nullable */ 
public JvmAnnotationReference getJvmAnnotationReference(/* @Nullable */ XAnnotation anno) {
	if(anno == null)
		return null;
	JvmAnnotationReference reference = typesFactory.createJvmAnnotationReference();
	final JvmType annotation = (JvmType) anno.eGet(
			XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE, false);
	if (annotation.eIsProxy()) {
		JvmAnnotationType copiedProxy = TypesFactory.eINSTANCE.createJvmAnnotationType();
		((InternalEObject)copiedProxy).eSetProxyURI(EcoreUtil.getURI(annotation));
		reference.setAnnotation(copiedProxy);
	} else if (annotation instanceof JvmAnnotationType){
		reference.setAnnotation((JvmAnnotationType) annotation);
	}
	for (XAnnotationElementValuePair val : anno.getElementValuePairs()) {
		XExpression valueExpression = val.getValue();
		JvmAnnotationValue annotationValue = toJvmAnnotationValue(valueExpression);
		if (annotationValue != null) {
			JvmOperation op = (JvmOperation) val.eGet(
					XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT, false);
			annotationValue.setOperation(op);
			reference.getExplicitValues().add(annotationValue);
		}
	}
	if (anno.getValue() != null) {
		JvmAnnotationValue value = toJvmAnnotationValue(anno.getValue());
		if (value != null) {
			reference.getExplicitValues().add(value);
		}
	}
	associate(anno, reference);
	return reference;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:41,代码来源:JvmTypesBuilder.java

示例7: isPropertyOfUnresolvedAnnotation

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
protected boolean isPropertyOfUnresolvedAnnotation(ILinkingDiagnosticContext context) {
	EObject object = context.getContext();
	if (object instanceof XAnnotationElementValuePair && context.getReference() == XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT) {
		XAnnotation annotation = EcoreUtil2.getContainerOfType(object, XAnnotation.class);
		if (annotation != null) {
			JvmType annotationType = annotation.getAnnotationType();
			if (annotationType == null || annotationType.eIsProxy() || !(annotationType instanceof JvmAnnotationType)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:UnresolvedAnnotationTypeAwareMessageProvider.java

示例8: computeChildTypesForUnknownAnnotation

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
protected void computeChildTypesForUnknownAnnotation(XAnnotation object, ITypeComputationState state) {
	XExpression expression = object.getValue();
	if (expression != null)
		state.withNonVoidExpectation().computeTypes(expression);
	else {
		List<XAnnotationElementValuePair> valuePairs = object.getElementValuePairs();
		for(XAnnotationElementValuePair pair: valuePairs) {
			computeTypes(object, pair.getElement(), pair.getValue(), state);
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:XbaseWithAnnotationsTypeComputer.java

示例9: findValue

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
public XExpression findValue(XAnnotation annotation, JvmOperation jvmOperation) {
	if (jvmOperation.getSimpleName().equals("value") && annotation.getValue() != null) {
		return annotation.getValue();
	}
	for (XAnnotationElementValuePair pair : annotation.getElementValuePairs()) {
		if (pair.getElement() == jvmOperation)
			return pair.getValue();
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XAnnotationUtil.java

示例10: initializePackageContents

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
/**
 * Complete the initialization of the package and its meta-model.  This
 * method is guarded to have no affect on any invocation but its first.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void initializePackageContents()
{
	if (isInitialized) return;
	isInitialized = true;

	// Initialize package
	setName(eNAME);
	setNsPrefix(eNS_PREFIX);
	setNsURI(eNS_URI);

	// Obtain other dependent packages
	XbasePackage theXbasePackage = (XbasePackage)EPackage.Registry.INSTANCE.getEPackage(XbasePackage.eNS_URI);
	TypesPackage theTypesPackage = (TypesPackage)EPackage.Registry.INSTANCE.getEPackage(TypesPackage.eNS_URI);

	// Create type parameters

	// Set bounds for type parameters

	// Add supertypes to classes
	xAnnotationEClass.getESuperTypes().add(theXbasePackage.getXExpression());

	// Initialize classes and features; add operations and parameters
	initEClass(xAnnotationEClass, XAnnotation.class, "XAnnotation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
	initEReference(getXAnnotation_ElementValuePairs(), this.getXAnnotationElementValuePair(), null, "elementValuePairs", null, 0, -1, XAnnotation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getXAnnotation_AnnotationType(), theTypesPackage.getJvmType(), null, "annotationType", null, 0, 1, XAnnotation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getXAnnotation_Value(), theXbasePackage.getXExpression(), null, "value", null, 0, 1, XAnnotation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

	initEClass(xAnnotationElementValuePairEClass, XAnnotationElementValuePair.class, "XAnnotationElementValuePair", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
	initEReference(getXAnnotationElementValuePair_Value(), theXbasePackage.getXExpression(), null, "value", null, 0, 1, XAnnotationElementValuePair.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getXAnnotationElementValuePair_Element(), theTypesPackage.getJvmOperation(), null, "element", null, 0, 1, XAnnotationElementValuePair.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

	// Create resource
	createResource(eNS_URI);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:42,代码来源:XAnnotationsPackageImpl.java

示例11: getElementValuePairs

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public EList<XAnnotationElementValuePair> getElementValuePairs()
{
	if (elementValuePairs == null)
	{
		elementValuePairs = new EObjectContainmentEList<XAnnotationElementValuePair>(XAnnotationElementValuePair.class, this, XAnnotationsPackage.XANNOTATION__ELEMENT_VALUE_PAIRS);
	}
	return elementValuePairs;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:XAnnotationImpl.java

示例12: testErrorModel_01

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
@Test
public void testErrorModel_01() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("estdata.Annotation2(value = \'foo\')");
  _builder.newLine();
  final XAnnotation annotation = this.processWithoutException(_builder);
  final XAnnotationElementValuePair singleValuePair = IterableExtensions.<XAnnotationElementValuePair>head(annotation.getElementValuePairs());
  Assert.assertNotNull(this.batchTypeResolver.resolveTypes(annotation).getActualType(singleValuePair.getValue()));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:ErrorTest.java

示例13: sequence_XAnnotationElementValuePair

import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair; //导入依赖的package包/类
/**
 * Constraint:
 *     (element=[JvmOperation|ValidID] value=XAnnotationElementValue)
 */
protected void sequence_XAnnotationElementValuePair(EObject context, XAnnotationElementValuePair semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE));
		if(transientValues.isValueTransient(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getXAnnotationElementValuePairAccess().getElementJvmOperationValidIDParserRuleCall_0_0_0_0_1(), semanticObject.getElement());
	feeder.accept(grammarAccess.getXAnnotationElementValuePairAccess().getValueXAnnotationElementValueParserRuleCall_1_0(), semanticObject.getValue());
	feeder.finish();
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:18,代码来源:AbstractCheckSemanticSequencer.java


注:本文中的org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。