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

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java (-1 / +262 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 38-43 Link Here
38
import org.eclipse.jdt.core.IJavaProject;
38
import org.eclipse.jdt.core.IJavaProject;
39
import org.eclipse.jdt.core.IType;
39
import org.eclipse.jdt.core.IType;
40
import org.eclipse.jdt.core.JavaCore;
40
import org.eclipse.jdt.core.JavaCore;
41
import org.eclipse.jdt.core.JavaModelException;
41
import org.eclipse.jdt.core.tests.util.Util;
42
import org.eclipse.jdt.core.tests.util.Util;
42
import org.eclipse.jdt.internal.codeassist.RelevanceConstants;
43
import org.eclipse.jdt.internal.codeassist.RelevanceConstants;
43
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
44
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
Lines 45-50 Link Here
45
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
46
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
46
47
47
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
48
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
49
	
50
	static {
51
//		TESTS_NAMES = new String[]{"testBug340945"};
52
	}
48
53
49
	public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
54
	public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
50
55
Lines 5591-5594 Link Here
5591
		deleteProject(project);
5596
		deleteProject(project);
5592
	}
5597
	}
5593
}
5598
}
5599
5600
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
5601
public void testBug340945() throws JavaModelException {
5602
	this.workingCopies = new ICompilationUnit[1];
5603
	this.workingCopies[0] = getWorkingCopy(
5604
			"/Completion/src/test/Try.java",
5605
			"package test;\n" +
5606
			"public class Try extends Thread{\n" +
5607
			"	int inty = 1;\n" +
5608
			"	void foo() {\n" +
5609
			"		int i = 1;\n" +
5610
			"		Object o = new Object() {\n" +
5611
			"			void running() {\n" +
5612
			"				int j = 1;\n" +
5613
			"				int k = " +
5614
			"			}\n" +
5615
			"		}\n" +
5616
			"	}\n" +
5617
			"}\n");
5618
5619
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5620
	requestor.setRequireExtendedContext(true);
5621
	requestor.allowAllRequiredProposals();
5622
	requestor.setComputeVisibleElements(true);
5623
//	requestor.setAssignableType("I");
5624
	String str = this.workingCopies[0].getSource();
5625
	String completeBehind = "int k =";
5626
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5627
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5628
	assertResults(
5629
			"<CompleteOnName:>",
5630
			requestor.getCompletionNode());
5631
	assertResults(
5632
			"int k = <CompleteOnName:>;",
5633
			requestor.getCompletionNodeParent());
5634
	assertResults(
5635
			"int j[pos: unused][id:2]\n" +
5636
			"int i[pos: unused][id:0]\n" +
5637
			"java.lang.Object o[pos: unused][id:1]\n",
5638
			requestor.getVisibleLocalVariables());
5639
	assertResults(
5640
			"int inty\n",
5641
			requestor.getVisibleFields());
5642
	assertResults(
5643
			"void running() \n" +
5644
			"public final void wait(long, int) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5645
			"public final void wait(long) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5646
			"public final void wait() throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5647
			"public java.lang.String toString() \n" +
5648
			"public final void notifyAll() throws java.lang.IllegalMonitorStateException\n" +
5649
			"public final void notify() throws java.lang.IllegalMonitorStateException\n" +
5650
			"public int hashCode() \n" +
5651
			"public final java.lang.Class getClass() \n" + 
5652
			"protected void finalize() throws java.lang.Throwable\n" +
5653
			"public boolean equals(java.lang.Object) \n" +
5654
			"protected java.lang.Object clone() throws java.lang.CloneNotSupportedException\n" +
5655
			"void foo() \n",
5656
			requestor.getVisibleMethods());
5657
}
5658
5659
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
5660
public void testBug340945a() throws JavaModelException {
5661
	this.workingCopies = new ICompilationUnit[1];
5662
	this.workingCopies[0] = getWorkingCopy(
5663
			"/Completion/src/test/Try.java",
5664
			"package test;\n" +
5665
			"public class Try extends Thread{\n" +
5666
			"	int int1 = 1;\n" +
5667
			"	int int2 = 2;\n" +
5668
			"	int int3 = " +
5669
			"}\n");
5670
5671
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5672
	requestor.setRequireExtendedContext(true);
5673
	requestor.allowAllRequiredProposals();
5674
	requestor.setComputeVisibleElements(true);
5675
	String str = this.workingCopies[0].getSource();
5676
	String completeBehind = "int int3 =";
5677
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5678
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5679
	assertResults(
5680
			"<CompleteOnName:>",
5681
			requestor.getCompletionNode());
5682
	assertResults(
5683
			"int int3 = <CompleteOnName:>;",
5684
			requestor.getCompletionNodeParent());
5685
	assertResults(
5686
			"",
5687
			requestor.getVisibleLocalVariables());
5688
	assertResults(
5689
			"int int2\n" +
5690
			"int int1\n",
5691
			requestor.getVisibleFields());
5692
	assertResults(
5693
			"public final void wait(long, int) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5694
			"public final void wait(long) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5695
			"public final void wait() throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5696
			"public java.lang.String toString() \n" +
5697
			"public final void notifyAll() throws java.lang.IllegalMonitorStateException\n" +
5698
			"public final void notify() throws java.lang.IllegalMonitorStateException\n" +
5699
			"public int hashCode() \n" +
5700
			"public final java.lang.Class getClass() \n" + 
5701
			"protected void finalize() throws java.lang.Throwable\n" +
5702
			"public boolean equals(java.lang.Object) \n" +
5703
			"protected java.lang.Object clone() throws java.lang.CloneNotSupportedException\n",
5704
			requestor.getVisibleMethods());
5705
}
5706
5707
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
5708
public void testBug340945b() throws JavaModelException {
5709
	this.workingCopies = new ICompilationUnit[1];
5710
	this.workingCopies[0] = getWorkingCopy(
5711
			"/Completion/src/test/Try.java",
5712
			"package test;\n" +
5713
			"public class Try extends Thread{\n" +
5714
			"Object field;\n" +
5715
			"void foo() {\n" +
5716
			"	int int1 = 1;\n" +
5717
			"	int int2 = 2;\n" +
5718
			"	int int3 = " +
5719
			"}\n" +
5720
			"}\n");
5721
5722
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5723
	requestor.setRequireExtendedContext(true);
5724
	requestor.allowAllRequiredProposals();
5725
	requestor.setComputeVisibleElements(true);
5726
	String str = this.workingCopies[0].getSource();
5727
	String completeBehind = "int int3 =";
5728
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5729
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5730
	assertResults(
5731
			"<CompleteOnName:>",
5732
			requestor.getCompletionNode());
5733
	assertResults(
5734
			"int int3 = <CompleteOnName:>;",
5735
			requestor.getCompletionNodeParent());
5736
	assertResults(
5737
			"int int1[pos: unused][id:0]\n" +
5738
			"int int2[pos: unused][id:1]\n",
5739
			requestor.getVisibleLocalVariables());
5740
	assertResults(
5741
			"java.lang.Object field\n",
5742
			requestor.getVisibleFields());
5743
	assertResults(
5744
			"void foo() \n" +
5745
			"public final void wait(long, int) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5746
			"public final void wait(long) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5747
			"public final void wait() throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5748
			"public java.lang.String toString() \n" +
5749
			"public final void notifyAll() throws java.lang.IllegalMonitorStateException\n" +
5750
			"public final void notify() throws java.lang.IllegalMonitorStateException\n" +
5751
			"public int hashCode() \n" +
5752
			"public final java.lang.Class getClass() \n" + 
5753
			"protected void finalize() throws java.lang.Throwable\n" +
5754
			"public boolean equals(java.lang.Object) \n" +
5755
			"protected java.lang.Object clone() throws java.lang.CloneNotSupportedException\n",			
5756
			requestor.getVisibleMethods());
5757
}
5758
5759
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
5760
public void testBug340945c() throws JavaModelException {
5761
	this.workingCopies = new ICompilationUnit[1];
5762
	this.workingCopies[0] = getWorkingCopy(
5763
			"/Completion/src/test/Try.java",
5764
			"package test;\n" +
5765
			"public class Try extends Thread{\n" +
5766
			"Object field;\n" +
5767
			"void foo() {\n" +
5768
			"	int int1 = 1;\n" +
5769
			"	int int2 = 2;\n" +
5770
			"	Object o1 = new Object();\n" +
5771
			"   o1." +
5772
			"}\n" +
5773
			"}\n");
5774
5775
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5776
	requestor.setRequireExtendedContext(true);
5777
	requestor.allowAllRequiredProposals();
5778
	requestor.setComputeVisibleElements(true);
5779
	String str = this.workingCopies[0].getSource();
5780
	String completeBehind = "o1.";
5781
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5782
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5783
	assertResults(
5784
			"<CompleteOnName:o1.>",
5785
			requestor.getCompletionNode());
5786
	assertNull(
5787
			"should be null",
5788
			requestor.getCompletionNodeParent());
5789
	assertResults(
5790
			"int int1[pos: unused][id:0]\n" +
5791
			"int int2[pos: unused][id:1]\n" +
5792
			"java.lang.Object o1[pos: unused][id:2]\n",
5793
			requestor.getVisibleLocalVariables());
5794
	assertResults(
5795
			"java.lang.Object field\n",
5796
			requestor.getVisibleFields());
5797
	assertResults(
5798
			"void foo() \n" +
5799
			"public final void wait(long, int) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5800
			"public final void wait(long) throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5801
			"public final void wait() throws java.lang.IllegalMonitorStateException, java.lang.InterruptedException\n" +
5802
			"public java.lang.String toString() \n" +
5803
			"public final void notifyAll() throws java.lang.IllegalMonitorStateException\n" +
5804
			"public final void notify() throws java.lang.IllegalMonitorStateException\n" +
5805
			"public int hashCode() \n" +
5806
			"public final java.lang.Class getClass() \n" + 
5807
			"protected void finalize() throws java.lang.Throwable\n" +
5808
			"public boolean equals(java.lang.Object) \n" +
5809
			"protected java.lang.Object clone() throws java.lang.CloneNotSupportedException\n",			
5810
			requestor.getVisibleMethods());
5811
}
5812
5813
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
5814
public void testBug340945d() throws JavaModelException {
5815
	this.workingCopies = new ICompilationUnit[1];
5816
	this.workingCopies[0] = getWorkingCopy(
5817
			"/Completion/src/test/Try.java",
5818
			"package test;\n" +
5819
			"public class Try extends Thread{\n" +
5820
			"Object field;\n" +
5821
			"static void foo() {\n" +	// field should not be visible here
5822
			"	int int1 = 1;\n" +
5823
			"	int int2 = 2;\n" +
5824
			"	Object o1 = new Object();\n" +
5825
			"   o1." +
5826
			"}\n" +
5827
			"}\n");
5828
5829
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5830
	requestor.setRequireExtendedContext(true);
5831
	requestor.allowAllRequiredProposals();
5832
	requestor.setComputeVisibleElements(true);
5833
	String str = this.workingCopies[0].getSource();
5834
	String completeBehind = "o1.";
5835
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5836
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5837
	assertResults(
5838
			"<CompleteOnName:o1.>",
5839
			requestor.getCompletionNode());
5840
	assertNull(
5841
			"should be null",
5842
			requestor.getCompletionNodeParent());
5843
	assertResults(
5844
			"int int1[pos: unused][id:0]\n" +
5845
			"int int2[pos: unused][id:1]\n" +
5846
			"java.lang.Object o1[pos: unused][id:2]\n",
5847
			requestor.getVisibleLocalVariables());
5848
	assertResults(
5849
			"",
5850
			requestor.getVisibleFields());
5851
	assertResults(
5852
			"static void foo() \n",			
5853
			requestor.getVisibleMethods());
5854
}
5594
}
5855
}
(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java (+53 lines)
Lines 20-25 Link Here
20
import org.eclipse.jdt.core.IJavaElement;
20
import org.eclipse.jdt.core.IJavaElement;
21
import org.eclipse.jdt.core.Signature;
21
import org.eclipse.jdt.core.Signature;
22
import org.eclipse.jdt.core.compiler.IProblem;
22
import org.eclipse.jdt.core.compiler.IProblem;
23
import org.eclipse.jdt.internal.codeassist.InternalCompletionContext;
24
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
25
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
23
import org.eclipse.jdt.internal.core.JavaElement;
26
import org.eclipse.jdt.internal.core.JavaElement;
24
27
25
public class CompletionTestsRequestor2 extends CompletionRequestor {
28
public class CompletionTestsRequestor2 extends CompletionRequestor {
Lines 605-608 Link Here
605
		}
608
		}
606
		return false;
609
		return false;
607
	}
