@@ -80,6 +80,10 @@ module FourSlashInterface {
8080 return FourSlash . currentTestState . getMarkers ( ) ;
8181 }
8282
83+ public marker ( name ?: string ) : Marker {
84+ return FourSlash . currentTestState . getMarkerByName ( name ) ;
85+ }
86+
8387 public ranges ( ) : Range [ ] {
8488 return FourSlash . currentTestState . getRanges ( ) ;
8589 }
@@ -401,11 +405,17 @@ module FourSlashInterface {
401405 FourSlash . currentTestState . verifyCompletionEntryDetails ( entryName , text , documentation , kind ) ;
402406 }
403407
408+ /**
409+ * This method *requires* a contiguous, complete, and ordered stream of classifications for a file.
410+ */
404411 public syntacticClassificationsAre ( ...classifications : { classificationType : string ; text : string } [ ] ) {
405412 FourSlash . currentTestState . verifySyntacticClassifications ( classifications ) ;
406413 }
407414
408- public semanticClassificationsAre ( ...classifications : { classificationType : string ; text : string } [ ] ) {
415+ /**
416+ * This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
417+ */
418+ public semanticClassificationsAre ( ...classifications : { classificationType : string ; text : string ; textSpan ?: TextSpan } [ ] ) {
409419 FourSlash . currentTestState . verifySemanticClassifications ( classifications ) ;
410420 }
411421
@@ -563,61 +573,69 @@ module FourSlashInterface {
563573 }
564574 }
565575
566- export class classification {
567- public static comment ( text : string ) : { classificationType : string ; text : string } {
568- return { classificationType : "comment" , text : text } ;
576+ export module classification {
577+ export function comment ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
578+ return getClassification ( "comment" , text , position ) ;
569579 }
570580
571- public static identifier ( text : string ) : { classificationType : string ; text : string } {
572- return { classificationType : "identifier" , text : text } ;
581+ export function identifier ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
582+ return getClassification ( "identifier" , text , position ) ;
573583 }
574584
575- public static keyword ( text : string ) : { classificationType : string ; text : string } {
576- return { classificationType : "keyword" , text : text } ;
585+ export function keyword ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
586+ return getClassification ( "keyword" , text , position ) ;
577587 }
578588
579- public static numericLiteral ( text : string ) : { classificationType : string ; text : string } {
580- return { classificationType : "numericLiteral" , text : text } ;
589+ export function numericLiteral ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
590+ return getClassification ( "numericLiteral" , text , position ) ;
581591 }
582592
583- public static operator ( text : string ) : { classificationType : string ; text : string } {
584- return { classificationType : "operator" , text : text } ;
593+ export function operator ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
594+ return getClassification ( "operator" , text , position ) ;
585595 }
586596
587- public static stringLiteral ( text : string ) : { classificationType : string ; text : string } {
588- return { classificationType : "stringLiteral" , text : text } ;
597+ export function stringLiteral ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
598+ return getClassification ( "stringLiteral" , text , position ) ;
589599 }
590600
591- public static whiteSpace ( text : string ) : { classificationType : string ; text : string } {
592- return { classificationType : "whiteSpace" , text : text } ;
601+ export function whiteSpace ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
602+ return getClassification ( "whiteSpace" , text , position ) ;
593603 }
594604
595- public static text ( text : string ) : { classificationType : string ; text : string } {
596- return { classificationType : "text" , text : text } ;
605+ export function text ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
606+ return getClassification ( "text" , text , position ) ;
597607 }
598608
599- public static punctuation ( text : string ) : { classificationType : string ; text : string } {
600- return { classificationType : "punctuation" , text : text } ;
609+ export function punctuation ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
610+ return getClassification ( "punctuation" , text , position ) ;
601611 }
602612
603- public static className ( text : string ) : { classificationType : string ; text : string } {
604- return { classificationType : "className" , text : text } ;
613+ export function className ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
614+ return getClassification ( "className" , text , position ) ;
605615 }
606616
607- public static enumName ( text : string ) : { classificationType : string ; text : string } {
608- return { classificationType : "enumName" , text : text } ;
617+ export function enumName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
618+ return getClassification ( "enumName" , text , position ) ;
609619 }
610620
611- public static interfaceName ( text : string ) : { classificationType : string ; text : string } {
612- return { classificationType : "interfaceName" , text : text } ;
621+ export function interfaceName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
622+ return getClassification ( "interfaceName" , text , position ) ;
613623 }
614624
615- public static moduleName ( text : string ) : { classificationType : string ; text : string } {
616- return { classificationType : "moduleName" , text : text } ;
625+ export function moduleName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
626+ return getClassification ( "moduleName" , text , position ) ;
617627 }
618628
619- public static typeParameterName ( text : string ) : { classificationType : string ; text : string } {
620- return { classificationType : "typeParameterName" , text : text } ;
629+ export function typeParameterName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: TextSpan } {
630+ return getClassification ( "typeParameterName" , text , position ) ;
631+ }
632+
633+ function getClassification ( type : string , text : string , position ?: number ) {
634+ return {
635+ classificationType : type ,
636+ text : text ,
637+ textSpan : position === undefined ? undefined : { start : position , end : position + text . length }
638+ } ;
621639 }
622640 }
623641}
@@ -635,6 +653,7 @@ module fs {
635653function verifyOperationIsCancelled ( f ) {
636654 FourSlash . verifyOperationIsCancelled ( f ) ;
637655}
656+
638657var test = new FourSlashInterface . test_ ( ) ;
639658var goTo = new FourSlashInterface . goTo ( ) ;
640659var verify = new FourSlashInterface . verify ( ) ;
0 commit comments