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 11926 Details for
Bug 66271
No need to resolve type names when selecting declaration
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
patch proposal
patchjdtcore.txt (text/plain), 28.42 KB, created by
David Audel
on 2004-06-11 06:10:43 EDT
(
hide
)
Description:
patch proposal
Filename:
MIME Type:
Creator:
David Audel
Created:
2004-06-11 06:10:43 EDT
Size:
28.42 KB
patch
obsolete
>Index: codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java,v >retrieving revision 1.13 >diff -u -r1.13 ISelectionRequestor.java >--- codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java 8 Jun 2004 11:02:47 -0000 1.13 >+++ codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java 11 Jun 2004 10:06:36 -0000 >@@ -27,6 +27,15 @@ > * @param needQualification boolean > * Flag indicating if the type name > * must be qualified by its package name (depending on imports). >+ * >+ * @param isDeclaration boolean >+ * Answer if the selected method is a declaration >+ * >+ * @param start >+ * Start of the selection >+ * >+ * @param end >+ * End of the selection > * > * NOTE - All package and type names are presented in their readable form: > * Package names are in the form "a.b.c". >@@ -36,7 +45,10 @@ > void acceptClass( > char[] packageName, > char[] className, >- boolean needQualification); >+ boolean needQualification, >+ boolean isDeclaration, >+ int start, >+ int end); > > /** > * Code assist notification of a compilation error detected during selection. >@@ -62,6 +74,15 @@ > * > * @param name char[] > * Name of the field. >+ * >+ * @param isDeclaration boolean >+ * Answer if the selected field is a declaration >+ * >+ * @param start >+ * Start of the selection >+ * >+ * @param end >+ * End of the selection > * > * NOTE - All package and type names are presented in their readable form: > * Package names are in the form "a.b.c". >@@ -71,7 +92,10 @@ > void acceptField( > char[] declaringTypePackageName, > char[] declaringTypeName, >- char[] name); >+ char[] name, >+ boolean isDeclaration, >+ int start, >+ int end); > > /** > * Code assist notification of an interface selection. >@@ -84,6 +108,15 @@ > * @param needQualification boolean > * Flag indicating if the type name > * must be qualified by its package name (depending on imports). >+ * >+ * @param isDeclaration boolean >+ * Answer if the selected method is a declaration >+ * >+ * @param start >+ * Start of the selection >+ * >+ * @param end >+ * End of the selection > * > * NOTE - All package and type names are presented in their readable form: > * Package names are in the form "a.b.c". >@@ -93,7 +126,10 @@ > void acceptInterface( > char[] packageName, > char[] interfaceName, >- boolean needQualification); >+ boolean needQualification, >+ boolean isDeclaration, >+ int start, >+ int end); > > /** > * Code assist notification of a method selection. >Index: codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java,v >retrieving revision 1.75 >diff -u -r1.75 SelectionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 8 Jun 2004 11:02:47 -0000 1.75 >+++ codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 11 Jun 2004 10:06:36 -0000 >@@ -162,7 +162,10 @@ > requestor.acceptClass( > packageName, > className, >- false); >+ false, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > this.acceptedAnswer = true; > } > } >@@ -209,7 +212,10 @@ > this.requestor.acceptInterface( > packageName, > interfaceName, >- false); >+ false, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > this.acceptedAnswer = true; > } > } >@@ -235,7 +241,10 @@ > this.requestor.acceptClass( > acceptedClasses[i][0], > acceptedClasses[i][1], >- true); >+ true, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > } > acceptedClasses = null; > acceptedClassesCount = 0; >@@ -247,7 +256,10 @@ > this.requestor.acceptInterface( > acceptedInterfaces[i][0], > acceptedInterfaces[i][1], >- true); >+ true, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > } > acceptedInterfaces = null; > acceptedInterfacesCount = 0; >@@ -492,12 +504,13 @@ > } > } > if (parsedUnit.types != null) { >+ if(selectDeclaration(parsedUnit)) >+ return; > lookupEnvironment.buildTypeBindings(parsedUnit); > if ((this.unitScope = parsedUnit.scope) != null) { > try { > lookupEnvironment.completeTypeBindings(parsedUnit, true); > parsedUnit.scope.faultInTypes(); >- selectDeclaration(parsedUnit); > ASTNode node = parseBlockStatements(parsedUnit, selectionSourceStart); > if(DEBUG) { > System.out.println("SELECTION - AST :"); //$NON-NLS-1$ >@@ -557,7 +570,10 @@ > this.requestor.acceptInterface( > typeBinding.qualifiedPackageName(), > typeBinding.qualifiedSourceName(), >- false); >+ false, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > } > } else if(typeBinding instanceof ProblemReferenceBinding){ > ReferenceBinding original = ((ProblemReferenceBinding) typeBinding).original; >@@ -571,7 +587,10 @@ > this.requestor.acceptClass( > original.qualifiedPackageName(), > original.qualifiedSourceName(), >- false); >+ false, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > } > } else { > noProposal = false; >@@ -583,7 +602,10 @@ > this.requestor.acceptClass( > typeBinding.qualifiedPackageName(), > typeBinding.qualifiedSourceName(), >- false); >+ false, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > } > } > this.acceptedAnswer = true; >@@ -643,7 +665,10 @@ > this.requestor.acceptField( > declaringClass.qualifiedPackageName(), > declaringClass.qualifiedSourceName(), >- fieldBinding.name); >+ fieldBinding.name, >+ false, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); > } > this.acceptedAnswer = true; > } >@@ -858,48 +883,111 @@ > } > > // Check if a declaration got selected in this unit >- private void selectDeclaration(CompilationUnitDeclaration compilationUnit){ >+ private boolean selectDeclaration(CompilationUnitDeclaration compilationUnit){ > > // the selected identifier is not identical to the parser one (equals but not identical), > // for traversing the parse tree, the parser assist identifier is necessary for identitiy checks > char[] assistIdentifier = this.getParser().assistIdentifier(); >- if (assistIdentifier == null) return; >+ if (assistIdentifier == null) return false; > >+ ImportReference currentPackage = compilationUnit.currentPackage; >+ char[] packageName = currentPackage == null ? new char[0] : CharOperation.concatWith(currentPackage.tokens, '.'); > // iterate over the types > TypeDeclaration[] types = compilationUnit.types; > for (int i = 0, length = types == null ? 0 : types.length; i < length; i++){ >- selectDeclaration(types[i], assistIdentifier); >+ if(selectDeclaration(types[i], assistIdentifier, packageName)) >+ return true; > } >+ return false; > } > > // Check if a declaration got selected in this type >- private void selectDeclaration(TypeDeclaration typeDeclaration, char[] assistIdentifier){ >+ private boolean selectDeclaration(TypeDeclaration typeDeclaration, char[] assistIdentifier, char[] packageName){ > > if (typeDeclaration.name == assistIdentifier){ >- throw new SelectionNodeFound(typeDeclaration.binding, true); >+ char[] qualifiedSourceName = null; >+ >+ TypeDeclaration enclosingType = typeDeclaration; >+ while(enclosingType != null) { >+ qualifiedSourceName = CharOperation.concat(enclosingType.name, qualifiedSourceName, '.'); >+ enclosingType = enclosingType.enclosingType; >+ } >+ >+ if(!typeDeclaration.isInterface()) { >+ this.requestor.acceptClass( >+ packageName, >+ qualifiedSourceName, >+ false, >+ true, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); >+ } else { >+ this.requestor.acceptInterface( >+ packageName, >+ qualifiedSourceName, >+ false, >+ true, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); >+ } >+ this.noProposal = false; >+ return true; > } > TypeDeclaration[] memberTypes = typeDeclaration.memberTypes; > for (int i = 0, length = memberTypes == null ? 0 : memberTypes.length; i < length; i++){ >- selectDeclaration(memberTypes[i], assistIdentifier); >+ if(selectDeclaration(memberTypes[i], assistIdentifier, packageName)) >+ return true; > } > FieldDeclaration[] fields = typeDeclaration.fields; > for (int i = 0, length = fields == null ? 0 : fields.length; i < length; i++){ > if (fields[i].name == assistIdentifier){ >- throw new SelectionNodeFound(fields[i].binding, true); >+ char[] qualifiedSourceName = null; >+ >+ TypeDeclaration enclosingType = typeDeclaration; >+ while(enclosingType != null) { >+ qualifiedSourceName = CharOperation.concat(enclosingType.name, qualifiedSourceName, '.'); >+ enclosingType = enclosingType.enclosingType; >+ } >+ >+ this.requestor.acceptField( >+ packageName, >+ qualifiedSourceName, >+ fields[i].name, >+ true, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); >+ >+ this.noProposal = false; >+ return true; > } > } > AbstractMethodDeclaration[] methods = typeDeclaration.methods; > for (int i = 0, length = methods == null ? 0 : methods.length; i < length; i++){ > AbstractMethodDeclaration method = methods[i]; > if (method.selector == assistIdentifier){ >- if(method.binding != null) { >- throw new SelectionNodeFound(method.binding, true); >- } else { >- if(method.scope != null) { >- throw new SelectionNodeFound(new MethodBinding(method.modifiers, method.selector, null, null, null, method.scope.referenceType().binding), true); >- } >+ char[] qualifiedSourceName = null; >+ >+ TypeDeclaration enclosingType = typeDeclaration; >+ while(enclosingType != null) { >+ qualifiedSourceName = CharOperation.concat(enclosingType.name, qualifiedSourceName, '.'); >+ enclosingType = enclosingType.enclosingType; > } >+ >+ this.requestor.acceptMethod( >+ packageName, >+ qualifiedSourceName, >+ method.selector, >+ null, // SelectionRequestor does not need of parameters type for method declaration >+ null, // SelectionRequestor does not need of parameters type for method declaration >+ method.isConstructor(), >+ true, >+ this.actualSelectionStart, >+ this.actualSelectionEnd); >+ >+ this.noProposal = false; >+ return true; > } > } >+ return false; > } > } >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java,v >retrieving revision 1.39 >diff -u -r1.39 CodeSnippetToCuMapper.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 8 Jun 2004 11:02:47 -0000 1.39 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 11 Jun 2004 10:06:36 -0000 >@@ -271,8 +271,8 @@ > */ > public ISelectionRequestor getSelectionRequestor(final ISelectionRequestor originalRequestor) { > return new ISelectionRequestor() { >- public void acceptClass(char[] packageName, char[] className, boolean needQualification) { >- originalRequestor.acceptClass(packageName, className, needQualification); >+ public void acceptClass(char[] packageName, char[] className, boolean needQualification, boolean isDeclaration, int start, int end) { >+ originalRequestor.acceptClass(packageName, className, needQualification, isDeclaration, start, end); > } > public void acceptError(IProblem error) { > error.setSourceLineNumber(error.getSourceLineNumber() - CodeSnippetToCuMapper.this.lineNumberOffset); >@@ -280,11 +280,11 @@ > error.setSourceEnd(error.getSourceEnd() - CodeSnippetToCuMapper.this.startPosOffset); > originalRequestor.acceptError(error); > } >- public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name) { >- originalRequestor.acceptField(declaringTypePackageName, declaringTypeName, name); >+ public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, boolean isDeclaration, int start, int end) { >+ originalRequestor.acceptField(declaringTypePackageName, declaringTypeName, name, isDeclaration, start, end); > } >- public void acceptInterface(char[] packageName, char[] interfaceName, boolean needQualification) { >- originalRequestor.acceptInterface(packageName, interfaceName, needQualification); >+ public void acceptInterface(char[] packageName, char[] interfaceName, boolean needQualification, boolean isDeclaration, int start, int end) { >+ originalRequestor.acceptInterface(packageName, interfaceName, needQualification, isDeclaration, start, end); > } > public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, boolean isConstructor, boolean isDeclaration, int start, int end) { > originalRequestor.acceptMethod(declaringTypePackageName, declaringTypeName, selector, parameterPackageNames, parameterTypeNames, isConstructor, isDeclaration, start, end); >Index: model/org/eclipse/jdt/internal/core/SelectionRequestor.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java,v >retrieving revision 1.39 >diff -u -r1.39 SelectionRequestor.java >--- model/org/eclipse/jdt/internal/core/SelectionRequestor.java 8 Jun 2004 11:02:47 -0000 1.39 >+++ model/org/eclipse/jdt/internal/core/SelectionRequestor.java 11 Jun 2004 10:06:36 -0000 >@@ -99,8 +99,8 @@ > /** > * Resolve the class. > */ >-public void acceptClass(char[] packageName, char[] className, boolean needQualification) { >- acceptType(packageName, className, NameLookup.ACCEPT_CLASSES, needQualification); >+public void acceptClass(char[] packageName, char[] className, boolean needQualification, boolean isDeclaration, int start, int end) { >+ acceptType(packageName, className, NameLookup.ACCEPT_CLASSES, needQualification, isDeclaration, start, end); > } > /** > * @see ISelectionRequestor#acceptError >@@ -111,17 +111,45 @@ > /** > * Resolve the field. > */ >-public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name) { >- IType type= resolveType(declaringTypePackageName, declaringTypeName, >- NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES); >- if (type != null) { >- IField field= type.getField(new String(name)); >- if (field.exists()) { >- addElement(field); >- if(SelectionEngine.DEBUG){ >- System.out.print("SELECTION - accept field("); //$NON-NLS-1$ >- System.out.print(field.toString()); >- System.out.println(")"); //$NON-NLS-1$ >+public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, boolean isDeclaration, int start, int end) { >+ if(isDeclaration) { >+ IType type= resolveType2(declaringTypePackageName, declaringTypeName, >+ NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES, >+ start, end); >+ if(type != null) { >+ try { >+ IField[] fields = type.getFields(); >+ for (int i = 0; i < fields.length; i++) { >+ IField field = fields[i]; >+ ISourceRange range = field.getNameRange(); >+ if(range.getOffset() <= start >+ && range.getOffset() + range.getLength() >= end >+ && field.getElementName().equals(new String(name))) { >+ addElement(fields[i]); >+ if(SelectionEngine.DEBUG){ >+ System.out.print("SELECTION - accept field("); //$NON-NLS-1$ >+ System.out.print(field.toString()); >+ System.out.println(")"); //$NON-NLS-1$ >+ } >+ return; // only one method is possible >+ } >+ } >+ } catch (JavaModelException e) { >+ return; >+ } >+ } >+ } else { >+ IType type= resolveType(declaringTypePackageName, declaringTypeName, >+ NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES); >+ if (type != null) { >+ IField field= type.getField(new String(name)); >+ if (field.exists()) { >+ addElement(field); >+ if(SelectionEngine.DEBUG){ >+ System.out.print("SELECTION - accept field("); //$NON-NLS-1$ >+ System.out.print(field.toString()); >+ System.out.println(")"); //$NON-NLS-1$ >+ } > } > } > } >@@ -129,8 +157,8 @@ > /** > * Resolve the interface > */ >-public void acceptInterface(char[] packageName, char[] interfaceName, boolean needQualification) { >- acceptType(packageName, interfaceName, NameLookup.ACCEPT_INTERFACES, needQualification); >+public void acceptInterface(char[] packageName, char[] interfaceName, boolean needQualification, boolean isDeclaration, int start, int end) { >+ acceptType(packageName, interfaceName, NameLookup.ACCEPT_INTERFACES, needQualification, isDeclaration, start, end); > } > public void acceptLocalField(SourceTypeBinding typeBinding, char[] name, CompilationUnitDeclaration parsedUnit) { > IType type = (IType)this.handleFactory.createElement(typeBinding.scope.referenceContext, parsedUnit, this.openable); >@@ -173,7 +201,7 @@ > > acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames); > } else { >- acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames, isDeclaration, start, end); >+ acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames); > } > } > } >@@ -203,34 +231,44 @@ > * Resolve the method > */ > public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, boolean isConstructor, boolean isDeclaration, int start, int end) { >- IType type= resolveType(declaringTypePackageName, declaringTypeName, >- NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES); >- // fix for 1FWFT6Q >- if (type != null) { >- if (type.isBinary()) { >- >- // need to add a paramater for constructor in binary type >- IType declaringDeclaringType = type.getDeclaringType(); >- >- boolean isStatic = false; >- try { >- isStatic = Flags.isStatic(type.getFlags()); >- } catch (JavaModelException e) { >- // isStatic == false >- } >- >- if(declaringDeclaringType != null && isConstructor && !isStatic) { >- int length = parameterPackageNames.length; >- System.arraycopy(parameterPackageNames, 0, parameterPackageNames = new char[length+1][], 1, length); >- System.arraycopy(parameterTypeNames, 0, parameterTypeNames = new char[length+1][], 1, length); >+ if(isDeclaration) { >+ IType type = resolveType2(declaringTypePackageName, declaringTypeName, >+ NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES, >+ start, end); >+ >+ if(type != null) { >+ this.acceptMethodDeclaration(type, selector, start, end); >+ } >+ } else { >+ IType type = resolveType(declaringTypePackageName, declaringTypeName, >+ NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES); >+ // fix for 1FWFT6Q >+ if (type != null) { >+ if (type.isBinary()) { > >- parameterPackageNames[0] = declaringDeclaringType.getPackageFragment().getElementName().toCharArray(); >- parameterTypeNames[0] = declaringDeclaringType.getTypeQualifiedName().toCharArray(); >+ // need to add a paramater for constructor in binary type >+ IType declaringDeclaringType = type.getDeclaringType(); >+ >+ boolean isStatic = false; >+ try { >+ isStatic = Flags.isStatic(type.getFlags()); >+ } catch (JavaModelException e) { >+ // isStatic == false >+ } >+ >+ if(declaringDeclaringType != null && isConstructor && !isStatic) { >+ int length = parameterPackageNames.length; >+ System.arraycopy(parameterPackageNames, 0, parameterPackageNames = new char[length+1][], 1, length); >+ System.arraycopy(parameterTypeNames, 0, parameterTypeNames = new char[length+1][], 1, length); >+ >+ parameterPackageNames[0] = declaringDeclaringType.getPackageFragment().getElementName().toCharArray(); >+ parameterTypeNames[0] = declaringDeclaringType.getTypeQualifiedName().toCharArray(); >+ } >+ >+ acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames); >+ } else { >+ acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames); > } >- >- acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames); >- } else { >- acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames, isDeclaration, start, end); > } > } > } >@@ -255,21 +293,15 @@ > * > * fix for 1FWFT6Q > */ >-protected void acceptSourceMethod(IType type, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, boolean isDeclaration, int start, int end) { >+protected void acceptSourceMethod(IType type, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames) { > String name = new String(selector); > IMethod[] methods = null; > try { > methods = type.getMethods(); > for (int i = 0; i < methods.length; i++) { >- if (methods[i].getElementName().equals(name) && methods[i].getParameterTypes().length == parameterTypeNames.length) { >- if(isDeclaration) { >- ISourceRange range = methods[i].getNameRange(); >- if(range.getOffset() <= start && range.getOffset() + range.getLength() >= end) { >- addElement(methods[i]); >- } >- } else { >- addElement(methods[i]); >- } >+ if (methods[i].getElementName().equals(name) >+ && methods[i].getParameterTypes().length == parameterTypeNames.length) { >+ addElement(methods[i]); > } > } > } catch (JavaModelException e) { >@@ -326,11 +358,50 @@ > } > > } >+protected void acceptMethodDeclaration(IType type, char[] selector, int start, int end) { >+ String name = new String(selector); >+ IMethod[] methods = null; >+ try { >+ methods = type.getMethods(); >+ for (int i = 0; i < methods.length; i++) { >+ if(methods[i].getElementName().equals(name)) { >+ ISourceRange range = methods[i].getNameRange(); >+ if(range.getOffset() <= start && range.getOffset() + range.getLength() >= end) { >+ addElement(methods[i]); >+ if(SelectionEngine.DEBUG){ >+ System.out.print("SELECTION - accept method("); //$NON-NLS-1$ >+ System.out.print(this.elements[0].toString()); >+ System.out.println(")"); //$NON-NLS-1$ >+ } >+ return; // only one method is possible >+ } >+ } >+ >+ } >+ } catch (JavaModelException e) { >+ return; >+ } >+ >+ // no match was actually found >+ addElement(type); >+ if(SelectionEngine.DEBUG){ >+ System.out.print("SELECTION - accept type("); //$NON-NLS-1$ >+ System.out.print(type.toString()); >+ System.out.println(")"); //$NON-NLS-1$ >+ } >+ return; >+} > /** > * Resolve the type, adding to the resolved elements. > */ >-protected void acceptType(char[] packageName, char[] typeName, int acceptFlags, boolean needQualification) { >- IType type= resolveType(packageName, typeName, acceptFlags); >+protected void acceptType(char[] packageName, char[] typeName, int acceptFlags, boolean needQualification, boolean isDeclaration, int start, int end) { >+ IType type = null; >+ if(isDeclaration) { >+ type = resolveType2(packageName, typeName, acceptFlags, start, end); >+ } else { >+ type = resolveType(packageName, typeName, acceptFlags); >+ } >+ > if (type != null) { > addElement(type); > if(SelectionEngine.DEBUG){ >@@ -339,7 +410,6 @@ > System.out.println(")"); //$NON-NLS-1$ > } > } >- > } > /* > * Adds the given element to the list of resolved elements. >@@ -379,6 +449,85 @@ > type = wc.getType(new String(compoundName[0])); > for (int i = 1, length = compoundName.length; i < length; i++) { > type = type.getType(new String(compoundName[i])); >+ } >+ } >+ >+ if(type != null && !type.exists()) { >+ type = null; >+ } >+ } >+ }catch (JavaModelException e) { >+ type = null; >+ } >+ } >+ >+ if(type == null) { >+ IPackageFragment[] pkgs = this.nameLookup.findPackageFragments( >+ (packageName == null || packageName.length == 0) ? IPackageFragment.DEFAULT_PACKAGE_NAME : new String(packageName), >+ false); >+ // iterate type lookup in each package fragment >+ for (int i = 0, length = pkgs == null ? 0 : pkgs.length; i < length; i++) { >+ type= this.nameLookup.findType(new String(typeName), pkgs[i], false, acceptFlags); >+ if (type != null) break; >+ } >+ if (type == null) { >+ String pName= IPackageFragment.DEFAULT_PACKAGE_NAME; >+ if (packageName != null) { >+ pName = new String(packageName); >+ } >+ if (this.openable != null && this.openable.getParent().getElementName().equals(pName)) { >+ // look inside the type in which we are resolving in >+ String tName= new String(typeName); >+ tName = tName.replace('.','$'); >+ IType[] allTypes= null; >+ try { >+ ArrayList list = this.openable.getChildrenOfType(IJavaElement.TYPE); >+ allTypes = new IType[list.size()]; >+ list.toArray(allTypes); >+ } catch (JavaModelException e) { >+ return null; >+ } >+ for (int i= 0; i < allTypes.length; i++) { >+ if (allTypes[i].getTypeQualifiedName().equals(tName)) { >+ return allTypes[i]; >+ } >+ } >+ } >+ } >+ } >+ return type; >+} >+protected IType resolveType2(char[] packageName, char[] typeName, int acceptFlags, int start, int end) { >+ >+ IType type= null; >+ >+ if (this.openable instanceof CompilationUnit && ((CompilationUnit)this.openable).isOpen()) { >+ CompilationUnit wc = (CompilationUnit) this.openable; >+ try { >+ if(((packageName == null || packageName.length == 0) && wc.getPackageDeclarations().length == 0) || >+ (!(packageName == null || packageName.length == 0) && wc.getPackageDeclaration(new String(packageName)).exists())) { >+ >+ char[][] compoundName = CharOperation.splitOn('.', typeName); >+ if(compoundName.length > 0) { >+ >+ IType[] tTypes = wc.getTypes(); >+ int i = 0; >+ int j = 0; >+ done : while(i < tTypes.length) { >+ ISourceRange range = tTypes[i].getSourceRange(); >+ if(range.getOffset() <= start >+ && range.getOffset() + range.getLength() >= end >+ && tTypes[i].getElementName().equals(new String(compoundName[j]))) { >+ if(j == compoundName.length - 1) { >+ type = tTypes[i]; >+ break done; >+ } >+ tTypes = tTypes[i].getTypes(); >+ i = 0; >+ j++; >+ continue done; >+ } >+ i++; > } > } > >Index: model/org/eclipse/jdt/internal/core/SourceType.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java,v >retrieving revision 1.89 >diff -u -r1.89 SourceType.java >--- model/org/eclipse/jdt/internal/core/SourceType.java 8 Jun 2004 11:02:47 -0000 1.89 >+++ model/org/eclipse/jdt/internal/core/SourceType.java 11 Jun 2004 10:06:36 -0000 >@@ -718,18 +718,18 @@ > this.answers[length] = answer; > } > } >- public void acceptClass(char[] packageName, char[] className, boolean needQualification) { >+ public void acceptClass(char[] packageName, char[] className, boolean needQualification, boolean isDeclaration, int start, int end) { > acceptType(new String[] { new String(packageName), new String(className) }); > } > >- public void acceptInterface(char[] packageName, char[] interfaceName, boolean needQualification) { >+ public void acceptInterface(char[] packageName, char[] interfaceName, boolean needQualification, boolean isDeclaration, int start, int end) { > acceptType(new String[] { new String(packageName), new String(interfaceName) }); > } > > public void acceptError(IProblem error) { > // ignore > } >- public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] fieldName) { >+ public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] fieldName, boolean isDeclaration, int start, int end) { > // ignore > } > public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, boolean isConstructor, boolean isDeclaration, int start, int end) {
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 Raw
Actions:
View
Attachments on
bug 66271
: 11926 |
11927