public override ResolveResultWithInfo Resolve(ISymbolTable symbolTable, IAccessContext context)
 {
     return(WebPathReferenceUtil.CheckResolveResult(this, base.Resolve(symbolTable, context)));
 }
Ejemplo n.º 2
0
        private static ISymbolTable GetReferenceSymbolTable(IPsiServices psiServices, [CanBeNull] string area,
                                                            [CanBeNull] string controller, [CanBeNull] string view, MvcKind mvcKind, [CanBeNull] IProject project, Version version)
        {
            if (project == null)
            {
                return(EmptySymbolTable.INSTANCE);
            }
            ISolution solution  = project.GetSolution();
            var       component = solution.GetComponent <MvcCache>();
            IEnumerable <IProject> searcheableProjects = GetSearcheableProjects(project);
            bool hasExtension = false;

            if (view != null)
            {
                if (view.IndexOfAny(FileSystemDefinition.InvalidPathChars) != -1)
                {
                    return(EmptySymbolTable.INSTANCE);
                }
                if (view == "???")
                {
                    return(EmptySymbolTable.INSTANCE);
                }
                hasExtension = Path.HasExtension(view);
            }
            ISymbolTable symbolTable = EmptySymbolTable.INSTANCE;

            foreach (IProject current in searcheableProjects)
            {
                ISymbolTable symbolTable2 = EmptySymbolTable.INSTANCE;
                string       text         = null;
                if (view != null)
                {
                    string text2 = Path.IsPathRooted(view) ? ("~" + view) : view;
                    text = HtmlPathReferenceUtil.ExpandRootName(text2.Replace('/', '\\'), current);
                    if (Path.IsPathRooted(text))
                    {
                        FileSystemPath fileSystemPath = FileSystemPath.Parse(text);
                        if (!fileSystemPath.IsAbsolute)
                        {
                            fileSystemPath = WebPathReferenceUtil.GetRootPath(project).Combine(fileSystemPath);
                        }
                        symbolTable2 = symbolTable2.Merge(new DeclaredElementsSymbolTable <PathDeclaredElement>(psiServices, new[]
                        {
                            new PathDeclaredElement(psiServices, fileSystemPath)
                        }, 0, null));
                    }
                }
                List <string> list = null;
                if (hasExtension)
                {
                    list = component.GetDisplayModes(current).ToList();
                }
                string[] arg_152_0;
                if (!area.IsEmpty())
                {
                    var array = new string[2];
                    array[0]  = area;
                    arg_152_0 = array;
                }
                else
                {
                    arg_152_0 = new[]
                    {
                        area
                    };
                }
                string[] array2 = arg_152_0;
                for (int i = 0; i < array2.Length; i++)
                {
                    string area2 = array2[i];
                    foreach (
                        string current2 in
                        component.GetLocations(current, MvcUtil.GetViewLocationType(mvcKind, area2), true))
                    {
                        using (
                            IEnumerator <Pair <string, string> > enumerator3 =
                                ParseLocationFormatString(current2, mvcKind, controller, area2).GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                Pair <string, string> location        = enumerator3.Current;
                                FileSystemPath        fileSystemPath2 = FileSystemPath.TryParse(location.First);
                                FileSystemPath        location2       = (location.First.LastIndexOf('\\') ==
                                                                         location.First.Length - 1)
                                    ? fileSystemPath2
                                    : fileSystemPath2.Directory;
                                var projectFolder = current.FindProjectItemByLocation(location2) as IProjectFolder;
                                if (projectFolder != null)
                                {
                                    Func <IProjectItem, bool> extensionFilter = item => item.Location.FullPath.EndsWith(location.Second, StringComparison.OrdinalIgnoreCase);
                                    Func <IProjectItem, bool> preFilter       = extensionFilter;
                                    if (view != null)
                                    {
                                        string text3 = Path.IsPathRooted(text)
                                            ? text
                                            : (location.First + text + location.Second);
                                        string extension     = Path.GetExtension(text3);
                                        var    possibleNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
                                        {
                                            text3
                                        };
                                        if (list != null)
                                        {
                                            foreach (string current3 in list)
                                            {
                                                possibleNames.Add(Path.ChangeExtension(text3, current3 + extension));
                                            }
                                        }
                                        preFilter = item => extensionFilter(item) && possibleNames.Contains(item.Location.FullPath);
                                    }
                                    // todo tmp
                                    var referenceContext = new PathReferenceContext(psiServices, projectFolder.Location);
                                    symbolTable2 = symbolTable2.Merge(PathReferenceUtil.GetSymbolTableByPath(referenceContext, false, true, projectItem => GetViewName(projectItem.Location, location), preFilter));
                                }
                            }
                        }
                    }
                }
                symbolTable = symbolTable.Merge(symbolTable2.Filter(new[]
                {
                    FileFilters.FileExists,
                    new FileFilters.ItemInProjectFilter(current)
                }));
            }
            return(symbolTable.Distinct(PathInfoComparer.Instance));
        }