@@ -8,7 +8,7 @@ Please refer to their documentation on https://mochajs.org/ for help.
8
8
import * as path from "path" ;
9
9
import * as vscode from "vscode" ;
10
10
import * as yara from "../yara/src/extension" ;
11
- import { YaraCompletionItemProvider } from "../yara/src/modules " ;
11
+ import { YaraCompletionItemProvider } from "../yara/src/completionProvider " ;
12
12
13
13
let workspace = path . join ( __dirname , ".." , ".." , "test/rules/" ) ;
14
14
@@ -146,14 +146,20 @@ suite("YARA: Provider", function () {
146
146
} ) ;
147
147
148
148
test ( "code completion" , function ( done ) {
149
- const filepath : string = path . join ( workspace , "peek_rules .yara" ) ;
149
+ const filepath : string = path . join ( workspace , "code_completion .yara" ) ;
150
150
vscode . workspace . openTextDocument ( filepath ) . then ( function ( doc ) {
151
151
const ccProvider : YaraCompletionItemProvider = new YaraCompletionItemProvider ( ) ;
152
- // ModuleCompletionExample : Line 53 , Col 12
153
- let pos : vscode . Position = new vscode . Position ( 52 , 12 ) ;
152
+ // "cuckoo." : Line 8 , Col 12
153
+ let pos : vscode . Position = new vscode . Position ( 7 , 12 ) ;
154
154
let tokenSource : vscode . CancellationTokenSource = new vscode . CancellationTokenSource ( ) ;
155
- let items = ccProvider . provideCompletionItems ( doc , pos , tokenSource . token , undefined ) ;
156
- console . log ( items ) ;
155
+ ccProvider . provideCompletionItems ( doc , pos , tokenSource . token , undefined ) . then ( function ( items ) {
156
+ if ( items [ 0 ] . label == "network" || items [ 0 ] . kind == vscode . CompletionItemKind . Class &&
157
+ items [ 1 ] . label == "registry" || items [ 1 ] . kind == vscode . CompletionItemKind . Class &&
158
+ items [ 2 ] . label == "filesystem" || items [ 2 ] . kind == vscode . CompletionItemKind . Class &&
159
+ items [ 3 ] . label == "sync" || items [ 3 ] . kind == vscode . CompletionItemKind . Class ) {
160
+ done ( ) ;
161
+ }
162
+ } ) ;
157
163
} ) ;
158
164
} ) ;
159
165
0 commit comments