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
2 changes: 1 addition & 1 deletion internal/ls/documenthighlights.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen
}

func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight {
options := refOptions{use: referenceUseReferences}
options := refOptions{use: referenceUseNone}
referenceEntries := l.getReferencedSymbolsForNode(ctx, position, node, program, []*ast.SourceFile{sourceFile}, options, &collections.Set[string]{})
if referenceEntries == nil {
return nil
Expand Down
4 changes: 4 additions & 0 deletions internal/ls/findallreferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit
}
}

if options.use == referenceUseReferences || options.use == referenceUseRename {
node = getAdjustedLocation(node, options.use == referenceUseRename, ast.GetSourceFileOfNode(node))
}

checker, done := program.GetTypeChecker(ctx)
defer done()

Expand Down
2 changes: 1 addition & 1 deletion internal/ls/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF
// specially by `getSymbolAtLocation`.
isModifier := func(node *ast.Node) bool {
if ast.IsModifier(node) && (forRename || node.Kind != ast.KindDefaultKeyword) {
return ast.CanHaveModifiers(parent) && slices.Contains(parent.Modifiers().NodeList.Nodes, node)
return ast.CanHaveModifiers(parent) && parent.Modifiers() != nil && slices.Contains(parent.Modifiers().NodeList.Nodes, node)
}
switch node.Kind {
case ast.KindClassKeyword:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// === findAllReferences ===
// === /constructorFindAllReferences1.ts ===
// export class C {
// /*FIND ALL REFS*/public constructor() { }
// /*FIND ALL REFS*/public [|constructor|]() { }
// public foo() { }
// }
//
// new C().foo();
// new [|C|]().foo();
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// === findAllReferences ===
// === /constructorFindAllReferences2.ts ===
// export class C {
// /*FIND ALL REFS*/private constructor() { }
// /*FIND ALL REFS*/private [|constructor|]() { }
// public foo() { }
// }
//
// new C().foo();
// new [|C|]().foo();
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// === findAllReferences ===
// === /constructorFindAllReferences4.ts ===
// export class C {
// /*FIND ALL REFS*/protected constructor() { }
// /*FIND ALL REFS*/protected [|constructor|]() { }
// public foo() { }
// }
//
// new C().foo();
// new [|C|]().foo();
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// === /foo.ts ===
// export function foo() { return "foo"; }
// import("./foo")
// /*FIND ALL REFS*/var x = import("./foo")
// /*FIND ALL REFS*/var [|x|] = import("./foo")



Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /foo.ts ===
// /*FIND ALL REFS*/import settings from "./settings.json";
// settings;
// /*FIND ALL REFS*/import [|settings|] from "./settings.json";
// [|settings|];



Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// === findAllReferences ===
// === /findAllRefsDeclareClass.ts ===
// /*FIND ALL REFS*/declare class C {
// /*FIND ALL REFS*/declare class [|C|] {
// static m(): void;
// }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /findAllRefsEnumAsNamespace.ts ===
// /*FIND ALL REFS*/enum E { A }
// let e: E.A;
// /*FIND ALL REFS*/enum [|E|] { A }
// let e: [|E|].A;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// === findAllReferences ===
// === /a.ts ===
// type T = number;
// /*FIND ALL REFS*/[|export|] = T;
// /*FIND ALL REFS*/export = [|T|];

// === /b.ts ===
// import T = require("[|./a|]");
// import [|T|] = require("./a");



Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// === findAllReferences ===
// === /findAllRefsForDefaultExport01.ts ===
// /*FIND ALL REFS*/export default class DefaultExportedClass {
// /*FIND ALL REFS*/export default class [|DefaultExportedClass|] {
// }
//
// var x: DefaultExportedClass;
// var x: [|DefaultExportedClass|];
//
// var y = new DefaultExportedClass;
// var y = new [|DefaultExportedClass|];



Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// === findAllReferences ===
// === /findAllRefsForDefaultExport02.ts ===
// /*FIND ALL REFS*/export default function DefaultExportedFunction() {
// return DefaultExportedFunction;
// /*FIND ALL REFS*/export default function [|DefaultExportedFunction|]() {
// return [|DefaultExportedFunction|];
// }
//
// // --- (line: 5) skipped ---
// var x: typeof [|DefaultExportedFunction|];
//
// var y = [|DefaultExportedFunction|]();
//
// namespace DefaultExportedFunction {
// }



Expand Down Expand Up @@ -74,7 +79,7 @@
//
// var y = DefaultExportedFunction();
//
// /*FIND ALL REFS*/namespace DefaultExportedFunction {
// /*FIND ALL REFS*/namespace [|DefaultExportedFunction|] {
// }


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /findAllRefsForVariableInExtendsClause01.ts ===
// /*FIND ALL REFS*/var Base = class { };
// class C extends Base { }
// /*FIND ALL REFS*/var [|Base|] = class { };
// class C extends [|Base|] { }



Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// === findAllReferences ===
// === /findAllRefsForVariableInExtendsClause02.ts ===
// /*FIND ALL REFS*/interface Base { }
// /*FIND ALL REFS*/interface [|Base|] { }
// namespace n {
// var Base = class { };
// interface I extends Base { }
// interface I extends [|Base|] { }
// }


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// === findAllReferences ===
// === /a.js ===
// module.exports = 0;
// /*FIND ALL REFS*/export type N = number;
// /*FIND ALL REFS*/export type [|N|] = number;

// === /b.js ===
// type T = import("./a").[|N|];



Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /findAllRefsInsideTemplates1.ts ===
// /*FIND ALL REFS*/var x = 10;
// var y = `${ x } ${ x }`
// /*FIND ALL REFS*/var [|x|] = 10;
// var y = `${ [|x|] } ${ [|x|] }`



Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /findAllRefsInsideTemplates2.ts ===
// /*FIND ALL REFS*/function f(...rest: any[]) { }
// f `${ f } ${ f }`
// /*FIND ALL REFS*/function [|f|](...rest: any[]) { }
// [|f|] `${ [|f|] } ${ [|f|] }`



Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// === findAllReferences ===
// === /findAllRefsInsideWithBlock.ts ===
// /*FIND ALL REFS*/var x = 0;
// /*FIND ALL REFS*/var [|x|] = 0;
//
// with ({}) {
// var y = x; // Reference of x here should not be picked
// // --- (line: 5) skipped ---
// y++; // also reference for y should be ignored
// }
//
// [|x|] = [|x|] + 1;



Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
// === findAllReferences ===
// === /a.ts ===
// /*FIND ALL REFS*/function decorator(target) {
// /*FIND ALL REFS*/function [|decorator|](target) {
// return target;
// }
// decorator();
// [|decorator|]();

// === /b.ts ===
// @[|decorator|] @[|decorator|]("again")
// class C {
// @[|decorator|]
// method() {}
// }



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
//
// }
//
// /*FIND ALL REFS*/public start(){
// /*FIND ALL REFS*/public [|start|](){
// return this;
// }
//
// // --- (line: 11) skipped ---

// === /findAllRefsOnDefinition.ts ===
// import Second = require("./findAllRefsOnDefinition-import");
//
// var second = new Second.Test()
// second.[|start|]();
// second.stop();



// === findAllReferences ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
// === /findAllRefsOnDefinition2-import.ts ===
// export module Test{
//
// /*FIND ALL REFS*/export interface start { }
// /*FIND ALL REFS*/export interface [|start|] { }
//
// export interface stop { }
// }

// === /findAllRefsOnDefinition2.ts ===
// import Second = require("./findAllRefsOnDefinition2-import");
//
// var start: Second.Test.[|start|];
// var stop: Second.Test.stop;



// === findAllReferences ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// === findAllReferences ===
// === /findAllRefsOnPrivateParameterProperty1.ts ===
// class ABCD {
// constructor(private x: number, public y: number, /*FIND ALL REFS*/private z: number) {
// constructor(private x: number, public y: number, /*FIND ALL REFS*/private [|z|]: number) {
// }
//
// func() {
// // --- (line: 6) skipped ---
// return this.[|z|];
// }
// }



Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// === findAllReferences ===
// === /findAllRefsPrivateNameAccessors.ts ===
// class C {
// /*FIND ALL REFS*/get #foo(){ return 1; }
// set #foo(value: number){ }
// /*FIND ALL REFS*/get [|#foo|](){ return 1; }
// set [|#foo|](value: number){ }
// constructor() {
// this.#foo();
// // --- (line: 6) skipped ---
// this.[|#foo|]();
// }
// }
// class D extends C {
// // --- (line: 9) skipped ---



Expand All @@ -26,12 +29,14 @@
// === findAllReferences ===
// === /findAllRefsPrivateNameAccessors.ts ===
// class C {
// get #foo(){ return 1; }
// /*FIND ALL REFS*/set #foo(value: number){ }
// get [|#foo|](){ return 1; }
// /*FIND ALL REFS*/set [|#foo|](value: number){ }
// constructor() {
// this.#foo();
// this.[|#foo|]();
// }
// // --- (line: 7) skipped ---
// }
// class D extends C {
// // --- (line: 9) skipped ---



Expand Down Expand Up @@ -69,10 +74,10 @@
// }
// }
// class E {
// /*FIND ALL REFS*/get #foo(){ return 1; }
// set #foo(value: number){ }
// /*FIND ALL REFS*/get [|#foo|](){ return 1; }
// set [|#foo|](value: number){ }
// constructor() {
// this.#foo();
// this.[|#foo|]();
// }
// }

Expand All @@ -95,13 +100,14 @@

// === findAllReferences ===
// === /findAllRefsPrivateNameAccessors.ts ===
// --- (line: 12) skipped ---
// --- (line: 11) skipped ---
// }
// }
// class E {
// get #foo(){ return 1; }
// /*FIND ALL REFS*/set #foo(value: number){ }
// get [|#foo|](){ return 1; }
// /*FIND ALL REFS*/set [|#foo|](value: number){ }
// constructor() {
// this.#foo();
// this.[|#foo|]();
// }
// }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// === findAllReferences ===
// === /findAllRefsWithLeadingUnderscoreNames1.ts ===
// class Foo {
// /*FIND ALL REFS*/public _bar() { return 0; }
// /*FIND ALL REFS*/public [|_bar|]() { return 0; }
// }
//
// var x: Foo;
// x._bar;
// x.[|_bar|];



Expand Down
Loading