CodeCompass icon indicating copy to clipboard operation
CodeCompass copied to clipboard

C++ Reparse: the AST isn't coloured anymore

Open whisperity opened this issue 3 years ago • 4 comments

The current version when generating the AST HTML output does not seem to call the appropriate methods which would result in calls to our ANSI colours -> HTML sequences formatting. It is very likely that during the uplift to LLVM 10.0 (#432) we forgot to add a virtual method's override or something like that.

Screenshot of the broken reparse AST-view. It shows the AST output in one giant default-coloured (black) monospace widget, with the Developer Tools visible underneath showing some HTML sequences like monospace font or explicit newlines.

Oddly enough, some of the logic, such as putting things between ' in the raw output to <tt> still runs, as seen in the picture. The relevant code snippet that seems to get executed properly:

https://github.com/Ericsson/CodeCompass/blob/e39c21346ccdfe8c36e12254c50e4932b2d3b3dd/plugins/cpp_reparse/service/src/asthtml.cpp#L54-L66

whisperity avatar Apr 21 '21 12:04 whisperity

I cannot reproduce this bug in my development environment with LLVM 10. However the bug is still present on https://codecompass.net/demo/ , where it was located initally.

Since codecompass.net uses the modelcpp/codecompass:web-pgsql Docker image we produce, that could be the next target for debugging locally.

mcserep avatar May 08 '21 20:05 mcserep

Okay, at the top of my head, we should check the following, because Clang tries to be too smart about what escape sequences it emits or what sort of callbacks it runs... Most likely it doesn't detect that the shell it is running in would be capable of using colours.

  • The environment variables TERM=xterm-256color and COLORTERM=24bit or COLORTERM=truecolor (or something at least compatible with the effect of these) should be set.
  • In case the Docker image is built on top of Ubuntu, libtinfo5 (and libtinfo-dev) should be installed.
    • According to my investigation, the dependency chain clang-10 -> llvm-10-dev -> libtinfo-dev should already have the latter package installed...

whisperity avatar May 10 '21 10:05 whisperity

The source of the issue indeed seems to be when the docker container is executed in detached mode (-d).

Unfortunately, setting any of the proposed environment variables has no effect.

mcserep avatar May 30 '21 18:05 mcserep

Well, that's sad, but not unexpected... :frowning: I'll try to look into it, mayhaps we can do some clever change to the inheritance we're already doing wrt. the ColorHTMLStream or what its name was...

whisperity avatar May 31 '21 09:05 whisperity