diff --git a/integrationtests/fixtures/snapshots/go/diagnostics/dependency.snap b/integrationtests/fixtures/snapshots/go/diagnostics/dependency.snap index d721535..1b8059b 100644 --- a/integrationtests/fixtures/snapshots/go/diagnostics/dependency.snap +++ b/integrationtests/fixtures/snapshots/go/diagnostics/dependency.snap @@ -1,34 +1,12 @@ -=== +--- + /TEST_OUTPUT/workspace/consumer.go -Location: Line 7, Column 28 -Message: not enough arguments in call to HelperFunction +Diagnostics in File: 1 +ERROR at L7:C28: not enough arguments in call to HelperFunction have () - want (int) -Source: compiler -Code: WrongArgCount -=== + want (int) (Source: compiler, Code: WrongArgCount) + 6|func ConsumerFunction() { 7| message := HelperFunction() 8| fmt.Println(message) 9| -10| // Use shared struct -11| s := &SharedStruct{ -12| ID: 1, -13| Name: "test", -14| Value: 42.0, -15| Constants: []string{SharedConstant}, -16| } -17| -18| // Call methods on the struct -19| fmt.Println(s.Method()) -20| s.Process() -21| -22| // Use shared interface -23| var iface SharedInterface = s -24| fmt.Println(iface.GetName()) -25| -26| // Use shared type -27| var t SharedType = 100 -28| fmt.Println(t) -29|} - diff --git a/integrationtests/fixtures/snapshots/go/diagnostics/unreachable.snap b/integrationtests/fixtures/snapshots/go/diagnostics/unreachable.snap index 7a76560..ca07c91 100644 --- a/integrationtests/fixtures/snapshots/go/diagnostics/unreachable.snap +++ b/integrationtests/fixtures/snapshots/go/diagnostics/unreachable.snap @@ -1,24 +1,11 @@ -=== -/TEST_OUTPUT/workspace/main.go -Location: Line 8, Column 2 -Message: unreachable code -Source: unreachable -Code: default -=== - 6|func FooBar() string { - 7| return "Hello, World!" - 8| fmt.Println("Unreachable code") // This is unreachable code - 9|} +--- -=== /TEST_OUTPUT/workspace/main.go -Location: Line 9, Column 1 -Message: missing return -Source: compiler -Code: MissingReturn -=== +Diagnostics in File: 2 +WARNING at L8:C2: unreachable code (Source: unreachable, Code: default) +ERROR at L9:C1: missing return (Source: compiler, Code: MissingReturn) + 6|func FooBar() string { 7| return "Hello, World!" 8| fmt.Println("Unreachable code") // This is unreachable code 9|} - diff --git a/integrationtests/fixtures/snapshots/python/diagnostics/dependency.snap b/integrationtests/fixtures/snapshots/python/diagnostics/dependency.snap index 5a733f0..da1e997 100644 --- a/integrationtests/fixtures/snapshots/python/diagnostics/dependency.snap +++ b/integrationtests/fixtures/snapshots/python/diagnostics/dependency.snap @@ -1,18 +1,12 @@ -=== +--- + /TEST_OUTPUT/workspace/consumer_clean.py -Location: Line 9, Column 15 -Message: Argument missing for parameter "age" -Source: Pyright -Code: reportCallIssue -=== +Diagnostics in File: 1 +ERROR at L9:C15: Argument missing for parameter "age" (Source: Pyright, Code: reportCallIssue) + 6|def consumer_function() -> None: 7| """Function that consumes the helper functions.""" 8| # Use the helper function 9| message = helper_function("World") 10| print(message) 11| -12| # Get and process items from the helper -13| items = get_items() -14| for item in items: -15| print(f"Processing {item}") - diff --git a/integrationtests/fixtures/snapshots/python/diagnostics/errors.snap b/integrationtests/fixtures/snapshots/python/diagnostics/errors.snap index d586c37..4c2e62f 100644 --- a/integrationtests/fixtures/snapshots/python/diagnostics/errors.snap +++ b/integrationtests/fixtures/snapshots/python/diagnostics/errors.snap @@ -1,46 +1,26 @@ -=== +--- + /TEST_OUTPUT/workspace/error_file.py -Location: Line 31, Column 12 -Message: Type "Literal[42]" is not assignable to return type "str" -  "Literal[42]" is not assignable to "str" -Source: Pyright -Code: reportReturnType -=== +Diagnostics in File: 3 +ERROR at L31:C12: Type "Literal[42]" is not assignable to return type "str" +  "Literal[42]" is not assignable to "str" (Source: Pyright, Code: reportReturnType) +ERROR at L47:C15: "undefined_variable" is not defined (Source: Pyright, Code: reportUndefinedVariable) +ERROR at L51:C19: Type "Literal[123]" is not assignable to declared type "str" +  "Literal[123]" is not assignable to "str" (Source: Pyright, Code: reportAssignmentType) + 25|def function_with_type_error() -> str: -26| """A function with a type error. -27| -28| Returns: +... 29| Should return a string but actually returns an int 30| """ 31| return 42 # Type error: Incompatible return value type (got "int", expected "str") - -=== -/TEST_OUTPUT/workspace/error_file.py -Location: Line 47, Column 15 -Message: "undefined_variable" is not defined -Source: Pyright -Code: reportUndefinedVariable -=== +... 34|class ErrorClass: -35| """A class with errors.""" -36| -37| def __init__(self, value: dict[str, Any]): -38| """Initialize with errors. -39| -40| Args: -41| value: A dictionary -42| """ -43| self.value = value -44| +... 45| def method_with_undefined_variable(self) -> None: 46| """A method that uses an undefined variable.""" 47| print(undefined_variable) # Error: undefined_variable is not defined - -=== -/TEST_OUTPUT/workspace/error_file.py -Location: Line 51, Column 19 -Message: Type "Literal[123]" is not assignable to declared type "str" -  "Literal[123]" is not assignable to "str" -Source: Pyright -Code: reportAssignmentType -=== \ No newline at end of file +... +49| +50|# Variable with incompatible type annotation +51|wrong_type: str = 123 # Type error: Incompatible types in assignment +52| diff --git a/integrationtests/fixtures/snapshots/python/references/class-method.snap b/integrationtests/fixtures/snapshots/python/references/class-method.snap index 63dcffa..716e910 100644 --- a/integrationtests/fixtures/snapshots/python/references/class-method.snap +++ b/integrationtests/fixtures/snapshots/python/references/class-method.snap @@ -1,12 +1,11 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.py References in File: 1 -=== -Reference at Line 40, Column 19: +At: L40:C19 + 31|def another_consumer_function() -> None: -32| """Another function that uses various shared components.""" -33| # Use shared constants -34| print(f"Using constant: {SHARED_CONSTANT}") +... 35| 36| # Use shared class with a different type parameter 37| shared = SharedClass[float]("another example", 3.14) @@ -18,30 +17,15 @@ Reference at Line 40, Column 19: 43| 44| # Use our own implementation 45| impl = AnotherImplementation() -46| result = impl.do_something() -47| print(f"Implementation result: {result}") -48| -49| # Use helper function -50| output = helper_function("another direct call") -51| print(f"Helper output: {output}") -52| -53| # Use enum-like class with a different color -54| color = Color.GREEN -55| print(f"Selected color: {color}") -=== +--- + /TEST_OUTPUT/workspace/consumer.py References in File: 1 -=== -Reference at Line 47, Column 41: +At: L47:C41 + 34|def consumer_function() -> None: -35| """Function that consumes the helper functions.""" -36| # Use the helper function -37| message = helper_function("World") -38| print(message) -39| -40| # Get and process items from the helper -41| items = get_items() +... 42| for item in items: 43| print(f"Processing {item}") 44| @@ -53,8 +37,3 @@ Reference at Line 47, Column 41: 50| impl = MyImplementation() 51| result = impl.process(items) 52| print(f"Processed items: {result}") -53| -54| # Use the enum -55| color = Color.RED -56| print(f"Selected color: {color}") - diff --git a/integrationtests/fixtures/snapshots/python/references/color-enum.snap b/integrationtests/fixtures/snapshots/python/references/color-enum.snap index d164c1e..a288d0e 100644 --- a/integrationtests/fixtures/snapshots/python/references/color-enum.snap +++ b/integrationtests/fixtures/snapshots/python/references/color-enum.snap @@ -1,26 +1,23 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.py References in File: 2 -=== -Reference at Line 54, Column 13: +At: L7:C5, L54:C13 + + 2| + 3|from helper import ( + 4| SHARED_CONSTANT, + 5| SharedClass, + 6| helper_function, + 7| Color, + 8|) + 9| +10| +11|class AnotherImplementation: +12| """A class that uses shared components but doesn't implement interfaces.""" +... 31|def another_consumer_function() -> None: -32| """Another function that uses various shared components.""" -33| # Use shared constants -34| print(f"Using constant: {SHARED_CONSTANT}") -35| -36| # Use shared class with a different type parameter -37| shared = SharedClass[float]("another example", 3.14) -38| -39| # Use methods from shared class -40| name = shared.get_name() -41| value = shared.get_value() -42| print(f"Name: {name}, Value: {value}") -43| -44| # Use our own implementation -45| impl = AnotherImplementation() -46| result = impl.do_something() -47| print(f"Implementation result: {result}") -48| +... 49| # Use helper function 50| output = helper_function("another direct call") 51| print(f"Helper output: {output}") @@ -29,27 +26,26 @@ Reference at Line 54, Column 13: 54| color = Color.GREEN 55| print(f"Selected color: {color}") -=== +--- + /TEST_OUTPUT/workspace/consumer.py References in File: 2 -=== -Reference at Line 55, Column 13: +At: L9:C5, L55:C13 + + 4| helper_function, + 5| get_items, + 6| SharedClass, + 7| SharedInterface, + 8| SHARED_CONSTANT, + 9| Color, +10|) +11| +12| +13|class MyImplementation(SharedInterface): +14| """An implementation of the SharedInterface.""" +... 34|def consumer_function() -> None: -35| """Function that consumes the helper functions.""" -36| # Use the helper function -37| message = helper_function("World") -38| print(message) -39| -40| # Get and process items from the helper -41| items = get_items() -42| for item in items: -43| print(f"Processing {item}") -44| -45| # Use the shared class -46| shared = SharedClass[str]("consumer", SHARED_CONSTANT) -47| print(f"Using shared class: {shared.get_name()} - {shared.get_value()}") -48| -49| # Use our implementation of the shared interface +... 50| impl = MyImplementation() 51| result = impl.process(items) 52| print(f"Processed items: {result}") @@ -57,4 +53,3 @@ Reference at Line 55, Column 13: 54| # Use the enum 55| color = Color.RED 56| print(f"Selected color: {color}") - diff --git a/integrationtests/fixtures/snapshots/python/references/helper-function.snap b/integrationtests/fixtures/snapshots/python/references/helper-function.snap index e8745b5..cd39a35 100644 --- a/integrationtests/fixtures/snapshots/python/references/helper-function.snap +++ b/integrationtests/fixtures/snapshots/python/references/helper-function.snap @@ -1,43 +1,30 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.py References in File: 3 -=== -Reference at Line 28, Column 16: +At: L6:C5, L28:C16, L50:C14 + + 1|"""Another module that uses helpers and shared components.""" + 2| + 3|from helper import ( + 4| SHARED_CONSTANT, + 5| SharedClass, + 6| helper_function, + 7| Color, + 8|) + 9| +10| 11|class AnotherImplementation: -12| """A class that uses shared components but doesn't implement interfaces.""" -13| -14| def __init__(self): -15| """Initialize the implementation.""" -16| self.shared = SharedClass[str]("another", SHARED_CONSTANT) -17| -18| def do_something(self) -> str: -19| """Do something with the shared components. -20| -21| Returns: -22| The processed result +... 23| """ 24| # Get the value from shared class 25| value = self.shared.get_value() 26| 27| # Process it using the helper function 28| return helper_function(value) - - -Reference at Line 50, Column 14: +... 31|def another_consumer_function() -> None: -32| """Another function that uses various shared components.""" -33| # Use shared constants -34| print(f"Using constant: {SHARED_CONSTANT}") -35| -36| # Use shared class with a different type parameter -37| shared = SharedClass[float]("another example", 3.14) -38| -39| # Use methods from shared class -40| name = shared.get_name() -41| value = shared.get_value() -42| print(f"Name: {name}, Value: {value}") -43| -44| # Use our own implementation +... 45| impl = AnotherImplementation() 46| result = impl.do_something() 47| print(f"Implementation result: {result}") @@ -50,11 +37,22 @@ Reference at Line 50, Column 14: 54| color = Color.GREEN 55| print(f"Selected color: {color}") -=== +--- + /TEST_OUTPUT/workspace/consumer.py References in File: 2 -=== -Reference at Line 37, Column 15: +At: L4:C5, L37:C15 + + 1|"""Consumer module that uses the helper module.""" + 2| + 3|from helper import ( + 4| helper_function, + 5| get_items, + 6| SharedClass, + 7| SharedInterface, + 8| SHARED_CONSTANT, + 9| Color, +... 34|def consumer_function() -> None: 35| """Function that consumes the helper functions.""" 36| # Use the helper function @@ -64,26 +62,18 @@ Reference at Line 37, Column 15: 40| # Get and process items from the helper 41| items = get_items() 42| for item in items: -43| print(f"Processing {item}") -44| -45| # Use the shared class -46| shared = SharedClass[str]("consumer", SHARED_CONSTANT) -47| print(f"Using shared class: {shared.get_name()} - {shared.get_value()}") -48| -49| # Use our implementation of the shared interface -50| impl = MyImplementation() -51| result = impl.process(items) -52| print(f"Processed items: {result}") -53| -54| # Use the enum -55| color = Color.RED -56| print(f"Selected color: {color}") -=== +--- + /TEST_OUTPUT/workspace/consumer_clean.py References in File: 2 -=== -Reference at Line 9, Column 15: +At: L3:C20, L9:C15 + + 1|"""Consumer module that uses the helper module.""" + 2| + 3|from helper import helper_function, get_items + 4| + 5| 6|def consumer_function() -> None: 7| """Function that consumes the helper functions.""" 8| # Use the helper function @@ -93,5 +83,3 @@ Reference at Line 9, Column 15: 12| # Get and process items from the helper 13| items = get_items() 14| for item in items: -15| print(f"Processing {item}") - diff --git a/integrationtests/fixtures/snapshots/python/references/interface-method.snap b/integrationtests/fixtures/snapshots/python/references/interface-method.snap index 8a84865..0bcad23 100644 --- a/integrationtests/fixtures/snapshots/python/references/interface-method.snap +++ b/integrationtests/fixtures/snapshots/python/references/interface-method.snap @@ -1,20 +1,11 @@ -=== +--- + /TEST_OUTPUT/workspace/consumer.py References in File: 1 -=== -Reference at Line 51, Column 19: +At: L51:C19 + 34|def consumer_function() -> None: -35| """Function that consumes the helper functions.""" -36| # Use the helper function -37| message = helper_function("World") -38| print(message) -39| -40| # Get and process items from the helper -41| items = get_items() -42| for item in items: -43| print(f"Processing {item}") -44| -45| # Use the shared class +... 46| shared = SharedClass[str]("consumer", SHARED_CONSTANT) 47| print(f"Using shared class: {shared.get_name()} - {shared.get_value()}") 48| @@ -26,4 +17,3 @@ Reference at Line 51, Column 19: 54| # Use the enum 55| color = Color.RED 56| print(f"Selected color: {color}") - diff --git a/integrationtests/fixtures/snapshots/python/references/shared-class.snap b/integrationtests/fixtures/snapshots/python/references/shared-class.snap index c8aa880..53ff13d 100644 --- a/integrationtests/fixtures/snapshots/python/references/shared-class.snap +++ b/integrationtests/fixtures/snapshots/python/references/shared-class.snap @@ -1,8 +1,19 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.py References in File: 3 -=== -Reference at Line 16, Column 23: +At: L5:C5, L16:C23, L37:C14 + + 1|"""Another module that uses helpers and shared components.""" + 2| + 3|from helper import ( + 4| SHARED_CONSTANT, + 5| SharedClass, + 6| helper_function, + 7| Color, + 8|) + 9| +10| 11|class AnotherImplementation: 12| """A class that uses shared components but doesn't implement interfaces.""" 13| @@ -14,16 +25,7 @@ Reference at Line 16, Column 23: 19| """Do something with the shared components. 20| 21| Returns: -22| The processed result -23| """ -24| # Get the value from shared class -25| value = self.shared.get_value() -26| -27| # Process it using the helper function -28| return helper_function(value) - - -Reference at Line 37, Column 14: +... 31|def another_consumer_function() -> None: 32| """Another function that uses various shared components.""" 33| # Use shared constants @@ -36,32 +38,27 @@ Reference at Line 37, Column 14: 40| name = shared.get_name() 41| value = shared.get_value() 42| print(f"Name: {name}, Value: {value}") -43| -44| # Use our own implementation -45| impl = AnotherImplementation() -46| result = impl.do_something() -47| print(f"Implementation result: {result}") -48| -49| # Use helper function -50| output = helper_function("another direct call") -51| print(f"Helper output: {output}") -52| -53| # Use enum-like class with a different color -54| color = Color.GREEN -55| print(f"Selected color: {color}") -=== +--- + /TEST_OUTPUT/workspace/consumer.py References in File: 2 -=== -Reference at Line 46, Column 14: +At: L6:C5, L46:C14 + + 1|"""Consumer module that uses the helper module.""" + 2| + 3|from helper import ( + 4| helper_function, + 5| get_items, + 6| SharedClass, + 7| SharedInterface, + 8| SHARED_CONSTANT, + 9| Color, +10|) +11| +... 34|def consumer_function() -> None: -35| """Function that consumes the helper functions.""" -36| # Use the helper function -37| message = helper_function("World") -38| print(message) -39| -40| # Get and process items from the helper +... 41| items = get_items() 42| for item in items: 43| print(f"Processing {item}") @@ -73,9 +70,3 @@ Reference at Line 46, Column 14: 49| # Use our implementation of the shared interface 50| impl = MyImplementation() 51| result = impl.process(items) -52| print(f"Processed items: {result}") -53| -54| # Use the enum -55| color = Color.RED -56| print(f"Selected color: {color}") - diff --git a/integrationtests/fixtures/snapshots/python/references/shared-constant.snap b/integrationtests/fixtures/snapshots/python/references/shared-constant.snap index e5204d3..3ebd81c 100644 --- a/integrationtests/fixtures/snapshots/python/references/shared-constant.snap +++ b/integrationtests/fixtures/snapshots/python/references/shared-constant.snap @@ -1,8 +1,19 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.py References in File: 3 -=== -Reference at Line 16, Column 51: +At: L4:C5, L16:C51, L34:C30 + + 1|"""Another module that uses helpers and shared components.""" + 2| + 3|from helper import ( + 4| SHARED_CONSTANT, + 5| SharedClass, + 6| helper_function, + 7| Color, + 8|) + 9| +... 11|class AnotherImplementation: 12| """A class that uses shared components but doesn't implement interfaces.""" 13| @@ -14,16 +25,7 @@ Reference at Line 16, Column 51: 19| """Do something with the shared components. 20| 21| Returns: -22| The processed result -23| """ -24| # Get the value from shared class -25| value = self.shared.get_value() -26| -27| # Process it using the helper function -28| return helper_function(value) - - -Reference at Line 34, Column 30: +... 31|def another_consumer_function() -> None: 32| """Another function that uses various shared components.""" 33| # Use shared constants @@ -33,35 +35,27 @@ Reference at Line 34, Column 30: 37| shared = SharedClass[float]("another example", 3.14) 38| 39| # Use methods from shared class -40| name = shared.get_name() -41| value = shared.get_value() -42| print(f"Name: {name}, Value: {value}") -43| -44| # Use our own implementation -45| impl = AnotherImplementation() -46| result = impl.do_something() -47| print(f"Implementation result: {result}") -48| -49| # Use helper function -50| output = helper_function("another direct call") -51| print(f"Helper output: {output}") -52| -53| # Use enum-like class with a different color -54| color = Color.GREEN -55| print(f"Selected color: {color}") -=== +--- + /TEST_OUTPUT/workspace/consumer.py References in File: 2 -=== -Reference at Line 46, Column 43: +At: L8:C5, L46:C43 + + 3|from helper import ( + 4| helper_function, + 5| get_items, + 6| SharedClass, + 7| SharedInterface, + 8| SHARED_CONSTANT, + 9| Color, +10|) +11| +12| +13|class MyImplementation(SharedInterface): +... 34|def consumer_function() -> None: -35| """Function that consumes the helper functions.""" -36| # Use the helper function -37| message = helper_function("World") -38| print(message) -39| -40| # Get and process items from the helper +... 41| items = get_items() 42| for item in items: 43| print(f"Processing {item}") @@ -73,9 +67,3 @@ Reference at Line 46, Column 43: 49| # Use our implementation of the shared interface 50| impl = MyImplementation() 51| result = impl.process(items) -52| print(f"Processed items: {result}") -53| -54| # Use the enum -55| color = Color.RED -56| print(f"Selected color: {color}") - diff --git a/integrationtests/fixtures/snapshots/python/references/shared-interface.snap b/integrationtests/fixtures/snapshots/python/references/shared-interface.snap index a083b4d..83cad91 100644 --- a/integrationtests/fixtures/snapshots/python/references/shared-interface.snap +++ b/integrationtests/fixtures/snapshots/python/references/shared-interface.snap @@ -1,25 +1,23 @@ -=== +--- + /TEST_OUTPUT/workspace/consumer.py References in File: 2 -=== -Reference at Line 13, Column 24: +At: L7:C5, L13:C24 + + 2| + 3|from helper import ( + 4| helper_function, + 5| get_items, + 6| SharedClass, + 7| SharedInterface, + 8| SHARED_CONSTANT, + 9| Color, +10|) +11| +12| 13|class MyImplementation(SharedInterface): 14| """An implementation of the SharedInterface.""" 15| 16| def process(self, data: list[str]) -> dict[str, int]: 17| """Process the given data by counting occurrences. 18| -19| Args: -20| data: list of strings to process -21| -22| Returns: -23| dictionary with counts of each item -24| """ -25| result = {} -26| for item in data: -27| if item in result: -28| result[item] += 1 -29| else: -30| result[item] = 1 -31| return result - diff --git a/integrationtests/fixtures/snapshots/rust/diagnostics/dependency.snap b/integrationtests/fixtures/snapshots/rust/diagnostics/dependency.snap index f3c233a..c10283a 100644 --- a/integrationtests/fixtures/snapshots/rust/diagnostics/dependency.snap +++ b/integrationtests/fixtures/snapshots/rust/diagnostics/dependency.snap @@ -1,28 +1,11 @@ -=== +--- + /TEST_OUTPUT/workspace/src/consumer.rs -Location: Line 9, Column 33 -Message: expected 1 argument, found 0 -Source: rust-analyzer -Code: E0107 -=== +Diagnostics in File: 1 +ERROR at L9:C33: expected 1 argument, found 0 (Source: rust-analyzer, Code: E0107) + 7|pub fn consumer_function() { 8| // Use the helper function 9| let result = helper_function(); 10| println!("Helper result: {}", result); 11| -12| // Use shared struct -13| let s = SharedStruct::new("test"); -14| println!("Struct method: {}", s.method()); -15| -16| // Use shared interface -17| let iface: &dyn SharedInterface = &s; -18| println!("Interface method: {}", iface.get_name()); -19| -20| // Use shared constant -21| println!("Constant: {}", SHARED_CONSTANT); -22| -23| // Use shared type -24| let t: SharedType = String::from("test"); -25| println!("Type: {}", t); -26|} - diff --git a/integrationtests/fixtures/snapshots/rust/diagnostics/unreachable.snap b/integrationtests/fixtures/snapshots/rust/diagnostics/unreachable.snap index 1c5fa33..95305f6 100644 --- a/integrationtests/fixtures/snapshots/rust/diagnostics/unreachable.snap +++ b/integrationtests/fixtures/snapshots/rust/diagnostics/unreachable.snap @@ -1,76 +1,17 @@ -=== -/TEST_OUTPUT/workspace/src/main.rs -Location: Line 10, Column 34 -Message: Syntax Error: expected SEMICOLON -Source: rust-analyzer -Code: syntax-error -=== - 8|// FooBar is a simple function for testing - 9|fn foo_bar() -> String { -10| String::from("Hello, World!") -11| println!("Unreachable code"); // This is unreachable code -12|} - -=== -/TEST_OUTPUT/workspace/src/main.rs -Location: Line 10, Column 34 -Message: expected `;`, found `println` -Source: rustc -=== - 8|// FooBar is a simple function for testing - 9|fn foo_bar() -> String { -10| String::from("Hello, World!") -11| println!("Unreachable code"); // This is unreachable code -12|} - -=== -/TEST_OUTPUT/workspace/src/main.rs -Location: Line 11, Column 5 -Message: unexpected token -Source: rustc -=== - 8|// FooBar is a simple function for testing - 9|fn foo_bar() -> String { -10| String::from("Hello, World!") -11| println!("Unreachable code"); // This is unreachable code -12|} +--- -=== /TEST_OUTPUT/workspace/src/main.rs -Location: Line 10, Column 34 -Message: add `;` here: `;` -Source: rustc -=== - 8|// FooBar is a simple function for testing - 9|fn foo_bar() -> String { -10| String::from("Hello, World!") -11| println!("Unreachable code"); // This is unreachable code -12|} +Diagnostics in File: 6 +ERROR at L10:C34: Syntax Error: expected SEMICOLON (Source: rust-analyzer, Code: syntax-error) +ERROR at L10:C34: expected `;`, found `println` (Source: rustc) +HINT at L11:C5: unexpected token (Source: rustc) +HINT at L10:C34: add `;` here: `;` (Source: rustc) +ERROR at L9:C17: mismatched types +expected `String`, found `()` (Source: rustc, Code: E0308) +HINT at L9:C4: implicitly returns `()` as its body has no tail or `return` expression (Source: rustc, Code: E0308) -=== -/TEST_OUTPUT/workspace/src/main.rs -Location: Line 9, Column 17 -Message: mismatched types -expected `String`, found `()` -Source: rustc -Code: E0308 -=== 8|// FooBar is a simple function for testing 9|fn foo_bar() -> String { 10| String::from("Hello, World!") 11| println!("Unreachable code"); // This is unreachable code 12|} - -=== -/TEST_OUTPUT/workspace/src/main.rs -Location: Line 9, Column 4 -Message: implicitly returns `()` as its body has no tail or `return` expression -Source: rustc -Code: E0308 -=== - 8|// FooBar is a simple function for testing - 9|fn foo_bar() -> String { -10| String::from("Hello, World!") -11| println!("Unreachable code"); // This is unreachable code -12|} - diff --git a/integrationtests/fixtures/snapshots/rust/references/foobar-function.snap b/integrationtests/fixtures/snapshots/rust/references/foobar-function.snap index 372d465..ed1bb69 100644 --- a/integrationtests/fixtures/snapshots/rust/references/foobar-function.snap +++ b/integrationtests/fixtures/snapshots/rust/references/foobar-function.snap @@ -1,9 +1,9 @@ -=== +--- + /TEST_OUTPUT/workspace/src/main.rs References in File: 1 -=== -Reference at Line 15, Column 20: +At: L15:C20 + 14|fn main() { 15| println!("{}", foo_bar()); 16|} - diff --git a/integrationtests/fixtures/snapshots/rust/references/helper-function.snap b/integrationtests/fixtures/snapshots/rust/references/helper-function.snap index 82aca75..7acf07a 100644 --- a/integrationtests/fixtures/snapshots/rust/references/helper-function.snap +++ b/integrationtests/fixtures/snapshots/rust/references/helper-function.snap @@ -1,8 +1,15 @@ -=== +--- + /TEST_OUTPUT/workspace/src/another_consumer.rs References in File: 2 -=== -Reference at Line 9, Column 18: +At: L2:C20, L9:C18 + + 1|// Another consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn another_consumer_function() { 8| // Use the helper function 9| let result = helper_function(); @@ -11,22 +18,19 @@ Reference at Line 9, Column 18: 12| // Use shared struct 13| let s = SharedStruct::new("another test"); 14| println!("Struct in another consumer: {}", s.name); -15| -16| // Use shared interface -17| let _iface: &dyn SharedInterface = &s; -18| -19| // Use shared constant -20| println!("Constant in another consumer: {}", SHARED_CONSTANT); -21| -22| // Use shared type -23| let _t: SharedType = String::from("another test"); -24|} -=== +--- + /TEST_OUTPUT/workspace/src/consumer.rs References in File: 2 -=== -Reference at Line 9, Column 18: +At: L2:C20, L9:C18 + + 1|// Consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn consumer_function() { 8| // Use the helper function 9| let result = helper_function(); @@ -35,16 +39,3 @@ Reference at Line 9, Column 18: 12| // Use shared struct 13| let s = SharedStruct::new("test"); 14| println!("Struct method: {}", s.method()); -15| -16| // Use shared interface -17| let iface: &dyn SharedInterface = &s; -18| println!("Interface method: {}", iface.get_name()); -19| -20| // Use shared constant -21| println!("Constant: {}", SHARED_CONSTANT); -22| -23| // Use shared type -24| let t: SharedType = String::from("test"); -25| println!("Type: {}", t); -26|} - diff --git a/integrationtests/fixtures/snapshots/rust/references/interface-method.snap b/integrationtests/fixtures/snapshots/rust/references/interface-method.snap index 99d793e..97cb820 100644 --- a/integrationtests/fixtures/snapshots/rust/references/interface-method.snap +++ b/integrationtests/fixtures/snapshots/rust/references/interface-method.snap @@ -1,3 +1,46 @@ -=== -No references found for symbol: SharedInterface::get_name -=== +--- + +/TEST_OUTPUT/workspace/src/types.rs +References in File: 1 +At: L40:C8 + +38|// Implementation of TestInterface for TestStruct +39|impl TestInterface for TestStruct { +40| fn get_name(&self) -> String { +41| self.name.clone() +42| } +43| +44| fn get_value(&self) -> i32 { +45| self.value + +--- + +/TEST_OUTPUT/workspace/src/consumer.rs +References in File: 1 +At: L18:C44 + +7|pub fn consumer_function() { +... +13| let s = SharedStruct::new("test"); +14| println!("Struct method: {}", s.method()); +15| +16| // Use shared interface +17| let iface: &dyn SharedInterface = &s; +18| println!("Interface method: {}", iface.get_name()); +19| +20| // Use shared constant +21| println!("Constant: {}", SHARED_CONSTANT); +22| +23| // Use shared type + +--- + +/TEST_OUTPUT/workspace/src/types.rs +References in File: 1 +At: L71:C8 + +70|impl SharedInterface for SharedStruct { +71| fn get_name(&self) -> String { +72| self.name.clone() +73| } +74|} diff --git a/integrationtests/fixtures/snapshots/rust/references/shared-constant.snap b/integrationtests/fixtures/snapshots/rust/references/shared-constant.snap index 22d76c0..5257b34 100644 --- a/integrationtests/fixtures/snapshots/rust/references/shared-constant.snap +++ b/integrationtests/fixtures/snapshots/rust/references/shared-constant.snap @@ -1,16 +1,19 @@ -=== +--- + /TEST_OUTPUT/workspace/src/another_consumer.rs References in File: 2 -=== -Reference at Line 20, Column 50: +At: L4:C48, L20:C50 + + 1|// Another consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn another_consumer_function() { 8| // Use the helper function 9| let result = helper_function(); -10| println!("Helper result from another consumer: {}", result); -11| -12| // Use shared struct -13| let s = SharedStruct::new("another test"); -14| println!("Struct in another consumer: {}", s.name); +... 15| 16| // Use shared interface 17| let _iface: &dyn SharedInterface = &s; @@ -22,20 +25,22 @@ Reference at Line 20, Column 50: 23| let _t: SharedType = String::from("another test"); 24|} -=== +--- + /TEST_OUTPUT/workspace/src/consumer.rs References in File: 2 -=== -Reference at Line 21, Column 30: +At: L4:C48, L21:C30 + + 1|// Consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn consumer_function() { 8| // Use the helper function 9| let result = helper_function(); -10| println!("Helper result: {}", result); -11| -12| // Use shared struct -13| let s = SharedStruct::new("test"); -14| println!("Struct method: {}", s.method()); -15| +... 16| // Use shared interface 17| let iface: &dyn SharedInterface = &s; 18| println!("Interface method: {}", iface.get_name()); @@ -47,4 +52,3 @@ Reference at Line 21, Column 30: 24| let t: SharedType = String::from("test"); 25| println!("Type: {}", t); 26|} - diff --git a/integrationtests/fixtures/snapshots/rust/references/shared-interface.snap b/integrationtests/fixtures/snapshots/rust/references/shared-interface.snap index 438e440..3409192 100644 --- a/integrationtests/fixtures/snapshots/rust/references/shared-interface.snap +++ b/integrationtests/fixtures/snapshots/rust/references/shared-interface.snap @@ -1,13 +1,19 @@ -=== +--- + /TEST_OUTPUT/workspace/src/another_consumer.rs References in File: 2 -=== -Reference at Line 17, Column 22: +At: L4:C5, L17:C22 + + 1|// Another consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn another_consumer_function() { 8| // Use the helper function 9| let result = helper_function(); -10| println!("Helper result from another consumer: {}", result); -11| +... 12| // Use shared struct 13| let s = SharedStruct::new("another test"); 14| println!("Struct in another consumer: {}", s.name); @@ -19,19 +25,23 @@ Reference at Line 17, Column 22: 20| println!("Constant in another consumer: {}", SHARED_CONSTANT); 21| 22| // Use shared type -23| let _t: SharedType = String::from("another test"); -24|} -=== +--- + /TEST_OUTPUT/workspace/src/consumer.rs References in File: 2 -=== -Reference at Line 17, Column 21: +At: L4:C5, L17:C21 + + 1|// Consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn consumer_function() { 8| // Use the helper function 9| let result = helper_function(); -10| println!("Helper result: {}", result); -11| +... 12| // Use shared struct 13| let s = SharedStruct::new("test"); 14| println!("Struct method: {}", s.method()); @@ -43,19 +53,15 @@ Reference at Line 17, Column 21: 20| // Use shared constant 21| println!("Constant: {}", SHARED_CONSTANT); 22| -23| // Use shared type -24| let t: SharedType = String::from("test"); -25| println!("Type: {}", t); -26|} -=== +--- + /TEST_OUTPUT/workspace/src/types.rs References in File: 1 -=== -Reference at Line 70, Column 6: +At: L70:C6 + 70|impl SharedInterface for SharedStruct { 71| fn get_name(&self) -> String { 72| self.name.clone() 73| } 74|} - diff --git a/integrationtests/fixtures/snapshots/rust/references/shared-struct.snap b/integrationtests/fixtures/snapshots/rust/references/shared-struct.snap index e07b4a2..211c7cc 100644 --- a/integrationtests/fixtures/snapshots/rust/references/shared-struct.snap +++ b/integrationtests/fixtures/snapshots/rust/references/shared-struct.snap @@ -1,8 +1,15 @@ -=== +--- + /TEST_OUTPUT/workspace/src/another_consumer.rs References in File: 2 -=== -Reference at Line 13, Column 13: +At: L4:C22, L13:C13 + + 1|// Another consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn another_consumer_function() { 8| // Use the helper function 9| let result = helper_function(); @@ -15,18 +22,19 @@ Reference at Line 13, Column 13: 16| // Use shared interface 17| let _iface: &dyn SharedInterface = &s; 18| -19| // Use shared constant -20| println!("Constant in another consumer: {}", SHARED_CONSTANT); -21| -22| // Use shared type -23| let _t: SharedType = String::from("another test"); -24|} -=== +--- + /TEST_OUTPUT/workspace/src/consumer.rs References in File: 2 -=== -Reference at Line 13, Column 13: +At: L4:C22, L13:C13 + + 1|// Consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn consumer_function() { 8| // Use the helper function 9| let result = helper_function(); @@ -39,34 +47,13 @@ Reference at Line 13, Column 13: 16| // Use shared interface 17| let iface: &dyn SharedInterface = &s; 18| println!("Interface method: {}", iface.get_name()); -19| -20| // Use shared constant -21| println!("Constant: {}", SHARED_CONSTANT); -22| -23| // Use shared type -24| let t: SharedType = String::from("test"); -25| println!("Type: {}", t); -26|} -=== +--- + /TEST_OUTPUT/workspace/src/types.rs References in File: 4 -=== -Reference at Line 54, Column 6: -54|impl SharedStruct { -55| pub fn new(name: &str) -> Self { -56| SharedStruct { -57| name: String::from(name), -58| } -59| } -60| -61| pub fn method(&self) -> String { -62| format!("SharedStruct: {}", self.name) -63| } -64|} - +At: L54:C6, L56:C9, L70:C26, L55:C31 -Reference at Line 56, Column 9: 54|impl SharedStruct { 55| pub fn new(name: &str) -> Self { 56| SharedStruct { @@ -75,29 +62,9 @@ Reference at Line 56, Column 9: 59| } 60| 61| pub fn method(&self) -> String { -62| format!("SharedStruct: {}", self.name) -63| } -64|} - - -Reference at Line 70, Column 26: +... 70|impl SharedInterface for SharedStruct { 71| fn get_name(&self) -> String { 72| self.name.clone() 73| } 74|} - - -Reference at Line 55, Column 31: -54|impl SharedStruct { -55| pub fn new(name: &str) -> Self { -56| SharedStruct { -57| name: String::from(name), -58| } -59| } -60| -61| pub fn method(&self) -> String { -62| format!("SharedStruct: {}", self.name) -63| } -64|} - diff --git a/integrationtests/fixtures/snapshots/rust/references/shared-type.snap b/integrationtests/fixtures/snapshots/rust/references/shared-type.snap index acac77a..e681f9d 100644 --- a/integrationtests/fixtures/snapshots/rust/references/shared-type.snap +++ b/integrationtests/fixtures/snapshots/rust/references/shared-type.snap @@ -1,19 +1,19 @@ -=== +--- + /TEST_OUTPUT/workspace/src/another_consumer.rs References in File: 2 -=== -Reference at Line 23, Column 13: +At: L4:C36, L23:C13 + + 1|// Another consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn another_consumer_function() { 8| // Use the helper function 9| let result = helper_function(); -10| println!("Helper result from another consumer: {}", result); -11| -12| // Use shared struct -13| let s = SharedStruct::new("another test"); -14| println!("Struct in another consumer: {}", s.name); -15| -16| // Use shared interface -17| let _iface: &dyn SharedInterface = &s; +... 18| 19| // Use shared constant 20| println!("Constant in another consumer: {}", SHARED_CONSTANT); @@ -22,23 +22,22 @@ Reference at Line 23, Column 13: 23| let _t: SharedType = String::from("another test"); 24|} -=== +--- + /TEST_OUTPUT/workspace/src/consumer.rs References in File: 2 -=== -Reference at Line 24, Column 12: +At: L4:C36, L24:C12 + + 1|// Consumer module for testing references + 2|use crate::helper::helper_function; + 3|use crate::types::{ + 4| SharedInterface, SharedStruct, SharedType, SHARED_CONSTANT, + 5|}; + 6| 7|pub fn consumer_function() { 8| // Use the helper function 9| let result = helper_function(); -10| println!("Helper result: {}", result); -11| -12| // Use shared struct -13| let s = SharedStruct::new("test"); -14| println!("Struct method: {}", s.method()); -15| -16| // Use shared interface -17| let iface: &dyn SharedInterface = &s; -18| println!("Interface method: {}", iface.get_name()); +... 19| 20| // Use shared constant 21| println!("Constant: {}", SHARED_CONSTANT); @@ -47,4 +46,3 @@ Reference at Line 24, Column 12: 24| let t: SharedType = String::from("test"); 25| println!("Type: {}", t); 26|} - diff --git a/integrationtests/fixtures/snapshots/rust/references/struct-method.snap b/integrationtests/fixtures/snapshots/rust/references/struct-method.snap index b700ace..f4eca63 100644 --- a/integrationtests/fixtures/snapshots/rust/references/struct-method.snap +++ b/integrationtests/fixtures/snapshots/rust/references/struct-method.snap @@ -1,3 +1,19 @@ -=== -No references found for symbol: SharedStruct::method -=== +--- + +/TEST_OUTPUT/workspace/src/consumer.rs +References in File: 1 +At: L14:C37 + +7|pub fn consumer_function() { +... + 9| let result = helper_function(); +10| println!("Helper result: {}", result); +11| +12| // Use shared struct +13| let s = SharedStruct::new("test"); +14| println!("Struct method: {}", s.method()); +15| +16| // Use shared interface +17| let iface: &dyn SharedInterface = &s; +18| println!("Interface method: {}", iface.get_name()); +19| diff --git a/integrationtests/fixtures/snapshots/typescript/diagnostics/dependency.snap b/integrationtests/fixtures/snapshots/typescript/diagnostics/dependency.snap index 525c505..8fc60f4 100644 --- a/integrationtests/fixtures/snapshots/typescript/diagnostics/dependency.snap +++ b/integrationtests/fixtures/snapshots/typescript/diagnostics/dependency.snap @@ -1,32 +1,10 @@ -=== +--- + /TEST_OUTPUT/workspace/consumer.ts -Location: Line 13, Column 36 -Message: Expected 1 arguments, but got 0. -Source: typescript -Code: 2554 -=== +Diagnostics in File: 1 +ERROR at L13:C36: Expected 1 arguments, but got 0. (Source: typescript, Code: 2554) + 12|export function ConsumerFunction(): void { 13| console.log("Consumer calling:", SharedFunction()); 14| 15| // Using SharedClass -16| const instance = new SharedClass("test instance"); -17| console.log(instance.getName()); -18| instance.helperMethod(); -19| -20| // Using SharedInterface -21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} - diff --git a/integrationtests/fixtures/snapshots/typescript/diagnostics/type-error.snap b/integrationtests/fixtures/snapshots/typescript/diagnostics/type-error.snap index 8199ef5..67fc56a 100644 --- a/integrationtests/fixtures/snapshots/typescript/diagnostics/type-error.snap +++ b/integrationtests/fixtures/snapshots/typescript/diagnostics/type-error.snap @@ -1,11 +1,9 @@ -=== +--- + /TEST_OUTPUT/workspace/error.ts -Location: Line 4, Column 3 -Message: Type 'number' is not assignable to type 'string'. -Source: typescript -Code: 2322 -=== +Diagnostics in File: 1 +ERROR at L4:C3: Type 'number' is not assignable to type 'string'. (Source: typescript, Code: 2322) + 3|function errorFunction(x: number): string { 4| return x; // Error: Type 'number' is not assignable to type 'string' 5|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/class-method.snap b/integrationtests/fixtures/snapshots/typescript/references/class-method.snap index 7f43222..4e3ebde 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/class-method.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/class-method.snap @@ -1,8 +1,9 @@ -=== +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 1 -=== -Reference at Line 18, Column 12: +At: L18:C12 + 12|export function ConsumerFunction(): void { 13| console.log("Consumer calling:", SharedFunction()); 14| @@ -15,16 +16,3 @@ Reference at Line 18, Column 12: 21| const iface: SharedInterface = instance; 22| console.log(iface.getName()); 23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/interface-method.snap b/integrationtests/fixtures/snapshots/typescript/references/interface-method.snap index 14c3830..8a12918 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/interface-method.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/interface-method.snap @@ -1,12 +1,11 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 1 -=== -Reference at Line 21, Column 5: +At: L21:C5 + 12|export function AnotherConsumerFunction(): void { -13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); -15| +... 16| // Using SharedClass differently 17| const instance = new SharedClass("another instance"); 18| @@ -18,21 +17,13 @@ Reference at Line 21, Column 5: 24| 25| // Using SharedType 26| const mixedArray: SharedType[] = ["string", 42, "another"]; -27| -28| // Using SharedConstant -29| const prefixed = `PREFIX_${SharedConstant}`; -30| -31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} - -=== + +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 2 -=== -Reference at Line 22, Column 21: +At: L22:C21, L17:C24 + 12|export function ConsumerFunction(): void { 13| console.log("Consumer calling:", SharedFunction()); 14| @@ -49,49 +40,15 @@ Reference at Line 22, Column 21: 25| // Using SharedType 26| const value: SharedType = "string value"; 27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} +--- -Reference at Line 17, Column 24: -12|export function ConsumerFunction(): void { -13| console.log("Consumer calling:", SharedFunction()); -14| -15| // Using SharedClass -16| const instance = new SharedClass("test instance"); -17| console.log(instance.getName()); -18| instance.helperMethod(); -19| -20| // Using SharedInterface -21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} - -=== /TEST_OUTPUT/workspace/helper.ts References in File: 1 -=== -Reference at Line 22, Column 3: +At: L22:C3 + 15|export class SharedClass implements SharedInterface { -16| private name: string; +... 17| 18| constructor(name: string) { 19| this.name = name; @@ -103,22 +60,15 @@ Reference at Line 22, Column 3: 25| 26| getValue(): number { 27| return 42; -28| } -29| -30| helperMethod(): void { -31| console.log("Helper method called"); -32| } -33|} - -=== + +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 1 -=== -Reference at Line 21, Column 5: +At: L21:C5 + 12|export function AnotherConsumerFunction(): void { -13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); -15| +... 16| // Using SharedClass differently 17| const instance = new SharedClass("another instance"); 18| @@ -130,21 +80,13 @@ Reference at Line 21, Column 5: 24| 25| // Using SharedType 26| const mixedArray: SharedType[] = ["string", 42, "another"]; -27| -28| // Using SharedConstant -29| const prefixed = `PREFIX_${SharedConstant}`; -30| -31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} - -=== + +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 2 -=== -Reference at Line 22, Column 21: +At: L22:C21, L17:C24 + 12|export function ConsumerFunction(): void { 13| console.log("Consumer calling:", SharedFunction()); 14| @@ -161,49 +103,14 @@ Reference at Line 22, Column 21: 25| // Using SharedType 26| const value: SharedType = "string value"; 27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} +--- -Reference at Line 17, Column 24: -12|export function ConsumerFunction(): void { -13| console.log("Consumer calling:", SharedFunction()); -14| -15| // Using SharedClass -16| const instance = new SharedClass("test instance"); -17| console.log(instance.getName()); -18| instance.helperMethod(); -19| -20| // Using SharedInterface -21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} - -=== /TEST_OUTPUT/workspace/helper.ts References in File: 1 -=== -Reference at Line 10, Column 3: +At: L10:C3 + 9|export interface SharedInterface { 10| getName(): string; 11| getValue(): number; 12|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/shared-class.snap b/integrationtests/fixtures/snapshots/typescript/references/shared-class.snap index 9f4162f..0958fb5 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/shared-class.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/shared-class.snap @@ -1,8 +1,20 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 2 -=== -Reference at Line 17, Column 24: +At: L5:C3, L17:C24 + + 1|// Another consumer file that uses elements from the helper file + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +... 12|export function AnotherConsumerFunction(): void { 13| const result = SharedFunction(); 14| console.log(`Result from shared function: ${result}`); @@ -14,25 +26,24 @@ Reference at Line 17, Column 24: 20| const iface: SharedInterface = { 21| getName: () => "custom implementation", 22| getValue: () => 100 -23| }; -24| -25| // Using SharedType -26| const mixedArray: SharedType[] = ["string", 42, "another"]; -27| -28| // Using SharedConstant -29| const prefixed = `PREFIX_${SharedConstant}`; -30| -31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} -=== +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 2 -=== -Reference at Line 16, Column 24: +At: L5:C3, L16:C24 + + 1|// Consumer file that uses elements from the helper file + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +... 12|export function ConsumerFunction(): void { 13| console.log("Consumer calling:", SharedFunction()); 14| @@ -43,18 +54,3 @@ Reference at Line 16, Column 24: 19| 20| // Using SharedInterface 21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/shared-constant.snap b/integrationtests/fixtures/snapshots/typescript/references/shared-constant.snap index 73b42dd..c68d72b 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/shared-constant.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/shared-constant.snap @@ -1,20 +1,21 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 2 -=== -Reference at Line 29, Column 30: +At: L7:C3, L29:C30 + + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +11|// AnotherConsumerFunction uses SharedFunction in a different way 12|export function AnotherConsumerFunction(): void { -13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); -15| -16| // Using SharedClass differently -17| const instance = new SharedClass("another instance"); -18| -19| // Using SharedInterface -20| const iface: SharedInterface = { -21| getName: () => "custom implementation", -22| getValue: () => 100 -23| }; +... 24| 25| // Using SharedType 26| const mixedArray: SharedType[] = ["string", 42, "another"]; @@ -26,27 +27,25 @@ Reference at Line 29, Column 30: 32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; 33| 34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} -=== +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 2 -=== -Reference at Line 31, Column 15: +At: L7:C3, L31:C15 + + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +11|// ConsumerFunction uses SharedFunction 12|export function ConsumerFunction(): void { -13| console.log("Consumer calling:", SharedFunction()); -14| -15| // Using SharedClass -16| const instance = new SharedClass("test instance"); -17| console.log(instance.getName()); -18| instance.helperMethod(); -19| -20| // Using SharedInterface -21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType +... 26| const value: SharedType = "string value"; 27| const numValue: SharedType = 42; 28| console.log(value, numValue); @@ -57,4 +56,3 @@ Reference at Line 31, Column 15: 33| // Using SharedEnum 34| console.log(SharedEnum.ONE); 35|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/shared-enum.snap b/integrationtests/fixtures/snapshots/typescript/references/shared-enum.snap index ba42341..1b8643c 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/shared-enum.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/shared-enum.snap @@ -1,50 +1,21 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 4 -=== -Reference at Line 32, Column 23: -12|export function AnotherConsumerFunction(): void { -13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); -15| -16| // Using SharedClass differently -17| const instance = new SharedClass("another instance"); -18| -19| // Using SharedInterface -20| const iface: SharedInterface = { -21| getName: () => "custom implementation", -22| getValue: () => 100 -23| }; -24| -25| // Using SharedType -26| const mixedArray: SharedType[] = ["string", 42, "another"]; -27| -28| // Using SharedConstant -29| const prefixed = `PREFIX_${SharedConstant}`; -30| -31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} - +At: L8:C3, L32:C23, L32:C39, L32:C55 -Reference at Line 32, Column 39: + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +11|// AnotherConsumerFunction uses SharedFunction in a different way 12|export function AnotherConsumerFunction(): void { 13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); -15| -16| // Using SharedClass differently -17| const instance = new SharedClass("another instance"); -18| -19| // Using SharedInterface -20| const iface: SharedInterface = { -21| getName: () => "custom implementation", -22| getValue: () => 100 -23| }; -24| -25| // Using SharedType -26| const mixedArray: SharedType[] = ["string", 42, "another"]; +... 27| 28| // Using SharedConstant 29| const prefixed = `PREFIX_${SharedConstant}`; @@ -55,55 +26,24 @@ Reference at Line 32, Column 39: 34| console.log(instance, iface, mixedArray, prefixed, enumValues); 35|} +--- -Reference at Line 32, Column 55: -12|export function AnotherConsumerFunction(): void { -13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); -15| -16| // Using SharedClass differently -17| const instance = new SharedClass("another instance"); -18| -19| // Using SharedInterface -20| const iface: SharedInterface = { -21| getName: () => "custom implementation", -22| getValue: () => 100 -23| }; -24| -25| // Using SharedType -26| const mixedArray: SharedType[] = ["string", 42, "another"]; -27| -28| // Using SharedConstant -29| const prefixed = `PREFIX_${SharedConstant}`; -30| -31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} - -=== /TEST_OUTPUT/workspace/consumer.ts References in File: 2 -=== -Reference at Line 34, Column 15: +At: L8:C3, L34:C15 + + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +11|// ConsumerFunction uses SharedFunction 12|export function ConsumerFunction(): void { 13| console.log("Consumer calling:", SharedFunction()); -14| -15| // Using SharedClass -16| const instance = new SharedClass("test instance"); -17| console.log(instance.getName()); -18| instance.helperMethod(); -19| -20| // Using SharedInterface -21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); +... 29| 30| // Using SharedConstant 31| console.log(SharedConstant); @@ -111,4 +51,3 @@ Reference at Line 34, Column 15: 33| // Using SharedEnum 34| console.log(SharedEnum.ONE); 35|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/shared-function.snap b/integrationtests/fixtures/snapshots/typescript/references/shared-function.snap index 35a5b45..823a3e7 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/shared-function.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/shared-function.snap @@ -1,8 +1,18 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 2 -=== -Reference at Line 13, Column 18: +At: L3:C3, L13:C18 + +1|// Another consumer file that uses elements from the helper file +2|import { +3| SharedFunction, +4| SharedInterface, +5| SharedClass, +6| SharedType, +7| SharedConstant, +8| SharedEnum +... 12|export function AnotherConsumerFunction(): void { 13| const result = SharedFunction(); 14| console.log(`Result from shared function: ${result}`); @@ -10,29 +20,22 @@ Reference at Line 13, Column 18: 16| // Using SharedClass differently 17| const instance = new SharedClass("another instance"); 18| -19| // Using SharedInterface -20| const iface: SharedInterface = { -21| getName: () => "custom implementation", -22| getValue: () => 100 -23| }; -24| -25| // Using SharedType -26| const mixedArray: SharedType[] = ["string", 42, "another"]; -27| -28| // Using SharedConstant -29| const prefixed = `PREFIX_${SharedConstant}`; -30| -31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} -=== +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 2 -=== -Reference at Line 13, Column 36: +At: L3:C3, L13:C36 + +1|// Consumer file that uses elements from the helper file +2|import { +3| SharedFunction, +4| SharedInterface, +5| SharedClass, +6| SharedType, +7| SharedConstant, +8| SharedEnum +... 12|export function ConsumerFunction(): void { 13| console.log("Consumer calling:", SharedFunction()); 14| @@ -40,21 +43,3 @@ Reference at Line 13, Column 36: 16| const instance = new SharedClass("test instance"); 17| console.log(instance.getName()); 18| instance.helperMethod(); -19| -20| // Using SharedInterface -21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/shared-interface.snap b/integrationtests/fixtures/snapshots/typescript/references/shared-interface.snap index b21642b..60e89e7 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/shared-interface.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/shared-interface.snap @@ -1,11 +1,21 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 2 -=== -Reference at Line 20, Column 16: +At: L4:C3, L20:C16 + + 1|// Another consumer file that uses elements from the helper file + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +... 12|export function AnotherConsumerFunction(): void { -13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); +... 15| 16| // Using SharedClass differently 17| const instance = new SharedClass("another instance"); @@ -17,26 +27,25 @@ Reference at Line 20, Column 16: 23| }; 24| 25| // Using SharedType -26| const mixedArray: SharedType[] = ["string", 42, "another"]; -27| -28| // Using SharedConstant -29| const prefixed = `PREFIX_${SharedConstant}`; -30| -31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} -=== +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 2 -=== -Reference at Line 21, Column 16: +At: L4:C3, L21:C16 + + 1|// Consumer file that uses elements from the helper file + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +... 12|export function ConsumerFunction(): void { -13| console.log("Consumer calling:", SharedFunction()); -14| -15| // Using SharedClass +... 16| const instance = new SharedClass("test instance"); 17| console.log(instance.getName()); 18| instance.helperMethod(); @@ -48,38 +57,16 @@ Reference at Line 21, Column 16: 24| 25| // Using SharedType 26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} -=== +--- + /TEST_OUTPUT/workspace/helper.ts References in File: 1 -=== -Reference at Line 15, Column 37: +At: L15:C37 + 15|export class SharedClass implements SharedInterface { 16| private name: string; 17| 18| constructor(name: string) { 19| this.name = name; 20| } -21| -22| getName(): string { -23| return this.name; -24| } -25| -26| getValue(): number { -27| return 42; -28| } -29| -30| helperMethod(): void { -31| console.log("Helper method called"); -32| } -33|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/shared-type.snap b/integrationtests/fixtures/snapshots/typescript/references/shared-type.snap index 4ed0143..806decd 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/shared-type.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/shared-type.snap @@ -1,17 +1,22 @@ -=== +--- + /TEST_OUTPUT/workspace/another_consumer.ts References in File: 2 -=== -Reference at Line 26, Column 21: +At: L6:C3, L26:C21 + + 1|// Another consumer file that uses elements from the helper file + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +11|// AnotherConsumerFunction uses SharedFunction in a different way 12|export function AnotherConsumerFunction(): void { -13| const result = SharedFunction(); -14| console.log(`Result from shared function: ${result}`); -15| -16| // Using SharedClass differently -17| const instance = new SharedClass("another instance"); -18| -19| // Using SharedInterface -20| const iface: SharedInterface = { +... 21| getName: () => "custom implementation", 22| getValue: () => 100 23| }; @@ -23,52 +28,26 @@ Reference at Line 26, Column 21: 29| const prefixed = `PREFIX_${SharedConstant}`; 30| 31| // Using SharedEnum -32| const enumValues = [SharedEnum.ONE, SharedEnum.TWO, SharedEnum.THREE]; -33| -34| console.log(instance, iface, mixedArray, prefixed, enumValues); -35|} -=== +--- + /TEST_OUTPUT/workspace/consumer.ts References in File: 3 -=== -Reference at Line 26, Column 16: -12|export function ConsumerFunction(): void { -13| console.log("Consumer calling:", SharedFunction()); -14| -15| // Using SharedClass -16| const instance = new SharedClass("test instance"); -17| console.log(instance.getName()); -18| instance.helperMethod(); -19| -20| // Using SharedInterface -21| const iface: SharedInterface = instance; -22| console.log(iface.getName()); -23| console.log(iface.getValue()); -24| -25| // Using SharedType -26| const value: SharedType = "string value"; -27| const numValue: SharedType = 42; -28| console.log(value, numValue); -29| -30| // Using SharedConstant -31| console.log(SharedConstant); -32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} +At: L6:C3, L26:C16, L27:C19 - -Reference at Line 27, Column 19: + 1|// Consumer file that uses elements from the helper file + 2|import { + 3| SharedFunction, + 4| SharedInterface, + 5| SharedClass, + 6| SharedType, + 7| SharedConstant, + 8| SharedEnum + 9|} from './helper'; +10| +11|// ConsumerFunction uses SharedFunction 12|export function ConsumerFunction(): void { -13| console.log("Consumer calling:", SharedFunction()); -14| -15| // Using SharedClass -16| const instance = new SharedClass("test instance"); -17| console.log(instance.getName()); -18| instance.helperMethod(); -19| -20| // Using SharedInterface +... 21| const iface: SharedInterface = instance; 22| console.log(iface.getName()); 23| console.log(iface.getValue()); @@ -81,7 +60,3 @@ Reference at Line 27, Column 19: 30| // Using SharedConstant 31| console.log(SharedConstant); 32| -33| // Using SharedEnum -34| console.log(SharedEnum.ONE); -35|} - diff --git a/integrationtests/fixtures/snapshots/typescript/references/test-function.snap b/integrationtests/fixtures/snapshots/typescript/references/test-function.snap index 6ac1c7d..44b2926 100644 --- a/integrationtests/fixtures/snapshots/typescript/references/test-function.snap +++ b/integrationtests/fixtures/snapshots/typescript/references/test-function.snap @@ -1,11 +1,11 @@ -=== +--- + /TEST_OUTPUT/workspace/main.ts References in File: 1 -=== -Reference at Line 37, Column 15: +At: L37:C15 + 36|function main() { 37| console.log(TestFunction()); 38| const instance = new TestClass(); 39| instance.method(); 40|} - diff --git a/integrationtests/languages/go/diagnostics/diagnostics_test.go b/integrationtests/languages/go/diagnostics/diagnostics_test.go index 1609c33..b66b632 100644 --- a/integrationtests/languages/go/diagnostics/diagnostics_test.go +++ b/integrationtests/languages/go/diagnostics/diagnostics_test.go @@ -25,7 +25,7 @@ func TestDiagnostics(t *testing.T) { defer cancel() filePath := filepath.Join(suite.WorkspaceDir, "clean.go") - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -50,7 +50,7 @@ func TestDiagnostics(t *testing.T) { defer cancel() filePath := filepath.Join(suite.WorkspaceDir, "main.go") - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -98,7 +98,7 @@ func TestDiagnostics(t *testing.T) { time.Sleep(2 * time.Second) // Get initial diagnostics for consumer.go - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -165,7 +165,7 @@ func HelperFunction(value int) string { time.Sleep(3 * time.Second) // Check diagnostics again on consumer file - should now have an error - result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed after dependency change: %v", err) } diff --git a/integrationtests/languages/python/diagnostics/diagnostics_test.go b/integrationtests/languages/python/diagnostics/diagnostics_test.go index b13c8e7..eb0d545 100644 --- a/integrationtests/languages/python/diagnostics/diagnostics_test.go +++ b/integrationtests/languages/python/diagnostics/diagnostics_test.go @@ -26,7 +26,7 @@ func TestDiagnostics(t *testing.T) { // Check diagnostics for clean.py, which shouldn't have any errors filePath := filepath.Join(suite.WorkspaceDir, "clean.py") - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -52,7 +52,7 @@ func TestDiagnostics(t *testing.T) { // Check diagnostics for error_file.py, which contains deliberate errors filePath := filepath.Join(suite.WorkspaceDir, "error_file.py") - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -102,7 +102,7 @@ func TestDiagnostics(t *testing.T) { time.Sleep(2 * time.Second) // Get initial diagnostics for consumer_clean.py - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -188,7 +188,7 @@ def get_items() -> List[str]: time.Sleep(3 * time.Second) // Check diagnostics again on consumer file - should now have an error - result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed after dependency change: %v", err) } diff --git a/integrationtests/languages/rust/diagnostics/diagnostics_test.go b/integrationtests/languages/rust/diagnostics/diagnostics_test.go index 9835341..baf88bf 100644 --- a/integrationtests/languages/rust/diagnostics/diagnostics_test.go +++ b/integrationtests/languages/rust/diagnostics/diagnostics_test.go @@ -49,7 +49,7 @@ func TestDiagnostics(t *testing.T) { openAllFilesAndWait(suite, ctx) filePath := filepath.Join(suite.WorkspaceDir, "src/clean.rs") - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -74,7 +74,7 @@ func TestDiagnostics(t *testing.T) { openAllFilesAndWait(suite, ctx) filePath := filepath.Join(suite.WorkspaceDir, "src/main.rs") - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -108,7 +108,7 @@ func TestDiagnostics(t *testing.T) { consumerPath := filepath.Join(suite.WorkspaceDir, "src/consumer.rs") // Get initial diagnostics for consumer.rs - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -170,7 +170,7 @@ pub fn helper_function(value: i32) -> String { time.Sleep(6 * time.Second) // Check diagnostics again on consumer file - should now have an error - result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed after dependency change: %v", err) } diff --git a/integrationtests/languages/rust/references/references_test.go b/integrationtests/languages/rust/references/references_test.go index 7a0cd3a..7a76a76 100644 --- a/integrationtests/languages/rust/references/references_test.go +++ b/integrationtests/languages/rust/references/references_test.go @@ -56,7 +56,7 @@ func TestFindReferences(t *testing.T) { name: "Function with references across files", symbolName: "helper_function", expectedText: "helper_function", - expectedFiles: 1, // rust-analyzer might not report references across all files initially + expectedFiles: 2, snapshotName: "helper-function", }, { @@ -75,9 +75,9 @@ func TestFindReferences(t *testing.T) { }, { name: "Method with references across files", - symbolName: "SharedStruct::method", + symbolName: "method", expectedText: "method", - expectedFiles: 0, // rust-analyzer might format differently or not include method references + expectedFiles: 1, snapshotName: "struct-method", }, { @@ -89,23 +89,23 @@ func TestFindReferences(t *testing.T) { }, { name: "Interface method with references", - symbolName: "SharedInterface::get_name", + symbolName: "get_name", expectedText: "get_name", - expectedFiles: 0, // rust-analyzer might format differently or not include trait method references + expectedFiles: 2, snapshotName: "interface-method", }, { name: "Constant with references across files", symbolName: "SHARED_CONSTANT", expectedText: "SHARED_CONSTANT", - expectedFiles: 1, // rust-analyzer might not report references across all files initially + expectedFiles: 2, snapshotName: "shared-constant", }, { name: "Type with references across files", symbolName: "SharedType", expectedText: "SharedType", - expectedFiles: 1, // rust-analyzer might not report references across all files initially + expectedFiles: 2, snapshotName: "shared-type", }, } @@ -143,9 +143,7 @@ func countFilesInResult(result string) int { // Any line containing "workspace" and ".rs" is a file path for line := range strings.SplitSeq(result, "\n") { if strings.Contains(line, "workspace") && strings.Contains(line, ".rs") { - if !strings.Contains(line, "References in File") { - fileMap[line] = true - } + fileMap[line] = true } } diff --git a/integrationtests/languages/typescript/diagnostics/diagnostics_test.go b/integrationtests/languages/typescript/diagnostics/diagnostics_test.go index 9a1e3de..ba0f79a 100644 --- a/integrationtests/languages/typescript/diagnostics/diagnostics_test.go +++ b/integrationtests/languages/typescript/diagnostics/diagnostics_test.go @@ -53,7 +53,7 @@ func TestDiagnostics(t *testing.T) { // Target the clean file filePath := filepath.Join(suite.WorkspaceDir, "clean.ts") - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, filePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -102,7 +102,7 @@ console.log(result); // Wait for diagnostics to be generated time.Sleep(3 * time.Second) - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, testFilePath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, testFilePath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -136,7 +136,7 @@ console.log(result); consumerPath := filepath.Join(suite.WorkspaceDir, "consumer.ts") // Get initial diagnostics for consumer.ts - result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err := tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed: %v", err) } @@ -243,7 +243,7 @@ export enum SharedEnum { time.Sleep(3 * time.Second) // Check diagnostics again on consumer file - should now have an error - result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, true, true) + result, err = tools.GetDiagnosticsForFile(ctx, suite.Client, consumerPath, 2, true) if err != nil { t.Fatalf("GetDiagnosticsForFile failed after dependency change: %v", err) } diff --git a/internal/tools/diagnostics.go b/internal/tools/diagnostics.go index a5585b3..2c78358 100644 --- a/internal/tools/diagnostics.go +++ b/internal/tools/diagnostics.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "strconv" "strings" "time" @@ -11,8 +12,15 @@ import ( "github.com/isaacphi/mcp-language-server/internal/protocol" ) -// GetDiagnostics retrieves diagnostics for a specific file from the language server -func GetDiagnosticsForFile(ctx context.Context, client *lsp.Client, filePath string, includeContext bool, showLineNumbers bool) (string, error) { +// GetDiagnosticsForFile retrieves diagnostics for a specific file from the language server +func GetDiagnosticsForFile(ctx context.Context, client *lsp.Client, filePath string, contextLines int, showLineNumbers bool) (string, error) { + // Override with environment variable if specified + if envLines := os.Getenv("LSP_CONTEXT_LINES"); envLines != "" { + if val, err := strconv.Atoi(envLines); err == nil && val >= 0 { + contextLines = val + } + } + err := client.OpenFile(ctx, filePath) if err != nil { return "", fmt.Errorf("could not open file: %v", err) @@ -41,70 +49,90 @@ func GetDiagnosticsForFile(ctx context.Context, client *lsp.Client, filePath str return "No diagnostics found for " + filePath, nil } - // Format the diagnostics - var formattedDiagnostics []string + // Format file header + fileInfo := fmt.Sprintf("---\n\n%s\nDiagnostics in File: %d\n", + filePath, + len(diagnostics), + ) + + // Create a summary of all the diagnostics + var diagSummaries []string + var diagLocations []protocol.Location + for _, diag := range diagnostics { severity := getSeverityString(diag.Severity) - location := fmt.Sprintf("Line %d, Column %d", + location := fmt.Sprintf("L%d:C%d", diag.Range.Start.Line+1, diag.Range.Start.Character+1) - // Get the file content for context if needed - var codeContext string - startLine := diag.Range.Start.Line + 1 - if includeContext { - content, loc, err := GetFullDefinition(ctx, client, protocol.Location{ - URI: uri, - Range: diag.Range, - }) - startLine = loc.Range.Start.Line + 1 - if err != nil { - toolsLogger.Error("Failed to get file content: %v", err) - } else { - codeContext = content - } - } else { - // Read just the line with the error - content, err := os.ReadFile(filePath) - if err == nil { - lines := strings.Split(string(content), "\n") - if int(diag.Range.Start.Line) < len(lines) { - codeContext = lines[diag.Range.Start.Line] - } - } - } - - formattedDiag := fmt.Sprintf( - "%s\n[%s] %s\n"+ - "Location: %s\n"+ - "Message: %s\n", - strings.Repeat("=", 3), + summary := fmt.Sprintf("%s at %s: %s", severity, - filePath, location, diag.Message) + // Add source and code if available if diag.Source != "" { - formattedDiag += fmt.Sprintf("Source: %s\n", diag.Source) + summary += fmt.Sprintf(" (Source: %s", diag.Source) + if diag.Code != nil { + summary += fmt.Sprintf(", Code: %v", diag.Code) + } + summary += ")" + } else if diag.Code != nil { + summary += fmt.Sprintf(" (Code: %v)", diag.Code) } - if diag.Code != nil { - formattedDiag += fmt.Sprintf("Code: %v\n", diag.Code) - } + diagSummaries = append(diagSummaries, summary) + + // Create a location for this diagnostic to use with line ranges + diagLocations = append(diagLocations, protocol.Location{ + URI: uri, + Range: diag.Range, + }) + } - formattedDiag += strings.Repeat("=", 3) + // Format content with context + fileContent, err := os.ReadFile(filePath) + if err != nil { + return fileInfo + "\nError reading file: " + err.Error(), nil + } - if codeContext != "" { - if showLineNumbers { - codeContext = addLineNumbers(codeContext, int(startLine)) + lines := strings.Split(string(fileContent), "\n") + + // Collect lines to display + var linesToShow map[int]bool + if contextLines > 0 { + // Use GetLineRangesToDisplay for context + linesToShow, err = GetLineRangesToDisplay(ctx, client, diagLocations, len(lines), contextLines) + if err != nil { + // If error, just show the diagnostic lines + linesToShow = make(map[int]bool) + for _, diag := range diagnostics { + linesToShow[int(diag.Range.Start.Line)] = true } - formattedDiag += fmt.Sprintf("\n%s\n", codeContext) } + } else { + // Just show the diagnostic lines + linesToShow = make(map[int]bool) + for _, diag := range diagnostics { + linesToShow[int(diag.Range.Start.Line)] = true + } + } + + // Convert to line ranges + lineRanges := ConvertLinesToRanges(linesToShow, len(lines)) + + // Format with diagnostics summary in header + result := fileInfo + if len(diagSummaries) > 0 { + result += strings.Join(diagSummaries, "\n") + "\n" + } - formattedDiagnostics = append(formattedDiagnostics, formattedDiag) + // Format the content with ranges + if showLineNumbers { + result += "\n" + FormatLinesWithRanges(lines, lineRanges) } - return strings.Join(formattedDiagnostics, ""), nil + return result, nil } func getSeverityString(severity protocol.DiagnosticSeverity) string { diff --git a/internal/tools/find-references.go b/internal/tools/find-references.go index cbc1f76..2e2bca1 100644 --- a/internal/tools/find-references.go +++ b/internal/tools/find-references.go @@ -139,9 +139,7 @@ func FindReferences(ctx context.Context, client *lsp.Client, symbolName string, } if len(allReferences) == 0 { - banner := "---\n\n" - return fmt.Sprintf("%sNo references found for symbol: %s\n%s", - banner, symbolName, banner), nil + return fmt.Sprintf("No references found for symbol: %s", symbolName), nil } return strings.Join(allReferences, "\n"), nil diff --git a/internal/tools/utilities_test.go b/internal/tools/utilities_test.go index 0e1f565..5b4959f 100644 --- a/internal/tools/utilities_test.go +++ b/internal/tools/utilities_test.go @@ -339,3 +339,118 @@ func TestAddLineNumbers(t *testing.T) { }) } } + +func TestConvertLinesToRanges(t *testing.T) { + testCases := []struct { + name string + linesToShow map[int]bool + totalLines int + expected []LineRange + }{ + { + name: "Empty map", + linesToShow: map[int]bool{}, + totalLines: 10, + expected: nil, // The function returns nil for empty input + }, + { + name: "Single line", + linesToShow: map[int]bool{5: true}, + totalLines: 10, + expected: []LineRange{{Start: 5, End: 5}}, + }, + { + name: "Consecutive lines", + linesToShow: map[int]bool{1: true, 2: true, 3: true}, + totalLines: 10, + expected: []LineRange{{Start: 1, End: 3}}, + }, + { + name: "Non-consecutive lines", + linesToShow: map[int]bool{1: true, 3: true, 5: true}, + totalLines: 10, + expected: []LineRange{{Start: 1, End: 1}, {Start: 3, End: 3}, {Start: 5, End: 5}}, + }, + { + name: "Mixed consecutive and non-consecutive lines", + linesToShow: map[int]bool{1: true, 2: true, 5: true, 6: true, 7: true, 9: true}, + totalLines: 10, + expected: []LineRange{{Start: 1, End: 2}, {Start: 5, End: 7}, {Start: 9, End: 9}}, + }, + { + name: "Lines outside range are filtered", + linesToShow: map[int]bool{-1: true, 0: true, 9: true, 10: true}, + totalLines: 10, + expected: []LineRange{{Start: 0, End: 0}, {Start: 9, End: 9}}, + }, + { + name: "Unsorted input gets sorted", + linesToShow: map[int]bool{5: true, 1: true, 3: true, 2: true}, + totalLines: 10, + expected: []LineRange{{Start: 1, End: 3}, {Start: 5, End: 5}}, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result := ConvertLinesToRanges(tc.linesToShow, tc.totalLines) + assert.Equal(t, tc.expected, result, "Expected ranges to match") + }) + } +} + +func TestFormatLinesWithRanges(t *testing.T) { + testCases := []struct { + name string + lines []string + ranges []LineRange + expected string + }{ + { + name: "Empty ranges", + lines: []string{"line1", "line2", "line3"}, + ranges: []LineRange{}, + expected: "", + }, + { + name: "Single range", + lines: []string{"line1", "line2", "line3", "line4", "line5"}, + ranges: []LineRange{{Start: 1, End: 3}}, + expected: "2|line2\n3|line3\n4|line4\n", + }, + { + name: "Multiple ranges with gap", + lines: []string{"line1", "line2", "line3", "line4", "line5", "line6", "line7"}, + ranges: []LineRange{{Start: 0, End: 1}, {Start: 4, End: 6}}, + expected: "1|line1\n2|line2\n...\n5|line5\n6|line6\n7|line7\n", + }, + { + name: "Adjacent ranges get combined - no gap in output", + lines: []string{"line1", "line2", "line3", "line4", "line5"}, + ranges: []LineRange{{Start: 0, End: 2}, {Start: 3, End: 4}}, + expected: "1|line1\n2|line2\n3|line3\n4|line4\n5|line5\n", + }, + { + name: "Real-world example", + lines: []string{ + "package main", + "", + "import \"fmt\"", + "", + "func main() {", + " s := \"Hello, World!\"", + " fmt.Println(s)", + "}", + }, + ranges: []LineRange{{Start: 4, End: 6}}, + expected: "5|func main() {\n6| s := \"Hello, World!\"\n7| fmt.Println(s)\n", + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result := FormatLinesWithRanges(tc.lines, tc.ranges) + assert.Equal(t, tc.expected, result, "Expected formatted output to match") + }) + } +} diff --git a/tools.go b/tools.go index fa27838..a478ec1 100644 --- a/tools.go +++ b/tools.go @@ -8,49 +8,6 @@ import ( "github.com/mark3labs/mcp-go/mcp" ) -type ReadDefinitionArgs struct { - SymbolName string `json:"symbolName" jsonschema:"required,description=The name of the symbol whose definition you want to find (e.g. 'mypackage.MyFunction', 'MyType.MyMethod')"` - ShowLineNumbers bool `json:"showLineNumbers" jsonschema:"required,default=true,description=Include line numbers in the returned source code"` -} - -type FindReferencesArgs struct { - SymbolName string `json:"symbolName" jsonschema:"required,description=The name of the symbol to search for (e.g. 'mypackage.MyFunction', 'MyType')"` - ShowLineNumbers bool `json:"showLineNumbers" jsonschema:"required,default=true,description=Include line numbers when showing where the symbol is used"` -} - -type ApplyTextEditArgs struct { - FilePath string `json:"filePath"` - Edits []tools.TextEdit `json:"edits"` -} - -type GetDiagnosticsArgs struct { - FilePath string `json:"filePath" jsonschema:"required,description=The path to the file to get diagnostics for"` - IncludeContext bool `json:"includeContext" jsonschema:"default=false,description=Include additional context for each diagnostic. Prefer false."` - ShowLineNumbers bool `json:"showLineNumbers" jsonschema:"required,default=true,description=If true, adds line numbers to the output"` -} - -type GetCodeLensArgs struct { - FilePath string `json:"filePath" jsonschema:"required,description=The path to the file to get code lens information for"` -} - -type ExecuteCodeLensArgs struct { - FilePath string `json:"filePath" jsonschema:"required,description=The path to the file containing the code lens to execute"` - Index int `json:"index" jsonschema:"required,description=The index of the code lens to execute (from get_codelens output), 1 indexed"` -} - -type GetHoverArgs struct { - FilePath string `json:"filePath" jsonschema:"required,description=The path to the file to get hover information for"` - Line int `json:"line" jsonschema:"required,description=The line number where the hover is requested (1-indexed)"` - Column int `json:"column" jsonschema:"required,description=The column number where the hover is requested (1-indexed)"` -} - -type RenameSymbolArgs struct { - FilePath string `json:"filePath" jsonschema:"required,description=The path to the file containing the symbol to rename"` - Line int `json:"line" jsonschema:"required,description=The line number where the symbol is located (1-indexed)"` - Column int `json:"column" jsonschema:"required,description=The column number where the symbol is located (1-indexed)"` - NewName string `json:"newName" jsonschema:"required,description=The new name for the symbol"` -} - func (s *mcpServer) registerTools() error { coreLogger.Debug("Registering MCP tools") @@ -192,8 +149,8 @@ func (s *mcpServer) registerTools() error { mcp.Required(), mcp.Description("The path to the file to get diagnostics for"), ), - mcp.WithBoolean("includeContext", - mcp.Description("Include additional context for each diagnostic. Prefer false."), + mcp.WithBoolean("contextLines", + mcp.Description("Lines to include around each diagnostic."), mcp.DefaultBool(false), ), mcp.WithBoolean("showLineNumbers", @@ -209,9 +166,9 @@ func (s *mcpServer) registerTools() error { return mcp.NewToolResultError("filePath must be a string"), nil } - includeContext := false // default value - if includeContextArg, ok := request.Params.Arguments["includeContext"].(bool); ok { - includeContext = includeContextArg + contextLines := 5 // default value + if contextLinesArg, ok := request.Params.Arguments["contextLines"].(int); ok { + contextLines = contextLinesArg } showLineNumbers := true // default value @@ -220,7 +177,7 @@ func (s *mcpServer) registerTools() error { } coreLogger.Debug("Executing get_diagnostics for file: %s", filePath) - text, err := tools.GetDiagnosticsForFile(s.ctx, s.lspClient, filePath, includeContext, showLineNumbers) + text, err := tools.GetDiagnosticsForFile(s.ctx, s.lspClient, filePath, contextLines, showLineNumbers) if err != nil { coreLogger.Error("Failed to get diagnostics: %v", err) return mcp.NewToolResultError(fmt.Sprintf("failed to get diagnostics: %v", err)), nil