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


Java IAnnotation类代码示例

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


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

示例1: isHiddenGeneratedElement

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
public static boolean isHiddenGeneratedElement(IJavaElement element) {
	// generated elements are tagged with javax.annotation.Generated and
	// they need to be filtered out
	if (element instanceof IAnnotatable) {
		try {
			IAnnotation[] annotations = ((IAnnotatable) element).getAnnotations();
			if (annotations.length != 0) {
				for (IAnnotation annotation : annotations) {
					if (isSilencedGeneratedAnnotation(annotation)) {
						return true;
					}
				}
			}
		} catch (JavaModelException e) {
			// ignore
		}
	}
	return false;
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:20,代码来源:JDTUtils.java

示例2: isSilencedGeneratedAnnotation

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
private static boolean isSilencedGeneratedAnnotation(IAnnotation annotation) throws JavaModelException {
	if ("javax.annotation.Generated".equals(annotation.getElementName())) {
		IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
		for (IMemberValuePair m : memberValuePairs) {
			if ("value".equals(m.getMemberName()) && IMemberValuePair.K_STRING == m.getValueKind()) {
				if (m.getValue() instanceof String) {
					return SILENCED_CODEGENS.contains(m.getValue());
				} else if (m.getValue() instanceof Object[]) {
					for (Object val : (Object[]) m.getValue()) {
						if (SILENCED_CODEGENS.contains(val)) {
							return true;
						}
					}
				}
			}
		}
	}
	return false;
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:20,代码来源:JDTUtils.java

示例3: parseVertigoDtoField

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
private static void parseVertigoDtoField(IMethod method, List<DtoField> fields) {
	try {
		if (method.isConstructor() || !Flags.isPublic(method.getFlags())) {
			return;
		}
		IAnnotation fieldAnnotation = JdtUtils.getAnnotation(method, FIELD_ANNOTATION_NAME);
		if (fieldAnnotation == null) {
			return;
		}
		String domain = (String) JdtUtils.getMemberValue(fieldAnnotation, DOMAIN_FIELD_NAME);

		/* Cas d'un champ de composition DTO/DTC : on filtre. */
		if (domain == null || domain.startsWith(DTO_DOMAIN_PREFIX)) {
			return;
		}

		String constantCaseName = StringUtils.toConstantCase(KspStringUtils.getFieldNameFromGetter(method.getElementName()));
		String label = (String) JdtUtils.getMemberValue(fieldAnnotation, LABEL_FIELD_NAME);
		Boolean persistent = (Boolean) JdtUtils.getMemberValue(fieldAnnotation, PERSISTENT_FIELD_NAME);

		DtoField field = new DtoField(constantCaseName, label, domain, persistent);
		fields.add(field);
	} catch (JavaModelException e) {
		ErrorUtils.handle(e);
	}
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:27,代码来源:DtoUtils.java

示例4: testFromMethodWithBooleanReturnValueAndIsPropertyReturnsProperty

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
@Test
public void testFromMethodWithBooleanReturnValueAndIsPropertyReturnsProperty()
    throws JavaModelException {
  IMethod method = mock(IMethod.class);
  when(method.getElementName()).thenReturn("isFoo");

  IAnnotation required = mock(IAnnotation.class);
  when(method.getAnnotation(PipelineOptionsNamespaces.validationRequired(version)))
      .thenReturn(required);
  when(required.exists()).thenReturn(false);
  when(required.getElementName())
      .thenReturn(PipelineOptionsNamespaces.validationRequired(version));
  when(method.getAnnotations()).thenReturn(new IAnnotation[] {required});

  IAnnotation description = mock(IAnnotation.class);
  when(description.exists()).thenReturn(false);
  when(method.getAnnotation(PipelineOptionsNamespaces.descriptionAnnotation(version)))
      .thenReturn(description);

  PipelineOptionsProperty property = PipelineOptionsProperty.fromMethod(method, version);

  assertEquals("foo", property.getName());
  assertFalse(property.isRequired());
  assertTrue(property.getGroups().isEmpty());
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:26,代码来源:PipelineOptionsPropertyTest.java

示例5: testFromMethodWithNoValidationRequiredAnnotationIsNotRequired

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
@Test
public void testFromMethodWithNoValidationRequiredAnnotationIsNotRequired()
    throws JavaModelException {
  IMethod method = mock(IMethod.class);
  when(method.getElementName()).thenReturn("getFoo");

  IAnnotation required = mock(IAnnotation.class);
  when(method.getAnnotation(PipelineOptionsNamespaces.validationRequired(version)))
      .thenReturn(required);
  when(required.exists()).thenReturn(false);
  when(required.getElementName())
      .thenReturn(PipelineOptionsNamespaces.validationRequired(version));
  when(method.getAnnotations()).thenReturn(new IAnnotation[] {required});

  IAnnotation description = mock(IAnnotation.class);
  when(description.exists()).thenReturn(false);
  when(method.getAnnotation(PipelineOptionsNamespaces.descriptionAnnotation(version)))
      .thenReturn(description);

  PipelineOptionsProperty property = PipelineOptionsProperty.fromMethod(method, version);

  assertEquals("foo", property.getName());
  assertFalse(property.isRequired());
  assertTrue(property.getGroups().isEmpty());
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:26,代码来源:PipelineOptionsPropertyTest.java

示例6: testFromMethodWithoutDescriptionHasAbsentOptional

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
@Test
public void testFromMethodWithoutDescriptionHasAbsentOptional() throws Exception {
  IMethod method = mock(IMethod.class);
  when(method.getElementName()).thenReturn("getFoo");

  IAnnotation required = mock(IAnnotation.class);
  when(method.getAnnotation(PipelineOptionsNamespaces.validationRequired(version)))
      .thenReturn(required);
  when(required.exists()).thenReturn(false);
  when(required.getElementName())
      .thenReturn(PipelineOptionsNamespaces.validationRequired(version));
  when(method.getAnnotations()).thenReturn(new IAnnotation[] {required});

  IAnnotation description = mock(IAnnotation.class);
  when(description.exists()).thenReturn(false);
  when(method.getAnnotation(PipelineOptionsNamespaces.descriptionAnnotation(version)))
      .thenReturn(description);

  PipelineOptionsProperty property = PipelineOptionsProperty.fromMethod(method, version);

  assertNull(property.getDescription());
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:23,代码来源:PipelineOptionsPropertyTest.java

示例7: isHiddenGeneratedElement

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
public static boolean isHiddenGeneratedElement(IJavaElement element) {
	// generated elements are tagged with javax.annotation.Generated and
	// they need to be filtered out
	if (element instanceof IAnnotatable) {
		try {
			IAnnotation[] annotations = ((IAnnotatable) element).getAnnotations();
			if (annotations.length != 0) {
				for (IAnnotation annotation : annotations) {
					if (isSilencedGeneratedAnnotation(annotation)) {
						return true;
					}
				}
			}
		} catch (JavaModelException e) {
			//ignore
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:JDTUtils.java

示例8: isSilencedGeneratedAnnotation

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
private static boolean isSilencedGeneratedAnnotation(IAnnotation annotation) throws JavaModelException {
	if ("javax.annotation.Generated".equals(annotation.getElementName())) {
		IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
		for (IMemberValuePair m : memberValuePairs) {
			if ("value".equals(m.getMemberName())
					&& IMemberValuePair.K_STRING == m.getValueKind()) {
				if (m.getValue() instanceof String) {
					return SILENCED_CODEGENS.contains(m.getValue());
				} else if (m.getValue() instanceof Object[]) {
					for (Object val : (Object[])m.getValue()) {
						if(SILENCED_CODEGENS.contains(val)) {
							return true;
						}
					}
				}
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:JDTUtils.java

示例9: appendAnnotationLabel

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
public void appendAnnotationLabel(IAnnotation annotation, long flags) throws JavaModelException {
	fBuilder.append('@');
	appendTypeSignatureLabel(annotation, Signature.createTypeSignature(annotation.getElementName(), false), flags);
	IMemberValuePair[] memberValuePairs= annotation.getMemberValuePairs();
	if (memberValuePairs.length == 0) {
		return;
	}
	fBuilder.append('(');
	for (int i= 0; i < memberValuePairs.length; i++) {
		if (i > 0) {
			fBuilder.append(JavaElementLabels.COMMA_STRING);
		}
		IMemberValuePair memberValuePair= memberValuePairs[i];
		fBuilder.append(getMemberName(annotation, annotation.getElementName(), memberValuePair.getMemberName()));
		fBuilder.append('=');
		appendAnnotationValue(annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags);
	}
	fBuilder.append(')');
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:JavaElementLabelComposer.java

示例10: removeSpecialAnnotations

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
/**
 * Remove any annotations that we don't want considered.
 *
 * @param annotationSet
 *            The set of annotations to work with.
 * @param type
 *            The type declaring the annotations.
 * @throws JavaModelException
 *             When resolving the annotation FQN fails.
 */
private void removeSpecialAnnotations(Set<IAnnotation> annotationSet, IType type) throws JavaModelException {
	// Special case: don't consider the @Override annotation in the source
	// (the target will never have this) #67.
	annotationSet.removeIf(a -> a.getElementName().equals(Override.class.getName()));
	annotationSet.removeIf(a -> a.getElementName().equals(Override.class.getSimpleName()));

	// also remove nonstandard annotations if necessary.
	if (!this.shouldConsiderNonstandardAnnotationDifferences())
		for (Iterator<IAnnotation> iterator = annotationSet.iterator(); iterator.hasNext();) {
			IAnnotation annotation = iterator.next();

			String annotationName = annotation.getElementName();
			String[][] resolveTyped = type.resolveType(annotationName);

			for (String[] element : resolveTyped) {
				String[] strings = element;

				// first element is the package name.
				if (!strings[0].startsWith("java.lang"))
					iterator.remove();
			}
		}
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:34,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例11: appendAnnotationLabel

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
public void appendAnnotationLabel(IAnnotation annotation, long flags, StringBuilder builder)
    throws JavaModelException {
  builder.append('@');
  appendTypeSignatureLabel(
      annotation,
      Signature.createTypeSignature(annotation.getElementName(), false),
      flags,
      builder);
  IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
  if (memberValuePairs.length == 0) return;
  builder.append('(');
  for (int i = 0; i < memberValuePairs.length; i++) {
    if (i > 0) builder.append(JavaElementLabels.COMMA_STRING);
    IMemberValuePair memberValuePair = memberValuePairs[i];
    builder.append(
        getMemberName(annotation, annotation.getElementName(), memberValuePair.getMemberName()));
    builder.append('=');
    appendAnnotationValue(
        annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags, builder);
  }
  builder.append(')');
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:SourcesFromBytecodeGenerator.java

示例12: appendFlags

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
protected void appendFlags(final IMember member) throws JavaModelException {
  if (member instanceof IAnnotatable)
    for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
      appendAnnotation(annotation);
    }

  int flags = member.getFlags();
  final int kind = member.getElementType();
  if (kind == IJavaElement.TYPE) {
    flags &= ~Flags.AccSuper;
    final IType type = (IType) member;
    if (!type.isMember()) flags &= ~Flags.AccPrivate;
    if (Flags.isEnum(flags)) flags &= ~Flags.AccAbstract;
  }
  if (Flags.isEnum(flags)) flags &= ~Flags.AccFinal;
  if (kind == IJavaElement.METHOD) {
    flags &= ~Flags.AccVarargs;
    flags &= ~Flags.AccBridge;
  }
  if (flags != 0) fBuffer.append(Flags.toString(flags));
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:StubCreator.java

示例13: appendAnnotation

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
private void appendAnnotation(IAnnotation annotation) throws JavaModelException {
  String name = annotation.getElementName();
  if (!fStubInvisible && name.startsWith("sun.")) // $NON-NLS-1$
  return; // skip Sun-internal annotations

  fBuffer.append('@');
  fBuffer.append(name);
  fBuffer.append('(');

  IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
  for (IMemberValuePair pair : memberValuePairs) {
    fBuffer.append(pair.getMemberName());
    fBuffer.append('=');
    appendAnnotationValue(pair.getValue(), pair.getValueKind());
    fBuffer.append(',');
  }
  if (memberValuePairs.length > 0) fBuffer.deleteCharAt(fBuffer.length() - 1);

  fBuffer.append(')').append('\n');
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:StubCreator.java

示例14: appendAnnotationValue

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
private void appendAnnotationValue(Object value, int valueKind) throws JavaModelException {
  if (value instanceof Object[]) {
    Object[] objects = (Object[]) value;
    fBuffer.append('{');
    for (Object object : objects) {
      appendAnnotationValue(object, valueKind);
      fBuffer.append(',');
    }
    if (objects.length > 0) fBuffer.deleteCharAt(fBuffer.length() - 1);
    fBuffer.append('}');

  } else {
    switch (valueKind) {
      case IMemberValuePair.K_ANNOTATION:
        appendAnnotation((IAnnotation) value);
        break;
      case IMemberValuePair.K_STRING:
        fBuffer.append('"').append(value).append('"');
        break;

      default:
        fBuffer.append(value);
        break;
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:StubCreator.java

示例15: appendAnnotationLabel

import org.eclipse.jdt.core.IAnnotation; //导入依赖的package包/类
public void appendAnnotationLabel(IAnnotation annotation, long flags) throws JavaModelException {
  fBuffer.append('@');
  appendTypeSignatureLabel(
      annotation, Signature.createTypeSignature(annotation.getElementName(), false), flags);
  IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
  if (memberValuePairs.length == 0) return;
  fBuffer.append('(');
  for (int i = 0; i < memberValuePairs.length; i++) {
    if (i > 0) fBuffer.append(JavaElementLabels.COMMA_STRING);
    IMemberValuePair memberValuePair = memberValuePairs[i];
    fBuffer.append(
        getMemberName(annotation, annotation.getElementName(), memberValuePair.getMemberName()));
    fBuffer.append('=');
    appendAnnotationValue(
        annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags);
  }
  fBuffer.append(')');
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:JavaElementLabelComposer.java


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