View | Details | Raw Unified | Return to bug 99399 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java (-20 / +24 lines)
Lines 39-45 Link Here
39
	String completeBehind = "Z<Y>.";
39
	String completeBehind = "Z<Y>.";
40
	int cursorLocation = str.indexOf("Z<Y>.") + completeBehind.length() - 1;
40
	int cursorLocation = str.indexOf("Z<Y>.") + completeBehind.length() - 1;
41
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.>";
41
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.>";
42
	String expectedParentNodeToString = "<NONE>";
42
	String expectedParentNodeToString = "T extends <CompleteOnType:Z<Y>.>";
43
	String completionIdentifier = "";
43
	String completionIdentifier = "";
44
	String expectedReplacedSource = "Z<Y>.";
44
	String expectedReplacedSource = "Z<Y>.";
45
	String expectedUnitDisplayString =
45
	String expectedUnitDisplayString =
Lines 67-73 Link Here
67
	String completeBehind = "Z<Y>.W";
67
	String completeBehind = "Z<Y>.W";
68
	int cursorLocation = str.indexOf("Z<Y>.W") + completeBehind.length() - 1;
68
	int cursorLocation = str.indexOf("Z<Y>.W") + completeBehind.length() - 1;
69
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.W>";
69
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.W>";
70
	String expectedParentNodeToString = "<NONE>";
70
	String expectedParentNodeToString = "T extends <CompleteOnType:Z<Y>.W>";
71
	String completionIdentifier = "W";
71
	String completionIdentifier = "W";
72
	String expectedReplacedSource = "Z<Y>.W";
72
	String expectedReplacedSource = "Z<Y>.W";
73
	String expectedUnitDisplayString =
73
	String expectedUnitDisplayString =
Lines 95-101 Link Here
95
	String completeBehind = "X<Y>.Z";
95
	String completeBehind = "X<Y>.Z";
96
	int cursorLocation = str.indexOf("X<Y>.Z") + completeBehind.length() - 1;
96
	int cursorLocation = str.indexOf("X<Y>.Z") + completeBehind.length() - 1;
97
	String expectedCompletionNodeToString = "<CompleteOnType:test0001.X<Y>.Z>";
97
	String expectedCompletionNodeToString = "<CompleteOnType:test0001.X<Y>.Z>";
98
	String expectedParentNodeToString = "<NONE>";
98
	String expectedParentNodeToString = "T extends <CompleteOnType:test0001.X<Y>.Z>";
99
	String completionIdentifier = "Z";
99
	String completionIdentifier = "Z";
100
	String expectedReplacedSource = "test0001.X<Y>.Z";
100
	String expectedReplacedSource = "test0001.X<Y>.Z";
101
	String expectedUnitDisplayString =
101
	String expectedUnitDisplayString =
Lines 428-434 Link Here
428
	String completeBehind = "Y<Z>.";
428
	String completeBehind = "Y<Z>.";
429
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
429
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
430
	String expectedCompletionNodeToString = "<CompleteOnClass:Y<Z>.>";
430
	String expectedCompletionNodeToString = "<CompleteOnClass:Y<Z>.>";
431
	String expectedParentNodeToString = "<NONE>";
431
	String expectedParentNodeToString = 
432
		"public class X extends <CompleteOnClass:Y<Z>.> {\n" + 
433
		"  public X() {\n" + 
434
		"  }\n" + 
435
		"}";
432
	String completionIdentifier = "";
436
	String completionIdentifier = "";
433
	String expectedReplacedSource = "Y<Z>.";
437
	String expectedReplacedSource = "Y<Z>.";
434
	String expectedUnitDisplayString =
438
	String expectedUnitDisplayString =
Lines 623-629 Link Here
623
	String completeBehind = "Y<Z>.";
627
	String completeBehind = "Y<Z>.";
624
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
628
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
625
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
629
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
626
	String expectedParentNodeToString = "<NONE>";
630
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
627
	String completionIdentifier = "";
631
	String completionIdentifier = "";
628
	String expectedReplacedSource = "Y<Z>.";
632
	String expectedReplacedSource = "Y<Z>.";
629
	String expectedUnitDisplayString =
633
	String expectedUnitDisplayString =
Lines 654-660 Link Here
654
	String completeBehind = "Y<Z>.";
