### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/CompletionRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CompletionRequestor.java,v retrieving revision 1.8 diff -u -r1.8 CompletionRequestor.java --- model/org/eclipse/jdt/core/CompletionRequestor.java 27 Oct 2005 15:30:05 -0000 1.8 +++ model/org/eclipse/jdt/core/CompletionRequestor.java 4 Sep 2006 14:22:36 -0000 @@ -80,7 +80,7 @@ * @see #setIgnored(int, boolean) * @see CompletionProposal#getKind() */ - public final boolean isIgnored(int completionProposalKind) { + public boolean isIgnored(int completionProposalKind) { if (completionProposalKind < CompletionProposal.FIRST_KIND || completionProposalKind > CompletionProposal.LAST_KIND) { throw new IllegalArgumentException("Unknown kind of completion proposal: "+completionProposalKind); //$NON-NLS-1$ @@ -99,7 +99,7 @@ * @see #isIgnored(int) * @see CompletionProposal#getKind() */ - public final void setIgnored(int completionProposalKind, boolean ignore) { + public void setIgnored(int completionProposalKind, boolean ignore) { if (completionProposalKind < CompletionProposal.FIRST_KIND || completionProposalKind > CompletionProposal.LAST_KIND) { throw new IllegalArgumentException("Unknown kind of completion proposal: "+completionProposalKind); //$NON-NLS-1$ 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.56 diff -u -r1.56 CodeSnippetToCuMapper.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 4 Sep 2006 08:58:33 -0000 1.56 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 4 Sep 2006 14:22:36 -0000 @@ -190,6 +190,22 @@ public void acceptContext(CompletionContext context) { originalRequestor.acceptContext(context); } + + public void beginReporting() { + originalRequestor.beginReporting(); + } + + public void endReporting() { + originalRequestor.endReporting(); + } + + public boolean isIgnored(int completionProposalKind) { + return originalRequestor.isIgnored(completionProposalKind); + } + + public void setIgnored(int completionProposalKind, boolean ignore) { + originalRequestor.setIgnored(completionProposalKind, ignore); + } }; } public char[] getCUSource(String lineSeparator) { #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.125 diff -u -r1.125 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 5 Jul 2006 14:21:58 -0000 1.125 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 4 Sep 2006 14:22:50 -0000 @@ -821,6 +821,107 @@ assertTrue("acceptContext() method isn't call", rc.acceptContext); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123 +public void testEvaluationContextCompletion2() throws JavaModelException { + class EvaluationContextCompletionRequestor extends CompletionRequestor { + public boolean acceptContext; + public boolean beginReporting; + public boolean endReporting; + + public void acceptContext(CompletionContext context) { + this.acceptContext = context != null; + } + public void accept(CompletionProposal proposal) { + // Do nothing + } + + public void beginReporting() { + this.beginReporting = true; + super.beginReporting(); + } + + public void endReporting() { + this.endReporting = true; + super.endReporting(); + } + } + String start = ""; + IJavaProject javaProject = getJavaProject("Completion"); + IEvaluationContext context = javaProject.newEvaluationContext(); + EvaluationContextCompletionRequestor rc = new EvaluationContextCompletionRequestor(); + context.codeComplete(start, start.length(), rc); + + assertTrue("acceptContext() method isn't call", rc.acceptContext); + assertTrue("beginReporting() method isn't call", rc.beginReporting); + assertTrue("endReporting() method isn't call", rc.endReporting); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123 +public void testEvaluationContextCompletion3() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/TestEvaluationContextCompletion3.java", + "package test;"+ + "public class TestEvaluationContextCompletion3 {\n"+ + "}"); + + String start = "TestEvaluationContextCompletion3"; + IJavaProject javaProject = getJavaProject("Completion"); + IEvaluationContext context = javaProject.newEvaluationContext(); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false); + context.codeComplete(start, start.length(), requestor, this.wcOwner); + + int startOffset = 0; + int endOffset = start.length(); + + assertResults( + "completion offset="+endOffset+"\n"+ + "completion range=["+startOffset+", "+(endOffset-1)+"]\n"+ + "completion token=\"TestEvaluationContextCompletion3\"\n"+ + "completion token kind=TOKEN_KIND_NAME\n"+ + "expectedTypesSignatures=null\n"+ + "expectedTypesKeys=null", + requestor.getContext()); + + assertResults( + "TestEvaluationContextCompletion3[TYPE_REF]{test.TestEvaluationContextCompletion3, test, Ltest.TestEvaluationContextCompletion3;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123 +public void testEvaluationContextCompletion4() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/TestEvaluationContextCompletion4.java", + "package test;"+ + "public class TestEvaluationContextCompletion4 {\n"+ + "}"); + + String start = "TestEvaluationContextCompletion4"; + IJavaProject javaProject = getJavaProject("Completion"); + IEvaluationContext context = javaProject.newEvaluationContext(); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false); + requestor.setIgnored(CompletionProposal.TYPE_REF, true); + context.codeComplete(start, start.length(), requestor, this.wcOwner); + + int startOffset = 0; + int endOffset = start.length(); + + assertResults( + "completion offset="+endOffset+"\n"+ + "completion range=["+startOffset+", "+(endOffset-1)+"]\n"+ + "completion token=\"TestEvaluationContextCompletion4\"\n"+ + "completion token kind=TOKEN_KIND_NAME\n"+ + "expectedTypesSignatures=null\n"+ + "expectedTypesKeys=null", + requestor.getContext()); + + assertResults( + "", + requestor.getResults()); +} /** * Ensures that completion is not case sensitive