本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}