public AnalysisResult Analyse(char currentCharacter, char?previousCharacter) { if (currentCharacter == '{') { return(AnalysisResult.NoInsertion(new DeclarationHeaderAnalyser())); } return(AnalysisResult.NoInsertion(this)); }
public AnalysisResult Analyse(char currentCharacter, char?previousCharacter) { // If there is no more content to process then this must be a marker insertion point since we're in a declaration header (2017-06-09 DWR: The first content // may be a @font-face declaration so check _declarationHeaderTerminators_NonMarkerInserting first since we're not ALWAYS going to want a marker here) if (previousCharacter == null) { if (_declarationHeaderTerminators_NonMarkerInserting.Contains(currentCharacter)) { return(AnalysisResult.NoInsertion(new StandardContentAnalyser())); } return(AnalysisResult.InsertBeforeCurrentCharacter(_declarationHeaderLineNumberOffset, new StandardContentAnalyser())); } if (_declarationHeaderTerminators_MarkerInserting.Contains(currentCharacter)) { // This terminator indicate the end of the header and suggests a return back to standard content (ie. not a header / css selector) return(AnalysisResult.InsertAfterCurrentCharacter(_declarationHeaderLineNumberOffset, new StandardContentAnalyser())); } else if (_declarationHeaderTerminators_NonMarkerInserting.Contains(currentCharacter)) { // This terminator indicates that we weren't in a css selector at all (so no marker will be generated) return(AnalysisResult.NoInsertion(new StandardContentAnalyser())); } else if (_declarationHeaderTerminators_Reset.Contains(currentCharacter)) { // If we hit a reset terminator then the current content (if any) should result in a marker being generated, as may the following content (eg. this // marker could be for a selector nested inside another) return(AnalysisResult.InsertAfterCurrentCharacter(_declarationHeaderLineNumberOffset, new DeclarationHeaderAnalyser())); } // If we've encountered a line break then we'll need to add one the marker line number offset - if there's loads of new lines between a declaration header // and the preceding content, the line number indicated in the marker should point to a line that includes part of the declaration header rather than // being the end of the new line / whitespace content from the content before it. This offset is only incremented if some non-whitespace content has // been encountered in the declaration header, so we indicate a class name rather than open bracket (when they're not on the same line), for example if ((currentCharacter == '\n') && _encounteredNonWhiteSpaceDeclarationContent) { return(AnalysisResult.NoInsertion(new DeclarationHeaderAnalyser(_declarationHeaderLineNumberOffset + 1, true))); } return(AnalysisResult.NoInsertion( new DeclarationHeaderAnalyser( _declarationHeaderLineNumberOffset, _encounteredNonWhiteSpaceDeclarationContent || !char.IsWhiteSpace(currentCharacter) ) )); }