Index: codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java,v retrieving revision 1.115 diff -u -r1.115 SelectionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 6 Jun 2005 17:07:18 -0000 1.115 +++ codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 13 Jun 2005 15:20:42 -0000 @@ -782,28 +782,35 @@ if(enclosingElement instanceof SourceTypeBinding) { SourceTypeBinding enclosingType = (SourceTypeBinding) enclosingElement; - this.requestor.acceptTypeParameter( - enclosingType.qualifiedPackageName(), - enclosingType.qualifiedSourceName(), - typeVariableBinding.sourceName(), - false, - this.actualSelectionStart, - this.actualSelectionEnd); + if (isLocal(enclosingType) && this.requestor instanceof SelectionRequestor) { + ((SelectionRequestor)this.requestor).acceptLocalTypeParameter(typeVariableBinding); + } else { + this.requestor.acceptTypeParameter( + enclosingType.qualifiedPackageName(), + enclosingType.qualifiedSourceName(), + typeVariableBinding.sourceName(), + false, + this.actualSelectionStart, + this.actualSelectionEnd); + } } else if(enclosingElement instanceof MethodBinding) { MethodBinding enclosingMethod = (MethodBinding) enclosingElement; - - this.requestor.acceptMethodTypeParameter( - enclosingMethod.declaringClass.qualifiedPackageName(), - enclosingMethod.declaringClass.qualifiedSourceName(), - enclosingMethod.isConstructor() - ? enclosingMethod.declaringClass.sourceName() - : enclosingMethod.selector, - enclosingMethod.sourceStart(), - enclosingMethod.sourceEnd(), - typeVariableBinding.sourceName(), - false, - this.actualSelectionStart, - this.actualSelectionEnd); + if (isLocal(enclosingMethod.declaringClass) && this.requestor instanceof SelectionRequestor) { + ((SelectionRequestor)this.requestor).acceptLocalMethodTypeParameter(typeVariableBinding); + } else { + this.requestor.acceptMethodTypeParameter( + enclosingMethod.declaringClass.qualifiedPackageName(), + enclosingMethod.declaringClass.qualifiedSourceName(), + enclosingMethod.isConstructor() + ? enclosingMethod.declaringClass.sourceName() + : enclosingMethod.selector, + enclosingMethod.sourceStart(), + enclosingMethod.sourceEnd(), + typeVariableBinding.sourceName(), + false, + this.actualSelectionStart, + this.actualSelectionEnd); + } } this.acceptedAnswer = true; } else if (binding instanceof ReferenceBinding) { @@ -967,6 +974,18 @@ } return true; } + public boolean visit(TypeParameter typeParameter, BlockScope scope) { + if (typeParameter.name == assistIdentifier) { + throw new SelectionNodeFound(typeParameter.binding); + } + return true; + } + public boolean visit(TypeParameter typeParameter, ClassScope scope) { + if (typeParameter.name == assistIdentifier) { + throw new SelectionNodeFound(typeParameter.binding); + } + return true; + } } if (node instanceof AbstractMethodDeclaration) { Index: model/org/eclipse/jdt/internal/core/SelectionRequestor.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java,v retrieving revision 1.58 diff -u -r1.58 SelectionRequestor.java --- model/org/eclipse/jdt/internal/core/SelectionRequestor.java 25 Mar 2005 18:39:49 -0000 1.58 +++ model/org/eclipse/jdt/internal/core/SelectionRequestor.java 13 Jun 2005 15:20:44 -0000 @@ -24,7 +24,6 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.compiler.*; -import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.codeassist.ISelectionRequestor; import org.eclipse.jdt.internal.codeassist.SelectionEngine; import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; @@ -36,6 +35,7 @@ import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; import org.eclipse.jdt.internal.core.util.HandleFactory; import org.eclipse.jdt.internal.core.util.Util; @@ -283,6 +283,45 @@ } } } +public void acceptLocalTypeParameter(TypeVariableBinding typeVariableBinding) { + IJavaElement res; + if(typeVariableBinding.declaringElement instanceof ParameterizedTypeBinding) { + LocalTypeBinding localTypeBinding = (LocalTypeBinding)((ParameterizedTypeBinding)typeVariableBinding.declaringElement).type; + res = findLocalElement(localTypeBinding.sourceStart()); + } else { + SourceTypeBinding typeBinding = (SourceTypeBinding)typeVariableBinding.declaringElement; + res = findLocalElement(typeBinding.sourceStart()); + } + if (res != null && res.getElementType() == IJavaElement.TYPE) { + IType type = (IType) res; + ITypeParameter typeParameter = type.getTypeParameter(new String(typeVariableBinding.sourceName)); + if (typeParameter.exists()) { + addElement(typeParameter); + if(SelectionEngine.DEBUG){ + System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$ + System.out.print(typeParameter.toString()); + System.out.println(")"); //$NON-NLS-1$ + } + } + } +} +public void acceptLocalMethodTypeParameter(TypeVariableBinding typeVariableBinding) { + MethodBinding methodBinding = (MethodBinding)typeVariableBinding.declaringElement; + IJavaElement res = findLocalElement(methodBinding.sourceStart()); + if(res != null && res.getElementType() == IJavaElement.METHOD) { + IMethod method = (IMethod) res; + + ITypeParameter typeParameter = method.getTypeParameter(new String(typeVariableBinding.sourceName)); + if (typeParameter.exists()) { + addElement(typeParameter); + if(SelectionEngine.DEBUG){ + System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$ + System.out.print(typeParameter.toString()); + System.out.println(")"); //$NON-NLS-1$ + } + } + } +} public void acceptLocalVariable(LocalVariableBinding binding) { LocalDeclaration local = binding.declaration; IJavaElement parent = findLocalElement(local.sourceStart); // findLocalElement() cannot find local variable