How to achieve inline values similar to debugger?

Answered

Hi All,

I'm trying to display text inline within the editor in a similar fashion to how the debugger displays inline values.

If anyone could help me achieve the desired effect it would be much appreciated!

3 comments
Comment actions Permalink

Here is what I found based on code in intellij-community:

import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.vladsch.idea.multimarkdown.highlighter.MultiMarkdownHighlighterColors;

public class MarkdownEditorLinePainter extends EditorLinePainter {
    @Override
    public Collection<LineExtensionInfo> getLineExtensions(@NotNull final Project project, @NotNull final VirtualFile file, final int lineNumber) {
        final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
        TextAttributes attributes = scheme.getAttributes(MultiMarkdownHighlighterColors.COMMENT_ATTR_KEY);
        return Collections.singletonList( new LineExtensionInfo(" { #%s }"), attributes);
    }
}

Need to register the extension in plugin.xml

<editor.linePainter implementation="com.vladsch.idea.multimarkdown.language.linepainter.MarkdownEditorLinePainter" />
0
Comment actions Permalink

Couldnt manage to invoke this successfully.. Could you provide some example of invocation 

0
Comment actions Permalink

This class is invoked by the IDE and in the getLineExtensions you add your extensions based on file and line number requested.

The sample I provided has all the logic for figuring out what to add removed because it is specific to my plugin and would confuse the issue. As is it should add the string to all lines, although I did not test it in a plugin.

Is your implementation not being invoked by the IDE? 

I forgot to wrap the line in extensions tag since this is SOP:

<extensions defaultExtensionNs="com.intellij">
<editor.linePainter
implementation="com.vladsch.idea.multimarkdown.language.linepainter.MarkdownEditorLinePainter" />
</extensions>

 

 

 

0

Please sign in to leave a comment.