658
	String completeBehind = "Y<Z>.";
655
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
659
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
656
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
660
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
657
	String expectedParentNodeToString = "<NONE>";
661
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
658
	String completionIdentifier = "";
662
	String completionIdentifier = "";
659
	String expectedReplacedSource = "Y<Z>.";
663
	String expectedReplacedSource = "Y<Z>.";
660
	String expectedUnitDisplayString =
664
	String expectedUnitDisplayString =
Lines 685-691 Link Here
685
	String completeBehind = "Y<Z>.";
689
	String completeBehind = "Y<Z>.";
686
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
690
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
687
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
691
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
688
	String expectedParentNodeToString = "<NONE>";
692
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
689
	String completionIdentifier = "";
693
	String completionIdentifier = "";
690
	String expectedReplacedSource = "Y<Z>.";
694
	String expectedReplacedSource = "Y<Z>.";
691
	String expectedUnitDisplayString =
695
	String expectedUnitDisplayString =
Lines 715-721 Link Here
715
	String completeBehind = "Y<Z>.";
719
	String completeBehind = "Y<Z>.";
716
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
720
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
717
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
721
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
718
	String expectedParentNodeToString = "<NONE>";
722
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
719
	String completionIdentifier = "";
723
	String completionIdentifier = "";
720
	String expectedReplacedSource = "Y<Z>.";
724
	String expectedReplacedSource = "Y<Z>.";
721
	String expectedUnitDisplayString =
725
	String expectedUnitDisplayString =
Lines 745-751 Link Here
745
	String completeBehind = "Y<Z>.";
749
	String completeBehind = "Y<Z>.";
746
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
750
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
747
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
751
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
748
	String expectedParentNodeToString = "<NONE>";
752
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
749
	String completionIdentifier = "";
753
	String completionIdentifier = "";
750
	String expectedReplacedSource = "Y<Z>.";
754
	String expectedReplacedSource = "Y<Z>.";
751
	String expectedUnitDisplayString =
755
	String expectedUnitDisplayString =
Lines 777-783 Link Here
777
	String completeBehind = "Y<Z>.";
781
	String completeBehind = "Y<Z>.";
778
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
782
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
779
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
783
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
780
	String expectedParentNodeToString = "<NONE>";
784
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
781
	String completionIdentifier = "";
785
	String completionIdentifier = "";
782
	String expectedReplacedSource = "Y<Z>.";
786
	String expectedReplacedSource = "Y<Z>.";
783
	String expectedUnitDisplayString =
787
	String expectedUnitDisplayString =
Lines 809-815 Link Here
809
	String completeBehind = "Y<Z>.";
813
	String completeBehind = "Y<Z>.";
810
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
814
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
811
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
815
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
812
	String expectedParentNodeToString = "<NONE>";
816
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
813
	String completionIdentifier = "";
817
	String completionIdentifier = "";
814
	String expectedReplacedSource = "Y<Z>.";
818
	String expectedReplacedSource = "Y<Z>.";
815
	String expectedUnitDisplayString =
819
	String expectedUnitDisplayString =
Lines 841-847 Link Here
841
	String completeBehind = "Y<Z>.";
845
	String completeBehind = "Y<Z>.";
842
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
846
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
843
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
847
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
844
	String expectedParentNodeToString = "<NONE>";
848
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
845
	String completionIdentifier = "";
849
	String completionIdentifier = "";
846
	String expectedReplacedSource = "Y<Z>.";
850
	String expectedReplacedSource = "Y<Z>.";
847
	String expectedUnitDisplayString =
851
	String expectedUnitDisplayString =
Lines 872-878 Link Here
872
	String completeBehind = "Y<Z>.";
876
	String completeBehind = "Y<Z>.";
873
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
877
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
874
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
878
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
875
	String expectedParentNodeToString = "<NONE>";
879
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
876
	String completionIdentifier = "";
880
	String completionIdentifier = "";
877
	String expectedReplacedSource = "Y<Z>.";
881
	String expectedReplacedSource = "Y<Z>.";
878
	String expectedUnitDisplayString =
882
	String expectedUnitDisplayString =
Lines 902-908 Link Here
902
	String completeBehind = "Y<Z>.";
906
	String completeBehind = "Y<Z>.";
903
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
907
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
904
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
908
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
905
	String expectedParentNodeToString = "<NONE>";
