diff --git a/src/server/navigation.ts b/src/server/navigation.ts index 754a3c2..84b048b 100644 --- a/src/server/navigation.ts +++ b/src/server/navigation.ts @@ -342,7 +342,7 @@ function searchInScope( return; } -function searchVariableBinding( +function searchDeclaration( reference: Reference, search: Search, dec: Node, @@ -366,6 +366,15 @@ function searchVariableBinding( body, } : undefined, + ) || + matchNode(dec, 'ClassD', (_sharedPat: any, name: string) => + name === search.name + ? { + uri: reference.uri, + cursor: dec, // TODO: cursor on variable name + body: dec, + } + : undefined, ) ); } @@ -375,14 +384,25 @@ function searchTypeBinding( search: Search, dec: Node, ): Definition | undefined { - return matchNode(dec, 'TypD', (name: string, typ: Node) => - name === search.name - ? { - uri: reference.uri, - cursor: typ, // TODO: source location from `name` - body: typ, - } - : undefined, + return ( + matchNode(dec, 'TypD', (name: string, typ: Node) => + name === search.name + ? { + uri: reference.uri, + cursor: typ, // TODO: source location from `name` + body: typ, + } + : undefined, + ) || + matchNode(dec, 'ClassD', (_sharedPat: any, name: string) => + name === search.name + ? { + uri: reference.uri, + cursor: dec, // TODO: cursor on variable name + body: dec, + } + : undefined, + ) ); } @@ -401,7 +421,7 @@ function searchObject( let definition: Definition | undefined; if (search.type === 'variable') { definition = - searchVariableBinding(reference, search, arg) || + searchDeclaration(reference, search, arg) || matchNode( arg, 'ExpField', @@ -413,7 +433,7 @@ function searchObject( }, ) || matchNode(arg, 'DecField', (dec: Node) => - searchVariableBinding(reference, search, dec), + searchDeclaration(reference, search, dec), ) || matchNode( arg, @@ -424,7 +444,7 @@ function searchObject( field, 'DecField', (dec: Node) => - searchVariableBinding( + searchDeclaration( reference, search, dec,