internal void ApplyReferenceProcessor(ReferenceProcessorBase refProcessor = null) { if (refProcessor == null) { return; } var references = References.References; references = refProcessor.FilterReferences(references, this); if (references == null) { references = new RtReference[0]; } _refinedReferences = references; var imports = References.Imports; imports = refProcessor.FilterImports(imports, this); if (imports == null) { imports = new RtImport[0]; } _refinedImports = imports; }
/// <summary> /// Ensures that reference for specified type presents in specified file /// </summary> /// <param name="t">Type to reference</param> /// <returns>Reference AST node or null if no reference needed. Returns existing reference in case if type is already referenced</returns> internal void EnsureReference(Type t) { if (TypesToExport.Contains(t)) { return; } var bp = _context.Project.Blueprint(t); if (bp.ThirdParty != null) { foreach (var tpi in bp.ThirdPartyReferences) { References.AddReference(tpi); } return; } if (AllTypesIsSingleFile) { return; } var relPath = GetRelativePathForType(t, FileName); var result = new RtReference() { Path = relPath }; References.AddReference(result); }
protected virtual void ExportCore(StreamWriter tw, ExportedFile file, ReferenceProcessorBase refProcessor = null) { var visitor = Context.Global.ExportPureTypings ? new TypingsExportVisitor(tw, Context.Global.TabSymbol, Context.Global.ReorderMembers) : new TypeScriptExportVisitor(tw, Context.Global.TabSymbol, Context.Global.ReorderMembers); WriteWarning(tw); var references = file.References.References; if (refProcessor != null) { references = refProcessor.FilterReferences(references, file); if (references == null) { references = new RtReference[0]; } } bool hasReferences = false; foreach (var rtReference in references) { visitor.Visit(rtReference); hasReferences = true; } var imports = file.References.Imports; if (refProcessor != null) { imports = refProcessor.FilterImports(imports, file); if (imports == null) { imports = new RtImport[0]; } } bool hasImports = false; foreach (var rtImport in imports) { visitor.Visit(rtImport); hasImports = true; } if (hasReferences || hasImports) { tw.WriteLine(); } foreach (var fileNamespace in file.Namespaces) { visitor.Visit(fileNamespace); } }
internal RtReference ToReference() { if (_reference == null) { _reference = new RtReference() { Path = RawPath } } ; return(_reference); } }
/// <summary> /// Ensures that reference for specified type presents in specified file /// </summary> /// <param name="t">Type to reference</param> /// <param name="file">Exported file</param> /// <returns>Reference AST node or null if no reference needed. Returns existing reference in case if type is already referenced</returns> public RtReference EnsureReference(Type t, ExportedFile file) { if (file.TypesToExport.Contains(t)) { return(null); } if (file.AllTypesIsSingleFile) { return(null); } var relPath = GetRelativePathForType(t, file.FileName); var result = new RtReference() { Path = relPath }; file.References.AddReference(result); return(result); }
/// <summary> /// Attaches new reference to existing ones /// </summary> /// <param name="reference">New reference</param> public void AddReference(RtReference reference) { _references.AddIfNotExists(reference); }
public abstract void Visit(RtReference node);
public override void Visit(RtReference node) { }
public abstract T Visit(RtReference node);
public override void Visit(RtReference node) { WriteLine(string.Format("///<reference path=\"{0}\"/>", node.Path)); }