### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: eval/org/eclipse/jdt/internal/eval/EvaluationContext.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java,v retrieving revision 1.56 diff -u -r1.56 EvaluationContext.java --- eval/org/eclipse/jdt/internal/eval/EvaluationContext.java 28 Sep 2006 14:14:30 -0000 1.56 +++ eval/org/eclipse/jdt/internal/eval/EvaluationContext.java 29 Mar 2007 14:39:47 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * 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 @@ -514,6 +514,10 @@ } return this.codeSnippetBinary; } +public char[] getVarClassName() { + if (installedVars == null) return CharOperation.NO_CHAR; + return CharOperation.concat(installedVars.packageName, installedVars.className, '.'); +} /** * Creates a new global variable with the given name, type and initializer. * If the variable is not initialized, the initializer can be null. Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java,v retrieving revision 1.60 diff -u -r1.60 CodeSnippetToCuMapper.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 7 Dec 2006 14:50:04 -0000 1.60 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 29 Mar 2007 14:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * 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 @@ -164,17 +164,22 @@ if (CharOperation.equals(packageName, CodeSnippetToCuMapper.this.snippetPackageName) && (CharOperation.equals(className, CodeSnippetToCuMapper.this.snippetClassName) || CharOperation.equals(className, CodeSnippetToCuMapper.this.snippetVarClassName))) return; + + if (CharOperation.equals(packageName, PACKAGE_NAME) + && CharOperation.equals(className, ROOT_CLASS_NAME)) return; } break; case CompletionProposal.METHOD_REF: case CompletionProposal.METHOD_DECLARATION: // Remove completion on generated method - char[] declaringTypePackageName = Signature.getSignatureSimpleName(proposal.getDeclarationSignature()); + char[] declaringTypePackageName = Signature.getSignatureQualifier(proposal.getDeclarationSignature()); char[] declaringTypeName = Signature.getSignatureSimpleName(proposal.getDeclarationSignature()); - char[] selector = proposal.getName(); + if (CharOperation.equals(declaringTypePackageName, CodeSnippetToCuMapper.this.snippetPackageName) - && CharOperation.equals(declaringTypeName, CodeSnippetToCuMapper.this.snippetClassName) - && CharOperation.equals(selector, "run".toCharArray())) return; //$NON-NLS-1$ + && CharOperation.equals(declaringTypeName, CodeSnippetToCuMapper.this.snippetClassName)) return; + + if (CharOperation.equals(declaringTypePackageName, PACKAGE_NAME) + && CharOperation.equals(declaringTypeName, ROOT_CLASS_NAME)) return; break; } originalRequestor.accept(proposal); Index: model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java,v retrieving revision 1.55 diff -u -r1.55 EvaluationContextWrapper.java --- model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java 10 May 2006 18:03:51 -0000 1.55 +++ model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java 29 Mar 2007 14:39:47 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * 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 @@ -272,6 +272,9 @@ protected INameEnvironment getBuildNameEnvironment() { return new NameEnvironment(getProject()); } +public char[] getVarClassName() { + return this.context.getVarClassName(); +} /** * @see org.eclipse.jdt.core.eval.IEvaluationContext#getImports() #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.153 diff -u -r1.153 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 20 Mar 2007 11:18:53 -0000 1.153 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 29 Mar 2007 14:40:00 -0000 @@ -19,6 +19,7 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.eval.IEvaluationContext; import org.eclipse.jdt.internal.codeassist.RelevanceConstants; +import org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper; import junit.framework.*; @@ -44,6 +45,10 @@ public void tearDownSuite() throws Exception { super.tearDownSuite(); } +private String getVarClassSignature(IEvaluationContext context) { + char[] varClassName = ((EvaluationContextWrapper)context).getVarClassName(); + return Signature.createTypeSignature(varClassName, true); +} //https://bugs.eclipse.org/bugs/show_bug.cgi?id=164311 public void testBug164311() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; @@ -14046,6 +14051,42 @@ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"}", requestor.getResults()); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=179000 +public void testEvaluationContextCompletion6() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/TestEvaluationContextCompletion6.java", + "package test;"+ + "public class TestEvaluationContextCompletion6 {\n"+ + "}"); + + String start = ""; + IJavaProject javaProject = getJavaProject("Completion"); + IEvaluationContext context = javaProject.newEvaluationContext(); + + context.newVariable( "Object", "someVariable", null ); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false); + context.codeComplete(start, start.length(), requestor, this.wcOwner); + + int startOffset = start.length(); + int endOffset = startOffset; + + assertResults( + "completion offset="+endOffset+"\n"+ + "completion range=["+startOffset+", "+(endOffset)+"]\n"+ + "completion token=\"\"\n"+ + "completion token kind=TOKEN_KIND_NAME\n"+ + "expectedTypesSignatures=null\n"+ + "expectedTypesKeys=null", + requestor.getContext()); + + String varClassSignature = getVarClassSignature(context); + + assertResults( + "someVariable[FIELD_REF]{someVariable, "+varClassSignature+", Ljava.lang.Object;, someVariable, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} //https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 public void testFavoriteImports001() throws JavaModelException { this.workingCopies = new ICompilationUnit[2];