File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
web/src/components/features/workspace/CodeEditor/autocomplete/symbols Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,33 @@ describe('parseQuery', () => {
3737 } )
3838 } )
3939
40+ test ( 'should match function call argument' , ( ) => {
41+ testParseExpression ( '(foo.bar' , {
42+ packageName : 'foo' ,
43+ value : 'bar' ,
44+ } )
45+ } )
46+
47+ test ( 'should match values near operators' , ( ) => {
48+ testParseExpression ( '+ foo' , {
49+ value : 'foo' ,
50+ } )
51+ } )
52+
53+ test ( 'should match pointer types' , ( ) => {
54+ testParseExpression ( '(t *testing.T' , {
55+ packageName : 'testing' ,
56+ value : 'T' ,
57+ } )
58+ } )
59+
4060 test ( 'should omit unmatched long expressions' , ( ) => {
4161 testParseExpression ( 'foo.bar.baz' , null )
4262 } )
63+
64+ test ( 'should not match inside string statement' , ( ) => {
65+ testParseExpression ( '" foo' , null )
66+ testParseExpression ( '"foo' , null )
67+ testParseExpression ( '`foo' , null )
68+ } )
4369} )
Original file line number Diff line number Diff line change 11// Matches package (and method name)
2- const queryRegexp = / ( ^ | \s ) ( [ a - z 0 - 9 _ ] + ) ( \. ( [ a - z 0 - 9 _ ] + ) ? ) ? $ / i
2+ //
3+ // See: parse.test.ts
4+ const queryRegexp = / (?< ! [ " ` ] ) ( ^ | \s | \( | \{ | \* | & | \+ | - | \/ | \| | = ) ( [ a - z 0 - 9 _ ] + ) ( \. ( [ a - z 0 - 9 _ ] + ) ? ) ? $ / i
35
46export const parseExpression = ( expr : string ) => {
57 queryRegexp . lastIndex = 0 // Reset regex state
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export class GoSymbolsCompletionItemProvider extends CacheBasedCompletionProvide
4848 . trim ( )
4949
5050 const query = parseExpression ( val )
51+ console . log ( 'expr' , query )
5152 if ( ! query ) {
5253 return null
5354 }
You can’t perform that action at this time.
0 commit comments