コード例 #1
0
        public List <CodeFile> GetReferences(FileSearcher fileSearcher)
        {
            var    files   = new List <CodeFile>();
            string content = GetContents();

            var componentRefs = GetComponentReferences(content);

            foreach (var comp in componentRefs)
            {
                string   relativePath = comp.RelativePath.Replace('.', FileSystem.Path.DirectorySeparatorChar) + ".cfc";
                CodeFile foundFile    = fileSearcher.LocateFile(relativePath);
                if (foundFile != null)
                {
                    files.Add(foundFile);
                }
            }

            var includeRefs      = GetIncludedFiles(content);
            var currentDirectory = FileSystem.Path.GetDirectoryName(FileName);

            foreach (var include in includeRefs)
            {
                CodeFile foundFile = null;
                if (FileSystem.Path.IsPathRooted(include.RelativePath))
                {
                    foundFile = fileSearcher.LocateFile(include.RelativePath.Substring(1, include.RelativePath.Length - 1));
                }
                else
                {
                    string path = FileSystem.Path.Combine(currentDirectory, include.RelativePath);
                    if (FileSystem.File.Exists(path))
                    {
                        foundFile = new CodeFile(path, FileSystem);
                    }
                }

                if (foundFile != null)
                {
                    files.Add(foundFile);
                }
            }//foreach included reference

            //Find Application File
            var appFile = fileSearcher.GetApplicationFile(FileName);

            if (appFile != null)
            {
                files.Add(appFile);
            }

            return(files);
        }