File tree Expand file tree Collapse file tree 4 files changed +31
-3
lines changed
Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 15231523 "syntax" : " { top\n | bottom\n | left\n | right\n | center }*"
15241524 },
15251525 {
1526- "name" : " titlebar-show-tooltips-on-buttons} " ,
1526+ "name" : " titlebar-show-tooltips-on-buttons" ,
15271527 "description" : {
15281528 "kind" : " markdown" ,
15291529 "value" : " Whether tool tips are shown on window title bar buttons."
Original file line number Diff line number Diff line change 1010"""
1111
1212from collections import OrderedDict
13+ import os
1314import re
1415import json
16+ import sys
1517import requests
1618from pyquery import PyQuery
1719
@@ -96,7 +98,8 @@ def generate_props(doc):
9698 d ['url' ] = 'https://doc.qt.io/qt-5/stylesheet-reference.html#list-of-properties'
9799 references .append (d )
98100
99- prop ['name' ] = tds [0 ].text ().replace ('*' , '' ).strip ()
101+ prop ['name' ] = tds [0 ].text ().replace ('*' ,
102+ '' ).strip ().strip ('{' ).strip ('}' )
100103 prop ['description' ] = desc
101104 prop ['references' ] = references
102105 if syntax in g_syntax :
@@ -139,6 +142,8 @@ def generate_pseudoElements(doc):
139142 data ['properties' ] = generate_props (doc )
140143 data ['pseudoClasses' ] = generate_pseudoClasses (doc )
141144 data ['pseudoElements' ] = generate_pseudoElements (doc )
142- with open ('../data/qss.json' , 'wb' ) as fp :
145+ with open (
146+ os .path .join (os .path .dirname (os .path .dirname (sys .argv [0 ])), 'data' ,
147+ 'qss.json' ), 'wb' ) as fp :
143148 fp .write (json .dumps (data , indent = 4 ).encode ())
144149 print ('generate qss.json finished' )
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ function applyStyle(doc) {
8989 styleSheets . push ( document . getText ( ) ) ;
9090 }
9191
92+ if ( styleSheets . length == 0 ) return ;
9293 g_client . notify ( 'setStyleSheet' , styleSheets ) ;
9394} ;
9495
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