public static ISymbolTable GetReferenceSymbolTableByLocation(IPsiServices psiServices, string name, IProject project) { var mvcCache = psiServices.GetComponent <MvcCache>(); var symbolTable = new SymbolTable(psiServices); try { bool hasExtension = Path.HasExtension(name); foreach (string location in mvcCache.GetLocations(project, MvcUtil.GetViewLocationType(MvcKind.View, null))) { string path = string.Format(location, name, null, null); if (hasExtension) { path = Path.ChangeExtension(path, null); } symbolTable.AddSymbol(new PathDeclaredElement(psiServices, FileSystemPath.Parse(path))); } } catch (InvalidPathException) { } return(symbolTable.Distinct(PathInfoComparer.Instance)); }
public override ISymbolTable GetReferenceSymbolTable(bool useReferenceName) { string name = GetName(); IProject project = myOwner.GetProject(); ISymbolTable symbolTable = EmptySymbolTable.INSTANCE; foreach (JetTuple <string, string, MvcUtil.DeterminationKind, ICollection <IClass> > tuple in names) { ISymbolTable symbolTable2; if (tuple.C == MvcUtil.DeterminationKind.ImplicitByContainingMember) { symbolTable2 = (from @class in tuple.D where @class != null && @class.IsValid() select GetReferenceSymbolTable(@class, useReferenceName ? name : null, mvcKind, version, tuple.A)).Merge(); } else { symbolTable2 = GetReferenceSymbolTable(psiServices, tuple.A, tuple.B, useReferenceName ? name : null, mvcKind, project, version); } if (useReferenceName && symbolTable2.GetAllSymbolInfos().IsEmpty() && name.IndexOfAny(FileSystemDefinition.InvalidPathChars) == -1) { var symbolTable3 = new SymbolTable(psiServices); try { bool hasExtension = Path.HasExtension(name); foreach (string location in mvcCache.GetLocations(project, MvcUtil.GetViewLocationType(mvcKind, tuple.A))) { string path = string.Format(location, name, tuple.B, tuple.A); if (hasExtension) { path = Path.ChangeExtension(path, null); } symbolTable3.AddSymbol(new PathDeclaredElement(psiServices, FileSystemPath.Parse(path))); } } catch (InvalidPathException) { } symbolTable2 = symbolTable3; } symbolTable = symbolTable.Merge(symbolTable2); } return(symbolTable.Distinct()); }
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)); }