File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 11const vscode = require ( 'vscode' ) ;
22const client = require ( './client.js' ) ;
33
4+ /**
5+ * 定义跳转
6+ * @param {vscode.TextDocument } document
7+ * @param {vscode.Position } position
8+ * @param {vscode.CancellationToken } token
9+ */
10+ function provideDefinition ( document , position , token ) {
11+ const word = document . getText ( document . getWordRangeAtPosition ( position ) ) ;
12+ if ( word . startsWith ( 'Q' ) || word . startsWith ( '#' ) ) {
13+ console . log ( 'provideDefinition: ' + word ) ;
14+ }
15+ }
16+
417/**
518 * 插件被激活时触发
619 * @param {vscode.ExtensionContext } context
@@ -21,6 +34,15 @@ function activate(context) {
2134 client . setPort ( ) ;
2235 } ) ) ;
2336
37+ // 注册跳转定义
38+ context . subscriptions . push ( vscode . languages . registerDefinitionProvider ( {
39+ scheme : 'file' ,
40+ language : 'css' ,
41+ pattern : '**/*.{css,qss,style}'
42+ } , {
43+ provideDefinition
44+ } ) ) ;
45+
2446 // 注册事件
2547 vscode . workspace . onDidChangeTextDocument ( client . onDidChangeTextDocument ) ;
2648 vscode . workspace . onDidSaveTextDocument ( client . onDidSaveTextDocument ) ;
You can’t perform that action at this time.
0 commit comments