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


Java IAnnotation.getElementName方法代码示例

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


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

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

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

示例3: isTest

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
/**
 * Check if a method is test method.
 *
 * @param method method which should be checked
 * @param compilationUnit parent of the method
 * @param testAnnotation java annotation which describes test method in the test framework
 * @return {@code true} if the method is test method
 */
public boolean isTest(IMethod method, ICompilationUnit compilationUnit, String testAnnotation) {
  try {
    IAnnotation[] annotations = method.getAnnotations();
    IAnnotation test = null;
    for (IAnnotation annotation : annotations) {
      String annotationElementName = annotation.getElementName();
      if ("Test".equals(annotationElementName)) {
        test = annotation;
        break;
      }
      if (testAnnotation.equals(annotationElementName)) {
        return true;
      }
    }
    return test != null && isImportOfTestAnnotationExist(compilationUnit, testAnnotation);
  } catch (JavaModelException e) {
    LOG.info("Can't read method's annotations.", e);
    return false;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:JavaTestFinder.java

示例4: 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:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:StubCreator.java

示例5: matches

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
@Override
public boolean matches(IMethod method) throws JavaModelException
{
	for (IAnnotation annotation : method.getAnnotations())
	{
		String annotationName = annotation.getElementName();
		if (MybatipseConstants.ANNOTATION_RESULTS.equals(annotationName))
		{
			IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
			for (IMemberValuePair valuePair : valuePairs)
			{
				if ("id".equals(valuePair.getMemberName()))
				{
					String resultsId = (String)valuePair.getValue();
					return nameMatches(resultsId, matchString, exactMatch);
				}
			}
		}
	}
	return false;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:22,代码来源:JavaMapperUtil.java

示例6: getAnnotationTypes

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
private Set<IPath> getAnnotationTypes(
    final List<IAnnotation> annotations,
    final List<IImport> imports,
    final Path path) {
  final Set<IPath> annotationPaths = new HashSet<>();
  for (final IAnnotation annotation : annotations) {
    final String qualifiedName = annotation.getElementName();
    annotationPaths.add(createTypePath(imports, path, qualifiedName));
  }
  return annotationPaths;
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:12,代码来源:WorkspaceDependenciesInvestigator.java

示例7: isDefaultExtensionsAnnotation

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
private static boolean isDefaultExtensionsAnnotation(IAnnotation annotation) {
  String name = annotation.getElementName();

  // Annotation name can be either simple or qualified, depending on whether
  // the annotation is a binary or source type
  return name.equals(DEFAULT_EXTENSIONS_ANNOTATION_NAME)
      || name.equals(Signature.getSimpleName(DEFAULT_EXTENSIONS_ANNOTATION_NAME));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:9,代码来源:ResourceTypeDefaultExtensions.java

示例8: isSelect

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
protected boolean isSelect() throws JavaModelException
{
	IAnnotation[] annotations = method.getAnnotations();
	for (IAnnotation annotation : annotations)
	{
		String name = annotation.getElementName();
		if ("Select".equals(name) || "SelectProvider".equals(name))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:14,代码来源:MapperMethodRenameParticipant.java

示例9: isJUnitStateMethod

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
private static boolean isJUnitStateMethod(IMethod method, JunitVersion junitVersion) throws JavaModelException {
	if (junitVersion == JunitVersion.JUNIT4) {
		IAnnotation[] annotations = method.getAnnotations();
		for (IAnnotation annotation : annotations) {
			String name = annotation.getElementName();
			if (filteredMethodAnnotations .contains(name)) {
				return true;
			}
		}
		return false;
	} else {
		String methodName = method.getElementName();
		return isNoArgMethod(method) && filteredJunit3Methods.contains(methodName);
	}
}
 
开发者ID:sunix,项目名称:org.concordion.ide.eclipse,代码行数:16,代码来源:JdtUtils.java

示例10: visitAnnotation

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
protected void visitAnnotation(final IAnnotation annotation, final Annotation anno)
		throws JavaModelException {
	initializeNode(anno);

	String typeName = annotation.getElementName();
	// typeName is not a signature : java.lang.Deprecated
	String typeSignature = Signature.createTypeSignature(typeName, true);
	anno.setType(getRefOnType(typeSignature));

	for (IMemberValuePair valuePair : annotation.getMemberValuePairs()) {
		AnnotationMemberValuePair element = getFactory().createAnnotationMemberValuePair();
		initializeNode(element);
		anno.getValues().add(element);

		Expression value = manageMemberValuePair(valuePair);
		element.setValue(value);

		// member is a method declared in an annotation
		PendingElement pending = new PendingElement(getFactory());
		pending.setClientNode(element);
		pending.setLinkName("member"); //$NON-NLS-1$
		Binding id = null;
		if (this.typeFinder.isTypeExists(typeName)) {
			ClassBinding parent = JavaModelDelegateBindingFactory.getInstance()
					.getBindingForName(typeSignature, this, true);
			id = new MethodBinding();
			((MethodBinding) id).setDeclaringClass(parent);
			id.setName(valuePair.getMemberName());
		} else {
			id = new Binding();
			id.setName(typeName + "." + valuePair.getMemberName() + "()"); //$NON-NLS-1$ //$NON-NLS-2$
		}
		getGlobalBindings().addPending(pending, id);
	}
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:36,代码来源:ClassFileParser.java

示例11: computeCompletionProposals

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(
	ContentAssistInvocationContext context, IProgressMonitor monitor)
{
	if (context instanceof JavaContentAssistInvocationContext)
	{
		JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext)context;
		ICompilationUnit unit = javaContext.getCompilationUnit();
		try
		{
			if (unit == null || !unit.isStructureKnown())
				return Collections.emptyList();
			IType primaryType = unit.findPrimaryType();
			if (primaryType == null || !primaryType.isInterface())
				return Collections.emptyList();

			int offset = javaContext.getInvocationOffset();
			IJavaElement element = unit.getElementAt(offset);
			if (element == null || !(element instanceof IMethod))
				return Collections.emptyList();

			IAnnotation annotation = JavaMapperUtil.getAnnotationAt((IAnnotatable)element, offset);
			if (annotation == null)
				return Collections.emptyList();

			final IJavaProject project = javaContext.getProject();
			final IMethod method = (IMethod)element;
			final String mapperFqn = method.getDeclaringType().getFullyQualifiedName();
			if (isInlineStatementAnnotation(annotation))
			{
				return proposeStatementText(project, unit, offset, annotation, method);
			}
			else
			{
				String elementName = annotation.getElementName();
				if ("ResultMap".equals(elementName))
				{
					return proposeResultMap(project, mapperFqn, offset, annotation);
				}
				else if ("Results".equals(elementName))
				{
					return proposeResults(project, mapperFqn, offset, annotation, method);
				}
				else if ("ConstructorArgs".equals(elementName))
				{
					return proposeConstructorArgs(project, mapperFqn, offset, annotation, method);
				}
				else if ("Options".equals(elementName) || "SelectKey".equals(elementName))
				{
					return proposeKeyProperty(project, mapperFqn, offset, annotation, method);
				}
			}
		}
		catch (JavaModelException e)
		{
			Activator.log(Status.ERROR, "Something went wrong.", e);
		}
	}
	return Collections.emptyList();
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:60,代码来源:JavaCompletionProposalComputer.java

示例12: isInlineStatementAnnotation

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
private boolean isInlineStatementAnnotation(IAnnotation annotation)
{
	String annotationName = annotation.getElementName();
	return inlineStatementAnnotations.contains(annotationName);
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:6,代码来源:JavaCompletionProposalComputer.java

示例13: parseBinaryMapper

import org.eclipse.jdt.core.IAnnotation; //导入方法依赖的package包/类
private static void parseBinaryMapper(final IJavaProject project, final IType mapperType,
	final MapperInfo mapperInfo) throws JavaModelException
{
	for (IMethod method : mapperType.getMethods())
	{
		if (Flags.isDefaultMethod(method.getFlags()))
			continue;

		String statementAnno = null;
		for (IAnnotation annotation : method.getAnnotations())
		{
			String annoName = annotation.getElementName();
			if (MybatipseConstants.STATEMENT_ANNOTATIONS.contains(annoName))
			{
				statementAnno = annoName;
			}
			else if (MybatipseConstants.ANNOTATION_RESULTS.equals(annoName))
			{
				IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
				for (IMemberValuePair valuePair : valuePairs)
				{
					if ("id".equals(valuePair.getMemberName()))
					{
						String resultsId = (String)valuePair.getValue();
						if (resultsId != null)
							mapperInfo.addResultMap(resultsId, method);
					}
				}
			}
		}
		mapperInfo.addMethod(method, statementAnno);

		String[] superInterfaces = mapperType.getSuperInterfaceNames();
		for (String superInterface : superInterfaces)
		{
			if (!Object.class.getName().equals(superInterface))
			{
				IType superInterfaceType = project.findType(superInterface.replace('$', '.'));
				parseMapper(project, superInterfaceType, mapperInfo);
			}
		}
	}
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:44,代码来源:JavaMapperCache.java


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