简体   繁体   中英

Pydev No Hover Text for String arguments

I'm building an RCP app that serves as an IDE for a custom domain. One of the things we do in that domain is write python scripts that use domain-specific commands which have been wrapped as python functions. I implemented hover text support integrated with PyDev, so that if there is any domain-specific hover text available, it calls a custom ITextHover instead of PyDev's.

I have this working, but I see that if I have a string literal argument to a function, the getTextHover() method is never called on the IHoverText instance. I traced this behavior to the partitioning implementation provided by getConfiguredDocumentPartitioning in PyEditConfiguration .

Is there a way I can use PyDev's partitioning scheme but somehow override the above behavior, so that getTextHover() is called for String literal arguments? I don't see anything in the preferences, and trying to follow the implementation in the PyDev source code was not successful.

EDIT: overriding TextSourceViewerConfiguration#getConfiguredDocumentPartitioning() to return IPythonPartitions.PY_DEFAULT solves the problem. But I'm not sure what the implications are of returning this rather than IPythonPartitions.PYTHON_PARTITION_TYPE , which is the behavior provided by PyEditCOnfigurationWithoutEditor .

You shouldn't change what you changed...

The proper way would be changing PyDev itself to support your use case.

You should provide your IPyHoverParticipant (instead of doing your own text hover) and create a pull request for PyDev so that the hover works in comments/strings (ie: skip the "if (!pythonCommentOrMultiline) {" in org.python.pydev.editor.hover.PyTextHover.getHoverInfo(ITextViewer, IRegion) if your hover implements IPyHoverParticipant2).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM