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


Java IAnnotatable类代码示例

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


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

示例1: isHiddenGeneratedElement

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的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: isHiddenGeneratedElement

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的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

示例3: appendFlags

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的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

示例4: 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

示例5: appendFlags

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的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:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:StubCreator.java

示例6: readMarkerAnnotation

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的package包/类
public List<String> readMarkerAnnotation(IAnnotatable annotatable) throws JavaModelException
{
    List<String> markers = new ArrayList<String>();
    
    IAnnotation annotation = TapestryUtils.findAnnotation(annotatable.getAnnotations(),
            TapestryUtils.ORG_APACHE_TAPESTRY5_IOC_ANNOTATIONS_MARKER);
    
    if (annotation != null)
    {
        String[] typeLiterals = EclipseUtils.readValuesFromAnnotation(getEclipseProject(), annotation, "value");
        
        for (String typeLiteral : typeLiterals)
        {
            String typeName = EclipseUtils.resolveTypeName(moduleClass, typeLiteral);
            
            markers.add(typeName);
        }
    }
    
    return markers;
}
 
开发者ID:anjlab,项目名称:eclipse-tapestry5-plugin,代码行数:22,代码来源:TapestryModule.java

示例7: 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

示例8: 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

示例9: 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

示例10: getAnnotation

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的package包/类
/**
 * Gets the corresponding IAnnotation.
 *
 * @param qualifiedAnnotationName the fully qualified annotation type name
 * @param annotatable the IAnnotatable java element which contains the
 *          annotation
 * @param contextType the type which is used to lookup imports
 * @return the IAnnotation or null
 * @throws JavaModelException
 */
public static Object getAnnotation(String qualifiedAnnotationName,
    Object annotatable, IType contextType) throws JavaModelException {
  for (IAnnotation annotation : ((IAnnotatable) annotatable).getAnnotations()) {
    if (qualifiedAnnotationName.equals(resolveTypeName(contextType,
        annotation.getElementName()))) {
      return annotation;
    }
  }

  return null;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:22,代码来源:PlatformJavaModelUtilities.java

示例11: consumeAnnotation

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的package包/类
public void consumeAnnotation() {
	if (!(this.element instanceof IAnnotatable)) return;
	int size = this.types.size();
	if (size == 0) return;
	IJavaElement annotationType = ((JavaElementFinder) this.types.get(size-1)).element;
	this.element = ((IAnnotatable) this.element).getAnnotation(annotationType.getElementName());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:JavaElementFinder.java

示例12: 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

示例13: 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

示例14: getAnnotations

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的package包/类
private static String getAnnotations(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion) throws URISyntaxException, JavaModelException {
	if (!(element instanceof IAnnotatable))
		return null;
	
	if (((IAnnotatable)element).getAnnotations().length == 0)
		return null;
	
	IBinding binding;
	ASTNode node= getHoveredASTNode(editorInputElement, hoverRegion);
	
	if (node == null) {
		ASTParser p= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
		p.setProject(element.getJavaProject());
		try {
			binding= p.createBindings(new IJavaElement[] { element }, null)[0];
		} catch (OperationCanceledException e) {
			return null;
		}
		
	} else {
		binding= resolveBinding(node);
	}
	
	if (binding == null)
		return null;
	
	IAnnotationBinding[] annotations= binding.getAnnotations();
	if (annotations.length == 0)
		return null;
	
	StringBuffer buf= new StringBuffer();
	for (int i= 0; i < annotations.length; i++) {
		//TODO: skip annotations that don't have an @Documented annotation?
		addAnnotation(buf, element, annotations[i]);
		buf.append("<br>"); //$NON-NLS-1$
	}
	
	return buf.toString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:40,代码来源:JavadocHover.java

示例15: checkAnnotations

import org.eclipse.jdt.core.IAnnotatable; //导入依赖的package包/类
private RefactoringStatus checkAnnotations(IAnnotatable source, IType sourceType, IAnnotatable target,
		IType targetType) throws JavaModelException {
	// a set of annotations from the source method.
	Set<IAnnotation> sourceAnnotationSet = new HashSet<>(Arrays.asList(source.getAnnotations()));

	// remove any annotations to not consider.
	removeSpecialAnnotations(sourceAnnotationSet, sourceType);

	// a set of source method annotation names.
	Set<String> sourceMethodAnnotationElementNames = getAnnotationElementNames(sourceAnnotationSet);

	// a set of annotations from the target method.
	Set<IAnnotation> targetAnnotationSet = new HashSet<>(Arrays.asList(target.getAnnotations()));

	// remove any annotations to not consider.
	removeSpecialAnnotations(targetAnnotationSet, targetType);

	// a set of target method annotation names.
	Set<String> targetAnnotationElementNames = getAnnotationElementNames(targetAnnotationSet);

	// if the source method annotation names don't match the target method
	// annotation names.
	if (!sourceMethodAnnotationElementNames.equals(targetAnnotationElementNames))
		return RefactoringStatus.createErrorStatus(PreconditionFailure.AnnotationNameMismatch.getMessage(),
				new RefactoringStatusContext() {

					@Override
					public Object getCorrespondingElement() {
						return source;
					}
				});
	else
		// otherwise, we have the same annotations names. Check the values.
		for (IAnnotation sourceAnnotation : sourceAnnotationSet) {
			IMemberValuePair[] sourcePairs = sourceAnnotation.getMemberValuePairs();

			IAnnotation targetAnnotation = target.getAnnotation(sourceAnnotation.getElementName());
			IMemberValuePair[] targetPairs = targetAnnotation.getMemberValuePairs();

			if (sourcePairs.length != targetPairs.length) {
				// TODO: Can perhaps analyze this situation further by
				// looking up default field values.
				logWarning(
						"There may be differences in the length of the value vectors as some annotations may use default field values.");
				return new RefactoringStatus();
			}

			Arrays.parallelSort(sourcePairs, Comparator.comparing(IMemberValuePair::getMemberName));
			Arrays.parallelSort(targetPairs, Comparator.comparing(IMemberValuePair::getMemberName));

			for (int i = 0; i < sourcePairs.length; i++)
				if (!sourcePairs[i].getMemberName().equals(targetPairs[i].getMemberName())
						|| sourcePairs[i].getValueKind() != targetPairs[i].getValueKind()
						|| !(sourcePairs[i].getValue().equals(targetPairs[i].getValue())))
					return RefactoringStatus.createErrorStatus(
							formatMessage(PreconditionFailure.AnnotationValueMismatch.getMessage(),
									sourceAnnotation, targetAnnotation),
							JavaStatusContext.create(findEnclosingMember(sourceAnnotation)));
		}
	return new RefactoringStatus(); // OK.
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:62,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java


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