File tree 3 files changed +30
-1
lines changed
web/src/components/features/workspace/CodeEditor/autocomplete/symbols
3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,33 @@ describe('parseQuery', () => {
37
37
} )
38
38
} )
39
39
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
+
40
60
test ( 'should omit unmatched long expressions' , ( ) => {
41
61
testParseExpression ( 'foo.bar.baz' , null )
42
62
} )
63
+
64
+ test ( 'should not match inside string statement' , ( ) => {
65
+ testParseExpression ( '" foo' , null )
66
+ testParseExpression ( '"foo' , null )
67
+ testParseExpression ( '`foo' , null )
68
+ } )
43
69
} )
Original file line number Diff line number Diff line change 1
1
// 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
3
5
4
6
export const parseExpression = ( expr : string ) => {
5
7
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
48
48
. trim ( )
49
49
50
50
const query = parseExpression ( val )
51
+ console . log ( 'expr' , query )
51
52
if ( ! query ) {
52
53
return null
53
54
}
You can’t perform that action at this time.
0 commit comments