Example #1
0
 TSFileAdditionalInfo ReportDependency(TSFileAdditionalInfo owner, TSFileAdditionalInfo dep)
 {
     if (dep != null)
     {
         owner.ReportDependency(dep.Owner.FullPath);
     }
     return(dep);
 }
Example #2
0
 void ReportDependenciesFromCss(TSFileAdditionalInfo info)
 {
     if (info.TranspilationDependencies != null)
     {
         foreach (var dep in info.TranspilationDependencies)
         {
             var fullJustName       = PathUtils.Join(info.Owner.Parent.FullPath, dep.Import);
             var fileAdditionalInfo =
                 AutodetectAndAddDependency(fullJustName);
             if (fileAdditionalInfo == null)
             {
                 info.ReportDiag(true, -3, "Missing dependency " + dep.Import, 0, 0, 0, 0);
             }
             info.ReportDependency(fullJustName);
         }
     }
 }
Example #3
0
        public void AddDependenciesFromSourceInfo(TSFileAdditionalInfo fileInfo)
        {
            var sourceInfo = fileInfo.SourceInfo;

            if (sourceInfo == null)
            {
                return;
            }
            sourceInfo.Imports?.ForEach(i =>
            {
                var resolved = ResolveImport(fileInfo.Owner.FullPath, i.Name);
                if (resolved != null && resolved != "?")
                {
                    fileInfo.ReportDependency(resolved);
                }
                else
                {
                    fileInfo.ReportDiag(true, -3, "Missing import " + i.Name, i.StartLine, i.StartCol, i.EndLine, i.EndCol);
                }
            });
            sourceInfo.Assets?.ForEach(a =>
            {
                if (a.Name == null)
                {
                    return;
                }
                var assetName = a.Name;
                if (assetName.StartsWith("resource:"))
                {
                    assetName = assetName.Substring(9);
                    if (ReportDependency(fileInfo, AutodetectAndAddDependency(assetName, true)) == null)
                    {
                        fileInfo.ReportDiag(true, -3, "Missing dependency " + assetName, a.StartLine, a.StartCol, a.EndLine, a.EndCol);
                    }
                }
                else
                {
                    if (ReportDependency(fileInfo, AutodetectAndAddDependency(assetName)) == null)
                    {
                        fileInfo.ReportDiag(true, -3, "Missing dependency " + assetName, a.StartLine, a.StartCol, a.EndLine, a.EndCol);
                    }
                }
            });
            if (sourceInfo.Sprites != null)
            {
                if (Owner.ProjectOptions.SpriteGeneration)
                {
                    var spriteHolder = Owner.ProjectOptions.SpriteGenerator;
                    spriteHolder.Process(sourceInfo.Sprites);
                }
                else
                {
                    sourceInfo.Sprites.ForEach(s =>
                    {
                        if (s.Name == null)
                        {
                            return;
                        }
                        var assetName = s.Name;
                        if (ReportDependency(fileInfo, AutodetectAndAddDependency(assetName)) == null)
                        {
                            fileInfo.ReportDiag(true, -3, "Missing dependency " + assetName, s.NameStartLine, s.NameStartCol, s.NameEndLine, s.NameEndCol);
                        }
                    });
                }
            }
            if (sourceInfo.Translations != null)
            {
                var trdb = Owner.ProjectOptions.TranslationDb;
                if (trdb != null)
                {
                    sourceInfo.Translations.ForEach(t =>
                    {
                        if (t.Message == null)
                        {
                            return;
                        }
                        if (t.WithParams)
                        {
                            var err = trdb.CheckMessage(t.Message, t.KnownParams);
                            if (err != null)
                            {
                                fileInfo.ReportDiag(false, -7,
                                                    "Problem with translation message \"" + t.Message + "\" " + err.ToString(), t.StartLine, t.StartCol, t.EndLine, t.EndCol);
                            }
                        }
                    });
                }
            }
        }