@@ -500,8 +500,8 @@ namespace FourSlashInterface {
500500 /**
501501 * This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
502502 */
503- public semanticClassificationsAre ( ...classifications : Classification [ ] ) {
504- this . state . verifySemanticClassifications ( classifications ) ;
503+ public semanticClassificationsAre ( format : "original" | "2020" , ...classifications : Classification [ ] ) {
504+ this . state . verifySemanticClassifications ( format , classifications ) ;
505505 }
506506
507507 public renameInfoSucceeded ( displayName ?: string , fullDisplayName ?: string , kind ?: string , kindModifiers ?: string , fileToRename ?: string , expectedRange ?: FourSlash . Range , options ?: ts . RenameInfoOptions ) {
@@ -745,108 +745,154 @@ namespace FourSlashInterface {
745745 }
746746
747747 interface Classification {
748- classificationType : ts . ClassificationTypeNames ;
749- text : string ;
748+ classificationType : ts . ClassificationTypeNames | number ;
749+ text ? : string ;
750750 textSpan ?: FourSlash . TextSpan ;
751751 }
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 {
754772 return getClassification ( ts . ClassificationTypeNames . comment , text , position ) ;
755773 }
756774
757- export function identifier ( text : string , position ?: number ) : Classification {
775+ function identifier ( text : string , position ?: number ) : Classification {
758776 return getClassification ( ts . ClassificationTypeNames . identifier , text , position ) ;
759777 }
760778
761- export function keyword ( text : string , position ?: number ) : Classification {
779+ function keyword ( text : string , position ?: number ) : Classification {
762780 return getClassification ( ts . ClassificationTypeNames . keyword , text , position ) ;
763781 }
764782
765- export function numericLiteral ( text : string , position ?: number ) : Classification {
783+ function numericLiteral ( text : string , position ?: number ) : Classification {
766784 return getClassification ( ts . ClassificationTypeNames . numericLiteral , text , position ) ;
767785 }
768786
769- export function operator ( text : string , position ?: number ) : Classification {
787+ function operator ( text : string , position ?: number ) : Classification {
770788 return getClassification ( ts . ClassificationTypeNames . operator , text , position ) ;
771789 }
772790
773- export function stringLiteral ( text : string , position ?: number ) : Classification {
791+ function stringLiteral ( text : string , position ?: number ) : Classification {
774792 return getClassification ( ts . ClassificationTypeNames . stringLiteral , text , position ) ;
775793 }
776794
777- export function whiteSpace ( text : string , position ?: number ) : Classification {
795+ function whiteSpace ( text : string , position ?: number ) : Classification {
778796 return getClassification ( ts . ClassificationTypeNames . whiteSpace , text , position ) ;
779797 }
780798
781- export function text ( text : string , position ?: number ) : Classification {
799+ function text ( text : string , position ?: number ) : Classification {
782800 return getClassification ( ts . ClassificationTypeNames . text , text , position ) ;
783801 }
784802
785- export function punctuation ( text : string , position ?: number ) : Classification {
803+ function punctuation ( text : string , position ?: number ) : Classification {
786804 return getClassification ( ts . ClassificationTypeNames . punctuation , text , position ) ;
787805 }
788806
789- export function docCommentTagName ( text : string , position ?: number ) : Classification {
807+ function docCommentTagName ( text : string , position ?: number ) : Classification {
790808 return getClassification ( ts . ClassificationTypeNames . docCommentTagName , text , position ) ;
791809 }
792810
793- export function className ( text : string , position ?: number ) : Classification {
811+ function className ( text : string , position ?: number ) : Classification {
794812 return getClassification ( ts . ClassificationTypeNames . className , text , position ) ;
795813 }
796814
797- export function enumName ( text : string , position ?: number ) : Classification {
815+ function enumName ( text : string , position ?: number ) : Classification {
798816 return getClassification ( ts . ClassificationTypeNames . enumName , text , position ) ;
799817 }
800818
801- export function interfaceName ( text : string , position ?: number ) : Classification {
819+ function interfaceName ( text : string , position ?: number ) : Classification {
802820 return getClassification ( ts . ClassificationTypeNames . interfaceName , text , position ) ;
803821 }
804822
805- export function moduleName ( text : string , position ?: number ) : Classification {
823+ function moduleName ( text : string , position ?: number ) : Classification {
806824 return getClassification ( ts . ClassificationTypeNames . moduleName , text , position ) ;
807825 }
808826
809- export function typeParameterName ( text : string , position ?: number ) : Classification {
827+ function typeParameterName ( text : string , position ?: number ) : Classification {
810828 return getClassification ( ts . ClassificationTypeNames . typeParameterName , text , position ) ;
811829 }
812830
813- export function parameterName ( text : string , position ?: number ) : Classification {
831+ function parameterName ( text : string , position ?: number ) : Classification {
814832 return getClassification ( ts . ClassificationTypeNames . parameterName , text , position ) ;
815833 }
816834
817- export function typeAliasName ( text : string , position ?: number ) : Classification {
835+ function typeAliasName ( text : string , position ?: number ) : Classification {
818836 return getClassification ( ts . ClassificationTypeNames . typeAliasName , text , position ) ;
819837 }
820838
821- export function jsxOpenTagName ( text : string , position ?: number ) : Classification {
839+ function jsxOpenTagName ( text : string , position ?: number ) : Classification {
822840 return getClassification ( ts . ClassificationTypeNames . jsxOpenTagName , text , position ) ;
823841 }
824842
825- export function jsxCloseTagName ( text : string , position ?: number ) : Classification {
843+ function jsxCloseTagName ( text : string , position ?: number ) : Classification {
826844 return getClassification ( ts . ClassificationTypeNames . jsxCloseTagName , text , position ) ;
827845 }
828846
829- export function jsxSelfClosingTagName ( text : string , position ?: number ) : Classification {
847+ function jsxSelfClosingTagName ( text : string , position ?: number ) : Classification {
830848 return getClassification ( ts . ClassificationTypeNames . jsxSelfClosingTagName , text , position ) ;
831849 }
832850
833- export function jsxAttribute ( text : string , position ?: number ) : Classification {
851+ function jsxAttribute ( text : string , position ?: number ) : Classification {
834852 return getClassification ( ts . ClassificationTypeNames . jsxAttribute , text , position ) ;
835853 }
836854
837- export function jsxText ( text : string , position ?: number ) : Classification {
855+ function jsxText ( text : string , position ?: number ) : Classification {
838856 return getClassification ( ts . ClassificationTypeNames . jsxText , text , position ) ;
839857 }
840858
841- export function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : Classification {
859+ function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : Classification {
842860 return getClassification ( ts . ClassificationTypeNames . jsxAttributeStringLiteralValue , text , position ) ;
843861 }
844862
845863 function getClassification ( classificationType : ts . ClassificationTypeNames , text : string , position ?: number ) : Classification {
846864 const textSpan = position === undefined ? undefined : { start : position , end : position + text . length } ;
847865 return { classificationType, text, textSpan } ;
848866 }
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+ }
849894 }
895+
850896 export namespace Completion {
851897 export import SortText = ts . Completions . SortText ;
852898 export import CompletionSource = ts . Completions . CompletionSource ;
0 commit comments