@@ -733,182 +733,3 @@ def hover_request(file_path, line, char):
733
733
check_return (results [8 ], ())
734
734
check_return (results [9 ], ())
735
735
check_return (results [10 ], ((3 , " !! Doc 9" ), (4 , " !! Doc 10" )))
736
-
737
-
738
- def test_diagnostics ():
739
- """
740
- Tests some aspects of diagnostics
741
- """
742
-
743
- def check_return (results , ref_results ):
744
- for i , r in enumerate (results ):
745
- print (r ["diagnostics" ], ref_results [i ])
746
- assert r ["diagnostics" ] == ref_results [i ]
747
-
748
- string = write_rpc_request (1 , "initialize" , {"rootPath" : str (test_dir )})
749
- # Test subroutines and functions with interfaces as arguments
750
- file_path = str (test_dir / "test_diagnostic_int.f90" )
751
- string += write_rpc_notification (
752
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
753
- )
754
- # Test that use, non_intrinsic does not raise a diagnostic error
755
- file_path = str (test_dir / "test_nonintrinsic.f90" )
756
- string += write_rpc_notification (
757
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
758
- )
759
- # Test that submodules with spacings in their parent's names are parsed
760
- file_path = str (test_dir / "test_submodule.f90" )
761
- string += write_rpc_notification (
762
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
763
- )
764
- # Tests that variables named end do not close the scope prematurely
765
- file_path = str (test_dir / "diag" / "test_scope_end_name_var.f90" )
766
- string += write_rpc_notification (
767
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
768
- )
769
- # Test that externals can be split between multiple lines
770
- # and that diagnostics for multiple definitions of externals can account
771
- # for that
772
- file_path = str (test_dir / "diag" / "test_external.f90" )
773
- string += write_rpc_notification (
774
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
775
- )
776
- # Checks that forall with end forall inside a case select does not cause
777
- # unexpected end of scope.
778
- file_path = str (test_dir / "diag" / "test_forall.f90" )
779
- string += write_rpc_notification (
780
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
781
- )
782
- # Test USE directive ordering errors
783
- file_path = str (test_dir / "diag" / "test_use_ordering.f90" )
784
- string += write_rpc_notification (
785
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
786
- )
787
- # Test where blocks
788
- file_path = str (test_dir / "diag" / "test_where.f90" )
789
- string += write_rpc_notification (
790
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
791
- )
792
- # Test where semicolon (multi-line)
793
- file_path = str (test_dir / "diag" / "test_semicolon.f90" )
794
- string += write_rpc_notification (
795
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
796
- )
797
- # Test ENUM block
798
- file_path = str (test_dir / "diag" / "test_enum.f90" )
799
- string += write_rpc_notification (
800
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
801
- )
802
- # Test module procedure in submodules importing scopes
803
- file_path = str (test_dir / "subdir" / "test_submod.F90" )
804
- string += write_rpc_notification (
805
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
806
- )
807
- errcode , results = run_request (string )
808
- assert errcode == 0
809
-
810
- # Load a different config file
811
- # Test long lines
812
- root = str (test_dir / "diag" )
813
- string = write_rpc_request (1 , "initialize" , {"rootPath" : root })
814
- file_path = str (test_dir / "diag" / "test_lines.f90" )
815
- string += write_rpc_notification (
816
- "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
817
- )
818
- file_path = str (test_dir / "diag" / "conf_long_lines.json" )
819
- errcode , res = run_request (string , [f"--config { file_path } " ])
820
- assert errcode == 0
821
- results .extend (res [1 :])
822
-
823
- root = path_to_uri (str ((test_dir / "diag" / "test_external.f90" ).resolve ()))
824
- ref_results = [
825
- [],
826
- [],
827
- [],
828
- [],
829
- [
830
- {
831
- "range" : {
832
- "start" : {"line" : 7 , "character" : 17 },
833
- "end" : {"line" : 7 , "character" : 22 },
834
- },
835
- "message" : 'Variable "VAR_B" declared twice in scope' ,
836
- "severity" : 1 ,
837
- "relatedInformation" : [
838
- {
839
- "location" : {
840
- "uri" : str (root ),
841
- "range" : {
842
- "start" : {"line" : 5 , "character" : 0 },
843
- "end" : {"line" : 5 , "character" : 0 },
844
- },
845
- },
846
- "message" : "First declaration" ,
847
- }
848
- ],
849
- },
850
- {
851
- "range" : {
852
- "start" : {"line" : 8 , "character" : 17 },
853
- "end" : {"line" : 8 , "character" : 22 },
854
- },
855
- "message" : 'Variable "VAR_A" declared twice in scope' ,
856
- "severity" : 1 ,
857
- "relatedInformation" : [
858
- {
859
- "location" : {
860
- "uri" : str (root ),
861
- "range" : {
862
- "start" : {"line" : 3 , "character" : 0 },
863
- "end" : {"line" : 3 , "character" : 0 },
864
- },
865
- },
866
- "message" : "First declaration" ,
867
- }
868
- ],
869
- },
870
- ],
871
- [],
872
- [],
873
- [],
874
- [],
875
- [],
876
- [],
877
- [
878
- {
879
- "range" : {
880
- "start" : {"line" : 2 , "character" : 100 },
881
- "end" : {"line" : 2 , "character" : 155 },
882
- },
883
- "message" : 'Line length exceeds "max_line_length" (100)' ,
884
- "severity" : 2 ,
885
- },
886
- {
887
- "range" : {
888
- "start" : {"line" : 3 , "character" : 100 },
889
- "end" : {"line" : 3 , "character" : 127 },
890
- },
891
- "message" : (
892
- 'Comment line length exceeds "max_comment_line_length" (100)'
893
- ),
894
- "severity" : 2 ,
895
- },
896
- ],
897
- ]
898
- check_return (results [1 :], ref_results )
899
-
900
-
901
- if __name__ == "__main__" :
902
- test_init ()
903
- test_logger ()
904
- test_open ()
905
- test_change ()
906
- test_symbols ()
907
- test_workspace_symbols ()
908
- test_comp ()
909
- test_sig ()
910
- test_def ()
911
- test_refs ()
912
- test_hover ()
913
- test_docs ()
914
- test_diagnostics ()
0 commit comments