@@ -558,6 +558,126 @@ public void test() {
558558 """ );
559559 }
560560
561+ @ Test
562+ public void beforeStatement () throws Exception {
563+ String content = """
564+ package org.sample.test;
565+
566+ import org.springframework.web.bind.annotation.RestController;
567+
568+ @RestController
569+ public class TestBeanCompletionClass {
570+ public void test() {
571+ owner<*>
572+ System.out.println();
573+ }
574+ }
575+ """ ;
576+
577+
578+ assertCompletions (content , new String [] {"ownerRepository" , "ownerService" }, 0 ,
579+ """
580+ package org.sample.test;
581+
582+ import org.springframework.samples.petclinic.owner.OwnerRepository;
583+ import org.springframework.web.bind.annotation.RestController;
584+
585+ @RestController
586+ public class TestBeanCompletionClass {
587+
588+ private final OwnerRepository ownerRepository;
589+
590+ TestBeanCompletionClass(OwnerRepository ownerRepository) {
591+ this.ownerRepository = ownerRepository;
592+ }
593+ public void test() {
594+ ownerRepository<*>
595+ System.out.println();
596+ }
597+ }
598+ """ );
599+ }
600+
601+ @ Test
602+ public void beforeStatementStartingWithThis () throws Exception {
603+ String content = """
604+ package org.sample.test;
605+
606+ import org.springframework.web.bind.annotation.RestController;
607+
608+ @RestController
609+ public class TestBeanCompletionClass {
610+ public void test() {
611+ this.<*>
612+ System.out.println();
613+ }
614+ }
615+ """ ;
616+
617+
618+ assertCompletions (content , new String [] {"ownerRepository" , "ownerService" , "petService" , "visitRepository" , "visitService" }, 0 ,
619+ """
620+ package org.sample.test;
621+
622+ import org.springframework.samples.petclinic.owner.OwnerRepository;
623+ import org.springframework.web.bind.annotation.RestController;
624+
625+ @RestController
626+ public class TestBeanCompletionClass {
627+
628+ private final OwnerRepository ownerRepository;
629+
630+ TestBeanCompletionClass(OwnerRepository ownerRepository) {
631+ this.ownerRepository = ownerRepository;
632+ }
633+ public void test() {
634+ this.ownerRepository<*>
635+ System.out.println();
636+ }
637+ }
638+ """ );
639+ }
640+
641+ @ Test
642+ public void beforeStatementStartingWithThisAndPrefix () throws Exception {
643+ String content = """
644+ package org.sample.test;
645+
646+ import org.springframework.web.bind.annotation.RestController;
647+
648+ @RestController
649+ public class TestBeanCompletionClass {
650+ public void test() {
651+ this.ow<*>
652+ System.out.println();
653+ }
654+ }
655+ """ ;
656+
657+
658+ assertCompletions (content , new String [] {"ownerRepository" , "ownerService" }, 0 ,
659+ """
660+ package org.sample.test;
661+
662+ import org.springframework.samples.petclinic.owner.OwnerRepository;
663+ import org.springframework.web.bind.annotation.RestController;
664+
665+ @RestController
666+ public class TestBeanCompletionClass {
667+
668+ private final OwnerRepository ownerRepository;
669+
670+ TestBeanCompletionClass(OwnerRepository ownerRepository) {
671+ this.ownerRepository = ownerRepository;
672+ }
673+ public void test() {
674+ this.ownerRepository<*>
675+ System.out.println();
676+ }
677+ }
678+ """ );
679+ }
680+
561681 private void assertCompletions (String completionLine , String [] expectedCompletions , int chosenCompletion , String expectedResult ) throws Exception {
562682 assertCompletions (completionLine , expectedCompletions .length , expectedCompletions , chosenCompletion , expectedResult );
563683 }
0 commit comments