Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 34415 Details for
Bug 123470
AST: new type IResolvedAnnotation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for jdt.core projects
123470_v3.txt (text/plain), 63.34 KB, created by
Jerome Lanneluc
on 2006-02-09 10:10:30 EST
(
hide
)
Description:
Patch for jdt.core projects
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2006-02-09 10:10:30 EST
Size:
63.34 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v >retrieving revision 1.187 >diff -u -r1.187 ASTConverter15Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 6 Feb 2006 16:25:20 -0000 1.187 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 9 Feb 2006 14:26:17 -0000 >@@ -6276,7 +6276,7 @@ > ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression; > IMethodBinding binding = classInstanceCreation.resolveConstructorBinding(); > assertNotNull("Should not be null", binding); >- IResolvedAnnotation[] annotations = binding.getAnnotations(); >+ IAnnotationBinding[] annotations = binding.getAnnotations(); > assertNotNull("Should not be null", annotations); > assertEquals("Should be empty", 0, annotations.length); > } >@@ -6308,8 +6308,8 @@ > assertEquals("Wrong size", 2, modifiers.size()); > assertTrue("Wrong type", modifiers.get(0) instanceof NormalAnnotation); > NormalAnnotation normalAnnotation = (NormalAnnotation) modifiers.get(0); >- IResolvedAnnotation resolvedAnnotation = normalAnnotation.resolveAnnotation(); >- IResolvedMemberValuePair[] pairs = resolvedAnnotation.getDeclaredMemberValuePairs(); >+ IAnnotationBinding annotationBinding = normalAnnotation.resolveAnnotation(); >+ IMemberValuePairBinding[] pairs = annotationBinding.getDeclaredMemberValuePairs(); > assertEquals("Wrong size", 1, pairs.length); > assertNotNull("Should not be null", pairs[0].getValue()); > } >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/TypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java,v >retrieving revision 1.112 >diff -u -r1.112 TypeBinding.java >--- dom/org/eclipse/jdt/core/dom/TypeBinding.java 10 Jan 2006 21:01:06 -0000 1.112 >+++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 9 Feb 2006 14:26:23 -0000 >@@ -32,7 +32,6 @@ > import org.eclipse.jdt.internal.compiler.ast.Wildcard; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.env.IDependent; >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; > import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; > import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.Binding; >@@ -75,15 +74,15 @@ > this.resolver = resolver; > } > >- public IResolvedAnnotation[] getAnnotations() { >- IResolvedAnnotation[] domInstances = ResolvedAnnotation.NoAnnotations; >+ public IAnnotationBinding[] getAnnotations() { >+ IAnnotationBinding[] domInstances = AnnotationBinding.NoAnnotations; > if (this.binding.isAnnotationType() || this.binding.isClass() || this.binding.isEnum() || this.binding.isInterface()) { > org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding refType = > (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.binding; >- AnnotationBinding[] internalAnnotations = refType.getAnnotations(); >+ org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = refType.getAnnotations(); > int length = internalAnnotations == null ? 0 : internalAnnotations.length; > if (length > 0) { >- domInstances = new ResolvedAnnotation[length]; >+ domInstances = new AnnotationBinding[length]; > for (int i = 0; i < length; i++) > domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); > } >Index: dom/org/eclipse/jdt/core/dom/MethodBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java,v >retrieving revision 1.69 >diff -u -r1.69 MethodBinding.java >--- dom/org/eclipse/jdt/core/dom/MethodBinding.java 1 Feb 2006 19:46:18 -0000 1.69 >+++ dom/org/eclipse/jdt/core/dom/MethodBinding.java 9 Feb 2006 14:26:22 -0000 >@@ -20,7 +20,6 @@ > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.compiler.CharOperation; >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; > import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; > import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment; > import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier; >@@ -102,12 +101,12 @@ > return name; > } > >- public IResolvedAnnotation[] getAnnotations() { >- AnnotationBinding[] annotations = this.binding.getAnnotations(); >+ public IAnnotationBinding[] getAnnotations() { >+ org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] annotations = this.binding.getAnnotations(); > int length; > if (annotations == null || (length = annotations.length) == 0) >- return ResolvedAnnotation.NoAnnotations; >- IResolvedAnnotation[] domInstances = new ResolvedAnnotation[length]; >+ return AnnotationBinding.NoAnnotations; >+ IAnnotationBinding[] domInstances = new AnnotationBinding[length]; > for (int i = 0; i < length; i++) > domInstances[i] = this.resolver.getAnnotationInstance(annotations[i]); > return domInstances; >@@ -123,12 +122,12 @@ > return declaringClass; > } > >- public IResolvedAnnotation[] getParameterAnnotations(int index) { >- AnnotationBinding[] annotations = this.binding.getParameterAnnotations(index); >+ public IAnnotationBinding[] getParameterAnnotations(int index) { >+ org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] annotations = this.binding.getParameterAnnotations(index); > int length; > if (annotations == null || (length = annotations.length) == 0) >- return ResolvedAnnotation.NoAnnotations; >- IResolvedAnnotation[] domInstances =new ResolvedAnnotation[length]; >+ return AnnotationBinding.NoAnnotations; >+ IAnnotationBinding[] domInstances =new AnnotationBinding[length]; > for (int i = 0; i < length; i++) > domInstances[i] = this.resolver.getAnnotationInstance(annotations[i]); > return domInstances; >@@ -166,7 +165,7 @@ > > public Object getDefaultValue() { > if (isAnnotationMember()) >- return ResolvedMemberValuePair.buildDOMValue(this.binding.getDefaultValue(), this.resolver); >+ return MemberValuePairBinding.buildDOMValue(this.binding.getDefaultValue(), this.resolver); > return null; > } > >Index: dom/org/eclipse/jdt/core/dom/Annotation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Annotation.java,v >retrieving revision 1.12 >diff -u -r1.12 Annotation.java >--- dom/org/eclipse/jdt/core/dom/Annotation.java 10 Jan 2006 21:01:06 -0000 1.12 >+++ dom/org/eclipse/jdt/core/dom/Annotation.java 9 Feb 2006 14:26:18 -0000 >@@ -175,7 +175,7 @@ > * @return the resolved annotation, or <code>null</code> if the annotation cannot be resolved > * @since 3.2 > */ >- public IResolvedAnnotation resolveAnnotation() { >+ public IAnnotationBinding resolveAnnotation() { > return this.ast.getBindingResolver().resolveAnnotation(this); > } > } >Index: dom/org/eclipse/jdt/core/dom/ResolvedDefaultValuePair.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/ResolvedDefaultValuePair.java >diff -N dom/org/eclipse/jdt/core/dom/ResolvedDefaultValuePair.java >--- dom/org/eclipse/jdt/core/dom/ResolvedDefaultValuePair.java 10 Jan 2006 21:01:06 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,77 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 BEA Systems, Inc. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * tyeung@bea.com - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jdt.core.dom; >- >-import org.eclipse.jdt.core.dom.BindingResolver; >-import org.eclipse.jdt.core.dom.IMethodBinding; >-import org.eclipse.jdt.core.dom.IResolvedMemberValuePair; >- >-/** >- * Member value pair which compose of default values. >- */ >-class ResolvedDefaultValuePair implements IResolvedMemberValuePair { >- >- private org.eclipse.jdt.internal.compiler.lookup.MethodBinding method; >- private Object domValue; >- private BindingResolver bindingResolver; >- >-static void appendValue(Object value, StringBuffer buffer) { >- if (value instanceof Object[]) { >- Object[] values = (Object[]) value; >- buffer.append('{'); >- for (int i = 0, l = values.length; i < l; i++) { >- if (i != 0) >- buffer.append(", "); //$NON-NLS-1$ >- appendValue(values[i], buffer); >- } >- buffer.append('}'); >- } else if (value instanceof ITypeBinding) { >- buffer.append(((ITypeBinding) value).getName()); >- buffer.append(".class"); //$NON-NLS-1$ >- } else { >- buffer.append(value); >- } >-} >- >-ResolvedDefaultValuePair(org.eclipse.jdt.internal.compiler.lookup.MethodBinding binding, BindingResolver resolver) { >- this.method = binding; >- this.domValue = ResolvedMemberValuePair.buildDOMValue(binding.getDefaultValue(), resolver); >- this.bindingResolver = resolver; >-} >- >-public String getName() { >- return new String(this.method.selector); >-} >- >-public IMethodBinding getMethodBinding() { >- return this.bindingResolver.getMethodBinding(this.method); >-} >- >-public Object getValue() { >- return this.domValue; >-} >- >-public boolean isDefault() { >- return true; >-} >- >-public String toString() { >- StringBuffer buffer = new StringBuffer(); >- toString(buffer); >- return buffer.toString(); >-} >- >-public void toString(StringBuffer buffer) { >- buffer.append(getName()); >- buffer.append(" = "); //$NON-NLS-1$ >- appendValue(getValue(), buffer); >-} >-} >Index: dom/org/eclipse/jdt/core/dom/IResolvedMemberValuePair.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/IResolvedMemberValuePair.java >diff -N dom/org/eclipse/jdt/core/dom/IResolvedMemberValuePair.java >--- dom/org/eclipse/jdt/core/dom/IResolvedMemberValuePair.java 10 Jan 2006 21:01:06 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,56 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 BEA Systems, Inc. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * tyeung@bea.com - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jdt.core.dom; >- >-/** >- * Represents a resolved instance of an annotation's member value pair. >- * Resolved annotation are computed along with other bindings; these objects >- * correspond to {@link MemberValuePair} nodes. >- * >- * @since 3.2 >- */ >-public interface IResolvedMemberValuePair { >-/** >- * Returns the name of the annotation type member. >- * >- * @return the name of the member >- */ >-public String getName(); >- >-/** >- * Returns the method binding corresponding to the named annotation type member. >- * >- * @return the method binding for the annotation type member >- */ >-public IMethodBinding getMethodBinding(); >- >-/** >- * Returns the resolved value. Resolved values are represented as follows: >- * <ul> >- * <li>Primitive type - the equivalent boxed object</li> >- * <li>java.lang.Class - the <code>ITypeBinding</code> for the class object</li> >- * <li>java.lang.String - the string value itself</li> >- * <li>enum type - the <code>IVariableBinding</code> for the enum constant</li> >- * <li>annotation type - an <code>IResolvedAnnotation</code></li> >- * <li>array type - an <code>Object[]</code> whose elements are as per above >- * (the language only allows single dimensional arrays in annotations)</li> >- * </ul> >- * >- * @return the resolved value, or <code>null</code> if none exists >- */ >-public Object getValue(); >- >-/** >- * @return <code>true</code> iff this member value pair's value is the default value. >- * Returns <code>false</code> otherwise. >- */ >-public boolean isDefault(); >-} >Index: dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java,v >retrieving revision 1.140 >diff -u -r1.140 DefaultBindingResolver.java >--- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 10 Jan 2006 21:01:06 -0000 1.140 >+++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 9 Feb 2006 14:26:21 -0000 >@@ -43,7 +43,6 @@ > import org.eclipse.jdt.internal.compiler.ast.ThisReference; > import org.eclipse.jdt.internal.compiler.ast.TypeReference; > import org.eclipse.jdt.internal.compiler.impl.Constant; >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; > import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; > import org.eclipse.jdt.internal.compiler.lookup.Binding; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >@@ -178,7 +177,7 @@ > return (ASTNode) this.bindingsToAstNodes.get(binding); > } > >- synchronized ASTNode findDeclaringNode(IResolvedAnnotation instance) { >+ synchronized ASTNode findDeclaringNode(IAnnotationBinding instance) { > if (instance == null) > return null; > return (ASTNode) this.bindingsToAstNodes.get(instance); >@@ -355,13 +354,13 @@ > return null; > } > >- synchronized IResolvedAnnotation getAnnotationInstance(AnnotationBinding internalInstance) { >+ synchronized IAnnotationBinding getAnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding internalInstance) { > if (internalInstance == null) return null; >- IResolvedAnnotation domInstance = >- (IResolvedAnnotation) this.bindingTables.compilerBindingsToASTBindings.get(internalInstance); >+ IAnnotationBinding domInstance = >+ (IAnnotationBinding) this.bindingTables.compilerBindingsToASTBindings.get(internalInstance); > if (domInstance != null) > return domInstance; >- domInstance = new ResolvedAnnotation(internalInstance, this); >+ domInstance = new AnnotationBinding(internalInstance, this); > this.bindingTables.compilerBindingsToASTBindings.put(internalInstance, domInstance); > return domInstance; > } >@@ -1550,13 +1549,13 @@ > return null; > } > >- synchronized IResolvedAnnotation resolveAnnotation(final Annotation domASTNode) { >+ synchronized IAnnotationBinding resolveAnnotation(final Annotation domASTNode) { > Object oldNode = this.newAstToOldAst.get(domASTNode); > if (oldNode instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) { > org.eclipse.jdt.internal.compiler.ast.Annotation internalAstNode = > (org.eclipse.jdt.internal.compiler.ast.Annotation) oldNode; > >- IResolvedAnnotation domAnnotation = this.getAnnotationInstance(internalAstNode.getCompilerAnnotation()); >+ IAnnotationBinding domAnnotation = this.getAnnotationInstance(internalAstNode.getCompilerAnnotation()); > if (domAnnotation == null) > return null; > this.bindingsToAstNodes.put(domAnnotation, domASTNode); >Index: dom/org/eclipse/jdt/core/dom/ResolvedMemberValuePair.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/ResolvedMemberValuePair.java >diff -N dom/org/eclipse/jdt/core/dom/ResolvedMemberValuePair.java >--- dom/org/eclipse/jdt/core/dom/ResolvedMemberValuePair.java 25 Jan 2006 14:53:00 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,120 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 BEA Systems, Inc. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * tyeung@bea.com - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jdt.core.dom; >- >-import org.eclipse.jdt.internal.compiler.impl.Constant; >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; >-import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; >-import org.eclipse.jdt.internal.compiler.lookup.TypeIds; >- >-/** >- * Internal class. >- */ >-class ResolvedMemberValuePair implements IResolvedMemberValuePair { >- static final ResolvedMemberValuePair[] NoPair = new ResolvedMemberValuePair[0]; >- private static final Object NoValue = new Object(); >- private static final Object[] EmptyArray = new Object[0]; >- >- private ElementValuePair internalPair; >- private Object value = null; >- private BindingResolver bindingResolver; >- >-static Object buildDOMValue(final Object internalObject, BindingResolver resolver) { >- if (internalObject == null) >- return null; >- >- if (internalObject instanceof Constant) { >- Constant constant = (Constant) internalObject; >- switch (constant.typeID()) { >- case TypeIds.T_boolean: >- return Boolean.valueOf(constant.booleanValue()); >- case TypeIds.T_byte: >- return new Byte(constant.byteValue()); >- case TypeIds.T_char: >- return new Character(constant.charValue()); >- case TypeIds.T_double: >- return new Double(constant.doubleValue()); >- case TypeIds.T_float: >- return new Float(constant.floatValue()); >- case TypeIds.T_int: >- return new Integer(constant.intValue()); >- case TypeIds.T_long: >- return new Long(constant.longValue()); >- case TypeIds.T_short: >- return new Short(constant.shortValue()); >- case TypeIds.T_JavaLangString: >- return constant.stringValue(); >- } >- } else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) { >- return resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) internalObject); >- } else if (internalObject instanceof AnnotationBinding) { >- return resolver.getAnnotationInstance((AnnotationBinding) internalObject); >- } else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.FieldBinding) { >- return resolver.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.FieldBinding) internalObject); >- } else if (internalObject instanceof Object[]) { >- Object[] elements = (Object[]) internalObject; >- int length = elements.length; >- Object[] values = length == 0 ? EmptyArray : new Object[length]; >- for (int i = 0; i < length; i++) >- values[i] = buildDOMValue(elements[i], resolver); >- return values; >- } >- throw new IllegalStateException(internalObject.toString()); // should never get here >-} >- >-ResolvedMemberValuePair(ElementValuePair pair, BindingResolver resolver) { >- this.internalPair = pair; >- this.bindingResolver = resolver; >-} >- >-public IMethodBinding getMethodBinding() { >- return this.bindingResolver.getMethodBinding(this.internalPair.getMethodBinding()); >-} >- >-public String getName() { >- if (this.internalPair == null) >- return null; >- final char[] membername = this.internalPair.getName(); >- return membername == null ? null : new String(membername); >-} >- >-public Object getValue() { >- if (value == null) >- init(); >- return value == NoValue ? null : this.value; >-} >- >-private void init() { >- this.value = buildDOMValue(this.internalPair.getValue(), this.bindingResolver); >- if (this.value == null) >- this.value = NoValue; >-} >- >-char[] internalName() { >- return this.internalPair == null ? null : this.internalPair.getName(); >-} >- >-public boolean isDefault() { >- return false; >-} >- >-public String toString() { >- StringBuffer buffer = new StringBuffer(); >- toString(buffer); >- return buffer.toString(); >-} >- >-public void toString(StringBuffer buffer) { >- buffer.append(getName()); >- buffer.append(" = "); //$NON-NLS-1$ >- ResolvedDefaultValuePair.appendValue(getValue(), buffer); >-} >-} >Index: dom/org/eclipse/jdt/core/dom/CompilationUnit.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java,v >retrieving revision 1.79 >diff -u -r1.79 CompilationUnit.java >--- dom/org/eclipse/jdt/core/dom/CompilationUnit.java 10 Jan 2006 21:01:06 -0000 1.79 >+++ dom/org/eclipse/jdt/core/dom/CompilationUnit.java 9 Feb 2006 14:26:20 -0000 >@@ -330,14 +330,14 @@ > * This method always returns <code>null</code> when the resolved annotation > * comes from a different AST. > * >- * @param resolvedAnnotation the resolved annotation >+ * @param annotationBinding the resolved annotation > * @return the corresponding node where the given resolved annotation is declared, > * or <code>null</code> if the resolved annotation does not correspond to a node in this > * compilation unit or if bindings were not requested when this AST was built > * @since 3.2 > */ >- public ASTNode findDeclaringNode(IResolvedAnnotation resolvedAnnotation) { >- return this.ast.getBindingResolver().findDeclaringNode(resolvedAnnotation); >+ public ASTNode findDeclaringNode(IAnnotationBinding annotationBinding) { >+ return this.ast.getBindingResolver().findDeclaringNode(annotationBinding); > } > > /** >Index: dom/org/eclipse/jdt/core/dom/PackageBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java,v >retrieving revision 1.29 >diff -u -r1.29 PackageBinding.java >--- dom/org/eclipse/jdt/core/dom/PackageBinding.java 10 Jan 2006 21:01:06 -0000 1.29 >+++ dom/org/eclipse/jdt/core/dom/PackageBinding.java 9 Feb 2006 14:26:22 -0000 >@@ -25,7 +25,6 @@ > import org.eclipse.jdt.internal.compiler.env.INameEnvironment; > import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; > import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; > import org.eclipse.jdt.internal.core.NameLookup; > import org.eclipse.jdt.internal.core.SearchableEnvironment; >@@ -49,18 +48,18 @@ > this.resolver = resolver; > } > >- public IResolvedAnnotation[] getAnnotations() { >+ public IAnnotationBinding[] getAnnotations() { > try { > INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment; > if (!(nameEnvironment instanceof SearchableEnvironment)) >- return ResolvedAnnotation.NoAnnotations; >+ return AnnotationBinding.NoAnnotations; > NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup; > if (nameLookup == null) >- return ResolvedAnnotation.NoAnnotations; >+ return AnnotationBinding.NoAnnotations; > final String pkgName = getName(); > IPackageFragment[] pkgs = nameLookup.findPackageFragments(pkgName, false/*exact match*/); > if (pkgs == null) >- return ResolvedAnnotation.NoAnnotations; >+ return AnnotationBinding.NoAnnotations; > > for (int i = 0, len = pkgs.length; i < len; i++) { > int fragType = pkgs[i].getKind(); >@@ -80,14 +79,14 @@ > if (pkgDecl != null) { > List annos = pkgDecl.annotations(); > if (annos == null || annos.isEmpty()) >- return ResolvedAnnotation.NoAnnotations; >- IResolvedAnnotation[] result = new IResolvedAnnotation[annos.size()]; >+ return AnnotationBinding.NoAnnotations; >+ IAnnotationBinding[] result = new IAnnotationBinding[annos.size()]; > int index=0; > for (Iterator it = annos.iterator(); it.hasNext(); index++) { > result[index] = ((Annotation) it.next()).resolveAnnotation(); > // not resolving bindings > if (result[index] == null) >- return ResolvedAnnotation.NoAnnotations; >+ return AnnotationBinding.NoAnnotations; > } > return result; > } >@@ -99,25 +98,25 @@ > if (answer != null && answer.isBinaryType()) { > IBinaryType type = answer.getBinaryType(); > IBinaryAnnotation[] binaryAnnotations = type.getAnnotations(); >- AnnotationBinding[] binaryInstances = >+ org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] binaryInstances = > BinaryTypeBinding.createAnnotations(binaryAnnotations, this.binding.environment); >- AnnotationBinding[] allInstances = >- AnnotationBinding.addStandardAnnotations(binaryInstances, type.getTagBits(), this.binding.environment); >+ org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] allInstances = >+ org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.addStandardAnnotations(binaryInstances, type.getTagBits(), this.binding.environment); > int total = allInstances.length; >- IResolvedAnnotation[] domInstances = new ResolvedAnnotation[total]; >+ IAnnotationBinding[] domInstances = new AnnotationBinding[total]; > for (int a = 0; a < total; a++) { > domInstances[a] = this.resolver.getAnnotationInstance(allInstances[a]); > if (domInstances[a] == null) // not resolving binding >- return ResolvedAnnotation.NoAnnotations; >+ return AnnotationBinding.NoAnnotations; > } > return domInstances; > } > } > } > } catch(JavaModelException e) { >- return ResolvedAnnotation.NoAnnotations; >+ return AnnotationBinding.NoAnnotations; > } >- return ResolvedAnnotation.NoAnnotations; >+ return AnnotationBinding.NoAnnotations; > } > > /* >Index: dom/org/eclipse/jdt/core/dom/IMethodBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IMethodBinding.java,v >retrieving revision 1.29 >diff -u -r1.29 IMethodBinding.java >--- dom/org/eclipse/jdt/core/dom/IMethodBinding.java 1 Feb 2006 21:09:34 -0000 1.29 >+++ dom/org/eclipse/jdt/core/dom/IMethodBinding.java 9 Feb 2006 14:26:22 -0000 >@@ -93,13 +93,13 @@ > * is not the binding for an annotation type member. > * <p> > * Resolved values are represented as follows (same as for >- * {@link IResolvedMemberValuePair#getValue()}): >+ * {@link IMemberValuePairBinding#getValue()}): > * <ul> > * <li>Primitive type - the equivalent boxed object</li> > * <li>java.lang.Class - the <code>ITypeBinding</code> for the class object</li> > * <li>java.lang.String - the string value itself</li> > * <li>enum type - the <code>IVariableBinding</code> for the enum constant</li> >- * <li>annotation type - an <code>IResolvedAnnotation</code></li> >+ * <li>annotation type - an <code>IAnnotationBinding</code></li> > * <li>array type - an <code>Object[]</code> whose elements are as per above > * (the language only allows single dimensional arrays in annotations)</li> > * </ul> >@@ -122,7 +122,7 @@ > * not a valid index > * @since 3.2 > */ >- public IResolvedAnnotation[] getParameterAnnotations(int paramIndex); >+ public IAnnotationBinding[] getParameterAnnotations(int paramIndex); > > /** > * Returns a list of type bindings representing the formal parameter types, >Index: dom/org/eclipse/jdt/core/dom/BindingResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java,v >retrieving revision 1.40 >diff -u -r1.40 BindingResolver.java >--- dom/org/eclipse/jdt/core/dom/BindingResolver.java 10 Jan 2006 21:01:06 -0000 1.40 >+++ dom/org/eclipse/jdt/core/dom/BindingResolver.java 9 Feb 2006 14:26:19 -0000 >@@ -11,7 +11,6 @@ > > package org.eclipse.jdt.core.dom; > >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; > import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; > import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment; >@@ -105,7 +104,7 @@ > * @return the corresponding node where the bindings is declared, > * or <code>null</code> if none > */ >- ASTNode findDeclaringNode(IResolvedAnnotation instance) { >+ ASTNode findDeclaringNode(IAnnotationBinding instance) { > return null; > } > >@@ -190,7 +189,7 @@ > * @param instance the old annotation > * @return the new DOM annotation > */ >- IResolvedAnnotation getAnnotationInstance(AnnotationBinding instance) { >+ IAnnotationBinding getAnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding instance) { > return null; > } > >@@ -830,7 +829,7 @@ > * @return the DOM annotation representation for the given ast node, or > * <code>null</code> if none is available > */ >- IResolvedAnnotation resolveAnnotation(Annotation annotation) { >+ IAnnotationBinding resolveAnnotation(Annotation annotation) { > return null; > } > >Index: dom/org/eclipse/jdt/core/dom/ResolvedAnnotation.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/ResolvedAnnotation.java >diff -N dom/org/eclipse/jdt/core/dom/ResolvedAnnotation.java >--- dom/org/eclipse/jdt/core/dom/ResolvedAnnotation.java 16 Jan 2006 20:52:23 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,91 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 BEA Systems, Inc. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * tyeung@bea.com - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jdt.core.dom; >- >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; >-import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; >-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; >-import org.eclipse.jdt.internal.compiler.util.*; >- >-/** >- * Internal class >- */ >-class ResolvedAnnotation implements IResolvedAnnotation { >- static final ResolvedAnnotation[] NoAnnotations = new ResolvedAnnotation[0]; >- private AnnotationBinding internalAnnotation; >- private BindingResolver bindingResolver; >- >- ResolvedAnnotation(AnnotationBinding annotation, BindingResolver resolver) { >- if (annotation == null) >- throw new IllegalStateException(); >- internalAnnotation = annotation; >- bindingResolver = resolver; >- } >- >- public ITypeBinding getAnnotationType() { >- ITypeBinding binding = this.bindingResolver.getTypeBinding(this.internalAnnotation.getAnnotationType()); >- if (binding == null || !binding.isAnnotation()) >- return null; >- return binding; >- } >- >- public IResolvedMemberValuePair[] getDeclaredMemberValuePairs() { >- ElementValuePair[] internalPairs = this.internalAnnotation.getElementValuePairs(); >- int length = internalPairs.length; >- IResolvedMemberValuePair[] pairs = length == 0 ? ResolvedMemberValuePair.NoPair : new ResolvedMemberValuePair[length]; >- for (int i = 0; i < length; i++) >- pairs[i] = new ResolvedMemberValuePair(internalPairs[i], this.bindingResolver); >- return pairs; >- } >- >- public IResolvedMemberValuePair[] getAllMemberValuePairs() { >- IResolvedMemberValuePair[] pairs = getDeclaredMemberValuePairs(); >- ReferenceBinding typeBinding = this.internalAnnotation.getAnnotationType(); >- if (typeBinding == null) return pairs; >- MethodBinding[] methods = typeBinding.methods(); >- int methodLength = methods == null ? 0 : methods.length; >- if (methodLength == 0) return pairs; >- >- int declaredLength = pairs.length; >- if (declaredLength == methodLength) >- return pairs; >- >- HashtableOfObject table = new HashtableOfObject(declaredLength); >- for (int i = 0; i < declaredLength; i++) >- table.put(((ResolvedMemberValuePair) pairs[i]).internalName(), pairs[i]); >- >- // handle case of more methods than declared members >- IResolvedMemberValuePair[] allPairs = new IResolvedMemberValuePair[methodLength]; >- for (int i = 0; i < methodLength; i++) { >- Object pair = table.get(methods[i].selector); >- allPairs[i] = pair == null ? new ResolvedDefaultValuePair(methods[i], this.bindingResolver) : (IResolvedMemberValuePair) pair; >- } >- return allPairs; >- } >- >- public String toString() { >- ITypeBinding type = getAnnotationType(); >- final StringBuffer buffer = new StringBuffer(); >- buffer.append('@'); >- if (type != null) >- buffer.append(type.getName()); >- buffer.append('('); >- IResolvedMemberValuePair[] pairs = getDeclaredMemberValuePairs(); >- for (int i = 0, len = pairs.length; i < len; i++) { >- if (i != 0) >- buffer.append(", "); //$NON-NLS-1$ >- buffer.append(pairs[i].toString()); >- } >- buffer.append(')'); >- return buffer.toString(); >- } >-} >Index: dom/org/eclipse/jdt/core/dom/IBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IBinding.java,v >retrieving revision 1.26 >diff -u -r1.26 IBinding.java >--- dom/org/eclipse/jdt/core/dom/IBinding.java 8 Feb 2006 11:10:51 -0000 1.26 >+++ dom/org/eclipse/jdt/core/dom/IBinding.java 9 Feb 2006 14:26:22 -0000 >@@ -68,6 +68,26 @@ > public static final int METHOD = 4; > > /** >+ * Kind constant (value 5) indicating an annotation binding. >+ * Bindings of this kind can be safely cast to <code>IAnnotationBinding</code>. >+ * >+ * @see #getKind() >+ * @see IAnnotationBinding >+ * @since 3.2 >+ */ >+ public static final int ANNOTATION = 5; >+ >+ /** >+ * Kind constant (value 6) indicating a member value pair binding. >+ * Bindings of this kind can be safely cast to <code>IMemberValuePairBinding</code>. >+ * >+ * @see #getKind() >+ * @see IMemberValuePairBinding >+ * @since 3.2 >+ */ >+ public static final int MEMBER_VALUE_PAIR = 6; >+ >+ /** > * Return the resolved annotations associated with this binding. > * <ul> > * <li>Package bindings - these are annotations on a package declaration. >@@ -80,22 +100,31 @@ > * parameterized.</li> > * <li>Variable bindings - these are annotations on a field, enum constant, > * or formal parameter declaration.</li> >+ * <li>Annotation bindings - an empty array is always returned</li> >+ * <li>Member value pair bindings - an empty array is always returned<li> > * </ul> > * > * @return the list of resolved annotations, or the empty list if there are no > * annotations associated with the object > * @since 3.2 > */ >- public IResolvedAnnotation[] getAnnotations(); >+ public IAnnotationBinding[] getAnnotations(); > > /** >- * Returns the kind of bindings this is. >- * >- * @return one of the kind constants: >- * <code>PACKAGE</code>, >+ * Returns the kind of bindings this is. That is one of the kind constants: >+ * <code>PACKAGE</code>, > * <code>TYPE</code>, > * <code>VARIABLE</code>, >- * or <code>METHOD</code>. >+ * <code>METHOD</code>, >+ * <code>ANNOTATION</code>, >+ * or <code>MEMBER_VALUE_PAIR</code>. >+ * <p> >+ * Note that additional kinds might be added in the >+ * future, so clients should not assume this list is exhaustive and >+ * should program defensively, e.g. by having a reasonable default >+ * in a switch statement. >+ * </p> >+ * @return one of the kind constants > */ > public int getKind(); > >@@ -166,8 +195,9 @@ > * <li>the "length" field of an array type</li> > * <li>the default constructor of a source class</li> > * <li>the constructor of an anonymous class</li> >+ * <li>member value pairs</li> > * </ul> >- * For all other kind of type, method, variable, and package bindings, >+ * For all other kind of type, method, variable, annotation and package bindings, > * this method returns non-<code>null</code>. > * </p> > * >@@ -231,6 +261,9 @@ > * type</li> > * </ul> > * </p> >+ * <p>Note that the key for annotation bindings and member value pair bindings is >+ * not yet implemented. This returns <code>null</code> for these 2 kinds of bindings. >+ * </p> > * > * @return the key for this binding > */ >Index: dom/org/eclipse/jdt/core/dom/VariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java,v >retrieving revision 1.49 >diff -u -r1.49 VariableBinding.java >--- dom/org/eclipse/jdt/core/dom/VariableBinding.java 30 Jan 2006 19:01:13 -0000 1.49 >+++ dom/org/eclipse/jdt/core/dom/VariableBinding.java 9 Feb 2006 14:26:23 -0000 >@@ -16,7 +16,6 @@ > import org.eclipse.jdt.core.util.IModifierConstants; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.impl.Constant; >-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; > import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; > import org.eclipse.jdt.internal.compiler.lookup.TagBits; > import org.eclipse.jdt.internal.compiler.lookup.TypeIds; >@@ -43,12 +42,12 @@ > this.binding = binding; > } > >- public IResolvedAnnotation[] getAnnotations() { >- AnnotationBinding[] internalAnnotations = this.binding.getAnnotations(); >+ public IAnnotationBinding[] getAnnotations() { >+ org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = this.binding.getAnnotations(); > // the variable is not an enum constant nor a field nor an argument. > int length = internalAnnotations == null ? 0 : internalAnnotations.length; >- IResolvedAnnotation[] domInstances = >- length == 0 ? ResolvedAnnotation.NoAnnotations : new ResolvedAnnotation[length]; >+ IAnnotationBinding[] domInstances = >+ length == 0 ? AnnotationBinding.NoAnnotations : new AnnotationBinding[length]; > for (int i = 0; i < length; i++) > domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); > return domInstances; >Index: dom/org/eclipse/jdt/core/dom/IResolvedAnnotation.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/IResolvedAnnotation.java >diff -N dom/org/eclipse/jdt/core/dom/IResolvedAnnotation.java >--- dom/org/eclipse/jdt/core/dom/IResolvedAnnotation.java 10 Jan 2006 21:01:06 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,52 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 BEA Systems, Inc. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * tyeung@bea.com - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jdt.core.dom; >- >-/** >- * Represents an resolved annotation. Resolved annotation are computed along with other >- * bindings; they correspond to {@link Annotation} nodes. >- * >- * @since 3.2 >- */ >-public interface IResolvedAnnotation { >-/** >- * Returns the type of the annotation. The resulting type binding will always >- * return <code>true</code> to <code>ITypeBinding.isAnnotation()</code>. >- * >- * @return the type of the annotation >- */ >-ITypeBinding getAnnotationType(); >- >-/** >- * Returns the list of declared member value pairs for this annotation. >- * Returns an empty list for a <code>MarkerAnnotation</code>, a one element >- * list for a <code>SingleMemberAnnotation</code>, and one entry for each >- * of the explicitly listed values in a <code>NormalAnnotation</code>. >- * <p> >- * Note that the list only includes entries for annotation type members that are >- * explicitly mentioned in the annotation. The list does not include any >- * annotation type members with default values that are merely implied. >- * Use {@link #getAllMemberValuePairs()} to get those as well. >- * </p> >- * >- * @return a possibly empty list of resolved member value pairs >- */ >-IResolvedMemberValuePair[] getDeclaredMemberValuePairs(); >- >-/** >- * Returns the complete list of member value pairs for this annotation, including >- * ones explicitly listed in the annotation as well as entries for >- * annotation type members with default values that are implied. >- * >- * @return a possibly empty list of resolved member value pairs >- */ >-IResolvedMemberValuePair[] getAllMemberValuePairs(); >-} >Index: dom/org/eclipse/jdt/core/dom/IAnnotationBinding.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/IAnnotationBinding.java >diff -N dom/org/eclipse/jdt/core/dom/IAnnotationBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/IAnnotationBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,66 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ * IBM Corporation - changed interface to extend IBinding >+ * IBM Corporation - renamed from IResolvedAnnotation to IAnnotationBinding >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+/** >+ * Represents an resolved annotation. Resolved annotation are computed along with other >+ * bindings; they correspond to {@link Annotation} nodes. >+ * <p> >+ * This interface is not intended to be implemented by clients. >+ * </p> >+ * >+ * @since 3.2 >+ */ >+public interface IAnnotationBinding extends IBinding { >+ >+ /** >+ * Returns the complete list of member value pairs for this annotation, including >+ * ones explicitly listed in the annotation as well as entries for >+ * annotation type members with default values that are implied. >+ * >+ * @return a possibly empty list of resolved member value pairs >+ */ >+ IMemberValuePairBinding[] getAllMemberValuePairs(); >+ >+ /** >+ * Returns the type of the annotation. The resulting type binding will always >+ * return <code>true</code> to <code>ITypeBinding.isAnnotation()</code>. >+ * >+ * @return the type of the annotation >+ */ >+ ITypeBinding getAnnotationType(); >+ >+ /** >+ * Returns the list of declared member value pairs for this annotation. >+ * Returns an empty list for a <code>MarkerAnnotation</code>, a one element >+ * list for a <code>SingleMemberAnnotation</code>, and one entry for each >+ * of the explicitly listed values in a <code>NormalAnnotation</code>. >+ * <p> >+ * Note that the list only includes entries for annotation type members that are >+ * explicitly mentioned in the annotation. The list does not include any >+ * annotation type members with default values that are merely implied. >+ * Use {@link #getAllMemberValuePairs()} to get those as well. >+ * </p> >+ * >+ * @return a possibly empty list of resolved member value pairs >+ */ >+ IMemberValuePairBinding[] getDeclaredMemberValuePairs(); >+ >+ /** >+ * Returns the name of the annotation type. >+ * >+ * @return the name of the annotation type >+ */ >+ public String getName(); >+ >+} >Index: dom/org/eclipse/jdt/core/dom/IMemberValuePairBinding.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/IMemberValuePairBinding.java >diff -N dom/org/eclipse/jdt/core/dom/IMemberValuePairBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/IMemberValuePairBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ * IBM Corporation - changed interface to extend IBinding >+ * IBM Corporation - renamed from IResolvedMemberValuePair to IMemberValuePairBinding >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+/** >+ * Represents a resolved instance of an annotation's member value pair. >+ * Resolved annotation are computed along with other bindings; these objects >+ * correspond to {@link MemberValuePair} nodes. >+ * <p> >+ * This interface is not intended to be implemented by clients. >+ * </p> >+ * >+ * @since 3.2 >+ */ >+public interface IMemberValuePairBinding extends IBinding { >+/** >+ * Returns the name of the annotation type member. >+ * >+ * @return the name of the member >+ */ >+public String getName(); >+ >+/** >+ * Returns the method binding corresponding to the named annotation type member. >+ * >+ * @return the method binding for the annotation type member >+ */ >+public IMethodBinding getMethodBinding(); >+ >+/** >+ * Returns the resolved value. Resolved values are represented as follows: >+ * <ul> >+ * <li>Primitive type - the equivalent boxed object</li> >+ * <li>java.lang.Class - the <code>ITypeBinding</code> for the class object</li> >+ * <li>java.lang.String - the string value itself</li> >+ * <li>enum type - the <code>IVariableBinding</code> for the enum constant</li> >+ * <li>annotation type - an <code>IAnnotationBinding</code></li> >+ * <li>array type - an <code>Object[]</code> whose elements are as per above >+ * (the language only allows single dimensional arrays in annotations)</li> >+ * </ul> >+ * >+ * @return the resolved value, or <code>null</code> if none exists >+ */ >+public Object getValue(); >+ >+/** >+ * @return <code>true</code> iff this member value pair's value is the default value. >+ * Returns <code>false</code> otherwise. >+ */ >+public boolean isDefault(); >+} >Index: dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java >diff -N dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,123 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ * IBM Corporation - implemented methods from IBinding >+ * IBM Corporation - renamed from ResolvedDefaultValuePair to DefaultValuePairBinding >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.dom.BindingResolver; >+import org.eclipse.jdt.core.dom.IMethodBinding; >+import org.eclipse.jdt.core.dom.IMemberValuePairBinding; >+ >+/** >+ * Member value pair which compose of default values. >+ */ >+class DefaultValuePairBinding implements IMemberValuePairBinding { >+ >+ private org.eclipse.jdt.internal.compiler.lookup.MethodBinding method; >+ private Object domValue; >+ private BindingResolver bindingResolver; >+ >+ static void appendValue(Object value, StringBuffer buffer) { >+ if (value instanceof Object[]) { >+ Object[] values = (Object[]) value; >+ buffer.append('{'); >+ for (int i = 0, l = values.length; i < l; i++) { >+ if (i != 0) >+ buffer.append(", "); //$NON-NLS-1$ >+ appendValue(values[i], buffer); >+ } >+ buffer.append('}'); >+ } else if (value instanceof ITypeBinding) { >+ buffer.append(((ITypeBinding) value).getName()); >+ buffer.append(".class"); //$NON-NLS-1$ >+ } else { >+ buffer.append(value); >+ } >+ } >+ >+ DefaultValuePairBinding(org.eclipse.jdt.internal.compiler.lookup.MethodBinding binding, BindingResolver resolver) { >+ this.method = binding; >+ this.domValue = MemberValuePairBinding.buildDOMValue(binding.getDefaultValue(), resolver); >+ this.bindingResolver = resolver; >+ } >+ >+ public IAnnotationBinding[] getAnnotations() { >+ return AnnotationBinding.NoAnnotations; >+ } >+ >+ public IJavaElement getJavaElement() { >+ return null; >+ } >+ >+ public String getKey() { >+ // TODO when implementing, update spec in IBinding >+ return null; >+ } >+ >+ public int getKind() { >+ return IBinding.MEMBER_VALUE_PAIR; >+ } >+ >+ public IMethodBinding getMethodBinding() { >+ return this.bindingResolver.getMethodBinding(this.method); >+ } >+ >+ public int getModifiers() { >+ return -1; >+ } >+ >+ public String getName() { >+ return new String(this.method.selector); >+ } >+ >+ public Object getValue() { >+ return this.domValue; >+ } >+ >+ public boolean isDefault() { >+ return true; >+ } >+ >+ public boolean isDeprecated() { >+ return false; >+ } >+ >+ public boolean isEqualTo(IBinding binding) { >+ if (this == binding) >+ return true; >+ if (binding.getKind() != IBinding.MEMBER_VALUE_PAIR) >+ return false; >+ IMemberValuePairBinding other = (IMemberValuePairBinding) binding; >+ if (!getMethodBinding().isEqualTo(other.getMethodBinding())) >+ return false; >+ Object value = getValue(); >+ if (value == null) >+ return other.getValue() == null; >+ return value.equals(other.getValue()); >+ } >+ >+ public boolean isSynthetic() { >+ return false; >+ } >+ >+ public String toString() { >+ StringBuffer buffer = new StringBuffer(); >+ toString(buffer); >+ return buffer.toString(); >+ } >+ >+ public void toString(StringBuffer buffer) { >+ buffer.append(getName()); >+ buffer.append(" = "); //$NON-NLS-1$ >+ appendValue(getValue(), buffer); >+ } >+} >Index: dom/org/eclipse/jdt/core/dom/AnnotationBinding.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/AnnotationBinding.java >diff -N dom/org/eclipse/jdt/core/dom/AnnotationBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/AnnotationBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,153 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ * IBM Corporation - implemented methods from IBinding >+ * IBM Corporation - renamed from ResolvedAnnotation to AnnotationBinding >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; >+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; >+import org.eclipse.jdt.internal.compiler.util.*; >+ >+/** >+ * Internal class >+ */ >+class AnnotationBinding implements IAnnotationBinding { >+ static final AnnotationBinding[] NoAnnotations = new AnnotationBinding[0]; >+ private org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding internalAnnotation; >+ private BindingResolver bindingResolver; >+ >+ AnnotationBinding(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding annotation, BindingResolver resolver) { >+ if (annotation == null) >+ throw new IllegalStateException(); >+ internalAnnotation = annotation; >+ bindingResolver = resolver; >+ } >+ >+ public IAnnotationBinding[] getAnnotations() { >+ return NoAnnotations; >+ } >+ >+ public ITypeBinding getAnnotationType() { >+ ITypeBinding binding = this.bindingResolver.getTypeBinding(this.internalAnnotation.getAnnotationType()); >+ if (binding == null || !binding.isAnnotation()) >+ return null; >+ return binding; >+ } >+ >+ public IMemberValuePairBinding[] getDeclaredMemberValuePairs() { >+ ElementValuePair[] internalPairs = this.internalAnnotation.getElementValuePairs(); >+ int length = internalPairs.length; >+ IMemberValuePairBinding[] pairs = length == 0 ? MemberValuePairBinding.NoPair : new MemberValuePairBinding[length]; >+ for (int i = 0; i < length; i++) >+ pairs[i] = new MemberValuePairBinding(internalPairs[i], this.bindingResolver); >+ return pairs; >+ } >+ >+ public IMemberValuePairBinding[] getAllMemberValuePairs() { >+ IMemberValuePairBinding[] pairs = getDeclaredMemberValuePairs(); >+ ReferenceBinding typeBinding = this.internalAnnotation.getAnnotationType(); >+ if (typeBinding == null) return pairs; >+ MethodBinding[] methods = typeBinding.methods(); >+ int methodLength = methods == null ? 0 : methods.length; >+ if (methodLength == 0) return pairs; >+ >+ int declaredLength = pairs.length; >+ if (declaredLength == methodLength) >+ return pairs; >+ >+ HashtableOfObject table = new HashtableOfObject(declaredLength); >+ for (int i = 0; i < declaredLength; i++) >+ table.put(((MemberValuePairBinding) pairs[i]).internalName(), pairs[i]); >+ >+ // handle case of more methods than declared members >+ IMemberValuePairBinding[] allPairs = new IMemberValuePairBinding[methodLength]; >+ for (int i = 0; i < methodLength; i++) { >+ Object pair = table.get(methods[i].selector); >+ allPairs[i] = pair == null ? new DefaultValuePairBinding(methods[i], this.bindingResolver) : (IMemberValuePairBinding) pair; >+ } >+ return allPairs; >+ } >+ >+ public IJavaElement getJavaElement() { >+ ITypeBinding annotationType = getAnnotationType(); >+ if (annotationType == null) >+ return null; >+ return annotationType.getJavaElement(); >+ } >+ >+ public String getKey() { >+ // TODO when implementing, update spec in IBinding >+ return null; >+ } >+ >+ public int getKind() { >+ return IBinding.ANNOTATION; >+ } >+ >+ public int getModifiers() { >+ return -1; >+ } >+ >+ public String getName() { >+ ITypeBinding annotationType = getAnnotationType(); >+ if (annotationType == null) >+ return new String(this.internalAnnotation.getAnnotationType().sourceName()); >+ else >+ return annotationType.getName(); >+ } >+ >+ public boolean isDeprecated() { >+ return false; >+ } >+ >+ public boolean isEqualTo(IBinding binding) { >+ if (this == binding) >+ return true; >+ if (binding.getKind() != IBinding.ANNOTATION) >+ return false; >+ IAnnotationBinding other = (IAnnotationBinding) binding; >+ if (!getAnnotationType().isEqualTo(other.getAnnotationType())) >+ return false; >+ IMemberValuePairBinding[] memberValuePairs = getDeclaredMemberValuePairs(); >+ IMemberValuePairBinding[] otherMemberValuePairs = other.getDeclaredMemberValuePairs(); >+ if (memberValuePairs.length != otherMemberValuePairs.length) >+ return false; >+ for (int i = 0, length = memberValuePairs.length; i < length; i++) { >+ if (!memberValuePairs[i].isEqualTo(otherMemberValuePairs[i])) >+ return false; >+ } >+ return true; >+ } >+ >+ public boolean isSynthetic() { >+ return false; >+ } >+ >+ public String toString() { >+ ITypeBinding type = getAnnotationType(); >+ final StringBuffer buffer = new StringBuffer(); >+ buffer.append('@'); >+ if (type != null) >+ buffer.append(type.getName()); >+ buffer.append('('); >+ IMemberValuePairBinding[] pairs = getDeclaredMemberValuePairs(); >+ for (int i = 0, len = pairs.length; i < len; i++) { >+ if (i != 0) >+ buffer.append(", "); //$NON-NLS-1$ >+ buffer.append(pairs[i].toString()); >+ } >+ buffer.append(')'); >+ return buffer.toString(); >+ } >+ >+} >Index: dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java >diff -N dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,164 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ * IBM Corporation - implemented methods from IBinding >+ * IBM Corporation - renamed from ResolvedMemberValuePair to MemberValuePairBinding >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.internal.compiler.impl.Constant; >+import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; >+import org.eclipse.jdt.internal.compiler.lookup.TypeIds; >+ >+/** >+ * Internal class. >+ */ >+class MemberValuePairBinding implements IMemberValuePairBinding { >+ static final MemberValuePairBinding[] NoPair = new MemberValuePairBinding[0]; >+ private static final Object NoValue = new Object(); >+ private static final Object[] EmptyArray = new Object[0]; >+ >+ private ElementValuePair internalPair; >+ private Object value = null; >+ private BindingResolver bindingResolver; >+ >+ static Object buildDOMValue(final Object internalObject, BindingResolver resolver) { >+ if (internalObject == null) >+ return null; >+ >+ if (internalObject instanceof Constant) { >+ Constant constant = (Constant) internalObject; >+ switch (constant.typeID()) { >+ case TypeIds.T_boolean: >+ return Boolean.valueOf(constant.booleanValue()); >+ case TypeIds.T_byte: >+ return new Byte(constant.byteValue()); >+ case TypeIds.T_char: >+ return new Character(constant.charValue()); >+ case TypeIds.T_double: >+ return new Double(constant.doubleValue()); >+ case TypeIds.T_float: >+ return new Float(constant.floatValue()); >+ case TypeIds.T_int: >+ return new Integer(constant.intValue()); >+ case TypeIds.T_long: >+ return new Long(constant.longValue()); >+ case TypeIds.T_short: >+ return new Short(constant.shortValue()); >+ case TypeIds.T_JavaLangString: >+ return constant.stringValue(); >+ } >+ } else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) { >+ return resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) internalObject); >+ } else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding) { >+ return resolver.getAnnotationInstance((org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding) internalObject); >+ } else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.FieldBinding) { >+ return resolver.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.FieldBinding) internalObject); >+ } else if (internalObject instanceof Object[]) { >+ Object[] elements = (Object[]) internalObject; >+ int length = elements.length; >+ Object[] values = length == 0 ? EmptyArray : new Object[length]; >+ for (int i = 0; i < length; i++) >+ values[i] = buildDOMValue(elements[i], resolver); >+ return values; >+ } >+ throw new IllegalStateException(internalObject.toString()); // should never get here >+ } >+ >+ MemberValuePairBinding(ElementValuePair pair, BindingResolver resolver) { >+ this.internalPair = pair; >+ this.bindingResolver = resolver; >+ } >+ >+ public IAnnotationBinding[] getAnnotations() { >+ return AnnotationBinding.NoAnnotations; >+ } >+ >+ public IJavaElement getJavaElement() { >+ return null; >+ } >+ >+ public String getKey() { >+ // TODO when implementing, update spec in IBinding >+ return null; >+ } >+ >+ public int getKind() { >+ return IBinding.MEMBER_VALUE_PAIR; >+ } >+ >+ public IMethodBinding getMethodBinding() { >+ return this.bindingResolver.getMethodBinding(this.internalPair.getMethodBinding()); >+ } >+ >+ public int getModifiers() { >+ return -1; >+ } >+ >+ public String getName() { >+ if (this.internalPair == null) >+ return null; >+ final char[] membername = this.internalPair.getName(); >+ return membername == null ? null : new String(membername); >+ } >+ >+ public Object getValue() { >+ if (value == null) >+ init(); >+ return value == NoValue ? null : this.value; >+ } >+ >+ private void init() { >+ this.value = buildDOMValue(this.internalPair.getValue(), this.bindingResolver); >+ if (this.value == null) >+ this.value = NoValue; >+ } >+ >+ char[] internalName() { >+ return this.internalPair == null ? null : this.internalPair.getName(); >+ } >+ >+ public boolean isDefault() { >+ return false; >+ } >+ >+ public boolean isDeprecated() { >+ return false; >+ } >+ >+ public boolean isEqualTo(IBinding binding) { >+ if (this == binding) >+ return true; >+ if (binding.getKind() != IBinding.MEMBER_VALUE_PAIR) >+ return false; >+ IMemberValuePairBinding other = (IMemberValuePairBinding) binding; >+ if (!getMethodBinding().isEqualTo(other.getMethodBinding())) >+ return false; >+ if (this.value == null) >+ return other.getValue() == null; >+ return this.value.equals(other.getValue()); >+ } >+ >+ public boolean isSynthetic() { >+ return false; >+ } >+ >+ public String toString() { >+ StringBuffer buffer = new StringBuffer(); >+ toString(buffer); >+ return buffer.toString(); >+ } >+ >+ public void toString(StringBuffer buffer) { >+ buffer.append(getName()); >+ buffer.append(" = "); //$NON-NLS-1$ >+ DefaultValuePairBinding.appendValue(getValue(), buffer); >+ } >+} >#P org.eclipse.jdt.core.tests.builder >Index: src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java,v >retrieving revision 1.9 >diff -u -r1.9 ParticipantBuildTests.java >--- src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java 26 Jan 2006 20:08:11 -0000 1.9 >+++ src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java 9 Feb 2006 14:26:27 -0000 >@@ -368,7 +368,7 @@ > ITypeBinding typeBinding = typeDecl.resolveBinding(); > if (typeBinding == null) continue; > typeBinding = typeBinding.getAnnotations()[0].getAnnotationType(); >- IResolvedAnnotation targetValue = typeBinding.getAnnotations()[0]; >+ IAnnotationBinding targetValue = typeBinding.getAnnotations()[0]; > IMethodBinding method = targetValue.getDeclaredMemberValuePairs()[0].getMethodBinding(); > if (!"value".equals(method.getName())) > problems.add(new ParticipantProblem("method " + method.getName() + " not found", file.getName()));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 123470
:
34415
|
34416
|
34435
|
34436