%Library.SyntaxColorReader
Class %Library.SyntaxColorReader Extends %RegisteredObject [ System = 4 ]
Front end for reading the CSV output from %SyntaxColor:Color. Instead of reading the stream directly and reconstructing the lines you can use a %SyntaxColorReader object and call its NextLine method.
To create a %SyntaxColorReader object you can pass a CSV stream to %New; alternatively you can call FromCode and it will call %SyntaxColor for you.
Properties
CSV
Property CSV As %RegisteredObject [ Private ];
AtEnd
Property AtEnd As %Boolean [ Calculated, Private ];
BufferedStream
Property BufferedStream As %Boolean [ Private ];
This is here so that we can give better error messages
PositionIsNoted
Property PositionIsNoted As %Boolean [ Private ];
InfoLine
Property InfoLine As %String [ Private ];
Not valid until AtEnd
ErrorInfo
Property ErrorInfo As %Stream.Object [ Private ];
Not valid until AtEnd
RewoundErrorInfo
Property RewoundErrorInfo As %Boolean [ Private ];
Whether or not we've rewound ErrorInfo
Methods
AtEndGet
Method AtEndGet() As %Boolean
The AtEnd property can be used to check for the end of the reader over the CSV stream
FromCode
ClassMethod FromCode(Code As %Stream.Object, Language As %String, ExtraFlags As %String, ByRef Reader As %Library.SyntaxColorReader, ByRef AnyColoringErrors As %Boolean, ByRef AnyColoringWarnings As %Boolean, Symbols As %String = "", BufferStream As %Boolean = 0) As %Status
Given a code stream, language, optional extra flags and/or symbols string for %SyntaxColor:Color
Return a %SyntaxColorReader over the resulting CSV and whether there were any coloring errors/warnings (anywhere in the document)
%OnNew
Method %OnNew(CSV As %Stream.Object, BufferStream As %Boolean = 0) As %Status
Create a %SyntaxColorReader over the given CSV stream
NextLine
Method NextLine(ByRef LineCSV As %List, ByRef ColoringErrors As %Boolean, ByRef ColoringWarnings As %Boolean) As %Boolean
Return a structured list of coloring information about the current line of code represented by the CSV stream, advancing the stream. In general, a number of lines will be read from the CSV stream to make up one logical line corresponding to a line of the original code. CSV lines of the form "\n" determine logical line boundaries.
If the stream is at its end this method returns 0, otherwise 1.
If 1 is returned the ByRef parameters are set up from the stream items which were read :-
- LineCSV is set to a list of items, where each item is $LB(lang,terminal,code)
- ColoringErrors and ColoringWarnings are set to whether there were any coloring errors/warnings at all on the line
SkipLines
Method SkipLines(N As %Integer)
Move forward N lines - stops if end of file found first (doesn't report any error)
Rewind
Method Rewind() As %Status
Move back to the beginning of the stream
- not allowed if the position is noted
NotePosition
Method NotePosition() As %Status
Note the current stream position, caller must call RestorePosition or ForgetPosition later.
RestoreNotedPosition
Method RestoreNotedPosition() As %Status
Restore the noted position
ForgetNotedPosition
Method ForgetNotedPosition() As %Status
Forget the noted position
GetInfoLine
Method GetInfoLine() As %String
Return the info line, if any Not valid until AtEnd
NextErrorInfo
Method NextErrorInfo(Output Description As %String, Output Source As %String, Output Location As %String, Output LineNumber As %Integer, Output LineOffset As %Integer) As %Boolean
Return the next error info Not valid until AtEnd