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 64747 Details for
Bug 180905
Tweaks to recovered bindings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
patch_180905.txt (text/plain), 18.66 KB, created by
Olivier Thomann
on 2007-04-24 10:54:51 EDT
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-04-24 10:54:51 EDT
Size:
18.66 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.47 >diff -u -r1.47 BindingResolver.java >--- dom/org/eclipse/jdt/core/dom/BindingResolver.java 16 Mar 2007 18:28:58 -0000 1.47 >+++ dom/org/eclipse/jdt/core/dom/BindingResolver.java 24 Apr 2007 14:55:40 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.jdt.core.dom; > >+import org.eclipse.jdt.core.WorkingCopyOwner; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; > import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; > import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; >@@ -219,9 +220,10 @@ > * </p> > * > * @param recoveredTypeBinding the recovered type binding >+ * @param dimensions the dimensions to add the to given type binding dimensions > * @return the new type binding > */ >- ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding) { >+ ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding, int dimensions) { > return null; > } > >@@ -240,6 +242,18 @@ > } > > /** >+ * Return the working copy owner for the receiver. >+ * <p> >+ * The default implementation of this method returns <code>null</code>. >+ * Subclasses may reimplement. >+ * </p> >+ * @return the working copy owner for the receiver >+ */ >+ public WorkingCopyOwner getWorkingCopyOwner() { >+ return null; >+ } >+ >+ /** > * Return the new annotation corresponding to the given old annotation > * <p> > * The default implementation of this method returns <code>null</code> >Index: dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java,v >retrieving revision 1.3 >diff -u -r1.3 RecoveredTypeBinding.java >--- dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 26 Mar 2007 17:30:23 -0000 1.3 >+++ dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 24 Apr 2007 14:55:42 -0000 >@@ -14,8 +14,11 @@ > import java.util.List; > > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; >+import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; > import org.eclipse.jdt.internal.compiler.util.Util; >+import org.eclipse.jdt.internal.core.CompilationUnit; > > /** > * This class represents the recovered binding for a type >@@ -55,17 +58,17 @@ > } > } > >- RecoveredTypeBinding(BindingResolver resolver, RecoveredTypeBinding typeBinding) { >+ RecoveredTypeBinding(BindingResolver resolver, RecoveredTypeBinding typeBinding, int dimensions) { > this.innerTypeBinding = typeBinding; >- this.dimensions = typeBinding.getDimensions() - 1; >+ this.dimensions = typeBinding.getDimensions() + dimensions; > this.resolver = resolver; > } > > /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ITypeBinding#createArrayType(int) > */ >- public ITypeBinding createArrayType(int dimension) { >- throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$ >+ public ITypeBinding createArrayType(int dims) { >+ return this.resolver.getTypeBinding(this, dims); > } > > /* (non-Javadoc) >@@ -87,7 +90,7 @@ > */ > public ITypeBinding getComponentType() { > if (this.dimensions == 0) return null; >- return this.resolver.getTypeBinding(this); >+ return this.resolver.getTypeBinding(this, -1); > } > > /* (non-Javadoc) >@@ -143,9 +146,13 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getElementType() > */ > public ITypeBinding getElementType() { >- if (this.referenceBinding != null && this.referenceBinding.isArrayType()) { >- ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; >- return new RecoveredTypeBinding(this.resolver, arrayBinding.leafComponentType); >+ if (this.referenceBinding != null) { >+ if (this.referenceBinding.isArrayType()) { >+ ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; >+ return new RecoveredTypeBinding(this.resolver, arrayBinding.leafComponentType); >+ } else { >+ return new RecoveredTypeBinding(this.resolver, this.referenceBinding); >+ } > } > if (this.innerTypeBinding != null) { > return this.innerTypeBinding.getElementType(); >@@ -216,6 +223,10 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() > */ > public IPackageBinding getPackage() { >+ CompilationUnitScope scope = this.resolver.scope(); >+ if (scope != null) { >+ return this.resolver.getPackageBinding(scope.getCurrentPackage()); >+ } > return null; > } > >@@ -230,7 +241,7 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() > */ > public ITypeBinding getSuperclass() { >- return null; >+ return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ > } > > /* (non-Javadoc) >@@ -240,7 +251,9 @@ > if (this.referenceBinding != null) { > return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; > } >- if (this.typeArguments != null) return typeArguments; >+ if (this.typeArguments != null) { >+ return typeArguments; >+ } > > if (this.innerTypeBinding != null) { > return this.innerTypeBinding.getTypeArguments(); >@@ -315,8 +328,11 @@ > /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ITypeBinding#isAssignmentCompatible(org.eclipse.jdt.core.dom.ITypeBinding) > */ >- public boolean isAssignmentCompatible(ITypeBinding variableType) { >- return false; >+ public boolean isAssignmentCompatible(ITypeBinding typeBinding) { >+ if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ >+ return true; >+ } >+ return this.isEqualTo(typeBinding); > } > > /* (non-Javadoc) >@@ -330,7 +346,10 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#isCastCompatible(org.eclipse.jdt.core.dom.ITypeBinding) > */ > public boolean isCastCompatible(ITypeBinding typeBinding) { >- return false; >+ if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ >+ return true; >+ } >+ return this.isEqualTo(typeBinding); > } > > /* (non-Javadoc) >@@ -427,7 +446,10 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#isSubTypeCompatible(org.eclipse.jdt.core.dom.ITypeBinding) > */ > public boolean isSubTypeCompatible(ITypeBinding typeBinding) { >- return false; >+ if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ >+ return true; >+ } >+ return this.isEqualTo(typeBinding); > } > > /* (non-Javadoc) >@@ -469,6 +491,11 @@ > * @see org.eclipse.jdt.core.dom.IBinding#getJavaElement() > */ > public IJavaElement getJavaElement() { >+ try { >+ return new CompilationUnit(null, this.getInternalName(), this.resolver.getWorkingCopyOwner()).getWorkingCopy(this.resolver.getWorkingCopyOwner(), null); >+ } catch (JavaModelException e) { >+ //ignore >+ } > return null; > } > >@@ -476,7 +503,36 @@ > * @see org.eclipse.jdt.core.dom.IBinding#getKey() > */ > public String getKey() { >- return null; >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append("Recovered#"); //$NON-NLS-1$ >+ if (this.innerTypeBinding != null) { >+ buffer.append("innerTypeBinding") //$NON-NLS-1$ >+ .append(this.innerTypeBinding.getKey()); >+ } else if (this.currentType != null) { >+ buffer.append("currentType") //$NON-NLS-1$ >+ .append(this.currentType.toString()); >+ } else if (this.referenceBinding != null) { >+ buffer.append("referenceBinding") //$NON-NLS-1$ >+ .append(this.referenceBinding.computeUniqueKey()); >+ } else if (variableDeclaration != null) { >+ buffer >+ .append("variableDeclaration") //$NON-NLS-1$ >+ .append(this.variableDeclaration.getClass()) >+ .append(this.variableDeclaration.getName().getIdentifier()) >+ .append(this.variableDeclaration.getExtraDimensions()); >+ } >+ buffer.append(this.getDimensions()); >+ if (this.typeArguments != null) { >+ buffer.append('<'); >+ for (int i = 0, max = this.typeArguments.length; i < max; i++) { >+ if (i != 0) { >+ buffer.append(','); >+ } >+ buffer.append(this.typeArguments[i].getKey()); >+ } >+ buffer.append('>'); >+ } >+ return String.valueOf(buffer); > } > > /* (non-Javadoc) >@@ -497,7 +553,8 @@ > * @see org.eclipse.jdt.core.dom.IBinding#isEqualTo(org.eclipse.jdt.core.dom.IBinding) > */ > public boolean isEqualTo(IBinding other) { >- return false; >+ if (!other.isRecovered() || other.getKind() != IBinding.TYPE) return false; >+ return this.getKey().equals(other.getKey()); > } > > /* (non-Javadoc) >Index: dom/org/eclipse/jdt/core/dom/ITypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java,v >retrieving revision 1.66 >diff -u -r1.66 ITypeBinding.java >--- dom/org/eclipse/jdt/core/dom/ITypeBinding.java 15 Mar 2007 16:06:40 -0000 1.66 >+++ dom/org/eclipse/jdt/core/dom/ITypeBinding.java 24 Apr 2007 14:55:42 -0000 >@@ -54,13 +54,11 @@ > * <p>If the receiver is an array binding, then the resulting dimension is the given dimension > * plus the dimension of the receiver. Otherwise the resulting dimension is the given > * dimension.</p> >- * <p>It cannot be called on a recovered binding.</p> > * > * @param dimension the given dimension > * @return an array type binding > * @throws IllegalArgumentException:<ul> > * <li>if the receiver represents the void type</li> >- * <li>if the receiver represents a recovered binding</li> > * <li>if the resulting dimensions is lower than one or greater than 255</li> > * </ul> > * @since 3.3 >@@ -306,12 +304,12 @@ > * original source, since the compiler may change them (in particular, > * for inner class emulation). The <code>getDeclaredModifiers</code> method > * should be used if the original modifiers are needed. >- * Returns 0 if this type does not represent a class, interface, enum, or annotation >- * type. >+ * Returns 0 if this type does not represent a class, an interface, an enum, an annotation >+ * type or a recovered type. > * > * @return the compiled modifiers for this type binding or 0 >- * if this type does not represent a class, interface, enum, or annotation >- * type >+ * if this type does not represent a class, an interface, an enum, an annotation >+ * type or a recovered type. > * @see #getDeclaredModifiers() > */ > public int getModifiers(); >@@ -365,11 +363,14 @@ > > /** > * Returns the binding for the package in which this type is declared. >+ * >+ * <p>The package of a recovered type reference binding is the package of the >+ * enclosing type.</p> > * > * @return the binding for the package in which this class, interface, > * enum, or annotation type is declared, or <code>null</code> if this type > * binding represents a primitive type, an array type, the null type, >- * a type variable, a wildcard type, a capture binding, or a recovered binding. >+ * a type variable, a wildcard type, a capture binding. > */ > public IPackageBinding getPackage(); > >@@ -454,8 +455,8 @@ > * <p> > * If this type binding represents an interface, an array type, a > * primitive type, the null type, a type variable, an enum type, >- * an annotation type, a wildcard type, a capture binding, or a >- * recovered binding then <code>null</code> is returned. >+ * an annotation type, a wildcard type, or a capture binding then >+ * <code>null</code> is returned. > * </p> > * > * @return the superclass of the class represented by this type binding, >@@ -593,7 +594,8 @@ > * of the given type, as specified in section 5.2 of <em>The Java Language > * Specification, Third Edition</em> (JLS3). > * >- * <p>If the receiver or the argument is a recovered type, the answer is always false.</p> >+ * <p>If the receiver or the argument is a recovered type, the answer is always false, >+ * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p> > * > * @param variableType the type of a variable to check compatibility against > * @return <code>true</code> if an expression of this type can be assigned to a >@@ -641,7 +643,8 @@ > * <code>A.isCastCompatible(B)</code> > * </p> > * >- * <p>If the receiver or the argument is a recovered type, the answer is always false.</p> >+ * <p>If the receiver or the argument is a recovered type, the answer is always false, >+ * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p> > * > * @param type the type to check compatibility against > * @return <code>true</code> if this type is cast compatible with the >@@ -651,9 +654,9 @@ > public boolean isCastCompatible(ITypeBinding type); > > /** >- * Returns whether this type binding represents a class type. >+ * Returns whether this type binding represents a class type or a recovered binding. > * >- * @return <code>true</code> if this object represents a class, >+ * @return <code>true</code> if this object represents a class or a recovered binding, > * and <code>false</code> otherwise > */ > public boolean isClass(); >@@ -844,7 +847,8 @@ > * as specified in section 4.10 of <em>The Java Language > * Specification, Third Edition</em> (JLS3). > * >- * <p>If the receiver or the argument is a recovered type, the answer is always false.</p> >+ * <p>If the receiver or the argument is a recovered type, the answer is always false, >+ * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p> > * > * @param type the type to check compatibility against > * @return <code>true</code> if this type is subtype compatible with the >Index: dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java,v >retrieving revision 1.2 >diff -u -r1.2 RecoveredVariableBinding.java >--- dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java 21 Mar 2007 18:20:26 -0000 1.2 >+++ dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java 24 Apr 2007 14:55:42 -0000 >@@ -29,10 +29,24 @@ > } > > public ITypeBinding getDeclaringClass() { >+ ASTNode parent = this.variableDeclaration.getParent(); >+ while (parent != null && parent.getNodeType() != ASTNode.TYPE_DECLARATION) { >+ parent = parent.getParent(); >+ } >+ if (parent != null) { >+ return ((TypeDeclaration) parent).resolveBinding(); >+ } > return null; > } > > public IMethodBinding getDeclaringMethod() { >+ ASTNode parent = this.variableDeclaration.getParent(); >+ while (parent != null && parent.getNodeType() != ASTNode.METHOD_DECLARATION) { >+ parent = parent.getParent(); >+ } >+ if (parent != null) { >+ return ((MethodDeclaration) parent).resolveBinding(); >+ } > return null; > } > >@@ -73,7 +87,16 @@ > } > > public String getKey() { >- return null; >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append("Recovered#"); //$NON-NLS-1$ >+ if (variableDeclaration != null) { >+ buffer >+ .append("variableDeclaration") //$NON-NLS-1$ >+ .append(this.variableDeclaration.getClass()) >+ .append(this.variableDeclaration.getName().getIdentifier()) >+ .append(this.variableDeclaration.getExtraDimensions()); >+ } >+ return String.valueOf(buffer); > } > > public int getKind() { >@@ -89,6 +112,9 @@ > } > > public boolean isEqualTo(IBinding binding) { >+ if (binding.isRecovered() && binding.getKind() == IBinding.VARIABLE) { >+ return this.getKey().equals(binding.getKey()); >+ } > return false; > } > >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.154 >diff -u -r1.154 DefaultBindingResolver.java >--- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 15 Mar 2007 16:06:40 -0000 1.154 >+++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 24 Apr 2007 14:55:41 -0000 >@@ -358,17 +358,11 @@ > /* > * Method declared on BindingResolver. > */ >- synchronized ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding) { >+ synchronized ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding, int dimensions) { > if (recoveredTypeBinding== null) { > return null; > } >- ITypeBinding binding = (ITypeBinding) this.bindingTables.compilerBindingsToASTBindings.get(recoveredTypeBinding); >- if (binding != null) { >- return binding; >- } >- binding = new RecoveredTypeBinding(this, recoveredTypeBinding); >- this.bindingTables.compilerBindingsToASTBindings.put(recoveredTypeBinding, binding); >- return binding; >+ return new RecoveredTypeBinding(this, recoveredTypeBinding, dimensions); > } > > synchronized IVariableBinding getVariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding variableBinding, VariableDeclaration variableDeclaration) { >@@ -417,6 +411,10 @@ > return this.getVariableBinding(variableBinding); > } > >+ public WorkingCopyOwner getWorkingCopyOwner() { >+ return this.workingCopyOwner; >+ } >+ > /* > * Method declared on BindingResolver. > */ >@@ -1734,8 +1732,7 @@ > * @param dimensions the given dimensions > * @return an array type binding with the given type binding and the given > * dimensions >- * @throws IllegalArgumentException if the type binding represents the <code>void</code> type binding or if the >- * given type binding is a recovered binding >+ * @throws IllegalArgumentException if the type binding represents the <code>void</code> type binding > */ > ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) { > if (typeBinding.isRecovered()) throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$ >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.32 >diff -u -r1.32 IBinding.java >--- dom/org/eclipse/jdt/core/dom/IBinding.java 21 Mar 2007 17:51:08 -0000 1.32 >+++ dom/org/eclipse/jdt/core/dom/IBinding.java 24 Apr 2007 14:55:41 -0000 >@@ -274,7 +274,7 @@ > * </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.<br> >- * <code>null</code> is also returned for recovered bindings >+ * Recovered bindings have a unique key. > * </p> > * > * @return the key for this binding
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 180905
:
62898
|
64669
| 64747