Menu

#2319 Jython completions using Java types

nextrelease
open
nobody
None
5
2023-09-23
2021-03-17
No

I'm always unable to find a place for completions, so I'm starting this new one where Java types should be used for completions where this is possible. For example, I allow for a kludge where you can say a symbol is an instance of something with the Jython code:

from java.awt.image import BufferedImage
from java.awt import Graphics2D
graphs=BufferedImage(100,100,BufferedImage.TYPE_INT_ARGB).getGraphics()

assert isinstance( graphs, Graphics2D )

At this point the completions know that the symbol "graphs" is a Graphics2D. The idea is also that the completions engine could see that BufferedImage's getGraphics command is a Graphics object, and automatically allow completions based on that knowledge.

See also https://sourceforge.net/p/autoplot/bugs/1687/

Discussion

  • Jeremy Faden

    Jeremy Faden - 2021-03-17

    This code shows a bug where completions drops a line:

    from java.awt.image import BufferedImage
    from java.awt import Graphics2D
    graphs=BufferedImage(100,100,BufferedImage.TYPE_INT_ARGB).getGraphics()
    
    assert isinstance( graphs, Graphics2D )
    
    # graphs.<C> bug here, because "from java.awt import Graphics2D" is dropped.
    
     
  • Jeremy Faden

    Jeremy Faden - 2021-03-18

    There's another system in there which assigns name__class to the Java class, but I can't figure out if this ever was finished. I've made it so instead of __class it will use __CLASSTYPE so that it is easier to search for.

     
MongoDB Logo MongoDB