909
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
906
	String completionIdentifier = "";
910
	String completionIdentifier = "";
907
	String expectedReplacedSource = "Y<Z>.";
911
	String expectedReplacedSource = "Y<Z>.";
908
	String expectedUnitDisplayString =
912
	String expectedUnitDisplayString =
Lines 7792-7798 Link Here
7792
	String completeBehind = "Z";
7796
	String completeBehind = "Z";
7793
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7797
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7794
	String expectedCompletionNodeToString = "<CompleteOnType:Z>";
7798
	String expectedCompletionNodeToString = "<CompleteOnType:Z>";
7795
	String expectedParentNodeToString = "<NONE>";
7799
	String expectedParentNodeToString = "T extends <CompleteOnType:Z>";
7796
	String completionIdentifier = "Z";
7800
	String completionIdentifier = "Z";
7797
	String expectedReplacedSource = "Z";
7801
	String expectedReplacedSource = "Z";
7798
	String expectedUnitDisplayString =
7802
	String expectedUnitDisplayString =
Lines 7820-7826 Link Here
7820
	String completeBehind = "Z";
7824
	String completeBehind = "Z";
7821
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7825
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7822
	String expectedCompletionNodeToString = "<CompleteOnType:X.Z>";
7826
	String expectedCompletionNodeToString = "<CompleteOnType:X.Z>";
7823
	String expectedParentNodeToString = "<NONE>";
7827
	String expectedParentNodeToString = "T extends <CompleteOnType:X.Z>";
7824
	String completionIdentifier = "Z";
7828
	String completionIdentifier = "Z";
7825
	String expectedReplacedSource = "X.Z";
7829
	String expectedReplacedSource = "X.Z";
7826
	String expectedUnitDisplayString =
7830
	String expectedUnitDisplayString =
Lines 7848-7854 Link Here
7848
	String completeBehind = "Z";
7852
	String completeBehind = "Z";
7849
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7853
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7850
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7854
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7851
	String expectedParentNodeToString = "<NONE>";
7855
	String expectedParentNodeToString = "T extends <CompleteOnType:X<W>.Z>";
7852
	String completionIdentifier = "Z";
7856
	String completionIdentifier = "Z";
7853
	String expectedReplacedSource = "X<W>.Z";
7857
	String expectedReplacedSource = "X<W>.Z";
7854
	String expectedUnitDisplayString =
7858
	String expectedUnitDisplayString =
Lines 7877-7883 Link Here
7877
	String completeBehind = "Z";
7881
	String completeBehind = "Z";
7878
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7882
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7879
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7883
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7880
	String expectedParentNodeToString = "<NONE>";
7884
	String expectedParentNodeToString = "T extends <CompleteOnType:X<W>.Z>";
7881
	String completionIdentifier = "Z";
7885
	String completionIdentifier = "Z";
7882
	String expectedReplacedSource = "X<W>.Z";
7886
	String expectedReplacedSource = "X<W>.Z";
7883
	String expectedUnitDisplayString =
7887
	String expectedUnitDisplayString =
Lines 9057-9063 Link Here
9057
	String completeBehind = "Strin";
9061
	String completeBehind = "Strin";
9058
	int cursorLocation = str.indexOf("Strin") + completeBehind.length() - 1;
9062
	int cursorLocation = str.indexOf("Strin") + completeBehind.length() - 1;
9059
	String expectedCompletionNodeToString = "<CompleteOnType:Strin>";
9063
	String expectedCompletionNodeToString = "<CompleteOnType:Strin>";
9060
	String expectedParentNodeToString = "<NONE>";
9064
	String expectedParentNodeToString = "? extends <CompleteOnType:Strin>";
9061
	String completionIdentifier = "Strin";
9065
	String completionIdentifier = "Strin";
9062
	String expectedReplacedSource = "String";
9066
	String expectedReplacedSource = "String";
9063
	String expectedUnitDisplayString =
9067
	String expectedUnitDisplayString =
Lines 10682-10688 Link Here
10682
	String completeBehind = "Obj";
10686
	String completeBehind = "Obj";
10683
	int cursorLocation = str.indexOf("Obj") + completeBehind.length() - 1;
10687
	int cursorLocation = str.indexOf("Obj") + completeBehind.length() - 1;