610
	}
611
	
612
	public String getCompletionNode() {
613
		if (this.context instanceof InternalCompletionContext) {
614
			InternalCompletionContext internalCompletionContext = (InternalCompletionContext) this.context;
615
			ASTNode astNode = internalCompletionContext.getCompletionNode();
616
			if (astNode != null) return astNode.toString();
617
			
618
		}
619
		return null;
620
	}
621
	
622
	public String getCompletionNodeParent() {
623
		if (this.context instanceof InternalCompletionContext) {
624
			InternalCompletionContext internalCompletionContext = (InternalCompletionContext) this.context;
625
			ASTNode astNode = internalCompletionContext.getCompletionNodeParent();
626
			if (astNode != null) return astNode.toString();
627
			
628
		}
629
		return null;
630
	}
631
	
632
	public String getVisibleLocalVariables() {
633
		if (this.context instanceof InternalCompletionContext) {
634
			InternalCompletionContext internalCompletionContext = (InternalCompletionContext) this.context;
635
			ObjectVector locals = internalCompletionContext.getVisibleLocalVariables();
636
			if (locals != null) return locals.toString();
637
			
638
		}
639
		return null;
640
	}
641
	
642
	public String getVisibleFields() {
643
		if (this.context instanceof InternalCompletionContext) {
644
			InternalCompletionContext internalCompletionContext = (InternalCompletionContext) this.context;
645
			ObjectVector fields = internalCompletionContext.getVisibleFields();
646
			if (fields != null) return fields.toString();
647
			
648
		}
649
		return null;
650
	}
