clojure-emacs / orchard

A fertile ground for Clojure tooling
Eclipse Public License 1.0
323 stars 54 forks source link

Inspector: remove redundant Java package prefixes #242

Closed vemv closed 2 months ago

vemv commented 2 months ago

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 commented 2 months ago

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

vemv commented 2 months ago

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

image

(this one is from PersistentVector)

alexander-yakushev commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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