10684
	String expectedCompletionNodeToString = "<CompleteOnType:Obj>";
10688
	String expectedCompletionNodeToString = "<CompleteOnType:Obj>";
10685
	String expectedParentNodeToString = "<NONE>";
10689
	String expectedParentNodeToString = "? extends <CompleteOnType:Obj>";
10686
	String completionIdentifier = "Obj";
10690
	String completionIdentifier = "Obj";
10687
	String expectedReplacedSource = "Obj";
10691
	String expectedReplacedSource = "Obj";
10688
	String expectedUnitDisplayString =
10692
	String expectedUnitDisplayString =
(-)src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java (-1 / +7 lines)
Lines 9327-9333 Link Here
9327
	String completeBehind = "Z.";
9327
	String completeBehind = "Z.";
9328
	int cursorLocation = str.indexOf("Z.") + completeBehind.length() - 1;
9328
	int cursorLocation = str.indexOf("Z.") + completeBehind.length() - 1;
9329
	String expectedCompletionNodeToString = "<CompleteOnClass:Z.>";
9329
	String expectedCompletionNodeToString = "<CompleteOnClass:Z.>";
9330
	String expectedParentNodeToString = "<NONE>";
9330
	String expectedParentNodeToString = 
9331
		"public class X extends <CompleteOnClass:Z.> {\n" + 
9332
		"  {\n" + 
9333
		"  }\n" + 
9334
		"  public X() {\n" + 
9335
		"  }\n" + 
9336
		"}";
9331
	String completionIdentifier = "";
9337
	String completionIdentifier = "";
9332
	String expectedReplacedSource = "Z.";
9338
	String expectedReplacedSource = "Z.";
9333
	String expectedUnitDisplayString =
9339
	String expectedUnitDisplayString =
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (+45 lines)
Lines 2076-2081 Link Here
2076
protected void consumeClassHeaderExtends() {
2076
protected void consumeClassHeaderExtends() {
2077
	pushOnElementStack(K_NEXT_TYPEREF_IS_CLASS);
2077
	pushOnElementStack(K_NEXT_TYPEREF_IS_CLASS);
2078
	super.consumeClassHeaderExtends();
2078
	super.consumeClassHeaderExtends();
2079
	if (this.assistNode != null && this.assistNodeParent == null) {
2080
		TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2081
		if (typeDecl != null && typeDecl.superclass == this.assistNode)
2082
			this.assistNodeParent = typeDecl;
2083
	}
2079
	popElement(K_NEXT_TYPEREF_IS_CLASS);
2084
	popElement(K_NEXT_TYPEREF_IS_CLASS);
2080
	popElement(K_EXTENDS_KEYWORD);
2085
	popElement(K_EXTENDS_KEYWORD);
2081
2086
Lines 3752-3769 Link Here
3752
}
3757
}
3753
protected void consumeTypeParameterWithExtends() {
3758
protected void consumeTypeParameterWithExtends() {
3754
	super.consumeTypeParameterWithExtends();
3759
	super.consumeTypeParameterWithExtends();
3760
	if (this.assistNode != null && this.assistNodeParent == null) {
3761
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3762
		if (typeParameter != null && typeParameter.type == this.assistNode)
3763
			this.assistNodeParent = typeParameter;
3764
	}
3755
	popElement(K_EXTENDS_KEYWORD);
3765
	popElement(K_EXTENDS_KEYWORD);
3756
}
3766
}
3757
protected void consumeTypeParameterWithExtendsAndBounds() {
3767
protected void consumeTypeParameterWithExtendsAndBounds() {
3758
	super.consumeTypeParameterWithExtendsAndBounds();
3768
	super.consumeTypeParameterWithExtendsAndBounds();
3769
	if (this.assistNode != null && this.assistNodeParent == null) {
3770
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3771
		if (typeParameter != null && typeParameter.type == this.assistNode)
3772
			this.assistNodeParent = typeParameter;
3773
	}
3759
	popElement(K_EXTENDS_KEYWORD);
3774
	popElement(K_EXTENDS_KEYWORD);
3760
}
3775
}
3761
protected void consumeTypeParameter1WithExtends() {
3776
protected void consumeTypeParameter1WithExtends() {
3762
	super.consumeTypeParameter1WithExtends();
3777
	super.consumeTypeParameter1WithExtends();
3778
	if (this.assistNode != null && this.assistNodeParent == null) {
3779
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3780
		if (typeParameter != null && typeParameter.type == this.assistNode)
3781
			this.assistNodeParent = typeParameter;
3782
	}
3763
	popElement(K_EXTENDS_KEYWORD);
3783
	popElement(K_EXTENDS_KEYWORD);
3764
}
3784
}
3765
protected void consumeTypeParameter1WithExtendsAndBounds() {
3785
protected void consumeTypeParameter1WithExtendsAndBounds() {
3766
	super.consumeTypeParameter1WithExtendsAndBounds();
3786
	super.consumeTypeParameter1WithExtendsAndBounds();
3787
	if (this.assistNode != null && this.assistNodeParent == null) {
3788
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3789
		if (typeParameter != null && typeParameter.type == this.assistNode)
3790
			this.assistNodeParent = typeParameter;
3791
	}
3767
	popElement(K_EXTENDS_KEYWORD);
3792
	popElement(K_EXTENDS_KEYWORD);
3768
}
3793
}
3769
protected void consumeWildcard() {
3794
protected void consumeWildcard() {
Lines 3808-3825 Link Here
3808
}
3833
}
3809
protected void consumeWildcardBoundsExtends() {
3834
protected void consumeWildcardBoundsExtends() {
3810
	super.consumeWildcardBoundsExtends();
3835
	super.consumeWildcardBoundsExtends();
3836
	if (this.assistNode != null && this.assistNodeParent == null) {
3837
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3838
		if (wildcard != null && wildcard.bound == this.assistNode)
3839
			this.assistNodeParent = wildcard;
3840
	}
3811
	popElement(K_EXTENDS_KEYWORD);
3841
	popElement(K_EXTENDS_KEYWORD);
3812
}
3842
}
3813
protected void consumeWildcardBounds1Extends() {
3843
protected void consumeWildcardBounds1Extends() {
3814
	super.consumeWildcardBounds1Extends();
3844
	super.consumeWildcardBounds1Extends();
3845
	if (this.assistNode != null && this.assistNodeParent == null) {
3846
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3847
		if (wildcard != null && wildcard.bound == this.assistNode)
3848
			this.assistNodeParent = wildcard;
3849
	}
3815
	popElement(K_EXTENDS_KEYWORD);
3850
	popElement(K_EXTENDS_KEYWORD);
3816
}
3851
}
3817
protected void consumeWildcardBounds2Extends() {
3852
protected void consumeWildcardBounds2Extends() {
3818
	super.consumeWildcardBounds2Extends();
3853
	super.consumeWildcardBounds2Extends();
3854
	if (this.assistNode != null && this.assistNodeParent == null) {
3855
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3856
		if (wildcard != null && wildcard.bound == this.assistNode)
3857
			this.assistNodeParent = wildcard;
3858
	}
3819
	popElement(K_EXTENDS_KEYWORD);
3859
	popElement(K_EXTENDS_KEYWORD);
3820
}
3860
}
3821
protected void consumeWildcardBounds3Extends() {
3861
protected void consumeWildcardBounds3Extends() {
3822
	super.consumeWildcardBounds3Extends();
3862
	super.consumeWildcardBounds3Extends();
3863
	if (this.assistNode != null && this.assistNodeParent == null) {
3864
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3865
		if (wildcard != null && wildcard.bound == this.assistNode)
3866
			this.assistNodeParent = wildcard;
3867
	}
3823
	popElement(K_EXTENDS_KEYWORD);
3868
	popElement(K_EXTENDS_KEYWORD);
3824
}
3869
}
3825
protected void consumeUnaryExpression(int op) {
3870
protected void consumeUnaryExpression(int op) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (+31 lines)
Lines 482-487 Link Here
482
	private final static int NONE = 0;
482
	private final static int NONE = 0;
483
	private final static int SUPERTYPE = 1;
483
	private final static int SUPERTYPE = 1;
484
	private final static int SUBTYPE = 2;
484
	private final static int SUBTYPE = 2;
485
	private final static int FINALTYPE = 4; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399
485
	
486
	
486
	int expectedTypesPtr = -1;
487
	int expectedTypesPtr = -1;
487
	TypeBinding[] expectedTypes = new TypeBinding[1];
488
	TypeBinding[] expectedTypes = new TypeBinding[1];
Lines 1113-1118 Link Here
1113
		this.foundTypesCount++;
1114
		this.foundTypesCount++;
1114
		
1115
		
1115
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1116
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1117
		if (((this.forbbidenBindingsFilter & FINALTYPE) != 0) && ((modifiers & ClassFileConstants.AccFinal) != 0)) return;
1116
1118
1117
		if (this.options.checkVisibility) {
1119
		if (this.options.checkVisibility) {
1118
			if((modifiers & ClassFileConstants.AccPublic) == 0) {
1120
			if((modifiers & ClassFileConstants.AccPublic) == 0) {
Lines 3725-3730 Link Here
3725
3727
3726
	private Scope computeForbiddenBindings(ASTNode astNode, ASTNode astNodeParent, Scope scope) {
3728
	private Scope computeForbiddenBindings(ASTNode astNode, ASTNode astNodeParent, Scope scope) {
3727
		this.forbbidenBindingsFilter = NONE;
3729
		this.forbbidenBindingsFilter = NONE;
3730
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399, don't propose final types for extension.
3731
		if (astNodeParent != null) {
3732
			if (astNodeParent instanceof TypeDeclaration) {
3733
				TypeDeclaration typeDeclaration = (TypeDeclaration) astNodeParent;
3734
				if (typeDeclaration.superclass == astNode)
3735
					this.forbbidenBindingsFilter = FINALTYPE;	
3736
			} else if (astNodeParent instanceof TypeParameter) {
3737
				TypeParameter typeParameter = (TypeParameter) astNodeParent;
3738
				if (typeParameter.type == astNode)
3739
					this.forbbidenBindingsFilter = FINALTYPE;
3740
			} else if (astNodeParent instanceof Wildcard) {
3741
				Wildcard wildcard = (Wildcard) astNodeParent;
3742
				if (wildcard.bound == astNode && wildcard.kind == Wildcard.EXTENDS)
3743
					this.forbbidenBindingsFilter = FINALTYPE;
3744
			}
3745
		}
3728
		if(scope instanceof ClassScope) {
3746
		if(scope instanceof ClassScope) {
3729
			TypeDeclaration typeDeclaration = ((ClassScope)scope).referenceContext;
3747
			TypeDeclaration typeDeclaration = ((ClassScope)scope).referenceContext;
3730
			if(typeDeclaration.superclass == astNode) {
3748
			if(typeDeclaration.superclass == astNode) {
Lines 7319-7324 Link Here
7319
7337
7320
			if (this.options.checkDeprecation && memberType.isViewedAsDeprecated()) continue next;
7338
			if (this.options.checkDeprecation && memberType.isViewedAsDeprecated()) continue next;
7321
7339
7340
			if (isForbidden(memberType)) continue next;
7341
7322
			if (this.options.checkVisibility
7342
			if (this.options.checkVisibility
7323
				&& !memberType.canBeSeenBy(this.unitScope.fPackage))
7343
				&& !memberType.canBeSeenBy(this.unitScope.fPackage))
7324
				continue next;
7344
				continue next;
Lines 10271-10276 Link Here
10271
						!scope.isDefinedInSameUnit(sourceType))
10291
						!scope.isDefinedInSameUnit(sourceType))
10272
					continue;
10292
					continue;
10273
10293
10294
				if (isForbidden(sourceType))
10295
					continue;
10296
10274
				int accessibility = IAccessRule.K_ACCESSIBLE;
10297
				int accessibility = IAccessRule.K_ACCESSIBLE;
10275
				if(sourceType.hasRestrictedAccess()) {
10298
				if(sourceType.hasRestrictedAccess()) {
10276
					AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(sourceType);
10299
					AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(sourceType);
Lines 10414-10419 Link Here
10414
							!scope.isDefinedInSameUnit(refBinding))
10437
							!scope.isDefinedInSameUnit(refBinding))
10415
						continue next;
10438
						continue next;
10416
10439
10440
					if (isForbidden(refBinding))
10441
						continue next;
10442
10417
					int accessibility = IAccessRule.K_ACCESSIBLE;
10443
					int accessibility = IAccessRule.K_ACCESSIBLE;
10418
					if(refBinding.hasRestrictedAccess()) {
10444
					if(refBinding.hasRestrictedAccess()) {
10419
						AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
10445
						AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
Lines 11596-11601 Link Here
11596
				}
11622
				}
11597
			}
11623
			}
11598
		}
11624
		}
11625
		if((this.forbbidenBindingsFilter & FINALTYPE) != 0) {
11626
			if (binding instanceof ReferenceBinding && ((ReferenceBinding)binding).isFinal()) {
11627
				return true;
11628
			}
11629
		}
11599
		return false;
11630
		return false;
11600
	}
11631
	}
11601
11632
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+67 lines)
Lines 19353-19356 Link Here
19353
			"",
19353
			"",
19354
			requestor.getResults());
19354
			requestor.getResults());
19355
}
19355
}
19356
19357
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 don't propose final types for extends type completion.
19358
public void testCompletionOnExtendFinalClass () throws JavaModelException {
19359
	this.workingCopies = new ICompilationUnit[1];
19360
	this.workingCopies[0] = getWorkingCopy(
19361
		"/Completion/src/test/Test.java",
19362
		"package test;"+
19363
		"class ThisClassIsNotFinal {}" +
19364
		"final class ThisClassIsFinal {}" +
19365
		"public class Event extends test.ThisClassI {\n" +
19366
		"}");
19367
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
19368
	String str = this.workingCopies[0].getSource();
19369
	String completeBehind = "test.ThisClassI";
19370
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
19371
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19372
19373
	assertResults(
19374
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_CLASS) + "}",	
19375
			requestor.getResults());
19376
}
19377
19378
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 don't propose final types for extends type completion.
19379
public void testCompletionOnExtendFinalClass2() throws JavaModelException {
19380
	this.workingCopies = new ICompilationUnit[1];
19381
	this.workingCopies[0] = getWorkingCopy(
19382
		"/Completion/src/test/Test.java",
19383
		"package test;"+
19384
		"class ThisClassIsNotFinal {}" +
19385
		"final class ThisClassIsFinal {}" +
19386
		"public class Event extends ThisClassI {\n" +
19387
		"}");
19388
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
19389
	String str = this.workingCopies[0].getSource();
19390
	String completeBehind = "ThisClassI";
19391
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
19392
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19393
19394
	assertResults(
19395
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}",
19396
			requestor.getResults());