651
	
652
	public String getVisibleMethods() {
653
		if (this.context instanceof InternalCompletionContext) {
654
			InternalCompletionContext internalCompletionContext = (InternalCompletionContext) this.context;
655
			ObjectVector methods = internalCompletionContext.getVisibleMethods();
656
			if (methods != null) return methods.toString();
657
			
658
		}
659
		return null;
660
	}
608
}
661
}
(-)a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (+1 lines)
Lines 1502-1507 Link Here
1502
					this.lookupEnvironment,
1502
					this.lookupEnvironment,
1503
					scope,
1503
					scope,
1504
					astNode,
1504
					astNode,
1505
					astNodeParent,
1505
					this.owner,
1506
					this.owner,
1506
					this.parser);
1507
					this.parser);
1507
		}
1508
		}
(-)a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionContext.java (-1 / +90 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-31 Link Here
24
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
24
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
25
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
25
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
26
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
26
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
27
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
29
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
30
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.Scope;
31
import org.eclipse.jdt.internal.compiler.lookup.Scope;
32
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
29
33
30
34
31
/**
35
/**
Lines 65-70 Link Here
65
			LookupEnvironment lookupEnvironment,
69
			LookupEnvironment lookupEnvironment,
66
			Scope scope,
70
			Scope scope,
67
			ASTNode astNode,
71
			ASTNode astNode,
72
			ASTNode astNodeParent,
68
			WorkingCopyOwner owner,
73
			WorkingCopyOwner owner,
69
			CompletionParser parser) {
74
			CompletionParser parser) {
70
		this.isExtended = true;
75
		this.isExtended = true;
Lines 76-81 Link Here
76
					lookupEnvironment,
81
					lookupEnvironment,
77
					scope,
82
					scope,
78
					astNode,
83
					astNode,
84
					astNodeParent,
79
					owner,
85
					owner,
80
					parser);
86
					parser);
81
	}
87
	}
Lines 368-371 Link Here
368
	public boolean isInJavadocText() {
374
	public boolean isInJavadocText() {
369
		return (this.javadoc & CompletionOnJavadoc.TEXT) != 0;
375
		return (this.javadoc & CompletionOnJavadoc.TEXT) != 0;
370
	}
376
	}
377
	
378
	/**
379
	 * Return the completion node associated with the current completion.
380
	 *
381
	 * @return completion AST node, or null if the extendedContext is null.
382
	 * @exception UnsupportedOperationException if the context is not an extended context
383
	 *
384
	 * @see #isExtended()
385
	 */
386
	public ASTNode getCompletionNode() {
387
		if (!this.isExtended) throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
388
	
389
		if (this.extendedContext == null) return null;
390
	
391
		return this.extendedContext.getCompletionNode();
392
	}
393
	
394
	/**
395
	 * Return the parent AST node of the completion node associated with the current completion.
396
	 *
397
	 * @return completion parent AST node, or null if the extendedContext is null.
398
	 * @exception UnsupportedOperationException if the context is not an extended context
399
	 *
400
	 * @see #isExtended()
401
	 */
402
	public ASTNode getCompletionNodeParent() {
403
		if (!this.isExtended) throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
404
	
405
		if (this.extendedContext == null) return null;
406
	
407
		return this.extendedContext.getCompletionNodeParent();
408
	}
409
	
410
	/**
411
	 * Return the bindings of all visible local variables in the current completion context.
412
	 *
413
	 * @return bindings of all visible local variables, or null if the extendedContext is null. Returned bindings are instances of
414
	 * {@link LocalVariableBinding}
415
	 * @exception UnsupportedOperationException if the context is not an extended context
416
	 *
417
	 * @see #isExtended()
418
	 */
419
	public ObjectVector getVisibleLocalVariables() {
420
		if (!this.isExtended) throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
421
	
422
		if (this.extendedContext == null) return null;
423
	
424
		return this.extendedContext.getVisibleLocalVariables();
425
	}
426
	
427
	/**
428
	 * Return the bindings of all visible fields in the current completion context.
429
	 *
430
	 * @return bindings of all visible fields, or null if the extendedContext is null. Returned bindings are instances of
431
	 * {@link FieldBinding}
432
	 * @exception UnsupportedOperationException if the context is not an extended context
433
	 *
434
	 * @see #isExtended()
435
	 */
436
	public ObjectVector getVisibleFields() {
437
		if (!this.isExtended) throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
438
	
439
		if (this.extendedContext == null) return null;
440
	
441
		return this.extendedContext.getVisibleFields();
442
	}
443
	
444
	/**
445
	 * Return the bindings of all visible methods in the current completion context.
446
	 *
447
	 * @return bindings of all visible methods, or null if the extendedContext is null. Returned bindings are instances of
448
	 * {@link MethodBinding}
449
	 * @exception UnsupportedOperationException if the context is not an extended context
450
	 *
451
	 * @see #isExtended()
452
	 */
453
	public ObjectVector getVisibleMethods() {
454
		if (!this.isExtended) throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
455
	
456
		if (this.extendedContext == null) return null;
457
	
458
		return this.extendedContext.getVisibleMethods();
459
	}
371
}
460
}
(-)a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java (+39 lines)
Lines 76-81 Link Here
76
	private LookupEnvironment lookupEnvironment;
