本文整理汇总了Java中org.eclipse.jdt.core.dom.Annotation.resolveTypeBinding方法的典型用法代码示例。如果您正苦于以下问题:Java Annotation.resolveTypeBinding方法的具体用法?Java Annotation.resolveTypeBinding怎么用?Java Annotation.resolveTypeBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Annotation
的用法示例。
在下文中一共展示了Annotation.resolveTypeBinding方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findExistingAnnotation
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
private static Annotation findExistingAnnotation(List<? extends ASTNode> modifiers) {
for (int i = 0, len = modifiers.size(); i < len; i++) {
Object curr = modifiers.get(i);
if (curr instanceof NormalAnnotation || curr instanceof SingleMemberAnnotation) {
Annotation annotation = (Annotation) curr;
ITypeBinding typeBinding = annotation.resolveTypeBinding();
if (typeBinding != null) {
if ("java.lang.SuppressWarnings"
.equals(typeBinding.getQualifiedName())) { // $NON-NLS-1$
return annotation;
}
} else {
String fullyQualifiedName = annotation.getTypeName().getFullyQualifiedName();
if ("SuppressWarnings".equals(fullyQualifiedName)
|| "java.lang.SuppressWarnings"
.equals(fullyQualifiedName)) { // $NON-NLS-1$ //$NON-NLS-2$
return annotation;
}
}
}
}
return null;
}
示例2: findExistingAnnotation
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
private static Annotation findExistingAnnotation(List<? extends ASTNode> modifiers) {
for (int i= 0, len= modifiers.size(); i < len; i++) {
Object curr= modifiers.get(i);
if (curr instanceof NormalAnnotation || curr instanceof SingleMemberAnnotation) {
Annotation annotation= (Annotation) curr;
ITypeBinding typeBinding= annotation.resolveTypeBinding();
if (typeBinding != null) {
if ("java.lang.SuppressWarnings".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$
return annotation;
}
} else {
String fullyQualifiedName= annotation.getTypeName().getFullyQualifiedName();
if ("SuppressWarnings".equals(fullyQualifiedName) || "java.lang.SuppressWarnings".equals(fullyQualifiedName)) { //$NON-NLS-1$ //$NON-NLS-2$
return annotation;
}
}
}
}
return null;
}
示例3: visitAnnotation
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
/**
* Processes the annotation to replace its name by FQN
*
* @param node
* @return
*/
private boolean visitAnnotation(Annotation node) {
if (node.getTypeName().isSimpleName()) {
ITypeBinding resolvedBinding = node.resolveTypeBinding();
if (resolvedBinding != null) {
String qualifiedName = null;
if (resolvedBinding.isParameterizedType()) {
ITypeBinding erasure = resolvedBinding.getErasure();
if (erasure != null && !erasure.isRecovered()) {
qualifiedName = erasure.getQualifiedName();
}
} else if (!resolvedBinding.isRecovered()) {
qualifiedName = resolvedBinding.getQualifiedName();
}
if (qualifiedName != null) {
node.setTypeName(node.getAST().newName(qualifiedName));
this.modified = true;
}
}
}
return true;
}
示例4: addValueForAnnotationProposals
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
public static void addValueForAnnotationProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ICompilationUnit cu= context.getCompilationUnit();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode instanceof Annotation) {
Annotation annotation= (Annotation) selectedNode;
if (annotation.resolveTypeBinding() == null) {
return;
}
MissingAnnotationAttributesProposal proposal= new MissingAnnotationAttributesProposal(cu, annotation, 10);
proposals.add(proposal);
}
}
示例5: findAnnotationMember
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
private static IMethodBinding findAnnotationMember(Annotation annotation, String name) {
ITypeBinding annotBinding= annotation.resolveTypeBinding();
if (annotBinding != null) {
return Bindings.findMethodInType(annotBinding, name, (String[]) null);
}
return null;
}
示例6: createMethodCopy
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的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();
}
}
示例7: processAnnotation
import org.eclipse.jdt.core.dom.Annotation; //导入方法依赖的package包/类
private AnnotationClassReference processAnnotation(ClassReference annotatedReference, Annotation node)
{
final ITypeBinding typeBinding = node.resolveTypeBinding();
final AnnotationClassReference reference;
final String qualifiedName;
final String packageName;
final String className;
final ResolutionStatus status;
if (typeBinding != null)
{
status = ResolutionStatus.RESOLVED;
qualifiedName = typeBinding.getQualifiedName();
packageName = typeBinding.getPackage().getName();
className = typeBinding.getName();
}
else
{
ResolveClassnameResult result = resolveClassname(node.getTypeName().toString());
status = result.found ? ResolutionStatus.RECOVERED : ResolutionStatus.UNRESOLVED;
qualifiedName = result.result;
PackageAndClassName packageAndClassName = PackageAndClassName.parseFromQualifiedName(result.result);
packageName = packageAndClassName.packageName;
className = packageAndClassName.className;
}
reference = new AnnotationClassReference(
annotatedReference,
qualifiedName,
packageName,
className,
status,
compilationUnit.getLineNumber(node.getStartPosition()),
compilationUnit.getColumnNumber(node.getStartPosition()),
node.getLength(),
node.toString());
addAnnotationValues(annotatedReference, reference, node);
return reference;
}