Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspector: remove redundant Java package prefixes #242

Closed
vemv opened this issue Apr 21, 2024 · 5 comments
Closed

Inspector: remove redundant Java package prefixes #242

vemv opened this issue Apr 21, 2024 · 5 comments
Labels
enhancement Improvement to an existing feature

Comments

@vemv
Copy link
Member

vemv commented Apr 21, 2024

When inspecting classes, often all fields/methods/... are prefixed with the fully-qualified class name.

Example:

Name: com.corp.Dog
Class: java.lang.Class

--- Interfaces:
  java.io.Serializable
  java.lang.Cloneable
  java.lang.Comparable
  org.apache.thrift.TBase

--- Constructors:
  public com.corp.Dog()
  public com.corp.Dog(com.corp.Dog)

--- Fields:
  public boolean com.corp.Dog.isTopStylist
  public static final java.util.Map com.corp.Dog.metaDataMap
  public java.lang.String com.corp.Dog.sub

--- Methods:
  public void com.corp.Dog.clear()
  public int com.corp.Dog.compareTo(java.lang.Object)
  public int com.corp.Dog.compareTo(com.corp.Dog)

This is particularly ugly in com.corp.Dog.isTopStylist - there isn't an actual thing named com.corp.Dog.isTopStylist - it's isTopStylist so removing the prefix would be both more readable and more correct.

There may be cases where there's a legit use case for rendering a prefix - I'm thinking interface implementation or method inheritance.

Even then, I believe the right thing would be to render the short name, and provide any extra info when going down that particular method.

@vemv
Copy link
Member Author

vemv commented Apr 21, 2024

@alexander-yakushev you may want to give this one a shot while you're with other things Inspector

@vemv
Copy link
Member Author

vemv commented May 3, 2024

Semi-related - when inspecting a Method, it can get trimmed

image

(this one is from PersistentVector)

@alexander-yakushev
Copy link
Member

I see what's going on. First, the method gets printed honoring the max-atom-length (which is 150 by default), and truncated above that limit. Then it gets shortened by stripping the package prefixes, so you get a truncated string that is shorter than 150 characters. The behavior hasn't changed from before (apart from shortening).

@alexander-yakushev
Copy link
Member

I don't mind dancing around truncation limits a bit (serialize into a separate printer, shorten, then truncate). But I'm not sure this is needed – method signature that is 100+ characters long is not very useful.

@vemv
Copy link
Member Author

vemv commented May 3, 2024

However it would seem simple enough to disable all trimming for Method/Field/... Values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants