public override void InstanceReleased(ViewCompiler compiler, ISparkView view) { if (compiler is PythonViewCompiler && view is IScriptingSparkView) { PythonEngineManager.InstanceReleased( (PythonViewCompiler)compiler, (IScriptingSparkView)view); } else { base.InstanceCreated(compiler, view); } }
public override void InstanceCreated(ViewCompiler compiler, ISparkView view) { if (compiler is RubyViewCompiler && view is IScriptingSparkView) { RubyEngineManager.InstanceCreated( (RubyViewCompiler)compiler, (IScriptingSparkView)view); } else { base.InstanceCreated(compiler, view); } }
private static void DoCompileView(ViewCompiler compiler, IList <Chunk> chunks) { compiler.CompileView(new[] { chunks }, new[] { chunks }); }
public virtual void InstanceReleased(ViewCompiler compiler, ISparkView view) { }
public virtual void InstanceCreated(ViewCompiler compiler, ISparkView view) { }
public static void SetCompiler(ViewCompiler compiler) { Couchbase.Lite.View.compiler = compiler; }
private static void ProcessProject(string projectPath, string projectBasePath, string outputFilePath, bool parseLiquid) { var strings = new LocalizableStringCollection(); var codeMetadataProvider = new CodeMetadataProvider(projectBasePath); var localizedStringsCollector = new CSharpCodeVisitor( new IStringExtractor <SyntaxNode>[] { new SingularStringExtractor(codeMetadataProvider), new PluralStringExtractor(codeMetadataProvider) }, strings); foreach (var file in Directory.EnumerateFiles(projectPath, "*.cs", SearchOption.AllDirectories)) { if (Path.GetFileName(file).EndsWith(".g.cshtml.cs")) { continue; } using (var stream = File.OpenRead(file)) { using (var reader = new StreamReader(stream)) { var syntaxTree = CSharpSyntaxTree.ParseText(reader.ReadToEnd(), path: file); localizedStringsCollector.Visit(syntaxTree.GetRoot()); } } } if (parseLiquid) { var liquidMetadataProvider = new LiquidMetadataProvider(projectBasePath); var liquidVisitor = new LiquidVisitor(new[] { new LiquidStringExtractor(liquidMetadataProvider) }, strings); var liquidParser = _liquidParseFactory.CreateParser(); foreach (var file in Directory.EnumerateFiles(projectPath, "*.liquid", SearchOption.AllDirectories)) { using (var stream = File.OpenRead(file)) { using (var reader = new StreamReader(stream)) { if (liquidParser.TryParse(reader.ReadToEnd(), true, out var ast, out var errors)) { foreach (var statement in ast) { liquidVisitor.Visit(new LiquidStatementContext() { Statement = statement, FilePath = file }); } } } } } } var razorMetadataProvider = new RazorMetadataProvider(projectBasePath); localizedStringsCollector.Extractors = new IStringExtractor <SyntaxNode>[] { new SingularStringExtractor(razorMetadataProvider), new PluralStringExtractor(razorMetadataProvider) }; var compiledViews = ViewCompiler.CompileViews(projectPath); var cs = new CSharpCodeProvider(); foreach (var view in compiledViews) { try { var syntaxTree = CSharpSyntaxTree.ParseText(view.GeneratedCode, path: view.FilePath); localizedStringsCollector.Visit(syntaxTree.GetRoot()); } catch (Exception ex) { Console.WriteLine("Compile fail for: {0}", view.FilePath); } } if (strings.Values.Any()) { var outputDirectory = Path.GetDirectoryName(outputFilePath); Directory.CreateDirectory(outputDirectory); using (var potFile = new PotFile(outputFilePath)) { potFile.WriteRecord(strings.Values); } } Console.WriteLine($"{Path.GetFileName(projectPath)}: Found {strings.Values.Count()} strings."); }