@@ -655,7 +655,7 @@ namespace FourSlash {
655655 this . assertItemInCompletionList ( completions . entries , symbol , text , documentation , kind ) ;
656656 }
657657 else {
658- this . raiseError ( `No completions at position '${ this . currentCaretPosition } ' when looking for '${ symbol } '.` ) ;
658+ this . raiseError ( `No completions at position '${ this . currentCaretPosition } ' when looking for '${ symbol } '.` ) ;
659659 }
660660 }
661661
@@ -1758,13 +1758,13 @@ namespace FourSlash {
17581758 const actual = ( < ts . server . SessionClient > this . languageService ) . getProjectInfo (
17591759 this . activeFile . fileName ,
17601760 /* needFileNameList */ true
1761- ) ;
1761+ ) ;
17621762 assert . equal (
17631763 expected . join ( "," ) ,
1764- actual . fileNames . map ( file => {
1764+ actual . fileNames . map ( file => {
17651765 return file . replace ( this . basePath + "/" , "" ) ;
1766- } ) . join ( "," )
1767- ) ;
1766+ } ) . join ( "," )
1767+ ) ;
17681768 }
17691769 }
17701770
@@ -1850,6 +1850,37 @@ namespace FourSlash {
18501850 } ) ;
18511851 }
18521852
1853+ public verifyBraceCompletionAtPostion ( negative : boolean , openingBrace : string ) {
1854+
1855+ const openBraceMap : ts . Map < ts . CharacterCodes > = {
1856+ "(" : ts . CharacterCodes . openParen ,
1857+ "{" : ts . CharacterCodes . openBrace ,
1858+ "[" : ts . CharacterCodes . openBracket ,
1859+ "'" : ts . CharacterCodes . singleQuote ,
1860+ '"' : ts . CharacterCodes . doubleQuote ,
1861+ "`" : ts . CharacterCodes . backtick ,
1862+ "<" : ts . CharacterCodes . lessThan
1863+ } ;
1864+
1865+ const charCode = openBraceMap [ openingBrace ] ;
1866+
1867+ if ( ! charCode ) {
1868+ this . raiseError ( `Invalid openingBrace '${ openingBrace } ' specified.` ) ;
1869+ }
1870+
1871+ const position = this . currentCaretPosition ;
1872+
1873+ const validBraceCompletion = this . languageService . isValidBraceCompletionAtPostion ( this . activeFile . fileName , position , charCode ) ;
1874+
1875+ if ( ! negative && ! validBraceCompletion ) {
1876+ this . raiseError ( `${ position } is not a valid brace completion position for ${ openingBrace } ` ) ;
1877+ }
1878+
1879+ if ( negative && validBraceCompletion ) {
1880+ this . raiseError ( `${ position } is a valid brace completion position for ${ openingBrace } ` ) ;
1881+ }
1882+ }
1883+
18531884 public verifyMatchingBracePosition ( bracePosition : number , expectedMatchPosition : number ) {
18541885 const actual = this . languageService . getBraceMatchingAtPosition ( this . activeFile . fileName , bracePosition ) ;
18551886
@@ -2239,7 +2270,7 @@ namespace FourSlash {
22392270 } ;
22402271
22412272 const host = Harness . Compiler . createCompilerHost (
2242- [ fourslashFile , testFile ] ,
2273+ [ fourslashFile , testFile ] ,
22432274 ( fn , contents ) => result = contents ,
22442275 ts . ScriptTarget . Latest ,
22452276 Harness . IO . useCaseSensitiveFileNames ( ) ,
@@ -2264,7 +2295,7 @@ namespace FourSlash {
22642295 function runCode ( code : string , state : TestState ) : void {
22652296 // Compile and execute the test
22662297 const wrappedCode =
2267- `(function(test, goTo, verify, edit, debug, format, cancellation, classification, verifyOperationIsCancelled) {
2298+ `(function(test, goTo, verify, edit, debug, format, cancellation, classification, verifyOperationIsCancelled) {
22682299${ code }
22692300})` ;
22702301 try {
@@ -2378,7 +2409,7 @@ ${code}
23782409 }
23792410 }
23802411 }
2381- // TODO: should be '==='?
2412+ // TODO: should be '==='?
23822413 }
23832414 else if ( line == "" || lineLength === 0 ) {
23842415 // Previously blank lines between fourslash content caused it to be considered as 2 files,
@@ -2870,6 +2901,10 @@ namespace FourSlashInterface {
28702901 public verifyDefinitionsName ( name : string , containerName : string ) {
28712902 this . state . verifyDefinitionsName ( this . negative , name , containerName ) ;
28722903 }
2904+
2905+ public isValidBraceCompletionAtPostion ( openingBrace : string ) {
2906+ this . state . verifyBraceCompletionAtPostion ( this . negative , openingBrace ) ;
2907+ }
28732908 }
28742909
28752910 export class Verify extends VerifyNegatable {
@@ -3088,7 +3123,7 @@ namespace FourSlashInterface {
30883123 this . state . getSemanticDiagnostics ( expected ) ;
30893124 }
30903125
3091- public ProjectInfo ( expected : string [ ] ) {
3126+ public ProjectInfo ( expected : string [ ] ) {
30923127 this . state . verifyProjectInfo ( expected ) ;
30933128 }
30943129 }
0 commit comments