public override ParsedDocument Parse (bool storeAst, string fileName, TextReader content, Project project = null) { ParsedTemplate template = new ParsedTemplate (fileName); try { var tk = new Tokeniser (fileName, content.ReadToEnd ()); template.ParseWithoutIncludes (tk); } catch (ParserException ex) { template.LogError (ex.Message, ex.Location); } T4ParsedDocument doc = new T4ParsedDocument (fileName, template.RawSegments); doc.Flags |= ParsedDocumentFlags.NonSerializable; foreach (System.CodeDom.Compiler.CompilerError err in template.Errors) doc.Errors.Add (new Error (err.IsWarning? ErrorType.Warning : ErrorType.Error, err.ErrorText, err.Line, err.Column)); return doc; }
public override System.Threading.Tasks.Task<ParsedDocument> Parse (ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken) { var fileName = parseOptions.FileName; ParsedTemplate template = new ParsedTemplate (fileName); var readOnlyDoc = TextEditorFactory.CreateNewReadonlyDocument (parseOptions.Content, fileName); try { var tk = new Tokeniser (fileName, readOnlyDoc.Text); template.ParseWithoutIncludes (tk); } catch (ParserException ex) { template.LogError (ex.Message, ex.Location); } var errors = new List<Error> (); foreach (System.CodeDom.Compiler.CompilerError err in template.Errors) { errors.Add (new Error (err.IsWarning ? ErrorType.Warning : ErrorType.Error, err.ErrorText, new DocumentLocation (err.Line, err.Column))); } var doc = new T4ParsedDocument (fileName, template.RawSegments, errors); doc.Flags |= ParsedDocumentFlags.NonSerializable; return System.Threading.Tasks.Task.FromResult((ParsedDocument)doc); }
public override ParsedDocument Parse(ProjectDom dom, string fileName, string content) { ParsedTemplate template = new ParsedTemplate(fileName); try { Tokeniser tk = new Tokeniser(fileName, content); template.ParseWithoutIncludes(tk); } catch (ParserException ex) { template.LogError(ex.Message, ex.Location); } T4ParsedDocument doc = new T4ParsedDocument(fileName, template.RawSegments); doc.Flags |= ParsedDocumentFlags.NonSerializable; foreach (System.CodeDom.Compiler.CompilerError err in template.Errors) { doc.Errors.Add(new Error(err.IsWarning? ErrorType.Warning : ErrorType.Error, err.Line, err.Column, err.ErrorText)); } return(doc); }
public override ParsedDocument Parse(bool storeAst, string fileName, TextReader content, Project project = null) { ParsedTemplate template = new ParsedTemplate(fileName); try { var tk = new Tokeniser(fileName, content.ReadToEnd()); template.ParseWithoutIncludes(tk); } catch (ParserException ex) { template.LogError(ex.Message, ex.Location); } var errors = new List <Error> (); foreach (System.CodeDom.Compiler.CompilerError err in template.Errors) { errors.Add(new Error(err.IsWarning ? ErrorType.Warning : ErrorType.Error, err.ErrorText, err.Line, err.Column)); } var doc = new T4ParsedDocument(fileName, template.RawSegments, errors); doc.Flags |= ParsedDocumentFlags.NonSerializable; return(doc); }
public override System.Threading.Tasks.Task <ParsedDocument> Parse(ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken) { var fileName = parseOptions.FileName; ParsedTemplate template = new ParsedTemplate(fileName); var readOnlyDoc = TextEditorFactory.CreateNewReadonlyDocument(parseOptions.Content, fileName); try { var tk = new Tokeniser(fileName, readOnlyDoc.Text); template.ParseWithoutIncludes(tk); } catch (ParserException ex) { template.LogError(ex.Message, ex.Location); } var errors = new List <Error> (); foreach (System.CodeDom.Compiler.CompilerError err in template.Errors) { errors.Add(new Error(err.IsWarning ? ErrorType.Warning : ErrorType.Error, err.ErrorText, new DocumentLocation(err.Line, err.Column))); } var doc = new T4ParsedDocument(fileName, template.RawSegments, errors); doc.Flags |= ParsedDocumentFlags.NonSerializable; return(System.Threading.Tasks.Task.FromResult((ParsedDocument)doc)); }