Class CodeHighlightStyleComputer
java.lang.Object
dev.zemco.codegame.presentation.highlighting.CodeHighlightStyleComputer
- All Implemented Interfaces:
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
commentclass - labels are highlighted using the
labelclass - instruction names are highlighted using the
instructionclass - for blank sections no classes are used
CodeProgramCompiler.- Author:
- Erik Zemčík
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCodeHighlightStyleComputer(Set<String> instructionNames) Creates an instance ofCodeHighlightStyleComputerwith specific instruction names to highlight. -
Method Summary
Modifier and TypeMethodDescriptionorg.fxmisc.richtext.model.StyleSpans<Collection<String>>computeHighlightStyles(String text) Computes CSS highlight styles for a given part of the source code.
-
Constructor Details
-
CodeHighlightStyleComputer
Creates an instance ofCodeHighlightStyleComputerwith specific instruction names to highlight.- Parameters:
instructionNames- specific instruction names to highlight- Throws:
IllegalArgumentException- ifinstructionNamesisnull
-
-
Method Details
-
computeHighlightStyles
Description copied from interface:IHighlightStyleComputerComputes 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:
computeHighlightStylesin interfaceIHighlightStyleComputer- Parameters:
text- part of the source code- Returns:
- style class spans
-