private void DoScan(ListenerExtender listenerExtender, int startLine, int errorRertyCount) { listenerExtender.LineOffset = startLine; var contentToScan = buffer.GetContentFrom(startLine); try { Lexer lexer = gherkinDialect.NativeLanguageService.lexer(listenerExtender); lexer.scan(contentToScan); } catch (ScanningCancelledException) { throw; } catch (LexingError lexingError) { HandleError(GetLexingError(lexingError, listenerExtender.LineOffset), lexingError, listenerExtender, errorRertyCount); } catch (ScanningErrorException scanningErrorException) { HandleError(scanningErrorException, scanningErrorException, listenerExtender, errorRertyCount); } catch (Exception ex) { HandleError(GetUnknownError(ex), ex, listenerExtender, errorRertyCount); } }
private void DoScan(ListenerExtender listenerExtender, int startLine, int errorRertyCount) { listenerExtender.LineOffset = startLine; var contentToScan = buffer.GetContentFrom(startLine); try { Lexer lexer = languageService.lexer(listenerExtender); lexer.scan(contentToScan, null, 0); } catch (ScanningCancelledException) { throw; } catch (LexingError lexingError) { HandleError(GetLexingError(lexingError, listenerExtender.LineOffset), lexingError, listenerExtender, errorRertyCount); } catch (ScanningErrorException scanningErrorException) { HandleError(scanningErrorException, scanningErrorException, listenerExtender, errorRertyCount); } catch (Exception ex) { HandleError(GetUnknownError(ex), ex, listenerExtender, errorRertyCount); } }
private void HandleError(ScanningErrorException scanningErrorException, Exception originalException, ListenerExtender listenerExtender, int errorRertyCount) { RegisterError(listenerExtender.GherkinListener, scanningErrorException, originalException); var position = scanningErrorException.GetPosition(buffer); // if (position != null && // position.Line + SKIP_LINES_BEFORE_RETRY <= buffer.LineCount - 1 && // errorRertyCount < MAX_ERROR_RETRY) var lastProcessedEditorLine = listenerExtender.LastProcessedEditorLine; if (position != null) lastProcessedEditorLine = Math.Max(position.Line, lastProcessedEditorLine); if (lastProcessedEditorLine + SKIP_LINES_BEFORE_RETRY <= buffer.LineCount - 1 && errorRertyCount < MAX_ERROR_RETRY) { var restartLineNumber = lastProcessedEditorLine + SKIP_LINES_BEFORE_RETRY; DoScan( listenerExtender, restartLineNumber, errorRertyCount + 1); } }
private void HandleError(ScanningErrorException scanningErrorException, Exception originalException, ListenerExtender listenerExtender, int errorRertyCount) { RegisterError(listenerExtender.GherkinListener, scanningErrorException, originalException); var position = scanningErrorException.GetPosition(buffer); // if (position != null && // position.Line + SKIP_LINES_BEFORE_RETRY <= buffer.LineCount - 1 && // errorRertyCount < MAX_ERROR_RETRY) var lastProcessedEditorLine = listenerExtender.LastProcessedEditorLine; if (position != null) { lastProcessedEditorLine = Math.Max(position.Line, lastProcessedEditorLine); } if (lastProcessedEditorLine + SKIP_LINES_BEFORE_RETRY <= buffer.LineCount - 1 && errorRertyCount < MAX_ERROR_RETRY) { var restartLineNumber = lastProcessedEditorLine + SKIP_LINES_BEFORE_RETRY; DoScan( listenerExtender, restartLineNumber, errorRertyCount + 1); } }
public void Scan(IGherkinListener listener) { ListenerExtender listenerExtender = new ListenerExtender(gherkinDialect, listener, buffer); DoScan(listenerExtender, buffer.LineOffset, 0); }
public void Scan(IGherkinListener listener) { ListenerExtender listenerExtender = new ListenerExtender(languageService, listener, buffer); DoScan(listenerExtender, buffer.LineOffset, 0); }
public void Scan(IGherkinListener listener) { ListenerExtender listenerExtender = new ListenerExtender(gherkinDialect, listener, buffer); DoScan(listenerExtender, buffer.LineOffset, 0); }