Esempio n. 1
0
        TsFileAdditionalInfo ReportDependency(TsFileAdditionalInfo owner, TsFileAdditionalInfo dep)
        {
            if (dep != null)
            {
                owner.ReportDependency(dep.Owner.FullPath);
            }

            return(dep);
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 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)
                {
                    fileInfo.ReportDiag(true, -5, "First parameter of b.asset must be resolved as constant string",
                                        a.StartLine, a.StartCol, a.EndLine,
                                        a.EndCol);
                    return;
                }

                var assetName = a.Name;
                if (assetName.StartsWith("project:"))
                {
                    var(pref, name) = SplitProjectAssetName(assetName);
                    if (pref.Length == 8)
                    {
                        name += "/package.json";
                    }

                    if (!(Owner.DiskCache.TryGetItem(PathUtils.Join(Owner.Owner.FullPath, name)) is
                          IFileCache))
                    {
                        fileInfo.ReportDiag(true, -3, "Missing dependency " + assetName, a.StartLine, a.StartCol,
                                            a.EndLine, a.EndCol);
                    }
                }
                else 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.VdomTranslations != null)
            {
                var trdb = Owner.ProjectOptions.TranslationDb;
                if (trdb != null)
                {
                    sourceInfo.VdomTranslations.ForEach(t =>
                    {
                        if (t.Message == null)
                        {
                            return;
                        }
                        var err = trdb.CheckMessage(t.Message, t.KnownParams);
                        if (err != null)
                        {
                            fileInfo.ReportDiag(false, -7,
                                                "Problem with translation message \"" + t.Message + "\" " + err, t.StartLine,
                                                t.StartCol, t.EndLine, t.EndCol);
                        }
                    });
                }
            }

            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, t.StartLine,
                                                    t.StartCol, t.EndLine, t.EndCol);
                            }
                        }
                    });
                }
            }
        }