19397
}
19398
19399
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we continue to propose final types
19400
// in other (non extends context).
19401
public void testCompletionOnExtendFinalClass3() throws JavaModelException {
19402
	this.workingCopies = new ICompilationUnit[1];
19403
	this.workingCopies[0] = getWorkingCopy(
19404
		"/Completion/src/test/Test.java",
19405
		"package test;"+
19406
		"class ThisClassIsNotFinal {}" +
19407
		"final class ThisClassIsFinal {}" +
19408
		"public class Event extends ThisClassIsFinal {\n" +
19409
		"	void Boo (ThisClassI x) {}\n" +
19410
		"}");
19411
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
19412
	String str = this.workingCopies[0].getSource();
19413
	String completeBehind = "ThisClassI";
19414
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
19415
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19416
19417
	assertResults(
19418
			"ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
19419
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
19420
			requestor.getResults());
19421
}
19422
19356
}
19423
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (-6 / +107 lines)
Lines 323-330 Link Here
323
            ".Y001");
323
            ".Y001");
324
324
325
    assertResults(
325
    assertResults(
326
            "expectedTypesSignatures=null\n" +
326
            "expectedTypesSignatures={Ltest0011.Z0011<Ljava.lang.Object;>;}\n" +
327
            "expectedTypesKeys=null",
327
            "expectedTypesKeys={Ltest0011/Test~Z0011<Ljava/lang/Object;>;}",
328
            result.context);
328
            result.context);
329
329
330
    assertResults(
330
    assertResults(
Lines 490-497 Link Here
490
            ".Y001");
490
            ".Y001");
491
491
492
    assertResults(
492
    assertResults(
493
            "expectedTypesSignatures=null\n" +
493
            "expectedTypesSignatures={Ltest0018.Z0018<Ljava.lang.Object;>;}\n" +
494
            "expectedTypesKeys=null",
494
            "expectedTypesKeys={Ltest0018/Test~Z0018<Ljava/lang/Object;>;}",
495
            result.context);
495
            result.context);
