@@ -500,8 +500,8 @@ namespace FourSlashInterface {
500
500
/**
501
501
* This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
502
502
*/
503
- public semanticClassificationsAre ( ...classifications : Classification [ ] ) {
504
- this . state . verifySemanticClassifications ( classifications ) ;
503
+ public semanticClassificationsAre ( format : "original" | "2020" , ...classifications : Classification [ ] ) {
504
+ this . state . verifySemanticClassifications ( format , classifications ) ;
505
505
}
506
506
507
507
public renameInfoSucceeded ( displayName ?: string , fullDisplayName ?: string , kind ?: string , kindModifiers ?: string , fileToRename ?: string , expectedRange ?: FourSlash . Range , options ?: ts . RenameInfoOptions ) {
@@ -745,108 +745,154 @@ namespace FourSlashInterface {
745
745
}
746
746
747
747
interface Classification {
748
- classificationType : ts . ClassificationTypeNames ;
749
- text : string ;
748
+ classificationType : ts . ClassificationTypeNames | number ;
749
+ text ? : string ;
750
750
textSpan ?: FourSlash . TextSpan ;
751
751
}
752
- export namespace Classification {
753
- export function comment ( text : string , position ?: number ) : Classification {
752
+
753
+ export function classification ( format : "original" | "2020" ) {
754
+ function token ( identifier : number , text : string , _position : number ) : Classification {
755
+ return {
756
+ classificationType : identifier ,
757
+ // textSpan: {
758
+ // start: position,
759
+ // end: -1
760
+ // },
761
+ text
762
+ }
763
+ }
764
+
765
+ if ( format === "2020" ) {
766
+ return {
767
+ token
768
+ }
769
+ }
770
+
771
+ function comment ( text : string , position ?: number ) : Classification {
754
772
return getClassification ( ts . ClassificationTypeNames . comment , text , position ) ;
755
773
}
756
774
757
- export function identifier ( text : string , position ?: number ) : Classification {
775
+ function identifier ( text : string , position ?: number ) : Classification {
758
776
return getClassification ( ts . ClassificationTypeNames . identifier , text , position ) ;
759
777
}
760
778
761
- export function keyword ( text : string , position ?: number ) : Classification {
779
+ function keyword ( text : string , position ?: number ) : Classification {
762
780
return getClassification ( ts . ClassificationTypeNames . keyword , text , position ) ;
763
781
}
764
782
765
- export function numericLiteral ( text : string , position ?: number ) : Classification {
783
+ function numericLiteral ( text : string , position ?: number ) : Classification {
766
784
return getClassification ( ts . ClassificationTypeNames . numericLiteral , text , position ) ;
767
785
}
768
786
769
- export function operator ( text : string , position ?: number ) : Classification {
787
+ function operator ( text : string , position ?: number ) : Classification {
770
788
return getClassification ( ts . ClassificationTypeNames . operator , text , position ) ;
771
789
}
772
790
773
- export function stringLiteral ( text : string , position ?: number ) : Classification {
791
+ function stringLiteral ( text : string , position ?: number ) : Classification {
774
792
return getClassification ( ts . ClassificationTypeNames . stringLiteral , text , position ) ;
775
793
}
776
794
777
- export function whiteSpace ( text : string , position ?: number ) : Classification {
795
+ function whiteSpace ( text : string , position ?: number ) : Classification {
778
796
return getClassification ( ts . ClassificationTypeNames . whiteSpace , text , position ) ;
779
797
}
780
798
781
- export function text ( text : string , position ?: number ) : Classification {
799
+ function text ( text : string , position ?: number ) : Classification {
782
800
return getClassification ( ts . ClassificationTypeNames . text , text , position ) ;
783
801
}
784
802
785
- export function punctuation ( text : string , position ?: number ) : Classification {
803
+ function punctuation ( text : string , position ?: number ) : Classification {
786
804
return getClassification ( ts . ClassificationTypeNames . punctuation , text , position ) ;
787
805
}
788
806
789
- export function docCommentTagName ( text : string , position ?: number ) : Classification {
807
+ function docCommentTagName ( text : string , position ?: number ) : Classification {
790
808
return getClassification ( ts . ClassificationTypeNames . docCommentTagName , text , position ) ;
791
809
}
792
810
793
- export function className ( text : string , position ?: number ) : Classification {
811
+ function className ( text : string , position ?: number ) : Classification {
794
812
return getClassification ( ts . ClassificationTypeNames . className , text , position ) ;
795
813
}
796
814
797
- export function enumName ( text : string , position ?: number ) : Classification {
815
+ function enumName ( text : string , position ?: number ) : Classification {
798
816
return getClassification ( ts . ClassificationTypeNames . enumName , text , position ) ;
799
817
}
800
818
801
- export function interfaceName ( text : string , position ?: number ) : Classification {
819
+ function interfaceName ( text : string , position ?: number ) : Classification {
802
820
return getClassification ( ts . ClassificationTypeNames . interfaceName , text , position ) ;
803
821
}
804
822
805
- export function moduleName ( text : string , position ?: number ) : Classification {
823
+ function moduleName ( text : string , position ?: number ) : Classification {
806
824
return getClassification ( ts . ClassificationTypeNames . moduleName , text , position ) ;
807
825
}
808
826
809
- export function typeParameterName ( text : string , position ?: number ) : Classification {
827
+ function typeParameterName ( text : string , position ?: number ) : Classification {
810
828
return getClassification ( ts . ClassificationTypeNames . typeParameterName , text , position ) ;
811
829
}
812
830
813
- export function parameterName ( text : string , position ?: number ) : Classification {
831
+ function parameterName ( text : string , position ?: number ) : Classification {
814
832
return getClassification ( ts . ClassificationTypeNames . parameterName , text , position ) ;
815
833
}
816
834
817
- export function typeAliasName ( text : string , position ?: number ) : Classification {
835
+ function typeAliasName ( text : string , position ?: number ) : Classification {
818
836
return getClassification ( ts . ClassificationTypeNames . typeAliasName , text , position ) ;
819
837
}
820
838
821
- export function jsxOpenTagName ( text : string , position ?: number ) : Classification {
839
+ function jsxOpenTagName ( text : string , position ?: number ) : Classification {
822
840
return getClassification ( ts . ClassificationTypeNames . jsxOpenTagName , text , position ) ;
823
841
}
824
842
825
- export function jsxCloseTagName ( text : string , position ?: number ) : Classification {
843
+ function jsxCloseTagName ( text : string , position ?: number ) : Classification {
826
844
return getClassification ( ts . ClassificationTypeNames . jsxCloseTagName , text , position ) ;
827
845
}
828
846
829
- export function jsxSelfClosingTagName ( text : string , position ?: number ) : Classification {
847
+ function jsxSelfClosingTagName ( text : string , position ?: number ) : Classification {
830
848
return getClassification ( ts . ClassificationTypeNames . jsxSelfClosingTagName , text , position ) ;
831
849
}
832
850
833
- export function jsxAttribute ( text : string , position ?: number ) : Classification {
851
+ function jsxAttribute ( text : string , position ?: number ) : Classification {
834
852
return getClassification ( ts . ClassificationTypeNames . jsxAttribute , text , position ) ;
835
853
}
836
854
837
- export function jsxText ( text : string , position ?: number ) : Classification {
855
+ function jsxText ( text : string , position ?: number ) : Classification {
838
856
return getClassification ( ts . ClassificationTypeNames . jsxText , text , position ) ;
839
857
}
840
858
841
- export function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : Classification {
859
+ function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : Classification {
842
860
return getClassification ( ts . ClassificationTypeNames . jsxAttributeStringLiteralValue , text , position ) ;
843
861
}
844
862
845
863
function getClassification ( classificationType : ts . ClassificationTypeNames , text : string , position ?: number ) : Classification {
846
864
const textSpan = position === undefined ? undefined : { start : position , end : position + text . length } ;
847
865
return { classificationType, text, textSpan } ;
848
866
}
867
+
868
+ return {
869
+ comment,
870
+ identifier,
871
+ keyword,
872
+ numericLiteral,
873
+ operator,
874
+ stringLiteral,
875
+ whiteSpace,
876
+ text,
877
+ punctuation,
878
+ docCommentTagName,
879
+ className,
880
+ enumName,
881
+ interfaceName,
882
+ moduleName,
883
+ typeParameterName,
884
+ parameterName,
885
+ typeAliasName,
886
+ jsxOpenTagName,
887
+ jsxCloseTagName,
888
+ jsxSelfClosingTagName,
889
+ jsxAttribute,
890
+ jsxText,
891
+ jsxAttributeStringLiteralValue,
892
+ getClassification
893
+ }
849
894
}
895
+
850
896
export namespace Completion {
851
897
export import SortText = ts . Completions . SortText ;
852
898
export import CompletionSource = ts . Completions . CompletionSource ;
0 commit comments