Note: value
must be a concrete, instantiated value with a concrete class,
and cannot be an interface or abstract class.
Note: value
must be a concrete, instantiated value with a concrete class,
and cannot be an interface or abstract class. We make use of line numbers
from the bytecode to decide which source to show, and those only exist
for concrete method implementations
Note: value
must be a concrete, instantiated value with a concrete class,
and cannot be an interface or abstract class.
Note: value
must be a concrete, instantiated value with a concrete class,
and cannot be an interface or abstract class. We make use of line numbers
from the bytecode to decide which source to show, and those only exist
for concrete method implementations
Pull the height from the pretty-printer as a heuristic to shift the desired line towards the middle of the screen.
Pull the height from the pretty-printer as a heuristic to shift the desired line towards the middle of the screen. Typically, the pretty-printer's default height is about half the height of the window, so this centers the target line vertically. There is some random variation due to the way we're getting line numbers from bytecode, so hopefully centering it will help ensure the *actual* desired line is visible even if the line number we're aiming for is inaccurate
A hacky way to try and find a "good" source location for a function, about as good as we can probably get without a huge amount more effort:
A hacky way to try and find a "good" source location for a function, about as good as we can probably get without a huge amount more effort:
- We rely on the bytecode line numbers to locate methods; unfortunately, this only works for concrete, non-abstract methods! But it's the best we're going to get short of parsing all the source code ourselves
- We look at the class that's the "owner" of the Scala symbol at compile time. This is based on the static type of the value; this *may* be an abstract method. If it's concrete, we can use it's bytecode line numbers to find it and we're done
- If it's abstract, we then look at the class that's the java.reflect DeclaringClass of the value's method, at runtime. This may still not find the actual location (if the method comes from a trait, it'll give us the class implementing the trait, rather than the trait itself) but it gives us another chance at finding the concrete implementation.
Again, this means it is important there is a concrete value
that has
the method we're looking for, since we're relying on the bytecode line
numbers to find the method, which only exist in concrete methods.