76
	private LookupEnvironment lookupEnvironment;
77
	private Scope assistScope;
77
	private Scope assistScope;
78
	private ASTNode assistNode;
78
	private ASTNode assistNode;
79
	private ASTNode assistNodeParent;
79
	private WorkingCopyOwner owner;
80
	private WorkingCopyOwner owner;
80
81
81
	private CompletionParser parser;
82
	private CompletionParser parser;
Lines 98-103 Link Here
98
			LookupEnvironment lookupEnvironment,
99
			LookupEnvironment lookupEnvironment,
99
			Scope assistScope,
100
			Scope assistScope,
100
			ASTNode assistNode,
101
			ASTNode assistNode,
102
			ASTNode assistNodeParent,
101
			WorkingCopyOwner owner,
103
			WorkingCopyOwner owner,
102
			CompletionParser parser) {
104
			CompletionParser parser) {
103
		this.completionContext = completionContext;
105
		this.completionContext = completionContext;
Lines 106-111 Link Here
106
		this.lookupEnvironment = lookupEnvironment;
108
		this.lookupEnvironment = lookupEnvironment;
107
		this.assistScope = assistScope;
109
		this.assistScope = assistScope;
108
		this.assistNode = assistNode;
110
		this.assistNode = assistNode;
111
		this.assistNodeParent = assistNodeParent;
109
		this.owner = owner;
112
		this.owner = owner;
110
		this.parser = parser;
113
		this.parser = parser;
111
	}
