View | Details | Raw Unified | Return to bug 140123
Collapse All | Expand All

(-)model/org/eclipse/jdt/core/CompletionRequestor.java (-2 / +2 lines)
Lines 80-86 Link Here
80
	 * @see #setIgnored(int, boolean)
80
	 * @see #setIgnored(int, boolean)
81
	 * @see CompletionProposal#getKind()
81
	 * @see CompletionProposal#getKind()
82
	 */
82
	 */
83
	public final boolean isIgnored(int completionProposalKind) {
83
	public boolean isIgnored(int completionProposalKind) {
84
		if (completionProposalKind < CompletionProposal.FIRST_KIND
84
		if (completionProposalKind < CompletionProposal.FIRST_KIND
85
			|| completionProposalKind > CompletionProposal.LAST_KIND) {
85
			|| completionProposalKind > CompletionProposal.LAST_KIND) {
86
				throw new IllegalArgumentException("Unknown kind of completion proposal: "+completionProposalKind); //$NON-NLS-1$
86
				throw new IllegalArgumentException("Unknown kind of completion proposal: "+completionProposalKind); //$NON-NLS-1$
Lines 99-105 Link Here
99
	 * @see #isIgnored(int)
99
	 * @see #isIgnored(int)
100
	 * @see CompletionProposal#getKind()
100
	 * @see CompletionProposal#getKind()
101
	 */
101
	 */
102
	public final void setIgnored(int completionProposalKind, boolean ignore) {
102
	public void setIgnored(int completionProposalKind, boolean ignore) {
103
		if (completionProposalKind < CompletionProposal.FIRST_KIND
103
		if (completionProposalKind < CompletionProposal.FIRST_KIND
104
			|| completionProposalKind > CompletionProposal.LAST_KIND) {
104
			|| completionProposalKind > CompletionProposal.LAST_KIND) {
105
				throw new IllegalArgumentException("Unknown kind of completion proposal: "+completionProposalKind); //$NON-NLS-1$
105
				throw new IllegalArgumentException("Unknown kind of completion proposal: "+completionProposalKind); //$NON-NLS-1$
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java (+16 lines)
Lines 190-195 Link Here
190
		public void acceptContext(CompletionContext context) {
190
		public void acceptContext(CompletionContext context) {
191
			originalRequestor.acceptContext(context);
191
			originalRequestor.acceptContext(context);
192
		}
192
		}
193
		
194
		public void beginReporting() {
195
			originalRequestor.beginReporting();
196
		}
197
		
198
		public void endReporting() {
199
			originalRequestor.endReporting();
200
		}
201
		
202
		public boolean isIgnored(int completionProposalKind) {
203
			return originalRequestor.isIgnored(completionProposalKind);
204
		}
205
		
206
		public void setIgnored(int completionProposalKind, boolean ignore) {
207
			originalRequestor.setIgnored(completionProposalKind, ignore);
208
		}
193
	};
209
	};
194
}
210
}
195
public char[] getCUSource(String lineSeparator) {
211
public char[] getCUSource(String lineSeparator) {
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+101 lines)
Lines 821-826 Link Here
821
	
821
	
822
	assertTrue("acceptContext() method isn't call", rc.acceptContext);
822
	assertTrue("acceptContext() method isn't call", rc.acceptContext);
823
}
823
}
824
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
825
public void testEvaluationContextCompletion2() throws JavaModelException {
826
	class EvaluationContextCompletionRequestor extends CompletionRequestor {
827
		public boolean acceptContext;
828
		public boolean beginReporting;
829
		public boolean endReporting;
830
		
831
		public void acceptContext(CompletionContext context) {
832
			this.acceptContext = context != null;
833
		}
834
		public void accept(CompletionProposal proposal) {
835
			// Do nothing
836
		}
837
		
838
		public void beginReporting() {
839
			this.beginReporting = true;
840
			super.beginReporting();
841
		}
842
		
843
		public void endReporting() {
844
			this.endReporting =  true;
845
			super.endReporting();
846
		}
847
	}
848
	String start = "";
849
	IJavaProject javaProject = getJavaProject("Completion");
850
	IEvaluationContext context = javaProject.newEvaluationContext();
851
    EvaluationContextCompletionRequestor rc = new EvaluationContextCompletionRequestor();
852
	context.codeComplete(start, start.length(), rc);
853
	
854
	assertTrue("acceptContext() method isn't call", rc.acceptContext);
855
	assertTrue("beginReporting() method isn't call", rc.beginReporting);
856
	assertTrue("endReporting() method isn't call", rc.endReporting);
857
}
858
859
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
860
public void testEvaluationContextCompletion3() throws JavaModelException {
861
	this.workingCopies = new ICompilationUnit[1];
862
	this.workingCopies[0] = getWorkingCopy(
863
		"/Completion/src/test/TestEvaluationContextCompletion3.java",
864
		"package test;"+
865
		"public class TestEvaluationContextCompletion3 {\n"+
866
		"}");
867
	
868
	String start = "TestEvaluationContextCompletion3";
869
	IJavaProject javaProject = getJavaProject("Completion");
870
	IEvaluationContext context = javaProject.newEvaluationContext();
871
	
872
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
873
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
874
	
875
	int startOffset = 0;
876
	int endOffset = start.length();
877
	
878
	assertResults(
879
			"completion offset="+endOffset+"\n"+
880
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
881
			"completion token=\"TestEvaluationContextCompletion3\"\n"+
882
			"completion token kind=TOKEN_KIND_NAME\n"+
883
			"expectedTypesSignatures=null\n"+
884
			"expectedTypesKeys=null",
885
            requestor.getContext());
886
    
887
	assertResults(
888
			"TestEvaluationContextCompletion3[TYPE_REF]{test.TestEvaluationContextCompletion3, test, Ltest.TestEvaluationContextCompletion3;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
889
			requestor.getResults());
890
}
891
892
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
893
public void testEvaluationContextCompletion4() throws JavaModelException {
894
	this.workingCopies = new ICompilationUnit[1];
895
	this.workingCopies[0] = getWorkingCopy(
896
		"/Completion/src/test/TestEvaluationContextCompletion4.java",
897
		"package test;"+
898
		"public class TestEvaluationContextCompletion4 {\n"+
899
		"}");
900
	
901
	String start = "TestEvaluationContextCompletion4";
902
	IJavaProject javaProject = getJavaProject("Completion");
903
	IEvaluationContext context = javaProject.newEvaluationContext();
904
	
905
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
906
	requestor.setIgnored(CompletionProposal.TYPE_REF, true);
907
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
908
	
909
	int startOffset = 0;
910
	int endOffset = start.length();
911
	
912
	assertResults(
913
			"completion offset="+endOffset+"\n"+
914
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
915
			"completion token=\"TestEvaluationContextCompletion4\"\n"+
916
			"completion token kind=TOKEN_KIND_NAME\n"+
917
			"expectedTypesSignatures=null\n"+
918
			"expectedTypesKeys=null",
919
            requestor.getContext());
920
    
921
	assertResults(
922
			"",
923
			requestor.getResults());
924
}
824
925
825
/**
926
/**
826
 * Ensures that completion is not case sensitive
927
 * Ensures that completion is not case sensitive

Return to bug 140123