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


Java IExtendedModifier.isAnnotation方法代码示例

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


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

示例1: getAnnotation

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
/**
 * Return an Annotation instance used on this body declaration
 */
public static Annotation getAnnotation(String annotationName,
		BodyDeclaration bodyDeclaration) {
	List<?> modifiers = bodyDeclaration.modifiers();

	// Test if this MethodDeclaration contains modifiers
	if (modifiers != null) {
		Iterator<?> modifiersIterator = modifiers.iterator();

		while (modifiersIterator.hasNext()) {
			IExtendedModifier modifier = (IExtendedModifier) modifiersIterator
					.next();

			if (modifier.isAnnotation()) {
				Annotation a = (Annotation) modifier;
				String annotationType = a.getTypeName().toString();

				if (annotationType.endsWith(annotationName)) {
					return a;
				}
			}
		}
	}

	return null;
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:29,代码来源:ASTHelper.java

示例2: findAnnotation

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
private static Annotation findAnnotation(final List<IExtendedModifier> modifiers, final String className) {
	for (final IExtendedModifier modifier : modifiers) {
		if (modifier.isAnnotation()) {
			final Annotation anno = (Annotation) modifier;
			final String fqn = anno.resolveTypeBinding().getQualifiedName();
			if (className.equals(fqn)) {
				return anno;
			}
		}
	}
	return null;
}
 
开发者ID:fabotronix,项目名称:jsr305CleanUp,代码行数:13,代码来源:Jsr305CleanUp.java

示例3: copyAllAnnotations

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
public void copyAllAnnotations(ASTNode otherDecl, TextEditGroup editGroup) {
  ListRewrite modifierList = evaluateListRewrite(fModifierRewrite.getASTRewrite(), otherDecl);
  List<IExtendedModifier> originalList = modifierList.getOriginalList();

  for (Iterator<IExtendedModifier> iterator = originalList.iterator(); iterator.hasNext(); ) {
    IExtendedModifier modifier = iterator.next();
    if (modifier.isAnnotation()) {
      fModifierRewrite.insertLast(
          fModifierRewrite.getASTRewrite().createCopyTarget((Annotation) modifier), editGroup);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:ModifierRewrite.java

示例4: obtainAnnotation

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
/**
 * @return the annotation node if it is present on the declaration or null
 */
public static Annotation obtainAnnotation(BodyDeclaration declaration, Class<?> annotationClass) {
	for (Object mod : declaration.modifiers()) {
		IExtendedModifier modifier = (IExtendedModifier) mod;
		if (modifier.isAnnotation()) {
			Annotation annotation = (Annotation) modifier;
			if (identicalAnnotations(annotation, annotationClass)) {
				return annotation;
			}
		}
	}
	return null;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:16,代码来源:SharedUtils.java

示例5: hasOverrideAnnotation

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
public static boolean hasOverrideAnnotation(final MethodDeclaration node) {
	final List modifiers = node.modifiers();
	for (final Object mod : modifiers) {
		final IExtendedModifier modifier = (IExtendedModifier) mod;
		if (modifier.isAnnotation()) {
			final Annotation annotation = (Annotation) modifier;
			if (annotation.getTypeName().toString().equals("Override")) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:mast-group,项目名称:tassal,代码行数:14,代码来源:MethodUtils.java

示例6: fieldCreated

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
@Override
		public void fieldCreated(CompilationUnitRewrite cuRewrite, FieldDeclaration field, ParameterInfo pi) {
			FieldInfo fieldInfo= getFieldInfo(pi.getOldName());
			FieldDeclaration parent= (FieldDeclaration) fieldInfo.declaration.getParent();
			List<IExtendedModifier> modifiers= parent.modifiers();
			ListRewrite listRewrite= cuRewrite.getASTRewrite().getListRewrite(field, FieldDeclaration.MODIFIERS2_PROPERTY);
			for (Iterator<IExtendedModifier> iterator= modifiers.iterator(); iterator.hasNext();) {
				IExtendedModifier mod= iterator.next();
				//Temporarily disabled until initialization of final fields is handled correctly
//				if (mod.isModifier()) {
//					Modifier modifier= (Modifier) mod;
//					if (modifier.isFinal())
//						listRewrite.insertLast(moveNode(cuRewrite, modifier), null);
//				}
				if (mod.isAnnotation()) {
					listRewrite.insertFirst(moveNode(cuRewrite, (ASTNode) mod), null);
				}
			}
			if (fieldInfo.initializer != null && fieldInfo.hasFieldReference()) {
				List<VariableDeclarationFragment> fragments= field.fragments();
				for (Iterator<VariableDeclarationFragment> iterator= fragments.iterator(); iterator.hasNext();) {
					VariableDeclarationFragment vdf= iterator.next();
					vdf.setInitializer((Expression) moveNode(cuRewrite, fieldInfo.initializer));
				}
			}
			if (parent.getJavadoc() != null) {
				field.setJavadoc((Javadoc) moveNode(cuRewrite, parent.getJavadoc()));
			}
		}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:ExtractClassRefactoring.java

示例7: copyAllAnnotations

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
public void copyAllAnnotations(ASTNode otherDecl, TextEditGroup editGroup) {
	ListRewrite modifierList= evaluateListRewrite(fModifierRewrite.getASTRewrite(), otherDecl);
	List<IExtendedModifier> originalList= modifierList.getOriginalList();

	for (Iterator<IExtendedModifier> iterator= originalList.iterator(); iterator.hasNext();) {
		IExtendedModifier modifier= iterator.next();
		if (modifier.isAnnotation()) {
			fModifierRewrite.insertLast(fModifierRewrite.getASTRewrite().createCopyTarget((Annotation) modifier), editGroup);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ModifierRewrite.java

示例8: hasParamAnnotation

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
private boolean hasParamAnnotation(List<IExtendedModifier> modifiers)
{
	for (IExtendedModifier modifier : modifiers)
	{
		if (modifier.isAnnotation()
			&& "Param".equals(((Annotation)modifier).getTypeName().getFullyQualifiedName()))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:13,代码来源:AddParamQuickAssist.java

示例9: endVisitBD

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
/**
 * Fill informations in the MoDisco {@code BodyDeclaration} node from the
 * JDT {@code BodyDeclaration} node.
 * 
 * @param node
 *            the JDT {@code BodyDeclaration} node
 * @param element
 *            the MoDisco {@code BodyDeclaration} node
 */
private void endVisitBD(final org.eclipse.jdt.core.dom.BodyDeclaration node,
		final BodyDeclaration element) {

	// visibility modifiers
	Modifier modiscoModifier = this.factory.createModifier();
	element.setModifier(modiscoModifier);
	modiscoModifier.setBodyDeclaration(element);

	for (Object modifierNode : node.modifiers()) {
		if (((IExtendedModifier) modifierNode).isModifier()) {
			manageModifier((org.eclipse.jdt.core.dom.Modifier) modifierNode, modiscoModifier);
		}
	}

	// annotation modifiers
	for (Iterator<?> anIt = node.modifiers().iterator(); anIt.hasNext();) {
		IExtendedModifier aModifier = (IExtendedModifier) anIt.next();
		if (aModifier.isAnnotation()) {
			Annotation annotation = (Annotation) this.binding.get(aModifier);
			if (annotation != null) {
				element.getAnnotations().add(annotation);
			}
		}
	}
	// Start position adjustment : for jdt visitor
	// a body starts at its javadoc, it is not consistent with others prefix
	// comments
	if (node.getJavadoc() != null) {
		Javadoc javadoc = (Javadoc) this.binding.get(node.getJavadoc());
		element.getComments().add(javadoc);
	}
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:42,代码来源:JDTVisitor.java

示例10: getAnnotation

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
/**
 * Return an Annotation object of a BodyDeclaration object
 */
public static Annotation getAnnotation(BodyDeclaration bd, String annotationFullyQualifiedName) {
	List<?> modifiers = bd.modifiers();
	Annotation result = null;

	// Test if this BodyDeclaration contains modifiers
	if (modifiers != null) {
		Iterator<?> modifiersIterator = bd.modifiers().iterator();

		// For each modifier, search for @annotationType marker
		// annotation
		while ((result == null) && modifiersIterator.hasNext()) {
			IExtendedModifier modifier = (IExtendedModifier) modifiersIterator.next();

			if (modifier.isAnnotation()) {
				Annotation a = (Annotation) modifier;

				// Test if the name of the annotation is a simple name or a
				// fully qualified name
				String annotationName = (a.getTypeName().isSimpleName()) ? annotationFullyQualifiedName
						.substring(annotationFullyQualifiedName.lastIndexOf('.') + 1)
						: annotationFullyQualifiedName;

				if (a.getTypeName().getFullyQualifiedName().equals(annotationName)) {
					result = a;
				}
			}
		}
	}

	return result;
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:35,代码来源:JavaCodeHelper.java

示例11: createMethodCopy

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
/**
 * Creates the necessary changes to create the delegate method with the
 * original method body.
 *
 * @param document
 *            the buffer containing the source of the source compilation
 *            unit
 * @param declaration
 *            the method declaration to use as source
 * @param rewrite
 *            the ast rewrite to use for the copy of the method body
 * @param rewrites
 *            the compilation unit rewrites
 * @param adjustments
 *            the map of elements to visibility adjustments
 * @param status
 *            the refactoring status
 * @param monitor
 *            the progress monitor to display progress
 * @throws CoreException
 *             if an error occurs
 */
protected void createMethodCopy(IDocument document, MethodDeclaration declaration, ASTRewrite rewrite, Map<ICompilationUnit, CompilationUnitRewrite> rewrites, Map<IMember, IncomingMemberVisibilityAdjustment> adjustments, RefactoringStatus status, IProgressMonitor monitor) throws CoreException {
	Assert.isNotNull(document);
	Assert.isNotNull(declaration);
	Assert.isNotNull(rewrite);
	Assert.isNotNull(rewrites);
	Assert.isNotNull(adjustments);
	Assert.isNotNull(status);
	Assert.isNotNull(monitor);
	final CompilationUnitRewrite rewriter= getCompilationUnitRewrite(rewrites, getTargetType().getCompilationUnit());
	try {
		rewrite.set(declaration, MethodDeclaration.NAME_PROPERTY, rewrite.getAST().newSimpleName(fMethodName), null);
		boolean same= false;
		final IMethodBinding binding= declaration.resolveBinding();
		if (binding != null) {
			final ITypeBinding declaring= binding.getDeclaringClass();
			if (declaring != null && Bindings.equals(declaring.getPackage(), fTarget.getType().getPackage()))
				same= true;
			final Modifier.ModifierKeyword keyword= same ? null : Modifier.ModifierKeyword.PUBLIC_KEYWORD;
			ModifierRewrite modifierRewrite= ModifierRewrite.create(rewrite, declaration);
			if (JdtFlags.isDefaultMethod(binding) && getTargetType().isClass()) {
				// Remove 'default' modifier and add 'public' visibility
				modifierRewrite.setVisibility(Modifier.PUBLIC, null);
				modifierRewrite.setModifiers(Modifier.NONE, Modifier.DEFAULT, null);
			} else if (!JdtFlags.isDefaultMethod(binding) && getTargetType().isInterface()) {
				// Remove visibility modifiers and add 'default'
				modifierRewrite.setModifiers(Modifier.DEFAULT, Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE, null);
			} else if (MemberVisibilityAdjustor.hasLowerVisibility(binding.getModifiers(), same ? Modifier.NONE : keyword == null ? Modifier.NONE : keyword.toFlagValue())
					&& MemberVisibilityAdjustor.needsVisibilityAdjustments(fMethod, keyword, adjustments)) {
				final MemberVisibilityAdjustor.IncomingMemberVisibilityAdjustment adjustment= new MemberVisibilityAdjustor.IncomingMemberVisibilityAdjustment(fMethod, keyword, RefactoringStatus.createStatus(RefactoringStatus.WARNING, Messages.format(RefactoringCoreMessages.MemberVisibilityAdjustor_change_visibility_method_warning, new String[] { MemberVisibilityAdjustor.getLabel(fMethod), MemberVisibilityAdjustor.getLabel(keyword) }), JavaStatusContext.create(fMethod), null, RefactoringStatusEntry.NO_CODE, null));
				modifierRewrite.setVisibility(keyword == null ? Modifier.NONE : keyword.toFlagValue(), null);
				adjustment.setNeedsRewriting(false);
				adjustments.put(fMethod, adjustment);
			}
		}
		for (IExtendedModifier modifier : (List<IExtendedModifier>) declaration.modifiers()) {
			if (modifier.isAnnotation()) {
				Annotation annotation= (Annotation) modifier;
				ITypeBinding typeBinding= annotation.resolveTypeBinding();
				if (typeBinding != null && typeBinding.getQualifiedName().equals("java.lang.Override")) { //$NON-NLS-1$
					rewrite.remove(annotation, null);
				}
			}
		}
		createMethodArguments(rewrites, rewrite, declaration, adjustments, status);
		createMethodTypeParameters(rewrite, declaration, status);
		createMethodComment(rewrite, declaration);
		createMethodBody(rewriter, rewrite, declaration);
	} finally {
		if (fMethod.getCompilationUnit().equals(getTargetType().getCompilationUnit()))
			rewriter.clearImportRewrites();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:75,代码来源:MoveInstanceMethodProcessor.java

示例12: isAModelizableModifier

import org.eclipse.jdt.core.dom.IExtendedModifier; //导入方法依赖的package包/类
/**
 * Return true if {@code modifier} is a modelizable modifier. A modelizable
 * modifier is one of abstract, static, private, protected, public, final or
 * transient. Other modifiers are not modelizable (it's technical modifiers
 * like synchronized,...).
 * 
 * @param modifier
 *            The modifier to test
 * @return true if {@code modifier} is a modelizable modifier, false
 *         otherwise.
 */
protected boolean isAModelizableModifier(BodyDeclaration existingFragment, IExtendedModifier modifier) {
	/* An annotation modifier is not processed by this method. */
	if (modifier.isAnnotation()) {
		return false;
	}

	Modifier m = (Modifier) modifier;
	return (m.isStatic() || m.isAbstract() || m.isPrivate() || m.isProtected() || m.isPublic() || m.isTransient() || m
			.isFinal());
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:22,代码来源:BodyDeclarationMerger.java


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