Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,33 @@ describe('parseQuery', () => {
})
})

test('should match function call argument', () => {
testParseExpression('(foo.bar', {
packageName: 'foo',
value: 'bar',
})
})

test('should match values near operators', () => {
testParseExpression('+ foo', {
value: 'foo',
})
})

test('should match pointer types', () => {
testParseExpression('(t *testing.T', {
packageName: 'testing',
value: 'T',
})
})

test('should omit unmatched long expressions', () => {
testParseExpression('foo.bar.baz', null)
})

test('should not match inside string statement', () => {
testParseExpression('" foo', null)
testParseExpression('"foo', null)
testParseExpression('`foo', null)
})
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Matches package (and method name)
const queryRegexp = /(^|\s)([a-z0-9_]+)(\.([a-z0-9_]+)?)?$/i
//
// See: parse.test.ts
const queryRegexp = /(?<!["`])(^|\s|\(|\{|\*|&|\+|-|\/|\||=)([a-z0-9_]+)(\.([a-z0-9_]+)?)?$/i

export const parseExpression = (expr: string) => {
queryRegexp.lastIndex = 0 // Reset regex state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class GoSymbolsCompletionItemProvider extends CacheBasedCompletionProvide
.trim()

const query = parseExpression(val)
console.log('expr', query)
if (!query) {
return null
}
Expand Down
Loading