496
496
497
    assertResults(
497
    assertResults(
Lines 513-520 Link Here
513
            ".Y001");
513
            ".Y001");
514
514
515
    assertResults(
515
    assertResults(
516
            "expectedTypesSignatures=null\n" +
516
            "expectedTypesSignatures={Ltest0019.Z0019<Ljava.lang.Object;>;}\n" +
517
            "expectedTypesKeys=null",
517
            "expectedTypesKeys={Ltest0019/Test~Z0019<Ljava/lang/Object;>;}",
518
            result.context);
518
            result.context);
519
519
520
    assertResults(
520
    assertResults(
Lines 13476-13479 Link Here
13476
			requestor.getResults());
13476
			requestor.getResults());
13477
}
13477
}
13478
13478
13479
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we continue to propose final
13480
// types in extends contexts but where they are not directly extended.
13481
public void testCompletionOnExtends() throws JavaModelException {
13482
	this.workingCopies = new ICompilationUnit[1];
13483
	this.workingCopies[0] = getWorkingCopy(
13484
			"/Completion/src3/test/Test.java",
13485
			"package test;\n" +
13486
			"class X<T> {};\n" +
13487
			"final class ThisClassIsFinal {}\n" +
13488
			"class ThisClassIsNotFinal {}\n" +
13489
			"public class Test extends X<ThisClassI> {}");
13490
13491
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13492
13493
	String str = this.workingCopies[0].getSource();
13494
	String completeBehind = "ThisClassI";
13495
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13496
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13497
13498
	assertResults(
13499
			"ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}\n" +
13500
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}",
13501
			requestor.getResults());
13502
}
13503
13504
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we don't propose final
13505
//types in extends contexts where we should not.
13506
public void testCompletionOnExtends2() throws JavaModelException {
13507
	this.workingCopies = new ICompilationUnit[1];
13508
	this.workingCopies[0] = getWorkingCopy(
13509
			"/Completion/src3/test/Test.java",
13510
			"package test;\n" +
13511
			"final class ThisClassIsFinal {}\n" +
13512
			"class ThisClassIsNotFinal {}\n" +
13513
			"public class Test <T extends ThisClassI> {}\n");
13514
13515
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13516
13517
	String str = this.workingCopies[0].getSource();
13518
	String completeBehind = "ThisClassI";
13519
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13520
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13521
13522
	assertResults(
13523
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13524
			requestor.getResults());
13525
}
13526
13527
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we don't propose final
13528
//types in extends contexts where we should not.
13529
public void testCompletionOnExtends3() throws JavaModelException {
13530
	this.workingCopies = new ICompilationUnit[1];
13531
	this.workingCopies[0] = getWorkingCopy(
13532
			"/Completion/src3/test/Test.java",
13533
			"package test;\n" +
13534
			"final class ThisClassIsFinal {}\n" +
13535
			"class ThisClassIsNotFinal {}\n" +
13536
			"public class Test {\n" +
13537
			"    Test(Bag<? extends ThisClassI> p) {}" +
13538
			"}\n");
13539
13540
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13541
13542
	String str = this.workingCopies[0].getSource();
13543
	String completeBehind = "ThisClassI";
13544
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13545
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13546
13547
	assertResults(
13548
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13549
			requestor.getResults());
13550
}
13551
13552
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we do propose final
13553
//types in super contexts where we should.
13554
public void testCompletionOnExtends4() throws JavaModelException {
13555
	this.workingCopies = new ICompilationUnit[1];
13556
	this.workingCopies[0] = getWorkingCopy(
13557
			"/Completion/src3/test/Test.java",
13558
			"package test;\n" +
13559
			"final class ThisClassIsFinal {}\n" +
13560
			"class ThisClassIsNotFinal {}\n" +
13561
			"public class Test {\n" +
13562
			"    void boo() {\n" +
13563
			"        Bag<? super ThisClassI> local;\n" +
13564
			"    }\n" +
13565
			"}\n");
13566
13567
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13568
13569
	String str = this.workingCopies[0].getSource();
13570
	String completeBehind = "ThisClassI";
13571
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13572
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13573
13574
	assertResults(
13575
			"ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13576
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13577
			requestor.getResults());
13578
}
13579
13479
}
13580
}

Return to bug 99399