114
	}
Lines 929-932 Link Here
929
		}
932
		}
930
		return false;
933
		return false;
931
	}
934
	}
935
	
936
	/**
937
	 * @see InternalCompletionContext#getCompletionNode()
938
	 */
939
	public ASTNode getCompletionNode() {
940
		return this.assistNode;
941
	}
942
	
943
	/**
944
	 * @see InternalCompletionContext#getCompletionNodeParent()
945
	 */
946
	public ASTNode getCompletionNodeParent() {
947
		// TODO Auto-generated method stub
948
		return this.assistNodeParent;
949
	}
950
	
951
	public ObjectVector getVisibleLocalVariables() {
952
		if (!this.hasComputedVisibleElementBindings) {
953
			computeVisibleElementBindings();
954
		}
955
		return this.visibleLocalVariables;
956
	}
957
	
958
	public ObjectVector getVisibleFields() {
959
		if (!this.hasComputedVisibleElementBindings) {
960
			computeVisibleElementBindings();
961
		}
962
		return this.visibleFields;
963
	}
964
	
965
	public ObjectVector getVisibleMethods() {
966
		if (!this.hasComputedVisibleElementBindings) {
967
			computeVisibleElementBindings();
968
		}
969
		return this.visibleMethods;
970
	}
932
}
971
}

Return to bug 340945