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


Java IAnnotatable.getAnnotations方法代码示例

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


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

示例1: shouldWriteMarkers

import org.eclipse.jdt.core.IAnnotatable; //导入方法依赖的package包/类
private boolean shouldWriteMarkers(IJavaElement currentElement) {
	IJavaElement parent = currentElement;
	while (parent != null) {

		if (parent instanceof IAnnotatable) {
			IAnnotatable p = (IAnnotatable) parent;
			try {
				for (IAnnotation a : p.getAnnotations()) {
					if (a.getElementName().equalsIgnoreCase("EvoIgnore")) {
						return false;
					}
				}
			} catch (JavaModelException e) {
				e.printStackTrace();
			}
		}
		parent = parent.getParent();
	}
	return true;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:21,代码来源:MarkerWriter.java

示例2: extractMarkers

import org.eclipse.jdt.core.IAnnotatable; //导入方法依赖的package包/类
private List<String> extractMarkers(IAnnotatable annotatable, Set<String> skipAnnotations)
                throws JavaModelException
{
    List<String> markers = new ArrayList<String>();
    
    for (IAnnotation annotation : annotatable.getAnnotations())
    {
        String typeName = EclipseUtils.resolveTypeName(
                tapestryModule.getModuleClass(), annotation.getElementName());
        
        if (skipAnnotations.contains(typeName))
        {
            continue;
        }
        
        markers.add(typeName);
    }
    return markers;
}
 
开发者ID:anjlab,项目名称:eclipse-tapestry5-plugin,代码行数:20,代码来源:TapestryServiceDiscovery.java

示例3: getAnnotation

import org.eclipse.jdt.core.IAnnotatable; //导入方法依赖的package包/类
/**
 * Obtient une annotation d'un nom donné sur un objet donné.
 * 
 * @param annotable Objet à inspecter.
 * @param name Nom de l'annotation.
 * @return Annotation, <code>null</code> sinon.
 */
public static IAnnotation getAnnotation(IAnnotatable annotable, String name) {
	try {
		for (IAnnotation annotation : annotable.getAnnotations()) {
			String annotationName = StringUtils.getLastNameFragment(annotation.getElementName());
			if (name.equals(annotationName)) {
				return annotation;
			}
		}
	} catch (JavaModelException e) {
		ErrorUtils.handle(e);
	}
	return null;
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:21,代码来源:JdtUtils.java

示例4: convertAnnotations

import org.eclipse.jdt.core.IAnnotatable; //导入方法依赖的package包/类
private Annotation[] convertAnnotations(IAnnotatable element) throws JavaModelException {
  IAnnotation[] annotations = element.getAnnotations();
  int length = annotations.length;
  Annotation[] astAnnotations = new Annotation[length];
  if (length > 0) {
    char[] cuSource = getSource();
    int recordedAnnotations = 0;
    for (int i = 0; i < length; i++) {
      ISourceRange positions = annotations[i].getSourceRange();
      int start = positions.getOffset();
      int end = start + positions.getLength();
      char[] annotationSource = CharOperation.subarray(cuSource, start, end);
      if (annotationSource != null) {
        Expression expression = parseMemberValue(annotationSource);
        /*
         * expression can be null or not an annotation if the source has changed between
         * the moment where the annotation source positions have been retrieved and the moment were
         * this parsing occurred.
         * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=90916
         */
        if (expression instanceof Annotation) {
          astAnnotations[recordedAnnotations++] = (Annotation) expression;
        }
      }
    }
    if (length != recordedAnnotations) {
      // resize to remove null annotations
      System.arraycopy(
          astAnnotations,
          0,
          (astAnnotations = new Annotation[recordedAnnotations]),
          0,
          recordedAnnotations);
    }
  }
  return astAnnotations;
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:SourceTypeConverter.java

示例5: convertAnnotations

import org.eclipse.jdt.core.IAnnotatable; //导入方法依赖的package包/类
private Annotation[] convertAnnotations(IAnnotatable element) throws JavaModelException {
	IAnnotation[] annotations = element.getAnnotations();
	int length = annotations.length;
	Annotation[] astAnnotations = new Annotation[length];
	if (length > 0) {
		char[] cuSource = getSource();
		int recordedAnnotations = 0;
		for (int i = 0; i < length; i++) {
			ISourceRange positions = annotations[i].getSourceRange();
			int start = positions.getOffset();
			int end = start + positions.getLength();
			char[] annotationSource = CharOperation.subarray(cuSource, start, end);
			if (annotationSource != null) {
    			Expression expression = parseMemberValue(annotationSource);
    			/*
    			 * expression can be null or not an annotation if the source has changed between
    			 * the moment where the annotation source positions have been retrieved and the moment were
    			 * this parsing occurred.
    			 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=90916
    			 */
    			if (expression instanceof Annotation) {
    				astAnnotations[recordedAnnotations++] = (Annotation) expression;
    			}
			}
		}
		if (length != recordedAnnotations) {
			// resize to remove null annotations
			System.arraycopy(astAnnotations, 0, (astAnnotations = new Annotation[recordedAnnotations]), 0, recordedAnnotations);
		}
	}
	return astAnnotations;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:SourceTypeConverter.java

示例6: getAnnotationAt

import org.eclipse.jdt.core.IAnnotatable; //导入方法依赖的package包/类
public static IAnnotation getAnnotationAt(IAnnotatable annotatable, int offset)
	throws JavaModelException
{
	IAnnotation[] annotations = annotatable.getAnnotations();
	for (IAnnotation annotation : annotations)
	{
		ISourceRange sourceRange = annotation.getSourceRange();
		if (isInRange(sourceRange, offset))
		{
			return annotation;
		}
	}
	return null;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:15,代码来源:JavaMapperUtil.java

示例7: fetchActionAnnotationValue

import org.eclipse.jdt.core.IAnnotatable; //导入方法依赖的package包/类
private List<IAnnotation> fetchActionAnnotationValue(
		IAnnotatable annotatable, boolean actionsImportExist,
		boolean actionImportExist) throws JavaModelException {
	List<IAnnotation> result = new ArrayList<IAnnotation>();

	IAnnotation[] annotations = annotatable.getAnnotations();
	for (IAnnotation annotation : annotations) {
		if (annotation.exists()) {
			boolean fetchValue = ACTIONS_ANNOTATION_FQN.equals(annotation
					.getElementName())
					|| (ACTIONS_ANNOTATION.equals(annotation
							.getElementName()) && actionsImportExist);

			if (fetchValue) {
				IMemberValuePair[] valuePairs = annotation
						.getMemberValuePairs();
				for (IMemberValuePair valuePair : valuePairs) {
					if (valuePair.getValueKind() == IMemberValuePair.K_ANNOTATION
							&& ANNOTATION_VALUE.equals(valuePair
									.getMemberName())) {
						// single value
						if (valuePair.getValue() instanceof IAnnotation) {
							result.add((IAnnotation) valuePair.getValue());
						} else {
							// array
							Object[] objs = (Object[]) valuePair.getValue();
							for (Object o : objs) {
								result.add((IAnnotation) o);
							}
						}
					}
				}
			} else {
				fetchValue = ACTION_ANNOTATION_FQN.equals(annotation
						.getElementName())
						|| (ACTION_ANNOTATION.equals(annotation
								.getElementName()) && actionImportExist);
				if (fetchValue) {
					result.add(annotation);
				}
			}
		}
	}

	return result;
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:47,代码来源:AnnotationParser.java


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