Class CodeHighlightStyleComputer

java.lang.Object
dev.zemco.codegame.presentation.highlighting.CodeHighlightStyleComputer
All Implemented Interfaces:
IHighlightStyleComputer

public class CodeHighlightStyleComputer extends Object implements IHighlightStyleComputer
Implementation of a compiler, which computes CSS highlight styles for individual parts of a source code using the CodeGame syntax. Each source code part is treated as an instruction line. Highlighted instructions are specified during the construction of the computer, and are unmodifiable.

In CodeGame syntax:

  • comments are highlighted using the comment class
  • labels are highlighted using the label class
  • instruction names are highlighted using the instruction class
  • for blank sections no classes are used
For more information about the used syntax see CodeProgramCompiler.
Author:
Erik Zemčík
See Also:
  • Constructor Details

    • CodeHighlightStyleComputer

      public CodeHighlightStyleComputer(Set<String> instructionNames)
      Creates an instance of CodeHighlightStyleComputer with specific instruction names to highlight.
      Parameters:
      instructionNames - specific instruction names to highlight
      Throws:
      IllegalArgumentException - if instructionNames is null
  • Method Details

    • computeHighlightStyles

      public org.fxmisc.richtext.model.StyleSpans<Collection<String>> computeHighlightStyles(String text)
      Description copied from interface: IHighlightStyleComputer
      Computes CSS highlight styles for a given part of the source code. These styles are divided into spans, where each span contains styles for the given subpart of the source code.
      Specified by:
      computeHighlightStyles in interface IHighlightStyleComputer
      Parameters:
      text - part of the source code
      Returns:
      style class spans