private static FileSystemPath GetRootPath([NotNull] IPathReference pathReference) { var project = pathReference.GetTreeNode().GetPsiModule().ContainingProjectModule as IProject; if (project != null) { return(WebFilesUtil.GetProjectPath(project)); } return(FileSystemPath.Empty); }
public ArrayPathElement(string key) : base(key) { if (key[0] != '[' || key[key.Length - 1] != ']') { throw new SpecException("Invalid ArrayPathElement key:" + key); } ArrayPathType apt; IPathReference r = null; TransposePathElement tpe = null; string aI = ""; if (key.Length == 2) { apt = ArrayPathType.AUTO_EXPAND; _canonicalForm = "[]"; } else { string meat = key.Substring(1, key.Length - 2); char firstChar = meat[0]; if (AmpReference.TOKEN == firstChar) { r = new AmpReference(meat); apt = ArrayPathType.REFERENCE; _canonicalForm = "[" + r.GetCanonicalForm() + "]"; } else if (HashReference.TOKEN == firstChar) { r = new HashReference(meat); apt = ArrayPathType.HASH; _canonicalForm = "[" + r.GetCanonicalForm() + "]"; } else if ('@' == firstChar) { apt = ArrayPathType.TRANSPOSE; tpe = TransposePathElement.Parse(meat); _canonicalForm = "[" + tpe.GetCanonicalForm() + "]"; } else { aI = VerifyStringIsNonNegativeInteger(meat); if (aI != null) { apt = ArrayPathType.EXPLICIT_INDEX; _canonicalForm = "[" + aI + "]"; } else { throw new SpecException("Bad explict array index:" + meat + " from key:" + key); } } } _transposePathElement = tpe; _arrayPathType = apt; _ref = r; _arrayIndex = aI; }
public static ISymbolTable GetReferenceSymbolTable(IPathReference pathReference, bool useReferenceName, bool includeHttpHandlers = true) { var propertiesSearcher = pathReference.GetTreeNode().GetSolution().GetComponent <MSBuildPropertiesCache>(); string productHomeDir = propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(), "ProductHomeDir"); var basePath = new FileSystemPath(productHomeDir); if (basePath.IsEmpty) { return(EmptySymbolTable.INSTANCE); } FolderQualifierInfo folderQualifierInfo = null; IPsiServices psiServices = pathReference.GetTreeNode().GetPsiServices(); var baseProjectFolder = psiServices.Solution.FindProjectItemsByLocation(basePath).FirstOrDefault() as IProjectFolder; if (baseProjectFolder != null) { folderQualifierInfo = new FolderQualifierInfo(baseProjectFolder); } FileSystemPath websiteRoot = GetRootPath(pathReference); IQualifier qualifier = pathReference.GetQualifier(); if (useReferenceName) { PathDeclaredElement target = null; string name = pathReference.GetName(); switch (name) { case PathDeclaredElement.CURRENT_DIR_NAME: target = new PathDeclaredElement(PathDeclaredElement.CURRENT_DIR_NAME, psiServices, basePath); break; case PathDeclaredElement.LEVEL_UP_NAME: target = new PathDeclaredElement(PathDeclaredElement.LEVEL_UP_NAME, psiServices, basePath.Directory); break; case PathDeclaredElement.ROOT_NAME: if (qualifier != null) { goto default; } target = new PathDeclaredElement(PathDeclaredElement.ROOT_NAME, psiServices, websiteRoot); break; default: try { string parserGenOutputBase = propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(), "ParserGenOutputBase"); FileSystemPath path = basePath.Combine(parserGenOutputBase + "\\" + name); target = new PathDeclaredElement(name, psiServices, path); } catch (InvalidPathException) { } catch (ArgumentException) { } break; } var table = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null); if (target != null) { table.AddSymbol(target, EmptySubstitution.INSTANCE, 1); } return(table); } FileSystemPath rootPath = (qualifier == null) ? websiteRoot : FileSystemPath.Empty; ISymbolTable symbolTableByPath = PathReferenceUtil.GetSymbolTableByPath(basePath, psiServices, basePath.Directory, rootPath, true); FileSystemPath basePathBeforeMapping = GetBasePathBeforeMapping(pathReference); if (!basePathBeforeMapping.IsNullOrEmpty()) { IWebProjectPathMapping pathMapping = WebPathMappingManager.GetPathMapping(pathReference); List <FileSystemPath> mappedPaths = pathMapping.GetAllPathPartsIn(basePathBeforeMapping).ToList(); if (mappedPaths.Any()) { var mappedPathsTable = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null); foreach (FileSystemPath mappedPath in mappedPaths) { var declaredElement = new PathDeclaredElement(psiServices, mappedPath); mappedPathsTable.AddSymbol(declaredElement, EmptySubstitution.INSTANCE, 1); } symbolTableByPath = symbolTableByPath.Merge(mappedPathsTable); } } if (!includeHttpHandlers) { return(symbolTableByPath); } var httpHandlersTable = new SymbolTable(psiServices); return(httpHandlersTable.Merge(symbolTableByPath)); }
public static ISymbolTable GetReferenceSymbolTable(IPathReference pathReference, bool useReferenceName, bool includeHttpHandlers = true) { var propertiesSearcher = pathReference.GetTreeNode().GetSolution().GetComponent<MSBuildPropertiesCache>(); string productHomeDir = propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(), "ProductHomeDir"); var basePath = new FileSystemPath(productHomeDir); if (basePath.IsEmpty) { return EmptySymbolTable.INSTANCE; } FolderQualifierInfo folderQualifierInfo = null; IPsiServices psiServices = pathReference.GetTreeNode().GetPsiServices(); var baseProjectFolder = psiServices.Solution.FindProjectItemsByLocation(basePath).FirstOrDefault() as IProjectFolder; if (baseProjectFolder != null) { folderQualifierInfo = new FolderQualifierInfo(baseProjectFolder); } FileSystemPath websiteRoot = GetRootPath(pathReference); IQualifier qualifier = pathReference.GetQualifier(); if (useReferenceName) { PathDeclaredElement target = null; string name = pathReference.GetName(); switch (name) { case PathDeclaredElement.CURRENT_DIR_NAME: target = new PathDeclaredElement(PathDeclaredElement.CURRENT_DIR_NAME, psiServices, basePath); break; case PathDeclaredElement.LEVEL_UP_NAME: target = new PathDeclaredElement(PathDeclaredElement.LEVEL_UP_NAME, psiServices, basePath.Directory); break; case PathDeclaredElement.ROOT_NAME: if (qualifier != null) { goto default; } target = new PathDeclaredElement(PathDeclaredElement.ROOT_NAME, psiServices, websiteRoot); break; default: try { string parserGenOutputBase = propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(), "ParserGenOutputBase"); FileSystemPath path = basePath.Combine(parserGenOutputBase + "\\" + name); target = new PathDeclaredElement(name, psiServices, path); } catch (InvalidPathException) { } catch (ArgumentException) { } break; } var table = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null); if (target != null) { table.AddSymbol(target, EmptySubstitution.INSTANCE, 1); } return table; } FileSystemPath rootPath = (qualifier == null) ? websiteRoot : FileSystemPath.Empty; ISymbolTable symbolTableByPath = PathReferenceUtil.GetSymbolTableByPath(basePath, psiServices, basePath.Directory, rootPath, true); FileSystemPath basePathBeforeMapping = GetBasePathBeforeMapping(pathReference); if (!basePathBeforeMapping.IsNullOrEmpty()) { IWebProjectPathMapping pathMapping = WebPathMappingManager.GetPathMapping(pathReference); List<FileSystemPath> mappedPaths = pathMapping.GetAllPathPartsIn(basePathBeforeMapping).ToList(); if (mappedPaths.Any()) { var mappedPathsTable = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null); foreach (FileSystemPath mappedPath in mappedPaths) { var declaredElement = new PathDeclaredElement(psiServices, mappedPath); mappedPathsTable.AddSymbol(declaredElement, EmptySubstitution.INSTANCE, 1); } symbolTableByPath = symbolTableByPath.Merge(mappedPathsTable); } } if (!includeHttpHandlers) { return symbolTableByPath; } var httpHandlersTable = new SymbolTable(psiServices); return httpHandlersTable.Merge(symbolTableByPath); }